How to manage work
Issue #619
Discover all the tech
Issue #618
Create custom Binding
List {
ForEach(self.items) { (item: item) in
ItemRowView(item: item)
.popover(isPresented: self.makeIsPresented(item: item)) {
ItemDetailView(item: item)
}
}
} …Issue #617
On macOS 11, we can use .help modifier to add tooltip
Button()
.help("Click here to open settings")
If you support macOS 10.15, then create empty NSView and use as overlay. Need to updateNSView in case we toggle the state of …
Issue #615
List {
ForEach(books) { (book: Book) in
BookRow(book: book)
}
}
.listStyle(SidebarListStyle())
Issue #614
struct MyTabView: View {
@EnvironmentObject
var preferenceManager: PreferenceManager
var body: some View {
VOrH(isVertical: preferenceManager.preference.position.isVertical) {
OneTabView(image: …Issue #613
struct VOrH<Content>: View where Content: View {
let isVertical: Bool
let content: () -> Content
init(isVertical: Bool, @ViewBuilder content: @escaping () -> Content) {
self.isVertical = isVertical …Issue #612
Use runModal
This method runs a modal event loop for the specified window synchronously. It displays the specified window, makes it key, starts the run loop, and processes events for that window. (You do not need to show the window …
Issue #611
enum WindowPosition: String, CaseIterable {
case left
case top
case bottom
case right
}
Picker(selection: $preference.position, label: Text("Position")) {
ForEach(WindowPosition.allCases, id: \.self) { …Issue #610
Set NSVisualEffectView as contentView of NSWindow, and our main view as subview of it. Remember to set frame or autoresizing mask as non-direct content view does not get full size as the window
let mainView = MainView()
.environment(\. …Issue #609
Use animator proxy and animate parameter
var rect = window.frame
rect.frame.origin.x = 1000
NSAnimationContext.runAnimationGroup({ context in
context.timingFunction = CAMediaTimingFunction(name: .easeIn)
window.animator().setFrame( …Issue #608
An NSRunningApplication instance for the current application.
NSRunningApplication.current
The running app instance for the app that receives key events.
NSWorkspace.shared.frontmostApplication
Issue #607
Implement Equatable and Comparable and use round
struct RGBA: Equatable, Comparable {
let red: CGFloat
let green: CGFloat
let blue: CGFloat
let alpha: CGFloat
init(_ red: CGFloat, _ green: CGFloat, _ blue: CGFloat, _ …Issue #606
Use ObjectIdentifier
A unique identifier for a class instance or metatype.
final class Worker: Hashable {
static func == (lhs: Worker, rhs: Worker) -> Bool {
return ObjectIdentifier(lhs) == ObjectIdentifier(rhs)
} …Issue #605
I use custom TextView in a master detail application.
import SwiftUI
struct TextView: NSViewRepresentable {
@Binding var text: String
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
func makeNSView …Issue #604
I see that the modifier needs to do something on the content, otherwise it is not getting called! This logs on the modifier, when the View is created. A View won’t be recreated unless necessary
struct LogModifier: ViewModifier { …Issue #603
Need to set correct frame for mask layer or UILabel, as it is relative to the coordinate of the view to be masked
let aView = UIView(frame: .init(x: 100, y: 110, width: 200, height: 100))
let textLayer = CATextLayer()
textLayer. …Issue #602
ForEach(store.blogs.enumerated().map({ $0 }), id: \.element.id) { index, blog in
}
```
##
Issue #601
On Xcode 11, applicationWillTerminate is not called because of default automatic termination on in Info.plist. Removing NSSupportsSuddenTermination to trigger will terminate notification
func applicationWillTerminate(_ notification: …Issue #600
Use same CACurrentMediaTime
final class AnimationSyncer {
static let now = CACurrentMediaTime()
func makeAnimation() -> CABasicAnimation {
let animation = CABasicAnimation(keyPath: "opacity")
animation. …Issue #599
Specify tag
enum Authentication: Int, Codable {
case key
case certificate
}
TabView(selection: $authentication) {
KeyAuthenticationView()
.tabItem {
Text("🔑 Key")
}
.tag( …I’m a thinker and storyteller with a passion for exploring the intersection of creativity and technology
🧑💻 I love crafting high quality and useful apps
🔥 I love open source. My GitHub open source has 2.3k followers with packages that are integrated by 45k+ apps and over 3.4m+ downloads on CocoaPods.
✍️ I write here on my blog and on Medium, which has over 2.7k+ followers with tons of articles and 90k+ monthly views.
🖥 Follow me for sharings about Swift, SwiftUI, iOS and macOS development.