diff --git a/Vernissage.xcodeproj/project.pbxproj b/Vernissage.xcodeproj/project.pbxproj index 8bb4f69..760ca29 100644 --- a/Vernissage.xcodeproj/project.pbxproj +++ b/Vernissage.xcodeproj/project.pbxproj @@ -85,6 +85,7 @@ F8A93D802965FED4001D8331 /* AccountService.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8A93D7F2965FED4001D8331 /* AccountService.swift */; }; F8C14392296AF0B3001FE31D /* String+Exif.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8C14391296AF0B3001FE31D /* String+Exif.swift */; }; F8C14394296AF21B001FE31D /* Double+Round.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8C14393296AF21B001FE31D /* Double+Round.swift */; }; + F8CC95CE2970761D00C9C2AC /* TintColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8CC95CD2970761D00C9C2AC /* TintColor.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -164,8 +165,10 @@ F89A46DD296EABA20062125F /* StatusPlaceholder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusPlaceholder.swift; sourceTree = ""; }; F8A93D7D2965FD89001D8331 /* UserProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserProfileView.swift; sourceTree = ""; }; F8A93D7F2965FED4001D8331 /* AccountService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountService.swift; sourceTree = ""; }; + F8AF2A61297073FE00D2DA3F /* Vernissage20230112-001.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "Vernissage20230112-001.xcdatamodel"; sourceTree = ""; }; F8C14391296AF0B3001FE31D /* String+Exif.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Exif.swift"; sourceTree = ""; }; F8C14393296AF21B001FE31D /* Double+Round.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Double+Round.swift"; sourceTree = ""; }; + F8CC95CD2970761D00C9C2AC /* TintColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TintColor.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -230,6 +233,7 @@ children = ( F88FAD2C295F4AD7009B20C9 /* ApplicationState.swift */, F866F6AD29606367002E8F88 /* ApplicationViewMode.swift */, + F8CC95CD2970761D00C9C2AC /* TintColor.swift */, ); path = Models; sourceTree = ""; @@ -499,6 +503,7 @@ F85D498329642FAC00751DF7 /* AttachmentData+Comperable.swift in Sources */, F85D497B29640C8200751DF7 /* UsernameRow.swift in Sources */, F85D497929640B9D00751DF7 /* ImagesCarousel.swift in Sources */, + F8CC95CE2970761D00C9C2AC /* TintColor.swift in Sources */, F89992CC296D9231005994BF /* StatusViewModel.swift in Sources */, F80048052961850500E6868A /* StatusData+CoreDataClass.swift in Sources */, F86B7221296C49A300EE59EC /* EmptyButtonStyle.swift in Sources */, @@ -794,9 +799,10 @@ F88C2476295C37BB0006098B /* Vernissage.xcdatamodeld */ = { isa = XCVersionGroup; children = ( + F8AF2A61297073FE00D2DA3F /* Vernissage20230112-001.xcdatamodel */, F88C2477295C37BB0006098B /* Vernissage.xcdatamodel */, ); - currentVersion = F88C2477295C37BB0006098B /* Vernissage.xcdatamodel */; + currentVersion = F8AF2A61297073FE00D2DA3F /* Vernissage20230112-001.xcdatamodel */; path = Vernissage.xcdatamodeld; sourceTree = ""; versionGroupType = wrapper.xcdatamodel; diff --git a/Vernissage/Assets.xcassets/AccentColor.colorset/Contents.json b/Vernissage/Assets.xcassets/AccentColors/AccentColor.colorset/Contents.json similarity index 76% rename from Vernissage/Assets.xcassets/AccentColor.colorset/Contents.json rename to Vernissage/Assets.xcassets/AccentColors/AccentColor.colorset/Contents.json index 7e73fbb..96e2586 100644 --- a/Vernissage/Assets.xcassets/AccentColor.colorset/Contents.json +++ b/Vernissage/Assets.xcassets/AccentColors/AccentColor.colorset/Contents.json @@ -5,9 +5,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "247", - "green" : "131", - "red" : "52" + "blue" : "0.969", + "green" : "0.514", + "red" : "0.204" } }, "idiom" : "universal" @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "248", - "green" : "167", - "red" : "74" + "blue" : "0.973", + "green" : "0.655", + "red" : "0.290" } }, "idiom" : "universal" diff --git a/Vernissage/Assets.xcassets/AccentColors/AccentColor1.colorset/Contents.json b/Vernissage/Assets.xcassets/AccentColors/AccentColor1.colorset/Contents.json new file mode 100644 index 0000000..1470134 --- /dev/null +++ b/Vernissage/Assets.xcassets/AccentColors/AccentColor1.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "85", + "green" : "123", + "red" : "238" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "101", + "green" : "137", + "red" : "238" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Vernissage/Assets.xcassets/AccentColors/AccentColor10.colorset/Contents.json b/Vernissage/Assets.xcassets/AccentColors/AccentColor10.colorset/Contents.json new file mode 100644 index 0000000..6a9ad80 --- /dev/null +++ b/Vernissage/Assets.xcassets/AccentColors/AccentColor10.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "61", + "green" : "78", + "red" : "235" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.307", + "green" : "0.386", + "red" : "0.936" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Vernissage/Assets.xcassets/AccentColors/AccentColor2.colorset/Contents.json b/Vernissage/Assets.xcassets/AccentColors/AccentColor2.colorset/Contents.json new file mode 100644 index 0000000..96e2586 --- /dev/null +++ b/Vernissage/Assets.xcassets/AccentColors/AccentColor2.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.969", + "green" : "0.514", + "red" : "0.204" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.973", + "green" : "0.655", + "red" : "0.290" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Vernissage/Assets.xcassets/AccentColors/AccentColor3.colorset/Contents.json b/Vernissage/Assets.xcassets/AccentColors/AccentColor3.colorset/Contents.json new file mode 100644 index 0000000..eb76f13 --- /dev/null +++ b/Vernissage/Assets.xcassets/AccentColors/AccentColor3.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "207", + "green" : "90", + "red" : "86" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.884", + "green" : "0.390", + "red" : "0.374" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Vernissage/Assets.xcassets/AccentColors/AccentColor4.colorset/Contents.json b/Vernissage/Assets.xcassets/AccentColors/AccentColor4.colorset/Contents.json new file mode 100644 index 0000000..478170a --- /dev/null +++ b/Vernissage/Assets.xcassets/AccentColors/AccentColor4.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "215", + "green" : "90", + "red" : "163" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.980", + "green" : "0.423", + "red" : "0.711" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Vernissage/Assets.xcassets/AccentColors/AccentColor5.colorset/Contents.json b/Vernissage/Assets.xcassets/AccentColors/AccentColor5.colorset/Contents.json new file mode 100644 index 0000000..2f92c71 --- /dev/null +++ b/Vernissage/Assets.xcassets/AccentColors/AccentColor5.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "197", + "green" : "174", + "red" : "88" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.875", + "green" : "0.767", + "red" : "0.490" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Vernissage/Assets.xcassets/AccentColors/AccentColor6.colorset/Contents.json b/Vernissage/Assets.xcassets/AccentColors/AccentColor6.colorset/Contents.json new file mode 100644 index 0000000..93ea185 --- /dev/null +++ b/Vernissage/Assets.xcassets/AccentColors/AccentColor6.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "102", + "green" : "195", + "red" : "101" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.495", + "green" : "0.844", + "red" : "0.540" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Vernissage/Assets.xcassets/AccentColors/AccentColor7.colorset/Contents.json b/Vernissage/Assets.xcassets/AccentColors/AccentColor7.colorset/Contents.json new file mode 100644 index 0000000..fad688e --- /dev/null +++ b/Vernissage/Assets.xcassets/AccentColors/AccentColor7.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "68", + "green" : "204", + "red" : "246" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.386", + "green" : "0.827", + "red" : "0.957" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Vernissage/Assets.xcassets/AccentColors/AccentColor8.colorset/Contents.json b/Vernissage/Assets.xcassets/AccentColors/AccentColor8.colorset/Contents.json new file mode 100644 index 0000000..5e50bde --- /dev/null +++ b/Vernissage/Assets.xcassets/AccentColors/AccentColor8.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "54", + "green" : "152", + "red" : "241" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.321", + "green" : "0.651", + "red" : "0.957" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Vernissage/Assets.xcassets/AccentColors/AccentColor9.colorset/Contents.json b/Vernissage/Assets.xcassets/AccentColors/AccentColor9.colorset/Contents.json new file mode 100644 index 0000000..d86e8b2 --- /dev/null +++ b/Vernissage/Assets.xcassets/AccentColors/AccentColor9.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "90", + "green" : "68", + "red" : "235" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "display-p3", + "components" : { + "alpha" : "1.000", + "blue" : "0.413", + "green" : "0.352", + "red" : "0.930" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Vernissage/Assets.xcassets/AccentColors/Contents.json b/Vernissage/Assets.xcassets/AccentColors/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Vernissage/Assets.xcassets/AccentColors/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Vernissage/CoreData/ApplicationSettings+CoreDataProperties.swift b/Vernissage/CoreData/ApplicationSettings+CoreDataProperties.swift index c4e33f3..a762e48 100644 --- a/Vernissage/CoreData/ApplicationSettings+CoreDataProperties.swift +++ b/Vernissage/CoreData/ApplicationSettings+CoreDataProperties.swift @@ -1,6 +1,6 @@ // // https://mczachurski.dev -// Copyright © 2022 Marcin Czachurski and the repository contributors. +// Copyright © 2023 Marcin Czachurski and the repository contributors. // Licensed under the MIT License. // @@ -17,9 +17,6 @@ extension ApplicationSettings { } @NSManaged public var currentAccount: String? - -} - -extension ApplicationSettings : Identifiable { + @NSManaged public var tintColor: Int32 } diff --git a/Vernissage/CoreData/ApplicationSettingsHandler.swift b/Vernissage/CoreData/ApplicationSettingsHandler.swift index 413a51c..2ae294a 100644 --- a/Vernissage/CoreData/ApplicationSettingsHandler.swift +++ b/Vernissage/CoreData/ApplicationSettingsHandler.swift @@ -38,6 +38,12 @@ class ApplicationSettingsHandler { CoreDataHandler.shared.save() } + func setDefaultTintColor(tintColor: TintColor) { + let defaultSettings = self.getDefaultSettings() + defaultSettings.tintColor = Int32(tintColor.rawValue) + CoreDataHandler.shared.save() + } + private func createApplicationSettingsEntity() -> ApplicationSettings { let context = CoreDataHandler.shared.container.viewContext return ApplicationSettings(context: context) diff --git a/Vernissage/Extensions/Color+Assets.swift b/Vernissage/Extensions/Color+Assets.swift index 964e922..b8076c9 100644 --- a/Vernissage/Extensions/Color+Assets.swift +++ b/Vernissage/Extensions/Color+Assets.swift @@ -13,5 +13,14 @@ extension Color { static let lightGrayColor = Color("LightGrayColor") static let mainTextColor = Color("MainTextColor") static let selectedRowColor = Color("SelectedRowColor") - + static let accentColor1 = Color("AccentColor1") + static let accentColor2 = Color("AccentColor2") + static let accentColor3 = Color("AccentColor3") + static let accentColor4 = Color("AccentColor4") + static let accentColor5 = Color("AccentColor5") + static let accentColor6 = Color("AccentColor6") + static let accentColor7 = Color("AccentColor7") + static let accentColor8 = Color("AccentColor8") + static let accentColor9 = Color("AccentColor9") + static let accentColor10 = Color("AccentColor10") } diff --git a/Vernissage/Models/ApplicationState.swift b/Vernissage/Models/ApplicationState.swift index f1b4f4a..fadac96 100644 --- a/Vernissage/Models/ApplicationState.swift +++ b/Vernissage/Models/ApplicationState.swift @@ -5,6 +5,7 @@ // import Foundation +import SwiftUI import MastodonKit public class ApplicationState: ObservableObject { @@ -12,6 +13,7 @@ public class ApplicationState: ObservableObject { private init() { } @Published var accountData: AccountData? + @Published var tintColor = TintColor.accentColor2 @Published var showInteractionStatusId = "" } diff --git a/Vernissage/Models/TintColor.swift b/Vernissage/Models/TintColor.swift new file mode 100644 index 0000000..2381ba9 --- /dev/null +++ b/Vernissage/Models/TintColor.swift @@ -0,0 +1,37 @@ +// +// https://mczachurski.dev +// Copyright © 2023 Marcin Czachurski and the repository contributors. +// Licensed under the MIT License. +// + +import SwiftUI + +public enum TintColor: Int { + case accentColor1, accentColor2, accentColor3, accentColor4, accentColor5, + accentColor6, accentColor7, accentColor8, accentColor9, accentColor10 + + public func color() -> Color { + switch self { + case .accentColor1: + return Color.accentColor1 + case .accentColor2: + return Color.accentColor2 + case .accentColor3: + return Color.accentColor3 + case .accentColor4: + return Color.accentColor4 + case .accentColor5: + return Color.accentColor5 + case .accentColor6: + return Color.accentColor6 + case .accentColor7: + return Color.accentColor7 + case .accentColor8: + return Color.accentColor8 + case .accentColor9: + return Color.accentColor9 + case .accentColor10: + return Color.accentColor10 + } + } +} diff --git a/Vernissage/SceneDelegate.swift b/Vernissage/SceneDelegate.swift index 77280d9..36b4bad 100644 --- a/Vernissage/SceneDelegate.swift +++ b/Vernissage/SceneDelegate.swift @@ -8,7 +8,7 @@ import SwiftUI import MastodonKit import OAuthSwift -class SceneDelegate: NSObject, UISceneDelegate { +class SceneDelegate: NSObject, UISceneDelegate { func scene(_ scene: UIScene, openURLContexts URLContexts: Set) { guard let url = URLContexts.first?.url else { return diff --git a/Vernissage/Vernissage.xcdatamodeld/.xccurrentversion b/Vernissage/Vernissage.xcdatamodeld/.xccurrentversion index b9f37ac..d4bfb6d 100644 --- a/Vernissage/Vernissage.xcdatamodeld/.xccurrentversion +++ b/Vernissage/Vernissage.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - Vernissage.xcdatamodel + Vernissage20230112-001.xcdatamodel diff --git a/Vernissage/Vernissage.xcdatamodeld/Vernissage20230112-001.xcdatamodel/contents b/Vernissage/Vernissage.xcdatamodeld/Vernissage20230112-001.xcdatamodel/contents new file mode 100644 index 0000000..8f93d68 --- /dev/null +++ b/Vernissage/Vernissage.xcdatamodeld/Vernissage20230112-001.xcdatamodel/contents @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Vernissage/VernissageApp.swift b/Vernissage/VernissageApp.swift index 9b5989c..0b82b27 100644 --- a/Vernissage/VernissageApp.swift +++ b/Vernissage/VernissageApp.swift @@ -14,6 +14,7 @@ struct VernissageApp: App { let applicationState = ApplicationState.shared @State var applicationViewMode: ApplicationViewMode = .loading + @State var tintColor = ApplicationState.shared.tintColor.color() var body: some Scene { WindowGroup { @@ -28,12 +29,21 @@ struct VernissageApp: App { .environment(\.managedObjectContext, coreDataHandler.container.viewContext) .environmentObject(applicationState) case .mainView: - MainView() - .environment(\.managedObjectContext, coreDataHandler.container.viewContext) - .environmentObject(applicationState) + MainView { color in + self.tintColor = color.color() + } + .environment(\.managedObjectContext, coreDataHandler.container.viewContext) + .environmentObject(applicationState) } } - .task { + .tint(self.tintColor) + .task { + let defaultSettings = ApplicationSettingsHandler.shared.getDefaultSettings() + if let tintColor = TintColor(rawValue: Int(defaultSettings.tintColor)) { + self.applicationState.tintColor = tintColor + self.tintColor = tintColor.color() + } + await AuthorizationService.shared.verifyAccount({ accountData in guard let accountData = accountData else { self.applicationViewMode = .signIn diff --git a/Vernissage/Views/MainView.swift b/Vernissage/Views/MainView.swift index c511562..3cd7da8 100644 --- a/Vernissage/Views/MainView.swift +++ b/Vernissage/Views/MainView.swift @@ -10,10 +10,19 @@ import CoreData import MastodonKit struct MainView: View { + enum Sheet: String, Identifiable { + case settings, compose + var id: String { rawValue } + } + @Environment(\.managedObjectContext) private var viewContext @EnvironmentObject var applicationState: ApplicationState + var onTintChange: ((TintColor) -> Void)? + @State private var showSettings = false + @State private var sheet: Sheet? + @State private var navBarTitle: String = "Home" @State private var viewMode: ViewMode = .home { didSet { @@ -31,12 +40,20 @@ struct MainView: View { self.getMainView() .navigationBarTitle(navBarTitle) .navigationBarTitleDisplayMode(.inline) - .sheet(isPresented: $showSettings, content: { - SettingsView() + .sheet(item: $sheet, content: { item in + switch item { + case .settings: + SettingsView { color in + self.onTintChange?(color) + } + case .compose: + ComposeView(statusViewModel: .constant(nil)) + } }) .toolbar { self.getLeadingToolbar() self.getPrincipalToolbar() + self.getTrailingToolbar() } } @@ -148,7 +165,7 @@ struct MainView: View { Divider() Button { - self.showSettings.toggle() + self.sheet = .settings } label: { Label("Settings", systemImage: "gear") } @@ -168,6 +185,19 @@ struct MainView: View { } } + @ToolbarContentBuilder + private func getTrailingToolbar() -> some ToolbarContent { + ToolbarItem(placement: .navigationBarTrailing) { + Button { + self.sheet = .compose + } label: { + Image(systemName: "photo.stack") + .tint(.mainTextColor) + } + + } + } + private func getViewTitle(viewMode: ViewMode) -> String { switch viewMode { case .home: diff --git a/Vernissage/Views/SettingsView.swift b/Vernissage/Views/SettingsView.swift index f29a2c9..0ff9876 100644 --- a/Vernissage/Views/SettingsView.swift +++ b/Vernissage/Views/SettingsView.swift @@ -11,6 +11,12 @@ struct SettingsView: View { @Environment(\.dismiss) private var dismiss @State var accounts: [AccountData] = [] + @State private var matchSystemTheme = true + + var onTintChange: ((TintColor) -> Void)? + + let accentColors1: [TintColor] = [.accentColor1, .accentColor2, .accentColor3, .accentColor4, .accentColor5] + let accentColors2: [TintColor] = [.accentColor6, .accentColor7, .accentColor8, .accentColor9, .accentColor10] var body: some View { NavigationView { @@ -32,13 +38,75 @@ struct SettingsView: View { } } - Section("General") { - Text("Accent") + Section("Theme") { + Toggle("Match system", isOn: $matchSystemTheme) + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + Text("Light") + Text("Dark") } - Section("About") { - Text("Website") - Text("License") + Section("Accent") { + VStack(alignment: .leading) { + HStack(alignment: .center) { + ForEach(accentColors1, id: \.self) { color in + ZStack { + Circle() + .fill(color.color()) + .frame(width: 36, height: 36) + .onTapGesture { + self.applicationState.tintColor = color + ApplicationSettingsHandler.shared.setDefaultTintColor(tintColor: color) + self.onTintChange?(color) + } + if color == self.applicationState.tintColor { + Image(systemName: "checkmark") + .tint(Color.mainTextColor) + .fontWeight(.bold) + } + } + + if color != accentColors1.last { + Spacer() + } + } + } + .padding(.vertical, 8) + + HStack(alignment: .center) { + ForEach(accentColors2, id: \.self) { color in + ZStack { + Circle() + .fill(color.color()) + .frame(width: 36, height: 36) + .onTapGesture { + self.applicationState.tintColor = color + ApplicationSettingsHandler.shared.setDefaultTintColor(tintColor: color) + self.onTintChange?(color) + } + if color == self.applicationState.tintColor { + Image(systemName: "checkmark") + .tint(Color.mainTextColor) + .fontWeight(.bold) + } + } + + if color != accentColors2.last { + Spacer() + } + } + } + .padding(.vertical, 8) + } + } + + Section("Other") { + Text("Third party") // Link to dependeinces + Text("Report a bug") + Text("Follow me on Mastodon") + } + + Section() { + Text("Version") // Link to dependeinces } } .frame(alignment: .topLeading) diff --git a/Vernissage/Widgets/InteractionRow.swift b/Vernissage/Widgets/InteractionRow.swift index ace55c1..e5d6720 100644 --- a/Vernissage/Widgets/InteractionRow.swift +++ b/Vernissage/Widgets/InteractionRow.swift @@ -110,7 +110,7 @@ struct InteractionRow: View { } } .font(.title3) - .fontWeight(.semibold) + .fontWeight(.bold) .onAppear { self.refreshCounters() }