mirror of
https://github.com/otaviocc/Triton.git
synced 2026-01-30 04:04:27 +00:00
Break EditorView into smaller methods
This commit is contained in:
parent
d4aecbe8ed
commit
b47c388351
1 changed files with 46 additions and 32 deletions
|
|
@ -53,50 +53,21 @@ struct EditorView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
// swiftlint:disable:next function_body_length
|
|
||||||
private func makeSidebarView() -> some View {
|
private func makeSidebarView() -> some View {
|
||||||
Grid(alignment: .leading, horizontalSpacing: 16, verticalSpacing: 16) {
|
Grid(alignment: .leading, horizontalSpacing: 16, verticalSpacing: 16) {
|
||||||
GridRow(alignment: .firstTextBaseline) {
|
GridRow(alignment: .firstTextBaseline) {
|
||||||
Text("Date")
|
makeDatePicker()
|
||||||
.gridColumnAlignment(.trailing)
|
|
||||||
|
|
||||||
DatePicker(
|
|
||||||
selection: $viewModel.date,
|
|
||||||
displayedComponents: [.date]
|
|
||||||
) {}
|
|
||||||
.help("Select publication date")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GridRow(alignment: .firstTextBaseline) {
|
GridRow(alignment: .firstTextBaseline) {
|
||||||
Text("Time")
|
makeTimePicker()
|
||||||
.gridColumnAlignment(.trailing)
|
|
||||||
|
|
||||||
DatePicker(
|
|
||||||
selection: $viewModel.date,
|
|
||||||
displayedComponents: [.hourAndMinute]
|
|
||||||
) {}
|
|
||||||
.help("Select publication time")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Divider()
|
Divider()
|
||||||
.foregroundStyle(Color.accentColor)
|
.foregroundStyle(Color.accentColor)
|
||||||
|
|
||||||
GridRow(alignment: .firstTextBaseline) {
|
GridRow(alignment: .firstTextBaseline) {
|
||||||
Text("Status")
|
makeStatusPicker()
|
||||||
.gridColumnAlignment(.trailing)
|
|
||||||
|
|
||||||
Picker(
|
|
||||||
selection: $viewModel.status,
|
|
||||||
content: {
|
|
||||||
ForEach(WeblogEntryStatus.allCases) { status in
|
|
||||||
Text(status.displayName)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
label: { EmptyView() }
|
|
||||||
)
|
|
||||||
.pickerStyle(.radioGroup)
|
|
||||||
.labelsHidden()
|
|
||||||
.help("Select publication visibility")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Divider()
|
Divider()
|
||||||
|
|
@ -117,6 +88,49 @@ struct EditorView: View {
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private func makeDatePicker() -> some View {
|
||||||
|
Text("Date")
|
||||||
|
.gridColumnAlignment(.trailing)
|
||||||
|
|
||||||
|
DatePicker(
|
||||||
|
selection: $viewModel.date,
|
||||||
|
displayedComponents: [.date]
|
||||||
|
) {}
|
||||||
|
.help("Select publication date")
|
||||||
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private func makeTimePicker() -> some View {
|
||||||
|
Text("Time")
|
||||||
|
.gridColumnAlignment(.trailing)
|
||||||
|
|
||||||
|
DatePicker(
|
||||||
|
selection: $viewModel.date,
|
||||||
|
displayedComponents: [.hourAndMinute]
|
||||||
|
) {}
|
||||||
|
.help("Select publication time")
|
||||||
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private func makeStatusPicker() -> some View {
|
||||||
|
Text("Status")
|
||||||
|
.gridColumnAlignment(.trailing)
|
||||||
|
|
||||||
|
Picker(
|
||||||
|
selection: $viewModel.status,
|
||||||
|
content: {
|
||||||
|
ForEach(WeblogEntryStatus.allCases) { status in
|
||||||
|
Text(status.displayName)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
label: { EmptyView() }
|
||||||
|
)
|
||||||
|
.pickerStyle(.radioGroup)
|
||||||
|
.labelsHidden()
|
||||||
|
.help("Select publication visibility")
|
||||||
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func makeTagInputView() -> some View {
|
private func makeTagInputView() -> some View {
|
||||||
TextField("Add tag", text: $viewModel.tagInput)
|
TextField("Add tag", text: $viewModel.tagInput)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue