mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
added devices
This commit is contained in:
@ -1,59 +1,97 @@
|
||||
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,
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
@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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -71,26 +109,21 @@ class CustomTextField extends StatelessWidget {
|
||||
),
|
||||
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!();
|
||||
|
Reference in New Issue
Block a user