forked from LoopKit/Loop
-
Notifications
You must be signed in to change notification settings - Fork 8
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
7 changed files
with
70 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// PresetsHistoryView.swift | ||
// Loop | ||
// | ||
// Created by Cameron Ingham on 11/27/24. | ||
// Copyright © 2024 LoopKit Authors. All rights reserved. | ||
// | ||
|
||
import LoopKit | ||
import SwiftUI | ||
|
||
struct PresetsHistoryView: View { | ||
|
||
@State var history: TemporaryScheduleOverrideHistory | ||
|
||
init () { | ||
self.history = TemporaryScheduleOverrideHistoryContainer.shared.fetch() | ||
} | ||
|
||
let formatter: DateComponentsFormatter = { | ||
let formatter = DateComponentsFormatter() | ||
formatter.allowedUnits = [.hour, .minute, .second] | ||
formatter.unitsStyle = .short | ||
return formatter | ||
}() | ||
|
||
var body: some View { | ||
List { | ||
Section("Recent Events") { | ||
ForEach(history.recentEvents.sorted(by: { $0.override.actualEndDate > $1.override.actualEndDate }), id: \.self) { recentEvent in | ||
|
||
let scheduledDuration = recentEvent.override.duration.timeInterval | ||
let actualDuration = recentEvent.override.actualDuration.timeInterval | ||
|
||
let value = scheduledDuration == actualDuration ? "\(formatter.string(from: scheduledDuration) ?? "")" : "\(formatter.string(from: actualDuration) ?? "") / \(formatter.string(from: scheduledDuration) ?? "")" | ||
|
||
LabeledContent { | ||
Text(value) | ||
} label: { | ||
Text(recentEvent.override.presetId) | ||
|
||
Text(recentEvent.override.startDate.formatted(date: .abbreviated, time: .shortened)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
PresetsHistoryView() | ||
} |
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