Post

Replies

Boosts

Views

Activity

How can I make SwiftUI Text Adapt To Background Color
How can I get SwiftUI text to properly react to different background colors? It seems to me that text will just default to white or black depending on whether you are in light or dark mode but won't take into consideration the background color of their parent. What if you wanted the background color to be user configurable and they select something like yellow, it would work fine in light mode because the text is black, however if the device is in dark mode the text would become white and unreadable on top of bright yellow. Is there some way I can fix this? Thanks!
0
0
883
Sep ’20
The compiler is unable to type-check this expression in reasonable time in Xcode 12 with SwiftUI
I've just begun running into this error and I've seen that a few others have had this problem as well but there never seems to be a general solution. Full error: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions I know my code isn't necessarily optimized per se but I don't think this should be happening var body: some View {         return NavigationView {             List {                 ForEach(tasks, id: \.dueDate) {                     TaskRow(task: $0)                 }.onDelete(perform: deleteTask)                 Section(header: Text("Projects")                             .font(.title2)                             .fontWeight(.bold)                             .foregroundColor(Color.pink)) {                     ForEach(projects, id: \.projectTitle) {                         ProjectRow(project: $0)                     }.onDelete(perform: deleteProject)                 }             }.toolbar {                 ToolbarItem (placement: .primaryAction) {                     #if os(iOS) EditButton() .padding(10) .background(Color.blue) .foregroundColor(.white) .cornerRadius(10)                  #endif                 }                 ToolbarItem (placement: .bottomBar) {                     Button(action:                         self.isAddingTask = true                         self.isAddingProject = false                         self.isPresenting = true                     }) {                         Text("Add Task")                             .fontWeight(.semibold)                    }.padding(10) .background(Color.blue) .foregroundColor(.white) .cornerRadius(10)                 }                 ToolbarItem (placement: .bottomBar) {                     Button(action: {                         self.isAddingTask = false                         self.isAddingProject = true                         self.isPresenting = true                     }) {                         Text("Add Project")                             .fontWeight(.semibold)                   }.padding(10) .background(Color.pink) .foregroundColor(.white) .cornerRadius(10)                 }             }             .sheet(isPresented: $isPresenting) {                 if isAddingProject {                     AddProject() { projectTitle in                         self.addProject(projectTitle: projectTitle)                         resetModal()                     }                 } else if isAddingTask {                     AddTask() { taskDescription, dueDate in                         self.addTask(taskDescription: taskDescription, dueDate: dueDate)                         resetModal()                     }                 }             }             .navigationBarTitle(Text("Tasky"))         } The error says it's happening at the Navigation View but I have a sneaking suspicion Xcode doesn't actually know.
15
4
49k
Jul ’20
EventKit with SwiftUI
I've been playing around with EventKit with SwiftUI trying to make my own version of a Reminders client, however, most of the tutorials or articles I've found really only explain it from a UIKit perspective and I'm not exactly sure how to make that applicable to SwiftUI, the documentation for EventKit is also of little to no help. Is there an article or example somewhere that shows how to do this?
2
0
2.2k
Jun ’20