Post

Replies

Boosts

Views

Activity

Refresh @CommandsBuilder to update menu bar items
I'm trying to update the menu items in the main menu for a SwiftUI macOS app (not Catalyst). I haven't been able to find any way to do it. The menu items are always as they are when first loaded. :( Is there a way to "validate" commands in SwiftUI? Examples for why you change menu items: "show" or "hide" title change, disabled item, or toggle state. CommandGroup(replacing: CommandGroupPlacement.toolbar) { Button(action: { NotificationCenter.default.post(name: .SortByName, object: nil) }) { Text(NSLocalizedString("Sort by \(sortType.rawValue)", comment: "key command for sorting all dates by name"))} .keyboardShortcut("1", modifiers: .command) .disabled(sortType == .name) The ".disabled" modifier needs to update in this example.
3
0
1.5k
Nov ’20
SwiftUI App WindowGroup options for Catalyst?
Can a Catalyst app built with SwiftUI App have a hidden titlebar, or other window titlebar options? Ie. an iOS app running on macOS built using the App protocol without this error: ERROR: 'HiddenTitleBarWindowStyle' is unavailable in iOS @main struct MyApp: App { var body: some Scene { WindowGroup { ContentView() } .windowToolbarStyle(HiddenTitleBarWindowStyle()) } I tried lots of work arounds including trying to use @UIApplicationDelegateAdaptor to get the windowScene (fails) windowScene.titlebar?.titleVisibility = .hidden Anyone have suggestions or workarounds?
0
1
984
Oct ’20
Allow Catalyst UIWindow resizable to smaller than default
How can I allow the window of my catalyst app to be resizable below 670 x 481? (The default min size is 770 x 797.)By setting either of the following, the window it still limited to 670x481.window?.canResizeToFitContent = truewindow?.windowScene?.sizeRestrictions?.minimumSize = CGSize(width: 100, height: 200)If I set a sizeRestrictions?.maximumSize the behavior is even stranger -- it will be smaller, but also resizes right off the screen!I note that the new Twitter catalyst app allows it's main window to resize smaller (400 x 425).Please help! 🙂
2
0
1.9k
Oct ’19