-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
275 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
CriticalMapsKit/Sources/SettingsFeature/RideEventRadius.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import ComposableArchitecture | ||
import Foundation | ||
import L10n | ||
import SharedModels | ||
import SwiftUI | ||
|
||
public struct RideEventRadius: ReducerProtocol { | ||
public init() {} | ||
|
||
public struct State: Equatable, Identifiable, Sendable, Codable { | ||
public let id: UUID | ||
public let eventDistance: EventDistance | ||
@BindingState public var isSelected = false | ||
|
||
public init(id: UUID = .init(), eventDistance: EventDistance, isSelected: Bool) { | ||
self.id = id | ||
self.eventDistance = eventDistance | ||
self.isSelected = isSelected | ||
} | ||
} | ||
|
||
public enum Action: BindableAction, Equatable, Sendable { | ||
case binding(BindingAction<State>) | ||
} | ||
|
||
public var body: some ReducerProtocol<State, Action> { | ||
BindingReducer() | ||
} | ||
} | ||
|
||
public struct RideEventRadiusView: View { | ||
let store: StoreOf<RideEventRadius> | ||
|
||
public var body: some View { | ||
WithViewStore(self.store, observe: { $0 }) { viewStore in | ||
SettingsRow { | ||
Button( | ||
action: { viewStore.send(.set(\.$isSelected, true)) }, | ||
label: { | ||
HStack(spacing: .grid(3)) { | ||
Text(String(viewStore.eventDistance.displayValue)) | ||
.accessibility(label: Text(viewStore.eventDistance.displayValue)) | ||
.padding(.vertical, .grid(2)) | ||
Spacer() | ||
if viewStore.isSelected { | ||
Image(systemName: "checkmark.circle.fill") | ||
.accessibilityRepresentation { | ||
Text(L10n.A11y.General.selected) | ||
} | ||
} | ||
} | ||
.accessibilityElement(children: .combine) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.