-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add options for measurements in Settings view (#364)
* add options for measurements in settings view * PR Suggestions Moving around the section for the units and small fixes in the MeasurementSystem --------- Co-authored-by: Omar Hegazy <[email protected]> Co-authored-by: Mikaela Caron <[email protected]>
- Loading branch information
1 parent
c210590
commit beb4704
Showing
5 changed files
with
88 additions
and
0 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
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
42 changes: 42 additions & 0 deletions
42
Basic-Car-Maintenance/Shared/Utilities/MeasurementSystem.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,42 @@ | ||
// | ||
// MeasurementSystem.swift | ||
// Basic-Car-Maintenance | ||
// | ||
// https://github.com/mikaelacaron/Basic-Car-Maintenance | ||
// See LICENSE for license information. | ||
// | ||
|
||
import SwiftUI | ||
|
||
enum MeasurementSystem: String, Identifiable, CaseIterable { | ||
case imperial | ||
case metric | ||
|
||
var id: String { | ||
return rawValue | ||
} | ||
|
||
var title: LocalizedStringResource { | ||
switch self { | ||
case .imperial: | ||
return LocalizedStringResource( | ||
"Imperial", | ||
defaultValue: "Imperial", | ||
comment: "Imperial unit system" | ||
) | ||
case .metric: | ||
return LocalizedStringResource("Metric", defaultValue: "Metric", comment: "Metric unit system") | ||
} | ||
} | ||
|
||
static var userDefault: MeasurementSystem { | ||
switch Locale.current.measurementSystem { | ||
case .uk: | ||
return .metric | ||
case .us: | ||
return .imperial | ||
default: | ||
return .metric | ||
} | ||
} | ||
} |