Skip to content

Commit

Permalink
✨ (LekaApp): Add CarereceiverPicker
Browse files Browse the repository at this point in the history
  • Loading branch information
HPezz committed Feb 9, 2024
1 parent 2b80f62 commit f104f51
Showing 1 changed file with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Leka - iOS Monorepo
// Copyright APF France handicap
// SPDX-License-Identifier: Apache-2.0

import DesignKit
import LocalizationKit
import SwiftUI

// MARK: - CarereceiverPicker

struct CarereceiverPicker: View {
// MARK: Internal

var body: some View {
NavigationStack {
VStack {
ScrollView(showsIndicators: false) {
LazyVGrid(columns: self.columns, spacing: 40) {
ForEach(self.rootOwnerViewModel.mockCarereceiversSet) { carereceiver in
Button {
// TODO: (@team) - Add carereceiver selection logic w/ Firebase
self.rootOwnerViewModel.currentCarereceiver = carereceiver
self.rootOwnerViewModel.isCarereceiverPickerViewPresented = false
} label: {
CarereceiverAvatarCell(carereceiver: carereceiver)
}
}

// ? Last item is Add profile button
self.addCarereceiverButton
}
.padding()
}
}
.padding()
.navigationTitle(String(l10n.CarereceiverPicker.title.characters))
.sheet(isPresented: self.$isCarereceiverCreationPresented) {
CreateCarereceiverView(isPresented: self.$isCarereceiverCreationPresented) {}
}
}
}

// MARK: Private

private let columns = Array(repeating: GridItem(), count: 4)

@ObservedObject private var rootOwnerViewModel: RootOwnerViewModel = .shared

@State private var selected: String = ""
@State private var isCarereceiverCreationPresented: Bool = false

private var addCarereceiverButton: some View {
Button {
self.isCarereceiverCreationPresented = true
} label: {
VStack(spacing: 10) {
Circle()
.fill(Color(uiColor: .systemGray4))
.frame(maxWidth: 120)
.overlay {
Image(systemName: "plus")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 50)
.foregroundStyle(.gray)
}

Text(l10n.CarereceiverPicker.addButtonLabel)
.font(.headline)
.foregroundStyle(.secondary)
}
}
}
}

// MARK: - l10n.CarereceiverPicker

extension l10n {
enum CarereceiverPicker {
static let title = LocalizedString("lekaapp.carereceiver_picker.title",
value: "Care receivers list",
comment: "Carereceiver picker title")

static let addButtonLabel = LocalizedString("lekaapp.carereceiver_picker.addButtonLabel",
value: "Add profile",
comment: "Carereceiver picker add button label")
}
}

#Preview {
CarereceiverPicker()
}

0 comments on commit f104f51

Please sign in to comment.