Skip to content

Commit

Permalink
UI Change: Centered and Divided Hide Button and fixed lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinentran committed Mar 11, 2024
1 parent 9b44804 commit 5b7d05e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
30 changes: 18 additions & 12 deletions Prisma/PrivacyControls/DeleteDataView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,25 @@ struct DeleteDataView: View {

var hideByCustomRangeSection: some View {
Section(header: Text("Hide Data by Custom Range")) {
DatePicker("Start date", selection: $customHideStartDate, displayedComponents: .date)
DatePicker("End date", selection: $customHideEndDate, displayedComponents: .date)
Button("Hide") {
let startDateString = formatDate(customHideStartDate)
let endDateString = formatDate(customHideEndDate)
Task {
customRangeTimestamps = await standard.fetchCustomRangeTimeStamps(
selectedTypeIdentifier: categoryIdentifier,
startDate: startDateString,
endDate: endDateString
)
VStack {
DatePicker("Start date", selection: $customHideStartDate, displayedComponents: .date)
DatePicker("End date", selection: $customHideEndDate, displayedComponents: .date)

Divider()

Button("Hide") {
let startDateString = formatDate(customHideStartDate)
let endDateString = formatDate(customHideEndDate)
Task {
customRangeTimestamps = await standard.fetchCustomRangeTimeStamps(
selectedTypeIdentifier: categoryIdentifier,
startDate: startDateString,
endDate: endDateString
)

Check warning on line 93 in Prisma/PrivacyControls/DeleteDataView.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/PrivacyControls/DeleteDataView.swift#L77-L93

Added lines #L77 - L93 were not covered by tests
}
switchHiddenInBackend(identifier: categoryIdentifier, timestamps: customRangeTimestamps, alwaysHide: true)

Check warning on line 95 in Prisma/PrivacyControls/DeleteDataView.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/PrivacyControls/DeleteDataView.swift#L95

Added line #L95 was not covered by tests
}
switchHiddenInBackend(identifier: categoryIdentifier, timestamps: customRangeTimestamps, alwaysHide: true)
// .frame(maxWidth: .infinity) // Make the button take full width

Check warning on line 97 in Prisma/PrivacyControls/DeleteDataView.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/PrivacyControls/DeleteDataView.swift#L97

Added line #L97 was not covered by tests
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Prisma/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@
}
}
}
},
"Hide" : {

},
"Hide by Timestamps" : {

Expand Down Expand Up @@ -695,9 +698,6 @@
}
}
}
},
"Submit" : {

},
"TASK_CONTEXT_ACTION_QUESTIONNAIRE" : {
"localizations" : {
Expand Down
12 changes: 8 additions & 4 deletions Prisma/Standard/PrismaStandard+HealthKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ extension PrismaStandard {

// If hideFlag exists, update its value
if let hideFlagExists = docSnapshot.data()?["hideFlag"] as? Bool {
if (alwaysHide) {
if alwaysHide {
// If alwaysHide is true, always set hideFlag to true regardless of original value
try await document.setData(["hideFlag": true], merge: true)
print("AlwaysHide is enabled; set hideFlag to true.")
Expand Down Expand Up @@ -214,13 +214,17 @@ extension PrismaStandard {
let documentDate = String(documentID.prefix(10))

// check if documentID date is within the start and end date range
if (documentDate >= startDate && documentDate <= endDate) {
if documentDate >= startDate && documentDate <= endDate {
timestampsArr.append(documentID)
}
}
return timestampsArr
} catch let error {
print("Error fetching documents: \(error.localizedDescription)")
} catch {
if let firestoreError = error as? FirestoreError {
print("Error fetching documents: \(firestoreError.localizedDescription)")
} else {
print("Unexpected error: \(error.localizedDescription)")
}
return []
}
}

Check warning on line 230 in Prisma/Standard/PrismaStandard+HealthKit.swift

View check run for this annotation

Codecov / codecov/patch

Prisma/Standard/PrismaStandard+HealthKit.swift#L200-L230

Added lines #L200 - L230 were not covered by tests
Expand Down

0 comments on commit 5b7d05e

Please sign in to comment.