Avatar Photo Picker

Avatar Photo Picker

A large profile avatar with a camera badge that opens the system photo picker and falls back to a gradient monogram. The new photo is revealed by an iris growing out of the badge, then an upload ring traces the avatar and resolves into a checkmark with a success haptic.

Luiz Mello
  • avatar
  • picker
  • profile

snippet.swift419 lines

5 files • Scroll to see all →
/// A photo shown by `AvatarPhotoPicker`. Every value has its own identity, so/// setting a new photo always plays the reveal, even if the pixels match.public struct AvatarPhotoPickerPhoto: Identifiable, Equatable {    public let id = UUID()    public let image: Image​    public init(_ image: Image) { self.image = image }    public init(uiImage: UIImage) { self.image = Image(uiImage: uiImage) }​    public static func == (lhs: Self, rhs: Self) -> Bool { lhs.id == rhs.id }​    /// Code-generated sample photos (gradient scene + SF Symbol) rendered with    /// `ImageRenderer`, so demos can swap photos without assets or the system picker.    @MainActor public static let samples: [AvatarPhotoPickerPhoto] = [        rendered(symbol: "sun.horizon.fill", colors: [Color(red: 1.0, green: 0.62, blue: 0.36), Color(red: 0.93, green: 0.33, blue: 0.42)]),        rendered(symbol: "figure.surfing", colors: [Color(red: 0.2, green: 0.72, blue: 0.86), Color(red: 0.12, green: 0.36, blue: 0.72)]),        rendered(symbol: "leaf.fill", colors: [Color(red: 0.48, green: 0.8, blue: 0.46), Color(red: 0.1, green: 0.5, blue: 0.44)]),    ]​    /// Renders a square "photo" from a gradient and a symbol.​// ... (click "Show full code" to see more)
Viewing: Model.swift•1 of 5