Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[SwiftUI] AvatarGroup SwiftUI API #2022

Merged

Conversation

mischreiber
Copy link
Contributor

@mischreiber mischreiber commented May 17, 2024

Platforms Impacted

  • iOS
  • visionOS
  • macOS

Description of changes

Creating a SwiftUI API for AvatarGroup.

Yes, it's always been a SwiftUI control, but the API was only ever designed to be used in a UIKit wrapper, where Avatar elements could be added and removed via event-driven method calls. Our new API is fully data-driven, as befits a native SwiftUI control.

let style = MSFAvatarGroupStyle.stack
let size = MSFAvatarSize.size40
let avatarCount = 5

// Basic initializer--there are more properties to explore!
AvatarGroup(style: style,
            size: size,
            avatarCount: avatarCount) { index in

    // Create and yield an Avatar for the given callback index.
    Avatar(style: style,
           size: size,
           image: fetchImage(index),
           primaryText: fetchName(index))
}

As part of this change, I've also avoided the ability to mark an AvatarGroup as transparent, aligning with our latest designs. This will eventually be deprecated across all existing Avatar endpoints.

Binary change

Total increase: 12,544 bytes
Total decrease: -52,432 bytes

File Before After Delta
Total 31,203,440 bytes 31,163,552 bytes 🎉 -39,888 bytes
Full breakdown
File Before After Delta
CalendarViewWeekdayHeadingView.o 77,928 bytes 83,480 bytes ⚠️ 5,552 bytes
SegmentedControl.o 330,216 bytes 333,640 bytes ⚠️ 3,424 bytes
PopupMenuController.o 375,464 bytes 378,064 bytes ⚠️ 2,600 bytes
MSFAvatarGroup.o 31,184 bytes 32,152 bytes ⚠️ 968 bytes
BottomSheetController.o 525,872 bytes 525,512 bytes 🎉 -360 bytes
MultilineCommandBar.o 140,104 bytes 139,352 bytes 🎉 -752 bytes
IndeterminateProgressBar.o 231,928 bytes 231,112 bytes 🎉 -816 bytes
HUD.o 267,176 bytes 266,200 bytes 🎉 -976 bytes
Avatar.o 604,704 bytes 596,968 bytes 🎉 -7,736 bytes
__.SYMDEF 4,863,752 bytes 4,855,520 bytes 🎉 -8,232 bytes
AvatarGroup.o 417,456 bytes 383,896 bytes 🎉 -33,560 bytes

Verification

Visual Verification SwiftUI
AvatarGroupSwiftUI.mp4

UIKit

AvatarGroupUIKit.mp4

Pull request checklist

This PR has considered:

  • Light and Dark appearances
  • iOS supported versions (all major versions greater than or equal current target deployment version)
  • VoiceOver and Keyboard Accessibility
  • Internationalization and Right to Left layouts
  • Different resolutions (1x, 2x, 3x)
  • Size classes and window sizes (iPhone vs iPad, notched devices, multitasking, different window sizes, etc)
  • iPad Pointer interaction
  • SwiftUI consumption (validation or new demo scenarios needed)
  • Objective-C exposure (provide it only if needed)
Microsoft Reviewers: Open in CodeFlow

@mischreiber mischreiber requested a review from a team as a code owner May 17, 2024 03:29
@mischreiber mischreiber enabled auto-merge (squash) May 18, 2024 23:20
@mischreiber mischreiber merged commit c0f2db7 into microsoft:main May 19, 2024
7 checks passed
@mischreiber mischreiber deleted the AvatarGroup_AvatarBuilder_SwiftUI branch May 22, 2024 13:54
@joannaquu joannaquu mentioned this pull request May 23, 2024
12 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants