Skip to content

Commit

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

import LocalizationKit

// swiftlint:disable line_length

extension l10n {
enum CarereceiverSettingsView {
static let navigationTitle = LocalizedString("carereceiver_settings_view.navigation_title", value: "Profil of ", comment: "The navigation title of Carereceiver Settings View")

static let saveButtonLabel = LocalizedString("carereceiver_settings_view.save_button_label", value: "Save", comment: "Save button label of Carereceiver Settings View")

static let closeButtonLabel = LocalizedString("carereceiver_settings_view.close_button_label", value: "Close", comment: "Close button label of Carereceiver Settings View")
}
}

// swiftlint:enable line_length
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Leka - iOS Monorepo
// Copyright APF France handicap
// SPDX-License-Identifier: Apache-2.0

import DesignKit
import LocalizationKit
import SwiftUI

// MARK: - CarereceiverSettingsView

struct CarereceiverSettingsView: View {
// MARK: Internal

@State var modifiedCarereceiver: Carereceiver

var body: some View {
NavigationStack {
VStack(spacing: 40) {
Form {
self.avatarPickerButton
.listRowBackground(Color.clear)

Section {
LabeledContent(String(l10n.CarereceiverCreation.carereceiverNameLabel.characters)) {
TextField("Nom", text: self.$modifiedCarereceiver.name)
.multilineTextAlignment(.trailing)
}
}

Section {
LabeledContent(String(l10n.ReinforcerPicker.header.characters)) {
ReinforcerPicker(carereceiver: self.$modifiedCarereceiver)
}
} footer: {
Text(l10n.ReinforcerPicker.description)
}
}
}
.navigationTitle(String(l10n.CarereceiverSettingsView.navigationTitle.characters) + self.modifiedCarereceiver.name)
.navigationBarTitleDisplayMode(.inline)
.interactiveDismissDisabled()
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Button(String(l10n.CarereceiverSettingsView.closeButtonLabel.characters)) {
self.rootOwnerViewModel.isCarereceiverSettingsViewPresented = false
}
}
ToolbarItem(placement: .topBarTrailing) {
Button(String(l10n.CarereceiverSettingsView.saveButtonLabel.characters)) {
// TODO: (@mathieu) - Add Firestore logic
self.rootOwnerViewModel.isCarereceiverSettingsViewPresented = false
self.rootOwnerViewModel.currentCarereceiver = self.modifiedCarereceiver
}
}
}
}
.preferredColorScheme(self.styleManager.colorScheme)
}

// MARK: Private

@ObservedObject private var rootOwnerViewModel: RootOwnerViewModel = .shared
@ObservedObject private var styleManager: StyleManager = .shared
@State private var isAvatarPickerPresented: Bool = false

private var avatarPickerButton: some View {
Button {
self.isAvatarPickerPresented = true
} label: {
VStack(alignment: .center, spacing: 15) {
AvatarPicker.ButtonLabel(image: self.modifiedCarereceiver.avatar)
Text(l10n.CarereceiverCreation.avatarChoiceButton)
.font(.headline)
}
}
.navigationDestination(isPresented: self.$isAvatarPickerPresented) {
AvatarPicker(avatar: self.$modifiedCarereceiver.avatar)
}
.frame(maxWidth: .infinity, alignment: .center)
}
}

#Preview {
CarereceiverSettingsView(modifiedCarereceiver: Carereceiver())
}

0 comments on commit ab3d43f

Please sign in to comment.