Add detent support for composer

This commit is contained in:
Thomas Ricouard 2024-01-05 18:04:15 +01:00
parent fcf00796b8
commit d07427b919

View File

@ -16,6 +16,7 @@ public struct StatusEditorView: View {
@Environment(CurrentAccount.self) private var currentAccount
@Environment(Theme.self) private var theme
@State private var presentationDetent: PresentationDetent = .large
@State private var mainSEVM: StatusEditorViewModel
@State private var followUpSEVMs: [StatusEditorViewModel] = []
@FocusState private var isSpoilerTextFocused: UUID? // connect CoreEditor and StatusEditorAccessoryView
@ -85,8 +86,10 @@ public struct StatusEditorView: View {
}
#else
.safeAreaInset(edge: .bottom) {
if presentationDetent == .large || presentationDetent == .medium {
StatusEditorAccessoryView(isSpoilerTextFocused: $isSpoilerTextFocused, focusedSEVM: focusedSEVM, followUpSEVMs: $followUpSEVMs)
}
}
#endif
.accessibilitySortPriority(1) // Ensure that all elements inside the `ScrollView` occur earlier than the accessory views
.navigationTitle(focusedSEVM.mode.title)
@ -138,5 +141,7 @@ public struct StatusEditorView: View {
.sheet(item: $editingMediaContainer) { container in
StatusEditorMediaEditView(viewModel: focusedSEVM, container: container)
}
.presentationDetents([.large, .medium, .height(50)], selection: $presentationDetent)
.presentationBackgroundInteraction(.enabled(upThrough: .medium))
}
}