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
|
||||
// swiftlint:disable:next function_body_length
|
||||
private func makeSidebarView() -> some View {
|
||||
Grid(alignment: .leading, horizontalSpacing: 16, verticalSpacing: 16) {
|
||||
GridRow(alignment: .firstTextBaseline) {
|
||||
Text("Date")
|
||||
.gridColumnAlignment(.trailing)
|
||||
|
||||
DatePicker(
|
||||
selection: $viewModel.date,
|
||||
displayedComponents: [.date]
|
||||
) {}
|
||||
.help("Select publication date")
|
||||
makeDatePicker()
|
||||
}
|
||||
|
||||
GridRow(alignment: .firstTextBaseline) {
|
||||
Text("Time")
|
||||
.gridColumnAlignment(.trailing)
|
||||
|
||||
DatePicker(
|
||||
selection: $viewModel.date,
|
||||
displayedComponents: [.hourAndMinute]
|
||||
) {}
|
||||
.help("Select publication time")
|
||||
makeTimePicker()
|
||||
}
|
||||
|
||||
Divider()
|
||||
.foregroundStyle(Color.accentColor)
|
||||
|
||||
GridRow(alignment: .firstTextBaseline) {
|
||||
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")
|
||||
makeStatusPicker()
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
|
@ -117,6 +88,49 @@ struct EditorView: View {
|
|||
.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
|
||||
private func makeTagInputView() -> some View {
|
||||
TextField("Add tag", text: $viewModel.tagInput)
|
||||
|
|
|
|||
Loading…
Reference in a new issue