From 9fec884e19a93f574a100b8ba160c693bcedf0f4 Mon Sep 17 00:00:00 2001 From: Terry Yiu Date: Mon, 20 Jan 2025 21:34:14 -0500 Subject: [PATCH] Add LoggedInView with tabs --- Yeti/Assets/Localizable.xcstrings | 13 +++- Yeti/Views/ContentView.swift | 29 +-------- Yeti/Views/HistoryView.swift | 18 ++++++ Yeti/Views/HomeView.swift | 18 ++++++ Yeti/Views/LoggedInView.swift | 68 +++++++++++++++++++++ Yeti/Views/OnboardingView.swift | 44 +++++++++++++ Yeti/Views/PermissionsView.swift | 18 ++++++ Yeti/Views/SettingsView.swift | 18 ++++++ Yeti/Views/SigningPolicySelectionView.swift | 13 ++-- 9 files changed, 205 insertions(+), 34 deletions(-) create mode 100644 Yeti/Views/HistoryView.swift create mode 100644 Yeti/Views/HomeView.swift create mode 100644 Yeti/Views/LoggedInView.swift create mode 100644 Yeti/Views/OnboardingView.swift create mode 100644 Yeti/Views/PermissionsView.swift create mode 100644 Yeti/Views/SettingsView.swift diff --git a/Yeti/Assets/Localizable.xcstrings b/Yeti/Assets/Localizable.xcstrings index 7b9ac65..1479097 100644 --- a/Yeti/Assets/Localizable.xcstrings +++ b/Yeti/Assets/Localizable.xcstrings @@ -16,8 +16,11 @@ "Done" : { "comment" : "Button to go to the next view that adds the user’s entered private key." }, + "History" : { + "comment" : "Title for History tab" + }, "Home" : { - "comment" : "Navigation title of home view." + "comment" : "Navigation title of home view.\nTitle for Home tab" }, "Hooo-raaaayyy!" : { "comment" : "Title of view that confirms the user’s selection of the signing policy." @@ -31,6 +34,9 @@ "nsec / private key" : { "comment" : "Prompt asking user to enter in a Nostr private key." }, + "Permissions" : { + "comment" : "Title for Permissions tab" + }, "Recommended for most people. This policy will minimize the number of interruptions during your app usage." : { "comment" : "Description of event signing policy that approves basic actions." }, @@ -40,8 +46,11 @@ "Select a signing policy" : { "comment" : "Title of view to select a signing policy." }, + "Settings" : { + "comment" : "Title for Settings tab" + }, "Should I approve Nostr events automatically or would you like to review them for each app?" : { - + "comment" : "Prompt asking user which signing policy to use." }, "Yeti: Nostr Helper" : { "comment" : "Application title." diff --git a/Yeti/Views/ContentView.swift b/Yeti/Views/ContentView.swift index 0cb1f42..ca14d03 100644 --- a/Yeti/Views/ContentView.swift +++ b/Yeti/Views/ContentView.swift @@ -12,33 +12,8 @@ struct ContentView: View { @Environment(\.modelContext) private var modelContext var body: some View { - NavigationStack { - Text("Yeti: Nostr Helper", comment: "Application title.") - - HStack { - NavigationLink( - destination: { - AddKeyView() - }, - label: { - Text("Add a key", comment: "Button to add a key.") - } - ) - .buttonStyle(.bordered) - - NavigationLink( - destination: { - AddKeyView() - }, - label: { - Text("Create a key", comment: "Button to create a key.") - } - ) - .buttonStyle(.borderedProminent) - } - } - .navigationTitle(String(localized: "Home", comment: "Navigation title of home view.")) - .toolbar(removing: .title) +// OnboardingView() + LoggedInView() } } diff --git a/Yeti/Views/HistoryView.swift b/Yeti/Views/HistoryView.swift new file mode 100644 index 0000000..ad5438b --- /dev/null +++ b/Yeti/Views/HistoryView.swift @@ -0,0 +1,18 @@ +// +// HistoryView.swift +// Yeti +// +// Created by Terry Yiu on 1/20/25. +// + +import SwiftUI + +struct HistoryView: View { + var body: some View { + EmptyView() + } +} + +#Preview { + HistoryView() +} diff --git a/Yeti/Views/HomeView.swift b/Yeti/Views/HomeView.swift new file mode 100644 index 0000000..e972a70 --- /dev/null +++ b/Yeti/Views/HomeView.swift @@ -0,0 +1,18 @@ +// +// HomeView.swift +// Yeti +// +// Created by Terry Yiu on 1/20/25. +// + +import SwiftUI + +struct HomeView: View { + var body: some View { + EmptyView() + } +} + +#Preview { + HomeView() +} diff --git a/Yeti/Views/LoggedInView.swift b/Yeti/Views/LoggedInView.swift new file mode 100644 index 0000000..8040a4b --- /dev/null +++ b/Yeti/Views/LoggedInView.swift @@ -0,0 +1,68 @@ +// +// LoggedInView.swift +// Yeti +// +// Created by Terry Yiu on 1/20/25. +// + +import SwiftUI + +struct LoggedInView: View { + @State var selectedTab: YetiTab = .home + + var body: some View { + TabView(selection: $selectedTab) { + ForEach(YetiTab.allCases, id: \.self) { yetiTab in + Tab(yetiTab.description, systemImage: yetiTab.systemImage, value: yetiTab) { + switch yetiTab { + case .home: + HomeView() + case .permissions: + PermissionsView() + case .history: + HistoryView() + case .settings: + SettingsView() + } + } + } + } + } +} + +enum YetiTab: CustomStringConvertible, CaseIterable { + case home + case permissions + case history + case settings + + var description: String { + switch self { + case .home: + String(localized: "Home", comment: "Title for Home tab") + case .permissions: + String(localized: "Permissions", comment: "Title for Permissions tab") + case .history: + String(localized: "History", comment: "Title for History tab") + case .settings: + String(localized: "Settings", comment: "Title for Settings tab") + } + } + + var systemImage: String { + switch self { + case .home: + "house" + case .permissions: + "shield.lefthalf.filled.badge.checkmark" + case .history: + "clock" + case .settings: + "gear" + } + } +} + +#Preview { + LoggedInView() +} diff --git a/Yeti/Views/OnboardingView.swift b/Yeti/Views/OnboardingView.swift new file mode 100644 index 0000000..1523344 --- /dev/null +++ b/Yeti/Views/OnboardingView.swift @@ -0,0 +1,44 @@ +// +// OnboardingView.swift +// Yeti +// +// Created by Terry Yiu on 1/20/25. +// + +import SwiftUI + +struct OnboardingView: View { + var body: some View { + NavigationStack { + Text("Yeti: Nostr Helper", comment: "Application title.") + + HStack { + NavigationLink( + destination: { + AddKeyView() + }, + label: { + Text("Add a key", comment: "Button to add a key.") + } + ) + .buttonStyle(.bordered) + + NavigationLink( + destination: { + AddKeyView() + }, + label: { + Text("Create a key", comment: "Button to create a key.") + } + ) + .buttonStyle(.borderedProminent) + } + } + .navigationTitle(String(localized: "Home", comment: "Navigation title of home view.")) + .toolbar(removing: .title) + } +} + +#Preview { + OnboardingView() +} diff --git a/Yeti/Views/PermissionsView.swift b/Yeti/Views/PermissionsView.swift new file mode 100644 index 0000000..b9fd0d9 --- /dev/null +++ b/Yeti/Views/PermissionsView.swift @@ -0,0 +1,18 @@ +// +// PermissionsView.swift +// Yeti +// +// Created by Terry Yiu on 1/20/25. +// + +import SwiftUI + +struct PermissionsView: View { + var body: some View { + EmptyView() + } +} + +#Preview { + PermissionsView() +} diff --git a/Yeti/Views/SettingsView.swift b/Yeti/Views/SettingsView.swift new file mode 100644 index 0000000..8f8ac82 --- /dev/null +++ b/Yeti/Views/SettingsView.swift @@ -0,0 +1,18 @@ +// +// SettingsView.swift +// Yeti +// +// Created by Terry Yiu on 1/20/25. +// + +import SwiftUI + +struct SettingsView: View { + var body: some View { + EmptyView() + } +} + +#Preview { + SettingsView() +} diff --git a/Yeti/Views/SigningPolicySelectionView.swift b/Yeti/Views/SigningPolicySelectionView.swift index d4c49a4..2cf4c71 100644 --- a/Yeti/Views/SigningPolicySelectionView.swift +++ b/Yeti/Views/SigningPolicySelectionView.swift @@ -24,11 +24,14 @@ struct SigningPolicySelectionView: View { .listRowInsets(EdgeInsets()) .background(Color(UIColor.systemGroupedBackground)) - Text("Should I approve Nostr events automatically or would you like to review them for each app?") - .font(.caption) - .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) - .listRowInsets(EdgeInsets()) - .background(Color(UIColor.systemGroupedBackground)) + Text( + "Should I approve Nostr events automatically or would you like to review them for each app?", + comment: "Prompt asking user which signing policy to use." + ) + .font(.caption) + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center) + .listRowInsets(EdgeInsets()) + .background(Color(UIColor.systemGroupedBackground)) Section( content: {