Add dark mode support with appearance picker and fix hardcoded colors
Add user-facing appearance setting (System/Light/Dark) wired via preferredColorScheme at the app root. Replace hardcoded .black tints and foreground styles with .primary so toolbar buttons and text remain visible in dark mode. Remove profile picture from settings and SwiftSoup from acknowledgements. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,30 +22,6 @@ struct SettingsView: View {
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
HStack(alignment: .center) {
|
||||
if let avatarImage = viewModel.avatarImage {
|
||||
Image(uiImage: avatarImage)
|
||||
.resizable()
|
||||
.clipShape(Circle())
|
||||
.frame(width: 100, height: 100)
|
||||
|
||||
}
|
||||
if let userData = viewModel.userData {
|
||||
VStack(alignment: .leading) {
|
||||
Text(userData.userDisplayName)
|
||||
.font(.title)
|
||||
.padding(.leading)
|
||||
Text("Username: \(userData.userId)")
|
||||
.font(.subheadline)
|
||||
.padding(.leading)
|
||||
|
||||
|
||||
// TODO: Add actions
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
|
||||
Section {
|
||||
Picker("Select a default cookbook", selection: $userSettings.defaultCategory) {
|
||||
Text("None").tag("None")
|
||||
@@ -59,6 +35,16 @@ struct SettingsView: View {
|
||||
Text("The selected cookbook will open on app launch by default.")
|
||||
}
|
||||
|
||||
Section {
|
||||
Picker("Appearance", selection: $userSettings.appearanceMode) {
|
||||
ForEach(AppearanceMode.allValues, id: \.self) { mode in
|
||||
Text(mode.descriptor()).tag(mode.rawValue)
|
||||
}
|
||||
}
|
||||
} footer: {
|
||||
Text("Choose whether the app follows the system appearance or always uses light or dark mode.")
|
||||
}
|
||||
|
||||
Section {
|
||||
Picker("Grocery list storage", selection: $userSettings.groceryListMode) {
|
||||
ForEach(GroceryListMode.allValues, id: \.self) { mode in
|
||||
@@ -211,13 +197,6 @@ struct SettingsView: View {
|
||||
}
|
||||
|
||||
Section(header: Text("Acknowledgements")) {
|
||||
VStack(alignment: .leading) {
|
||||
if let url = URL(string: "https://github.com/scinfu/SwiftSoup") {
|
||||
Link("SwiftSoup", destination: url)
|
||||
.font(.headline)
|
||||
Text("An HTML parsing and web scraping library for Swift. Used for importing schema.org recipes from websites.")
|
||||
}
|
||||
}
|
||||
VStack(alignment: .leading) {
|
||||
if let url = URL(string: "https://github.com/techprimate/TPPDF") {
|
||||
Link("TPPDF", destination: url)
|
||||
@@ -240,7 +219,6 @@ struct SettingsView: View {
|
||||
Text(viewModel.alertType.getMessage())
|
||||
}
|
||||
.task {
|
||||
await viewModel.getUserData()
|
||||
remindersPermission = groceryListManager.remindersPermissionStatus
|
||||
if remindersPermission == .fullAccess {
|
||||
reminderLists = groceryListManager.availableReminderLists()
|
||||
@@ -270,9 +248,6 @@ struct SettingsView: View {
|
||||
|
||||
extension SettingsView {
|
||||
class ViewModel: ObservableObject {
|
||||
@Published var avatarImage: UIImage? = nil
|
||||
@Published var userData: UserData? = nil
|
||||
|
||||
@Published var showAlert: Bool = false
|
||||
fileprivate var alertType: SettingsAlert = .NONE
|
||||
|
||||
@@ -297,16 +272,6 @@ extension SettingsView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getUserData() async {
|
||||
let (data, _) = await NextcloudApi.getAvatar()
|
||||
let (userData, _) = await NextcloudApi.getHoverCard()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.avatarImage = data
|
||||
self.userData = userData
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user