Feat: Fixing equipment settings form
This commit is contained in:
19
Sources/Styleguide/EquipmentTypePicker.swift
Normal file
19
Sources/Styleguide/EquipmentTypePicker.swift
Normal file
@@ -0,0 +1,19 @@
|
||||
import SharedModels
|
||||
import SwiftUI
|
||||
|
||||
public struct EquipmentTypePicker: View {
|
||||
@Binding var selection: EquipmentType
|
||||
|
||||
public init(selection: Binding<EquipmentType>) {
|
||||
self._selection = selection
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
Picker("Equipment Type", selection: $selection) {
|
||||
ForEach(EquipmentType.allCases) {
|
||||
Text($0.description)
|
||||
.tag($0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,109 +34,3 @@ extension FlaggedView where Label == EmptyView {
|
||||
self.init(flagged: flagged) { EmptyView() }
|
||||
}
|
||||
}
|
||||
|
||||
//public struct FlaggedView: View {
|
||||
//
|
||||
// public let style: Style?
|
||||
// public let title: String
|
||||
// public let flagged: Flagged
|
||||
// public let fractionLength: Int
|
||||
//
|
||||
// public init(
|
||||
// style: Style? = nil,
|
||||
// title: String,
|
||||
// flagged: Flagged,
|
||||
// fractionLength: Int = 3
|
||||
// ) {
|
||||
// self.style = style
|
||||
// self.title = title
|
||||
// self.flagged = flagged
|
||||
// self.fractionLength = fractionLength
|
||||
// }
|
||||
//
|
||||
// public init(
|
||||
// _ title: String,
|
||||
// flagged: Flagged,
|
||||
// style: Style? = nil,
|
||||
// fractionLength: Int = 3
|
||||
// ) {
|
||||
// self.style = style
|
||||
// self.title = title
|
||||
// self.flagged = flagged
|
||||
// self.fractionLength = fractionLength
|
||||
// }
|
||||
//
|
||||
// @ViewBuilder
|
||||
// private var messageView: some View {
|
||||
// if let message = flagged.message {
|
||||
// HStack {
|
||||
// Text(flagged.projectedValue.key.title)
|
||||
// .bold()
|
||||
// .foregroundStyle(flagged.projectedValue.key.flagColor)
|
||||
//
|
||||
// Text(message)
|
||||
// .foregroundStyle(Color.secondary)
|
||||
// }
|
||||
// .font(.caption)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public var body: some View {
|
||||
// switch style {
|
||||
// case .none:
|
||||
// VStack(alignment: .leading, spacing: 8) {
|
||||
// HStack {
|
||||
// Text(title)
|
||||
// .foregroundStyle(Color.secondary)
|
||||
// Spacer()
|
||||
// Text(
|
||||
// flagged.wrappedValue,
|
||||
// format: .number.precision(.fractionLength(fractionLength))
|
||||
// )
|
||||
// Image(systemName: "flag.fill")
|
||||
// .foregroundStyle(flagged.projectedValue.key.flagColor)
|
||||
// }
|
||||
// messageView
|
||||
// }
|
||||
// case .some(.gridRow):
|
||||
// GridRow {
|
||||
// VStack(alignment: .leading, spacing: 8) {
|
||||
// Text(title)
|
||||
// .foregroundStyle(Color.secondary)
|
||||
// messageView
|
||||
// }
|
||||
//
|
||||
// Spacer()
|
||||
//
|
||||
// Text(flagged.wrappedValue, format: .number.precision(.fractionLength(fractionLength)))
|
||||
// .gridCellAnchor(.trailing)
|
||||
//
|
||||
// Image(systemName: "flag.fill")
|
||||
// .foregroundStyle(flagged.flagColor)
|
||||
// .gridCellAnchor(.trailing)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public enum Style {
|
||||
// case gridRow
|
||||
// }
|
||||
//
|
||||
// public static func gridRow(_ title: String, flagged: Flagged) -> Self {
|
||||
// .init(style: .gridRow, title: title, flagged: flagged)
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//#Preview {
|
||||
// List {
|
||||
// Grid(horizontalSpacing: 20) {
|
||||
// FlaggedView(style: .gridRow, title: "Test", flagged: .error(message: "Error message"))
|
||||
// FlaggedView(style: .gridRow, title: "Test", flagged: .init(wrappedValue: 0.5, .result(.good("Good message"))))
|
||||
// }
|
||||
//
|
||||
// FlaggedView(style: nil, title: "Test", flagged: .error(message: "Error message"))
|
||||
// FlaggedView(style: nil, title: "Test", flagged: .init(wrappedValue: 0.5, .result(.good("Good message"))))
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -44,13 +44,12 @@ public struct InfoView: View {
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
VStack(spacing: 40) {
|
||||
Text(store.bodyText)
|
||||
.font(.callout)
|
||||
.padding()
|
||||
VStack {
|
||||
TextLabel(store.bodyText)
|
||||
Spacer()
|
||||
}
|
||||
.navigationTitle(store.titleText)
|
||||
.textLabelStyle(.secondary)
|
||||
.padding(.horizontal)
|
||||
.navigationBarBackButtonHidden()
|
||||
.toolbar {
|
||||
|
||||
@@ -30,4 +30,32 @@ extension TextField where Label == Text {
|
||||
)
|
||||
}
|
||||
|
||||
public init(
|
||||
_ titleKey: LocalizedStringKey,
|
||||
value: Binding<Double>,
|
||||
fractionLength: Int,
|
||||
prompt: Text? = nil
|
||||
) {
|
||||
self.init(
|
||||
titleKey,
|
||||
value: value,
|
||||
format: .number.precision(.fractionLength(fractionLength)),
|
||||
prompt: prompt
|
||||
)
|
||||
}
|
||||
|
||||
public init<S: StringProtocol>(
|
||||
_ titleKey: S,
|
||||
value: Binding<Double>,
|
||||
fractionLength: Int,
|
||||
prompt: Text? = nil
|
||||
) {
|
||||
self.init(
|
||||
titleKey,
|
||||
value: value,
|
||||
format: .number.precision(.fractionLength(fractionLength)),
|
||||
prompt: prompt
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user