generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
52e0d6e
commit 198ec09
Showing
18 changed files
with
645 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
public struct LogEntry: Codable, Equatable { | ||
public let scheduledTime: Date? | ||
public var event: LogEntryEvent | ||
public var date: Date | ||
public var dosage: Double | ||
|
||
|
||
public init( | ||
scheduledTime: Date?, | ||
event: LogEntryEvent, | ||
date: Date, | ||
dosage: Double | ||
) { | ||
self.scheduledTime = scheduledTime | ||
self.event = event | ||
self.date = date | ||
self.dosage = dosage | ||
} | ||
} |
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,22 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Paul Shmiedmayer on 1/28/24. | ||
// | ||
|
||
|
||
public enum LogEntryEvent: Codable { | ||
case skipped | ||
case taken | ||
|
||
|
||
public var localizedDescription: String { | ||
switch self { | ||
case .skipped: | ||
String(localized: "Skipped", bundle: .module) | ||
case .taken: | ||
String(localized: "Taken", bundle: .module) | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -53,6 +53,12 @@ | |
}, | ||
"Every other Day" : { | ||
|
||
}, | ||
"Skipped" : { | ||
|
||
}, | ||
"Taken" : { | ||
|
||
}, | ||
"Weekend" : { | ||
|
||
|
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,46 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import SpeziMedication | ||
import SwiftUI | ||
|
||
|
||
struct LogEntryEventButton: View { | ||
private let role: LogEntryEvent | ||
@Binding private var logEntryEvent: LogEntryEvent? | ||
|
||
|
||
var body: some View { | ||
Button( | ||
action: { | ||
withAnimation { | ||
if logEntryEvent != role { | ||
logEntryEvent = role | ||
} else { | ||
logEntryEvent = nil | ||
} | ||
} | ||
}, | ||
label: { | ||
HStack { | ||
if logEntryEvent == role { | ||
Image(systemName: "checkmark.circle.fill") | ||
.accessibilityHidden(true) | ||
} | ||
Text(role.localizedDescription) | ||
} | ||
} | ||
) | ||
} | ||
|
||
|
||
init(role: LogEntryEvent, logEntryEvent: Binding<LogEntryEvent?>) { | ||
self.role = role | ||
self._logEntryEvent = logEntryEvent | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
Sources/SpeziMedicationTracking/MedicationDosageAndDateSheet.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,70 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import SpeziMedication | ||
import SwiftUI | ||
|
||
|
||
private let numberOfDosageFormatter: NumberFormatter = { | ||
let formatter = NumberFormatter() | ||
formatter.numberStyle = .decimal | ||
return formatter | ||
}() | ||
|
||
|
||
struct MedicationDosageAndDateSheet<MI: MedicationInstance>: View { | ||
let medicationInstance: MI | ||
|
||
@Environment(\.dismiss) var dismiss | ||
|
||
@Binding private var logEntryDosage: Double | ||
@Binding private var logEntryDate: Date | ||
|
||
|
||
var body: some View { | ||
NavigationStack { | ||
HStack { | ||
Text(medicationInstance.type.localizedDescription) | ||
.bold() | ||
Text(medicationInstance.dosage.localizedDescription) | ||
.foregroundStyle(.secondary) | ||
Form { | ||
Section { | ||
TextField( | ||
"Dosage", | ||
value: $logEntryDosage, | ||
formatter: numberOfDosageFormatter | ||
) | ||
} | ||
Section { | ||
DatePicker( | ||
"Time", | ||
selection: $logEntryDate, | ||
displayedComponents: .hourAndMinute | ||
) | ||
} | ||
} | ||
} | ||
.toolbar { | ||
ToolbarItem(placement: .primaryAction) { | ||
Button("Done") { | ||
dismiss() | ||
} | ||
} | ||
} | ||
.navigationTitle("Log Details") | ||
} | ||
} | ||
|
||
|
||
init(medicationInstance: MI, logEntryDosage: Binding<Double>, logEntryDate: Binding<Date>) { | ||
self.medicationInstance = medicationInstance | ||
self._logEntryDosage = logEntryDosage | ||
self._logEntryDate = logEntryDate | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
Sources/SpeziMedicationTracking/MedicationLogLoggedRow.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,21 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import SpeziMedication | ||
import SwiftUI | ||
|
||
|
||
struct MedicationLogLoggedRow<MI: MedicationInstance>: View { | ||
@Binding private var medicationInstances: [MI] | ||
private var selectedDate: Date = .now | ||
|
||
|
||
var body: some View { | ||
Text("...") | ||
} | ||
} |
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,60 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import SpeziMedication | ||
import SwiftUI | ||
|
||
|
||
struct MedicationLogRow<MI: MedicationInstance>: View { | ||
private let medicationLogRowModel: MedicationLogRowModel<MI> | ||
|
||
@State var presentMedicationLogSheet = false | ||
|
||
|
||
var body: some View { | ||
VStack { | ||
HStack { | ||
if let date = medicationLogRowModel.date { | ||
Text(date, style: .time) | ||
} else { | ||
Text("As Needed Medications") | ||
} | ||
Spacer() | ||
Image(systemName: "plus") | ||
.accessibilityHidden(true) | ||
.foregroundColor(.accentColor) | ||
} | ||
if medicationLogRowModel.date != nil { | ||
ForEach(medicationLogRowModel.medications) { medicationInstance in | ||
HStack { | ||
Image(systemName: "pills.circle.fill") | ||
.symbolRenderingMode(.hierarchical) | ||
.accessibilityHidden(true) | ||
Text(medicationInstance.wrappedValue.type.localizedDescription) | ||
} | ||
} | ||
} | ||
} | ||
.background { | ||
RoundedRectangle(cornerRadius: 5.0) | ||
.foregroundColor(.accentColor.opacity(0.2)) | ||
} | ||
.contentShape(Rectangle()) | ||
.onTapGesture { | ||
presentMedicationLogSheet.toggle() | ||
} | ||
.sheet(isPresented: $presentMedicationLogSheet) { | ||
MedicationLogSheet(medicationLogRowModel: medicationLogRowModel) | ||
} | ||
} | ||
|
||
|
||
init(medicationLogRowModel: MedicationLogRowModel<MI>) { | ||
self.medicationLogRowModel = medicationLogRowModel | ||
} | ||
} |
Oops, something went wrong.