mirror of
https://github.com/block/buzz.git
synced 2026-11-26 03:01:38 +00:00
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>
88 lines
2.8 KiB
Dart
88 lines
2.8 KiB
Dart
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),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|