Implemented Loading Indicator in MainMenu
This commit is contained in:
@@ -16,17 +16,23 @@ class MainMenuView extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MainMenuViewState extends State<MainMenuView> {
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
LocalStorageService.loadGameSessions().then((_) {
|
||||
setState(() {});
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('MainMenuView build');
|
||||
LocalStorageService.loadGameSessions();
|
||||
|
||||
return CupertinoPageScaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
@@ -57,74 +63,76 @@ class _MainMenuViewState extends State<MainMenuView> {
|
||||
),
|
||||
child: CupertinoPageScaffold(
|
||||
child: SafeArea(
|
||||
child: Globals.gameList.isEmpty
|
||||
? Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center, // Oben ausrichten
|
||||
children: [
|
||||
const SizedBox(height: 30), // Abstand von oben
|
||||
Center(
|
||||
child: GestureDetector(
|
||||
onTap: () => setState(() {}),
|
||||
child: Icon(
|
||||
CupertinoIcons.plus,
|
||||
size: 60,
|
||||
color: CustomTheme.primaryColor,
|
||||
),
|
||||
)),
|
||||
const SizedBox(height: 10), // Abstand von oben
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 70),
|
||||
child: Text(
|
||||
'Ganz schön leer hier...\nFüge über den Button oben rechts eine neue Runde hinzu.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: Globals.gameList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final session = Globals.gameList[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: CupertinoListTile(
|
||||
title: Text(session.gameTitle),
|
||||
subtitle: session.isGameFinished == true
|
||||
? Text(
|
||||
'\u{1F947} ${session.winner}',
|
||||
style: const TextStyle(fontSize: 14),
|
||||
)
|
||||
: Text(
|
||||
'Modus: ${_translateGameMode(session.isPointsLimitEnabled)}',
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
trailing: Row(
|
||||
children: [
|
||||
Text('${session.roundNumber}'),
|
||||
const SizedBox(width: 3),
|
||||
const Icon(CupertinoIcons
|
||||
.arrow_2_circlepath_circle_fill),
|
||||
const SizedBox(width: 15),
|
||||
Text('${session.players.length}'),
|
||||
const SizedBox(width: 3),
|
||||
const Icon(CupertinoIcons.person_2_fill),
|
||||
],
|
||||
child: _isLoading
|
||||
? const Center(child: CupertinoActivityIndicator())
|
||||
: Globals.gameList.isEmpty
|
||||
? Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center, // Oben ausrichten
|
||||
children: [
|
||||
const SizedBox(height: 30), // Abstand von oben
|
||||
Center(
|
||||
child: GestureDetector(
|
||||
onTap: () => setState(() {}),
|
||||
child: Icon(
|
||||
CupertinoIcons.plus,
|
||||
size: 60,
|
||||
color: CustomTheme.primaryColor,
|
||||
),
|
||||
onTap: () async {
|
||||
//ignore: unused_local_variable
|
||||
final val = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => ActiveGameView(
|
||||
gameSession: Globals.gameList[index]),
|
||||
)),
|
||||
const SizedBox(height: 10), // Abstand von oben
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 70),
|
||||
child: Text(
|
||||
'Ganz schön leer hier...\nFüge über den Button oben rechts eine neue Runde hinzu.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: Globals.gameList.length,
|
||||
itemBuilder: (context, index) {
|
||||
final session = Globals.gameList[index];
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10.0),
|
||||
child: CupertinoListTile(
|
||||
title: Text(session.gameTitle),
|
||||
subtitle: session.isGameFinished == true
|
||||
? Text(
|
||||
'\u{1F947} ${session.winner}',
|
||||
style: const TextStyle(fontSize: 14),
|
||||
)
|
||||
: Text(
|
||||
'Modus: ${_translateGameMode(session.isPointsLimitEnabled)}',
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
trailing: Row(
|
||||
children: [
|
||||
Text('${session.roundNumber}'),
|
||||
const SizedBox(width: 3),
|
||||
const Icon(CupertinoIcons
|
||||
.arrow_2_circlepath_circle_fill),
|
||||
const SizedBox(width: 15),
|
||||
Text('${session.players.length}'),
|
||||
const SizedBox(width: 3),
|
||||
const Icon(CupertinoIcons.person_2_fill),
|
||||
],
|
||||
),
|
||||
);
|
||||
setState(() {});
|
||||
},
|
||||
));
|
||||
}),
|
||||
onTap: () async {
|
||||
//ignore: unused_local_variable
|
||||
final val = await Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (context) => ActiveGameView(
|
||||
gameSession: Globals.gameList[index]),
|
||||
),
|
||||
);
|
||||
setState(() {});
|
||||
},
|
||||
));
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ name: cabo_counter
|
||||
description: "Mobile app for the card game Cabo"
|
||||
publish_to: 'none'
|
||||
|
||||
version: 0.1.5+113
|
||||
version: 0.1.6+122
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.4
|
||||
|
||||
Reference in New Issue
Block a user