added 2 themes

This commit is contained in:
2026-03-12 11:45:59 +01:00
parent 0658b0cd5b
commit bd56d97b6d
6 changed files with 225 additions and 76 deletions

View File

@@ -17,7 +17,8 @@ class HomePage extends StatefulWidget {
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin {
class _HomePageState extends State<HomePage>
with SingleTickerProviderStateMixin {
int _selectedIndex = 0;
late TabController _tabController;
@@ -35,12 +36,23 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
@override
Widget build(BuildContext context) {
final appBarForeground =
Theme.of(context).appBarTheme.foregroundColor ??
Theme.of(context).colorScheme.onSurface;
return Scaffold(
appBar: AppBar(
title: Text(_selectedIndex == 0 ? "Tournaments" : "Teams"),
bottom: _selectedIndex == 1
? TabBar(
controller: _tabController,
labelColor: appBarForeground,
unselectedLabelColor: appBarForeground.withValues(alpha: 0.82),
indicatorColor: appBarForeground,
labelStyle: const TextStyle(fontWeight: FontWeight.w700),
unselectedLabelStyle: const TextStyle(
fontWeight: FontWeight.w500,
),
tabs: const [
Tab(text: 'All Teams'),
Tab(text: 'My Teams'),
@@ -101,10 +113,7 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
// Teams View with tabs
TabBarView(
controller: _tabController,
children: const [
TeamsListWidget(),
MyTeamsWidget(),
],
children: const [TeamsListWidget(), MyTeamsWidget()],
),
],
),
@@ -120,10 +129,7 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
icon: Icon(Icons.emoji_events),
label: 'Tournaments',
),
BottomNavigationBarItem(
icon: Icon(Icons.groups),
label: 'Teams',
),
BottomNavigationBarItem(icon: Icon(Icons.groups), label: 'Teams'),
],
),
floatingActionButton: FloatingActionButton(
@@ -138,9 +144,7 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const CreateTeamPage(),
),
MaterialPageRoute(builder: (context) => const CreateTeamPage()),
);
}
},

View File

@@ -18,15 +18,19 @@ class _TournamentDetailPageState extends State<TournamentDetailPage> {
void _showJoinTeamDialog(BuildContext context, int tournamentId) async {
final teamProvider = Provider.of<TeamProvider>(context, listen: false);
try {
final teams = await teamProvider.getUserTeams();
if (!context.mounted) return;
if (teams.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('You are not a member of any team. Join or create a team first!')),
const SnackBar(
content: Text(
'You are not a member of any team. Join or create a team first!',
),
),
);
return;
}
@@ -46,8 +50,8 @@ class _TournamentDetailPageState extends State<TournamentDetailPage> {
return ListTile(
leading: CircleAvatar(child: Text(team.tag)),
title: Text(team.name),
subtitle: team.description.isNotEmpty
? Text(team.description)
subtitle: team.description.isNotEmpty
? Text(team.description)
: null,
onTap: () => Navigator.pop(dialogContext, team),
);
@@ -70,15 +74,15 @@ class _TournamentDetailPageState extends State<TournamentDetailPage> {
tournamentId,
selectedTeam.id,
);
if (!context.mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('${selectedTeam.name} joined the tournament!'),
),
);
// Refresh teams list if currently showing
if (isShowingTeams) {
setState(() {});
@@ -87,25 +91,34 @@ class _TournamentDetailPageState extends State<TournamentDetailPage> {
if (!context.mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Failed to join: ${e.toString().replaceAll('Exception: ', '')}'),
content: Text(
'Failed to join: ${e.toString().replaceAll('Exception: ', '')}',
),
),
);
}
}
} catch (e) {
if (!context.mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Failed to load your teams: $e')),
);
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('Failed to load your teams: $e')));
}
}
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
final appBarBackground = colorScheme.surface.withValues(alpha: 0.78);
return Scaffold(
appBar: AppBar(
title: Text(widget.tournament.name, style: TextStyle(overflow: TextOverflow.ellipsis)),
backgroundColor: Theme.of(context).colorScheme.surface.withAlpha(180),
backgroundColor: appBarBackground,
foregroundColor: colorScheme.onSurface,
title: Text(
widget.tournament.name,
style: TextStyle(overflow: TextOverflow.ellipsis),
),
elevation: 3,
actions: [
IconButton(