feat: add easter egg with triple-tap AppBar and animation

This commit is contained in:
fiatcode 2026-04-30 18:15:46 +07:00
parent c5ebeed0ef
commit 9ef92a805a
No known key found for this signature in database
2 changed files with 144 additions and 8 deletions

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart';
import 'bridge/location_bridge.dart';
import 'preferences.dart';
@ -19,6 +20,38 @@ class _SettingsScreenState extends State<SettingsScreen> {
late int _accuracy;
late bool _offlineBuffer;
late bool _stopDetection;
bool _showEasterEgg = false;
int _tapCount = 0;
DateTime? _lastTapTime;
void _handleAppBarTap() {
const tripleTapInterval = Duration(milliseconds: 500);
final now = DateTime.now();
if (_lastTapTime != null &&
now.difference(_lastTapTime!) > tripleTapInterval) {
_tapCount = 0;
}
_tapCount++;
_lastTapTime = now;
if (_tapCount == 3) {
_tapCount = 0;
setState(() => _showEasterEgg = true);
}
}
Future<void> _triggerEasterEgg() async {
await Future.delayed(const Duration(milliseconds: 1500));
final uri = Uri.parse('https://fiatcode.dev');
if (await canLaunchUrl(uri)) {
await launchUrl(uri, mode: LaunchMode.externalApplication);
}
if (mounted) {
setState(() => _showEasterEgg = false);
}
}
@override
void initState() {
@ -116,14 +149,17 @@ class _SettingsScreenState extends State<SettingsScreen> {
),
onPressed: () => Navigator.pop(context),
),
title: const Text(
'SETTINGS',
style: TextStyle(
fontFamily: 'monospace',
fontSize: 14,
fontWeight: FontWeight.w700,
letterSpacing: 2,
color: Color(0xFFe0e0e0),
title: GestureDetector(
onTap: _handleAppBarTap,
child: const Text(
'SETTINGS',
style: TextStyle(
fontFamily: 'monospace',
fontSize: 14,
fontWeight: FontWeight.w700,
letterSpacing: 2,
color: Color(0xFFe0e0e0),
),
),
),
bottom: PreferredSize(
@ -168,6 +204,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
const SizedBox(height: 32),
_buildSaveButton(),
const SizedBox(height: 20),
if (_showEasterEgg) _buildEasterEggOverlay(),
],
),
);
@ -400,4 +437,39 @@ class _SettingsScreenState extends State<SettingsScreen> {
),
);
}
Widget _buildEasterEggOverlay() {
return AnimatedOpacity(
opacity: _showEasterEgg ? 1.0 : 0.0,
duration: const Duration(milliseconds: 300),
onEnd: _triggerEasterEgg,
child: AnimatedScale(
scale: _showEasterEgg ? 1.0 : 0.5,
duration: const Duration(milliseconds: 300),
curve: Curves.easeOutBack,
child: Container(
color: Colors.black.withValues(alpha: 0.85),
width: double.infinity,
height: double.infinity,
child: Center(
child: Text(
'🎉 FIAT CODE! 🎉',
style: TextStyle(
fontFamily: 'monospace',
fontSize: 32,
fontWeight: FontWeight.w700,
color: const Color(0xFF00e676),
shadows: [
Shadow(
color: const Color(0xFF00e676).withValues(alpha: 0.5),
blurRadius: 20,
),
],
),
),
),
),
),
);
}
}