diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5f8f84a05a..04daacb3ce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -59,6 +59,19 @@ repos: additional_dependencies: ["pygments"] files: '.*\.xcstrings' + - id: check_yaml_definitions_avatars + name: Check avatars.yml + description: | + This hook checks avatars.yml for: + - non unique ids + - jtd schema validation + - filename and image consistency + It also formats the file + entry: python3 Tools/Hooks/check_yaml_definitions_avatars.py + language: python + additional_dependencies: ["ruamel.yaml"] + files: avatars.yml + - id: check_yaml_definitions_professions name: Check professions.yml description: | diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Data/AvatarsData.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Data/AvatarsData.swift deleted file mode 100644 index 39f98f5a48..0000000000 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Data/AvatarsData.swift +++ /dev/null @@ -1,241 +0,0 @@ -// Leka - iOS Monorepo -// Copyright APF France handicap -// SPDX-License-Identifier: Apache-2.0 - -import DesignKit -import Foundation - -// MARK: - AvatarCategory - -// Avatar Picker Models -struct AvatarCategory: Identifiable, Hashable { - let id = UUID() - let category: String - let images: [String] -} - -// MARK: - AvatarSets - -// AvatarPicker Data -enum AvatarSets: Int, CaseIterable, Hashable { - case girls - case boys - case lekaGirls - case lekaBoys - case jobs - case weather - case sunglasses - case animals - case fruits - case vegies - - // MARK: Internal - - var id: Self { self } - - var content: AvatarCategory { - switch self { - case .girls: - AvatarCategory( - category: "Filles", - images: [ - DesignKitAsset.Avatars.avatarsGirl1a.name, - DesignKitAsset.Avatars.avatarsGirl1b.name, - DesignKitAsset.Avatars.avatarsGirl1c.name, - DesignKitAsset.Avatars.avatarsGirl1d.name, - DesignKitAsset.Avatars.avatarsGirl1e.name, - DesignKitAsset.Avatars.avatarsGirl1f.name, - DesignKitAsset.Avatars.avatarsGirl2a.name, - DesignKitAsset.Avatars.avatarsGirl2b.name, - DesignKitAsset.Avatars.avatarsGirl2c.name, - DesignKitAsset.Avatars.avatarsGirl2d.name, - DesignKitAsset.Avatars.avatarsGirl2e.name, - DesignKitAsset.Avatars.avatarsGirl2f.name, - DesignKitAsset.Avatars.avatarsGirl3a.name, - DesignKitAsset.Avatars.avatarsGirl3b.name, - DesignKitAsset.Avatars.avatarsGirl3c.name, - DesignKitAsset.Avatars.avatarsGirl3d.name, - DesignKitAsset.Avatars.avatarsGirl3e62.name, - DesignKitAsset.Avatars.avatarsGirl3e97.name, - DesignKitAsset.Avatars.avatarsGirl4a.name, - DesignKitAsset.Avatars.avatarsGirl4b.name, - DesignKitAsset.Avatars.avatarsGirl4c.name, - DesignKitAsset.Avatars.avatarsGirl4d.name, - DesignKitAsset.Avatars.avatarsGirl4e.name, - DesignKitAsset.Avatars.avatarsGirl5a.name, - DesignKitAsset.Avatars.avatarsGirl5b.name, - DesignKitAsset.Avatars.avatarsGirl5c.name, - DesignKitAsset.Avatars.avatarsGirl5d.name, - DesignKitAsset.Avatars.avatarsGirl5e.name, - ] - ) - case .boys: - AvatarCategory( - category: "Garçons", - images: [ - DesignKitAsset.Avatars.avatarsBoy1a.name, - DesignKitAsset.Avatars.avatarsBoy1b.name, - DesignKitAsset.Avatars.avatarsBoy1c75.name, - DesignKitAsset.Avatars.avatarsBoy1d76.name, - DesignKitAsset.Avatars.avatarsBoy1e.name, - DesignKitAsset.Avatars.avatarsBoy1f.name, - DesignKitAsset.Avatars.avatarsBoy1g.name, - DesignKitAsset.Avatars.avatarsBoy2a.name, - DesignKitAsset.Avatars.avatarsBoy2b.name, - DesignKitAsset.Avatars.avatarsBoy2c.name, - DesignKitAsset.Avatars.avatarsBoy2d.name, - DesignKitAsset.Avatars.avatarsBoy2e82.name, - DesignKitAsset.Avatars.avatarsBoy2e115.name, - DesignKitAsset.Avatars.avatarsBoy2f.name, - DesignKitAsset.Avatars.avatarsBoy2g.name, - DesignKitAsset.Avatars.avatarsBoy3a.name, - DesignKitAsset.Avatars.avatarsBoy3b.name, - DesignKitAsset.Avatars.avatarsBoy3c.name, - DesignKitAsset.Avatars.avatarsBoy3d.name, - DesignKitAsset.Avatars.avatarsBoy3e.name, - DesignKitAsset.Avatars.avatarsBoy3f.name, - DesignKitAsset.Avatars.avatarsBoy3g.name, - DesignKitAsset.Avatars.avatarsBoy4a.name, - DesignKitAsset.Avatars.avatarsBoy4b.name, - DesignKitAsset.Avatars.avatarsBoy4c.name, - DesignKitAsset.Avatars.avatarsBoy4d.name, - DesignKitAsset.Avatars.avatarsBoy4e.name, - DesignKitAsset.Avatars.avatarsBoy4f.name, - DesignKitAsset.Avatars.avatarsBoy4g.name, - ] - ) - case .lekaGirls: - AvatarCategory( - category: "Filles Leka", - images: [ - DesignKitAsset.Avatars.avatarsLekaGirl1a.name, - DesignKitAsset.Avatars.avatarsLekaGirl1b.name, - DesignKitAsset.Avatars.avatarsLekaGirl1c118.name, - DesignKitAsset.Avatars.avatarsLekaGirl1c119.name, - DesignKitAsset.Avatars.avatarsLekaGirl2a.name, - DesignKitAsset.Avatars.avatarsLekaGirl2b.name, - DesignKitAsset.Avatars.avatarsLekaGirl2c.name, - DesignKitAsset.Avatars.avatarsLekaGirl2d.name, - DesignKitAsset.Avatars.avatarsLekaGirl3a.name, - DesignKitAsset.Avatars.avatarsLekaGirl3b.name, - DesignKitAsset.Avatars.avatarsLekaGirl3c.name, - DesignKitAsset.Avatars.avatarsLekaGirl3d.name, - DesignKitAsset.Avatars.avatarsLekaGirl4a.name, - DesignKitAsset.Avatars.avatarsLekaGirl4b.name, - DesignKitAsset.Avatars.avatarsLekaGirl4c.name, - DesignKitAsset.Avatars.avatarsLekaGirl4d.name, - DesignKitAsset.Avatars.avatarsLekaGirl5a.name, - DesignKitAsset.Avatars.avatarsLekaGirl5b.name, - DesignKitAsset.Avatars.avatarsLekaGirl5c.name, - DesignKitAsset.Avatars.avatarsLekaGirl5d.name, - DesignKitAsset.Avatars.avatarsLekaGirl6a.name, - DesignKitAsset.Avatars.avatarsLekaGirl6b.name, - DesignKitAsset.Avatars.avatarsLekaGirl6c.name, - DesignKitAsset.Avatars.avatarsLekaGirl6d.name, - ] - ) - case .lekaBoys: - AvatarCategory( - category: "Garçons Leka", - images: [ - DesignKitAsset.Avatars.avatarsLekaBoy1a.name, - DesignKitAsset.Avatars.avatarsLekaBoy1b.name, - DesignKitAsset.Avatars.avatarsBoy1c138.name, - DesignKitAsset.Avatars.avatarsBoy1d144.name, - DesignKitAsset.Avatars.avatarsLekaBoy2a.name, - DesignKitAsset.Avatars.avatarsLekaBoy2b.name, - DesignKitAsset.Avatars.avatarsLekaBoy2c.name, - DesignKitAsset.Avatars.avatarsLekaBoy2d.name, - ] - ) - case .jobs: - AvatarCategory( - category: "Métiers Leka", - images: [ - DesignKitAsset.Avatars.avatarsLekaCook.name, - DesignKitAsset.Avatars.avatarsLekaAstronaut.name, - DesignKitAsset.Avatars.avatarsLekaDoctor.name, - DesignKitAsset.Avatars.avatarsLekaExplorer.name, - DesignKitAsset.Avatars.avatarsLekaMarine.name, - DesignKitAsset.Avatars.avatarsLekaPirate.name, - ] - ) - case .weather: - AvatarCategory( - category: "Météo Leka", - images: [ - DesignKitAsset.Avatars.avatarsLekaCloud.name, - DesignKitAsset.Avatars.avatarsLekaFlake.name, - DesignKitAsset.Avatars.avatarsLekaMoon.name, - DesignKitAsset.Avatars.avatarsLekaStar.name, - DesignKitAsset.Avatars.avatarsSun.name, - ] - ) - case .sunglasses: - AvatarCategory( - category: "Lunettes de soleil", - images: [ - DesignKitAsset.Avatars.avatarsLekaSunglassesBlue.name, - DesignKitAsset.Avatars.avatarsLekaSunglassesGreen.name, - DesignKitAsset.Avatars.avatarsLekaSunglassesYellow.name, - DesignKitAsset.Avatars.avatarsLekaSunglassesPink.name, - ] - ) - case .animals: - AvatarCategory( - category: "Animaux", - images: [ - DesignKitAsset.Avatars.avatarsPictogramsAnimalsFarmBirdYellow0071.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsFarmHorseBrown006A.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsFarmRoosterWhite006B.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsForestBearBrown005E.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsForestFoxOrange0064.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsForestHedgehogBrown0062.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsForestRabbitGray0061.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsForestSquirrelOrange005C.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsPetsFishBlue0055.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsPetsTurtleGreen0056.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsSavannaElephantGray0085.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsSavannaGiraffeYellow0081.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsSavannaKangarooBrown0078.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsSavannaKoalaGray0077.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsSavannaLionBrown0082.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsSeaCrabRed003E.name, - DesignKitAsset.Avatars.avatarsPictogramsAnimalsSeaTurtleGreen0041.name, - ] - ) - case .fruits: - AvatarCategory( - category: "Fruits", - images: [ - DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsAppleGreen0100.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsAppleRed0101.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsBananaYellow00FB.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsCherryRed00FF.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsGrapePurple00FE.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsKiwiGreen00F8.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsLemonYellow00F7.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsPearYellow00FC.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsPineappleOrange00F9.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsStrawberryRed00FD.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsWatermelonRed00FA.name, - ] - ) - case .vegies: - AvatarCategory( - category: "Légumes", - images: [ - DesignKitAsset.Avatars.avatarsPictogramsFoodsVegetablesAvocadoGreen00E1.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsVegetablesBroccoliGreen00E5.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsVegetablesCarrotOrange00E6.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsVegetablesCornYellow00E3.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsVegetablesEggplantPurple00E4.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsVegetablesOnionYellow00E8.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsVegetablesPotatoYellow100E9.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsVegetablesSaladGreen100EA.name, - DesignKitAsset.Avatars.avatarsPictogramsFoodsVegetablesTomatoRed00E2.name, - ] - ) - } - } -} diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+AvatarCellLabel.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+AvatarCellLabel.swift index aa21806c80..0e3a1211ed 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+AvatarCellLabel.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+AvatarCellLabel.swift @@ -2,6 +2,7 @@ // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 +import AccountKit import DesignKit import SwiftUI @@ -9,20 +10,21 @@ extension AvatarPicker { struct AvatarCellLabel: View { // MARK: Internal - let image: String + let image: UIImage @Binding var isSelected: Bool var body: some View { - Image(self.image, bundle: Bundle(for: DesignKitResources.self)) + Image(uiImage: self.image) .resizable() .aspectRatio(contentMode: .fit) + .background(DesignKitAsset.Colors.blueGray.swiftUIColor) .clipShape(Circle()) - .frame(maxWidth: 125, maxHeight: 125) + .frame(maxWidth: 130, maxHeight: 130) .animation(.default, value: self.isSelected) .overlay( Circle() .stroke(self.styleManager.accentColor!, - lineWidth: self.isSelected ? 7 : 0) + lineWidth: self.isSelected ? 4 : 0) ) } @@ -34,7 +36,7 @@ extension AvatarPicker { #Preview { HStack { - AvatarPicker.AvatarCellLabel(image: DesignKitAsset.Avatars.accompanyingBlue.name, isSelected: .constant(false)) - AvatarPicker.AvatarCellLabel(image: DesignKitAsset.Avatars.accompanyingBlue.name, isSelected: .constant(true)) + AvatarPicker.AvatarCellLabel(image: Avatars.iconToUIImage(icon: Avatars.categories[0].avatars[0]), isSelected: .constant(false)) + AvatarPicker.AvatarCellLabel(image: Avatars.iconToUIImage(icon: Avatars.categories[0].avatars[0]), isSelected: .constant(true)) } } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+ButtonLabel.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+ButtonLabel.swift index 74bfd145a7..977ed43418 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+ButtonLabel.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+ButtonLabel.swift @@ -2,6 +2,7 @@ // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 +import AccountKit import DesignKit import SwiftUI @@ -20,9 +21,10 @@ extension AvatarPicker { .frame(width: 30) .foregroundStyle(self.styleManager.accentColor!) } else { - Image(self.image, bundle: Bundle(for: DesignKitResources.self)) + Image(uiImage: Avatars.iconToUIImage(icon: self.image)) .resizable() .aspectRatio(contentMode: .fit) + .background(DesignKitAsset.Colors.blueGray.swiftUIColor) .clipShape(Circle()) } } @@ -43,6 +45,6 @@ extension AvatarPicker { HStack { AvatarPicker.ButtonLabel(image: "") - AvatarPicker.ButtonLabel(image: DesignKitAsset.Avatars.accompanyingBlue.name) + AvatarPicker.ButtonLabel(image: Avatars.categories[0].avatars[0]) } } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+ListView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+ListView.swift index 8bf80e41f6..951f893f25 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+ListView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker+ListView.swift @@ -2,6 +2,7 @@ // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 +import AccountKit import DesignKit import SwiftUI @@ -9,24 +10,24 @@ extension AvatarPicker { struct ListView: View { // MARK: Internal - @Binding var selected: String + @Binding var selectedAvatar: String var body: some View { List { - ForEach(AvatarSets.allCases, id: \.id) { category in - Section(category.content.category) { + ForEach(Avatars.categories, id: \.self) { category in + Section(category.name) { ScrollView(.horizontal) { LazyHGrid(rows: self.rows, spacing: 50) { - ForEach(category.content.images, id: \.self) { item in + ForEach(category.avatars, id: \.self) { icon in Button { - self.selected = item + self.selectedAvatar = icon } label: { AvatarCellLabel( - image: item, - isSelected: .constant(self.selected == item) + image: Avatars.iconToUIImage(icon: icon), + isSelected: .constant(self.selectedAvatar == icon) ) } - .animation(.easeIn, value: self.selected) + .animation(.easeIn, value: self.selectedAvatar) } } .padding() @@ -45,5 +46,5 @@ extension AvatarPicker { } #Preview { - AvatarPicker.ListView(selected: .constant("")) + AvatarPicker.ListView(selectedAvatar: .constant("")) } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker.swift index 59d74d1282..780f035b8e 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/AvatarPicker/AvatarPicker.swift @@ -2,6 +2,7 @@ // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 +import AccountKit import DesignKit import LocalizationKit import SwiftUI @@ -12,32 +13,32 @@ struct AvatarPicker: View { @Environment(\.dismiss) var dismiss var body: some View { - ListView(selected: self.$selected) + ListView(selectedAvatar: self.$selectedAvatar) .onAppear { - self.selected = self.avatar + self.selectedAvatar = self.avatar } .navigationTitle(String(l10n.AvatarPicker.title.characters)) .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button { - self.avatar = self.selected + self.avatar = self.selectedAvatar self.dismiss() } label: { Label(String(l10n.AvatarPicker.validateButton.characters), systemImage: "checkmark.circle") } - .disabled(self.selected.isEmpty) + .disabled(self.selectedAvatar.isEmpty) } } } // MARK: Private - @State private var selected: String = "" + @State private var selectedAvatar: String = "" @Binding var avatar: String } #Preview { NavigationStack { - AvatarPicker(avatar: .constant(DesignKitAsset.Avatars.accompanyingBlue.name)) + AvatarPicker(avatar: .constant(Avatars.categories[0].avatars[0])) } } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/CarereceiverView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/CarereceiverView.swift index f7094db50c..54a549587e 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/CarereceiverView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/CarereceiverView.swift @@ -2,6 +2,7 @@ // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 +import AccountKit import DesignKit import LocalizationKit import SwiftUI @@ -45,9 +46,10 @@ struct CarereceiverView: View { @ObservedObject private var rootOwnerViewModel: RootOwnerViewModel = .shared private var editCarereceiverButtonLabel: some View { - Image(self.carereceiver.avatar, bundle: Bundle(for: DesignKitResources.self)) + Image(uiImage: Avatars.iconToUIImage(icon: self.carereceiver.avatar)) .resizable() .aspectRatio(contentMode: .fit) + .background(DesignKitAsset.Colors.blueGray.swiftUIColor) .clipShape(Circle()) .overlay { Image(systemName: "pencil.circle.fill") @@ -90,5 +92,5 @@ extension l10n { // swiftlint:enable line_length #Preview { - CarereceiverView(carereceiver: Carereceiver(name: "Peet", avatar: DesignKitAsset.Avatars.avatarsBoy1a.name, reinforcer: 2)) + CarereceiverView(carereceiver: Carereceiver(name: "Peet", avatar: Avatars.categories[0].avatars[0], reinforcer: 2)) } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/EditCaregiverLabel.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/EditCaregiverLabel.swift index fd00910241..f5e5091643 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/EditCaregiverLabel.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/EditCaregiverLabel.swift @@ -2,6 +2,7 @@ // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 +import AccountKit import DesignKit import LocalizationKit import RobotKit @@ -21,9 +22,10 @@ struct EditCaregiverLabel: View { self.rootOwnerViewModel.isEditCaregiverViewPresented = true } label: { HStack(spacing: 10) { - Image(caregiver.avatar, bundle: Bundle(for: DesignKitResources.self)) + Image(uiImage: Avatars.iconToUIImage(icon: caregiver.avatar)) .resizable() .aspectRatio(contentMode: .fit) + .background(DesignKitAsset.Colors.blueGray.swiftUIColor) .clipShape(Circle()) .frame(maxWidth: 90) VStack(alignment: .leading, spacing: 0) { @@ -97,6 +99,6 @@ extension l10n { }) .onAppear { let rootOwnerViewModel = RootOwnerViewModel.shared - rootOwnerViewModel.currentCaregiver = Caregiver(name: "Joe", avatar: "avatars_boy-1a") + rootOwnerViewModel.currentCaregiver = Caregiver(name: "Joe", avatar: Avatars.categories[0].avatars[2]) } } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView+CategoryLabel.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView+CategoryLabel.swift index c047633472..350d5169c9 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView+CategoryLabel.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/MainView+CategoryLabel.swift @@ -43,7 +43,7 @@ extension MainView { case .carereceivers: self.title = String(l10n.MainView.Sidebar.CategoryLabel.carereceivers.characters) - self.systemImage = "person.circle" + self.systemImage = "figure.2.arms.open" } } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift index 0db7621b6b..6ed496e38c 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/MainView/RootOwnerViewModel.swift @@ -30,23 +30,23 @@ class RootOwnerViewModel: ObservableObject { @Published var showConfirmDeleteAccount: Bool = false @Published var mockCaregiversSet: [Caregiver] = [ - Caregiver(name: "Chantal", avatar: DesignKitAsset.Avatars.avatarsBoy4f.name, professions: [Professions.list[6]]), - Caregiver(name: "Gaëtan", avatar: DesignKitAsset.Avatars.avatarsLekaSunglassesBlue.name, professions: [Professions.list[9]], colorScheme: .dark, accentColor: .green), - Caregiver(name: "Fabrizio", avatar: DesignKitAsset.Avatars.avatarsPictogramsAnimalsFarmBirdYellow0071.name, professions: [Professions.list[10]]), - Caregiver(name: "Hakima", avatar: DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsPearYellow00FC.name, professions: [Professions.list[10], Professions.list[1]]), - Caregiver(name: "Eric", avatar: DesignKitAsset.Avatars.avatarsBoy2a.name, professions: [Professions.list[10]]), - Caregiver(name: "Razmo", avatar: DesignKitAsset.Avatars.avatarsBoy3b.name, professions: [Professions.list[5]], colorScheme: .dark, accentColor: .orange), - Caregiver(name: "Corinne", avatar: DesignKitAsset.Avatars.avatarsGirl1d.name, professions: [Professions.list[4]]), - Caregiver(name: "Alphonso", avatar: DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsAppleRed0101.name, professions: [Professions.list[0]]), - Caregiver(name: "Gargantua", avatar: DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsCherryRed00FF.name, professions: [Professions.list[2]]), + Caregiver(name: "Chantal", avatar: Avatars.categories[0].avatars[2], professions: [Professions.list[6]]), + Caregiver(name: "Gaëtan", avatar: Avatars.categories[3].avatars[1], professions: [Professions.list[9]], colorScheme: .dark, accentColor: .green), + Caregiver(name: "Fabrizio", avatar: Avatars.categories[4].avatars[1], professions: [Professions.list[10]]), + Caregiver(name: "Hakima", avatar: Avatars.categories[2].avatars[1], professions: [Professions.list[10], Professions.list[1]]), + Caregiver(name: "Eric", avatar: Avatars.categories[1].avatars[0], professions: [Professions.list[10]]), + Caregiver(name: "Razmo", avatar: Avatars.categories[2].avatars[2], professions: [Professions.list[5]], colorScheme: .dark, accentColor: .orange), + Caregiver(name: "Corinne", avatar: Avatars.categories[5].avatars[1], professions: [Professions.list[4]]), + Caregiver(name: "Alphonso", avatar: Avatars.categories[4].avatars[1], professions: [Professions.list[0]]), + Caregiver(name: "Gargantua", avatar: Avatars.categories[3].avatars[2], professions: [Professions.list[2]]), ] @Published var mockCarereceiversSet: [Carereceiver] = [ - Carereceiver(name: "Peet", avatar: DesignKitAsset.Avatars.avatarsLekaAstronaut.name, reinforcer: 1), - Carereceiver(name: "Rounhaa", avatar: DesignKitAsset.Avatars.avatarsPictogramsAnimalsForestSquirrelOrange005C.name, reinforcer: 3), - Carereceiver(name: "Selug", avatar: DesignKitAsset.Avatars.avatarsPictogramsAnimalsSeaCrabRed003E.name, reinforcer: 4), - Carereceiver(name: "Luther", avatar: DesignKitAsset.Avatars.avatarsPictogramsFoodsFruitsAppleRed0101.name, reinforcer: 5), - Carereceiver(name: "Abel", avatar: DesignKitAsset.Avatars.avatarsBoy1g.name, reinforcer: 2), + Carereceiver(name: "Peet", avatar: Avatars.categories[2].avatars[2], reinforcer: 1), + Carereceiver(name: "Rounhaa", avatar: Avatars.categories[4].avatars[0], reinforcer: 3), + Carereceiver(name: "Selug", avatar: Avatars.categories[5].avatars[1], reinforcer: 4), + Carereceiver(name: "Luther", avatar: Avatars.categories[1].avatars[2], reinforcer: 5), + Carereceiver(name: "Abel", avatar: Avatars.categories[2].avatars[3], reinforcer: 2), ] func getReinforcerFor(index: Int) -> UIImage { diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverAvatarCell.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverAvatarCell.swift index eb48878787..7562c2c889 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverAvatarCell.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CaregiverAvatarCell.swift @@ -11,9 +11,10 @@ struct CaregiverAvatarCell: View { var body: some View { VStack(spacing: 10) { - Image(self.caregiver.avatar, bundle: Bundle(for: DesignKitResources.self)) + Image(uiImage: Avatars.iconToUIImage(icon: self.caregiver.avatar)) .resizable() .aspectRatio(contentMode: .fit) + .background(DesignKitAsset.Colors.blueGray.swiftUIColor) .clipShape(Circle()) Text(self.caregiver.name) @@ -23,5 +24,5 @@ struct CaregiverAvatarCell: View { } #Preview { - CaregiverAvatarCell(caregiver: Caregiver(name: "Chantal", avatar: DesignKitAsset.Avatars.avatarsBoy4f.name, professions: [])) + CaregiverAvatarCell(caregiver: Caregiver(name: "Chantal", avatar: Avatars.categories[2].avatars[4], professions: [])) } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CarereceiverAvatarCell.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CarereceiverAvatarCell.swift index f38089d0fa..fefdd3038d 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CarereceiverAvatarCell.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CarereceiverAvatarCell.swift @@ -2,6 +2,7 @@ // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 +import AccountKit import DesignKit import SwiftUI @@ -16,9 +17,10 @@ struct CarereceiverAvatarCell: View { var body: some View { VStack(spacing: 10) { - Image(self.carereceiver.avatar, bundle: Bundle(for: DesignKitResources.self)) + Image(uiImage: Avatars.iconToUIImage(icon: self.carereceiver.avatar)) .resizable() .aspectRatio(contentMode: .fit) + .background(DesignKitAsset.Colors.blueGray.swiftUIColor) .clipShape(Circle()) .overlay { Circle() @@ -45,5 +47,5 @@ struct CarereceiverAvatarCell: View { } #Preview { - CarereceiverAvatarCell(carereceiver: Carereceiver(name: "Chantal", avatar: DesignKitAsset.Avatars.avatarsPictogramsAnimalsSavannaKangarooBrown0078.name, reinforcer: 2)) + CarereceiverAvatarCell(carereceiver: Carereceiver(name: "Chantal", avatar: Avatars.categories[2].avatars[4], reinforcer: 2)) } diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCaregiverView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCaregiverView.swift index 14c1d92a10..614a2ea0e5 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCaregiverView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCaregiverView.swift @@ -2,6 +2,7 @@ // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 +import AccountKit import DesignKit import LocalizationKit import SwiftUI @@ -41,7 +42,7 @@ struct CreateCaregiverView: View { self.onDismissAction() } if self.newCaregiver.avatar.isEmpty { - self.newCaregiver.avatar = AvatarSets.weather.content.images.randomElement()! + self.newCaregiver.avatar = Avatars.categories.last!.avatars.randomElement()! } // TODO: (@team) : add the caregiver profile to the account // TODO: (@team) : assign the caregiver profile as the current selected one diff --git a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCarereceiverView.swift b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCarereceiverView.swift index e349f6ff16..9449387f4d 100644 --- a/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCarereceiverView.swift +++ b/Apps/LekaApp/Sources/_NEWCodeBase/Views/Profiles/CreateCarereceiverView.swift @@ -2,6 +2,7 @@ // Copyright APF France handicap // SPDX-License-Identifier: Apache-2.0 +import AccountKit import DesignKit import LocalizationKit import SwiftUI @@ -37,7 +38,7 @@ struct CreateCarereceiverView: View { self.onDismissAction() } if self.newCarereceiver.avatar.isEmpty { - self.newCarereceiver.avatar = AvatarSets.sunglasses.content.images.randomElement()! + self.newCarereceiver.avatar = Avatars.categories.last!.avatars.randomElement()! } // TODO: (@team) : add the carereceiver profile to the account // TODO: (@team) : assign the carereceiver profile as the current selected one diff --git a/Modules/AccountKit/Examples/AccountKitExample/Sources/MainView.swift b/Modules/AccountKit/Examples/AccountKitExample/Sources/MainView.swift index 2b78b964e2..937439f887 100644 --- a/Modules/AccountKit/Examples/AccountKitExample/Sources/MainView.swift +++ b/Modules/AccountKit/Examples/AccountKitExample/Sources/MainView.swift @@ -17,6 +17,17 @@ struct MainView: View { print("name: \(profession.name)") print("description: \(profession.description)") } + + let avatarCategories = Avatars.categories + for (index, avatarCategorie) in avatarCategories.enumerated() { + print("index: \(index + 1)") + print("version: \(Avatars.version)") + print("id: \(avatarCategorie.id)") + print("name: \(avatarCategorie.name)") + for icon in avatarCategorie.icons { + print("iconName: \(icon)") + } + } } } } diff --git a/Modules/AccountKit/Resources/avatars/avatars.yml b/Modules/AccountKit/Resources/avatars/avatars.yml new file mode 100644 index 0000000000..9a95555a7f --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/avatars.yml @@ -0,0 +1,104 @@ +# Leka - iOS Monorepo +# Copyright APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +version: 1.0.0 +categories: + - id: weather + l10n: + - locale: fr_FR + name: Météo + - locale: en_US + name: Weather + avatars: + - weather_cloud_with_face + - weather_snowflake_with_face + - weather_moon_with_face + - weather_star_with_face + - weather_sun_with_face + + - id: professions + l10n: + - locale: fr_FR + name: Métiers + - locale: en_US + name: Professions + avatars: + - professions_astronaut_leka + - professions_cook_leka + - professions_doctor_leka + - professions_explorer_leka + - professions_sailor_leka + - professions_pirate_leka + + - id: eyeglasses + l10n: + - locale: fr_FR + name: Lunettes + - locale: en_US + name: Eyeglasses + avatars: + - eyeglasses_blue_leka + - eyeglasses_green_leka + - eyeglasses_pink_leka + - eyeglasses_yellow_leka + + - id: animals + l10n: + - locale: fr_FR + name: Animaux + - locale: en_US + name: Animals + avatars: + - animals_bird + - animals_horse + - animals_rooster + - animals_bear + - animals_fox + - animals_hedgehog + - animals_rabbit + - animals_squirrel + - animals_fish + - animals_turtle + - animals_elephant + - animals_giraffe + - animals_koala + - animals_lion + - animals_crab + - animals_turtle + + - id: fruits + l10n: + - locale: fr_FR + name: Fruits + - locale: en_US + name: Fruits + avatars: + - fruits_apple_green + - fruits_apple_red + - fruits_banana + - fruits_cherry + - fruits_grape + - fruits_kiwi + - fruits_lemon + - fruits_pear + - fruits_pineapple + - fruits_strawberry + - fruits_watermelon + + - id: vegetables + l10n: + - locale: fr_FR + name: Légumes + - locale: en_US + name: Vegetables + avatars: + - vegetables_avocado + - vegetables_broccoli + - vegetables_carrot + - vegetables_corn + - vegetables_eggplant + - vegetables_onion + - vegetables_potato + - vegetables_salad + - vegetables_tomato diff --git a/Modules/AccountKit/Resources/avatars/images/animals_bear.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_bear.avatars.png new file mode 100755 index 0000000000..22a8cb846f --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_bear.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57a468f31c8ebd630cff24de6a898cdea2088093a32453e15bc11371b91c0cbf +size 9779 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_bird.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_bird.avatars.png new file mode 100755 index 0000000000..9d5b71aa14 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_bird.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8b3cfb34d98607e65dc81f1cec3d1d30b878e2bb7b3547ae1ad6571dff39f5d6 +size 9475 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_crab.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_crab.avatars.png new file mode 100755 index 0000000000..3ab01ff1e7 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_crab.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:54a1351a5e073f2133e4e1ea7f053a4bf51c1f8287788e1c304a62fdf8e3cf30 +size 21257 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_elephant.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_elephant.avatars.png new file mode 100755 index 0000000000..dda51c93ca --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_elephant.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6fa3462dae48ed7bf7e8b8273c7a22be030384602d652af4e99fd3674000bf60 +size 13505 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_fish.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_fish.avatars.png new file mode 100755 index 0000000000..69560ee399 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_fish.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7d868c63e4e39a26293ff66faa1b4b5af30a0c48384a628f2be0f71ad9df835d +size 12040 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_fox.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_fox.avatars.png new file mode 100755 index 0000000000..c01b80f764 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_fox.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a9890011214689315f1cefc714e3791d4b38cf8f9958e5214a77b91920620c7f +size 12742 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_giraffe.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_giraffe.avatars.png new file mode 100755 index 0000000000..7b2c5597b4 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_giraffe.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f17e5f2571470431bb523af8cd4e20af3af3ff34289c1beaab1ec0e27b41de2b +size 12496 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_hedgehog.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_hedgehog.avatars.png new file mode 100755 index 0000000000..686277fc81 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_hedgehog.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5825c5c50c48ecfdaae5e42ea97ed80a5b51409c39f674ebec9ed52bec077678 +size 11552 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_horse.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_horse.avatars.png new file mode 100755 index 0000000000..23bbbf26cd --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_horse.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b2b526b723b3af90af2176f6928b7b389da1c58e3fa78bcbbf66f1069049a78 +size 12647 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_koala.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_koala.avatars.png new file mode 100755 index 0000000000..fef3bdb486 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_koala.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a12dfee166f14cbb14edac41e27c3ad1355cb698579f5b6865d5dd801d06038b +size 16133 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_lion.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_lion.avatars.png new file mode 100755 index 0000000000..d1d2957e69 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_lion.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d9cacd2b2111eef2d837605e9583ead13449d5b9809167a55b7e3ac03d955a50 +size 13767 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_rabbit.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_rabbit.avatars.png new file mode 100755 index 0000000000..16bf5179e7 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_rabbit.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bac37c8415ad8b89cc0b09048cf864acbfb17409f78a857d9b213000d7daf805 +size 12726 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_rooster.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_rooster.avatars.png new file mode 100755 index 0000000000..ddfb6f65a8 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_rooster.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18d4cd1d5dc19d154b124681543cbe05694e4dde9225773879e3a5dcbf240ba0 +size 12665 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_squirrel.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_squirrel.avatars.png new file mode 100755 index 0000000000..b4c8301f03 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_squirrel.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:762d17b8f01403f6a04c917ca1dddaa789151d1737a3741185d4a83f14d8bb55 +size 14716 diff --git a/Modules/AccountKit/Resources/avatars/images/animals_turtle.avatars.png b/Modules/AccountKit/Resources/avatars/images/animals_turtle.avatars.png new file mode 100755 index 0000000000..32dc71b54c --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/animals_turtle.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c073d99871438b6c74c37be8448fe43d5493bcfd48654bcfdae4082d0e8cac3a +size 11734 diff --git a/Modules/AccountKit/Resources/avatars/images/eyeglasses_blue_leka.avatars.png b/Modules/AccountKit/Resources/avatars/images/eyeglasses_blue_leka.avatars.png new file mode 100755 index 0000000000..197deb92ec --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/eyeglasses_blue_leka.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2ab2616c7784be7047b64331a5dac47b61e3bb7f35b93da72293dd0ad65f3d99 +size 21607 diff --git a/Modules/AccountKit/Resources/avatars/images/eyeglasses_green_leka.avatars.png b/Modules/AccountKit/Resources/avatars/images/eyeglasses_green_leka.avatars.png new file mode 100755 index 0000000000..51c6b62e73 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/eyeglasses_green_leka.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7fdb114d859d75531f8e8842058ecbb058e4ce7451dd031351246e6efdcbbf61 +size 21682 diff --git a/Modules/AccountKit/Resources/avatars/images/eyeglasses_pink_leka.avatars.png b/Modules/AccountKit/Resources/avatars/images/eyeglasses_pink_leka.avatars.png new file mode 100755 index 0000000000..472b3675ee --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/eyeglasses_pink_leka.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:18c2a799661cc684668bb09cab810f64f4fcb622fbb36949a8688bad295dfab1 +size 21508 diff --git a/Modules/AccountKit/Resources/avatars/images/eyeglasses_yellow_leka.avatars.png b/Modules/AccountKit/Resources/avatars/images/eyeglasses_yellow_leka.avatars.png new file mode 100755 index 0000000000..fc79a90a73 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/eyeglasses_yellow_leka.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c123dbd205e12f83893ff0cd93f003ee12bc3ce522bfb858dea3210c25f5a30c +size 20601 diff --git a/Modules/AccountKit/Resources/avatars/images/fruits_apple_green.avatars.png b/Modules/AccountKit/Resources/avatars/images/fruits_apple_green.avatars.png new file mode 100755 index 0000000000..ea1dde4f01 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/fruits_apple_green.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e65351423c631e117768e3b66c39317a8188137526141ad64381d3b2726d2217 +size 7216 diff --git a/Modules/AccountKit/Resources/avatars/images/fruits_apple_red.avatars.png b/Modules/AccountKit/Resources/avatars/images/fruits_apple_red.avatars.png new file mode 100755 index 0000000000..0b8bd63bfb --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/fruits_apple_red.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e197fedbf17dcbabdecdeb9d111d17bfcc77ed147f83754f70da3cacfb207c01 +size 7076 diff --git a/Modules/AccountKit/Resources/avatars/images/fruits_banana.avatars.png b/Modules/AccountKit/Resources/avatars/images/fruits_banana.avatars.png new file mode 100755 index 0000000000..cf11f3ebde --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/fruits_banana.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:96fe6371dfeea996e907931ca9f22bf83839be8d8dd6738f1172162e572ef14b +size 9968 diff --git a/Modules/AccountKit/Resources/avatars/images/fruits_cherry.avatars.png b/Modules/AccountKit/Resources/avatars/images/fruits_cherry.avatars.png new file mode 100755 index 0000000000..c79602cc7e --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/fruits_cherry.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5dd72c994f78b9ecf6090ab76c3b1d6a811e0450c88f67f58ffe330925910369 +size 10027 diff --git a/Modules/AccountKit/Resources/avatars/images/fruits_grape.avatars.png b/Modules/AccountKit/Resources/avatars/images/fruits_grape.avatars.png new file mode 100755 index 0000000000..843d79e387 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/fruits_grape.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a35f8e52ddbed992eba4c6a25009177d89fbe98f5208977240a140b94cd5b3cb +size 15390 diff --git a/Modules/AccountKit/Resources/avatars/images/fruits_kiwi.avatars.png b/Modules/AccountKit/Resources/avatars/images/fruits_kiwi.avatars.png new file mode 100755 index 0000000000..e49de4bc13 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/fruits_kiwi.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb21f7dd2ae35940314093cdf6756c9f2832a8cc9e0e9f123f3d6f57bfa9ad7c +size 15908 diff --git a/Modules/AccountKit/Resources/avatars/images/fruits_lemon.avatars.png b/Modules/AccountKit/Resources/avatars/images/fruits_lemon.avatars.png new file mode 100755 index 0000000000..ab69fdfad4 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/fruits_lemon.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa0d245777d5a16ce70f8f19ebad3070f6733495740f4c6e022cf7bf5c5fc188 +size 8265 diff --git a/Modules/AccountKit/Resources/avatars/images/fruits_pear.avatars.png b/Modules/AccountKit/Resources/avatars/images/fruits_pear.avatars.png new file mode 100755 index 0000000000..85c0824815 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/fruits_pear.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:52e20d704f7761f620a6abcfb2fe287c9d42557fcd091384fe579b39028d002b +size 9087 diff --git a/Modules/AccountKit/Resources/avatars/images/fruits_pineapple.avatars.png b/Modules/AccountKit/Resources/avatars/images/fruits_pineapple.avatars.png new file mode 100755 index 0000000000..c1e09fe26c --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/fruits_pineapple.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:31f793b25374746db013441672476d6d1747f5def69fc82ab9b8d3e391820d06 +size 14125 diff --git a/Modules/AccountKit/Resources/avatars/images/fruits_strawberry.avatars.png b/Modules/AccountKit/Resources/avatars/images/fruits_strawberry.avatars.png new file mode 100755 index 0000000000..59d95fd232 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/fruits_strawberry.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4099c24b4e63d45fe983403f09b5e9d5dfbad82c7172d289b03990c74ce39bc +size 10729 diff --git a/Modules/AccountKit/Resources/avatars/images/fruits_watermelon.avatars.png b/Modules/AccountKit/Resources/avatars/images/fruits_watermelon.avatars.png new file mode 100755 index 0000000000..b54592a2c0 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/fruits_watermelon.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9dbf32963a919c487ebb38ec15028b850dd8202b2ad9b281d99a4efa0602d05 +size 7123 diff --git a/Modules/AccountKit/Resources/avatars/images/professions_astronaut_leka.avatars.png b/Modules/AccountKit/Resources/avatars/images/professions_astronaut_leka.avatars.png new file mode 100755 index 0000000000..b54c3ee67e --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/professions_astronaut_leka.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4495ab8844f23eeefa04b657bcfb05fccabd98bbc59d3a4ba8ad508f5cacf0f +size 19394 diff --git a/Modules/AccountKit/Resources/avatars/images/professions_cook_leka.avatars.png b/Modules/AccountKit/Resources/avatars/images/professions_cook_leka.avatars.png new file mode 100755 index 0000000000..3fd30598d8 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/professions_cook_leka.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:910b6e733c00c60aed639184b20e4d138f8978996a7f22b36d752ad4031449e7 +size 14089 diff --git a/Modules/AccountKit/Resources/avatars/images/professions_doctor_leka.avatars.png b/Modules/AccountKit/Resources/avatars/images/professions_doctor_leka.avatars.png new file mode 100755 index 0000000000..ff5696aeaf --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/professions_doctor_leka.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4d2e7ea822420e6ed6afabd1b0b7a23e65e2dfdeac2ee2bced12be28b14004f8 +size 12775 diff --git a/Modules/AccountKit/Resources/avatars/images/professions_explorer_leka.avatars.png b/Modules/AccountKit/Resources/avatars/images/professions_explorer_leka.avatars.png new file mode 100755 index 0000000000..24eb4be995 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/professions_explorer_leka.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71e500ec7c2bca357bfef0434f48ee7ca9a298d1303970d68a7b1ac3ad1d0f27 +size 11536 diff --git a/Modules/AccountKit/Resources/avatars/images/professions_pirate_leka.avatars.png b/Modules/AccountKit/Resources/avatars/images/professions_pirate_leka.avatars.png new file mode 100755 index 0000000000..376481ca4e --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/professions_pirate_leka.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:40a85e69878627d9a8d222a6f5e79ec799357411501798908d99f907847b5522 +size 14483 diff --git a/Modules/AccountKit/Resources/avatars/images/professions_sailor_leka.avatars.png b/Modules/AccountKit/Resources/avatars/images/professions_sailor_leka.avatars.png new file mode 100755 index 0000000000..cea0bbc828 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/professions_sailor_leka.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eedb989f6c88c4414bf237b3b9ed360efadfad92c66cd32187f7063a1b090851 +size 16923 diff --git a/Modules/AccountKit/Resources/avatars/images/vegetables_avocado.avatars.png b/Modules/AccountKit/Resources/avatars/images/vegetables_avocado.avatars.png new file mode 100755 index 0000000000..2e316103a3 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/vegetables_avocado.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:155d440ddddd193c98c58e0a40877312bfcc78545f55be2b5f204a698cb00116 +size 12907 diff --git a/Modules/AccountKit/Resources/avatars/images/vegetables_broccoli.avatars.png b/Modules/AccountKit/Resources/avatars/images/vegetables_broccoli.avatars.png new file mode 100755 index 0000000000..83b69aab8f --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/vegetables_broccoli.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33b2693f21bcdea131e58cf1ea4b190987d80f9d5660cd24bbf8d6aed2530283 +size 12340 diff --git a/Modules/AccountKit/Resources/avatars/images/vegetables_carrot.avatars.png b/Modules/AccountKit/Resources/avatars/images/vegetables_carrot.avatars.png new file mode 100755 index 0000000000..8079f7d298 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/vegetables_carrot.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b495620bcec634b451aa37bb9d347abfce96e4816203a7416fce0242604ddb73 +size 6989 diff --git a/Modules/AccountKit/Resources/avatars/images/vegetables_corn.avatars.png b/Modules/AccountKit/Resources/avatars/images/vegetables_corn.avatars.png new file mode 100755 index 0000000000..fb9a947eec --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/vegetables_corn.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48c5775804369ccb367bd01dc07776ccb6adfa363ffd9cc868482462469f3283 +size 13673 diff --git a/Modules/AccountKit/Resources/avatars/images/vegetables_eggplant.avatars.png b/Modules/AccountKit/Resources/avatars/images/vegetables_eggplant.avatars.png new file mode 100755 index 0000000000..25425bc0d2 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/vegetables_eggplant.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a9034d009a156011fdace54a1f20607db3a283f947b5153882eb79a59254bd8 +size 8841 diff --git a/Modules/AccountKit/Resources/avatars/images/vegetables_onion.avatars.png b/Modules/AccountKit/Resources/avatars/images/vegetables_onion.avatars.png new file mode 100755 index 0000000000..a30b398207 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/vegetables_onion.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8543a93b2494a6b75ee16260e036087ca3f12f94a17913479d0939a95fee309c +size 11305 diff --git a/Modules/AccountKit/Resources/avatars/images/vegetables_potato.avatars.png b/Modules/AccountKit/Resources/avatars/images/vegetables_potato.avatars.png new file mode 100755 index 0000000000..f6ab2d961a --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/vegetables_potato.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:43e82cc6e50ff0ecdbefb1c52a1fbd162229468bed7ec8eb9b275f2311801ca9 +size 8735 diff --git a/Modules/AccountKit/Resources/avatars/images/vegetables_salad.avatars.png b/Modules/AccountKit/Resources/avatars/images/vegetables_salad.avatars.png new file mode 100755 index 0000000000..1c22db4b16 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/vegetables_salad.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e83ce9338932550f93514a0bc8cc5bea0c8332f012cc9fc3d4fb4dfb7b7a3be4 +size 16941 diff --git a/Modules/AccountKit/Resources/avatars/images/vegetables_tomato.avatars.png b/Modules/AccountKit/Resources/avatars/images/vegetables_tomato.avatars.png new file mode 100755 index 0000000000..ee4ee90187 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/vegetables_tomato.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cda26da4cd8a4b1e330cc0eda1ee89dc58742d0a9e4b7527da2d866842a7abdf +size 11541 diff --git a/Modules/AccountKit/Resources/avatars/images/weather_cloud_with_face.avatars.png b/Modules/AccountKit/Resources/avatars/images/weather_cloud_with_face.avatars.png new file mode 100755 index 0000000000..4f3c32327e --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/weather_cloud_with_face.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:019a474e4b05b6384ae9c1446a0c6fcf477efc49cac799aa63af5519bf5c3821 +size 8687 diff --git a/Modules/AccountKit/Resources/avatars/images/weather_moon_with_face.avatars.png b/Modules/AccountKit/Resources/avatars/images/weather_moon_with_face.avatars.png new file mode 100755 index 0000000000..44623ffed3 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/weather_moon_with_face.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bed1df680017be273fe45d555e6a6d447caed011a5dc0ec8004c60bc5a855cfe +size 14729 diff --git a/Modules/AccountKit/Resources/avatars/images/weather_snowflake_with_face.avatars.png b/Modules/AccountKit/Resources/avatars/images/weather_snowflake_with_face.avatars.png new file mode 100755 index 0000000000..71ef076531 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/weather_snowflake_with_face.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3242b560d664b61230bfd987a68da8ea153452782ddd321231d2d80e0a06a1be +size 20395 diff --git a/Modules/AccountKit/Resources/avatars/images/weather_star_with_face.avatars.png b/Modules/AccountKit/Resources/avatars/images/weather_star_with_face.avatars.png new file mode 100755 index 0000000000..c2671266ec --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/weather_star_with_face.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e21a0693fb98e94cb2ca4be9ede963963930988c8c55327ad24095b157ae4164 +size 10594 diff --git a/Modules/AccountKit/Resources/avatars/images/weather_sun_with_face.avatars.png b/Modules/AccountKit/Resources/avatars/images/weather_sun_with_face.avatars.png new file mode 100755 index 0000000000..efc6f3c4f1 --- /dev/null +++ b/Modules/AccountKit/Resources/avatars/images/weather_sun_with_face.avatars.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1b35bafb2af4b340fc312688c101149d65727915c71e433587282d31e4a7e7d4 +size 15091 diff --git a/Modules/AccountKit/Sources/Models/Avatar.swift b/Modules/AccountKit/Sources/Models/Avatar.swift new file mode 100644 index 0000000000..5953b505a4 --- /dev/null +++ b/Modules/AccountKit/Sources/Models/Avatar.swift @@ -0,0 +1,136 @@ +// Leka - iOS Monorepo +// Copyright APF France handicap +// SPDX-License-Identifier: Apache-2.0 + +import Foundation +import LocalizationKit +import LogKit +import SwiftUI +import Version +import Yams + +// MARK: - Avatars + +public class Avatars: Codable { + // MARK: Lifecycle + + private init() { + self.container = Self.loadAvatars() + } + + // MARK: Public + + public static var categories: [AvatarCategory] { + shared.container.categories + } + + public static var version: Version { + shared.container.version + } + + public static func avatar(for id: String) -> AvatarCategory? { + self.categories.first(where: { $0.id == id }) + } + + public static func iconToUIImage(icon: String) -> UIImage { + guard let image = UIImage(named: "\(icon).avatars.png", in: .module, with: nil) else { + log.error("No image found for icon \(icon)") + fatalError("💥 No image found for icon \(icon)") + } + return image + } + + // MARK: Private + + private struct AvatarsContainer: Codable { + let version: Version + let categories: [AvatarCategory] + } + + private static let shared: Avatars = .init() + + private let container: AvatarsContainer + + private static func loadAvatars() -> AvatarsContainer { + if let fileURL = Bundle.module.url(forResource: "avatars", withExtension: "yml") { + do { + let yamlString = try String(contentsOf: fileURL, encoding: .utf8) + let container = try YAMLDecoder().decode(AvatarsContainer.self, from: yamlString) + return container + } catch { + log.error("Failed to read YAML file: \(error)") + return AvatarsContainer(version: .init(1, 0, 0), categories: []) + } + } else { + log.error("Avatars.yml not found") + return AvatarsContainer(version: .init(1, 0, 0), categories: []) + } + } +} + +// MARK: - AvatarCategory + +public struct AvatarCategory: Codable, Identifiable { + // MARK: Lifecycle + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.id = try container.decode(String.self, forKey: .id) + + self.l10n = try container.decode([AvatarCategory.Localization].self, forKey: .l10n) + + let availableLocales = self.l10n.map(\.locale) + + let currentLocale = availableLocales.first(where: { + $0.language.languageCode == LocalizationKit.l10n.language + }) ?? Locale(identifier: "en_US") + + self.name = self.l10n.first(where: { $0.locale == currentLocale })!.name + self.avatars = try container.decode([String].self, forKey: .avatars) + } + + // MARK: Public + + public let id: String + public let name: String + public let avatars: [String] + + // MARK: Private + + private let l10n: [Localization] +} + +// MARK: Equatable + +extension AvatarCategory: Equatable { + public static func == (lhs: AvatarCategory, rhs: AvatarCategory) -> Bool { + lhs.id == rhs.id + } +} + +// MARK: Hashable + +extension AvatarCategory: Hashable { + public func hash(into hasher: inout Hasher) { + hasher.combine(self.id) + } +} + +// MARK: AvatarCategory.Localization + +public extension AvatarCategory { + struct Localization: Codable { + // MARK: Lifecycle + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.locale = try Locale(identifier: container.decode(String.self, forKey: .locale)) + self.name = try container.decode(String.self, forKey: .name) + } + + // MARK: Internal + + let locale: Locale + let name: String + } +} diff --git a/Specs/jtd/avatars.jtd.json b/Specs/jtd/avatars.jtd.json new file mode 100644 index 0000000000..3cf7ba7b1c --- /dev/null +++ b/Specs/jtd/avatars.jtd.json @@ -0,0 +1,47 @@ +{ + "properties": { + "version": { + "type": "string" + }, + "categories": { + "elements": { + "ref": "$category" + } + } + }, + "definitions": { + "$locale": { + "enum": ["en_US", "fr_FR"] + }, + "$l10n": { + "properties": { + "locale": { + "ref": "$locale" + }, + "name": { + "type": "string" + } + } + }, + "$avatar": { + "type": "string" + }, + "$category": { + "properties": { + "id": { + "type": "string" + }, + "l10n": { + "elements": { + "ref": "$l10n" + } + }, + "avatars": { + "elements": { + "ref": "$avatar" + } + } + } + } + } +} diff --git a/Tools/Hooks/check_yaml_definitions_avatars.py b/Tools/Hooks/check_yaml_definitions_avatars.py new file mode 100755 index 0000000000..fc8c066211 --- /dev/null +++ b/Tools/Hooks/check_yaml_definitions_avatars.py @@ -0,0 +1,123 @@ +#!/usr/bin/python3 +"""Check avatars definitions""" + +# Leka - LekaOS +# Copyright 2024 APF France handicap +# SPDX-License-Identifier: Apache-2.0 + +import os +import subprocess +import sys +from pathlib import Path +import ruamel.yaml + +JTD_SCHEMA = "Specs/jtd/avatars.jtd.json" +ACCOUNTKIT_DIRECTORY = "Modules/AccountKit/Resources/avatars/images" + +# +# Mark: - Functions +# + +def find_image(image): + """Find the image file""" + start_path = Path(ACCOUNTKIT_DIRECTORY) + image_filename = image + ".avatars.png" + for file in start_path.rglob("*.avatars.png"): + if file.name == image_filename: + return file + return None + +def list_images(data): + """List of images from the YAML file""" + images = [] + category = [item["avatars"] for item in data["categories"]] + for avatars in category: + for avatar in avatars: + images.append(avatar) + return images + +def check_avatar_definitions(filename): + """Check avatar definitions""" + # ? Create a YAML object + yaml = ruamel.yaml.YAML(typ="rt") + yaml.indent(mapping=2, sequence=4, offset=2) + + # ? Load the YAML file + with open(filename, "r", encoding="utf8") as file: + data = yaml.load(file) + + # ? Extract the ids + ids = [item["id"] for item in data["categories"]] + + file_is_valid = True + + # ? Check if all ids are unique + if len(set(ids)) != len(ids): + print(f"❌ There are duplicate ids in {filename}") + seen = set() + duplicate = set() + for id in ids: + if id in seen: + duplicate.add(id) + else: + seen.add(id) + print(f"Duplicate ids: {duplicate}") + file_is_valid = False + + # ? Check schema validation with ajv + os.environ["FORCE_COLOR"] = "true" + cmd = ( + f"ajv validate --verbose --all-errors --spec=jtd -s {JTD_SCHEMA} -d {filename}" + ) + + result = subprocess.run(cmd, shell=True, capture_output=True, check=False) + + if result.returncode != 0: + error = result.stderr.decode("utf-8") + print(f"\n❌ File does not match the schema {JTD_SCHEMA}") + print(error) + file_is_valid = False + + # ? Check image exists + images = list_images(data) + for image in images: + if "-" in image: + print(f"❌ The image {image}.avatars.png include \"-\" instead of \"_\"") + file_is_valid = False + if find_image(image) is None: + print(f"❌ The image {image}.avatars.png in {filename} does not exist") + file_is_valid = False + + return file_is_valid + + +# +# Mark: - Main +# + + +def main(): + """Main function""" + # ? Check if a file was specified + if len(sys.argv) > 1: + avatar_definitions_files = sys.argv[1:] + else: + print("❌ No file specified") + sys.exit(1) + + must_fail = False + + for file in avatar_definitions_files: + file_is_valid = check_avatar_definitions(file) + + if file_is_valid is False: + must_fail = True + + if must_fail: + return 1 + + return 0 + + +if __name__ == "__main__": + sys.exit(main())