Skip to content

Commit

Permalink
Finish cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg committed Mar 19, 2024
1 parent 5448262 commit 8ed62e9
Show file tree
Hide file tree
Showing 45 changed files with 765 additions and 810 deletions.
157 changes: 88 additions & 69 deletions PICS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "05e327451e18c7ec1bcbb995ae92606157a1e8e81cca779ac79d52123c30306e",
"originHash" : "e3a25241397786f0f92600126ae926c27c41f21b0197ca6b9a97681904c02778",
"pins" : [
{
"identity" : "abseil-cpp-binary",
Expand Down Expand Up @@ -208,15 +208,6 @@
"version" : "0.5.3"
}
},
{
"identity" : "spezimockwebservice",
"kind" : "remoteSourceControl",
"location" : "https://github.com/StanfordSpezi/SpeziMockWebService.git",
"state" : {
"revision" : "b18067d3499e630bbd995ef05a296ef8fdd42528",
"version" : "1.0.0"
}
},
{
"identity" : "spezionboarding",
"kind" : "remoteSourceControl",
Expand Down
8 changes: 5 additions & 3 deletions PICS/Account/AccountSetupHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import SwiftUI


struct AccountSetupHeader: View {
@Environment(Account.self) private var account
@Environment(\._accountSetupState) private var setupState

@Environment(Account.self)
private var account
@Environment(\._accountSetupState)
private var setupState


var body: some View {
VStack {
Expand Down
13 changes: 8 additions & 5 deletions PICS/Account/AccountSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import SwiftUI


struct AccountSheet: View {
@Environment(\.dismiss) var dismiss

@Environment(Account.self) private var account
@Environment(\.accountRequired) var accountRequired

@Environment(\.dismiss)
private var dismiss

@Environment(Account.self)
private var account
@Environment(\.accountRequired)
private var accountRequired

@State var isInSetup = false
@State var overviewIsEditing = false

Expand Down
30 changes: 18 additions & 12 deletions PICS/Appointment/AppointmentBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@ import Foundation
import SwiftUI

struct Item: Identifiable, Hashable {
let name: String
let id = UUID()
let name: LocalizedStringResource

func hash(into hasher: inout Hasher) {
hasher.combine(id)
hasher.combine(name.key)
}
}

struct AppointmentBlock: View {
var date: String
var time: String
var items = [
Item(name: String(localized: "REQUIRED_ITEMS_1")),
Item(name: String(localized: "REQUIRED_ITEMS_2")),
Item(name: String(localized: "REQUIRED_ITEMS_3")),
Item(name: String(localized: "REQUIRED_ITEMS_4")),
Item(name: String(localized: "REQUIRED_ITEMS_5")),
Item(name: String(localized: "REQUIRED_ITEMS_6")),
Item(name: String(localized: "REQUIRED_ITEMS_7"))
Item(name: "REQUIRED_ITEMS_1"),
Item(name: "REQUIRED_ITEMS_2"),
Item(name: "REQUIRED_ITEMS_3"),
Item(name: "REQUIRED_ITEMS_4"),
Item(name: "REQUIRED_ITEMS_5"),
Item(name: "REQUIRED_ITEMS_6"),
Item(name: "REQUIRED_ITEMS_7")
]

@State private var multiSelection = Set<UUID>()
@State private var showingSheet = false

@Environment(AppointmentInformation.self) private var appointmentInfo
@Environment(PatientInformation.self)
private var patientInformation

var body: some View {
Color(UIColor.secondarySystemBackground)
Expand All @@ -50,7 +56,7 @@ struct AppointmentBlock: View {
Spacer()
HStack {
Spacer()
Button(String(localized: "REQUIRED_ITEMS_HEADING")) {
Button("REQUIRED_ITEMS_HEADING") {
showingSheet.toggle()
}
.buttonStyle(.bordered)
Expand All @@ -64,11 +70,11 @@ struct AppointmentBlock: View {
List(items, selection: $multiSelection) {
Text($0.name)
}
.navigationTitle(String(localized: "REQUIRED_ITEMS_HEADING"))
.navigationTitle("REQUIRED_ITEMS_HEADING")
.environment(\.editMode, .constant(.active))
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(String(localized: "CLOSE")) {
Button("CLOSE") {
showingSheet.toggle()
}
.buttonStyle(.bordered)
Expand Down
27 changes: 14 additions & 13 deletions PICS/Appointment/AppointmentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import SwiftUI

struct AppointmentView: View {
@Environment(AppointmentInformation.self) private var appointmentInfo
@Environment(PatientInformation.self)
private var patientInformation
@State private var showingEdit = false

@State private var appt0User = Date()
Expand All @@ -19,17 +20,17 @@ struct AppointmentView: View {
var body: some View {
VStack(alignment: .center) {
VStack(alignment: .leading) {
AppointmentBlock(date: formattedDate(appointmentInfo.appt1), time: formattedTime(appointmentInfo.appt1))
AppointmentBlock(date: formattedDate(appointmentInfo.appt2), time: formattedTime(appointmentInfo.appt2))
AppointmentBlock(date: formattedDate(patientInformation.appt1), time: formattedTime(patientInformation.appt1))
AppointmentBlock(date: formattedDate(patientInformation.appt2), time: formattedTime(patientInformation.appt2))
.padding(.bottom)
HStack {
Button(String(localized: "RESCHEDULE_BUTTON_LABEL")) {
Button("RESCHEDULE_BUTTON_LABEL") {
showingEdit.toggle()
}
.buttonStyle(.bordered)
}
.padding(.bottom)
Text(String(localized: "TIMELINE_TITLE"))
Text("TIMELINE_TITLE")
.foregroundColor(.primary)
.italic()
TimelineView()
Expand All @@ -47,31 +48,31 @@ struct AppointmentView: View {
.sheet(isPresented: $showingEdit) {
NavigationView {
VStack {
Text(String(localized: "APPTQ_0"))
Text("APPTQ_0")
.font(.headline)
.padding(.top, 32)
DateTimePickerView(selectedDateTime: $appt0User)
.padding(.bottom, 32)
Text(String(localized: "APPTQ_1"))
Text("APPTQ_1")
.font(.headline)
DateTimePickerView(selectedDateTime: $appt1User)
.padding(.bottom, 32)
Text(String(localized: "APPTQ_2"))
Text("APPTQ_2")
.font(.headline)
DateTimePickerView(selectedDateTime: $appt2User)
.padding(.bottom, 32)
Button(String(localized: "SAVE_BUTTON")) {
appointmentInfo.storeDates(appt0User, appt1User, appt2User)
Button("SAVE_BUTTON") {
patientInformation.storeDates(appt0User, appt1User, appt2User)
showingEdit.toggle()
}
.buttonStyle(.bordered)
Spacer()
}
.padding(.horizontal, 20)
.navigationTitle(String(localized: "EDIT_APPT_HEADER"))
.navigationTitle("EDIT_APPT_HEADER")
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button(String(localized: "CLOSE")) {
Button("CLOSE") {
showingEdit.toggle()
}
.buttonStyle(.bordered)
Expand All @@ -97,5 +98,5 @@ struct AppointmentView: View {

#Preview {
AppointmentView()
.environment(AppointmentInformation())
.environment(PatientInformation())
}
7 changes: 4 additions & 3 deletions PICS/Appointment/Appointments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import SwiftUI

/// Displays the contacts for the PICS.
struct Appointments: View {
@Environment(AppointmentInformation.self) private var appointmentInfo
@Environment(PatientInformation.self)
private var patientInformation
@Binding var presentingAccount: Bool

var body: some View {
NavigationStack {
ScrollView {
AppointmentView()
.navigationTitle(String(localized: "APPOINTMENTS_NAVIGATION_TITLE"))
.navigationTitle("APPOINTMENTS_NAVIGATION_TITLE")
.toolbar {
if AccountButton.shouldDisplay {
AccountButton(isPresented: $presentingAccount)
Expand All @@ -38,6 +39,6 @@ struct Appointments: View {
#if DEBUG
#Preview {
Appointments(presentingAccount: .constant(false))
.environment(AppointmentInformation())
.environment(PatientInformation())
}
#endif
4 changes: 1 addition & 3 deletions PICS/Appointment/GettingThere.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import Foundation
import SwiftUI

// TODO: remove all String(localized: ?


struct GettingThere: View {
var body: some View {
Expand All @@ -29,7 +27,7 @@ struct GettingThere: View {
.font(.subheadline)
.foregroundStyle(.secondary)
}
.padding() // TODO: remove?
.padding()
}
}

Expand Down
11 changes: 6 additions & 5 deletions PICS/Appointment/TimelineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,15 @@ struct BidirectionalArrow: Shape {


struct TimelineView: View {
@Environment(AppointmentInformation.self) private var appointmentInfo

@Environment(PatientInformation.self)
private var patientInformation

var body: some View {
let calendar = Calendar.current
let currentDate = Date()

let components1 = calendar.dateComponents([.year, .month, .day], from: appointmentInfo.appt1)
let components2 = calendar.dateComponents([.year, .month, .day], from: appointmentInfo.appt2)
let components1 = calendar.dateComponents([.year, .month, .day], from: patientInformation.appt1)
let components2 = calendar.dateComponents([.year, .month, .day], from: patientInformation.appt2)
let components3 = calendar.dateComponents([.year, .month, .day], from: currentDate)

if let date1 = calendar.date(from: components1), let date2 = calendar.date(from: components2), let now = calendar.date(from: components3) {
Expand All @@ -112,7 +113,7 @@ struct TimelineView: View {
)
HStack(spacing: 0) {
Spacer()
Text(String(localized: "APPT1_TITLE"))
Text("APPT1_TITLE")
.padding(.leading, 45)
.foregroundColor(.primary)
Spacer()
Expand Down
9 changes: 4 additions & 5 deletions PICS/Assessment/Assessments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
import SwiftUI


struct Assessments: View {
struct Assessments: View {
@State private var assessmentResults = AssessmentResults()
@State private var presentedTask: AssessmentTask?

// Binding to control the display of account-related UI.
@Binding private var presentingAccount: Bool

var body: some View {
Expand All @@ -23,7 +22,7 @@ struct Assessments: View {
AssessmentTaskSection(task: .stroopTest, presentingTask: $presentedTask)
AssessmentTaskSection(task: .reactionTime, presentingTask: $presentedTask)
}
.navigationTitle(String(localized: "ASSESSMENTS_NAVIGATION_TITLE"))
.navigationTitle("ASSESSMENTS_NAVIGATION_TITLE")
.toolbar {
if AccountButton.shouldDisplay {
AccountButton(isPresented: $presentingAccount)
Expand All @@ -46,7 +45,7 @@ struct Assessments: View {
ReactionTimeView()
}
}
.background(Color(uiColor: .systemGroupedBackground))
.background(Color(uiColor: .systemGroupedBackground)) // fix ResearchKit background color
}
.environment(assessmentResults)
}
Expand All @@ -61,6 +60,6 @@ struct Assessments: View {
#if DEBUG
#Preview("AssessmentView") {
Assessments(presentingAccount: .constant(false))
.environment(AppointmentInformation())
.environment(PatientInformation())
}
#endif
19 changes: 13 additions & 6 deletions PICS/Assessment/Model/AssessmentResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ import Foundation


struct AssessmentResult: Codable, Identifiable {
var id = UUID()
let id: UUID

var testDateTime: Date
var timeSpent: Double
var errorCnt: Int = -1
// Score that might be collected for MiniCog.
var score: Int = -1 // TODO: used?
let testDateTime: Date
let timeSpent: Double
let errorCnt: Int?


init(id: UUID = UUID(), testDateTime: Date, timeSpent: Double, errorCnt: Int? = nil) {
// swiftlint:disable:previous function_default_parameter_at_end
self.id = id
self.testDateTime = testDateTime
self.timeSpent = timeSpent
self.errorCnt = errorCnt
}
}
Loading

0 comments on commit 8ed62e9

Please sign in to comment.