Post editor: Replace visibility menu with a bottom sheet to close #58

This commit is contained in:
Thomas Ricouard 2023-01-11 07:33:18 +01:00
parent 77ad9afb85
commit 54ac3d5adb

View file

@ -5,10 +5,12 @@ import Models
import Env import Env
struct StatusEditorAccessoryView: View { struct StatusEditorAccessoryView: View {
@EnvironmentObject private var theme: Theme
@EnvironmentObject private var currentInstance: CurrentInstance @EnvironmentObject private var currentInstance: CurrentInstance
@FocusState<Bool>.Binding var isSpoilerTextFocused: Bool @FocusState<Bool>.Binding var isSpoilerTextFocused: Bool
@ObservedObject var viewModel: StatusEditorViewModel @ObservedObject var viewModel: StatusEditorViewModel
@State private var isPrivacySheetDisplayed: Bool = false
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
@ -61,18 +63,28 @@ struct StatusEditorAccessoryView: View {
} }
private var visibilityMenu: some View { private var visibilityMenu: some View {
Menu { Button {
isPrivacySheetDisplayed = true
} label: {
Image(systemName: viewModel.visibility.iconName)
}
.sheet(isPresented: $isPrivacySheetDisplayed) {
Form {
Section("Post visibility") { Section("Post visibility") {
ForEach(Models.Visibility.allCases, id: \.self) { visibility in ForEach(Models.Visibility.allCases, id: \.self) { visibility in
Button { Button {
viewModel.visibility = visibility viewModel.visibility = visibility
isPrivacySheetDisplayed = false
} label: { } label: {
Label(visibility.title, systemImage: visibility.iconName) Label(visibility.title, systemImage: visibility.iconName)
} }
} }
.listRowBackground(theme.primaryBackgroundColor)
} }
} label: { }
Image(systemName: viewModel.visibility.iconName) .presentationDetents([.height(300)])
.scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor)
} }
} }
} }