When switching the application to dark mode, the confirmationDialog
is displayed in white. How can I make the confirmationDialog
also show up in dark mode?
import SwiftUI
struct SettingListView: View, Themeable {
@Environment(\.dismiss) var dismiss
@State private var showingConfirmation = false
@Environment(\.colorScheme) var colorScheme
@AppStorage("isDarkMode") private var isDarkMode = false
@StateObject var settingsListViewModel = SettingsListViewModel()
@State private var changeValueID = true
@State private var showContacts = true
var body: some View {
NavigationStack {
List {
Section {
VStack {
ZStack(alignment: .bottomTrailing) {
Image("avatar")
.resizable()
.scaledToFill()
.frame(width: 120, height: 120)
.clipShape(Circle())
.onTapGesture {
showingConfirmation = true
}
.confirmationDialog("Change Profile Picture", isPresented: $showingConfirmation, titleVisibility: .visible) {
Button(role: .none, action: {}) {
Text("Take Photo")
}
Button(role: .none, action: {}) {
Text("Choose from library")
}
Button(role: .none, action: {}) {
Text("Use Avatar")
}
}
Image(systemName: "pencil")
.foregroundColor(isDarkMode ? .white : .black)
.frame(width: 28, height: 28)
.background(isDarkMode ? Color(#colorLiteral(red: 0.370555222, green: 0.3705646992, blue: 0.3705595732, alpha: 1)) : Color(#colorLiteral(red: 0.921431005, green: 0.9214526415, blue: 0.9214410186, alpha: 1)))
.clipShape(Circle())
.overlay {
Circle().stroke(isDarkMode ? .black : Color(.secondarySystemBackground), lineWidth: 4)
}
.scaleEffect(x: 1.1, y: 1.1, anchor: .center)
}
}