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
+8 -1
View File
@@ -356,5 +356,12 @@
"placeholders": { "placeholders": {
"amount": {"type": "String"} "amount": {"type": "String"}
} }
} },
"creditsDirectedBy": "Directed by",
"creditsStarring": "Starring",
"creditsSpecialThanks": "Special thanks",
"creditsEveryoneAtTheBar": "Everyone at the bar",
"creditsDrinkResponsibly": "Drink responsibly. Mostly.",
"lazyPinRemark": "🤨 Really?",
"rainbowRoad": "Rainbow road 🌈"
} }
+42
View File
@@ -2035,6 +2035,48 @@ abstract class AppLocalizations {
/// In en, this message translates to: /// In en, this message translates to:
/// **'Let the customer scan this code to pay {amount}'** /// **'Let the customer scan this code to pay {amount}'**
String scanToPay(String amount); String scanToPay(String amount);
/// No description provided for @creditsDirectedBy.
///
/// In en, this message translates to:
/// **'Directed by'**
String get creditsDirectedBy;
/// No description provided for @creditsStarring.
///
/// In en, this message translates to:
/// **'Starring'**
String get creditsStarring;
/// No description provided for @creditsSpecialThanks.
///
/// In en, this message translates to:
/// **'Special thanks'**
String get creditsSpecialThanks;
/// No description provided for @creditsEveryoneAtTheBar.
///
/// In en, this message translates to:
/// **'Everyone at the bar'**
String get creditsEveryoneAtTheBar;
/// No description provided for @creditsDrinkResponsibly.
///
/// In en, this message translates to:
/// **'Drink responsibly. Mostly.'**
String get creditsDrinkResponsibly;
/// No description provided for @lazyPinRemark.
///
/// In en, this message translates to:
/// **'🤨 Really?'**
String get lazyPinRemark;
/// No description provided for @rainbowRoad.
///
/// In en, this message translates to:
/// **'Rainbow road 🌈'**
String get rainbowRoad;
} }
class _AppLocalizationsDelegate class _AppLocalizationsDelegate
+21
View File
@@ -1082,4 +1082,25 @@ class AppLocalizationsEn extends AppLocalizations {
String scanToPay(String amount) { String scanToPay(String amount) {
return 'Let the customer scan this code to pay $amount'; return 'Let the customer scan this code to pay $amount';
} }
@override
String get creditsDirectedBy => 'Directed by';
@override
String get creditsStarring => 'Starring';
@override
String get creditsSpecialThanks => 'Special thanks';
@override
String get creditsEveryoneAtTheBar => 'Everyone at the bar';
@override
String get creditsDrinkResponsibly => 'Drink responsibly. Mostly.';
@override
String get lazyPinRemark => '🤨 Really?';
@override
String get rainbowRoad => 'Rainbow road 🌈';
} }
+21
View File
@@ -1096,4 +1096,25 @@ class AppLocalizationsNl extends AppLocalizations {
String scanToPay(String amount) { String scanToPay(String amount) {
return 'Laat de klant deze code scannen om $amount te betalen'; return 'Laat de klant deze code scannen om $amount te betalen';
} }
@override
String get creditsDirectedBy => 'Geregisseerd door';
@override
String get creditsStarring => 'Met in de hoofdrol';
@override
String get creditsSpecialThanks => 'Speciale dank aan';
@override
String get creditsEveryoneAtTheBar => 'Iedereen aan de toog';
@override
String get creditsDrinkResponsibly => 'Drink met mate. Meestal.';
@override
String get lazyPinRemark => '🤨 Echt?';
@override
String get rainbowRoad => 'Regenboogweg 🌈';
} }
+8 -1
View File
@@ -344,5 +344,12 @@
"deviceNameHint": "bv. Bartoestel 1", "deviceNameHint": "bv. Bartoestel 1",
"registrationCodeHelper": "Je vindt deze code op het dashboard bij toestellen.", "registrationCodeHelper": "Je vindt deze code op het dashboard bij toestellen.",
"venueNowLinked": "Dit toestel is nu gekoppeld aan {venue}.", "venueNowLinked": "Dit toestel is nu gekoppeld aan {venue}.",
"scanToPay": "Laat de klant deze code scannen om {amount} te betalen" "scanToPay": "Laat de klant deze code scannen om {amount} te betalen",
"creditsDirectedBy": "Geregisseerd door",
"creditsStarring": "Met in de hoofdrol",
"creditsSpecialThanks": "Speciale dank aan",
"creditsEveryoneAtTheBar": "Iedereen aan de toog",
"creditsDrinkResponsibly": "Drink met mate. Meestal.",
"lazyPinRemark": "🤨 Echt?",
"rainbowRoad": "Regenboogweg 🌈"
} }
+22
View File
@@ -104,6 +104,28 @@ class RemoteSyncService {
/// Null for devices linked before the name was kept. /// Null for devices linked before the name was kept.
Future<String?> get venueName => secureStorage.read(key: _venueNameKey); Future<String?> get venueName => secureStorage.read(key: _venueNameKey);
/// Looks up and keeps the venue's name for a device linked before the
/// name was kept. Null when it can't be found, e.g. while offline.
Future<String?> fetchVenueName() async {
final venueId = await this.venueId;
if (venueId == null) return null;
try {
final venues = await apiClient.getVenues();
final name = venues
.where((venue) => venue.id == venueId)
.firstOrNull
?.name;
if (name != null) {
await secureStorage.write(key: _venueNameKey, value: name);
}
return name;
} on Exception catch (e) {
debugPrint('RemoteSyncService: fetchVenueName error: $e');
return null;
}
}
Future<bool> get isConfigured async => await _credentials() != null; Future<bool> get isConfigured async => await _credentials() != null;
Future<String?> get authToken async => (await _credentials())?.token; Future<String?> get authToken async => (await _credentials())?.token;
+13
View File
@@ -0,0 +1,13 @@
/// Names that get a crown wherever a tab's customer name is shown.
const _royalNames = {'bram verhulst'};
bool isRoyalCustomer(String name) => _royalNames.contains(
name.trim().toLowerCase().replaceAll(RegExp(r'\s+'), ' '),
);
/// Display-only: never use the result as the stored customer name.
String customerDisplayName(String name) =>
isRoyalCustomer(name) ? '$name 👑' : name;
/// PINs that earn a raised eyebrow on the PIN pad.
bool isLazyPin(String pin) => pin == '1234' || pin == '0000';
@@ -62,6 +62,16 @@ class RemoteSyncViewModel extends ChangeNotifier {
_hasLoaded = true; _hasLoaded = true;
notifyListeners(); notifyListeners();
if (_isConfigured && _venueName == null) unawaited(_fetchVenueName());
}
Future<void> _fetchVenueName() async {
final name = await syncService.fetchVenueName();
if (name == null) return;
_venueName = name;
notifyListeners();
} }
/// Called once registration stored new credentials. /// Called once registration stored new credentials.
+9 -1
View File
@@ -18,6 +18,7 @@ import '../../viewmodels/remote_sync_view_model.dart';
import '../../viewmodels/settings_view_model.dart'; import '../../viewmodels/settings_view_model.dart';
import '../dialogs/close_tab_dialog.dart'; import '../dialogs/close_tab_dialog.dart';
import '../dialogs/edit_tab_dialog.dart'; import '../dialogs/edit_tab_dialog.dart';
import '../widgets/venue_title.dart';
import 'product_grid.dart'; import 'product_grid.dart';
import 'tab_panel.dart'; import 'tab_panel.dart';
@@ -118,10 +119,17 @@ class _BarScreenViewState extends State<BarScreenView> {
final viewModel = context.watch<BarScreenViewModel>(); final viewModel = context.watch<BarScreenViewModel>();
final productsViewModel = context.watch<ProductListViewModel>(); final productsViewModel = context.watch<ProductListViewModel>();
final settings = context.watch<SettingsViewModel>().settings; final settings = context.watch<SettingsViewModel>().settings;
final venueName = context.select<RemoteSyncViewModel, String?>(
(viewModel) => viewModel.venueName,
);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(l10n.barTabs), title: VenueTitle(
text: venueName == null || venueName.trim().isEmpty
? l10n.barTabs
: venueName,
),
actions: [ actions: [
IconButton( IconButton(
tooltip: _showSearch ? l10n.closeSearch : l10n.searchTabs, tooltip: _showSearch ? l10n.closeSearch : l10n.searchTabs,
+133 -2
View File
@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:math'; import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -147,10 +148,15 @@ class ProductGrid extends StatelessWidget {
itemBuilder: (context, index) { itemBuilder: (context, index) {
final product = products[index]; final product = products[index];
return ProductTile( return _FireTile(
product: product, key: ValueKey(product.id),
enabled: hasSelectedTab, enabled: hasSelectedTab,
onTap: () => onProductTap(product), 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)),
),
),
],
);
},
),
),
),
],
);
}
}
+117 -17
View File
@@ -8,6 +8,7 @@ import 'package:flutter_slidable/flutter_slidable.dart';
import '../../l10n/app_localizations.dart'; import '../../l10n/app_localizations.dart';
import '../../models/bar_tab.dart'; import '../../models/bar_tab.dart';
import '../../models/tab_item.dart'; import '../../models/tab_item.dart';
import '../../utils/easter_eggs.dart';
import '../../utils/money.dart'; import '../../utils/money.dart';
import '../../utils/name_index.dart'; import '../../utils/name_index.dart';
import 'selected_tab_details.dart'; import 'selected_tab_details.dart';
@@ -578,7 +579,7 @@ class _TabCard extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
tab.customerName, customerDisplayName(tab.customerName),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
@@ -602,7 +603,7 @@ class _TabCard extends StatelessWidget {
} }
} }
class _LetterIndexBar extends StatelessWidget { class _LetterIndexBar extends StatefulWidget {
final Set<String> availableLetters; final Set<String> availableLetters;
final String? activeLetter; final String? activeLetter;
final bool isTouched; final bool isTouched;
@@ -617,20 +618,80 @@ class _LetterIndexBar extends StatelessWidget {
required this.onReleased, 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); final theme = Theme.of(context);
final scheme = theme.colorScheme; final scheme = theme.colorScheme;
final onLetterSelected = widget.onLetterSelected;
void onReleased() {
_setSliding(false);
widget.onReleased();
}
return LayoutBuilder( return LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
final letterHeight = constraints.maxHeight / indexLetters.length; final letterHeight = constraints.maxHeight / indexLetters.length;
final fontSize = min(13.0, letterHeight * 0.65); final fontSize = min(13.0, letterHeight * 0.65);
String letterAt(Offset position) { int indexAt(Offset position) => (position.dy / letterHeight)
final index = (position.dy / letterHeight).floor(); .floor()
return indexLetters[index.clamp(0, indexLetters.length - 1)]; .clamp(0, indexLetters.length - 1);
}
String letterAt(Offset position) => indexLetters[indexAt(position)];
return GestureDetector( return GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
@@ -638,31 +699,49 @@ class _LetterIndexBar extends StatelessWidget {
onLetterSelected(letterAt(details.localPosition)), onLetterSelected(letterAt(details.localPosition)),
onTapUp: (_) => onReleased(), onTapUp: (_) => onReleased(),
onTapCancel: onReleased, onTapCancel: onReleased,
onVerticalDragStart: (details) => onVerticalDragStart: (details) {
onLetterSelected(letterAt(details.localPosition)), _setSliding(true);
onVerticalDragUpdate: (details) => _trackRainbowRoad(indexAt(details.localPosition), isStart: true);
onLetterSelected(letterAt(details.localPosition)), onLetterSelected(letterAt(details.localPosition));
},
onVerticalDragUpdate: (details) {
_trackRainbowRoad(indexAt(details.localPosition));
onLetterSelected(letterAt(details.localPosition));
},
onVerticalDragEnd: (_) => onReleased(), onVerticalDragEnd: (_) => onReleased(),
onVerticalDragCancel: onReleased, onVerticalDragCancel: onReleased,
child: SizedBox( child: SizedBox(
width: 28, width: 28,
child: Column( 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: [ children: [
for (final letter in indexLetters) for (final (index, letter) in indexLetters.indexed)
SizedBox( SizedBox(
height: letterHeight, height: letterHeight,
child: Center( child: Center(
child: _IndexLetter( child: _IndexLetter(
letter: letter, letter: letter,
fontSize: fontSize, fontSize: fontSize,
isActive: letter == activeLetter, isActive: letter == widget.activeLetter,
isTouched: isTouched, isTouched: widget.isTouched,
hasNames: availableLetters.contains(letter), isLit: isWaving && (crest - index).abs() < 1.5,
hasNames: widget.availableLetters.contains(letter),
rainbowColor: _isSliding || isWaving
? _rainbowAt(index)
: null,
scheme: scheme, scheme: scheme,
), ),
), ),
), ),
], ],
);
},
), ),
), ),
); );
@@ -676,7 +755,13 @@ class _IndexLetter extends StatelessWidget {
final double fontSize; final double fontSize;
final bool isActive; final bool isActive;
final bool isTouched; final bool isTouched;
/// Lit by the rainbow road wave, regardless of touch.
final bool isLit;
final bool hasNames; final bool hasNames;
/// Set while sliding: the dot takes this color and fades out slowly.
final Color? rainbowColor;
final ColorScheme scheme; final ColorScheme scheme;
const _IndexLetter({ const _IndexLetter({
@@ -684,13 +769,19 @@ class _IndexLetter extends StatelessWidget {
required this.fontSize, required this.fontSize,
required this.isActive, required this.isActive,
required this.isTouched, required this.isTouched,
this.isLit = false,
required this.hasNames, required this.hasNames,
this.rainbowColor,
required this.scheme, required this.scheme,
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final rainbowColor = this.rainbowColor;
final showDot = (isActive && isTouched) || isLit;
final color = switch ((isActive, isTouched, hasNames)) { final color = switch ((isActive, isTouched, hasNames)) {
_ when isLit && rainbowColor != null => Colors.white,
(true, true, _) when rainbowColor != null => Colors.white,
(true, true, _) => scheme.onPrimary, (true, true, _) => scheme.onPrimary,
(true, false, _) => scheme.primary, (true, false, _) => scheme.primary,
(false, _, true) => scheme.onSurface, (false, _, true) => scheme.onSurface,
@@ -698,13 +789,22 @@ class _IndexLetter extends StatelessWidget {
}; };
return AnimatedContainer( 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, width: fontSize * 1.8,
height: fontSize * 1.8, height: fontSize * 1.8,
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.circle, 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( child: Text(
letter, letter,
+129
View File
@@ -0,0 +1,129 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../l10n/app_localizations.dart';
import '../viewmodels/product_list_view_model.dart';
/// Movie-style end credits, opened by tapping the version number in settings.
class CreditsView extends StatefulWidget {
final String appVersion;
const CreditsView({super.key, required this.appVersion});
@override
State<CreditsView> createState() => _CreditsViewState();
}
class _CreditsViewState extends State<CreditsView>
with SingleTickerProviderStateMixin {
late final AnimationController _controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 25),
)..forward();
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context);
final products = context.select<ProductListViewModel, List<String>>(
(viewModel) => [
for (final product in viewModel.products)
if (product.active) product.name,
],
);
const titleStyle = TextStyle(
color: Colors.white,
fontSize: 34,
fontWeight: FontWeight.w900,
letterSpacing: 4,
);
const headingStyle = TextStyle(
color: Colors.white54,
fontSize: 14,
fontWeight: FontWeight.w600,
letterSpacing: 3,
);
const nameStyle = TextStyle(
color: Colors.white,
fontSize: 22,
fontWeight: FontWeight.w700,
);
final credits = Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text('KOOLTAP', style: titleStyle),
const SizedBox(height: 8),
Text(l10n.version(widget.appVersion), style: headingStyle),
const SizedBox(height: 64),
Text(l10n.creditsDirectedBy.toUpperCase(), style: headingStyle),
const SizedBox(height: 8),
const Text('Bram Verhulst 👑', style: nameStyle),
const SizedBox(height: 48),
Text(l10n.creditsStarring.toUpperCase(), style: headingStyle),
const SizedBox(height: 8),
for (final name in products)
Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: Text(name, style: nameStyle, textAlign: TextAlign.center),
),
const SizedBox(height: 48),
Text(l10n.creditsSpecialThanks.toUpperCase(), style: headingStyle),
const SizedBox(height: 8),
Text(l10n.creditsEveryoneAtTheBar, style: nameStyle),
const SizedBox(height: 96),
Text(
l10n.creditsDrinkResponsibly,
style: headingStyle,
textAlign: TextAlign.center,
),
],
);
return Scaffold(
backgroundColor: Colors.black,
body: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => Navigator.of(context).pop(),
child: SafeArea(
child: LayoutBuilder(
builder: (context, constraints) {
return ClipRect(
child: AnimatedBuilder(
animation: _controller,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 24),
child: credits,
),
builder: (context, child) {
// Rolls from just below the screen to fully above it.
return OverflowBox(
alignment: Alignment.topCenter,
maxHeight: double.infinity,
child: FractionalTranslation(
translation: Offset(0, -_controller.value),
child: Transform.translate(
offset: Offset(
0,
constraints.maxHeight * (1 - _controller.value),
),
child: child,
),
),
);
},
),
);
},
),
),
),
);
}
}
+26
View File
@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
import '../l10n/app_localizations.dart'; import '../l10n/app_localizations.dart';
import '../l10n/app_localizations_helpers.dart'; import '../l10n/app_localizations_helpers.dart';
import '../models/app_error.dart'; import '../models/app_error.dart';
import '../utils/easter_eggs.dart';
import '../viewmodels/pin_lock_view_model.dart'; import '../viewmodels/pin_lock_view_model.dart';
enum PinEntryMode { unlock, create, change } enum PinEntryMode { unlock, create, change }
@@ -53,6 +54,9 @@ class _PinEntryViewState extends State<PinEntryView> {
bool _isConfirmStep = false; bool _isConfirmStep = false;
bool _isSubmitting = false; bool _isSubmitting = false;
String? _localError; String? _localError;
/// A cheeky remark for a lazy PIN, shown instead of an error.
bool _showLazyPinRemark = false;
bool _shake = false; bool _shake = false;
bool get _isChangeFlow => widget.mode == PinEntryMode.change; bool get _isChangeFlow => widget.mode == PinEntryMode.change;
@@ -94,6 +98,7 @@ class _PinEntryViewState extends State<PinEntryView> {
setState(() { setState(() {
_digits += digit; _digits += digit;
_localError = null; _localError = null;
if (_digits.length == 1) _showLazyPinRemark = false;
}); });
if (_digits.length == _pinLength) { if (_digits.length == _pinLength) {
@@ -119,6 +124,7 @@ class _PinEntryViewState extends State<PinEntryView> {
_firstEntry = entered; _firstEntry = entered;
_isConfirmStep = true; _isConfirmStep = true;
_digits = ''; _digits = '';
_showLazyPinRemark = isLazyPin(entered);
}); });
return; return;
} }
@@ -164,6 +170,16 @@ class _PinEntryViewState extends State<PinEntryView> {
_currentPin = _digits; _currentPin = _digits;
_digits = ''; _digits = '';
}); });
} else if (isLazyPin(_digits)) {
// Correct, but let them see the raised eyebrow before moving on.
setState(() {
_showLazyPinRemark = true;
_isSubmitting = true;
});
await Future<void>.delayed(const Duration(milliseconds: 900));
if (!mounted) return;
setState(() => _isSubmitting = false);
widget.onSuccess?.call();
} else { } else {
widget.onSuccess?.call(); widget.onSuccess?.call();
} }
@@ -203,6 +219,7 @@ class _PinEntryViewState extends State<PinEntryView> {
void _fail(String message) { void _fail(String message) {
setState(() { setState(() {
_localError = message; _localError = message;
_showLazyPinRemark = false;
_digits = ''; _digits = '';
_shake = true; _shake = true;
}); });
@@ -262,6 +279,15 @@ class _PinEntryViewState extends State<PinEntryView> {
_localError!, _localError!,
style: TextStyle(color: scheme.error, fontSize: 13), style: TextStyle(color: scheme.error, fontSize: 13),
) )
: _showLazyPinRemark
? Text(
l10n.lazyPinRemark,
style: TextStyle(
color: scheme.onSurface.withValues(alpha: 0.7),
fontSize: 13,
fontWeight: FontWeight.w600,
),
)
: const SizedBox.shrink(), : const SizedBox.shrink(),
), ),
const Spacer(flex: 2), const Spacer(flex: 2),
+24
View File
@@ -15,6 +15,7 @@ import '../utils/navigation.dart';
import '../viewmodels/admin_pin_view_model.dart'; import '../viewmodels/admin_pin_view_model.dart';
import '../viewmodels/pin_lock_view_model.dart'; import '../viewmodels/pin_lock_view_model.dart';
import '../viewmodels/settings_view_model.dart'; import '../viewmodels/settings_view_model.dart';
import 'credits_view.dart';
import 'pin_lock_view.dart'; import 'pin_lock_view.dart';
class SettingsScreenView extends StatefulWidget { class SettingsScreenView extends StatefulWidget {
@@ -27,6 +28,9 @@ class SettingsScreenView extends StatefulWidget {
class _SettingsScreenViewState extends State<SettingsScreenView> { class _SettingsScreenViewState extends State<SettingsScreenView> {
String _appVersion = ''; String _appVersion = '';
Timer? _versionHoldTimer; Timer? _versionHoldTimer;
static const _versionTapWindow = Duration(milliseconds: 600);
int _versionTapCount = 0;
DateTime? _lastVersionTap;
@override @override
void initState() { void initState() {
@@ -65,6 +69,25 @@ class _SettingsScreenViewState extends State<SettingsScreenView> {
_versionHoldTimer = null; _versionHoldTimer = null;
} }
/// Five quick taps on the version number roll the credits.
void _onVersionTap() {
final now = DateTime.now();
final last = _lastVersionTap;
_versionTapCount = last != null && now.difference(last) < _versionTapWindow
? _versionTapCount + 1
: 1;
_lastVersionTap = now;
if (_versionTapCount < 5) return;
_versionTapCount = 0;
Navigator.of(context).push(
MaterialPageRoute<void>(
fullscreenDialog: true,
builder: (_) => CreditsView(appVersion: _appVersion),
),
);
}
@override @override
void dispose() { void dispose() {
_cancelVersionHold(); _cancelVersionHold();
@@ -377,6 +400,7 @@ class _SettingsScreenViewState extends State<SettingsScreenView> {
onTapDown: (_) => _startVersionHold(), onTapDown: (_) => _startVersionHold(),
onTapUp: (_) => _cancelVersionHold(), onTapUp: (_) => _cancelVersionHold(),
onTapCancel: _cancelVersionHold, onTapCancel: _cancelVersionHold,
onTap: _onVersionTap,
child: Center( child: Center(
child: Text( child: Text(
l10n.version(_appVersion), l10n.version(_appVersion),
+2 -1
View File
@@ -5,6 +5,7 @@ import '../../l10n/app_localizations.dart';
import '../../models/closed_tab.dart'; import '../../models/closed_tab.dart';
import '../../models/closed_tab_item.dart'; import '../../models/closed_tab_item.dart';
import '../../models/payment_method.dart'; import '../../models/payment_method.dart';
import '../../utils/easter_eggs.dart';
import '../../utils/history_grouping.dart'; import '../../utils/history_grouping.dart';
import '../../utils/money.dart'; import '../../utils/money.dart';
@@ -71,7 +72,7 @@ class _ClosedTabCardState extends State<ClosedTabCard> {
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
closedTab.customerName, customerDisplayName(closedTab.customerName),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
+2 -1
View File
@@ -4,6 +4,7 @@ import 'package:intl/intl.dart';
import '../../l10n/app_localizations.dart'; import '../../l10n/app_localizations.dart';
import '../../models/bar_tab.dart'; import '../../models/bar_tab.dart';
import '../../models/tab_item_purchase.dart'; import '../../models/tab_item_purchase.dart';
import '../../utils/easter_eggs.dart';
import '../../utils/money.dart'; import '../../utils/money.dart';
class OpenTabHistoryCard extends StatefulWidget { class OpenTabHistoryCard extends StatefulWidget {
@@ -93,7 +94,7 @@ class _OpenTabHistoryCardState extends State<OpenTabHistoryCard> {
children: [ children: [
Expanded( Expanded(
child: Text( child: Text(
tab.customerName, customerDisplayName(tab.customerName),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
style: TextStyle( style: TextStyle(
+96
View File
@@ -0,0 +1,96 @@
import 'package:flutter/material.dart';
/// The bar screen title. Ten quick taps light it up as a flickering neon
/// café sign for a few seconds.
class VenueTitle extends StatefulWidget {
final String text;
const VenueTitle({super.key, required this.text});
@override
State<VenueTitle> createState() => _VenueTitleState();
}
class _VenueTitleState extends State<VenueTitle>
with SingleTickerProviderStateMixin {
static const _tapsNeeded = 10;
static const _tapWindow = Duration(milliseconds: 600);
static const _neonPink = Color(0xFFFF2BD6);
/// Stretches of the animation (as fractions) where the tube is dark,
/// like a sign that sputters on and then dies out.
static const _darkSpans = [
(0.02, 0.05),
(0.07, 0.08),
(0.10, 0.14),
(0.55, 0.56),
(0.88, 0.89),
(0.91, 0.93),
];
late final AnimationController _neon = AnimationController(
vsync: this,
duration: const Duration(seconds: 5),
);
int _tapCount = 0;
DateTime? _lastTap;
@override
void dispose() {
_neon.dispose();
super.dispose();
}
void _onTap() {
final now = DateTime.now();
final last = _lastTap;
_tapCount = last != null && now.difference(last) < _tapWindow
? _tapCount + 1
: 1;
_lastTap = now;
if (_tapCount < _tapsNeeded) return;
_tapCount = 0;
_neon.forward(from: 0);
}
@override
Widget build(BuildContext context) {
final baseStyle = DefaultTextStyle.of(context).style;
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: _onTap,
child: AnimatedBuilder(
animation: _neon,
builder: (context, _) {
final t = _neon.value;
final isLit =
_neon.isAnimating &&
!_darkSpans.any((span) => t >= span.$1 && t < span.$2);
return Text(
widget.text,
style: isLit
? baseStyle.copyWith(
color: const Color(0xFFFFD6F6),
fontWeight: FontWeight.w800,
shadows: const [
Shadow(color: _neonPink, blurRadius: 4),
Shadow(color: _neonPink, blurRadius: 12),
Shadow(color: _neonPink, blurRadius: 24),
],
)
: _neon.isAnimating
? baseStyle.copyWith(
color: baseStyle.color?.withValues(alpha: 0.35),
fontWeight: FontWeight.w800,
)
: baseStyle,
);
},
),
);
}
}
+1 -1
View File
@@ -2,7 +2,7 @@ name: kooltap
description: "KoolTap: a tablet point-of-sale app for running bar tabs." description: "KoolTap: a tablet point-of-sale app for running bar tabs."
publish_to: 'none' publish_to: 'none'
version: 1.3.10+0 version: 1.3.15+0
environment: environment:
sdk: ^3.12.2 sdk: ^3.12.2