Post

Replies

Boosts

Views

Activity

Reply to Alerts and Action Sheets not using SwiftUI accent color
It looks like the issue is with UIColor.tintColor. A color value that resolves at runtime based on the current tint color of the app or trait hierarchy. When adding this line of code: UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = .tintColor the same buggy behaviour occurs, but setting it to any other colour makes it work fine. Apple's implementation must use UIColor.tintColor which is why alert buttons' colours are "broken".
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to Space when combining Lists
This is a common problem people have. It’s probably because you have a NavigationView nested inside another one. Remove the NavigationView from the detail view (Espacios Protegidos) so that you only have one at the top of the view hierarchy. If this doesn’t work or you only have one NavigationView, you will need to show some actual code so that the issue can be identified.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to Why does Xcode warn for using ViewBuilder with a return statement?
The implementation of ViewBuilder relies on the @resultBuilder attribute. These articles provide a good overview of result builders: https://www.hackingwithswift.com/swift/5.4/result-builders https://www.avanderlee.com/swift/result-builders This is why you can't explicitly return a value. Something like this will work: @ViewBuilder var osText: some View {     #if os(iOS)     let os = "iOS"     #elseif os(macOS)     let os = "macOS"     #endif     let str = "You are on \(os)"     Text(str) } Adding the return keyword results in this warning: Application of result builder 'ViewBuilder' disabled by explicit 'return' statement This means that the @ViewBuilder won't do anything. You need to remove return to restore the desired behaviour. ‎ If I apply either of the fixes it suggests, it breaks my code with errors so it can't compile. This must be to do with the code you are running beforehand, as in my example performing either of the fixes complies cleanly. Can you show this code you are running? Note: The body property of View is already marked with @ViewBuilder so there is no need to add it yourself.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to How do I copy a variable in Swift/SwiftUi
I am assuming this is where the problem lies: hoursLogged = hoursGoal minutesLogged = minutesGoal You shouldn't modify @State variables inside a view's body property or content closure. Do this in an onAppear(_:) modifier or similar. That's what might be causing the issue. Also, you haven't shown enough code to understand how things are connected. Where is the "next page" Section located? Is it in ContentView?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to NavigationSplitView two and three column interfaces in the same app
From the way Apple made the NavigationSplitView API, it is clear that having two and three column layouts shouldn't happen or should be avoided. Nevertheless, you can still achieve this through the use of two split views wrapped in a condition. Something like this, which I have tested, will work: struct ContentView: View {     @State private var selectedInt: Int? = 1     @State private var columnVisibility: NavigationSplitViewVisibility = .all     var sidebarList: some View {         List(1...10, id: \.self, selection: $selectedInt) { int in             NavigationLink("Row \(int)", value: int)         }         .navigationTitle("Sidebar")     }     var contentView: some View {         Text("Content \(selectedInt ?? 0)")     }     var detailView: some View {         Text("Detail \(selectedInt ?? 0)")     }     var body: some View {         Group { // Only rows that are a multiple of 2 will have a two-column layout             if selectedInt?.isMultiple(of: 2) == true {                 NavigationSplitView(columnVisibility: $columnVisibility) {                     sidebarList                 } detail: {                     detailView                 }             } else {                 NavigationSplitView(columnVisibility: $columnVisibility) {                     sidebarList                 } content: {                     contentView                 } detail: {                     detailView                 }             }         }         .navigationSplitViewStyle(.balanced)     } } I don't know, however, what impact this has on performance or rendering, if any.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to How to convert NavigationLink tag and selection to value?
By rearranging the way properties are fed into SwiftUI, you can make it fit for the new APIs. Something like this should work: NavigationStack { List(workoutTypes) { workoutType in NavigationLink(workoutType.name, value: workoutType) } .navigationDestination(for: HKWorkoutActivityType.self) { workoutType in SessionPagingView() } } NavigationSplitView { List(workoutTypes, selection: $workoutManager.selectedWorkout) { workoutType in NavigationLink(workoutType.name, value: workoutType) } } detail: { SessionPagingView() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22