Implemented various new forms of CustomFormRow into SettingsView

This commit is contained in:
2025-07-09 17:15:30 +02:00
parent 9bc80a8cd9
commit 696ade5b9b
2 changed files with 139 additions and 97 deletions

View File

@@ -46,14 +46,16 @@ class _SettingsViewState extends State<SettingsView> {
), ),
), ),
Padding( Padding(
padding: const EdgeInsets.fromLTRB(15, 10, 10, 0), padding: const EdgeInsets.fromLTRB(10, 15, 10, 10),
child: CupertinoListTile( child: CupertinoFormSection.insetGrouped(
padding: EdgeInsets.zero, backgroundColor: CustomTheme.backgroundColor,
title: Text(AppLocalizations.of(context).cabo_penalty), margin: EdgeInsets.zero,
subtitle: Text( children: [
AppLocalizations.of(context).cabo_penalty_subtitle), CustomFormRow(
trailing: Stepper(
key: _stepperKey1, key: _stepperKey1,
prefixText: 'Cabo-Strafe',
prefixIcon: CupertinoIcons.minus_square,
suffixWidget: Stepper(
initialValue: ConfigService.caboPenalty, initialValue: ConfigService.caboPenalty,
minValue: 0, minValue: 0,
maxValue: 50, maxValue: 50,
@@ -65,16 +67,12 @@ class _SettingsViewState extends State<SettingsView> {
}); });
}, },
), ),
)), ),
Padding( CustomFormRow(
padding: const EdgeInsets.fromLTRB(15, 10, 10, 0),
child: CupertinoListTile(
padding: EdgeInsets.zero,
title: Text(AppLocalizations.of(context).point_limit),
subtitle:
Text(AppLocalizations.of(context).point_limit_subtitle),
trailing: Stepper(
key: _stepperKey2, key: _stepperKey2,
prefixText: 'Punkte-Limit',
prefixIcon: FontAwesomeIcons.bullseye,
suffixWidget: Stepper(
initialValue: ConfigService.pointLimit, initialValue: ConfigService.pointLimit,
minValue: 30, minValue: 30,
maxValue: 1000, maxValue: 1000,
@@ -86,26 +84,51 @@ class _SettingsViewState extends State<SettingsView> {
}); });
}, },
), ),
)), ),
Padding( CustomFormRow(
padding: const EdgeInsets.fromLTRB(0, 10, 0, 0), prefixText:
child: Center( AppLocalizations.of(context).reset_to_default,
heightFactor: 0.9, prefixIcon: CupertinoIcons.arrow_counterclockwise,
child: CupertinoButton( onPressed: () {
padding: EdgeInsets.zero,
onPressed: () => setState(() {
ConfigService.resetConfig(); ConfigService.resetConfig();
setState(() {
_stepperKey1 = UniqueKey(); _stepperKey1 = UniqueKey();
_stepperKey2 = UniqueKey(); _stepperKey2 = UniqueKey();
}), print('Config reset to default');
child: });
Text(AppLocalizations.of(context).reset_to_default), },
), )
)), ])),
Padding( Padding(
padding: const EdgeInsets.fromLTRB(10, 10, 0, 0), padding: const EdgeInsets.fromLTRB(10, 10, 0, 0),
child: Text( child: Text(
AppLocalizations.of(context).game_data, AppLocalizations.of(context).data,
style: CustomTheme.rowTitle,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(10, 15, 10, 10),
child: CupertinoFormSection.insetGrouped(
backgroundColor: CustomTheme.backgroundColor,
margin: EdgeInsets.zero,
children: [
CustomFormRow(
prefixText: AppLocalizations.of(context).import_data,
prefixIcon: CupertinoIcons.square_arrow_down,
onPressed: () => LocalStorageService.importJsonFile(),
suffixWidget: const CupertinoListTileChevron(),
),
CustomFormRow(
prefixText: AppLocalizations.of(context).export_data,
prefixIcon: CupertinoIcons.square_arrow_up,
onPressed: () => LocalStorageService.importJsonFile(),
suffixWidget: const CupertinoListTileChevron(),
),
])),
Padding(
padding: const EdgeInsets.fromLTRB(10, 10, 0, 0),
child: Text(
AppLocalizations.of(context).app,
style: CustomTheme.rowTitle, style: CustomTheme.rowTitle,
), ),
), ),
@@ -115,54 +138,73 @@ class _SettingsViewState extends State<SettingsView> {
backgroundColor: CustomTheme.backgroundColor, backgroundColor: CustomTheme.backgroundColor,
margin: EdgeInsets.zero, margin: EdgeInsets.zero,
children: [ children: [
CustomFormRow(
prefixText: 'Spieldaten importieren',
prefixIcon: CupertinoIcons.square_arrow_down,
onTap: () {},
suffixWidget: CupertinoListTileChevron(),
),
CustomFormRow(
prefixText: 'Spieldaten exportieren',
prefixIcon: CupertinoIcons.square_arrow_up,
onTap: () {},
suffixWidget: const CupertinoListTileChevron(),
),
CustomFormRow( CustomFormRow(
prefixText: AppLocalizations.of(context).create_issue, prefixText: AppLocalizations.of(context).create_issue,
prefixIcon: FontAwesomeIcons.github, prefixIcon: FontAwesomeIcons.github,
onTap: () => launchUrl(Uri.parse( onPressed: () => launchUrl(Uri.parse(
'https://github.com/flixcoo/Cabo-Counter/issues')), 'https://github.com/flixcoo/Cabo-Counter/issues')),
suffixWidget: const CupertinoListTileChevron(), suffixWidget: const CupertinoListTileChevron(),
), ),
])), CustomFormRow(
], prefixText: 'App-Version',
), prefixIcon: CupertinoIcons.info,
Positioned( onPressed: null,
bottom: 30, suffixWidget: FutureBuilder<PackageInfo>(
left: 0,
right: 0,
child: Center(
child: FutureBuilder<PackageInfo>(
future: _getPackageInfo(), future: _getPackageInfo(),
builder: (context, snapshot) { builder: (context, snapshot) {
if (snapshot.hasData) { if (snapshot.hasData) {
return Text( return Text(
'${Globals.appDevPhase} ${snapshot.data!.version} ' '${Globals.appDevPhase} ${snapshot.data!.version} ',
'(${AppLocalizations.of(context).build} ${snapshot.data!.buildNumber})', style: TextStyle(
textAlign: TextAlign.center, color: CustomTheme.primaryColor,
),
); );
} else if (snapshot.hasError) { } else if (snapshot.hasError) {
return Text( return Text(
'${AppLocalizations.of(context).app_version} -.-.- (${AppLocalizations.of(context).build} -)', '${AppLocalizations.of(context).app_version} -.-.-',
textAlign: TextAlign.center, style: TextStyle(
color: CustomTheme.primaryColor,
),
); );
} }
return Text( return Text(
AppLocalizations.of(context).load_version, AppLocalizations.of(context).loading,
textAlign: TextAlign.center, style: TextStyle(
color: CustomTheme.primaryColor,
),
); );
}, },
))), )),
CustomFormRow(
prefixText: 'Build-Nr.',
prefixIcon: CupertinoIcons.info,
onPressed: null,
suffixWidget: FutureBuilder<PackageInfo>(
future: _getPackageInfo(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(
snapshot.data!.buildNumber,
style: TextStyle(
color: CustomTheme.primaryColor,
),
);
} else if (snapshot.hasError) {
return Text(
'-',
style: TextStyle(
color: CustomTheme.primaryColor,
),
);
}
return Text(
AppLocalizations.of(context).loading,
);
},
)),
])),
],
),
], ],
)), )),
); );

View File

@@ -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.3.9+337 version: 0.4.0+371
environment: environment:
sdk: ^3.5.4 sdk: ^3.5.4