Feature: Login-Effekte pro Person (Akzentfarbe + Sound + Begruessung)
- UserEffekt: Baka = rot + Fanfare, Tinker = tuerkis + Chime, Standard-Ping - MeloTheme: dynamische Akzentfarbe via ValueNotifier (Theme wechselt live) - Ausloeser: App-Start (wenn Token vorhanden) + nach erfolgreichem Login - Assets: 3 kurze WAV-Sounds (assets/sounds/) - Web: /whoami-Endpoint (Caddy) + Willkommens-Banner auf baka-net.de
This commit is contained in:
@@ -9,12 +9,18 @@ class MeloTheme {
|
||||
static const Color textPrimaer = Color(0xFFFFFFFF);
|
||||
static const Color textSekundaer = Color(0xFF888888);
|
||||
|
||||
/// Akzentfarbe – wechselt pro angemeldeter Person (Login-Effekt).
|
||||
/// UI hängt per ValueListenableBuilder an [akzentNotifier].
|
||||
static final ValueNotifier<Color> akzentNotifier = ValueNotifier<Color>(rot);
|
||||
static Color get akzent => akzentNotifier.value;
|
||||
static set akzent(Color farbe) => akzentNotifier.value = farbe;
|
||||
|
||||
static ThemeData get theme => ThemeData(
|
||||
brightness: Brightness.dark,
|
||||
scaffoldBackgroundColor: schwarz,
|
||||
colorScheme: const ColorScheme.dark(
|
||||
primary: rot,
|
||||
secondary: rot,
|
||||
colorScheme: ColorScheme.dark(
|
||||
primary: akzent,
|
||||
secondary: akzent,
|
||||
surface: schwarz,
|
||||
),
|
||||
appBarTheme: const AppBarTheme(
|
||||
@@ -22,9 +28,9 @@ class MeloTheme {
|
||||
foregroundColor: textPrimaer,
|
||||
elevation: 0,
|
||||
),
|
||||
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
|
||||
bottomNavigationBarTheme: BottomNavigationBarThemeData(
|
||||
backgroundColor: schwarz,
|
||||
selectedItemColor: rot,
|
||||
selectedItemColor: akzent,
|
||||
unselectedItemColor: textSekundaer,
|
||||
),
|
||||
cardTheme: CardThemeData(
|
||||
@@ -35,7 +41,7 @@ class MeloTheme {
|
||||
),
|
||||
chipTheme: ChipThemeData(
|
||||
backgroundColor: dunkel1,
|
||||
selectedColor: rot,
|
||||
selectedColor: akzent,
|
||||
labelStyle: const TextStyle(color: textPrimaer),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'farb_theme.dart';
|
||||
|
||||
/// Login-Effekte: Pro Person eigener Akzent, Willkommens-Sound und Begrüßung.
|
||||
/// Wird nach erfolgreichem Login und beim App-Start (wenn Token vorhanden) ausgelöst.
|
||||
class UserEffekt {
|
||||
final Color akzent;
|
||||
final String begruessung;
|
||||
final String soundAsset;
|
||||
|
||||
const UserEffekt(this.akzent, this.begruessung, this.soundAsset);
|
||||
|
||||
/// Baka = königlich-rot + Fanfare 👑
|
||||
static const baka = UserEffekt(
|
||||
Color(0xFFCC0000),
|
||||
'Willkommen zurück, Baka! 👑',
|
||||
'assets/sounds/baka_fanfare.wav',
|
||||
);
|
||||
|
||||
/// Tinker = türkis + heller Chime 🐱
|
||||
static const tinker = UserEffekt(
|
||||
Color(0xFF00B8A9),
|
||||
'Tinker ist da! 🐱✨',
|
||||
'assets/sounds/tinker_chime.wav',
|
||||
);
|
||||
|
||||
static const standard = UserEffekt(
|
||||
Color(0xFFCC0000),
|
||||
'Willkommen! 🎵',
|
||||
'assets/sounds/willkommen_ping.wav',
|
||||
);
|
||||
|
||||
static UserEffekt fuer(String? user) {
|
||||
final u = (user ?? '').toLowerCase().trim();
|
||||
if (u == 'baka' || u == 'dustin') return baka;
|
||||
if (u == 'tinker') return tinker;
|
||||
return standard;
|
||||
}
|
||||
|
||||
/// Setzt die Akzentfarbe (Thema wechselt live) und spielt den Sound ab.
|
||||
static Future<void> anwenden(String? user) async {
|
||||
final e = fuer(user);
|
||||
MeloTheme.akzent = e.akzent;
|
||||
try {
|
||||
final p = AudioPlayer();
|
||||
await p.setAsset(e.soundAsset);
|
||||
unawaited(p.play());
|
||||
// Player nach dem Abspielen sauber freigeben (kein Memory-Leak)
|
||||
Future.delayed(const Duration(seconds: 4), () {
|
||||
if (p.playing) p.stop();
|
||||
p.dispose();
|
||||
});
|
||||
} catch (_) {
|
||||
// Sound-Fehler ignorieren – Akzent bleibt trotzdem aktiv
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user