From 426d2e15b2df770fdc7b2e99aa43bdb6aaf02ab0 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Sun, 29 Jan 2023 15:08:41 +0100 Subject: [PATCH] Change timeline icon + move OpenAI icon to the accessory bar --- IceCubesApp/App/Tabs/Tabs.swift | 2 +- .../Models/Sources/Models/ServerFilter.swift | 2 +- .../StatusEditorAccessoryView.swift | 35 ++++++++++++++++++ .../Status/Editor/StatusEditorView.swift | 37 ------------------- 4 files changed, 37 insertions(+), 39 deletions(-) diff --git a/IceCubesApp/App/Tabs/Tabs.swift b/IceCubesApp/App/Tabs/Tabs.swift index 684e0291..de0275af 100644 --- a/IceCubesApp/App/Tabs/Tabs.swift +++ b/IceCubesApp/App/Tabs/Tabs.swift @@ -84,7 +84,7 @@ enum Tab: Int, Identifiable, Hashable { var iconName: String { switch self { case .timeline: - return "rectangle.on.rectangle" + return "rectangle.stack" case .trending: return "chart.line.uptrend.xyaxis" case .local: diff --git a/Packages/Models/Sources/Models/ServerFilter.swift b/Packages/Models/Sources/Models/ServerFilter.swift index f14daac7..561353d3 100644 --- a/Packages/Models/Sources/Models/ServerFilter.swift +++ b/Packages/Models/Sources/Models/ServerFilter.swift @@ -27,7 +27,7 @@ public extension ServerFilter.Context { var iconName: String { switch self { case .home: - return "rectangle.on.rectangle" + return "rectangle.stack" case .notifications: return "bell" case .public: diff --git a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift index 802b721e..c8c1f92b 100644 --- a/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift +++ b/Packages/Status/Sources/Status/Editor/Components/StatusEditorAccessoryView.swift @@ -17,6 +17,7 @@ struct StatusEditorAccessoryView: View { @State private var isLanguageSheetDisplayed: Bool = false @State private var isCustomEmojisSheetDisplay: Bool = false @State private var languageSearch: String = "" + @State private var isLoadingAIRequest: Bool = false var body: some View { VStack(spacing: 0) { @@ -77,6 +78,10 @@ struct StatusEditorAccessoryView: View { Image(systemName: "globe") } } + + if preferences.isOpenAIEnabled { + AIMenu.disabled(!viewModel.canPost) + } } .padding(.horizontal, .layoutPadding) } @@ -110,6 +115,36 @@ struct StatusEditorAccessoryView: View { Text(isoCode.uppercased()) } } + + private var AIMenu: some View { + Menu { + ForEach(StatusEditorAIPrompts.allCases, id: \.self) { prompt in + Button { + Task { + isLoadingAIRequest = true + await viewModel.runOpenAI(prompt: prompt.toRequestPrompt(text: viewModel.statusText.string)) + isLoadingAIRequest = false + } + } label: { + prompt.label + } + } + if let backup = viewModel.backupStatusText { + Button { + viewModel.replaceTextWith(text: backup.string) + viewModel.backupStatusText = nil + } label: { + Label("status.editor.restore-previous", systemImage: "arrow.uturn.right") + } + } + } label: { + if isLoadingAIRequest { + ProgressView() + } else { + Image(systemName: "faxmachine") + } + } + } private var languageSheetView: some View { NavigationStack { diff --git a/Packages/Status/Sources/Status/Editor/StatusEditorView.swift b/Packages/Status/Sources/Status/Editor/StatusEditorView.swift index 9e5da062..116fb3c1 100644 --- a/Packages/Status/Sources/Status/Editor/StatusEditorView.swift +++ b/Packages/Status/Sources/Status/Editor/StatusEditorView.swift @@ -22,7 +22,6 @@ public struct StatusEditorView: View { @FocusState private var isSpoilerTextFocused: Bool @State private var isDismissAlertPresented: Bool = false - @State private var isLoadingAIRequest: Bool = false public init(mode: StatusEditorViewModel.Mode) { _viewModel = StateObject(wrappedValue: .init(mode: mode)) @@ -101,12 +100,6 @@ public struct StatusEditorView: View { Text(viewModel.postingError ?? "") }) .toolbar { - if preferences.isOpenAIEnabled { - ToolbarItem(placement: .navigationBarTrailing) { - AIMenu - .disabled(!viewModel.canPost) - } - } ToolbarItem(placement: .navigationBarTrailing) { Button { Task { @@ -218,34 +211,4 @@ public struct StatusEditorView: View { ) } } - - private var AIMenu: some View { - Menu { - ForEach(StatusEditorAIPrompts.allCases, id: \.self) { prompt in - Button { - Task { - isLoadingAIRequest = true - await viewModel.runOpenAI(prompt: prompt.toRequestPrompt(text: viewModel.statusText.string)) - isLoadingAIRequest = false - } - } label: { - prompt.label - } - } - if let backup = viewModel.backupStatusText { - Button { - viewModel.replaceTextWith(text: backup.string) - viewModel.backupStatusText = nil - } label: { - Label("status.editor.restore-previous", systemImage: "arrow.uturn.right") - } - } - } label: { - if isLoadingAIRequest { - ProgressView() - } else { - Image(systemName: "faxmachine") - } - } - } }