2022-08-21 17:46:42 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class CustomTextField extends StatelessWidget {
|
|
|
|
const CustomTextField({
|
|
|
|
Key? key,
|
|
|
|
required this.inputController,
|
|
|
|
required this.label,
|
|
|
|
required this.hint,
|
2022-09-07 03:37:25 +02:00
|
|
|
this.leadingIcon,
|
2022-08-21 17:46:42 +02:00
|
|
|
required this.onChanged,
|
|
|
|
}) : super(key: key);
|
2023-01-30 13:35:06 +01:00
|
|
|
final TextEditingController inputController;
|
|
|
|
final Widget label;
|
|
|
|
final String hint;
|
|
|
|
final Widget? leadingIcon;
|
|
|
|
final Function(String)? onChanged;
|
2022-08-21 17:46:42 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-09-07 03:37:25 +02:00
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 4.0),
|
|
|
|
child: TextField(
|
|
|
|
controller: inputController,
|
|
|
|
onChanged: onChanged,
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
icon: leadingIcon,
|
|
|
|
label: label,
|
|
|
|
filled: true,
|
|
|
|
fillColor: Theme.of(context).colorScheme.secondaryContainer,
|
|
|
|
hintText: hint,
|
2022-09-07 13:38:40 +02:00
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
),
|
|
|
|
floatingLabelStyle: MaterialStateTextStyle.resolveWith(
|
|
|
|
(states) => states.contains(MaterialState.focused)
|
|
|
|
? TextStyle(color: Theme.of(context).colorScheme.primary)
|
|
|
|
: TextStyle(color: Theme.of(context).colorScheme.secondary),
|
|
|
|
),
|
2022-09-07 03:37:25 +02:00
|
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
|
|
vertical: 8.0,
|
|
|
|
horizontal: 16.0,
|
|
|
|
),
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
2022-09-05 04:32:36 +02:00
|
|
|
),
|
2022-09-07 03:37:25 +02:00
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
|
|
|
width: 2.0,
|
2022-09-05 04:32:36 +02:00
|
|
|
),
|
2022-09-07 03:37:25 +02:00
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
|
|
|
errorBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: Theme.of(context).colorScheme.error,
|
2022-09-05 04:32:36 +02:00
|
|
|
),
|
2022-09-07 03:37:25 +02:00
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
),
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
|
|
|
color: Theme.of(context).colorScheme.primary,
|
2022-08-21 17:46:42 +02:00
|
|
|
),
|
2022-09-07 03:37:25 +02:00
|
|
|
borderRadius: BorderRadius.circular(10),
|
2022-08-21 17:46:42 +02:00
|
|
|
),
|
2022-09-05 04:32:36 +02:00
|
|
|
),
|
2022-09-07 03:37:25 +02:00
|
|
|
),
|
2022-08-21 17:46:42 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|