Post editor: Replace visibility menu with a bottom sheet to close #58
This commit is contained in:
parent
77ad9afb85
commit
54ac3d5adb
|
@ -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 {
|
||||||
Section("Post visibility") {
|
isPrivacySheetDisplayed = true
|
||||||
ForEach(Models.Visibility.allCases, id: \.self) { visibility in
|
|
||||||
Button {
|
|
||||||
viewModel.visibility = visibility
|
|
||||||
} label: {
|
|
||||||
Label(visibility.title, systemImage: visibility.iconName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} label: {
|
} label: {
|
||||||
Image(systemName: viewModel.visibility.iconName)
|
Image(systemName: viewModel.visibility.iconName)
|
||||||
}
|
}
|
||||||
|
.sheet(isPresented: $isPrivacySheetDisplayed) {
|
||||||
|
Form {
|
||||||
|
Section("Post visibility") {
|
||||||
|
ForEach(Models.Visibility.allCases, id: \.self) { visibility in
|
||||||
|
Button {
|
||||||
|
viewModel.visibility = visibility
|
||||||
|
isPrivacySheetDisplayed = false
|
||||||
|
} label: {
|
||||||
|
Label(visibility.title, systemImage: visibility.iconName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.listRowBackground(theme.primaryBackgroundColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.presentationDetents([.height(300)])
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.background(theme.secondaryBackgroundColor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue