feat : unit_text_field.dart and baller inputs
This commit is contained in:
3
packages/core/lib/presentation/widget/inputs/inputs.dart
Normal file
3
packages/core/lib/presentation/widget/inputs/inputs.dart
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export 'unit_text_field.dart';
|
||||||
|
export 'r_input.dart';
|
||||||
|
export 'input_fixed_hint.dart';
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:rasadyar_core/presentation/common/app_color.dart';
|
||||||
|
import 'package:rasadyar_core/presentation/common/app_fonts.dart';
|
||||||
|
|
||||||
|
class UnitTextField extends StatefulWidget {
|
||||||
|
const UnitTextField({
|
||||||
|
super.key,
|
||||||
|
required this.hint,
|
||||||
|
required this.unit,
|
||||||
|
required this.onChanged,
|
||||||
|
this.initialValue,
|
||||||
|
this.controller,
|
||||||
|
this.keyboardType,
|
||||||
|
this.textInputAction,
|
||||||
|
this.enabled,
|
||||||
|
this.readOnly,
|
||||||
|
this.maxLines,
|
||||||
|
this.minLines,
|
||||||
|
this.textStyle,
|
||||||
|
this.textColor,
|
||||||
|
this.inputFormatters,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String hint;
|
||||||
|
final String unit;
|
||||||
|
final TextStyle? textStyle;
|
||||||
|
final Color? textColor;
|
||||||
|
final ValueChanged<String>? onChanged;
|
||||||
|
final String? initialValue;
|
||||||
|
final TextEditingController? controller;
|
||||||
|
final TextInputType? keyboardType;
|
||||||
|
final TextInputAction? textInputAction;
|
||||||
|
final List<TextInputFormatter>? inputFormatters;
|
||||||
|
final bool? enabled;
|
||||||
|
final bool? readOnly;
|
||||||
|
final int? maxLines;
|
||||||
|
final int? minLines;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<UnitTextField> createState() => _UnitTextFieldState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UnitTextFieldState extends State<UnitTextField> {
|
||||||
|
TextEditingController? tmpController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (widget.controller == null) {
|
||||||
|
tmpController = TextEditingController(text: widget.initialValue);
|
||||||
|
if (widget.initialValue != null) {
|
||||||
|
tmpController?.text = widget.initialValue!;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tmpController = widget.controller;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
height: 40,
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColor.bgLight,
|
||||||
|
border: Border.all(color: AppColor.darkGreyLight),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
widget.hint,
|
||||||
|
style:
|
||||||
|
widget.textStyle?.copyWith(color: widget.textColor) ??
|
||||||
|
AppFonts.yekan14.copyWith(color: widget.textColor ?? AppColor.textColorLight),
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
controller: tmpController,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
textInputAction: widget.textInputAction,
|
||||||
|
onChanged: widget.onChanged,
|
||||||
|
enabled: widget.enabled,
|
||||||
|
readOnly: widget.readOnly ?? false,
|
||||||
|
maxLines: 1,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
inputFormatters: widget.inputFormatters,
|
||||||
|
style: AppFonts.yekan18.copyWith(color: AppColor.darkGreyNormalActive),
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
isDense: true,
|
||||||
|
border: InputBorder.none,
|
||||||
|
contentPadding: EdgeInsets.symmetric(vertical: 8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
|
||||||
|
Text(
|
||||||
|
widget.unit,
|
||||||
|
style:
|
||||||
|
widget.textStyle?.copyWith(color: widget.textColor) ??
|
||||||
|
AppFonts.yekan14.copyWith(color: widget.textColor ?? AppColor.textColorLight),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user