From e34e5fbbb8362f303168b29b0d77ce4136e48231 Mon Sep 17 00:00:00 2001 From: Hugo Pezziardi Date: Tue, 6 Feb 2024 18:58:17 +0100 Subject: [PATCH] :recycle: (LekaApp): Refactor SettingsView without Appearance --- .../Views/MainView/MainView.swift | 19 ++---- ...iew+AppearanceSection+AccentColorRow.swift | 68 ------------------- ...View+AppearanceSection+AppearanceRow.swift | 42 ------------ .../SettingsView+AppearanceSection.swift | 26 ------- .../Views/Settings/SettingsView+l10n.swift | 12 ---- .../Views/Settings/SettingsView.swift | 8 +-- 6 files changed, 9 insertions(+), 166 deletions(-) delete mode 100644 Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AccentColorRow.swift delete mode 100644 Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AppearanceRow.swift delete mode 100644 Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection.swift diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView.swift index b29c606012..acec775d28 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView.swift @@ -46,27 +46,22 @@ struct MainView: View { CategoryLabel(category: .stories) } - HStack { - Spacer() - VStack(spacing: 20) { + VStack(alignment: .center, spacing: 20) { + if self.rootOwnerViewModel.isCompanyConnected { Button { self.rootOwnerViewModel.isSettingsViewPresented = true } label: { SettingsLabel() } - - Text("My Leka App - Version \(Bundle.version!) (\(Bundle.buildNumber!))") - .foregroundColor(.gray) - .font(.caption2) } - Spacer() - } - HStack { - Spacer() + Text("My Leka App - Version \(Bundle.version!) (\(Bundle.buildNumber!))") + .foregroundColor(.gray) + .font(.caption2) + LekaLogo(width: 50) - Spacer() } + .frame(maxWidth: .infinity) } // TODO: (@ladislas) remove if not necessary // .disabled(navigation.disableUICompletly) diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AccentColorRow.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AccentColorRow.swift deleted file mode 100644 index f32e2602ad..0000000000 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AccentColorRow.swift +++ /dev/null @@ -1,68 +0,0 @@ -// Leka - iOS Monorepo -// Copyright APF France handicap -// SPDX-License-Identifier: Apache-2.0 - -import DesignKit -import LocalizationKit -import SwiftUI - -// swiftlint:disable nesting - -// MARK: - SettingsView.AppearanceSection.AccentColorRow - -extension SettingsView.AppearanceSection { - struct AccentColorRow: View { - // MARK: Internal - - // MARK: - ColorCircleView - - struct ColorCircleView: View { - let color: Color - let isSelected: Bool - - var body: some View { - VStack { - Circle() - .fill(self.color) - .frame(width: 25) - .overlay(Circle().fill(self.isSelected ? .white : .clear).frame(width: 8)) - .overlay(Circle().stroke(.gray, lineWidth: 0.5)) - } - .animation(.easeIn, value: self.isSelected) - } - } - - @ObservedObject var styleManager: StyleManager = .shared - - var body: some View { - HStack { - Text(l10n.SettingsView.AppearanceSection.AccentColorRow.title) - - Spacer() - - ForEach(self.colors, id: \.self) { color in - ColorCircleView(color: color, isSelected: self.selectedColor == color) - .onTapGesture { - self.styleManager.accentColor = color - } - } - } - } - - // MARK: Private - - private let colors: [Color] = [DesignKitAsset.Colors.lekaDarkBlue.swiftUIColor, .blue, .purple, .red, .orange, .yellow, .green, .gray] - - private var selectedColor: Color { - self.styleManager.accentColor ?? .clear - } - } -} - -// swiftlint:enable nesting - -#Preview { - Form { - SettingsView.AppearanceSection.AccentColorRow() - } -} diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AppearanceRow.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AppearanceRow.swift deleted file mode 100644 index 14c696ca26..0000000000 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection+AppearanceRow.swift +++ /dev/null @@ -1,42 +0,0 @@ -// Leka - iOS Monorepo -// Copyright APF France handicap -// SPDX-License-Identifier: Apache-2.0 - -import DesignKit -import LocalizationKit -import SwiftUI - -// MARK: - SettingsView.AppearanceSection - -extension SettingsView.AppearanceSection { - struct AppearanceRow: View { - // MARK: Internal - - @ObservedObject var styleManager: StyleManager = .shared - - var body: some View { - HStack(spacing: 10) { - Text(l10n.SettingsView.AppearanceSection.AppearanceRow.title) - - Spacer() - - Toggle("", isOn: Binding( - get: { self.styleManager.colorScheme == .dark }, - set: { self.styleManager.colorScheme = $0 ? .dark : .light } - )) - } - } - - // MARK: Private - - private var selectedColorScheme: ColorScheme { - self.styleManager.colorScheme - } - } -} - -#Preview { - Form { - SettingsView.AppearanceSection() - } -} diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection.swift deleted file mode 100644 index e4ca0e28df..0000000000 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+AppearanceSection.swift +++ /dev/null @@ -1,26 +0,0 @@ -// Leka - iOS Monorepo -// Copyright APF France handicap -// SPDX-License-Identifier: Apache-2.0 - -import DesignKit -import LocalizationKit -import SwiftUI - -// MARK: - SettingsView.AppearanceSection - -extension SettingsView { - struct AppearanceSection: View { - var body: some View { - Section(String(l10n.SettingsView.AppearanceSection.header.characters)) { - AppearanceRow() - AccentColorRow() - } - } - } -} - -#Preview { - Form { - SettingsView.AppearanceSection() - } -} diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+l10n.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+l10n.swift index 3152e077ac..98480fdde3 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+l10n.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView+l10n.swift @@ -8,18 +8,6 @@ import LocalizationKit extension l10n { enum SettingsView { - enum AppearanceSection { - enum AppearanceRow { - static let title = LocalizedString("settings_view.appearance_section.appearance_row.title", value: "Dark mode", comment: "Appearance Row title") - } - - enum AccentColorRow { - static let title = LocalizedString("settings_view.appearance_section.accent_color_row.title", value: "Accent Color", comment: "AccentColor Row title") - } - - static let header = LocalizedString("settings_view.appearance_section.header", value: "Appearance", comment: "Appearance section header") - } - enum CredentialsSection { enum ChangeCredentials { static let buttonLabel = LocalizedString("settings_view.credentials_section.change_credentials.button_label", value: "Change email and password", comment: "Change credentials button label") diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift index 4098d4dac7..3ed84de520 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Settings/SettingsView.swift @@ -15,12 +15,8 @@ struct SettingsView: View { var body: some View { NavigationStack { Form { - AppearanceSection() - - if self.rootOwnerViewModel.isCompanyConnected { - CredentialsSection() - AccountSection() - } + CredentialsSection() + AccountSection() } .navigationTitle(String(l10n.SettingsView.navigationTitle.characters)) .navigationBarTitleDisplayMode(.inline)