226 lines
6.7 KiB
Dart
226 lines
6.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:regroup/Utils/texts.dart';
|
|
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
|
|
import 'package:path/path.dart' as path;
|
|
|
|
// ignore: must_be_immutable
|
|
class TextInputField extends StatefulWidget {
|
|
TextInputField({Key? key, this.hinttext, this.controller, this.validator})
|
|
: super(key: key);
|
|
final String? hinttext;
|
|
final TextEditingController? controller;
|
|
dynamic validator;
|
|
|
|
@override
|
|
State<TextInputField> createState() => _TextInputFieldState();
|
|
}
|
|
|
|
class _TextInputFieldState extends State<TextInputField> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: double.infinity,
|
|
height: 46.h,
|
|
child: TextFormField(
|
|
inputFormatters: [
|
|
RemoveEmojiInputFormatter(),
|
|
],
|
|
controller: widget.controller,
|
|
validator: widget.validator ??
|
|
(value) {
|
|
if (value == null || value.isEmpty) {
|
|
return "Empty value";
|
|
}
|
|
return null;
|
|
},
|
|
decoration: InputDecoration(
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
vertical: 12.0,
|
|
horizontal: 16), //<-- Adjust the vertical padding as needed
|
|
|
|
hintText: widget.hinttext,
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: const BorderSide(
|
|
width: 1, color: Color(0x7FE8C69F)), //<-- SEE HERE
|
|
borderRadius: BorderRadius.circular(5.0),
|
|
),
|
|
border: OutlineInputBorder(
|
|
borderSide: const BorderSide(
|
|
width: 1, color: Color(0x7FE8C69F)), //<-- SEE HERE
|
|
borderRadius: BorderRadius.circular(5.0),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide: const BorderSide(
|
|
width: 1, color: Color(0x7FE8C69F)), //<-- SEE HERE
|
|
borderRadius: BorderRadius.circular(5.0),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
Widget MessageTextInputField(
|
|
String hinttext, TextEditingController controller, dynamic validator) {
|
|
return TextFormField(
|
|
inputFormatters: [RemoveEmojiInputFormatter()],
|
|
// maxLength: 5,
|
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
|
maxLines: 5,
|
|
validator: validator,
|
|
controller: controller,
|
|
decoration: InputDecoration(
|
|
labelStyle: const TextStyle(color: Colors.black),
|
|
errorStyle: TextStyle(
|
|
fontSize: 13.sp,
|
|
color: Color.fromARGB(255, 245, 130, 122),
|
|
),
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
vertical: 12.0,
|
|
horizontal: 16), //<-- Adjust the vertical padding as needed
|
|
filled: true,
|
|
fillColor: Color(0xFFFFF3E4),
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(5),
|
|
borderSide: const BorderSide(color: Color(0xFFE8C69F80), width: 1),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(5),
|
|
borderSide: const BorderSide(color: Color(0xFFE8C69F80), width: 1),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(5),
|
|
borderSide: const BorderSide(color: Color(0xFFE8C69F80), width: 1),
|
|
),
|
|
errorBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(5),
|
|
borderSide: const BorderSide(color: Colors.red, width: 1),
|
|
),
|
|
focusedErrorBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(5),
|
|
borderSide: const BorderSide(color: Colors.red, width: 1),
|
|
),
|
|
hintText: hinttext,
|
|
hintStyle: const TextStyle(
|
|
color: Color(0xFF737373),
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w400,
|
|
fontFamily: "DM Sans"),
|
|
|
|
// focusedBorder: const OutlineInputBorder(borderSide: BorderSide.none),
|
|
// border: const OutlineInputBorder(borderSide: BorderSide.none),
|
|
// enabledBorder: const OutlineInputBorder(borderSide: BorderSide.none),
|
|
),
|
|
keyboardType: TextInputType.text,
|
|
);
|
|
}
|
|
|
|
Widget commonDivider() {
|
|
return Container(
|
|
height: 1.5.h,
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
colors: [
|
|
Color.fromRGBO(255, 255, 255, 0.07),
|
|
Color.fromRGBO(255, 255, 255, 0.09),
|
|
],
|
|
transform: GradientRotation(1.78),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget stackContainers({
|
|
required String number,
|
|
required List<String> containerImages,
|
|
}) {
|
|
return Row(
|
|
children: [
|
|
SizedBox(width: 12),
|
|
Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
Container(
|
|
height: 30,
|
|
width: 30,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: Color(0xFFD90B2E),
|
|
border: Border.all(color: Color(0xFF2C3742), width: 1),
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
number,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.w400,
|
|
fontSize: 8,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Positioned(
|
|
left: 20,
|
|
child: SizedBox(
|
|
height: 30,
|
|
width: 50,
|
|
child: Stack(
|
|
clipBehavior: Clip.none,
|
|
children: List.generate(containerImages.length, (index) {
|
|
return Positioned(
|
|
left: index * 22.0,
|
|
child: Container(
|
|
height: 30,
|
|
width: 30,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
border: Border.all(color: Color(0xFF2C3742), width: 1),
|
|
),
|
|
child: CircleAvatar(
|
|
foregroundImage: AssetImage(containerImages[index]),
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget popupMenuItemWidget({
|
|
required void Function()? ontap,
|
|
required String text,
|
|
required String imageIcon,
|
|
}) {
|
|
return PopupMenuItem(
|
|
onTap: ontap,
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w),
|
|
child: Row(
|
|
children: [
|
|
text14w400white(text),
|
|
Spacer(),
|
|
Image.asset(
|
|
imageIcon,
|
|
height: 25.h,
|
|
width: 25.w,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
String extractFileName(String filePath) {
|
|
return path.basename(filePath);
|
|
}
|