Skip to content

Commit c136ce4

Browse files
committed
Add attendance status selection view
1 parent 925b8fd commit c136ce4

File tree

3 files changed

+138
-1
lines changed

3 files changed

+138
-1
lines changed

WooCommerce/Classes/ViewRelated/Bookings/Booking Details/BookingDetailsView.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ struct BookingDetailsView: View {
55
@Environment(\.safeAreaInsets) var safeAreaInsets: EdgeInsets
66
@Environment(\.dismiss) private var dismiss
77
@State private var showingOptions = false
8+
@State private var showingStatusSheet = false
89

910
@ObservedObject private var viewModel: BookingDetailsViewModel
1011

@@ -70,6 +71,12 @@ struct BookingDetailsView: View {
7071
}
7172
}
7273
}
74+
.sheet(isPresented: $showingStatusSheet) {
75+
UpdateAttendanceStatusView()
76+
.padding(.top)
77+
.presentationDetents([.medium])
78+
.presentationDragIndicator(.visible)
79+
}
7380
}
7481
}
7582

@@ -157,7 +164,9 @@ private extension BookingDetailsView {
157164
value: .placeholder(content.value),
158165
selectionStyle: .disclosure,
159166
horizontalPadding: 0
160-
)
167+
) {
168+
showingStatusSheet = true
169+
}
161170
}
162171

163172
func appointmentDetailsView(with content: BookingDetailsViewModel.AppointmentDetailsContent) -> some View {
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import SwiftUI
2+
3+
struct UpdateAttendanceStatusView: View {
4+
private let statuses = AttendanceStatus.allCases
5+
6+
var body: some View {
7+
VStack(alignment: .leading, spacing: 24) {
8+
Text(Localization.title)
9+
.font(.subheadline.weight(.medium))
10+
.foregroundColor(.secondary)
11+
.padding(.horizontal)
12+
13+
ForEach(statuses) { status in
14+
HStack(spacing: 16) {
15+
Image(systemName: status.iconName)
16+
.font(.title3.weight(.medium))
17+
.foregroundStyle(Color(.systemGray))
18+
VStack(alignment: .leading, spacing: 4) {
19+
Text(status.title)
20+
.font(.body.weight(.medium))
21+
Text(status.description)
22+
.font(.subheadline)
23+
.foregroundColor(.secondary)
24+
}
25+
}
26+
.padding(.horizontal)
27+
}
28+
Spacer()
29+
}
30+
.padding(.top)
31+
}
32+
}
33+
34+
private extension UpdateAttendanceStatusView {
35+
enum Localization {
36+
static let title = NSLocalizedString(
37+
"UpdateAttendanceStatusView.title",
38+
value: "Update attendance status",
39+
comment: "Title of the update attendance status bottom sheet."
40+
)
41+
42+
static let bookedTitle = NSLocalizedString(
43+
"UpdateAttendanceStatusView.booked.title",
44+
value: "Booked",
45+
comment: "Title for the 'Booked' attendance status."
46+
)
47+
static let bookedDescription = NSLocalizedString(
48+
"UpdateAttendanceStatusView.booked.description",
49+
value: "The appointment is scheduled but hasn't happened yet.",
50+
comment: "Description for the 'Booked' attendance status."
51+
)
52+
53+
static let checkedInTitle = NSLocalizedString(
54+
"UpdateAttendanceStatusView.checkedIn.title",
55+
value: "Checked-in",
56+
comment: "Title for the 'Checked-in' attendance status."
57+
)
58+
static let checkedInDescription = NSLocalizedString(
59+
"UpdateAttendanceStatusView.checkedIn.description",
60+
value: "The customer arrived and the session took place as planned.",
61+
comment: "Description for the 'Checked-in' attendance status."
62+
)
63+
64+
static let noShowTitle = NSLocalizedString(
65+
"UpdateAttendanceStatusView.noShow.title",
66+
value: "No-show",
67+
comment: "Title for the 'No-show' attendance status."
68+
)
69+
static let noShowDescription = NSLocalizedString(
70+
"UpdateAttendanceStatusView.noShow.description",
71+
value: "The client missed the appointment without canceling in advance.",
72+
comment: "Description for the 'No-show' attendance status."
73+
)
74+
}
75+
}
76+
77+
private enum AttendanceStatus: CaseIterable, Identifiable {
78+
case booked
79+
case checkedIn
80+
case noShow
81+
82+
var id: Self { self }
83+
84+
var title: String {
85+
switch self {
86+
case .booked:
87+
return UpdateAttendanceStatusView.Localization.bookedTitle
88+
case .checkedIn:
89+
return UpdateAttendanceStatusView.Localization.checkedInTitle
90+
case .noShow:
91+
return UpdateAttendanceStatusView.Localization.noShowTitle
92+
}
93+
}
94+
95+
var description: String {
96+
switch self {
97+
case .booked:
98+
return UpdateAttendanceStatusView.Localization.bookedDescription
99+
case .checkedIn:
100+
return UpdateAttendanceStatusView.Localization.checkedInDescription
101+
case .noShow:
102+
return UpdateAttendanceStatusView.Localization.noShowDescription
103+
}
104+
}
105+
106+
var iconName: String {
107+
switch self {
108+
case .booked:
109+
return "calendar.badge.checkmark"
110+
case .checkedIn:
111+
return "calendar.and.person"
112+
case .noShow:
113+
return "calendar.badge.exclamationmark"
114+
}
115+
}
116+
}
117+
118+
#if DEBUG
119+
struct UpdateAttendanceStatusView_Previews: PreviewProvider {
120+
static var previews: some View {
121+
UpdateAttendanceStatusView()
122+
}
123+
}
124+
#endif

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,7 @@
12611261
2D05E8112E8A9905004111FD /* CustomerContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D05E8102E8A98FE004111FD /* CustomerContent.swift */; };
12621262
2D05E8132E8AADB9004111FD /* PaymentContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D05E8122E8AADB2004111FD /* PaymentContent.swift */; };
12631263
2D05F7102E8BE921004111FD /* View+Tappable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D05F70F2E8BE91E004111FD /* View+Tappable.swift */; };
1264+
2D05FE962E8D71EA004111FD /* UpdateAttendanceStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D05FE952E8D71EA004111FD /* UpdateAttendanceStatusView.swift */; };
12641265
2D09E0D12E61BC7F005C26F3 /* ApplicationPasswordsExperimentState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D09E0D02E61BC7D005C26F3 /* ApplicationPasswordsExperimentState.swift */; };
12651266
2D09E0D52E65C9B9005C26F3 /* ApplicationPasswordsExperimentStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D09E0D42E65C9B9005C26F3 /* ApplicationPasswordsExperimentStateTests.swift */; };
12661267
2D7A3E232E7891DB00C46401 /* CIABEligibilityCheckerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D7A3E222E7891D200C46401 /* CIABEligibilityCheckerTests.swift */; };
@@ -4469,6 +4470,7 @@
44694470
2D05E8102E8A98FE004111FD /* CustomerContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerContent.swift; sourceTree = "<group>"; };
44704471
2D05E8122E8AADB2004111FD /* PaymentContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentContent.swift; sourceTree = "<group>"; };
44714472
2D05F70F2E8BE91E004111FD /* View+Tappable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Tappable.swift"; sourceTree = "<group>"; };
4473+
2D05FE952E8D71EA004111FD /* UpdateAttendanceStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateAttendanceStatusView.swift; sourceTree = "<group>"; };
44724474
2D09E0D02E61BC7D005C26F3 /* ApplicationPasswordsExperimentState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationPasswordsExperimentState.swift; sourceTree = "<group>"; };
44734475
2D09E0D42E65C9B9005C26F3 /* ApplicationPasswordsExperimentStateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationPasswordsExperimentStateTests.swift; sourceTree = "<group>"; };
44744476
2D7A3E222E7891D200C46401 /* CIABEligibilityCheckerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CIABEligibilityCheckerTests.swift; sourceTree = "<group>"; };
@@ -9184,6 +9186,7 @@
91849186
isa = PBXGroup;
91859187
children = (
91869188
2DAC2C972E82A185008521AF /* BookingDetailsView.swift */,
9189+
2D05FE952E8D71EA004111FD /* UpdateAttendanceStatusView.swift */,
91879190
);
91889191
path = "Booking Details";
91899192
sourceTree = "<group>";
@@ -16558,6 +16561,7 @@
1655816561
DE2FE5862925DA050018040A /* SiteCredentialLoginView.swift in Sources */,
1655916562
020DD48F232392C9005822B1 /* UIViewController+AppReview.swift in Sources */,
1656016563
2687165524D21BC80042F6AE /* SurveySubmittedViewController.swift in Sources */,
16564+
2D05FE962E8D71EA004111FD /* UpdateAttendanceStatusView.swift in Sources */,
1656116565
CE263DE8206ACE3E0015A693 /* MainTabBarController.swift in Sources */,
1656216566
20A3AFE32B10EF860033AF2D /* CardReaderSettingsFlowPresentingView.swift in Sources */,
1656316567
CE14452E2188C11700A991D8 /* ZendeskManager.swift in Sources */,

0 commit comments

Comments
 (0)