Implemented Theme class in every dart file

This commit is contained in:
Felix Kirchner
2025-04-30 13:57:54 +02:00
parent d49fec2b48
commit 1adbd16687
6 changed files with 49 additions and 47 deletions

View File

@@ -1,4 +1,4 @@
import 'package:cabo_counter/utility/theme.dart' as theme; import 'package:cabo_counter/utility/theme.dart';
import 'package:cabo_counter/views/main_menu_view.dart'; import 'package:cabo_counter/views/main_menu_view.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@@ -14,10 +14,10 @@ class App extends StatelessWidget {
return CupertinoApp( return CupertinoApp(
theme: CupertinoThemeData( theme: CupertinoThemeData(
brightness: Brightness.dark, brightness: Brightness.dark,
primaryColor: theme.primaryColor, primaryColor: Theme.primaryColor,
scaffoldBackgroundColor: theme.backgroundColor, scaffoldBackgroundColor: Theme.backgroundColor,
textTheme: CupertinoTextThemeData( textTheme: CupertinoTextThemeData(
primaryColor: theme.primaryColor, primaryColor: Theme.primaryColor,
), ),
), ),
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,

View File

@@ -1,34 +1,36 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
Color white = CupertinoColors.white; class Theme {
Color primaryColor = CupertinoColors.systemGreen; static Color white = CupertinoColors.white;
Color backgroundColor = const Color(0xFF101010); static Color primaryColor = CupertinoColors.systemGreen;
Color backgroundTintColor = CupertinoColors.darkBackgroundGray; static Color backgroundColor = const Color(0xFF101010);
static Color backgroundTintColor = CupertinoColors.darkBackgroundGray;
TextStyle modeTitle = TextStyle( static TextStyle modeTitle = TextStyle(
color: primaryColor, color: primaryColor,
fontSize: 20, fontSize: 20,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
); );
const TextStyle modeDescription = TextStyle( static const TextStyle modeDescription = TextStyle(
fontSize: 16, fontSize: 16,
); );
TextStyle createGameTitle = TextStyle( static TextStyle createGameTitle = TextStyle(
fontSize: 20, fontSize: 20,
color: primaryColor, color: primaryColor,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
); );
TextStyle roundTitle = const TextStyle( static TextStyle roundTitle = TextStyle(
fontSize: 60, fontSize: 60,
color: CupertinoColors.white, color: white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
); );
TextStyle roundPlayers = const TextStyle( static TextStyle roundPlayers = TextStyle(
fontSize: 20, fontSize: 20,
color: CupertinoColors.white, color: white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
); );
}

View File

@@ -1,5 +1,5 @@
import 'package:cabo_counter/data/game_session.dart'; import 'package:cabo_counter/data/game_session.dart';
import 'package:cabo_counter/utility/theme.dart' as theme; import 'package:cabo_counter/utility/theme.dart';
import 'package:cabo_counter/views/round_view.dart'; import 'package:cabo_counter/views/round_view.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@@ -28,7 +28,7 @@ class _ActiveGameViewState extends State<ActiveGameView> {
padding: const EdgeInsets.fromLTRB(10, 10, 0, 0), padding: const EdgeInsets.fromLTRB(10, 10, 0, 0),
child: Text( child: Text(
'Spieler:innen', 'Spieler:innen',
style: theme.createGameTitle, style: Theme.createGameTitle,
), ),
), ),
ListView.builder( ListView.builder(
@@ -61,7 +61,7 @@ class _ActiveGameViewState extends State<ActiveGameView> {
padding: const EdgeInsets.fromLTRB(10, 10, 0, 0), padding: const EdgeInsets.fromLTRB(10, 10, 0, 0),
child: Text( child: Text(
'Runden', 'Runden',
style: theme.createGameTitle, style: Theme.createGameTitle,
), ),
), ),
ListView.builder( ListView.builder(

View File

@@ -1,5 +1,5 @@
import 'package:cabo_counter/data/game_session.dart'; import 'package:cabo_counter/data/game_session.dart';
import 'package:cabo_counter/utility/theme.dart' as theme; import 'package:cabo_counter/utility/theme.dart';
import 'package:cabo_counter/views/active_game_view.dart'; import 'package:cabo_counter/views/active_game_view.dart';
import 'package:cabo_counter/views/mode_selection_view.dart'; import 'package:cabo_counter/views/mode_selection_view.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@@ -42,7 +42,7 @@ class _CreateGameState extends State<CreateGame> {
padding: const EdgeInsets.fromLTRB(10, 10, 0, 0), padding: const EdgeInsets.fromLTRB(10, 10, 0, 0),
child: Text( child: Text(
'Spiel', 'Spiel',
style: theme.createGameTitle, style: Theme.createGameTitle,
), ),
), ),
Padding( Padding(
@@ -96,7 +96,7 @@ class _CreateGameState extends State<CreateGame> {
padding: const EdgeInsets.fromLTRB(10, 10, 0, 0), padding: const EdgeInsets.fromLTRB(10, 10, 0, 0),
child: Text( child: Text(
'Spieler:innen', 'Spieler:innen',
style: theme.createGameTitle, style: Theme.createGameTitle,
), ),
), ),
Expanded( Expanded(

View File

@@ -1,4 +1,4 @@
import 'package:cabo_counter/utility/theme.dart' as theme; import 'package:cabo_counter/utility/theme.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
class ModeSelectionMenu extends StatelessWidget { class ModeSelectionMenu extends StatelessWidget {
@@ -15,10 +15,10 @@ class ModeSelectionMenu extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.fromLTRB(0, 16, 0, 0), padding: const EdgeInsets.fromLTRB(0, 16, 0, 0),
child: CupertinoListTile( child: CupertinoListTile(
title: Text('101 Punkte', style: theme.modeTitle), title: Text('101 Punkte', style: Theme.modeTitle),
subtitle: const Text( subtitle: const Text(
'Es wird solange gespielt, bis einer Spieler mehr als 100 Punkte erreicht', 'Es wird solange gespielt, bis einer Spieler mehr als 100 Punkte erreicht',
style: theme.modeDescription, style: Theme.modeDescription,
maxLines: 3, maxLines: 3,
), ),
onTap: () { onTap: () {
@@ -29,11 +29,11 @@ class ModeSelectionMenu extends StatelessWidget {
Padding( Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0), padding: const EdgeInsets.symmetric(vertical: 16.0),
child: CupertinoListTile( child: CupertinoListTile(
title: Text('Unbegrenzt', style: theme.modeTitle), title: Text('Unbegrenzt', style: Theme.modeTitle),
subtitle: const Text( subtitle: const Text(
'Dem Spiel sind keine Grenzen gesetzt. Es wird so lange ' 'Dem Spiel sind keine Grenzen gesetzt. Es wird so lange '
'gespielt, bis Ihr keine Lust mehr habt.', 'gespielt, bis Ihr keine Lust mehr habt.',
style: theme.modeDescription, style: Theme.modeDescription,
maxLines: 3, maxLines: 3,
), ),
onTap: () { onTap: () {

View File

@@ -1,5 +1,5 @@
import 'package:cabo_counter/data/game_session.dart'; import 'package:cabo_counter/data/game_session.dart';
import 'package:cabo_counter/utility/theme.dart' as theme; import 'package:cabo_counter/utility/theme.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart'; import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
@@ -86,7 +86,7 @@ class _RoundViewState extends State<RoundView> {
children: [ children: [
const SizedBox(height: 40), const SizedBox(height: 40),
Text('Runde ${widget.roundNumber}', Text('Runde ${widget.roundNumber}',
style: theme.roundTitle), style: Theme.roundTitle),
const SizedBox(height: 10), const SizedBox(height: 10),
const Text( const Text(
'Wer hat CABO gesagt?', 'Wer hat CABO gesagt?',
@@ -101,8 +101,8 @@ class _RoundViewState extends State<RoundView> {
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: CupertinoSegmentedControl<int>( child: CupertinoSegmentedControl<int>(
unselectedColor: theme.backgroundTintColor, unselectedColor: Theme.backgroundTintColor,
selectedColor: theme.primaryColor, selectedColor: Theme.primaryColor,
groupValue: _caboPlayerIndex, groupValue: _caboPlayerIndex,
children: Map.fromEntries(widget.gameSession.players children: Map.fromEntries(widget.gameSession.players
.asMap() .asMap()
@@ -267,7 +267,7 @@ class _RoundViewState extends State<RoundView> {
return Container( return Container(
height: 80, height: 80,
padding: const EdgeInsets.only(bottom: 20), padding: const EdgeInsets.only(bottom: 20),
color: theme.backgroundTintColor, color: Theme.backgroundTintColor,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [