From 52046909d5598bebef85b9c1ea591d58b4a92d27 Mon Sep 17 00:00:00 2001 From: Rafeek Alkhoudare Date: Wed, 28 May 2025 00:41:01 -0500 Subject: [PATCH] seperate textfield of the space name --- .../space_name_textfield_widget.dart | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 lib/pages/spaces_management/all_spaces/widgets/create_space_widgets/space_name_textfield_widget.dart diff --git a/lib/pages/spaces_management/all_spaces/widgets/create_space_widgets/space_name_textfield_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/create_space_widgets/space_name_textfield_widget.dart new file mode 100644 index 00000000..d9abbf7f --- /dev/null +++ b/lib/pages/spaces_management/all_spaces/widgets/create_space_widgets/space_name_textfield_widget.dart @@ -0,0 +1,81 @@ +import 'package:flutter/material.dart'; + +import '../../../../../utils/color_manager.dart'; + +class SpaceNameTextfieldWidget extends StatelessWidget { + SpaceNameTextfieldWidget({ + super.key, + required this.isNameFieldExist, + required this.isNameFieldInvalid, + required this.onChange, + required this.screenWidth, + }); + TextEditingController nameController = TextEditingController(); + final void Function(String value) onChange; + final double screenWidth; + bool isNameFieldExist; + bool isNameFieldInvalid; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + SizedBox( + width: screenWidth * 0.25, + child: TextField( + controller: nameController, + onChanged: onChange, + style: Theme.of(context).textTheme.bodyMedium, + decoration: InputDecoration( + hintText: 'Please enter the name', + hintStyle: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith(color: ColorsManager.lightGrayColor), + filled: true, + fillColor: ColorsManager.boxColor, + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide( + color: isNameFieldInvalid || isNameFieldExist + ? ColorsManager.red + : ColorsManager.boxColor, + width: 1.5, + ), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: const BorderSide( + color: ColorsManager.boxColor, + width: 1.5, + ), + ), + ), + ), + ), + if (isNameFieldInvalid) + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text( + '*Space name should not be empty.', + style: Theme.of(context) + .textTheme + .bodySmall + ?.copyWith(color: ColorsManager.red), + ), + ), + if (isNameFieldExist) + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text( + '*Name already exist', + style: Theme.of(context) + .textTheme + .bodySmall + ?.copyWith(color: ColorsManager.red), + ), + ), + ], + ); + } +}