Files
buzz/mobile/lib/features/onboarding/hosted_community_selection.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

92 lines
2.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../shared/hosted/hosted_flow.dart';
import '../../shared/theme/grid.dart';
import '../../shared/community/community_grid.dart';
import '../../shared/community/community_grid_option.dart';
import '../../shared/community/community_grid_add.dart';
import '../../onboarding_app_entry.dart';
import '../../shared/widgets/onboarding_step_page.dart';
/// Community selection is completed before admission reveals Home.
class HostedCommunitySelection extends HookConsumerWidget {
const HostedCommunitySelection({
super.key,
required this.flow,
this.onAddCommunity,
this.fullScreen = false,
this.onBack,
});
final HostedFlow flow;
final VoidCallback? onAddCommunity;
final bool fullScreen;
final VoidCallback? onBack;
@override
Widget build(BuildContext context, WidgetRef ref) {
useListenable(flow);
Future<void> addCommunity() async {
final navigator = Navigator.of(context, rootNavigator: true);
if (!await flow.prepareToAddCommunity() || !navigator.mounted) return;
late final MaterialPageRoute<void> route;
var exiting = false;
Future<void> exit() async {
if (exiting) return;
exiting = true;
await flow.signInAccount();
if (flow.stage == HostedFlowStage.signIn ||
flow.stage == HostedFlowStage.idle) {
exiting = false;
return;
}
if (route.isActive) route.navigator?.removeRoute(route);
}
route = MaterialPageRoute<void>(
builder: (_) => OnboardingAppEntry(
addingCommunity: true,
restoreAccount: false,
onExit: exit,
),
);
navigator.push(route);
// Mount the opaque entry route before retiring the setup cover.
WidgetsBinding.instance.addPostFrameCallback((_) {
if (route.isActive) flow.leave();
});
}
final choices = CommunityGrid(
children: [
for (final community in flow.communities)
CommunityGridOption(
id: community.relayUrl,
name: community.name,
relayUrl: community.relayUrl,
onSelect: (_) async {
flow.chooseLandingCommunity(community.relayUrl);
await flow.addSelectedCommunities();
},
),
CommunityGridAdd(onTap: onAddCommunity ?? addCommunity),
],
);
if (fullScreen) {
return OnboardingStepPage(
title: 'Select a community',
onBack: onBack ?? () {},
content: choices,
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
choices,
const SizedBox(height: Grid.sm),
],
);
}
}