Skip to content

Commit

Permalink
feat: 🎸 generate duration picker view with sourcery
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyu0722 committed Nov 21, 2022
1 parent 2b83f2c commit 840457f
Show file tree
Hide file tree
Showing 17 changed files with 307 additions and 568 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,33 @@ import FioriSwiftUICore
import SwiftUI

struct DurationPickerExample: View {
@State var dateSelection = Date()
@State var selection1: Int = 0
@State var selection2: Int = 244
@State var selection3: Int = 100

var formatter: MeasurementFormatter {
let formatter = MeasurementFormatter()
formatter.locale = Locale(identifier: "zh-CN")
formatter.unitStyle = .long
formatter.unitOptions = .providedUnit
return formatter
}

var body: some View {
List {
HStack {
Spacer()
DurationPicker(0, minuteInterval: 4)
}

HStack {
Spacer()
DatePicker("System Date Picker", selection: $dateSelection, displayedComponents: .hourAndMinute)
.labelsHidden()
}

HStack {
DurationPicker(145, minuteInterval: 2)
Spacer()
}

HStack {
DatePicker("System Date Picker", selection: $dateSelection, displayedComponents: .hourAndMinute)
.labelsHidden()
Spacer()
}

HStack {
Spacer()
DurationPicker(0, minuteInterval: 7)
Spacer()
}

HStack {
Spacer()
DatePicker("System Date Picker", selection: $dateSelection, displayedComponents: .hourAndMinute)
.labelsHidden()
Spacer()
}

HStack {
Spacer()
DurationPicker(0, minuteInterval: 4)
}

HStack {
DurationPicker(145, minuteInterval: 2)
Spacer()
}

HStack {
Spacer()
DurationPicker(0, minuteInterval: 7)
Spacer()
}
HStack {
Spacer()
DatePicker("System Date Picker", selection: $dateSelection, displayedComponents: .hourAndMinute)
.labelsHidden()
Spacer()
}
VStack {
DurationPicker(selection: $selection1)
Divider()
Text("Total \(selection1) minutes")
Text("\(selection1 / 60) Hrs, \(selection1 % 60) Min")

DurationPicker(selection: $selection2, minimumMinutes: 1, minuteInterval: 2)
Divider()
Text("Total \(selection2) minutes")

DurationPicker(selection: $selection3, maximumMinutes: 120, minimumMinutes: 60, minuteInterval: 2)
.measurementFormatter(formatter)
Divider()
Text("Total \(selection3) minutes")
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions Sources/FioriSwiftUICore/Components/MultiPropertyComponents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,25 @@ internal protocol _KpiProgress: KpiComponent, _ComponentMultiPropGenerating {
internal protocol _ProgressIndicator: _ComponentMultiPropGenerating {
var progressIndicatorText_: String? { get }
}

internal protocol _DurationPicker: _ComponentMultiPropGenerating, AnyObject {
// sourcery: bindingProperty
// sourcery: no_view
var selection: Int { get set }

// sourcery: no_view
// sourcery: default.value = 1439
var maximumMinutes: Int { get set }

// sourcery: no_view
// sourcery: default.value = 0
var minimumMinutes: Int { get set }

// sourcery: no_view
// sourcery: default.value = 1
var minuteInterval: Int { get set }

// sourcery: no_view
// sourcery: default.value = nil
var measurementFormatter: MeasurementFormatter? { get set }
}
103 changes: 0 additions & 103 deletions Sources/FioriSwiftUICore/DurationPicker/DurationPicker.swift

This file was deleted.

Loading

0 comments on commit 840457f

Please sign in to comment.