Files
buzz/mobile/lib/shared/widgets/onboarding_step_page.dart
klopez4212 e922dc08ff Unify mobile onboarding and community entry screens (#8687)
## 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>
2026-10-29 16:12:31 +00:00

215 lines
9.8 KiB
Dart

import 'dart:ui' show ImageFilter;
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/semantics.dart';
import '../theme/theme.dart';
import 'ios_navigation_bar.dart';
/// Opaque onboarding chrome shared by account setup and identity import.
/// A scrollable minimum-height body keeps actions at the bottom without
/// clipping content when the keyboard or larger accessibility text is shown.
class OnboardingStepPage extends StatelessWidget {
const OnboardingStepPage({
super.key,
required this.title,
this.subtitle,
this.onConnectionOptions,
this.foregroundProgress = 0,
this.keyboardBottomSpacing = Grid.sm,
required this.onBack,
required this.content,
this.actions = const [],
});
final String title;
final String? subtitle;
final VoidCallback? onConnectionOptions;
final double foregroundProgress;
final double keyboardBottomSpacing;
final VoidCallback onBack;
final Widget content;
final List<Widget> actions;
@override
Widget build(BuildContext context) {
final theme = utilitySurfaceThemeData(Theme.of(context));
final ios = defaultTargetPlatform == TargetPlatform.iOS;
final buttonStyle = FilledButton.styleFrom(
minimumSize: const Size.fromHeight(52),
shape: const StadiumBorder(),
);
return Theme(
data: theme.copyWith(
filledButtonTheme: FilledButtonThemeData(style: buttonStyle),
outlinedButtonTheme: OutlinedButtonThemeData(style: buttonStyle),
textButtonTheme: TextButtonThemeData(style: buttonStyle),
),
child: PopScope(
canPop: false,
onPopInvokedWithResult: (didPop, _) {
if (!didPop) onBack();
},
child: Scaffold(
backgroundColor: theme.colorScheme.surface,
body: SafeArea(
top: !ios,
child: ExcludeFocus(
excluding: foregroundProgress > 0,
child: ExcludeSemantics(
excluding: foregroundProgress > 0,
child: IgnorePointer(
ignoring: foregroundProgress > 0,
child: Opacity(
key: const Key('scanner-welcome-opacity'),
opacity: 1 - foregroundProgress,
child: Transform.scale(
key: const Key('scanner-welcome-scale'),
scale: MediaQuery.disableAnimationsOf(context)
? 1
: 1 - .04 * foregroundProgress,
child: ImageFiltered(
enabled:
!MediaQuery.disableAnimationsOf(context) &&
foregroundProgress > 0 &&
foregroundProgress < 1,
imageFilter: ImageFilter.blur(
sigmaX: 16 * foregroundProgress,
sigmaY: 16 * foregroundProgress,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (ios)
SizedBox(
height:
MediaQuery.paddingOf(context).top +
IosNavigationMetrics.of(
context,
).compactHeight,
child: IosNavigationBar(
title: '',
leading: IosNavigationAction(
label: 'Back',
symbol: 'chevron.backward',
onPressed: onBack,
),
),
)
else
Align(
alignment: AlignmentDirectional.centerStart,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: Grid.xxs,
),
child: IconButton(
tooltip: 'Back',
onPressed: onBack,
icon: const BackButtonIcon(),
),
),
),
Expanded(
child: CustomScrollView(
keyboardDismissBehavior:
ScrollViewKeyboardDismissBehavior.onDrag,
slivers: [
SliverFillRemaining(
hasScrollBody: false,
child: Padding(
padding: EdgeInsets.fromLTRB(
Grid.sm,
Grid.sm,
Grid.sm,
MediaQuery.viewInsetsOf(
context,
).bottom >
0
? keyboardBottomSpacing
: Grid.sm,
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.stretch,
children: [
GestureDetector(
key: onConnectionOptions == null
? null
: const Key(
'developer-pairing-trigger',
),
excludeFromSemantics: true,
child: Semantics(
header: true,
namesRoute: true,
customSemanticsActions:
onConnectionOptions == null
? null
: {
const CustomSemanticsAction(
label:
'More connection options',
): onConnectionOptions!,
},
child: Text(
title,
style: OnboardingTypography
.title
.copyWith(
color: theme
.colorScheme
.onSurface,
),
),
),
),
if (subtitle != null) ...[
const SizedBox(height: Grid.xs),
Text(
subtitle!,
style: OnboardingTypography
.subtitle
.copyWith(
color: theme
.colorScheme
.onSurfaceVariant,
),
),
],
const SizedBox(height: Grid.xs),
content,
const Spacer(),
if (actions.isNotEmpty)
const SizedBox(height: Grid.sm),
for (
var i = 0;
i < actions.length;
i++
) ...[
if (i > 0)
const SizedBox(height: Grid.xxs),
actions[i],
],
],
),
),
),
],
),
),
],
),
),
),
),
),
),
),
),
),
),
);
}
}