Skip to content

Commit

Permalink
🔀 Merge branch 'hugo/feature/Move-Avatar-to-AccountKit'
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Feb 22, 2024
2 parents 5fcd92b + c01d958 commit bec129e
Show file tree
Hide file tree
Showing 69 changed files with 647 additions and 289 deletions.
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
241 changes: 0 additions & 241 deletions Apps/LekaApp/Sources/_NEWCodeBase/Data/AvatarsData.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
// Copyright APF France handicap
// SPDX-License-Identifier: Apache-2.0

import AccountKit
import DesignKit
import SwiftUI

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)
)
}

Expand All @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright APF France handicap
// SPDX-License-Identifier: Apache-2.0

import AccountKit
import DesignKit
import SwiftUI

Expand All @@ -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())
}
}
Expand All @@ -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])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@
// Copyright APF France handicap
// SPDX-License-Identifier: Apache-2.0

import AccountKit
import DesignKit
import SwiftUI

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()
Expand All @@ -45,5 +46,5 @@ extension AvatarPicker {
}

#Preview {
AvatarPicker.ListView(selected: .constant(""))
AvatarPicker.ListView(selectedAvatar: .constant(""))
}
Loading

0 comments on commit bec129e

Please sign in to comment.