mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-04-27 02:14:45 +00:00
Change timeline icon + move OpenAI icon to the accessory bar
This commit is contained in:
parent
e33def60a3
commit
426d2e15b2
4 changed files with 37 additions and 39 deletions
|
@ -84,7 +84,7 @@ enum Tab: Int, Identifiable, Hashable {
|
||||||
var iconName: String {
|
var iconName: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .timeline:
|
case .timeline:
|
||||||
return "rectangle.on.rectangle"
|
return "rectangle.stack"
|
||||||
case .trending:
|
case .trending:
|
||||||
return "chart.line.uptrend.xyaxis"
|
return "chart.line.uptrend.xyaxis"
|
||||||
case .local:
|
case .local:
|
||||||
|
|
|
@ -27,7 +27,7 @@ public extension ServerFilter.Context {
|
||||||
var iconName: String {
|
var iconName: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .home:
|
case .home:
|
||||||
return "rectangle.on.rectangle"
|
return "rectangle.stack"
|
||||||
case .notifications:
|
case .notifications:
|
||||||
return "bell"
|
return "bell"
|
||||||
case .public:
|
case .public:
|
||||||
|
|
|
@ -17,6 +17,7 @@ struct StatusEditorAccessoryView: View {
|
||||||
@State private var isLanguageSheetDisplayed: Bool = false
|
@State private var isLanguageSheetDisplayed: Bool = false
|
||||||
@State private var isCustomEmojisSheetDisplay: Bool = false
|
@State private var isCustomEmojisSheetDisplay: Bool = false
|
||||||
@State private var languageSearch: String = ""
|
@State private var languageSearch: String = ""
|
||||||
|
@State private var isLoadingAIRequest: Bool = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
|
@ -77,6 +78,10 @@ struct StatusEditorAccessoryView: View {
|
||||||
Image(systemName: "globe")
|
Image(systemName: "globe")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if preferences.isOpenAIEnabled {
|
||||||
|
AIMenu.disabled(!viewModel.canPost)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, .layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
}
|
}
|
||||||
|
@ -110,6 +115,36 @@ struct StatusEditorAccessoryView: View {
|
||||||
Text(isoCode.uppercased())
|
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 {
|
private var languageSheetView: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
|
|
|
@ -22,7 +22,6 @@ public struct StatusEditorView: View {
|
||||||
@FocusState private var isSpoilerTextFocused: Bool
|
@FocusState private var isSpoilerTextFocused: Bool
|
||||||
|
|
||||||
@State private var isDismissAlertPresented: Bool = false
|
@State private var isDismissAlertPresented: Bool = false
|
||||||
@State private var isLoadingAIRequest: Bool = false
|
|
||||||
|
|
||||||
public init(mode: StatusEditorViewModel.Mode) {
|
public init(mode: StatusEditorViewModel.Mode) {
|
||||||
_viewModel = StateObject(wrappedValue: .init(mode: mode))
|
_viewModel = StateObject(wrappedValue: .init(mode: mode))
|
||||||
|
@ -101,12 +100,6 @@ public struct StatusEditorView: View {
|
||||||
Text(viewModel.postingError ?? "")
|
Text(viewModel.postingError ?? "")
|
||||||
})
|
})
|
||||||
.toolbar {
|
.toolbar {
|
||||||
if preferences.isOpenAIEnabled {
|
|
||||||
ToolbarItem(placement: .navigationBarTrailing) {
|
|
||||||
AIMenu
|
|
||||||
.disabled(!viewModel.canPost)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ToolbarItem(placement: .navigationBarTrailing) {
|
ToolbarItem(placement: .navigationBarTrailing) {
|
||||||
Button {
|
Button {
|
||||||
Task {
|
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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue