Maximale Input in Textfelder gefixtx #176
@@ -48,6 +48,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
|||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
return ScaffoldMessenger(
|
return ScaffoldMessenger(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
resizeToAvoidBottomInset: false,
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
appBar: AppBar(title: Text(loc.create_new_group)),
|
appBar: AppBar(title: Text(loc.create_new_group)),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class _ChooseGameViewState extends State<ChooseGameView> {
|
|||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
|
resizeToAvoidBottomInset: false,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: const Icon(Icons.arrow_back_ios),
|
icon: const Icon(Icons.arrow_back_ios),
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class _ChooseGroupViewState extends State<ChooseGroupView> {
|
|||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
|
resizeToAvoidBottomInset: false,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: const Icon(Icons.arrow_back_ios),
|
icon: const Icon(Icons.arrow_back_ios),
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:game_tracker/core/custom_theme.dart';
|
|
||||||
import 'package:game_tracker/core/enums.dart';
|
|
||||||
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
|
||||||
import 'package:game_tracker/presentation/widgets/tiles/title_description_list_tile.dart';
|
|
||||||
|
|
||||||
class ChooseRulesetView extends StatefulWidget {
|
|
||||||
/// A view that allows the user to choose a ruleset from a list of available rulesets
|
|
||||||
/// - [rulesets]: A list of tuples containing the ruleset and its description
|
|
||||||
/// - [initialRulesetIndex]: The index of the initially selected ruleset
|
|
||||||
const ChooseRulesetView({
|
|
||||||
super.key,
|
|
||||||
required this.rulesets,
|
|
||||||
required this.initialRulesetIndex,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// A list of tuples containing the ruleset and its description
|
|
||||||
final List<(Ruleset, String)> rulesets;
|
|
||||||
|
|
||||||
/// The index of the initially selected ruleset
|
|
||||||
final int initialRulesetIndex;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ChooseRulesetView> createState() => _ChooseRulesetViewState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ChooseRulesetViewState extends State<ChooseRulesetView> {
|
|
||||||
/// Currently selected ruleset index
|
|
||||||
late int selectedRulesetIndex;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
selectedRulesetIndex = widget.initialRulesetIndex;
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final loc = AppLocalizations.of(context);
|
|
||||||
return DefaultTabController(
|
|
||||||
length: 2,
|
|
||||||
initialIndex: 0,
|
|
||||||
child: Scaffold(
|
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
|
||||||
appBar: AppBar(
|
|
||||||
leading: IconButton(
|
|
||||||
icon: const Icon(Icons.arrow_back_ios),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop(
|
|
||||||
selectedRulesetIndex == -1
|
|
||||||
? null
|
|
||||||
: widget.rulesets[selectedRulesetIndex].$1,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
title: Text(loc.choose_ruleset),
|
|
||||||
),
|
|
||||||
body: PopScope(
|
|
||||||
// This fixes that the Android Back Gesture didn't return the
|
|
||||||
// selectedRulesetIndex and therefore the selected Ruleset wasn't saved
|
|
||||||
canPop: false,
|
|
||||||
onPopInvokedWithResult: (bool didPop, Object? result) {
|
|
||||||
if (didPop) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Navigator.of(context).pop(
|
|
||||||
selectedRulesetIndex == -1
|
|
||||||
? null
|
|
||||||
: widget.rulesets[selectedRulesetIndex].$1,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: ListView.builder(
|
|
||||||
padding: const EdgeInsets.only(bottom: 85),
|
|
||||||
itemCount: widget.rulesets.length,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
return TitleDescriptionListTile(
|
|
||||||
onPressed: () async {
|
|
||||||
setState(() {
|
|
||||||
if (selectedRulesetIndex == index) {
|
|
||||||
selectedRulesetIndex = -1;
|
|
||||||
} else {
|
|
||||||
selectedRulesetIndex = index;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
title: translateRulesetToString(
|
|
||||||
widget.rulesets[index].$1,
|
|
||||||
context,
|
|
||||||
),
|
|
||||||
description: widget.rulesets[index].$2,
|
|
||||||
isHighlighted: selectedRulesetIndex == index,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,6 @@ import 'package:game_tracker/data/dto/player.dart';
|
|||||||
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/choose_game_view.dart';
|
import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/choose_game_view.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/choose_group_view.dart';
|
import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/choose_group_view.dart';
|
||||||
import 'package:game_tracker/presentation/views/main_menu/match_view/create_match/choose_ruleset_view.dart';
|
|
||||||
import 'package:game_tracker/presentation/views/main_menu/match_view/match_result_view.dart';
|
import 'package:game_tracker/presentation/views/main_menu/match_view/match_result_view.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
|
import 'package:game_tracker/presentation/widgets/buttons/custom_width_button.dart';
|
||||||
import 'package:game_tracker/presentation/widgets/player_selection.dart';
|
import 'package:game_tracker/presentation/widgets/player_selection.dart';
|
||||||
@@ -58,13 +57,6 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
/// the [ChooseGroupView]
|
/// the [ChooseGroupView]
|
||||||
String selectedGroupId = '';
|
String selectedGroupId = '';
|
||||||
|
|
||||||
/// The currently selected ruleset
|
|
||||||
Ruleset? selectedRuleset;
|
|
||||||
|
|
||||||
/// The index of the currently selected ruleset in [rulesets] to mark it in
|
|
||||||
/// the [ChooseRulesetView]
|
|
||||||
int selectedRulesetIndex = -1;
|
|
||||||
|
|
||||||
/// The index of the currently selected game in [games] to mark it in
|
/// The index of the currently selected game in [games] to mark it in
|
||||||
/// the [ChooseGameView]
|
/// the [ChooseGameView]
|
||||||
int selectedGameIndex = -1;
|
int selectedGameIndex = -1;
|
||||||
@@ -72,9 +64,6 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
/// The currently selected players
|
/// The currently selected players
|
||||||
List<Player>? selectedPlayers;
|
List<Player>? selectedPlayers;
|
||||||
|
|
||||||
/// List of available rulesets with their localized string representations
|
|
||||||
late final List<(Ruleset, String)> _rulesets;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -107,15 +96,8 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
hintText ??= loc.match_name;
|
hintText ??= loc.match_name;
|
||||||
_rulesets = [
|
|
||||||
(Ruleset.singleWinner, loc.ruleset_single_winner),
|
|
||||||
(Ruleset.singleLoser, loc.ruleset_single_loser),
|
|
||||||
(Ruleset.mostPoints, loc.ruleset_most_points),
|
|
||||||
(Ruleset.leastPoints, loc.ruleset_least_points),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Replace when games are implemented
|
|
||||||
List<(String, String, Ruleset)> games = [
|
List<(String, String, Ruleset)> games = [
|
||||||
('Example Game 1', 'This is a description', Ruleset.leastPoints),
|
('Example Game 1', 'This is a description', Ruleset.leastPoints),
|
||||||
('Example Game 2', '', Ruleset.singleWinner),
|
('Example Game 2', '', Ruleset.singleWinner),
|
||||||
@@ -126,6 +108,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
final loc = AppLocalizations.of(context);
|
final loc = AppLocalizations.of(context);
|
||||||
return ScaffoldMessenger(
|
return ScaffoldMessenger(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
resizeToAvoidBottomInset: false,
|
||||||
backgroundColor: CustomTheme.backgroundColor,
|
backgroundColor: CustomTheme.backgroundColor,
|
||||||
appBar: AppBar(title: Text(loc.create_new_match)),
|
appBar: AppBar(title: Text(loc.create_new_match)),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
@@ -157,39 +140,12 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
if (selectedGameIndex != -1) {
|
if (selectedGameIndex != -1) {
|
||||||
hintText = games[selectedGameIndex].$1;
|
hintText = games[selectedGameIndex].$1;
|
||||||
selectedRuleset = games[selectedGameIndex].$3;
|
|
||||||
selectedRulesetIndex = _rulesets.indexWhere(
|
|
||||||
(r) => r.$1 == selectedRuleset,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
hintText = loc.match_name;
|
hintText = loc.match_name;
|
||||||
selectedRuleset = null;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ChooseTile(
|
|
||||||
title: loc.ruleset,
|
|
||||||
trailingText: selectedRuleset == null
|
|
||||||
? loc.none
|
|
||||||
: translateRulesetToString(selectedRuleset!, context),
|
|
||||||
onPressed: () async {
|
|
||||||
selectedRuleset = await Navigator.of(context).push(
|
|
||||||
adaptivePageRoute(
|
|
||||||
builder: (context) => ChooseRulesetView(
|
|
||||||
rulesets: _rulesets,
|
|
||||||
initialRulesetIndex: selectedRulesetIndex,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (!mounted) return;
|
|
||||||
selectedRulesetIndex = _rulesets.indexWhere(
|
|
||||||
(r) => r.$1 == selectedRuleset,
|
|
||||||
);
|
|
||||||
selectedGameIndex = -1;
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ChooseTile(
|
ChooseTile(
|
||||||
title: loc.group,
|
title: loc.group,
|
||||||
trailingText: selectedGroup == null
|
trailingText: selectedGroup == null
|
||||||
@@ -274,7 +230,6 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
|||||||
/// - Either a group is selected OR at least 2 players are selected
|
/// - Either a group is selected OR at least 2 players are selected
|
||||||
bool _enableCreateGameButton() {
|
bool _enableCreateGameButton() {
|
||||||
return (selectedGroup != null ||
|
return (selectedGroup != null ||
|
||||||
(selectedPlayers != null && selectedPlayers!.length > 1)) &&
|
(selectedPlayers != null && selectedPlayers!.length > 1));
|
||||||
selectedRuleset != null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ class TitleDescriptionListTile extends StatelessWidget {
|
|||||||
const Spacer(),
|
const Spacer(),
|
||||||
Container(
|
Container(
|
||||||
constraints: const BoxConstraints(maxWidth: 115),
|
constraints: const BoxConstraints(maxWidth: 115),
|
||||||
margin: const EdgeInsets.only(top: 4),
|
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 2,
|
vertical: 2,
|
||||||
horizontal: 6,
|
horizontal: 6,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: game_tracker
|
name: game_tracker
|
||||||
description: "Game Tracking App for Card Games"
|
description: "Game Tracking App for Card Games"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 0.0.8+234
|
version: 0.0.10+237
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.8.1
|
sdk: ^3.8.1
|
||||||
|
|||||||
Reference in New Issue
Block a user