mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Merged with dev
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/bloc/device_managment_bloc.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/all_devices/bloc/device_mgmt_bloc/device_managment_bloc.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
@ -1,59 +1,107 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
import 'package:syncrow_web/utils/style.dart';
|
||||
|
||||
class StatefulTextField extends StatefulWidget {
|
||||
const StatefulTextField(
|
||||
{super.key,
|
||||
required this.title,
|
||||
this.hintText = 'Please enter',
|
||||
required this.width,
|
||||
this.elevation = 0,
|
||||
required this.controller,
|
||||
this.onSubmitted});
|
||||
const StatefulTextField({
|
||||
super.key,
|
||||
required this.title,
|
||||
this.hintText = 'Please enter',
|
||||
required this.width,
|
||||
this.elevation,
|
||||
required this.controller,
|
||||
this.onSubmitted,
|
||||
this.boxDecoration,
|
||||
this.borderRadius,
|
||||
this.height,
|
||||
this.padding,
|
||||
this.icon,
|
||||
this.hintColor,
|
||||
required this.onChanged,
|
||||
this.isRequired,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String hintText;
|
||||
final double width;
|
||||
final double elevation;
|
||||
final double? elevation;
|
||||
final TextEditingController controller;
|
||||
final Function? onSubmitted;
|
||||
final BoxDecoration? boxDecoration;
|
||||
final double? borderRadius;
|
||||
final double? height;
|
||||
final double? padding;
|
||||
final IconData? icon;
|
||||
final Color? hintColor;
|
||||
final Function(String)? onChanged;
|
||||
final bool? isRequired;
|
||||
|
||||
@override
|
||||
State<StatefulTextField> createState() => _StatefulTextFieldState();
|
||||
}
|
||||
|
||||
class _StatefulTextFieldState extends State<StatefulTextField> {
|
||||
@override
|
||||
void dispose() {
|
||||
widget.controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
child: CustomTextField(
|
||||
title: widget.title,
|
||||
controller: widget.controller,
|
||||
hintText: widget.hintText,
|
||||
width: widget.width,
|
||||
elevation: widget.elevation,
|
||||
onSubmittedFun: widget.onSubmitted),
|
||||
return CustomTextField(
|
||||
title: widget.title,
|
||||
controller: widget.controller,
|
||||
hintText: widget.hintText,
|
||||
width: widget.width,
|
||||
elevation: widget.elevation,
|
||||
onSubmittedFun: widget.onSubmitted,
|
||||
boxDecoration: widget.boxDecoration,
|
||||
borderRadius: widget.borderRadius,
|
||||
height: widget.height,
|
||||
padding: widget.padding,
|
||||
icon: widget.icon,
|
||||
hintColor: widget.hintColor,
|
||||
onChanged: widget.onChanged,
|
||||
isRequired: widget.isRequired,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CustomTextField extends StatelessWidget {
|
||||
const CustomTextField(
|
||||
{super.key,
|
||||
required this.title,
|
||||
required this.controller,
|
||||
this.hintText = 'Please enter',
|
||||
required this.width,
|
||||
this.elevation = 0,
|
||||
this.onSubmittedFun});
|
||||
const CustomTextField({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.controller,
|
||||
this.hintText = 'Please enter',
|
||||
required this.width,
|
||||
this.elevation,
|
||||
this.onSubmittedFun,
|
||||
this.boxDecoration,
|
||||
this.borderRadius,
|
||||
this.height,
|
||||
this.padding,
|
||||
this.icon,
|
||||
this.hintColor,
|
||||
required this.onChanged,
|
||||
this.isRequired,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final TextEditingController controller;
|
||||
final String hintText;
|
||||
final double width;
|
||||
final double elevation;
|
||||
final double? elevation;
|
||||
final Function? onSubmittedFun;
|
||||
final BoxDecoration? boxDecoration;
|
||||
final double? borderRadius;
|
||||
final double? height;
|
||||
final double? padding;
|
||||
final IconData? icon;
|
||||
final Color? hintColor;
|
||||
final Function(String)? onChanged;
|
||||
final bool? isRequired;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -61,40 +109,65 @@ class CustomTextField extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: context.textTheme.bodyMedium!.copyWith(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: const Color(0xff000000),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: isRequired == true,
|
||||
child: Text('* ',
|
||||
style: context.textTheme.bodyMedium!
|
||||
.copyWith(color: Colors.red, fontSize: 13)),
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
style: context.textTheme.bodyMedium!.copyWith(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: const Color(0xff000000),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Material(
|
||||
elevation: elevation,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
elevation: elevation ?? 0,
|
||||
borderRadius: BorderRadius.circular(borderRadius ?? 8),
|
||||
child: Container(
|
||||
width: width,
|
||||
height: 45,
|
||||
decoration: containerDecoration,
|
||||
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.white,
|
||||
// borderRadius: BorderRadius.circular(8),
|
||||
// ),
|
||||
height: height ?? 45,
|
||||
decoration: boxDecoration ?? containerDecoration,
|
||||
child: TextFormField(
|
||||
controller: controller,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
|
||||
decoration: InputDecoration(
|
||||
hintText: hintText,
|
||||
hintStyle: const TextStyle(fontSize: 12),
|
||||
contentPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 12, color: hintColor ?? ColorsManager.blackColor),
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: padding ?? 10),
|
||||
border: InputBorder.none,
|
||||
suffixIcon: icon != null
|
||||
? Icon(icon, color: ColorsManager.greyColor)
|
||||
: null,
|
||||
),
|
||||
onFieldSubmitted: (_) {
|
||||
onSubmittedFun!();
|
||||
},
|
||||
onChanged: (value) {
|
||||
onChanged!(value);
|
||||
},
|
||||
|
||||
/// required validator
|
||||
validator: (value) {
|
||||
if (isRequired == true) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'This field is required';
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user