|
| 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 |
0 commit comments