Post

Replies

Boosts

Views

Activity

Reply to Animation for DisclosureGroup open/close
I can confirm that @lcurry's solution work. Also, I put the onTapGesture on the DisclosureGroup, not on the Text label. swift @State var isGuestsExpanded: Bool = true var body: some View { List() { DisclosureGroup(isExpanded: $isGuestsExpanded, content: { ForEach( model.guests ) { guest in GuestView(guest: guest, selectedGuests: $selectedGuests) } }, label: { Text("Guests") }.onTapGesture { withAnimation { isGuestsExpanded.toggle() } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Opening a SwiftUI app window to a particular place via intent?
Just did that for my own app, which had a pre-existing setup that made it easy. Essentially, it's this @main struct MyApp: App { @StateObject private var appStateRegistry = AppStateRegistry.shared var body: some Scene {         WindowGroup { MainView() .environmentObject(appStateRegistry)                 .environmentObject(appStateRegistry.tabStateHandler) } } } // See https://www.fivestars.blog/articles/app-state/ for why we need both AppStateRegistry and TabStateHandler class AppStateRegistry: ObservableObject {     static let shared = AppStateRegistry()     var tabStateHandler = TabStateHandler() } public enum MainTab: String {     case tab1, tab2, tab3 } class TabStateHandler: ObservableObject {     @Published var selection: MainTab = .tab1 } struct MainView: View { @EnvironmentObject var tabStateHandler: TabStateHandler var body: some View {         TabView(selection: $tabStateHandler.selection) {…} } } And now in your AppIntent all you need to do is // It's not the same enum since you could have more (or less) options here public enum ShortcutableView: String, AppEnum {     case tab1, tab2 } struct OpenViewIntent: AppIntent {     static var openAppWhenRun: Bool = true // Make sure you have this     @Parameter(title: "View")     var view: ShortcutableView     @MainActor     func perform() async throws -> some IntentResult {         switch view {         case .tab1:             AppStateRegistry.shared.tabStateHandler.selection = .tab1         case .tab2:             AppStateRegistry.shared.tabStateHandler.selection = .tab2         }         return .result()     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to Primary Language of Keyboard-Extension
If you don't want it to display anything, see if you can use "mis" which is the tag for "Uncoded languages". You can find that code listed here: https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry, and it's considered a valid BCP47 value by Apple.
Topic: UI Frameworks SubTopic: UIKit Tags:
Nov ’23
Reply to Animation for DisclosureGroup open/close
I can confirm that @lcurry's solution work. Also, I put the onTapGesture on the DisclosureGroup, not on the Text label. swift @State var isGuestsExpanded: Bool = true var body: some View { List() { DisclosureGroup(isExpanded: $isGuestsExpanded, content: { ForEach( model.guests ) { guest in GuestView(guest: guest, selectedGuests: $selectedGuests) } }, label: { Text("Guests") }.onTapGesture { withAnimation { isGuestsExpanded.toggle() } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’21
Reply to Opening a SwiftUI app window to a particular place via intent?
Just did that for my own app, which had a pre-existing setup that made it easy. Essentially, it's this @main struct MyApp: App { @StateObject private var appStateRegistry = AppStateRegistry.shared var body: some Scene {         WindowGroup { MainView() .environmentObject(appStateRegistry)                 .environmentObject(appStateRegistry.tabStateHandler) } } } // See https://www.fivestars.blog/articles/app-state/ for why we need both AppStateRegistry and TabStateHandler class AppStateRegistry: ObservableObject {     static let shared = AppStateRegistry()     var tabStateHandler = TabStateHandler() } public enum MainTab: String {     case tab1, tab2, tab3 } class TabStateHandler: ObservableObject {     @Published var selection: MainTab = .tab1 } struct MainView: View { @EnvironmentObject var tabStateHandler: TabStateHandler var body: some View {         TabView(selection: $tabStateHandler.selection) {…} } } And now in your AppIntent all you need to do is // It's not the same enum since you could have more (or less) options here public enum ShortcutableView: String, AppEnum {     case tab1, tab2 } struct OpenViewIntent: AppIntent {     static var openAppWhenRun: Bool = true // Make sure you have this     @Parameter(title: "View")     var view: ShortcutableView     @MainActor     func perform() async throws -> some IntentResult {         switch view {         case .tab1:             AppStateRegistry.shared.tabStateHandler.selection = .tab1         case .tab2:             AppStateRegistry.shared.tabStateHandler.selection = .tab2         }         return .result()     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’22
Reply to Autoscaling PDF Images on watchOS
I guess you need to because that solved my issue: it would scale on iOS but not for watchOS widgets. Thanks!
Replies
Boosts
Views
Activity
Sep ’22
Reply to Xcode 14 beta 3: Widget archival failed due to image being too large
If you're using vector files (PDF, SVG), you don't need to resize your images. Head to the image's attributes inspector and check "Preserve vector data" in front of Resizing.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to Adding watchOS complications in Xcode 14 results in CoreData API Misuse error
Did you find a solution to this?
Replies
Boosts
Views
Activity
Nov ’22
Reply to Primary Language of Keyboard-Extension
If you don't want it to display anything, see if you can use "mis" which is the tag for "Uncoded languages". You can find that code listed here: https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry, and it's considered a valid BCP47 value by Apple.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Nov ’23
Reply to ModelContainer causes errors depending on the order in which configurations are supplied
This is related to https://developer.apple.com/forums/thread/735268. You should see that only the first configuration is taken into account, which means that trying to Query Type.A will crash if you reverse the order, so it's not really a solution 🫤
Replies
Boosts
Views
Activity
Nov ’23
Reply to Running com.apple.springboard for WidgetKit Error
I ran into this issue because I added my Widget extension as multiplatform, when I should have added 2 extensions: one for iOS, one for macOS. Just edit the Build Settings and remove macOS or iOS from the "Base SDK" and "Supported Platforms", then create another extension for the other SDK/platform.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Mar ’24
Reply to Xcode 15 beta 7 Previews building issue
In my case, this was an issue with the latest version of Sentry (https://github.com/getsentry/sentry-cocoa/issues/3809).
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’24