manager-app/lib/Components/rounded_input_field.dart
2023-04-01 16:52:13 +02:00

61 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:manager_app/Components/text_field_container.dart';
import 'package:manager_app/constants.dart';
class RoundedInputField extends StatelessWidget {
final String? hintText;
final IconData? icon;
final ValueChanged<String> onChanged;
final String? initialValue;
final Color color, textColor, iconColor;
final int? maxLength;
final bool isEmail;
final double fontSize;
final String? autofill;
final bool isInt;
const RoundedInputField({
Key? key,
this.hintText,
this.initialValue,
this.icon,
this.color = kSecond,
this.textColor = kBlack,
this.iconColor = kPrimaryColor,
required this.onChanged,
this.maxLength, // 50
this.isEmail = false,
this.fontSize = 20,
this.autofill,
this.isInt = false
}) : super(key: key);
@override
Widget build(BuildContext context) {
return TextFieldContainer(
color: color,
child: TextFormField (
onChanged: onChanged,
initialValue: initialValue,
cursorColor: textColor,
maxLength: maxLength,
autofillHints: autofill != null ? [autofill!] : [],
keyboardType: isEmail ? TextInputType.emailAddress : isInt ? TextInputType.number : TextInputType.text,
inputFormatters: !isInt ? [] : <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
],
style: TextStyle(fontSize: fontSize, color: textColor),
decoration: InputDecoration(
icon: icon != null ? Icon(
icon,
color: iconColor,
): null,
hintText: hintText,
hintStyle: TextStyle(fontSize: fontSize, color: textColor),
border: InputBorder.none,
)
),
);
}
}