94 lines
3.2 KiB
Dart
94 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:gap/gap.dart';
|
|
import 'package:tanami_app/core/styles/app_color.dart';
|
|
import 'package:tanami_app/core/styles/app_text.dart';
|
|
import 'package:tanami_app/shared/components/password_text_form_field.dart';
|
|
import 'package:tanami_app/shared/components/text_widget.dart';
|
|
|
|
import '../../core/routes/route_name.dart';
|
|
import '../../core/routes/routes.dart';
|
|
import 'text_from_field_widget.dart';
|
|
|
|
class FormLabelTextField extends StatelessWidget {
|
|
const FormLabelTextField({
|
|
super.key,
|
|
required this.title,
|
|
required this.type,
|
|
required this.textEditingController,
|
|
required this.hintText,
|
|
this.prefixWidget,
|
|
this.onChangeFun,
|
|
});
|
|
final String title;
|
|
final String type;
|
|
final String hintText;
|
|
final TextEditingController textEditingController;
|
|
final Widget? prefixWidget;
|
|
final Function(String)? onChangeFun;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
TextWidget().text14W500(
|
|
title,
|
|
clr: AppColor.textLabelColor,
|
|
txtAlign: type == "description" ? TextAlign.start : TextAlign.center,
|
|
),
|
|
const Gap(10),
|
|
type == "password"
|
|
? PasswordField(
|
|
controller: textEditingController,
|
|
hintText: hintText,
|
|
)
|
|
: textFormField(
|
|
onInput: onChangeFun,
|
|
validator: (value) {
|
|
if (type == "phone number") {
|
|
if (value != null && value.isEmpty) {
|
|
return AppText.enterPhoneNo;
|
|
}
|
|
return null;
|
|
} else if (type == "country selection") {
|
|
if (textEditingController.text.isEmpty) {
|
|
return AppText.chooseCountry;
|
|
}
|
|
return null;
|
|
} else if (type == "description") {
|
|
if (textEditingController.text.isEmpty) {
|
|
return AppText.pleaseEnteraDescription;
|
|
}
|
|
return null;
|
|
} else {
|
|
return null;
|
|
}
|
|
},
|
|
inputFormatters: [
|
|
LengthLimitingTextInputFormatter(350),
|
|
],
|
|
maxlines: type == "description" ? 6 : 1,
|
|
texttype: type == "phone number"
|
|
? TextInputType.phone
|
|
: TextInputType.name,
|
|
textEditingController: textEditingController,
|
|
readonly: type == "country selection" ? true : false,
|
|
hintText: hintText,
|
|
leadingIcon: prefixWidget,
|
|
suffixIcon: type == "country selection"
|
|
? const Icon(
|
|
Icons.arrow_forward_ios_rounded,
|
|
color: Color(0xFFB4B4B4),
|
|
)
|
|
: const SizedBox(),
|
|
onTap: () {
|
|
if (type == "country selection") {
|
|
goRouter.pushNamed(RouteName.chooseCountryScreen);
|
|
}
|
|
})
|
|
],
|
|
);
|
|
}
|
|
}
|