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:flutter/cupertino.dart';
@@ -14,10 +14,10 @@ class App extends StatelessWidget {
return CupertinoApp(
theme: CupertinoThemeData(
brightness: Brightness.dark,
primaryColor: theme.primaryColor,
scaffoldBackgroundColor: theme.backgroundColor,
primaryColor: Theme.primaryColor,
scaffoldBackgroundColor: Theme.backgroundColor,
textTheme: CupertinoTextThemeData(
primaryColor: theme.primaryColor,
primaryColor: Theme.primaryColor,
),
),
debugShowCheckedModeBanner: false,

View File

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

View File

@@ -1,5 +1,5 @@
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:flutter/cupertino.dart';
@@ -28,7 +28,7 @@ class _ActiveGameViewState extends State<ActiveGameView> {
padding: const EdgeInsets.fromLTRB(10, 10, 0, 0),
child: Text(
'Spieler:innen',
style: theme.createGameTitle,
style: Theme.createGameTitle,
),
),
ListView.builder(
@@ -61,7 +61,7 @@ class _ActiveGameViewState extends State<ActiveGameView> {
padding: const EdgeInsets.fromLTRB(10, 10, 0, 0),
child: Text(
'Runden',
style: theme.createGameTitle,
style: Theme.createGameTitle,
),
),
ListView.builder(

View File

@@ -1,5 +1,5 @@
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/mode_selection_view.dart';
import 'package:flutter/cupertino.dart';
@@ -42,7 +42,7 @@ class _CreateGameState extends State<CreateGame> {
padding: const EdgeInsets.fromLTRB(10, 10, 0, 0),
child: Text(
'Spiel',
style: theme.createGameTitle,
style: Theme.createGameTitle,
),
),
Padding(
@@ -96,7 +96,7 @@ class _CreateGameState extends State<CreateGame> {
padding: const EdgeInsets.fromLTRB(10, 10, 0, 0),
child: Text(
'Spieler:innen',
style: theme.createGameTitle,
style: Theme.createGameTitle,
),
),
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';
class ModeSelectionMenu extends StatelessWidget {
@@ -15,10 +15,10 @@ class ModeSelectionMenu extends StatelessWidget {
Padding(
padding: const EdgeInsets.fromLTRB(0, 16, 0, 0),
child: CupertinoListTile(
title: Text('101 Punkte', style: theme.modeTitle),
title: Text('101 Punkte', style: Theme.modeTitle),
subtitle: const Text(
'Es wird solange gespielt, bis einer Spieler mehr als 100 Punkte erreicht',
style: theme.modeDescription,
style: Theme.modeDescription,
maxLines: 3,
),
onTap: () {
@@ -29,11 +29,11 @@ class ModeSelectionMenu extends StatelessWidget {
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: CupertinoListTile(
title: Text('Unbegrenzt', style: theme.modeTitle),
title: Text('Unbegrenzt', style: Theme.modeTitle),
subtitle: const Text(
'Dem Spiel sind keine Grenzen gesetzt. Es wird so lange '
'gespielt, bis Ihr keine Lust mehr habt.',
style: theme.modeDescription,
style: Theme.modeDescription,
maxLines: 3,
),
onTap: () {

View File

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