Konstanten für Länge von Namen #170
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/core/constants.dart';
|
||||
import 'package:game_tracker/core/custom_theme.dart';
|
||||
import 'package:game_tracker/core/enums.dart';
|
||||
import 'package:game_tracker/data/db/database.dart';
|
||||
@@ -58,6 +59,7 @@ class _CreateGroupViewState extends State<CreateGroupView> {
|
||||
child: TextInputField(
|
||||
controller: _groupNameController,
|
||||
hintText: loc.group_name,
|
||||
maxLength: Constants.MAX_GROUP_NAME_LENGTH,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/core/adaptive_page_route.dart';
|
||||
import 'package:game_tracker/core/constants.dart';
|
||||
import 'package:game_tracker/core/custom_theme.dart';
|
||||
import 'package:game_tracker/core/enums.dart';
|
||||
import 'package:game_tracker/data/db/database.dart';
|
||||
@@ -136,6 +137,7 @@ class _CreateMatchViewState extends State<CreateMatchView> {
|
||||
child: TextInputField(
|
||||
controller: _matchNameController,
|
||||
hintText: hintText ?? '',
|
||||
maxLength: Constants.MAX_MATCH_NAME_LENGTH,
|
||||
),
|
||||
),
|
||||
ChooseTile(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:game_tracker/core/constants.dart';
|
||||
import 'package:game_tracker/core/custom_theme.dart';
|
||||
|
||||
class CustomSearchBar extends StatelessWidget {
|
||||
@@ -49,6 +50,15 @@ class CustomSearchBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
/// Enforce maximum length on the input text
|
||||
const maxLength = Constants.MAX_PLAYER_NAME_LENGTH;
|
||||
if (controller.text.length > maxLength) {
|
||||
controller.text = controller.text.substring(0, maxLength);
|
||||
controller.selection = TextSelection.fromPosition(
|
||||
TextPosition(offset: controller.text.length),
|
||||
);
|
||||
}
|
||||
|
||||
return SearchBar(
|
||||
controller: controller,
|
||||
constraints:
|
||||
|
||||
@@ -6,11 +6,13 @@ class TextInputField extends StatelessWidget {
|
||||
/// - [controller]: The controller for the text input field.
|
||||
/// - [onChanged]: The callback invoked when the text in the field changes.
|
||||
/// - [hintText]: The hint text displayed in the text input field when it is empty
|
||||
/// - [maxLength]: The maximum length of the input text.
|
||||
|
sneeex marked this conversation as resolved
Outdated
|
||||
const TextInputField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.hintText,
|
||||
this.onChanged,
|
||||
this.maxLength,
|
||||
});
|
||||
|
||||
/// The controller for the text input field.
|
||||
@@ -22,11 +24,15 @@ class TextInputField extends StatelessWidget {
|
||||
/// The hint text displayed in the text input field when it is empty.
|
||||
final String hintText;
|
||||
|
||||
/// The maximum length of the input text.
|
||||
final int? maxLength;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextField(
|
||||
controller: controller,
|
||||
onChanged: onChanged,
|
||||
maxLength: maxLength,
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
fillColor: CustomTheme.boxColor,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: game_tracker
|
||||
description: "Game Tracking App for Card Games"
|
||||
publish_to: 'none'
|
||||
version: 0.0.7+212
|
||||
version: 0.0.7+213
|
||||
|
||||
environment:
|
||||
sdk: ^3.8.1
|
||||
|
||||
Reference in New Issue
Block a user
optional ergänzen? gleiche bei onchanged? bzw. onChanged kann ja auch required sein