-
-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reformat odometer view * Small PR udpates --------- Co-authored-by: Mikaela Caron <mikaelacaron@gmail.com>
- Loading branch information
1 parent
7595807
commit 5e5ed93
Showing
3 changed files
with
73 additions
and
99 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
34 changes: 34 additions & 0 deletions
34
Basic-Car-Maintenance/Shared/Odometer/Views/OdometerRowView.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,34 @@ | ||
// | ||
// OdometerRowView.swift | ||
// Basic-Car-Maintenance | ||
// | ||
// https://github.com/mikaelacaron/Basic-Car-Maintenance | ||
// See LICENSE for license information. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct OdometerRowView: View { | ||
let reading: OdometerReading | ||
let vehicleName: String? | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 8) { | ||
Text("\(vehicleName ?? "No Name")") | ||
.font(.title3) | ||
|
||
VStack(alignment: .leading, spacing: 4) { | ||
Text("Mileage: \(reading.distance) \(reading.isMetric ? "km" : "mi")") | ||
.foregroundStyle(.gray) | ||
|
||
Text("Recorded On: \(reading.date.formatted(date: .abbreviated, time: .omitted))") | ||
.foregroundStyle(.gray) | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
OdometerRowView(reading: .init(date: .now, distance: 1000, isMetric: true, vehicleID: "1234"), | ||
vehicleName: "Sample Vehicle Name") | ||
} |
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