Files
fcs/lib/pages/widgets/input_text.dart

104 lines
3.5 KiB
Dart
Raw Normal View History

2020-10-07 02:33:06 +06:30
import 'package:fcs/helpers/theme.dart';
import 'package:fcs/localization/app_translations.dart';
import 'package:fcs/pages/main/model/language_model.dart';
2020-09-07 16:05:28 +06:30
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class InputText extends StatelessWidget {
2021-09-10 14:25:37 +06:30
final String? labelTextKey;
final IconData? iconData;
final TextEditingController? controller;
final FormFieldValidator<String>? validator;
2020-09-07 16:05:28 +06:30
final int maxLines;
final bool withBorder;
2021-09-10 14:25:37 +06:30
final Color? borderColor;
final TextInputType? textInputType;
2020-09-16 02:29:50 +06:30
final bool autoFocus;
2020-10-14 01:51:53 +06:30
final TextAlign textAlign;
final bool enabled;
2024-02-02 18:00:51 +06:30
final BoxConstraints? constraints;
final EdgeInsetsGeometry? contentPadding;
final bool? isDense;
2020-09-07 16:05:28 +06:30
const InputText(
2021-09-10 14:25:37 +06:30
{Key? key,
2020-09-07 16:05:28 +06:30
this.labelTextKey,
this.iconData,
this.controller,
this.validator,
this.maxLines = 1,
this.withBorder = false,
2020-09-11 16:14:36 +06:30
this.borderColor,
2020-09-16 02:29:50 +06:30
this.autoFocus = false,
2020-10-14 01:51:53 +06:30
this.textInputType,
this.enabled = true,
2024-02-02 18:00:51 +06:30
this.textAlign = TextAlign.start,
this.constraints,
this.contentPadding,
this.isDense})
2020-09-07 16:05:28 +06:30
: super(key: key);
@override
Widget build(BuildContext context) {
var languageModel = Provider.of<LanguageModel>(context);
return Padding(
padding: const EdgeInsets.only(top: 15.0, bottom: 5),
child: TextFormField(
2020-10-14 01:51:53 +06:30
enabled: enabled,
2020-09-07 16:05:28 +06:30
controller: controller,
2020-09-16 02:29:50 +06:30
autofocus: autoFocus,
2020-09-07 16:05:28 +06:30
cursorColor: primaryColor,
style: textStyle,
maxLines: maxLines,
2020-09-11 16:14:36 +06:30
keyboardType: textInputType,
2021-09-10 14:25:37 +06:30
textAlign: textAlign,
2020-09-07 16:05:28 +06:30
decoration: new InputDecoration(
2024-02-02 18:00:51 +06:30
isDense: isDense,
constraints: constraints,
contentPadding: contentPadding,
2020-09-11 16:14:36 +06:30
// hintText: '',
2020-09-10 16:04:09 +06:30
hintStyle: TextStyle(
2020-09-15 07:13:41 +06:30
height: 1.5,
),
2020-09-10 16:04:09 +06:30
labelText: labelTextKey == null
? null
2021-09-10 14:25:37 +06:30
: AppTranslations.of(context)!.text(labelTextKey!),
2020-10-12 08:26:27 +06:30
labelStyle: languageModel.isEng
? newLabelStyle(color: Colors.black54, fontSize: 20)
: newLabelStyleMM(color: Colors.black54, fontSize: 20),
2020-09-07 16:05:28 +06:30
icon: iconData == null
? null
: Icon(
iconData,
color: primaryColor,
),
enabledBorder: withBorder
? OutlineInputBorder(
2024-02-02 18:00:51 +06:30
borderSide: BorderSide(
color: borderColor ?? primaryColor, width: 1.0),
2020-09-07 16:05:28 +06:30
)
: UnderlineInputBorder(
2024-02-02 18:00:51 +06:30
borderSide: BorderSide(
color: borderColor ?? primaryColor, width: 1.0)),
2020-09-07 16:05:28 +06:30
focusedBorder: withBorder
? OutlineInputBorder(
2024-02-02 18:00:51 +06:30
borderSide: BorderSide(
color: borderColor ?? primaryColor, width: 1.0),
2020-09-07 16:05:28 +06:30
)
: UnderlineInputBorder(
2024-02-02 18:00:51 +06:30
borderSide: BorderSide(
color: borderColor ?? primaryColor, width: 1.0)),
disabledBorder: withBorder
? OutlineInputBorder(
borderSide: BorderSide(
color: borderColor ?? primaryColor, width: 1.0),
)
: UnderlineInputBorder(
borderSide: BorderSide(
color: borderColor ?? primaryColor, width: 1.0)),
2020-09-07 16:05:28 +06:30
),
validator: validator),
);
}
}