Merge remote-tracking branch 'origin/development' into feature/119-implementierung-der-games
# Conflicts: # lib/presentation/widgets/text_input/text_input_field.dart
This commit is contained in:
@@ -84,6 +84,7 @@ class _PlayerSelectionState extends State<PlayerSelection> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
CustomSearchBar(
|
CustomSearchBar(
|
||||||
|
maxLength: Constants.MAX_PLAYER_NAME_LENGTH,
|
||||||
controller: _searchBarController,
|
controller: _searchBarController,
|
||||||
constraints: const BoxConstraints(maxHeight: 45, minHeight: 45),
|
constraints: const BoxConstraints(maxHeight: 45, minHeight: 45),
|
||||||
hintText: loc.search_for_players,
|
hintText: loc.search_for_players,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
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/custom_theme.dart';
|
||||||
|
|
||||||
class CustomSearchBar extends StatelessWidget {
|
class CustomSearchBar extends StatelessWidget {
|
||||||
@@ -22,6 +21,7 @@ class CustomSearchBar extends StatelessWidget {
|
|||||||
this.onTrailingButtonPressed,
|
this.onTrailingButtonPressed,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.constraints,
|
this.constraints,
|
||||||
|
this.maxLength,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The controller for the search bar's text input.
|
/// The controller for the search bar's text input.
|
||||||
@@ -48,16 +48,20 @@ class CustomSearchBar extends StatelessWidget {
|
|||||||
/// The constraints for the search bar.
|
/// The constraints for the search bar.
|
||||||
final BoxConstraints? constraints;
|
final BoxConstraints? constraints;
|
||||||
|
|
||||||
|
/// Optional parameter for maximum length of the input text.
|
||||||
|
final int? maxLength;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
/// Enforce maximum length on the input text
|
/// Enforce maximum length on the input text
|
||||||
const maxLength = Constants.MAX_PLAYER_NAME_LENGTH;
|
if (maxLength != null) {
|
||||||
if (controller.text.length > maxLength) {
|
if (controller.text.length > maxLength!) {
|
||||||
controller.text = controller.text.substring(0, maxLength);
|
controller.text = controller.text.substring(0, maxLength);
|
||||||
controller.selection = TextSelection.fromPosition(
|
controller.selection = TextSelection.fromPosition(
|
||||||
TextPosition(offset: controller.text.length),
|
TextPosition(offset: controller.text.length),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return SearchBar(
|
return SearchBar(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:game_tracker/core/custom_theme.dart';
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
|
|
||||||
class TextInputField extends StatelessWidget {
|
class TextInputField extends StatelessWidget {
|
||||||
@@ -48,6 +49,7 @@ class TextInputField extends StatelessWidget {
|
|||||||
controller: controller,
|
controller: controller,
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
maxLength: maxLength,
|
maxLength: maxLength,
|
||||||
|
maxLengthEnforcement: MaxLengthEnforcement.truncateAfterCompositionEnds,
|
||||||
maxLines: maxLines,
|
maxLines: maxLines,
|
||||||
minLines: minLines,
|
minLines: minLines,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
|||||||
Reference in New Issue
Block a user