81 lines
2.4 KiB
Dart
81 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:frontend/utils/colorOpcity.dart';
|
|
|
|
class CustomTextFieldWrapper extends StatefulWidget {
|
|
final Widget child;
|
|
final bool isFocused;
|
|
final bool isDesktop;
|
|
final double? width;
|
|
final Color? color;
|
|
final VoidCallback? onFocusChange; // Callback for focus handling
|
|
final EdgeInsetsGeometry padding;
|
|
final BorderRadius? borderRadius;
|
|
final Color? layoutColor;
|
|
|
|
const CustomTextFieldWrapper({
|
|
super.key,
|
|
required this.child,
|
|
required this.isFocused,
|
|
required this.isDesktop,
|
|
this.width,
|
|
this.color = Colors.white,
|
|
this.onFocusChange,
|
|
this.padding = const EdgeInsets.symmetric(horizontal: 12),
|
|
this.borderRadius,
|
|
this.layoutColor,
|
|
});
|
|
|
|
@override
|
|
_CustomTextFieldWrapperState createState() => _CustomTextFieldWrapperState();
|
|
}
|
|
|
|
class _CustomTextFieldWrapperState extends State<CustomTextFieldWrapper> {
|
|
Color getColorWithOpacity(Color color, double opacity) {
|
|
final int alpha = (opacity * 255).round().clamp(0, 255);
|
|
return Color.fromARGB(
|
|
alpha,
|
|
color.r.toInt(),
|
|
color.g.toInt(),
|
|
color.b.toInt(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
width: widget.width ?? // Use custom width if provided, else default
|
|
(widget.isDesktop
|
|
? MediaQuery.of(context).size.width * 0.3
|
|
: MediaQuery.of(context).size.width * 0.85),
|
|
padding: widget.padding,
|
|
decoration: BoxDecoration(
|
|
color: widget.isFocused
|
|
? (widget.layoutColor ?? widget.color)
|
|
: widget.color,
|
|
borderRadius: widget.borderRadius ?? BorderRadius.circular(8),
|
|
|
|
border: Border.all(
|
|
color: widget.isFocused
|
|
? (widget.layoutColor ?? Colors.blueAccent)
|
|
: Color(0xFFF5F5F5),
|
|
width: widget.isFocused ? 1.5 : 1.5,
|
|
),
|
|
// boxShadow: widget.isFocused
|
|
// ? [
|
|
// BoxShadow(
|
|
// // color: Color.fromRGBO(120, 180, 252, 0.3),
|
|
// // color: widget.isFocused
|
|
// // ? (widget.layoutColor ?? Colors.red).withAlpha(204)
|
|
// // : Color(0xFFF5F5F5),
|
|
// blurRadius: 10,
|
|
// spreadRadius: 1,
|
|
// offset: Offset(0, 4),
|
|
// ),
|
|
// ]
|
|
// : [],
|
|
),
|
|
child: widget.child,
|
|
);
|
|
}
|
|
}
|