mirror of
https://github.com/block/buzz.git
synced 2026-10-31 14:31:02 +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>
150 lines
4.3 KiB
Dart
150 lines
4.3 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
import '../../shared/theme/theme.dart';
|
|
import '../../shared/widgets/ios_glass_navigation_button.dart';
|
|
|
|
/// Space between avatar-editor controls and their labels.
|
|
const avatarEditorOptionLabelGap = Grid.half;
|
|
|
|
/// A labelled circular option used by the profile avatar editor rails.
|
|
class AvatarEditorOptionButton extends StatelessWidget {
|
|
/// Creates a selectable avatar-editor rail option.
|
|
const AvatarEditorOptionButton({
|
|
super.key,
|
|
required this.icon,
|
|
this.iosIcon,
|
|
required this.label,
|
|
required this.selected,
|
|
required this.onTap,
|
|
this.labelMaxWidth,
|
|
});
|
|
|
|
/// The symbol displayed inside the circular control.
|
|
final IconData icon;
|
|
|
|
/// Native symbol used by the iOS liquid-glass control.
|
|
final IosGlassNavigationIcon? iosIcon;
|
|
|
|
/// The text displayed beneath the control.
|
|
final String label;
|
|
|
|
/// Whether this option represents the active editor section.
|
|
final bool selected;
|
|
|
|
/// Called when the option is selected, or null when disabled.
|
|
final VoidCallback? onTap;
|
|
|
|
/// Optional width constraint for the label's overflow region.
|
|
final double? labelMaxWidth;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final handleTap = onTap == null
|
|
? null
|
|
: () {
|
|
unawaited(HapticFeedback.selectionClick());
|
|
onTap!();
|
|
};
|
|
Widget labelWidget() {
|
|
final width = labelMaxWidth;
|
|
if (width != null) {
|
|
return SizedBox(
|
|
height: 20,
|
|
child: OverflowBox(
|
|
maxWidth: width,
|
|
maxHeight: 20,
|
|
child: Text(
|
|
label,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: context.textTheme.labelSmall?.copyWith(
|
|
color: selected
|
|
? context.colors.onSurface
|
|
: context.colors.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
return Text(
|
|
label,
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: context.textTheme.labelSmall?.copyWith(
|
|
color: selected
|
|
? context.colors.onSurface
|
|
: context.colors.onSurfaceVariant,
|
|
),
|
|
);
|
|
}
|
|
|
|
if (defaultTargetPlatform == TargetPlatform.iOS && iosIcon != null) {
|
|
return Column(
|
|
children: [
|
|
IosGlassNavigationButton(
|
|
icon: iosIcon!,
|
|
semanticLabel: label,
|
|
onPressed: handleTap,
|
|
width: 64,
|
|
height: 64,
|
|
controlSize: 64,
|
|
foregroundColor: selected
|
|
? context.colors.primary
|
|
: context.colors.onSurface,
|
|
isSelected: selected,
|
|
),
|
|
const SizedBox(height: avatarEditorOptionLabelGap),
|
|
ExcludeSemantics(child: labelWidget()),
|
|
],
|
|
);
|
|
}
|
|
return Semantics(
|
|
label: label,
|
|
button: true,
|
|
selected: selected,
|
|
enabled: handleTap != null,
|
|
onTap: handleTap,
|
|
child: ExcludeSemantics(
|
|
child: InkResponse(
|
|
radius: 34,
|
|
onTap: handleTap,
|
|
child: SizedBox(
|
|
width: double.infinity,
|
|
child: Column(
|
|
children: [
|
|
AnimatedContainer(
|
|
duration: MediaQuery.disableAnimationsOf(context)
|
|
? Duration.zero
|
|
: const Duration(milliseconds: 150),
|
|
curve: Curves.easeOutCubic,
|
|
width: 64,
|
|
height: 64,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: selected
|
|
? context.colors.onSurface
|
|
: context.colors.surfaceContainerHighest,
|
|
),
|
|
child: Icon(
|
|
icon,
|
|
size: 26,
|
|
color: selected
|
|
? context.colors.surface
|
|
: context.colors.onSurface,
|
|
),
|
|
),
|
|
const SizedBox(height: avatarEditorOptionLabelGap),
|
|
labelWidget(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|