Layout adjustments to the editor

This commit is contained in:
Thomas Ricouard 2024-01-06 20:02:16 +01:00
parent 7eb382c052
commit ca9dd5b469
5 changed files with 84 additions and 78 deletions

View file

@ -1931,115 +1931,115 @@
"localizations" : {
"be" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Папярэджанне пра спойлер"
}
},
"ca" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Spoiler warning"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Inhaltswarnung"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Spoiler warning"
"value" : "Content warning"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "Spoiler warning"
"value" : "Content warning"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Advertencia"
}
},
"eu" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Edukiari buruzko oharra"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Alerte spoiler"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Avviso di Spoiler"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "ネタバレを警告"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "열람 주의 문구"
}
},
"nb" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Spoiler advarsel"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Spoilerwaarschuwing"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Ostrzeżenie o spoilerze"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Aviso de spoiler"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Spoiler uyarısı"
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Увага! Спойлер."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "剧透警告"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "劇透警告"
}
}
@ -64977,115 +64977,115 @@
"localizations" : {
"be" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Тэкст спойлера"
}
},
"ca" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Escriviu l'espòiler"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Inhaltswarnung"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Spoiler Text"
"value" : "Content warning"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "Spoiler Text"
"value" : "Content Warning"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Escribe tu advertencia aquí"
}
},
"eu" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Edukiari buruzko oharra"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Texte spoilé"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Testo spoiler"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "ネタバレ"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "열람 주의 문구"
}
},
"nb" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Spoilertekst"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Spoilertekst"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Tekst spoilera"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Texto de Spoiler"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Spoiler Yazısı"
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Спойлер"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "剧透警告"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "劇透警告"
}
}

View file

@ -20,7 +20,6 @@ extension StatusEditor {
let focusedSEVM: ViewModel
@Binding var followUpSEVMs: [ViewModel]
@State private var isDraftsSheetDisplayed: Bool = false
@State private var isLanguageSheetDisplayed: Bool = false
@State private var isCustomEmojisSheetDisplay: Bool = false
@State private var languageSearch: String = ""
@ -188,24 +187,6 @@ extension StatusEditor {
}
.accessibilityLabel("accessibility.editor.button.spoiler")
if !viewModel.mode.isInShareExtension {
Button {
isDraftsSheetDisplayed = true
} label: {
Image(systemName: "archivebox")
}
.accessibilityLabel("accessibility.editor.button.drafts")
.popover(isPresented: $isDraftsSheetDisplayed) {
if UIDevice.current.userInterfaceIdiom == .phone {
draftsListView
.presentationDetents([.medium])
} else {
draftsListView
.frame(width: 400, height: 500)
}
}
}
if !viewModel.customEmojiContainer.isEmpty {
Button {
isCustomEmojisSheetDisplay = true
@ -292,16 +273,6 @@ extension StatusEditor {
}
#endif
private var draftsListView: some View {
DraftsListView(selectedDraft: .init(get: {
nil
}, set: { draft in
if let draft {
focusedSEVM.insertStatusText(text: draft.content)
}
}))
}
@ViewBuilder
private func languageTextView(isoCode: String, nativeName: String?, name: String?) -> some View {
if let nativeName, let name {

View file

@ -147,7 +147,6 @@ extension StatusEditor {
private var characterCountView: some View {
let value = (currentInstance.instance?.configuration?.statuses.maxCharacters ?? 500) + viewModel.statusTextCharacterLength
HStack {
Spacer()
Text("\(value)")
.foregroundColor(value < 0 ? .red : .secondary)
.font(.scaledCallout)
@ -156,8 +155,9 @@ extension StatusEditor {
.accessibilityRemoveTraits(.isStaticText)
.accessibilityAddTraits(.updatesFrequently)
.accessibilityRespondsToUserInteraction(false)
.padding(.trailing, 8)
.padding(.leading, .layoutPadding)
.padding(.bottom, 8)
Spacer()
}
}

View file

@ -95,7 +95,9 @@ extension StatusEditor {
.accessibilitySortPriority(1) // Ensure that all elements inside the `ScrollView` occur earlier than the accessory views
.navigationTitle(focusedSEVM.mode.title)
.navigationBarTitleDisplayMode(.inline)
.toolbar { ToolbarItems(mainSEVM: mainSEVM, followUpSEVMs: followUpSEVMs) }
.toolbar { ToolbarItems(mainSEVM: mainSEVM,
focusedSEVM: focusedSEVM,
followUpSEVMs: followUpSEVMs) }
.toolbarBackground(.visible, for: .navigationBar)
.alert(
"status.error.posting.title",
@ -142,8 +144,8 @@ extension StatusEditor {
.sheet(item: $editingMediaContainer) { container in
StatusEditor.MediaEditView(viewModel: focusedSEVM, container: container)
}
.presentationDetents([.large, .medium, .height(50)], selection: $presentationDetent)
.presentationBackgroundInteraction(.enabled(upThrough: .medium))
.presentationDetents([.large, .height(100)], selection: $presentationDetent)
.presentationBackgroundInteraction(.enabled)
}
}

View file

@ -2,17 +2,23 @@ import Env
import Models
import StoreKit
import SwiftUI
import DesignSystem
extension StatusEditor {
@MainActor
struct ToolbarItems: ToolbarContent {
@State private var isLanguageConfirmPresented = false
@State private var isDismissAlertPresented: Bool = false
@State private var isDraftsSheetDisplayed: Bool = false
let mainSEVM: ViewModel
let focusedSEVM: ViewModel
let followUpSEVMs: [ViewModel]
@Environment(\.modelContext) private var context
@Environment(UserPreferences.self) private var preferences
@Environment(Theme.self) private var theme
#if targetEnvironment(macCatalyst)
@Environment(\.dismissWindow) private var dismissWindow
#else
@ -20,6 +26,26 @@ extension StatusEditor {
#endif
var body: some ToolbarContent {
if !mainSEVM.mode.isInShareExtension {
ToolbarItem(placement: .navigationBarTrailing) {
Button {
isDraftsSheetDisplayed = true
} label: {
Text("status.editor.drafts.navigation-title")
}
.accessibilityLabel("accessibility.editor.button.drafts")
.popover(isPresented: $isDraftsSheetDisplayed) {
if UIDevice.current.userInterfaceIdiom == .phone {
draftsListView
.presentationDetents([.medium])
} else {
draftsListView
.frame(width: 400, height: 500)
}
}
}
}
ToolbarItem(placement: .navigationBarTrailing) {
Button {
Task {
@ -31,13 +57,10 @@ extension StatusEditor {
}
}
} label: {
if mainSEVM.isPosting {
ProgressView()
} else {
Text("status.action.post").bold()
}
Text("status.action.post").bold()
}
.disabled(!mainSEVM.canPost)
.buttonStyle(.borderedProminent)
.disabled(!mainSEVM.canPost || mainSEVM.isPosting)
.keyboardShortcut(.return, modifiers: .command)
.confirmationDialog("", isPresented: $isLanguageConfirmPresented, actions: {
languageConfirmationDialog
@ -137,5 +160,15 @@ extension StatusEditor {
EmptyView()
}
}
private var draftsListView: some View {
DraftsListView(selectedDraft: .init(get: {
nil
}, set: { draft in
if let draft {
focusedSEVM.insertStatusText(text: draft.content)
}
}))
}
}
}