You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
178 lines
7.1 KiB
Dart
178 lines
7.1 KiB
Dart
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/text_fields/text_field_error.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../app_texts_widget.dart';
|
|
|
|
class AppTextFieldCustom2 extends StatefulWidget {
|
|
final double height;
|
|
final Function onClick;
|
|
final String hintText;
|
|
final TextEditingController controller;
|
|
final bool isTextFieldHasSuffix;
|
|
final bool hasBorder;
|
|
final String dropDownText;
|
|
final IconButton suffixIcon;
|
|
final Color dropDownColor;
|
|
final bool enabled;
|
|
final TextInputType inputType;
|
|
final int minLines;
|
|
final int maxLines;
|
|
final List<TextInputFormatter> inputFormatters;
|
|
final Function(String) onChanged;
|
|
final String validationError;
|
|
final bool isPrscription;
|
|
final bool isSecure;
|
|
|
|
AppTextFieldCustom2({
|
|
this.height = 0,
|
|
this.onClick,
|
|
this.hintText,
|
|
this.controller,
|
|
this.hasBorder = true,
|
|
this.isTextFieldHasSuffix = false,
|
|
this.dropDownText,
|
|
this.suffixIcon,
|
|
this.dropDownColor,
|
|
this.enabled = true,
|
|
this.inputType,
|
|
this.minLines = 1,
|
|
this.maxLines = 1,
|
|
this.inputFormatters,
|
|
this.onChanged,
|
|
this.validationError,
|
|
this.isPrscription = false,
|
|
this.isSecure = false,
|
|
});
|
|
|
|
@override
|
|
_AppTextFieldCustomState createState() => _AppTextFieldCustomState();
|
|
}
|
|
|
|
class _AppTextFieldCustomState extends State<AppTextFieldCustom2> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
ProjectViewModel projectViewModel = Provider.of(context);
|
|
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
height: widget.height != 0 && widget.maxLines == 1
|
|
? widget.height + 8
|
|
: null,
|
|
decoration: widget.hasBorder
|
|
? TextFieldsUtils.containerBorderDecoration(
|
|
Color(0Xffffffff),
|
|
widget.validationError == null
|
|
? Color(0xFFEFEFEF)
|
|
: Colors.red.shade700)
|
|
: null,
|
|
padding:
|
|
EdgeInsets.only(top: 4.0, bottom: 4.0, left: 8.0, right: 8.0),
|
|
child: InkWell(
|
|
onTap: widget.onClick ?? null,
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
padding: widget.dropDownText == null
|
|
? EdgeInsets.symmetric(vertical: 0)
|
|
: EdgeInsets.symmetric(vertical: 0), // 8.0
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
if ((widget.controller != null &&
|
|
widget.controller.text != "") ||
|
|
widget.dropDownText != null)
|
|
AppText(
|
|
widget.hintText,
|
|
color: Color(0xFF2E303A),
|
|
fontSize: widget.isPrscription == false
|
|
? SizeConfig.textMultiplier * 1.3
|
|
: 0,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
widget.dropDownText == null
|
|
? Container(
|
|
height:
|
|
widget.height != 0 && widget.maxLines == 1
|
|
? widget.height - 22
|
|
: null,
|
|
child: TextFormField(
|
|
textAlign: projectViewModel.isArabic
|
|
? TextAlign.right
|
|
: TextAlign.left,
|
|
decoration: TextFieldsUtils
|
|
.textFieldSelectorDecoration(
|
|
widget.hintText, null, true),
|
|
style: TextStyle(
|
|
fontSize: SizeConfig.textMultiplier * 1.7,
|
|
fontFamily: 'Poppins',
|
|
color: Color(0xFF575757),
|
|
),
|
|
controller: widget.controller,
|
|
keyboardType: widget.inputType ??
|
|
(widget.maxLines == 1
|
|
? TextInputType.text
|
|
: TextInputType.multiline),
|
|
enabled: widget.enabled,
|
|
minLines: widget.minLines,
|
|
maxLines: widget.maxLines,
|
|
inputFormatters:
|
|
widget.inputFormatters != null
|
|
? widget.inputFormatters
|
|
: [],
|
|
onChanged: (value) {
|
|
setState(() {});
|
|
if (widget.onChanged != null) {
|
|
widget.onChanged(value);
|
|
}
|
|
},
|
|
obscureText: widget.isSecure,
|
|
validator: (value) {
|
|
if (value == null || value.isEmpty) {
|
|
return 'Please enter some text';
|
|
}
|
|
return null;
|
|
},
|
|
),
|
|
)
|
|
: AppText(
|
|
widget.dropDownText,
|
|
fontFamily: 'Poppins',
|
|
color: Color(0xFF575757),
|
|
fontSize: SizeConfig.textMultiplier * 1.7,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
widget.isTextFieldHasSuffix
|
|
? widget.suffixIcon != null
|
|
? widget.suffixIcon
|
|
: InkWell(
|
|
child: Icon(
|
|
Icons.keyboard_arrow_down,
|
|
color: widget.dropDownColor != null
|
|
? widget.dropDownColor
|
|
: Colors.black,
|
|
),
|
|
)
|
|
: Container(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (widget.validationError != null)
|
|
TextFieldsError(error: widget.validationError),
|
|
],
|
|
);
|
|
}
|
|
}
|