added sound during countdown, and upgraded minsdkversion
This commit is contained in:
32
lib/widgets/generic/elements/form_drop_down.dart
Normal file
32
lib/widgets/generic/elements/form_drop_down.dart
Normal file
@ -0,0 +1,32 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sendtrain/helpers/widget_helpers.dart';
|
||||
|
||||
class FormDropDown extends StatelessWidget {
|
||||
const FormDropDown(
|
||||
{super.key,
|
||||
required this.title,
|
||||
required this.entries,
|
||||
required this.controller});
|
||||
|
||||
final List<DropdownMenuEntry> entries;
|
||||
final String title;
|
||||
final TextEditingController controller;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return formItemWrapper(
|
||||
DropdownMenu(
|
||||
leadingIcon: Icon(Icons.select_all_rounded),
|
||||
initialSelection: controller.text,
|
||||
controller: controller,
|
||||
expandedInsets: EdgeInsets.zero,
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: BorderRadius.circular(12))),
|
||||
label: Text(title),
|
||||
dropdownMenuEntries: entries),
|
||||
EdgeInsets.fromLTRB(10, 5, 10, 5));
|
||||
}
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
enum InputTypes { text, number }
|
||||
|
||||
class FormTextInput extends StatelessWidget {
|
||||
const FormTextInput(
|
||||
@ -9,7 +12,10 @@ class FormTextInput extends StatelessWidget {
|
||||
this.maxLines,
|
||||
this.minLines,
|
||||
this.onTap,
|
||||
this.requiresValidation=true});
|
||||
this.requiresValidation = true,
|
||||
this.type = InputTypes.text,
|
||||
this.hint,
|
||||
this.validations});
|
||||
|
||||
final TextEditingController controller;
|
||||
final String title;
|
||||
@ -18,12 +24,25 @@ class FormTextInput extends StatelessWidget {
|
||||
final Icon? icon;
|
||||
final dynamic onTap;
|
||||
final bool requiresValidation;
|
||||
final InputTypes type;
|
||||
final String? hint;
|
||||
final Function? validations;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Map params = {};
|
||||
if (type == InputTypes.number) {
|
||||
params['keyboardType'] = TextInputType.number;
|
||||
params['inputFormatters'] = <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.digitsOnly
|
||||
];
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(top: 10, bottom: 10),
|
||||
child: TextFormField(
|
||||
keyboardType: params['keyboardType'] ?? TextInputType.text,
|
||||
inputFormatters: params['inputFormatters'] ?? [],
|
||||
minLines: minLines ?? 1,
|
||||
maxLines: maxLines ?? 1,
|
||||
controller: controller,
|
||||
@ -34,6 +53,7 @@ class FormTextInput extends StatelessWidget {
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
labelText: title,
|
||||
hintText: hint ?? '',
|
||||
),
|
||||
validator: (String? value) {
|
||||
if (requiresValidation == true) {
|
||||
@ -41,9 +61,11 @@ class FormTextInput extends StatelessWidget {
|
||||
return 'Please enter some text';
|
||||
}
|
||||
|
||||
if (value.length < 3) {
|
||||
return 'Please enter a minimum of 3 characters';
|
||||
}
|
||||
if (validations != null) validations!(value);
|
||||
|
||||
// if (value.length < 3) {
|
||||
// return 'Please enter a minimum of 3 characters';
|
||||
// }
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
Reference in New Issue
Block a user