mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
fix changes
This commit is contained in:
@ -34,6 +34,8 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
final TextEditingController forgetPasswordController = TextEditingController();
|
final TextEditingController forgetPasswordController = TextEditingController();
|
||||||
final TextEditingController forgetOtp = TextEditingController();
|
final TextEditingController forgetOtp = TextEditingController();
|
||||||
final forgetFormKey = GlobalKey<FormState>();
|
final forgetFormKey = GlobalKey<FormState>();
|
||||||
|
final forgetEmailKey = GlobalKey<FormState>();
|
||||||
|
final forgetRegionKey = GlobalKey<FormState>();
|
||||||
late bool checkValidate = false;
|
late bool checkValidate = false;
|
||||||
|
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
@ -93,13 +95,14 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> changePassword(ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
Future<void> changePassword(ChangePasswordEvent event, Emitter<AuthState> emit) async {
|
||||||
try {
|
|
||||||
emit(LoadingForgetState());
|
emit(LoadingForgetState());
|
||||||
|
try {
|
||||||
var response = await AuthenticationAPI.verifyOtp(
|
var response = await AuthenticationAPI.verifyOtp(
|
||||||
email: forgetEmailController.text, otpCode: forgetOtp.text);
|
email: forgetEmailController.text, otpCode: forgetOtp.text);
|
||||||
if (response == true) {
|
if (response == true) {
|
||||||
await AuthenticationAPI.forgetPassword(
|
await AuthenticationAPI.forgetPassword(
|
||||||
password: forgetPasswordController.text, email: forgetEmailController.text);
|
password: forgetPasswordController.text,
|
||||||
|
email: forgetEmailController.text);
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||||
emit(SuccessForgetState());
|
emit(SuccessForgetState());
|
||||||
@ -121,6 +124,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
emit(AuthInitialState());
|
emit(AuthInitialState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String? validateCode(String? value) {
|
String? validateCode(String? value) {
|
||||||
@ -231,9 +235,10 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
return 'Email is required';
|
return 'Email is required';
|
||||||
} else if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value)) {
|
} else if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value)) {
|
||||||
return 'Enter a valid email address';
|
return 'Enter a valid email address';
|
||||||
} else if (regionUuid == '') {
|
|
||||||
return 'Please select your region';
|
|
||||||
}
|
}
|
||||||
|
// else if (regionUuid == '') {
|
||||||
|
// return 'Please select your region';
|
||||||
|
// }
|
||||||
validate = '';
|
validate = '';
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -371,6 +376,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|||||||
try {
|
try {
|
||||||
emit(AuthLoading());
|
emit(AuthLoading());
|
||||||
regionUuid = event.val;
|
regionUuid = event.val;
|
||||||
|
add(CheckEnableEvent());
|
||||||
emit(AuthInitialState());
|
emit(AuthInitialState());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailureForgetState(error: e.toString()));
|
emit(FailureForgetState(error: e.toString()));
|
||||||
|
@ -140,15 +140,18 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: _buildDropdownField(context, forgetBloc, size)
|
child: _buildDropdownField(
|
||||||
)
|
context, forgetBloc, size))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
Column(
|
Form(
|
||||||
|
key: forgetBloc.forgetEmailKey,
|
||||||
|
child: Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
CrossAxisAlignment.start,
|
CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Account",
|
"Account",
|
||||||
@ -157,16 +160,19 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
.bodySmall!
|
.bodySmall!
|
||||||
.copyWith(
|
.copyWith(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w400),
|
fontWeight:
|
||||||
|
FontWeight.w400),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: forgetBloc.forgetEmailController,
|
controller: forgetBloc.forgetEmailController,
|
||||||
validator: forgetBloc.validateEmail,
|
validator: forgetBloc.validateEmail,
|
||||||
decoration: textBoxDecoration()!.copyWith(
|
decoration:
|
||||||
|
textBoxDecoration()!.copyWith(
|
||||||
hintText: 'Enter your email',
|
hintText: 'Enter your email',
|
||||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
hintStyle: Theme.of(context)
|
||||||
|
.textTheme.bodySmall!.copyWith(
|
||||||
color: ColorsManager.grayColor,
|
color: ColorsManager.grayColor,
|
||||||
fontWeight: FontWeight.w400),
|
fontWeight: FontWeight.w400),
|
||||||
),
|
),
|
||||||
@ -174,19 +180,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
color: Colors.black),
|
color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if(forgetBloc.forgetEmailValidate!='')
|
|
||||||
SizedBox(
|
|
||||||
child: Text(
|
|
||||||
forgetBloc.forgetEmailValidate,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
color: ColorsManager.red),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
)),
|
||||||
const SizedBox(height: 20.0),
|
const SizedBox(height: 20.0),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
@ -212,27 +207,43 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
decoration:
|
decoration:
|
||||||
textBoxDecoration()!.copyWith(
|
textBoxDecoration()!.copyWith(
|
||||||
hintText: 'Enter Code',
|
hintText: 'Enter Code',
|
||||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
hintStyle: Theme.of(context)
|
||||||
color: ColorsManager.grayColor,
|
.textTheme
|
||||||
fontWeight: FontWeight.w400),
|
.bodySmall!
|
||||||
|
.copyWith(
|
||||||
|
color:
|
||||||
|
ColorsManager.grayColor,
|
||||||
|
fontWeight:
|
||||||
|
FontWeight.w400),
|
||||||
suffixIcon: SizedBox(
|
suffixIcon: SizedBox(
|
||||||
width: 100,
|
width: 100,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: state is TimerState &&
|
onTap: state is TimerState &&
|
||||||
!state.isButtonEnabled &&
|
!state
|
||||||
state.remainingTime != 1
|
.isButtonEnabled &&
|
||||||
? null : () {
|
state.remainingTime !=
|
||||||
forgetBloc.add(StartTimerEvent());
|
1
|
||||||
|
? null
|
||||||
|
: () {
|
||||||
|
if (forgetBloc
|
||||||
|
.forgetEmailKey
|
||||||
|
.currentState!
|
||||||
|
.validate()) {
|
||||||
|
forgetBloc.add(
|
||||||
|
StartTimerEvent());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'Get Code ${state is TimerState && !state.isButtonEnabled && state.remainingTime != 1 ? "(${forgetBloc.formattedTime(state.remainingTime)}) " : ""}',
|
'Get Code ${state is TimerState && !state.isButtonEnabled && state.remainingTime != 1 ? "(${forgetBloc.formattedTime(state.remainingTime)}) " : ""}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: state is TimerState &&
|
color: state
|
||||||
!state.isButtonEnabled
|
is TimerState &&
|
||||||
|
!state
|
||||||
|
.isButtonEnabled
|
||||||
? Colors.grey
|
? Colors.grey
|
||||||
: ColorsManager.btnColor,
|
: ColorsManager
|
||||||
|
.btnColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -243,7 +254,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
color: Colors.black),
|
color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (forgetBloc.forgetValidate != '') // Check if there is a validation message
|
if (forgetBloc.forgetValidate !=
|
||||||
|
'') // Check if there is a validation message
|
||||||
Padding(
|
Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.only(top: 8.0),
|
const EdgeInsets.only(top: 8.0),
|
||||||
@ -275,16 +287,45 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
validator: forgetBloc.passwordValidator,
|
obscureText: forgetBloc.obscureText,
|
||||||
keyboardType: TextInputType.visiblePassword,
|
keyboardType:
|
||||||
controller: forgetBloc.forgetPasswordController,
|
TextInputType.visiblePassword,
|
||||||
decoration: textBoxDecoration()!.copyWith(
|
validator:
|
||||||
hintText: 'At least 8 characters',
|
forgetBloc.passwordValidator,
|
||||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
controller: forgetBloc
|
||||||
color: ColorsManager.grayColor,
|
.forgetPasswordController,
|
||||||
fontWeight: FontWeight.w400),
|
decoration:
|
||||||
|
textBoxDecoration()!.copyWith(
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
forgetBloc.add(
|
||||||
|
PasswordVisibleEvent(
|
||||||
|
newValue: forgetBloc
|
||||||
|
.obscureText));
|
||||||
|
},
|
||||||
|
icon: SizedBox(
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
forgetBloc.obscureText
|
||||||
|
? Assets.visiblePassword
|
||||||
|
: Assets
|
||||||
|
.invisiblePassword,
|
||||||
|
height: 15,
|
||||||
|
width: 15,
|
||||||
),
|
),
|
||||||
style: const TextStyle(color: Colors.black),
|
),
|
||||||
|
),
|
||||||
|
hintText: 'At least 8 characters',
|
||||||
|
hintStyle: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodySmall!
|
||||||
|
.copyWith(
|
||||||
|
color:
|
||||||
|
ColorsManager.grayColor,
|
||||||
|
fontWeight:
|
||||||
|
FontWeight.w400),
|
||||||
|
),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -305,9 +346,13 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
ColorsManager.btnColor,
|
ColorsManager.btnColor,
|
||||||
child: const Text('Submit'),
|
child: const Text('Submit'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (forgetBloc.forgetFormKey.currentState!.validate()) {
|
if (forgetBloc.forgetFormKey.currentState!.validate() ||
|
||||||
|
forgetBloc.forgetEmailKey.currentState!.validate() ) {
|
||||||
|
if( forgetBloc.forgetEmailKey.currentState!.validate()
|
||||||
|
&&forgetBloc.forgetFormKey.currentState!.validate() ){
|
||||||
forgetBloc.add(ChangePasswordEvent());
|
forgetBloc.add(ChangePasswordEvent());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -333,7 +378,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
"Do you have an account? ",
|
"Do you have an account? ",
|
||||||
style: TextStyle(color: Colors.white),
|
style:
|
||||||
|
TextStyle(color: Colors.white),
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@ -367,7 +413,6 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Widget _buildDropdownField(
|
Widget _buildDropdownField(
|
||||||
BuildContext context, AuthBloc loginBloc, Size size) {
|
BuildContext context, AuthBloc loginBloc, Size size) {
|
||||||
final TextEditingController textEditingController = TextEditingController();
|
final TextEditingController textEditingController = TextEditingController();
|
||||||
@ -384,15 +429,57 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Container(
|
Container(
|
||||||
height: 50,
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: ColorsManager.boxColor,
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
|
||||||
),
|
|
||||||
width: size.width * 0.9,
|
width: size.width * 0.9,
|
||||||
|
child: FormField<String>(
|
||||||
|
validator: (value) {
|
||||||
|
if (value == null || value.isEmpty) {
|
||||||
|
return 'Please select a country/region';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
builder: (FormFieldState<String> field) {
|
||||||
|
return InputDecorator(
|
||||||
|
decoration: InputDecoration(
|
||||||
|
contentPadding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||||
|
errorText: field.errorText,
|
||||||
|
filled:
|
||||||
|
true, // Ensure the dropdown is filled with the background color
|
||||||
|
fillColor: ColorsManager
|
||||||
|
.boxColor, // Match the dropdown container color
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: field.hasError ? Colors.red : Colors.transparent,
|
||||||
|
width: 1.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color:
|
||||||
|
field.hasError ? Colors.red : ColorsManager.grayColor,
|
||||||
|
width: 1.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color:
|
||||||
|
field.hasError ? Colors.red : ColorsManager.grayColor,
|
||||||
|
width: 1.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
errorBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: Colors.red,
|
||||||
|
width: 1.5,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
child: DropdownButtonHideUnderline(
|
child: DropdownButtonHideUnderline(
|
||||||
child: DropdownButton2<String>(
|
child: DropdownButton2<String>(
|
||||||
style: TextStyle(color: Colors.black),
|
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
hint: Text(
|
hint: Text(
|
||||||
'Select your region/country',
|
'Select your region/country',
|
||||||
@ -404,7 +491,7 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
items: loginBloc.regionList!.map((RegionModel region) {
|
items: loginBloc.regionList!.map((RegionModel region) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: region.id, // Use region.id as the value
|
value: region.id,
|
||||||
child: Text(
|
child: Text(
|
||||||
region.name,
|
region.name,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
@ -412,16 +499,15 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
value: loginBloc.regionList!.any(
|
value: loginBloc.regionList!
|
||||||
(region) => region.id == loginBloc.regionUuid,)
|
.any((region) => region.id == loginBloc.regionUuid)
|
||||||
? loginBloc.regionUuid
|
? loginBloc.regionUuid
|
||||||
: null,
|
: null,
|
||||||
onChanged: (String? value) {
|
onChanged: (String? value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
loginBloc.add(SelectRegionEvent(val: value));
|
||||||
loginBloc.add(SelectRegionEvent(
|
field.didChange(
|
||||||
val: value,
|
value); // Notify the form field of the change
|
||||||
));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
buttonStyleData: const ButtonStyleData(
|
buttonStyleData: const ButtonStyleData(
|
||||||
@ -431,6 +517,11 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
dropdownStyleData: DropdownStyleData(
|
dropdownStyleData: DropdownStyleData(
|
||||||
maxHeight: size.height * 0.70,
|
maxHeight: size.height * 0.70,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ColorsManager
|
||||||
|
.boxColor, // Match dropdown background color to the container
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
menuItemStyleData: const MenuItemStyleData(
|
menuItemStyleData: const MenuItemStyleData(
|
||||||
height: 40,
|
height: 40,
|
||||||
@ -440,7 +531,8 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
searchInnerWidgetHeight: 50,
|
searchInnerWidgetHeight: 50,
|
||||||
searchInnerWidget: Container(
|
searchInnerWidget: Container(
|
||||||
height: 50,
|
height: 50,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 8, vertical: 4),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
controller: textEditingController,
|
controller: textEditingController,
|
||||||
@ -454,11 +546,9 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
searchMatchFn: (item, searchValue) {
|
searchMatchFn: (item, searchValue) {
|
||||||
// Use the item's child text (region name) for searching.
|
final regionName =
|
||||||
final regionName = (item.child as Text).data?.toLowerCase() ?? '';
|
(item.child as Text).data?.toLowerCase() ?? '';
|
||||||
final search = searchValue.toLowerCase().trim();
|
final search = searchValue.toLowerCase().trim();
|
||||||
// Debugging print statement to ensure values are captured correctly.
|
|
||||||
// Return true if the region name contains the search term.
|
|
||||||
return regionName.contains(search);
|
return regionName.contains(search);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -469,9 +559,260 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Widget _buildDropdownField(BuildContext context, AuthBloc loginBloc, Size size) {
|
||||||
|
// final TextEditingController textEditingController = TextEditingController();
|
||||||
|
//
|
||||||
|
// return Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// Text(
|
||||||
|
// "Country/Region",
|
||||||
|
// style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
// fontSize: 14,
|
||||||
|
// fontWeight: FontWeight.w400,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 10),
|
||||||
|
// Container(
|
||||||
|
// decoration: const BoxDecoration(
|
||||||
|
// color: ColorsManager.boxColor,
|
||||||
|
// borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||||
|
// ),
|
||||||
|
// width: size.width * 0.9,
|
||||||
|
// child: FormField<String>(
|
||||||
|
// validator: (value) {
|
||||||
|
// if (value == null || value.isEmpty) {
|
||||||
|
// return 'Please select a country/region';
|
||||||
|
// }
|
||||||
|
// return null;
|
||||||
|
// },
|
||||||
|
// builder: (FormFieldState<String> field) {
|
||||||
|
// return InputDecorator(
|
||||||
|
// decoration: InputDecoration(
|
||||||
|
// contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||||
|
// errorText: field.errorText,
|
||||||
|
// border: OutlineInputBorder(
|
||||||
|
// borderRadius: BorderRadius.circular(8.0),
|
||||||
|
// borderSide: BorderSide(
|
||||||
|
// color: field.hasError ? Colors.red : Colors.transparent,
|
||||||
|
// width: 1.5,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// enabledBorder: OutlineInputBorder(
|
||||||
|
// borderRadius: BorderRadius.circular(8.0),
|
||||||
|
// borderSide: BorderSide(
|
||||||
|
// color: field.hasError ? Colors.red : ColorsManager.grayColor,
|
||||||
|
// width: 1.5,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// focusedBorder: OutlineInputBorder(
|
||||||
|
// borderRadius: BorderRadius.circular(8.0),
|
||||||
|
// borderSide: BorderSide(
|
||||||
|
// color: field.hasError ? Colors.red : ColorsManager.grayColor,
|
||||||
|
// width: 1.5,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// errorBorder: OutlineInputBorder(
|
||||||
|
// borderRadius: BorderRadius.circular(8.0),
|
||||||
|
// borderSide: BorderSide(
|
||||||
|
// color: Colors.red,
|
||||||
|
// width: 1.5,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// child: DropdownButtonHideUnderline(
|
||||||
|
// child: DropdownButton2<String>(
|
||||||
|
// isExpanded: true,
|
||||||
|
// hint: Text(
|
||||||
|
// 'Select your region/country',
|
||||||
|
// style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
// color: ColorsManager.grayColor,
|
||||||
|
// fontWeight: FontWeight.w400,
|
||||||
|
// ),
|
||||||
|
// overflow: TextOverflow.ellipsis,
|
||||||
|
// ),
|
||||||
|
// items: loginBloc.regionList!.map((RegionModel region) {
|
||||||
|
// return DropdownMenuItem<String>(
|
||||||
|
// value: region.id,
|
||||||
|
// child: Text(
|
||||||
|
// region.name,
|
||||||
|
// overflow: TextOverflow.ellipsis,
|
||||||
|
// maxLines: 1,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// }).toList(),
|
||||||
|
// value: loginBloc.regionList!.any((region) => region.id == loginBloc.regionUuid)
|
||||||
|
// ? loginBloc.regionUuid
|
||||||
|
// : null,
|
||||||
|
// onChanged: (String? value) {
|
||||||
|
// if (value != null) {
|
||||||
|
// loginBloc.add(SelectRegionEvent(val: value));
|
||||||
|
// field.didChange(value); // Notify the form field of the change
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// buttonStyleData: const ButtonStyleData(
|
||||||
|
// padding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
// height: 40,
|
||||||
|
// width: double.infinity,
|
||||||
|
// ),
|
||||||
|
// dropdownStyleData: DropdownStyleData(
|
||||||
|
// maxHeight: size.height * 0.70,
|
||||||
|
// ),
|
||||||
|
// menuItemStyleData: const MenuItemStyleData(
|
||||||
|
// height: 40,
|
||||||
|
// ),
|
||||||
|
// dropdownSearchData: DropdownSearchData(
|
||||||
|
// searchController: textEditingController,
|
||||||
|
// searchInnerWidgetHeight: 50,
|
||||||
|
// searchInnerWidget: Container(
|
||||||
|
// height: 50,
|
||||||
|
// padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
// child: TextFormField(
|
||||||
|
// style: const TextStyle(color: Colors.black),
|
||||||
|
// controller: textEditingController,
|
||||||
|
// decoration: textBoxDecoration()!.copyWith(
|
||||||
|
// errorStyle: const TextStyle(height: 0),
|
||||||
|
// contentPadding: const EdgeInsets.symmetric(
|
||||||
|
// vertical: 12,
|
||||||
|
// horizontal: 10,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// searchMatchFn: (item, searchValue) {
|
||||||
|
// final regionName = (item.child as Text).data?.toLowerCase() ?? '';
|
||||||
|
// final search = searchValue.toLowerCase().trim();
|
||||||
|
// return regionName.contains(search);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// onMenuStateChange: (isOpen) {
|
||||||
|
// if (!isOpen) {
|
||||||
|
// textEditingController.clear();
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Widget _buildDropdownField(
|
||||||
|
// BuildContext context, AuthBloc loginBloc, Size size) {
|
||||||
|
// final TextEditingController textEditingController = TextEditingController();
|
||||||
|
// return Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
// children: [
|
||||||
|
// Text(
|
||||||
|
// "Country/Region",
|
||||||
|
// style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
// fontSize: 14,
|
||||||
|
// fontWeight: FontWeight.w400,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 10),
|
||||||
|
// Container(
|
||||||
|
// height: 50,
|
||||||
|
// decoration: const BoxDecoration(
|
||||||
|
// color: ColorsManager.boxColor,
|
||||||
|
// borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||||
|
// ),
|
||||||
|
// width: size.width * 0.9,
|
||||||
|
// child: DropdownButtonHideUnderline(
|
||||||
|
// child: DropdownButton2<String>(
|
||||||
|
// style: TextStyle(color: Colors.black),
|
||||||
|
// isExpanded: true,
|
||||||
|
// hint: Text(
|
||||||
|
// 'Select your region/country',
|
||||||
|
// style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
|
// color: ColorsManager.grayColor,
|
||||||
|
// fontWeight: FontWeight.w400,
|
||||||
|
// ),
|
||||||
|
// overflow: TextOverflow.ellipsis,
|
||||||
|
// ),
|
||||||
|
// items: loginBloc.regionList!.map((RegionModel region) {
|
||||||
|
// return DropdownMenuItem<String>(
|
||||||
|
// value: region.id, // Use region.id as the value
|
||||||
|
// child: Text(
|
||||||
|
// region.name,
|
||||||
|
// overflow: TextOverflow.ellipsis,
|
||||||
|
// maxLines: 1,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// }).toList(),
|
||||||
|
// value: loginBloc.regionList!.any(
|
||||||
|
// (region) => region.id == loginBloc.regionUuid,)
|
||||||
|
// ? loginBloc.regionUuid
|
||||||
|
// : null,
|
||||||
|
// onChanged: (String? value) {
|
||||||
|
// if (value != null) {
|
||||||
|
//
|
||||||
|
// loginBloc.add(SelectRegionEvent(
|
||||||
|
// val: value,
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// buttonStyleData: const ButtonStyleData(
|
||||||
|
// padding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
// height: 40,
|
||||||
|
// width: double.infinity,
|
||||||
|
// ),
|
||||||
|
// dropdownStyleData: DropdownStyleData(
|
||||||
|
// maxHeight: size.height * 0.70,
|
||||||
|
// ),
|
||||||
|
// menuItemStyleData: const MenuItemStyleData(
|
||||||
|
// height: 40,
|
||||||
|
// ),
|
||||||
|
// dropdownSearchData: DropdownSearchData(
|
||||||
|
// searchController: textEditingController,
|
||||||
|
// searchInnerWidgetHeight: 50,
|
||||||
|
// searchInnerWidget: Container(
|
||||||
|
// height: 50,
|
||||||
|
// padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
|
// child: TextFormField(
|
||||||
|
// style: const TextStyle(color: Colors.black),
|
||||||
|
// controller: textEditingController,
|
||||||
|
// decoration: textBoxDecoration()!.copyWith(
|
||||||
|
// errorStyle: const TextStyle(height: 0),
|
||||||
|
// contentPadding: const EdgeInsets.symmetric(
|
||||||
|
// vertical: 12,
|
||||||
|
// horizontal: 10,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// searchMatchFn: (item, searchValue) {
|
||||||
|
// // Use the item's child text (region name) for searching.
|
||||||
|
// final regionName = (item.child as Text).data?.toLowerCase() ?? '';
|
||||||
|
// final search = searchValue.toLowerCase().trim();
|
||||||
|
// // Debugging print statement to ensure values are captured correctly.
|
||||||
|
// // Return true if the region name contains the search term.
|
||||||
|
// return regionName.contains(search);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// onMenuStateChange: (isOpen) {
|
||||||
|
// if (!isOpen) {
|
||||||
|
// textEditingController.clear();
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ class HourPickerDialog extends StatefulWidget {
|
|||||||
|
|
||||||
class _HourPickerDialogState extends State<HourPickerDialog> {
|
class _HourPickerDialogState extends State<HourPickerDialog> {
|
||||||
late int _selectedHour;
|
late int _selectedHour;
|
||||||
bool _isPm = false;
|
bool _isPm = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -18,7 +18,7 @@ class _HourPickerDialogState extends State<HourPickerDialog> {
|
|||||||
_selectedHour = widget.initialTime.hour > 12
|
_selectedHour = widget.initialTime.hour > 12
|
||||||
? widget.initialTime.hour - 12
|
? widget.initialTime.hour - 12
|
||||||
: widget.initialTime.hour;
|
: widget.initialTime.hour;
|
||||||
_isPm = widget.initialTime.period == DayPeriod.pm;
|
_isPm = widget.initialTime.period == DayPeriod.am;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -69,7 +69,7 @@ class AcDeviceControl extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
deviceId: device.uuid!,
|
deviceId: device.uuid!,
|
||||||
description: 'Child Lock',
|
description: 'Child Lock',
|
||||||
icon:
|
icon:
|
||||||
state.status.childLock ? Assets.unlock : Assets.childLock,
|
state.status.childLock ? Assets.childLock:Assets.unlock ,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user