Replaced tenary operator with Visibility Widget
This commit is contained in:
@@ -58,160 +58,156 @@ class _MainMenuViewState extends State<MainMenuView> {
|
|||||||
listenable: gameManager,
|
listenable: gameManager,
|
||||||
builder: (context, _) {
|
builder: (context, _) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: CupertinoNavigationBar(
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) => const SettingsView(),
|
|
||||||
),
|
|
||||||
).then((_) {
|
|
||||||
setState(() {});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
icon: const Icon(CupertinoIcons.settings, size: 30)),
|
|
||||||
middle: Text(AppLocalizations.of(context).app_name),
|
|
||||||
trailing: IconButton(
|
|
||||||
onPressed: () => Navigator.push(
|
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (context) => CreateGameView(
|
builder: (context) => const SettingsView(),
|
||||||
gameMode: ConfigService.getGameMode()),
|
|
||||||
),
|
),
|
||||||
|
).then((_) {
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: const Icon(CupertinoIcons.settings, size: 30)),
|
||||||
|
middle: Text(AppLocalizations.of(context).app_name),
|
||||||
|
trailing: IconButton(
|
||||||
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => CreateGameView(
|
||||||
|
gameMode: ConfigService.getGameMode()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
icon: const Icon(CupertinoIcons.add)),
|
||||||
|
),
|
||||||
|
child: CupertinoPageScaffold(
|
||||||
|
child: SafeArea(
|
||||||
|
child: Visibility(
|
||||||
|
replacement:
|
||||||
|
const Center(child: CupertinoActivityIndicator()),
|
||||||
|
child: Visibility(
|
||||||
|
visible: gameManager.gameList.isEmpty,
|
||||||
|
replacement: ListView.separated(
|
||||||
|
itemCount: gameManager.gameList.length,
|
||||||
|
separatorBuilder: (context, index) => Divider(
|
||||||
|
height: 1,
|
||||||
|
thickness: 0.5,
|
||||||
|
color: CustomTheme.white.withAlpha(50),
|
||||||
|
indent: 50,
|
||||||
|
endIndent: 50,
|
||||||
),
|
),
|
||||||
icon: const Icon(CupertinoIcons.add)),
|
itemBuilder: (context, index) {
|
||||||
),
|
final session = gameManager.gameList[index];
|
||||||
child: CupertinoPageScaffold(
|
return ListenableBuilder(
|
||||||
child: SafeArea(
|
listenable: session,
|
||||||
child: _isLoading
|
builder: (context, _) {
|
||||||
? const Center(child: CupertinoActivityIndicator())
|
return Dismissible(
|
||||||
: gameManager.gameList.isEmpty
|
key: Key(session.id),
|
||||||
? Column(
|
background: Container(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
color: CupertinoColors.destructiveRed,
|
||||||
children: [
|
alignment: Alignment.centerRight,
|
||||||
const SizedBox(height: 30),
|
padding: const EdgeInsets.only(right: 20.0),
|
||||||
Center(
|
child: const Icon(
|
||||||
child: GestureDetector(
|
CupertinoIcons.delete,
|
||||||
onTap: () => Navigator.push(
|
color: CupertinoColors.white,
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) => CreateGameView(
|
|
||||||
gameMode: ConfigService.getGameMode()),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Icon(
|
direction: DismissDirection.endToStart,
|
||||||
CupertinoIcons.plus,
|
confirmDismiss: (direction) async {
|
||||||
size: 60,
|
return await _showDeleteGamePopup(
|
||||||
color: CustomTheme.primaryColor,
|
context, session.gameTitle);
|
||||||
|
},
|
||||||
|
onDismissed: (direction) {
|
||||||
|
gameManager.removeGameSessionById(session.id);
|
||||||
|
},
|
||||||
|
dismissThresholds: const {
|
||||||
|
DismissDirection.startToEnd: 0.6
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 10.0),
|
||||||
|
child: CupertinoListTile(
|
||||||
|
backgroundColorActivated:
|
||||||
|
CustomTheme.backgroundColor,
|
||||||
|
title: Text(session.gameTitle),
|
||||||
|
subtitle: Visibility(
|
||||||
|
visible: session.isGameFinished,
|
||||||
|
replacement: Text(
|
||||||
|
'${AppLocalizations.of(context).mode}: ${_translateGameMode(session.isPointsLimitEnabled)}',
|
||||||
|
style: const TextStyle(fontSize: 14),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'\u{1F947} ${session.winner}',
|
||||||
|
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),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
final session =
|
||||||
|
gameManager.gameList[index];
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (context) => ActiveGameView(
|
||||||
|
gameSession: session),
|
||||||
|
),
|
||||||
|
).then((_) {
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)),
|
);
|
||||||
const SizedBox(height: 10),
|
});
|
||||||
Padding(
|
},
|
||||||
padding:
|
),
|
||||||
const EdgeInsets.symmetric(horizontal: 70),
|
child: Column(
|
||||||
child: Text(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
'${AppLocalizations.of(context).empty_text_1}\n${AppLocalizations.of(context).empty_text_2}',
|
children: [
|
||||||
textAlign: TextAlign.center,
|
const SizedBox(height: 30),
|
||||||
style: const TextStyle(fontSize: 16),
|
Center(
|
||||||
),
|
child: GestureDetector(
|
||||||
),
|
onTap: () => Navigator.push(
|
||||||
],
|
context,
|
||||||
)
|
CupertinoPageRoute(
|
||||||
: ListView.separated(
|
builder: (context) => CreateGameView(
|
||||||
itemCount: gameManager.gameList.length,
|
gameMode: ConfigService.getGameMode()),
|
||||||
separatorBuilder: (context, index) => Divider(
|
|
||||||
height: 1,
|
|
||||||
thickness: 0.5,
|
|
||||||
color: CustomTheme.white.withAlpha(50),
|
|
||||||
indent: 50,
|
|
||||||
endIndent: 50,
|
|
||||||
),
|
),
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final session = gameManager.gameList[index];
|
|
||||||
return ListenableBuilder(
|
|
||||||
listenable: session,
|
|
||||||
builder: (context, _) {
|
|
||||||
return Dismissible(
|
|
||||||
key: Key(session.id),
|
|
||||||
background: Container(
|
|
||||||
color: CupertinoColors.destructiveRed,
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.only(right: 20.0),
|
|
||||||
child: const Icon(
|
|
||||||
CupertinoIcons.delete,
|
|
||||||
color: CupertinoColors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
direction: DismissDirection.endToStart,
|
|
||||||
confirmDismiss: (direction) async {
|
|
||||||
return await _showDeleteGamePopup(
|
|
||||||
context, session.gameTitle);
|
|
||||||
},
|
|
||||||
onDismissed: (direction) {
|
|
||||||
gameManager
|
|
||||||
.removeGameSessionById(session.id);
|
|
||||||
},
|
|
||||||
dismissThresholds: const {
|
|
||||||
DismissDirection.startToEnd: 0.6
|
|
||||||
},
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 10.0),
|
|
||||||
child: CupertinoListTile(
|
|
||||||
backgroundColorActivated:
|
|
||||||
CustomTheme.backgroundColor,
|
|
||||||
title: Text(session.gameTitle),
|
|
||||||
subtitle:
|
|
||||||
session.isGameFinished == true
|
|
||||||
? Text(
|
|
||||||
'\u{1F947} ${session.winner}',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 14),
|
|
||||||
)
|
|
||||||
: Text(
|
|
||||||
'${AppLocalizations.of(context).mode}: ${_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),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
final session =
|
|
||||||
gameManager.gameList[index];
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (context) =>
|
|
||||||
ActiveGameView(
|
|
||||||
gameSession: session),
|
|
||||||
),
|
|
||||||
).then((_) {
|
|
||||||
setState(() {});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
child: Icon(
|
||||||
),
|
CupertinoIcons.plus,
|
||||||
);
|
size: 60,
|
||||||
|
color: CustomTheme.primaryColor,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 70),
|
||||||
|
child: Text(
|
||||||
|
'${AppLocalizations.of(context).empty_text_1}\n${AppLocalizations.of(context).empty_text_2}',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: const TextStyle(fontSize: 16),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ name: cabo_counter
|
|||||||
description: "Mobile app for the card game Cabo"
|
description: "Mobile app for the card game Cabo"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 0.5.2+579
|
version: 0.5.2+580
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.5.4
|
sdk: ^3.5.4
|
||||||
|
|||||||
Reference in New Issue
Block a user