What I want to achieve is a form with a different background color. But I want the items inside always using the light mode variant (dark text colors). But not the complete view. I've searched for it but couldn't find any solution.
I've tried listRowBackground to change background of the items which works and preferredColorScheme to use the light mode but that will make the complete view in light mode:
...
Form {
DatePicker(selection: $date, displayedComponents: .date) { ... }
.listRowBackground(Color.yellow)
TextField("Name", text: $name)
.listRowBackground(Color.yellow)
Picker("amount", selection: $amount) {
ForEach(amounts, id: \.self) {
Text($0)
}
}
.listRowBackground(Color.yellow)
Button(action: { ... }) {
Label("More", systemImage: "chevron.up")
}
.listRowBackground(Color.yellow)
}
.preferredColorScheme(.light)
...
