2022-12-31 08:10:27 +00:00
|
|
|
import SwiftUI
|
|
|
|
import DesignSystem
|
|
|
|
import PhotosUI
|
|
|
|
import Models
|
|
|
|
import Env
|
|
|
|
|
|
|
|
struct StatusEditorAccessoryView: View {
|
|
|
|
@EnvironmentObject private var currentInstance: CurrentInstance
|
|
|
|
|
|
|
|
@FocusState<Bool>.Binding var isSpoilerTextFocused: Bool
|
|
|
|
@ObservedObject var viewModel: StatusEditorViewModel
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
VStack(spacing: 0) {
|
|
|
|
Divider()
|
|
|
|
HStack(alignment: .center, spacing: 16) {
|
|
|
|
PhotosPicker(selection: $viewModel.selectedMedias,
|
|
|
|
matching: .images) {
|
|
|
|
Image(systemName: "photo.fill.on.rectangle.fill")
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
viewModel.insertStatusText(text: " @")
|
|
|
|
} label: {
|
|
|
|
Image(systemName: "at")
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
viewModel.insertStatusText(text: " #")
|
|
|
|
} label: {
|
|
|
|
Image(systemName: "number")
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
withAnimation {
|
|
|
|
viewModel.spoilerOn.toggle()
|
|
|
|
}
|
|
|
|
isSpoilerTextFocused.toggle()
|
|
|
|
} label: {
|
|
|
|
Image(systemName: viewModel.spoilerOn ? "exclamationmark.triangle.fill": "exclamationmark.triangle")
|
|
|
|
}
|
|
|
|
|
|
|
|
visibilityMenu
|
|
|
|
|
|
|
|
Spacer()
|
|
|
|
|
|
|
|
characterCountView
|
|
|
|
}
|
|
|
|
.frame(height: 20)
|
2023-01-03 06:41:29 +00:00
|
|
|
.padding(.horizontal, .layoutPadding)
|
2022-12-31 08:10:27 +00:00
|
|
|
.padding(.vertical, 12)
|
|
|
|
.background(.ultraThinMaterial)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private var characterCountView: some View {
|
|
|
|
Text("\((currentInstance.instance?.configuration.statuses.maxCharacters ?? 500) - viewModel.statusText.string.utf16.count)")
|
|
|
|
.foregroundColor(.gray)
|
|
|
|
.font(.callout)
|
|
|
|
}
|
|
|
|
|
|
|
|
private var visibilityMenu: some View {
|
|
|
|
Menu {
|
2023-01-04 17:37:58 +00:00
|
|
|
Section("Post visibility") {
|
|
|
|
ForEach(Models.Visibility.allCases, id: \.self) { visibility in
|
|
|
|
Button {
|
|
|
|
viewModel.visibility = visibility
|
|
|
|
} label: {
|
|
|
|
Label(visibility.title, systemImage: visibility.iconName)
|
|
|
|
}
|
2022-12-31 08:10:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} label: {
|
|
|
|
Image(systemName: viewModel.visibility.iconName)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|