mirror of
https://github.com/block/buzz.git
synced 2026-11-29 04:32:08 +00:00
## Summary Use consistent fullscreen screens for identity setup, community selection, joining, and Add Community. Restore all memberships and open the selected community; share the community grid with the switcher. Add QR-first choices, animated link entry with 12px keyboard clearance, a two-finger double-tap pairing toggle, and the centered reversing bee loader. Preserve cancellation, Back, and reduced-motion behavior. Add intentionally omits community creation and Builderlab sign-in: this route follows sign-in and the existing-community picker. ### Related issue Related: #8628 (native profile setup). No duplicate fullscreen onboarding PR found. ### Testing - Full standard and hosted-authentication mobile suites, static analysis, and required push checks passed. - iPhone preview iterated with Kenny; final simulator walkthrough below uses synthetic data and does not authenticate or save account changes. - Independent review completed; regressions cover cancellation during loading, Add recovery after failed/conflicting memberships, retrying skipped communities, and explicit picker stages. Walkthrough recorded before the copy and recovery followups: https://github.com/user-attachments/assets/bfea3ad3-1dde-40c4-8748-44c84226c292 --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
458 lines
16 KiB
Dart
458 lines
16 KiB
Dart
part of '../pairing_page.dart';
|
|
|
|
/// Keeps the selected community surface in place as it opens into a form.
|
|
class _OnboardingConnectionView extends HookWidget {
|
|
const _OnboardingConnectionView({
|
|
required this.enteringLink,
|
|
required this.onCommunityLink,
|
|
required this.onBack,
|
|
required this.onOpenCommunity,
|
|
required this.onPairing,
|
|
});
|
|
|
|
final bool enteringLink;
|
|
final VoidCallback? onCommunityLink;
|
|
final VoidCallback? onBack;
|
|
final ValueChanged<Uri> onOpenCommunity;
|
|
final VoidCallback? onPairing;
|
|
|
|
double _textProgress(double progress, bool opening) =>
|
|
opening ? ((progress - 0.2) / 0.8).clamp(0.0, 1.0) : progress;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final reducedMotion = MediaQuery.disableAnimationsOf(context);
|
|
final ios = defaultTargetPlatform == TargetPlatform.iOS;
|
|
final staggerEntrance = enteringLink && !ios;
|
|
// Match the iOS return motion, starting after keyboard preparation.
|
|
final duration = reducedMotion
|
|
? Duration.zero
|
|
: Duration(milliseconds: ios ? 200 : 150);
|
|
final controller = useTextEditingController();
|
|
final focus = useFocusNode();
|
|
// Keep the return destination stable while keyboard insets change.
|
|
// A new viewport (for example rotation) gets a fresh measurement.
|
|
final viewport = MediaQuery.sizeOf(context);
|
|
final restingHeight = useMemoized(() => <double?>[null], [viewport]);
|
|
final keyboardReady = useCommunityLinkFocus(
|
|
context,
|
|
enteringLink: enteringLink,
|
|
focus: focus,
|
|
);
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: Grid.gutter),
|
|
child: Column(
|
|
children: [
|
|
Align(
|
|
alignment: Alignment.centerLeft,
|
|
child: defaultTargetPlatform == TargetPlatform.iOS
|
|
? IosGlassNavigationButton(
|
|
key: const Key('community-link-back'),
|
|
icon: IosGlassNavigationIcon.back,
|
|
semanticLabel: 'Back',
|
|
foregroundColor: context.colors.onSurface,
|
|
onPressed: onBack,
|
|
)
|
|
: BackButton(
|
|
key: const Key('community-link-back'),
|
|
color: context.colors.onSurface,
|
|
onPressed: onBack,
|
|
),
|
|
),
|
|
Expanded(
|
|
child: LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
if (!enteringLink &&
|
|
MediaQuery.viewInsetsOf(context).bottom == 0) {
|
|
restingHeight[0] ??= constraints.maxHeight;
|
|
}
|
|
return TweenAnimationBuilder<double>(
|
|
tween: Tween(
|
|
end: enteringLink && (!ios || keyboardReady) ? 1 : 0,
|
|
),
|
|
duration: duration,
|
|
curve: ios
|
|
? Curves.easeOutCubic
|
|
: enteringLink
|
|
? Curves.easeOutQuad
|
|
: Curves.easeOutCubic.flipped,
|
|
builder: (context, progress, _) => _CommunityLinkForm(
|
|
controller: controller,
|
|
focusNode: focus,
|
|
showBack: false,
|
|
fullPage: true,
|
|
autofocus: false,
|
|
showHeading: false,
|
|
onOpen: onOpenCommunity,
|
|
onBack: onBack,
|
|
layoutBuilder: (fields, action) => CustomMultiChildLayout(
|
|
delegate: _ConnectionLayout(
|
|
progress: progress,
|
|
opening: staggerEntrance,
|
|
restingHeight: restingHeight[0],
|
|
),
|
|
children: [
|
|
LayoutId(
|
|
id: 'heading',
|
|
child: SingleChildScrollView(
|
|
child: Stack(
|
|
children: [
|
|
_ConnectionMotionLayer(
|
|
progress:
|
|
1 -
|
|
_textProgress(progress, staggerEntrance),
|
|
active: !enteringLink,
|
|
maintainSize: true,
|
|
child: const _ConnectionHeading(
|
|
title: 'Connect to a community',
|
|
subtitle:
|
|
'Enter a community link or use a pairing code to continue.',
|
|
),
|
|
),
|
|
_ConnectionMotionLayer(
|
|
progress: _textProgress(
|
|
progress,
|
|
staggerEntrance,
|
|
),
|
|
active: enteringLink,
|
|
maintainSize: true,
|
|
child: const _ConnectionHeading(
|
|
title: 'Enter a community link',
|
|
subtitle:
|
|
'Paste an invite link or community address.',
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
LayoutId(
|
|
id: 'scan',
|
|
child: _ConnectionMotionLayer(
|
|
key: const Key('connection-options-motion'),
|
|
progress: 1 - progress,
|
|
active: !enteringLink,
|
|
maintainSize: true,
|
|
child: _OnboardingChoiceContainer(
|
|
title: 'Use a pairing code',
|
|
icon: BuzzIcons.qrcode,
|
|
subtitle:
|
|
'Paste the pairing code from your desktop app.',
|
|
onTap: onPairing,
|
|
),
|
|
),
|
|
),
|
|
LayoutId(
|
|
id: 'surface',
|
|
child: DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
color: Color.lerp(
|
|
context.colors.surface,
|
|
context.colors.primary,
|
|
progress,
|
|
),
|
|
borderRadius: BorderRadius.circular(
|
|
Radii.container +
|
|
(26 - Radii.container) * progress,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
LayoutId(
|
|
id: 'link',
|
|
child: _ConnectionMotionLayer(
|
|
progress: 1 - progress,
|
|
active: !enteringLink,
|
|
maintainSize: true,
|
|
child: _OnboardingChoiceContainer(
|
|
title: 'Enter a community link',
|
|
transparent: true,
|
|
icon: BuzzIcons.link,
|
|
subtitle:
|
|
'Join a community with its address or invite.',
|
|
onTap: onCommunityLink,
|
|
),
|
|
),
|
|
),
|
|
LayoutId(
|
|
id: 'action',
|
|
child: _ConnectionMotionLayer(
|
|
progress: progress,
|
|
active: enteringLink,
|
|
maintainSize: true,
|
|
child: action,
|
|
),
|
|
),
|
|
LayoutId(
|
|
id: 'form',
|
|
child: _ConnectionMotionLayer(
|
|
key: const Key('community-form-motion'),
|
|
maintainSize: true,
|
|
progress: staggerEntrance
|
|
? ((progress - 0.4) / 0.6).clamp(0.0, 1.0)
|
|
: (progress / 0.8).clamp(0.0, 1.0),
|
|
active: enteringLink,
|
|
child: fields,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Measures the cards so the resting heading sits directly above them,
|
|
/// independent of text wrapping. Both states share the same moving heading.
|
|
class _ConnectionLayout extends MultiChildLayoutDelegate {
|
|
_ConnectionLayout({
|
|
required this.progress,
|
|
required this.opening,
|
|
this.restingHeight,
|
|
});
|
|
|
|
final bool opening;
|
|
|
|
final double? restingHeight;
|
|
|
|
final double progress;
|
|
|
|
@override
|
|
void performLayout(Size size) {
|
|
final baselineHeight = restingHeight ?? size.height;
|
|
final heading = layoutChild(
|
|
'heading',
|
|
BoxConstraints(
|
|
minWidth: size.width,
|
|
maxWidth: size.width,
|
|
maxHeight: size.height / 3,
|
|
),
|
|
);
|
|
final cardConstraints = BoxConstraints(
|
|
minWidth: size.width,
|
|
maxWidth: size.width,
|
|
maxHeight: baselineHeight,
|
|
);
|
|
final scan = layoutChild('scan', cardConstraints);
|
|
final link = layoutChild('link', cardConstraints);
|
|
final restingTop =
|
|
(baselineHeight -
|
|
Grid.sm -
|
|
link.height -
|
|
Grid.xs -
|
|
scan.height -
|
|
Grid.sm -
|
|
heading.height)
|
|
.clamp(0.0, baselineHeight);
|
|
final expandedTop = Grid.sm.toDouble();
|
|
final movement = opening ? (progress / 0.8).clamp(0.0, 1.0) : progress;
|
|
final headingTop = restingTop + (expandedTop - restingTop) * movement;
|
|
positionChild('heading', Offset(0, headingTop));
|
|
positionChild(
|
|
'scan',
|
|
Offset(
|
|
0,
|
|
baselineHeight -
|
|
Grid.sm -
|
|
link.height -
|
|
Grid.xs -
|
|
scan.height +
|
|
Grid.sm * progress,
|
|
),
|
|
);
|
|
final linkTop = baselineHeight - Grid.sm - link.height;
|
|
final actionTop = size.height - Grid.sm - 52;
|
|
final sharedTop = linkTop + (actionTop - linkTop) * progress;
|
|
positionChild('link', Offset(0, sharedTop));
|
|
layoutChild(
|
|
'surface',
|
|
BoxConstraints.tight(
|
|
Size(size.width, link.height + (52 - link.height) * progress),
|
|
),
|
|
);
|
|
positionChild('surface', Offset(0, sharedTop));
|
|
layoutChild(
|
|
'action',
|
|
BoxConstraints.tight(
|
|
Size(size.width, link.height + (52 - link.height) * progress),
|
|
),
|
|
);
|
|
positionChild('action', Offset(0, sharedTop));
|
|
if (hasChild('form')) {
|
|
final formTop = expandedTop + heading.height + Grid.sm;
|
|
layoutChild(
|
|
'form',
|
|
BoxConstraints.tight(
|
|
Size(
|
|
size.width,
|
|
(size.height - formTop - Grid.sm - 52 - Grid.xs).clamp(
|
|
0.0,
|
|
size.height,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
positionChild('form', Offset(0, headingTop + heading.height + Grid.sm));
|
|
}
|
|
}
|
|
|
|
@override
|
|
bool shouldRelayout(_ConnectionLayout oldDelegate) =>
|
|
oldDelegate.progress != progress ||
|
|
oldDelegate.opening != opening ||
|
|
oldDelegate.restingHeight != restingHeight;
|
|
}
|
|
|
|
class _ConnectionHeading extends StatelessWidget {
|
|
const _ConnectionHeading({required this.title, required this.subtitle});
|
|
final String title;
|
|
final String subtitle;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: OnboardingTypography.title.copyWith(
|
|
color: context.colors.onSurface,
|
|
),
|
|
),
|
|
const SizedBox(height: Grid.xs),
|
|
Text(
|
|
subtitle,
|
|
style: OnboardingTypography.subtitle.copyWith(
|
|
color: context.colors.onSurfaceVariant,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
class _ConnectionMotionLayer extends StatelessWidget {
|
|
const _ConnectionMotionLayer({
|
|
super.key,
|
|
required this.progress,
|
|
required this.active,
|
|
required this.child,
|
|
this.maintainSize = false,
|
|
});
|
|
final double progress;
|
|
final bool active;
|
|
final Widget child;
|
|
final bool maintainSize;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Visibility(
|
|
visible: active || progress > 0,
|
|
maintainState: true,
|
|
maintainAnimation: true,
|
|
maintainSize: maintainSize,
|
|
child: IgnorePointer(
|
|
ignoring: !active,
|
|
child: ExcludeFocus(
|
|
excluding: !active,
|
|
child: ExcludeSemantics(
|
|
excluding: !active,
|
|
child: Opacity(opacity: progress, child: child),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
class _OnboardingChoiceContainer extends StatelessWidget {
|
|
const _OnboardingChoiceContainer({
|
|
required this.title,
|
|
required this.subtitle,
|
|
required this.icon,
|
|
this.onTap,
|
|
this.transparent = false,
|
|
});
|
|
|
|
final String title;
|
|
final String subtitle;
|
|
final IconData icon;
|
|
final bool transparent;
|
|
final VoidCallback? onTap;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Semantics(
|
|
button: onTap != null,
|
|
label: title,
|
|
hint: subtitle,
|
|
onTap: onTap,
|
|
child: ExcludeSemantics(
|
|
excluding: true,
|
|
child: Material(
|
|
// White surface cards over the onboarding artwork.
|
|
color: transparent ? Colors.transparent : context.colors.surface,
|
|
borderRadius: BorderRadius.circular(Radii.container),
|
|
clipBehavior: Clip.antiAlias,
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
excludeFromSemantics: true,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(Grid.gutter),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
ExcludeSemantics(
|
|
child: SizedBox(
|
|
width: Grid.sm,
|
|
height: Grid.sm,
|
|
child: Icon(
|
|
icon,
|
|
size: Grid.sm,
|
|
color: context.colors.onSurface,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: Grid.xs),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Align the visible glyphs with the icon, accounting
|
|
// for the title font's leading above its cap height.
|
|
Transform.translate(
|
|
offset: const Offset(0, -2),
|
|
child: Text(
|
|
title,
|
|
style: context.textTheme.titleSmall?.copyWith(
|
|
color: context.colors.onSurface,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: Grid.half),
|
|
Text(
|
|
subtitle,
|
|
style: context.textTheme.bodyMedium?.copyWith(
|
|
color: context.colors.onSurfaceVariant,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|