mirror of
https://github.com/block/buzz.git
synced 2026-11-30 13:12:38 +00:00
Bring buzz.xyz branding and animated bees to mobile welcome (#8853)
Replaces the mobile welcome gradient with buzz.xyz’s green and 12 animated bees. The swarm keeps flying through rotation, respects Reduce Motion, and leaves controls tappable; the primary button label is now white. The ghost button has an opaque chartreuse fill so bees cannot show through its text. Validated in the iPhone simulator, with animation/rotation journeys, analysis, and the full mobile suite passing. Agent review found no blockers. https://github.com/user-attachments/assets/9aa1472c-c8e5-4e8b-a016-a8cba36805e1 --------- Signed-off-by: kenny lopez <klopez4212@gmail.com> Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
This commit is contained in:
1
mobile/assets/images/welcome-bee.svg
Normal file
1
mobile/assets/images/welcome-bee.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 466 309"><!-- Bee geometry from https://buzz.xyz, retrieved 2026-10-31. --><path fill="#231e1e" fill-rule="evenodd" d="M128 70.3 A91.7 91.7 0 1 0 128 238.7 Z M338 70.3 A91.7 91.7 0 1 1 338 238.7 Z M162 0 H304 A34 34 0 0 1 338 34 V275 A34 34 0 0 1 304 309 H162 A34 34 0 0 1 128 275 V34 A34 34 0 0 1 162 0 Z M220.3 84.4 A27 27 0 1 1 166.3 84.4 A27 27 0 1 1 220.3 84.4 Z M303 84.4 A27 27 0 1 1 249 84.4 A27 27 0 1 1 303 84.4 Z M171.3 157.2 H298.2 A5 5 0 0 1 303.2 162.2 V190.5 A5 5 0 0 1 298.2 195.5 H171.3 A5 5 0 0 1 166.3 190.5 V162.2 A5 5 0 0 1 171.3 157.2 Z M171.9 235.1 H298.1 A5 5 0 0 1 303.1 240.1 V267.7 A5 5 0 0 1 298.1 272.7 H171.9 A5 5 0 0 1 166.9 267.7 V240.1 A5 5 0 0 1 171.9 235.1 Z"/></svg>
|
||||
|
After Width: | Height: | Size: 756 B |
@@ -7,6 +7,7 @@ import '../../shared/hosted/hosted_community_creation.dart';
|
||||
import '../../shared/hosted/hosted_environment.dart';
|
||||
import '../../shared/hosted/hosted_flow_problem_message.dart';
|
||||
import 'dart:math' show sqrt2;
|
||||
import 'dart:math' as math;
|
||||
import 'dart:ui' show ImageFilter;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -16,6 +17,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter/semantics.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:buzz/shared/theme/buzz_icons.dart';
|
||||
|
||||
@@ -36,6 +38,9 @@ import '../../shared/widgets/onboarding_step_page.dart';
|
||||
import 'pairing_qr_scanner.dart';
|
||||
|
||||
part 'pairing_page/onboarding_background.dart';
|
||||
part 'pairing_page/website_welcome_background.dart';
|
||||
part 'pairing_page/website_bee_swarm.dart';
|
||||
part 'pairing_page/website_bee_motion.dart';
|
||||
part 'pairing_page/onboarding_colors.dart';
|
||||
part 'pairing_page/onboarding_glass_button.dart';
|
||||
part 'pairing_page/pairing_welcome_view.dart';
|
||||
@@ -175,8 +180,16 @@ class PairingPage extends HookConsumerWidget {
|
||||
}
|
||||
|
||||
final isVerifyingSas = pairingState.status == PairingStatus.confirmingSas;
|
||||
final websiteWelcome =
|
||||
connectionLanding &&
|
||||
!addingCommunity &&
|
||||
!existingUser &&
|
||||
!enteringCommunityLink &&
|
||||
!creatingCommunity &&
|
||||
setupContent == null &&
|
||||
!isVerifyingSas;
|
||||
final onboardingSystemOverlayStyle =
|
||||
(context._onboardingIsDark
|
||||
(context._onboardingIsDark && !websiteWelcome
|
||||
? SystemUiOverlayStyle.light
|
||||
: SystemUiOverlayStyle.dark)
|
||||
.copyWith(statusBarColor: Colors.transparent);
|
||||
@@ -349,6 +362,7 @@ class PairingPage extends HookConsumerWidget {
|
||||
key: const Key('pairing-onboarding-system-overlay'),
|
||||
value: onboardingSystemOverlayStyle,
|
||||
child: _OnboardingBackground(
|
||||
websiteWelcome: websiteWelcome,
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset:
|
||||
hostedFlow?.stage != HostedFlowStage.profile,
|
||||
|
||||
@@ -2,11 +2,18 @@ part of '../pairing_page.dart';
|
||||
|
||||
class _OnboardingBackground extends StatelessWidget {
|
||||
final Widget child;
|
||||
final bool websiteWelcome;
|
||||
|
||||
const _OnboardingBackground({required this.child});
|
||||
const _OnboardingBackground({
|
||||
required this.child,
|
||||
this.websiteWelcome = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (websiteWelcome) {
|
||||
return _WebsiteWelcomeBackground(child: child);
|
||||
}
|
||||
final isDark = context._onboardingIsDark;
|
||||
return DecoratedBox(
|
||||
key: const Key('pairing-onboarding-background'),
|
||||
|
||||
@@ -8,7 +8,7 @@ extension _OnboardingColors on BuildContext {
|
||||
Color get _onboardingMutedInk =>
|
||||
_onboardingIsDark ? const Color(0xFFAAB8C0) : const Color(0xB3111111);
|
||||
Color get _onboardingCtaLabel =>
|
||||
_onboardingIsDark ? const Color(0xFF172229) : const Color(0xFFD7E6F0);
|
||||
_onboardingIsDark ? const Color(0xFF172229) : Colors.white;
|
||||
Color get _onboardingErrorInk => colors.error;
|
||||
Color get _onboardingInputSurface => _onboardingIsDark
|
||||
? const Color(0xFF233039)
|
||||
|
||||
@@ -41,7 +41,9 @@ extension _OnboardingActionStyles on BuildContext {
|
||||
|
||||
ButtonStyle get _onboardingGhostButtonStyle =>
|
||||
_onboardingSecondaryButtonStyle.copyWith(
|
||||
backgroundColor: const WidgetStatePropertyAll(Colors.transparent),
|
||||
backgroundColor:
|
||||
Theme.of(this).textButtonTheme.style?.backgroundColor ??
|
||||
const WidgetStatePropertyAll(Colors.transparent),
|
||||
side: WidgetStateProperty.resolveWith(
|
||||
(states) => states.contains(WidgetState.focused)
|
||||
? BorderSide(color: _onboardingInk, width: 2)
|
||||
|
||||
146
mobile/lib/features/pairing/pairing_page/website_bee_motion.dart
Normal file
146
mobile/lib/features/pairing/pairing_page/website_bee_motion.dart
Normal file
@@ -0,0 +1,146 @@
|
||||
part of '../pairing_page.dart';
|
||||
|
||||
// Port of buzz.xyz's BeeSwarm flight model (2026-10-31): wandering heading,
|
||||
// periodic darting, separation, home attraction, and soft edge turns.
|
||||
class _WebsiteBee {
|
||||
Offset position;
|
||||
Offset velocity = Offset.zero;
|
||||
Offset home;
|
||||
Offset entrance;
|
||||
final double seed;
|
||||
double heading;
|
||||
double rotation;
|
||||
|
||||
_WebsiteBee(Size size, int index)
|
||||
: seed = ((index + 1) * 0.7548776662) % 1,
|
||||
position = Offset(
|
||||
(0.5 + (index + 1) / 1.324717957244746) % 1 * size.width,
|
||||
(0.5 + (index + 1) / math.pow(1.324717957244746, 2)) % 1 * size.height,
|
||||
),
|
||||
home = Offset(
|
||||
(0.12 + ((0.5 + (index + 1) / 1.324717957244746) % 1) * 0.76) *
|
||||
size.width,
|
||||
(0.14 +
|
||||
((0.5 + (index + 1) / math.pow(1.324717957244746, 2)) % 1) *
|
||||
0.72) *
|
||||
size.height,
|
||||
),
|
||||
entrance = Offset(
|
||||
size.width / 2 +
|
||||
math.cos(
|
||||
((index + 1) * 0.7548776662 % 1) * math.pi * 2 + index * 0.37,
|
||||
) *
|
||||
(size.width * 0.7 + 46),
|
||||
size.height / 2 +
|
||||
math.sin(
|
||||
((index + 1) * 0.7548776662 % 1) * math.pi * 2 + index * 0.37,
|
||||
) *
|
||||
(size.height * 0.7 + 31),
|
||||
),
|
||||
heading = ((index + 1) * 0.7548776662 % 1) * math.pi * 2,
|
||||
rotation = ((index + 1) * 0.7548776662 % 1) * math.pi * 2 + math.pi / 2;
|
||||
}
|
||||
|
||||
class _WebsiteBeeMotion {
|
||||
Size size;
|
||||
late final bees = List.generate(12, (index) => _WebsiteBee(size, index));
|
||||
double elapsed = 0;
|
||||
|
||||
_WebsiteBeeMotion(this.size);
|
||||
|
||||
// Preserve each bee and the flight clock across rotation/window resizing.
|
||||
// Mapping positions to the new bounds avoids replaying the entrance or
|
||||
// leaving a portrait swarm outside a shorter landscape viewport.
|
||||
void resize(Size nextSize) {
|
||||
if (nextSize == size || nextSize.isEmpty || size.isEmpty) return;
|
||||
Offset remap(Offset point) => Offset(
|
||||
point.dx / size.width * nextSize.width,
|
||||
point.dy / size.height * nextSize.height,
|
||||
);
|
||||
for (final bee in bees) {
|
||||
bee.position = remap(bee.position);
|
||||
bee.home = remap(bee.home);
|
||||
bee.entrance = remap(bee.entrance);
|
||||
}
|
||||
size = nextSize;
|
||||
}
|
||||
|
||||
void advance(double dt, Offset? pointer) {
|
||||
elapsed += dt;
|
||||
final positions = bees.map((bee) => bee.position).toList();
|
||||
for (var index = 0; index < bees.length; index++) {
|
||||
final bee = bees[index];
|
||||
final p = bee.position;
|
||||
final seed = bee.seed;
|
||||
const tau = math.pi * 2;
|
||||
var heading =
|
||||
bee.heading +
|
||||
(math.sin(elapsed * (0.27 + seed * 0.4) + seed * tau) +
|
||||
0.6 * math.sin(elapsed * (0.13 + seed * 0.11) + seed * 7)) *
|
||||
1.15 *
|
||||
dt;
|
||||
double edge(double value, double extent) => value < 110
|
||||
? 1 - value / 110
|
||||
: value > extent - 110
|
||||
? -(1 - (extent - value) / 110)
|
||||
: 0;
|
||||
final turn = Offset(edge(p.dx, size.width), edge(p.dy, size.height));
|
||||
if (turn != Offset.zero) {
|
||||
final delta = (turn.direction - heading + math.pi * 3) % tau - math.pi;
|
||||
heading += delta * 3.2 * math.min(1, turn.distance) * dt;
|
||||
}
|
||||
final phase = (elapsed * (0.24 + seed * 0.2) + seed * 5.37) % 1;
|
||||
final burst = phase < 0.18 ? math.sin(phase / 0.18 * math.pi) : 0.0;
|
||||
final speed = math.max(
|
||||
58 * 0.46,
|
||||
58 *
|
||||
(1 +
|
||||
math.sin(elapsed * (0.42 + seed * 0.28) + seed * tau) *
|
||||
0.32) +
|
||||
math.max(1, size.width) * 1.1 * burst,
|
||||
);
|
||||
final target = Offset(math.cos(heading), math.sin(heading)) * speed;
|
||||
var velocity =
|
||||
bee.velocity + (target - bee.velocity) * (2.4 + 11 * burst) * dt;
|
||||
for (var other = 0; other < positions.length; other++) {
|
||||
if (other == index) continue;
|
||||
final delta = p - positions[other];
|
||||
final distance = delta.distance;
|
||||
if (distance > 0 && distance < 66) {
|
||||
velocity += delta * (1300 * (1 - distance / 66) / distance) * dt;
|
||||
}
|
||||
}
|
||||
if (pointer != null) {
|
||||
final delta = p - pointer;
|
||||
final distance = delta.distance;
|
||||
if (distance > 0 && distance < 380) {
|
||||
velocity += delta * (1600 * (1 - distance / 380) / distance) * dt;
|
||||
}
|
||||
}
|
||||
velocity += (bee.home - p) * 0.18 * dt;
|
||||
velocity += turn * 900 * dt;
|
||||
velocity *= 0.97;
|
||||
var next = p + velocity * dt;
|
||||
if (next.dx < 0 || next.dx > size.width) {
|
||||
velocity = Offset(-velocity.dx * 0.5, velocity.dy);
|
||||
}
|
||||
if (next.dy < 0 || next.dy > size.height) {
|
||||
velocity = Offset(velocity.dx, -velocity.dy * 0.5);
|
||||
}
|
||||
next = Offset(
|
||||
next.dx.clamp(0, size.width),
|
||||
next.dy.clamp(0, size.height),
|
||||
);
|
||||
bee.position = next;
|
||||
bee.velocity = velocity;
|
||||
bee.heading = heading;
|
||||
if (velocity.distance > 6) {
|
||||
final delta =
|
||||
(velocity.direction + math.pi / 2 - bee.rotation + math.pi * 3) %
|
||||
tau -
|
||||
math.pi;
|
||||
bee.rotation += delta * 0.18;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
part of '../pairing_page.dart';
|
||||
|
||||
class _WebsiteBeeSwarm extends HookWidget {
|
||||
final Size size;
|
||||
final ObjectRef<Offset?> pointer;
|
||||
|
||||
const _WebsiteBeeSwarm({required this.size, required this.pointer});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final motion = useMemoized(() => _WebsiteBeeMotion(size));
|
||||
if (motion.size != size) {
|
||||
motion.resize(size);
|
||||
pointer.value = null;
|
||||
}
|
||||
final clock = useAnimationController(duration: const Duration(days: 1));
|
||||
final lifecycle = useAppLifecycleState();
|
||||
final reducedMotion = MediaQuery.disableAnimationsOf(context);
|
||||
final playing =
|
||||
!reducedMotion &&
|
||||
TickerMode.valuesOf(context).enabled &&
|
||||
(lifecycle == null || lifecycle == AppLifecycleState.resumed);
|
||||
useEffect(() {
|
||||
if (!playing) return null;
|
||||
var previous = Duration.zero;
|
||||
var remainder = 0.0;
|
||||
void tick() {
|
||||
final now = clock.lastElapsedDuration ?? Duration.zero;
|
||||
// Fixed 60 Hz reproduces the site's per-frame damping on 60/120 Hz
|
||||
// phones. Cap catch-up after stalls; never simulate a background gap.
|
||||
remainder += ((now - previous).inMicroseconds / 1e6).clamp(0, 0.05);
|
||||
previous = now;
|
||||
while (remainder >= 1 / 60) {
|
||||
motion.advance(1 / 60, pointer.value);
|
||||
remainder -= 1 / 60;
|
||||
}
|
||||
}
|
||||
|
||||
clock.addListener(tick);
|
||||
clock.repeat();
|
||||
return () {
|
||||
clock.removeListener(tick);
|
||||
clock.stop();
|
||||
};
|
||||
}, [clock, motion, playing]);
|
||||
|
||||
return ClipRect(
|
||||
key: const Key('welcome-bee-flight-area'),
|
||||
child: Stack(
|
||||
children: [
|
||||
for (var index = 0; index < motion.bees.length; index++)
|
||||
AnimatedBuilder(
|
||||
animation: clock,
|
||||
child: SvgPicture.asset(
|
||||
'assets/images/welcome-bee.svg',
|
||||
width: 46,
|
||||
height: 31,
|
||||
colorFilter: ColorFilter.mode(
|
||||
index.isOdd
|
||||
? const Color(0xFFD7E7F5)
|
||||
: const Color(0xFF231E1E),
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
),
|
||||
builder: (context, child) {
|
||||
final bee = motion.bees[index];
|
||||
final progress = (motion.elapsed / 1.05).clamp(0.0, 1.0);
|
||||
final entrance = reducedMotion
|
||||
? 1.0
|
||||
: 1 - math.pow(1 - progress, 3).toDouble();
|
||||
final position = Offset.lerp(
|
||||
bee.entrance,
|
||||
bee.position,
|
||||
entrance,
|
||||
)!;
|
||||
return Transform.translate(
|
||||
key: ValueKey('welcome-bee-$index'),
|
||||
offset: position,
|
||||
child: Transform.rotate(angle: bee.rotation, child: child),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
part of '../pairing_page.dart';
|
||||
|
||||
// Colours and bee silhouette from https://buzz.xyz (2026-10-31).
|
||||
// The bee layer uses the website’s flight model and remains decorative.
|
||||
class _WebsiteWelcomeBackground extends HookWidget {
|
||||
final Widget child;
|
||||
|
||||
const _WebsiteWelcomeBackground({required this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final pointer = useRef<Offset?>(null);
|
||||
final theme = AppTheme.light();
|
||||
return MouseRegion(
|
||||
onHover: (event) => pointer.value = event.localPosition,
|
||||
onExit: (_) => pointer.value = null,
|
||||
child: Listener(
|
||||
onPointerDown: (event) => pointer.value = event.localPosition,
|
||||
onPointerMove: (event) => pointer.value = event.localPosition,
|
||||
onPointerUp: (_) => pointer.value = null,
|
||||
onPointerCancel: (_) => pointer.value = null,
|
||||
child: DecoratedBox(
|
||||
key: const Key('pairing-website-welcome-background'),
|
||||
decoration: const BoxDecoration(color: Color(0xFFD7D72E)),
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
if (MediaQuery.textScalerOf(context).scale(16) <= 24)
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: ExcludeSemantics(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => RepaintBoundary(
|
||||
child: _WebsiteBeeSwarm(
|
||||
size: constraints.biggest,
|
||||
pointer: pointer,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Theme(
|
||||
data: theme.copyWith(
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: theme.textButtonTheme.style?.copyWith(
|
||||
backgroundColor: const WidgetStatePropertyAll(
|
||||
Color(0xFFD7D72E),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: child,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,7 @@ flutter:
|
||||
shaders:
|
||||
- shaders/onboarding_wordmark.frag
|
||||
assets:
|
||||
- assets/images/welcome-bee.svg
|
||||
- assets/images/buzz-icon.png
|
||||
- assets/images/shell-gradient.png
|
||||
- assets/images/buzz-wordmark.png
|
||||
|
||||
@@ -49,11 +49,11 @@ void main() {
|
||||
overrides: [hostedFlowProvider.overrideWithValue(f.flow)],
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await pumpUntilVisible(tester, find.bySemanticsLabel('Buzz'));
|
||||
await revealOptionsWithSemantics(tester);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
tester.view.physicalSize = const Size(420, 900);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
final linkCard = find.ancestor(
|
||||
of: find.text('Enter a community link').hitTestable(),
|
||||
matching: find.byType(InkWell),
|
||||
@@ -72,7 +72,7 @@ void main() {
|
||||
greaterThanOrEqualTo(24),
|
||||
);
|
||||
tester.view.physicalSize = const Size(320, 640);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
final optionTop = tester
|
||||
.getTopLeft(find.text('Enter a community link').hitTestable())
|
||||
.dy;
|
||||
@@ -118,7 +118,7 @@ void main() {
|
||||
}
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
await pumpUntilVisible(tester, find.text('Use a pairing code'));
|
||||
expect(tester.testTextInput.isVisible, isFalse);
|
||||
expect(find.text('Use a pairing code').hitTestable(), findsOneWidget);
|
||||
await tester.tap(find.text('Enter a community link').hitTestable());
|
||||
@@ -150,7 +150,7 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
tester.view.viewInsets = const FakeViewPadding();
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
await pumpUntilVisible(tester, find.text('Use a pairing code'));
|
||||
expect(tester.testTextInput.isVisible, isFalse);
|
||||
expect(find.text('Use pairing code'), findsNothing);
|
||||
await tester.tap(find.text('Use a pairing code').hitTestable());
|
||||
@@ -162,7 +162,7 @@ void main() {
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.text('Back').hitTestable());
|
||||
await tester.pumpAndSettle();
|
||||
await pumpUntilVisible(tester, find.text('or sign in with email'));
|
||||
expect(
|
||||
find.text('or sign in with email').hitTestable(),
|
||||
findsOneWidget,
|
||||
@@ -379,10 +379,31 @@ Future<void> revealOptionsWithSemantics(WidgetTester tester) async {
|
||||
ui.SemanticsAction.customAction,
|
||||
actionIds.single,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await pumpUntilVisible(tester, find.text('Use a pairing code'));
|
||||
expect(find.text('Enter a community link').hitTestable(), findsOneWidget);
|
||||
expect(find.text('Use a pairing code').hitTestable(), findsOneWidget);
|
||||
} finally {
|
||||
handle.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// The welcome bees intentionally never settle. Wait for the requested control
|
||||
// and its ancestor fades to finish instead of waiting for every app animation.
|
||||
Future<void> pumpUntilVisible(WidgetTester tester, Finder target) async {
|
||||
bool visible() {
|
||||
final hit = target.hitTestable();
|
||||
if (hit.evaluate().length != 1) return false;
|
||||
return tester
|
||||
.widgetList<Opacity>(
|
||||
find.ancestor(of: hit, matching: find.byType(Opacity)),
|
||||
)
|
||||
.every((opacity) => opacity.opacity == 1);
|
||||
}
|
||||
|
||||
for (var frame = 0; frame < 120; frame++) {
|
||||
await tester.pump(const Duration(milliseconds: 16));
|
||||
if (visible()) return;
|
||||
}
|
||||
expect(target.hitTestable(), findsOneWidget);
|
||||
expect(visible(), isTrue, reason: 'The control must finish fading in');
|
||||
}
|
||||
|
||||
@@ -314,9 +314,30 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
final opacity = find.byKey(const Key('scanner-welcome-opacity'));
|
||||
final scale = find.byKey(const Key('scanner-welcome-scale'));
|
||||
// The welcome swarm animates continuously. Wait for the scanner's
|
||||
// observable transition endpoint rather than global frame idleness.
|
||||
Future<void> waitForOpacity(double target) async {
|
||||
for (
|
||||
var frame = 0;
|
||||
frame < 120 &&
|
||||
(tester.widget<Opacity>(opacity).opacity != target ||
|
||||
(target == 1 &&
|
||||
find
|
||||
.byKey(
|
||||
const ValueKey('dynamic-island-qr-scanner-portal'),
|
||||
)
|
||||
.evaluate()
|
||||
.isNotEmpty));
|
||||
frame++
|
||||
) {
|
||||
await tester.pump(const Duration(milliseconds: 16));
|
||||
}
|
||||
expect(tester.widget<Opacity>(opacity).opacity, target);
|
||||
}
|
||||
|
||||
expect(tester.widget<Opacity>(opacity).opacity, 1);
|
||||
if (adding) {
|
||||
// Only foreground controls transition; the opaque page stays fixed.
|
||||
@@ -351,7 +372,7 @@ void main() {
|
||||
closeTo(1 - 0.04 * progress, 0.001),
|
||||
);
|
||||
}
|
||||
await tester.pumpAndSettle();
|
||||
await waitForOpacity(0);
|
||||
expect(tester.widget<Opacity>(opacity).opacity, 0);
|
||||
expect(
|
||||
tester.widget<Transform>(scale).transform.storage[0],
|
||||
@@ -367,7 +388,8 @@ void main() {
|
||||
findsNothing,
|
||||
);
|
||||
await tester.tapAt(const Offset(196.5, 700));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await waitForOpacity(1);
|
||||
expect(tester.widget<Opacity>(opacity).opacity, 1);
|
||||
expect(tester.widget<Transform>(scale).transform.storage[0], 1);
|
||||
expect(
|
||||
|
||||
121
mobile/test/features/pairing/website_bee_motion_test.dart
Normal file
121
mobile/test/features/pairing/website_bee_motion_test.dart
Normal file
@@ -0,0 +1,121 @@
|
||||
import 'package:buzz/features/pairing/pairing_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import '../../helpers/widget_helpers.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'welcome flight moves, pauses accessibly, and leaves actions usable',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(402, 874);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final reducedMotion = ValueNotifier(false);
|
||||
addTearDown(reducedMotion.dispose);
|
||||
var communityLinks = 0;
|
||||
await tester.pumpWidget(
|
||||
WidgetHelpers.testable(
|
||||
child: ValueListenableBuilder<bool>(
|
||||
valueListenable: reducedMotion,
|
||||
builder: (context, reduced, _) => MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(disableAnimations: reduced),
|
||||
child: PairingPage(
|
||||
connectionLanding: true,
|
||||
onCommunityLink: () => communityLinks++,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
Offset beePosition() {
|
||||
final transform = tester
|
||||
.widget<Transform>(find.byKey(const ValueKey('welcome-bee-0')))
|
||||
.transform;
|
||||
return Offset(transform.storage[12], transform.storage[13]);
|
||||
}
|
||||
|
||||
final entrance = beePosition();
|
||||
for (var frame = 0; frame < 120; frame++) {
|
||||
await tester.pump(const Duration(milliseconds: 17));
|
||||
}
|
||||
expect(beePosition(), isNot(entrance));
|
||||
final flying = beePosition();
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
expect(beePosition(), isNot(flying));
|
||||
await tester.tap(find.text('Enter a community link').hitTestable());
|
||||
expect(communityLinks, 1);
|
||||
|
||||
expect(find.byKey(const ValueKey('welcome-bee-11')), findsOneWidget);
|
||||
Size flightSize() =>
|
||||
tester.getSize(find.byKey(const Key('welcome-bee-flight-area')));
|
||||
final portraitSize = flightSize();
|
||||
final portrait = beePosition();
|
||||
tester.view.physicalSize = const Size(874, 402);
|
||||
await tester.pump();
|
||||
expect(
|
||||
beePosition().dx,
|
||||
closeTo(portrait.dx / portraitSize.width * flightSize().width, 0.001),
|
||||
);
|
||||
expect(
|
||||
beePosition().dy,
|
||||
closeTo(portrait.dy / portraitSize.height * flightSize().height, 0.001),
|
||||
);
|
||||
expect(find.byKey(const ValueKey('welcome-bee-11')), findsOneWidget);
|
||||
final landscapeSize = flightSize();
|
||||
final landscape = beePosition();
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
expect(beePosition(), isNot(landscape));
|
||||
await tester.ensureVisible(find.text('Enter a community link'));
|
||||
await tester.pump();
|
||||
await tester.tap(find.text('Enter a community link').hitTestable());
|
||||
expect(communityLinks, 2);
|
||||
final beforeReturn = beePosition();
|
||||
tester.view.physicalSize = const Size(402, 874);
|
||||
await tester.pump();
|
||||
expect(
|
||||
beePosition().dx,
|
||||
closeTo(
|
||||
beforeReturn.dx / landscapeSize.width * flightSize().width,
|
||||
0.001,
|
||||
),
|
||||
);
|
||||
expect(
|
||||
beePosition().dy,
|
||||
closeTo(
|
||||
beforeReturn.dy / landscapeSize.height * flightSize().height,
|
||||
0.001,
|
||||
),
|
||||
);
|
||||
|
||||
reducedMotion.value = true;
|
||||
await tester.pump();
|
||||
final still = beePosition();
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
expect(beePosition(), still);
|
||||
expect(find.bySemanticsLabel('Buzz'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel('Animated bee'), findsNothing);
|
||||
|
||||
reducedMotion.value = false;
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
expect(beePosition(), isNot(still));
|
||||
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
|
||||
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.hidden);
|
||||
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.paused);
|
||||
await tester.pump();
|
||||
final paused = beePosition();
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
expect(beePosition(), paused);
|
||||
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.hidden);
|
||||
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
|
||||
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
expect(beePosition(), isNot(paused));
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user