feat: add more easter eggs

This commit is contained in:
2026-10-26 23:54:06 +01:00
parent 08f4847800
commit 4d9ba67eb1
18 changed files with 695 additions and 36 deletions
+9 -1
View File
@@ -18,6 +18,7 @@ import '../../viewmodels/remote_sync_view_model.dart';
import '../../viewmodels/settings_view_model.dart';
import '../dialogs/close_tab_dialog.dart';
import '../dialogs/edit_tab_dialog.dart';
import '../widgets/venue_title.dart';
import 'product_grid.dart';
import 'tab_panel.dart';
@@ -118,10 +119,17 @@ class _BarScreenViewState extends State<BarScreenView> {
final viewModel = context.watch<BarScreenViewModel>();
final productsViewModel = context.watch<ProductListViewModel>();
final settings = context.watch<SettingsViewModel>().settings;
final venueName = context.select<RemoteSyncViewModel, String?>(
(viewModel) => viewModel.venueName,
);
return Scaffold(
appBar: AppBar(
title: Text(l10n.barTabs),
title: VenueTitle(
text: venueName == null || venueName.trim().isEmpty
? l10n.barTabs
: venueName,
),
actions: [
IconButton(
tooltip: _showSearch ? l10n.closeSearch : l10n.searchTabs,
+133 -2
View File
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
@@ -147,10 +148,15 @@ class ProductGrid extends StatelessWidget {
itemBuilder: (context, index) {
final product = products[index];
return ProductTile(
product: product,
return _FireTile(
key: ValueKey(product.id),
enabled: hasSelectedTab,
onTap: () => onProductTap(product),
builder: (onTap) => ProductTile(
product: product,
enabled: hasSelectedTab,
onTap: onTap,
),
);
},
);
@@ -161,3 +167,128 @@ class ProductGrid extends StatelessWidget {
);
}
}
/// Five quick taps on the same product set its tile on fire for a moment.
class _FireTile extends StatefulWidget {
final bool enabled;
final VoidCallback onTap;
final Widget Function(VoidCallback onTap) builder;
const _FireTile({
super.key,
required this.enabled,
required this.onTap,
required this.builder,
});
@override
State<_FireTile> createState() => _FireTileState();
}
class _FireTileState extends State<_FireTile>
with SingleTickerProviderStateMixin {
static const _tapsNeeded = 5;
static const _tapWindow = Duration(milliseconds: 700);
static const _burnTime = Duration(milliseconds: 2500);
late final AnimationController _flicker = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 180),
);
int _tapCount = 0;
DateTime? _lastTap;
Timer? _burnTimer;
bool get _isOnFire => _burnTimer != null;
@override
void dispose() {
_burnTimer?.cancel();
_flicker.dispose();
super.dispose();
}
void _onTap() {
widget.onTap();
final now = DateTime.now();
final last = _lastTap;
_tapCount = last != null && now.difference(last) < _tapWindow
? _tapCount + 1
: 1;
_lastTap = now;
if (_tapCount < _tapsNeeded && !_isOnFire) return;
// Each extra quick tap keeps it burning.
_burnTimer?.cancel();
_burnTimer = Timer(_burnTime, () {
if (!mounted) return;
_flicker.stop();
setState(() => _burnTimer = null);
});
if (!_flicker.isAnimating) _flicker.repeat(reverse: true);
setState(() {});
}
@override
Widget build(BuildContext context) {
return Stack(
fit: StackFit.expand,
clipBehavior: Clip.none,
children: [
widget.builder(_onTap),
IgnorePointer(
child: AnimatedOpacity(
opacity: _isOnFire ? 1 : 0,
duration: const Duration(milliseconds: 300),
child: AnimatedBuilder(
animation: _flicker,
builder: (context, _) {
final heat = _flicker.value;
return Stack(
fit: StackFit.expand,
clipBehavior: Clip.none,
children: [
DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
border: Border.all(
color: Color.lerp(
Colors.deepOrange,
Colors.amber,
heat,
)!,
width: 2.5,
),
boxShadow: [
BoxShadow(
color: Colors.deepOrange.withValues(
alpha: 0.45 + 0.3 * heat,
),
blurRadius: 14 + 10 * heat,
spreadRadius: 1 + 2 * heat,
),
],
),
),
Positioned(
left: 8,
bottom: 6,
child: Transform.scale(
scale: 1 + 0.15 * heat,
alignment: Alignment.bottomCenter,
child: const Text('🔥', style: TextStyle(fontSize: 26)),
),
),
],
);
},
),
),
),
],
);
}
}
+128 -28
View File
@@ -8,6 +8,7 @@ import 'package:flutter_slidable/flutter_slidable.dart';
import '../../l10n/app_localizations.dart';
import '../../models/bar_tab.dart';
import '../../models/tab_item.dart';
import '../../utils/easter_eggs.dart';
import '../../utils/money.dart';
import '../../utils/name_index.dart';
import 'selected_tab_details.dart';
@@ -578,7 +579,7 @@ class _TabCard extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Text(
tab.customerName,
customerDisplayName(tab.customerName),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -602,7 +603,7 @@ class _TabCard extends StatelessWidget {
}
}
class _LetterIndexBar extends StatelessWidget {
class _LetterIndexBar extends StatefulWidget {
final Set<String> availableLetters;
final String? activeLetter;
final bool isTouched;
@@ -617,20 +618,80 @@ class _LetterIndexBar extends StatelessWidget {
required this.onReleased,
});
@override
State<_LetterIndexBar> createState() => _LetterIndexBarState();
}
class _LetterIndexBarState extends State<_LetterIndexBar>
with SingleTickerProviderStateMixin {
static final _zIndex = indexLetters.indexOf('Z');
/// Sliding (rather than tapping) leaves a fading trail of rainbow dots.
bool _isSliding = false;
/// Progress of an A → Z → A slide: null once broken, else whether Z was hit.
bool? _reachedZ;
/// Sweeps a rainbow down the bar after a full A → Z → A slide.
late final AnimationController _wave = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 1400),
);
@override
void dispose() {
_wave.dispose();
super.dispose();
}
void _setSliding(bool value) {
if (_isSliding != value) setState(() => _isSliding = value);
}
void _trackRainbowRoad(int index, {bool isStart = false}) {
if (isStart) {
_reachedZ = index == 0 ? false : null;
} else if (_reachedZ == false && index >= _zIndex) {
_reachedZ = true;
} else if (_reachedZ == true && index == 0) {
_reachedZ = null;
_wave.forward(from: 0);
ScaffoldMessenger.maybeOf(context)
?..hideCurrentSnackBar()
..showSnackBar(
SnackBar(content: Text(AppLocalizations.of(context).rainbowRoad)),
);
}
}
static Color _rainbowAt(int index) => HSVColor.fromAHSV(
1,
360 * index / indexLetters.length,
0.75,
0.95,
).toColor();
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final onLetterSelected = widget.onLetterSelected;
void onReleased() {
_setSliding(false);
widget.onReleased();
}
return LayoutBuilder(
builder: (context, constraints) {
final letterHeight = constraints.maxHeight / indexLetters.length;
final fontSize = min(13.0, letterHeight * 0.65);
String letterAt(Offset position) {
final index = (position.dy / letterHeight).floor();
return indexLetters[index.clamp(0, indexLetters.length - 1)];
}
int indexAt(Offset position) => (position.dy / letterHeight)
.floor()
.clamp(0, indexLetters.length - 1);
String letterAt(Offset position) => indexLetters[indexAt(position)];
return GestureDetector(
behavior: HitTestBehavior.opaque,
@@ -638,31 +699,49 @@ class _LetterIndexBar extends StatelessWidget {
onLetterSelected(letterAt(details.localPosition)),
onTapUp: (_) => onReleased(),
onTapCancel: onReleased,
onVerticalDragStart: (details) =>
onLetterSelected(letterAt(details.localPosition)),
onVerticalDragUpdate: (details) =>
onLetterSelected(letterAt(details.localPosition)),
onVerticalDragStart: (details) {
_setSliding(true);
_trackRainbowRoad(indexAt(details.localPosition), isStart: true);
onLetterSelected(letterAt(details.localPosition));
},
onVerticalDragUpdate: (details) {
_trackRainbowRoad(indexAt(details.localPosition));
onLetterSelected(letterAt(details.localPosition));
},
onVerticalDragEnd: (_) => onReleased(),
onVerticalDragCancel: onReleased,
child: SizedBox(
width: 28,
child: Column(
children: [
for (final letter in indexLetters)
SizedBox(
height: letterHeight,
child: Center(
child: _IndexLetter(
letter: letter,
fontSize: fontSize,
isActive: letter == activeLetter,
isTouched: isTouched,
hasNames: availableLetters.contains(letter),
scheme: scheme,
child: AnimatedBuilder(
animation: _wave,
builder: (context, _) {
final isWaving = _wave.isAnimating;
// Runs past both ends so the first and last dots fade too.
final crest = _wave.value * (indexLetters.length + 8) - 2;
return Column(
children: [
for (final (index, letter) in indexLetters.indexed)
SizedBox(
height: letterHeight,
child: Center(
child: _IndexLetter(
letter: letter,
fontSize: fontSize,
isActive: letter == widget.activeLetter,
isTouched: widget.isTouched,
isLit: isWaving && (crest - index).abs() < 1.5,
hasNames: widget.availableLetters.contains(letter),
rainbowColor: _isSliding || isWaving
? _rainbowAt(index)
: null,
scheme: scheme,
),
),
),
),
),
],
],
);
},
),
),
);
@@ -676,7 +755,13 @@ class _IndexLetter extends StatelessWidget {
final double fontSize;
final bool isActive;
final bool isTouched;
/// Lit by the rainbow road wave, regardless of touch.
final bool isLit;
final bool hasNames;
/// Set while sliding: the dot takes this color and fades out slowly.
final Color? rainbowColor;
final ColorScheme scheme;
const _IndexLetter({
@@ -684,13 +769,19 @@ class _IndexLetter extends StatelessWidget {
required this.fontSize,
required this.isActive,
required this.isTouched,
this.isLit = false,
required this.hasNames,
this.rainbowColor,
required this.scheme,
});
@override
Widget build(BuildContext context) {
final rainbowColor = this.rainbowColor;
final showDot = (isActive && isTouched) || isLit;
final color = switch ((isActive, isTouched, hasNames)) {
_ when isLit && rainbowColor != null => Colors.white,
(true, true, _) when rainbowColor != null => Colors.white,
(true, true, _) => scheme.onPrimary,
(true, false, _) => scheme.primary,
(false, _, true) => scheme.onSurface,
@@ -698,13 +789,22 @@ class _IndexLetter extends StatelessWidget {
};
return AnimatedContainer(
duration: const Duration(milliseconds: 120),
// Applies to the transition being started, so a sliding dot appears
// instantly but lingers on its way out.
duration: Duration(
milliseconds: rainbowColor != null && !showDot ? 600 : 120,
),
width: fontSize * 1.8,
height: fontSize * 1.8,
alignment: Alignment.center,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: isActive && isTouched ? scheme.primary : Colors.transparent,
color: switch ((showDot, rainbowColor)) {
(true, final Color rainbow?) => rainbow,
(true, null) => scheme.primary,
(false, final Color rainbow?) => rainbow.withValues(alpha: 0),
(false, null) => Colors.transparent,
},
),
child: Text(
letter,