generated from StanfordSpezi/SpeziTemplateApplication
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Onboarding Medication Page ## ♻️ Current situation & Problem Allows users to upload a picture of their medication which is stored in Firebase. ## ⚙️ Release Notes Created Medication Page in the onboarding flow where user can take a photo or upload a photo of their medication chart. <img width="150" alt="Screenshot 2024-03-06 at 10 24 12 am" src="https://github.com/CS342/2024-PICS/assets/137839789/129caebe-167f-4706-b93d-56efc2c0e5d7"> ## 📚 Documentation Used SourceImage Package ## ✅ Testing ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md).
- Loading branch information
Showing
7 changed files
with
201 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// This source file is part of the ImageSource open source project | ||
// | ||
// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
import Foundation | ||
import ImageSource | ||
import PDFKit | ||
import SwiftUI | ||
|
||
|
||
struct ContentView: View { | ||
@State var image: UIImage? | ||
@Environment(PICSStandard.self) private var standard | ||
|
||
private var swiftUIImage: some View { | ||
image.flatMap { | ||
Image(uiImage: $0) | ||
.accessibilityLabel(Text("Medication Plan")) | ||
} | ||
} | ||
|
||
var body: some View { | ||
ImageSource(image: $image) | ||
.clipShape(RoundedRectangle(cornerRadius: 8)) | ||
.padding() | ||
.onChange(of: image) { | ||
uploadImage(image: image) | ||
} | ||
} | ||
func uploadImage(image: UIImage?) { | ||
if let img = image { | ||
if let pdfPage = PDFPage(image: img) { | ||
let pdfDocument = PDFDocument() | ||
pdfDocument.insert(pdfPage, at: 0) | ||
Task { | ||
await standard.storeImage(image: pdfDocument) | ||
} | ||
} else { | ||
print("Failed to create PDFPage from image") | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
struct ContentView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ContentView() | ||
} | ||
} |
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 @@ | ||
// | ||
// This source file is part of the PICS based on the Stanford Spezi Template Application project | ||
// | ||
// SPDX-FileCopyrightText: 2023 Stanford University | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
import Foundation | ||
import SpeziHealthKit | ||
import SpeziOnboarding | ||
import SwiftUI | ||
|
||
|
||
struct Medication: View { | ||
@Environment(OnboardingNavigationPath.self) private var onboardingNavigationPath | ||
|
||
var body: some View { | ||
OnboardingView( | ||
contentView: { | ||
VStack { | ||
OnboardingTitleView( | ||
title: "MEDICATION_TITLE", | ||
subtitle: "MEDICATION_SUBTITLE" | ||
) | ||
Spacer() | ||
ContentView() | ||
} | ||
}, actionView: { | ||
OnboardingActionsView( | ||
"Upload Photo", | ||
action: { | ||
onboardingNavigationPath.nextStep() | ||
} | ||
) | ||
} | ||
) | ||
|
||
// Small fix as otherwise "Login" or "Sign up" is still shown in the nav bar | ||
.navigationTitle(Text(verbatim: "")) | ||
} | ||
} | ||
|
||
|
||
#if DEBUG | ||
#Preview { | ||
OnboardingStack { | ||
Medication() | ||
} | ||
.previewWith(standard: PICSStandard()) { | ||
} | ||
} | ||
#endif |
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