Editor: Cleanup focus state

This commit is contained in:
Thomas Ricouard 2024-01-21 11:13:47 +01:00
parent 3c82af0273
commit fb944f9c48
3 changed files with 4 additions and 10 deletions

View File

@ -16,7 +16,6 @@ extension StatusEditor {
@Environment(CurrentInstance.self) private var currentInstance
@Environment(\.colorScheme) private var colorScheme
@FocusState<UUID?>.Binding var isSpoilerTextFocused: UUID?
let focusedSEVM: ViewModel
@Binding var followUpSEVMs: [ViewModel]

View File

@ -24,7 +24,7 @@ extension StatusEditor {
@Binding var followUpSEVMs: [ViewModel]
@Binding var editingMediaContainer: MediaContainer?
@FocusState<UUID?>.Binding var isSpoilerTextFocused: UUID?
@FocusState<UUID?> var isSpoilerTextFocused: UUID?
@FocusState<EditorFocusState?>.Binding var editorFocusState: EditorFocusState?
let assignedFocusState: EditorFocusState
let isMain: Bool

View File

@ -20,7 +20,6 @@ extension StatusEditor {
@State private var presentationDetent: PresentationDetent = .large
@State private var mainSEVM: ViewModel
@State private var followUpSEVMs: [ViewModel] = []
@FocusState private var isSpoilerTextFocused: UUID? // connect CoreEditor and StatusEditorAccessoryView
@State private var editingMediaContainer: MediaContainer?
@State private var scrollID: UUID?
@ -49,9 +48,8 @@ extension StatusEditor {
}
EditorView(
viewModel: mainSEVM,
followUpSEVMs: $followUpSEVMs,
followUpSEVMs: $followUpSEVMs,
editingMediaContainer: $editingMediaContainer,
isSpoilerTextFocused: $isSpoilerTextFocused,
editorFocusState: $editorFocusState,
assignedFocusState: .main,
isMain: true
@ -65,7 +63,6 @@ extension StatusEditor {
viewModel: sevm,
followUpSEVMs: $followUpSEVMs,
editingMediaContainer: $editingMediaContainer,
isSpoilerTextFocused: $isSpoilerTextFocused,
editorFocusState: $editorFocusState,
assignedFocusState: .followUp(index: sevm.id),
isMain: false
@ -86,15 +83,13 @@ extension StatusEditor {
}
#if os(visionOS)
.ornament(attachmentAnchor: .scene(.leading)) {
AccessoryView(isSpoilerTextFocused: $isSpoilerTextFocused,
focusedSEVM: focusedSEVM,
AccessoryView(focusedSEVM: focusedSEVM,
followUpSEVMs: $followUpSEVMs)
}
#else
.safeAreaInset(edge: .bottom) {
if presentationDetent == .large || presentationDetent == .medium {
AccessoryView(isSpoilerTextFocused: $isSpoilerTextFocused,
focusedSEVM: focusedSEVM,
AccessoryView(focusedSEVM: focusedSEVM,
followUpSEVMs: $followUpSEVMs)
}
}