mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-09-02 08:03:47 +00:00
composer tweaks
This commit is contained in:
parent
6435b40a51
commit
e5bb521502
3 changed files with 35 additions and 19 deletions
|
@ -60,8 +60,6 @@ struct StatusEditorAccessoryView: View {
|
||||||
#if os(visionOS)
|
#if os(visionOS)
|
||||||
HStack(spacing: 8) {
|
HStack(spacing: 8) {
|
||||||
actionsView
|
actionsView
|
||||||
characterCountView
|
|
||||||
.padding(.leading, 16)
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
|
@ -71,8 +69,6 @@ struct StatusEditorAccessoryView: View {
|
||||||
.padding(.horizontal, .layoutPadding)
|
.padding(.horizontal, .layoutPadding)
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
characterCountView
|
|
||||||
.padding(.trailing, .layoutPadding)
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,6 +225,18 @@ struct StatusEditorAccessoryView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
viewModel.insertStatusText(text: "#")
|
||||||
|
} label: {
|
||||||
|
Image(systemName: "number")
|
||||||
|
}
|
||||||
|
|
||||||
|
Button {
|
||||||
|
viewModel.insertStatusText(text: "@")
|
||||||
|
} label: {
|
||||||
|
Image(systemName: "at")
|
||||||
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
isLanguageSheetDisplayed.toggle()
|
isLanguageSheetDisplayed.toggle()
|
||||||
} label: {
|
} label: {
|
||||||
|
@ -433,20 +441,6 @@ struct StatusEditorAccessoryView: View {
|
||||||
.presentationDetents([.medium])
|
.presentationDetents([.medium])
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
|
||||||
private var characterCountView: some View {
|
|
||||||
let value = (currentInstance.instance?.configuration?.statuses.maxCharacters ?? 500) + focusedSEVM.statusTextCharacterLength
|
|
||||||
|
|
||||||
Text("\(value)")
|
|
||||||
.foregroundColor(value < 0 ? .red : .secondary)
|
|
||||||
.font(.scaledCallout)
|
|
||||||
.accessibilityLabel("accessibility.editor.button.characters-remaining")
|
|
||||||
.accessibilityValue("\(value)")
|
|
||||||
.accessibilityRemoveTraits(.isStaticText)
|
|
||||||
.accessibilityAddTraits(.updatesFrequently)
|
|
||||||
.accessibilityRespondsToUserInteraction(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
private var recentlyUsedLanguages: [Language] {
|
private var recentlyUsedLanguages: [Language] {
|
||||||
preferences.recentlyUsedLanguages.compactMap { isoCode in
|
preferences.recentlyUsedLanguages.compactMap { isoCode in
|
||||||
Language.allAvailableLanguages.first { $0.isoCode == isoCode }
|
Language.allAvailableLanguages.first { $0.isoCode == isoCode }
|
||||||
|
|
|
@ -19,6 +19,7 @@ struct StatusEditorCoreView: View {
|
||||||
@Environment(Theme.self) private var theme
|
@Environment(Theme.self) private var theme
|
||||||
@Environment(UserPreferences.self) private var preferences
|
@Environment(UserPreferences.self) private var preferences
|
||||||
@Environment(CurrentAccount.self) private var currentAccount
|
@Environment(CurrentAccount.self) private var currentAccount
|
||||||
|
@Environment(CurrentInstance.self) private var currentInstance
|
||||||
@Environment(AppAccountsManager.self) private var appAccounts
|
@Environment(AppAccountsManager.self) private var appAccounts
|
||||||
@Environment(Client.self) private var client
|
@Environment(Client.self) private var client
|
||||||
#if targetEnvironment(macCatalyst)
|
#if targetEnvironment(macCatalyst)
|
||||||
|
@ -42,6 +43,7 @@ struct StatusEditorCoreView: View {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
accountHeaderView
|
accountHeaderView
|
||||||
textInput
|
textInput
|
||||||
|
characterCountView
|
||||||
StatusEditorMediaView(viewModel: viewModel, editingMediaContainer: $editingMediaContainer)
|
StatusEditorMediaView(viewModel: viewModel, editingMediaContainer: $editingMediaContainer)
|
||||||
embeddedStatus
|
embeddedStatus
|
||||||
pollView
|
pollView
|
||||||
|
@ -139,6 +141,25 @@ struct StatusEditorCoreView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
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)
|
||||||
|
.accessibilityLabel("accessibility.editor.button.characters-remaining")
|
||||||
|
.accessibilityValue("\(value)")
|
||||||
|
.accessibilityRemoveTraits(.isStaticText)
|
||||||
|
.accessibilityAddTraits(.updatesFrequently)
|
||||||
|
.accessibilityRespondsToUserInteraction(false)
|
||||||
|
.padding(.trailing, 8)
|
||||||
|
.padding(.bottom, 8)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func setupViewModel() {
|
private func setupViewModel() {
|
||||||
viewModel.client = client
|
viewModel.client = client
|
||||||
viewModel.currentAccount = currentAccount.account
|
viewModel.currentAccount = currentAccount.account
|
||||||
|
|
|
@ -235,6 +235,7 @@ import SwiftUI
|
||||||
string.mutableString.insert(text, at: selectedRange.location)
|
string.mutableString.insert(text, at: selectedRange.location)
|
||||||
statusText = string
|
statusText = string
|
||||||
selectedRange = NSRange(location: selectedRange.location + text.utf16.count, length: 0)
|
selectedRange = NSRange(location: selectedRange.location + text.utf16.count, length: 0)
|
||||||
|
processText()
|
||||||
}
|
}
|
||||||
|
|
||||||
func replaceTextWith(text: String, inRange: NSRange) {
|
func replaceTextWith(text: String, inRange: NSRange) {
|
||||||
|
|
Loading…
Reference in a new issue