mirror of
https://github.com/block/buzz.git
synced 2026-10-27 12:40:30 +00:00
## Summary - add inline profile photo capture with smooth avatar-to-viewfinder transitions - add close, flip, shutter, retry, and use-photo states with haptics and front-camera mirroring - polish iOS liquid-glass controls and avatar editor motion ### Related issue Follow-up to #6583. ### Testing - just mobile-check - just mobile-test (1,743 tests) - built, installed, and launched on Pixel 10 and iPhone Air --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Signed-off-by: Code Reviewer <037593536284cf40e221c96c931e9877d4166d54f6bb84e5341a86d7fd5d05a4@buzz.block.builderlab.xyz> Signed-off-by: Perci <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@buzz.block.builderlab.xyz> Signed-off-by: Max <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@buzz.block.builderlab.xyz> Signed-off-by: Wren <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@buzz.block.builderlab.xyz> Signed-off-by: Meli <5aaa86bce934fc3445fc254aab560a40923f10252f92107e665073dede0e04d3@buzz.block.builderlab.xyz> Signed-off-by: morgmart <98432065+morgmart@users.noreply.github.com> Co-authored-by: Code Reviewer <037593536284cf40e221c96c931e9877d4166d54f6bb84e5341a86d7fd5d05a4@buzz.block.builderlab.xyz> Co-authored-by: Tyler <109685178+tlongwell-block@users.noreply.github.com> Co-authored-by: Perci <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@buzz.block.builderlab.xyz> Co-authored-by: Max <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@buzz.block.builderlab.xyz> Co-authored-by: Wren <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@buzz.block.builderlab.xyz> Co-authored-by: Meli <5aaa86bce934fc3445fc254aab560a40923f10252f92107e665073dede0e04d3@buzz.block.builderlab.xyz> Co-authored-by: morgmart <98432065+morgmart@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
111 lines
3.3 KiB
Dart
111 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../relay/media_image.dart';
|
|
import '../animated_avatar.dart';
|
|
import 'avatar_image.dart';
|
|
import 'progressive_animated_avatar.dart';
|
|
|
|
/// A circular avatar that opts into playback for animated profile descriptors.
|
|
class PlayingAvatarImage extends StatelessWidget {
|
|
/// Creates an avatar that plays animation when the profile URL describes it.
|
|
const PlayingAvatarImage({
|
|
super.key,
|
|
required this.imageUrl,
|
|
required this.radius,
|
|
required this.fallback,
|
|
this.backgroundColor,
|
|
this.loadingImage,
|
|
this.loadingPosterImage,
|
|
this.onAnimationReady,
|
|
});
|
|
|
|
/// The still-image URL or encoded animated-avatar descriptor.
|
|
final String? imageUrl;
|
|
|
|
/// The radius of the circular avatar.
|
|
final double radius;
|
|
|
|
/// Optional background shown behind still-image content.
|
|
final Color? backgroundColor;
|
|
|
|
/// A local image shown while the persisted animation warms up.
|
|
final ImageProvider? loadingImage;
|
|
|
|
/// A local poster shown when motion is disabled while remote media loads.
|
|
final ImageProvider? loadingPosterImage;
|
|
|
|
/// Called after persisted avatar media produces its first frame.
|
|
final VoidCallback? onAnimationReady;
|
|
|
|
/// Content shown while media is unavailable or still loading.
|
|
final Widget fallback;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final descriptor = parseAnimatedAvatarUrl(imageUrl);
|
|
if (descriptor != null &&
|
|
MediaQuery.disableAnimationsOf(context) &&
|
|
loadingPosterImage != null) {
|
|
return CircleAvatar(
|
|
radius: radius,
|
|
backgroundColor: Colors.transparent,
|
|
child: ClipOval(
|
|
child: SizedBox.square(
|
|
dimension: radius * 2,
|
|
child: Stack(
|
|
fit: StackFit.expand,
|
|
children: [
|
|
Image(
|
|
image: loadingPosterImage!,
|
|
fit: BoxFit.cover,
|
|
gaplessPlayback: true,
|
|
),
|
|
Offstage(
|
|
offstage: true,
|
|
child: MediaImage(
|
|
url: descriptor.posterUrl,
|
|
fit: BoxFit.cover,
|
|
errorBuilder: (_, _, _) => const SizedBox.shrink(),
|
|
frameBuilder: (_, child, frame, wasSynchronouslyLoaded) {
|
|
if (wasSynchronouslyLoaded || frame != null) {
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
onAnimationReady?.call();
|
|
});
|
|
}
|
|
return child;
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
if (descriptor == null || MediaQuery.disableAnimationsOf(context)) {
|
|
return AvatarImage(
|
|
imageUrl: descriptor?.posterUrl ?? imageUrl,
|
|
radius: radius,
|
|
backgroundColor: backgroundColor,
|
|
fallback: fallback,
|
|
);
|
|
}
|
|
|
|
return CircleAvatar(
|
|
radius: radius,
|
|
backgroundColor: Colors.transparent,
|
|
child: ClipOval(
|
|
child: SizedBox.square(
|
|
dimension: radius * 2,
|
|
child: ProgressiveAnimatedAvatar(
|
|
descriptor: descriptor,
|
|
fallback: fallback,
|
|
loadingImage: loadingImage,
|
|
onAnimationReady: onAnimationReady,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|