From 2e9b4f5d19de9ce45e306706bb15f180b1bbd234 Mon Sep 17 00:00:00 2001 From: fmodf Date: Mon, 7 Oct 2024 14:54:07 +0200 Subject: [PATCH] wip --- .../Resources/Strings/Localizable.strings | 3 + .../View/Main/Settings/SettingsScreen.swift | 88 ++++++++++++++++--- .../SharedComponents/SharedSectionTitle.swift | 21 +++++ 3 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 ConversationsClassic/View/SharedComponents/SharedSectionTitle.swift diff --git a/ConversationsClassic/Resources/Strings/Localizable.strings b/ConversationsClassic/Resources/Strings/Localizable.strings index 5f6eab7..c50bbb3 100644 --- a/ConversationsClassic/Resources/Strings/Localizable.strings +++ b/ConversationsClassic/Resources/Strings/Localizable.strings @@ -73,4 +73,7 @@ "Chats.Create.Main.createChannel" = "Create channel"; "Chats.Create.Main.findChannel" = "Find channel"; +// MARK: Settings +"Settings.Main.title" = "Settings"; +"Settings.Section.Accounts.title" = "Accounts"; diff --git a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift index 81b4af7..3e3764c 100644 --- a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift +++ b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift @@ -5,22 +5,86 @@ struct SettingsScreen: View { var body: some View { ZStack { - // bg + // Background color Color.Material.Background.light .ignoresSafeArea() - // debug buttons - #if DEBUG - // clean all data - Button { - clientsStore.flushAllData() - Database.shared.flushAllData() - } label: { - Text("Clean all (for test)") - .font(.title) - .foregroundColor(.Material.Elements.active) + // Content + VStack(spacing: 0) { + // Header + SharedNavigationBar( + centerText: .init(text: L10n.Settings.Main.title) + ) + + // List + List { + // Accounts section + SharedSectionTitle(text: L10n.Settings.Section.Accounts.title) + + ForEach(clientsStore.clients) { client in + SharedListRow( + iconType: .image(Image(systemName: "person.fill"), .Material.Elements.active), + text: "name", + controlType: .none + ) + .onTapGesture { + print("Tapped client: \(client.name)") + } + } + + SharedListRow( + iconType: .image(Image(systemName: "person.2.fill"), .Material.Elements.active), + text: L10n.Chats.Create.Main.createGroup, + controlType: .none + ) + .onTapGesture { + print("Tapped createGroup") + } + SharedListRow( + iconType: .image(Image(systemName: "person.2.fill"), .Material.Elements.active), + text: L10n.Chats.Create.Main.createGroup, + controlType: .none + ) + .onTapGesture { + print("Tapped createGroup") + } + SharedListRow( + iconType: .image(Image(systemName: "person.2.fill"), .Material.Elements.active), + text: L10n.Chats.Create.Main.createGroup, + controlType: .none + ) + .onTapGesture { + print("Tapped createGroup") + } + SharedListRow( + iconType: .image(Image(systemName: "person.2.fill"), .Material.Elements.active), + text: L10n.Chats.Create.Main.createGroup, + controlType: .none + ) + .onTapGesture { + print("Tapped createGroup") + } + + // Dev section + #if DEBUG + SharedSectionTitle(text: "Dev tools") + + SharedListRow( + iconType: .image(Image(systemName: "xmark.octagon"), .Material.Elements.active), + text: "Clean all data", + controlType: .none + ) + .onTapGesture { + clientsStore.flushAllData() + Database.shared.flushAllData() + } + #endif } - #endif + .listStyle(.plain) + .environment(\.defaultMinListRowHeight, 10) + + Spacer() + } } } } diff --git a/ConversationsClassic/View/SharedComponents/SharedSectionTitle.swift b/ConversationsClassic/View/SharedComponents/SharedSectionTitle.swift new file mode 100644 index 0000000..128afe9 --- /dev/null +++ b/ConversationsClassic/View/SharedComponents/SharedSectionTitle.swift @@ -0,0 +1,21 @@ +import SwiftUI + +struct SharedSectionTitle: View { + let text: String + + var body: some View { + HStack(spacing: 0) { + // Text + Text(text) + .foregroundColor(Color.Material.Text.sub) + .font(.body3) + .padding(.leading, 16) + .padding(.top, 16) + Spacer() + } + .listRowInsets(.zero) + .listRowSeparator(.hidden) + .frame(maxWidth: .infinity, maxHeight: .infinity) + .background(Color.Material.Background.light) + } +}