mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-27 09:54:55 +00:00
Compare commits
3 Commits
otp_change
...
web_change
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b2e0b1ce5 | |||
| 2162c996ea | |||
| 177baca864 |
@ -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,34 +95,36 @@ 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,
|
||||||
_timer?.cancel();
|
email: forgetEmailController.text);
|
||||||
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
_timer?.cancel();
|
||||||
emit(SuccessForgetState());
|
emit(const TimerState(isButtonEnabled: true, remainingTime: 0));
|
||||||
|
emit(SuccessForgetState());
|
||||||
|
}
|
||||||
|
} on DioException catch (e) {
|
||||||
|
final errorData = e.response!.data;
|
||||||
|
String errorMessage = errorData['message'];
|
||||||
|
if (errorMessage == 'this email is not registered') {
|
||||||
|
validate = 'Invalid Credentials!';
|
||||||
|
emit(AuthInitialState());
|
||||||
|
} else if (errorMessage == "You entered wrong otp") {
|
||||||
|
forgetValidate = 'Wrong one time password.';
|
||||||
|
emit(AuthInitialState());
|
||||||
|
} else if (errorMessage == "OTP expired") {
|
||||||
|
forgetValidate = 'One time password has been expired.';
|
||||||
|
emit(AuthInitialState());
|
||||||
|
} else {
|
||||||
|
validate = '';
|
||||||
|
emit(AuthInitialState());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
|
||||||
final errorData = e.response!.data;
|
|
||||||
String errorMessage = errorData['message'];
|
|
||||||
if (errorMessage == 'this email is not registered') {
|
|
||||||
validate = 'Invalid Credentials!';
|
|
||||||
emit(AuthInitialState());
|
|
||||||
} else if (errorMessage == "You entered wrong otp") {
|
|
||||||
forgetValidate = 'Wrong one time password.';
|
|
||||||
emit(AuthInitialState());
|
|
||||||
} else if (errorMessage == "OTP expired") {
|
|
||||||
forgetValidate = 'One time password has been expired.';
|
|
||||||
emit(AuthInitialState());
|
|
||||||
} else {
|
|
||||||
validate = '';
|
|
||||||
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()));
|
||||||
|
|||||||
@ -64,91 +64,94 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
return FirstLayer(
|
return FirstLayer(
|
||||||
second: Center(
|
second: Center(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
if (state is AuthLoading)
|
||||||
|
const Center(child: CircularProgressIndicator()),
|
||||||
|
ListView(
|
||||||
|
shrinkWrap: true,
|
||||||
|
controller: _scrollController,
|
||||||
children: [
|
children: [
|
||||||
if (state is AuthLoading)
|
Container(
|
||||||
const Center(child: CircularProgressIndicator()),
|
padding: EdgeInsets.all(size.width * 0.02),
|
||||||
ListView(
|
margin: EdgeInsets.all(size.width * 0.09),
|
||||||
shrinkWrap: true,
|
decoration: BoxDecoration(
|
||||||
controller: _scrollController,
|
color: Colors.black.withOpacity(0.3),
|
||||||
children: [
|
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||||
Container(
|
),
|
||||||
padding: EdgeInsets.all(size.width * 0.02),
|
child: Center(
|
||||||
margin: EdgeInsets.all(size.width * 0.09),
|
child: Row(
|
||||||
decoration: BoxDecoration(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
color: Colors.black.withOpacity(0.3),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
children: [
|
||||||
),
|
const Spacer(),
|
||||||
child: Center(
|
Expanded(
|
||||||
child: Row(
|
flex: 3,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
child: SvgPicture.asset(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
Assets.loginLogo,
|
||||||
children: [
|
),
|
||||||
const Spacer(),
|
),
|
||||||
Expanded(
|
const Spacer(),
|
||||||
flex: 3,
|
Expanded(
|
||||||
child: SvgPicture.asset(
|
flex: 3,
|
||||||
Assets.loginLogo,
|
child: Container(
|
||||||
),
|
decoration: BoxDecoration(
|
||||||
),
|
color: Colors.white.withOpacity(0.1),
|
||||||
const Spacer(),
|
borderRadius:
|
||||||
Expanded(
|
|
||||||
flex: 3,
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.white.withOpacity(0.1),
|
|
||||||
borderRadius:
|
|
||||||
const BorderRadius.all(Radius.circular(30)),
|
const BorderRadius.all(Radius.circular(30)),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color:
|
color:
|
||||||
ColorsManager.graysColor.withOpacity(0.2)),
|
ColorsManager.graysColor.withOpacity(0.2)),
|
||||||
),
|
),
|
||||||
child: Form(
|
child: Form(
|
||||||
key: forgetBloc.forgetFormKey,
|
key: forgetBloc.forgetFormKey,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: size.width * 0.02,
|
horizontal: size.width * 0.02,
|
||||||
vertical: size.width * 0.003),
|
vertical: size.width * 0.003),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.spaceEvenly,
|
MainAxisAlignment.spaceEvenly,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
const Text(
|
const Text(
|
||||||
'Forget Password',
|
'Forget Password',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
fontWeight: FontWeight.bold),
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Text(
|
Text(
|
||||||
'Please fill in your account information to\nretrieve your password',
|
'Please fill in your account information to\nretrieve your password',
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
.copyWith(
|
.copyWith(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w400),
|
fontWeight: FontWeight.w400),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Column(
|
SizedBox(
|
||||||
|
child: _buildDropdownField(
|
||||||
|
context, forgetBloc, size))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Form(
|
||||||
|
key: forgetBloc.forgetEmailKey,
|
||||||
|
child: Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
CrossAxisAlignment.start,
|
CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment:
|
||||||
children: [
|
MainAxisAlignment.start,
|
||||||
const SizedBox(height: 10),
|
|
||||||
SizedBox(
|
|
||||||
child: _buildDropdownField(context, forgetBloc, size)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment:
|
|
||||||
CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Account",
|
"Account",
|
||||||
@ -156,17 +159,20 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
.textTheme
|
.textTheme
|
||||||
.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,200 +180,239 @@ 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:
|
||||||
CrossAxisAlignment.start,
|
CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"One Time Password",
|
"One Time Password",
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodySmall!
|
||||||
|
.copyWith(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
SizedBox(
|
||||||
|
child: TextFormField(
|
||||||
|
validator: forgetBloc.validateCode,
|
||||||
|
keyboardType:
|
||||||
|
TextInputType.visiblePassword,
|
||||||
|
controller: forgetBloc.forgetOtp,
|
||||||
|
decoration:
|
||||||
|
textBoxDecoration()!.copyWith(
|
||||||
|
hintText: 'Enter Code',
|
||||||
|
hintStyle: Theme.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
.copyWith(
|
.copyWith(
|
||||||
fontSize: 14,
|
color:
|
||||||
fontWeight: FontWeight.w400),
|
ColorsManager.grayColor,
|
||||||
),
|
fontWeight:
|
||||||
const SizedBox(height: 10),
|
FontWeight.w400),
|
||||||
SizedBox(
|
suffixIcon: SizedBox(
|
||||||
child: TextFormField(
|
width: 100,
|
||||||
validator: forgetBloc.validateCode,
|
child: Center(
|
||||||
keyboardType:
|
child: InkWell(
|
||||||
TextInputType.visiblePassword,
|
onTap: state is TimerState &&
|
||||||
controller: forgetBloc.forgetOtp,
|
!state
|
||||||
decoration:
|
.isButtonEnabled &&
|
||||||
textBoxDecoration()!.copyWith(
|
state.remainingTime !=
|
||||||
hintText: 'Enter Code',
|
1
|
||||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
? null
|
||||||
color: ColorsManager.grayColor,
|
: () {
|
||||||
fontWeight: FontWeight.w400),
|
if (forgetBloc
|
||||||
suffixIcon: SizedBox(
|
.forgetEmailKey
|
||||||
width: 100,
|
.currentState!
|
||||||
child: Center(
|
.validate()) {
|
||||||
child: InkWell(
|
forgetBloc.add(
|
||||||
onTap: state is TimerState &&
|
StartTimerEvent());
|
||||||
!state.isButtonEnabled &&
|
}
|
||||||
state.remainingTime != 1
|
},
|
||||||
? null : () {
|
child: Text(
|
||||||
forgetBloc.add(StartTimerEvent());
|
'Get Code ${state is TimerState && !state.isButtonEnabled && state.remainingTime != 1 ? "(${forgetBloc.formattedTime(state.remainingTime)}) " : ""}',
|
||||||
|
style: TextStyle(
|
||||||
},
|
color: state
|
||||||
child: Text(
|
is TimerState &&
|
||||||
'Get Code ${state is TimerState && !state.isButtonEnabled && state.remainingTime != 1 ? "(${forgetBloc.formattedTime(state.remainingTime)}) " : ""}',
|
!state
|
||||||
style: TextStyle(
|
.isButtonEnabled
|
||||||
color: state is TimerState &&
|
? Colors.grey
|
||||||
!state.isButtonEnabled
|
: ColorsManager
|
||||||
? Colors.grey
|
.btnColor,
|
||||||
: ColorsManager.btnColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.black),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (forgetBloc.forgetValidate != '') // Check if there is a validation message
|
style: const TextStyle(
|
||||||
Padding(
|
color: Colors.black),
|
||||||
padding:
|
),
|
||||||
|
),
|
||||||
|
if (forgetBloc.forgetValidate !=
|
||||||
|
'') // Check if there is a validation message
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
const EdgeInsets.only(top: 8.0),
|
const EdgeInsets.only(top: 8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
forgetBloc.forgetValidate,
|
forgetBloc.forgetValidate,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: ColorsManager.red,
|
color: ColorsManager.red,
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
fontWeight: FontWeight.w700),
|
fontWeight: FontWeight.w700),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20.0),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Password",
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.bodySmall!
|
||||||
|
.copyWith(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w400),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
SizedBox(
|
||||||
|
child: TextFormField(
|
||||||
|
obscureText: forgetBloc.obscureText,
|
||||||
|
keyboardType:
|
||||||
|
TextInputType.visiblePassword,
|
||||||
|
validator:
|
||||||
|
forgetBloc.passwordValidator,
|
||||||
|
controller: forgetBloc
|
||||||
|
.forgetPasswordController,
|
||||||
|
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,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
hintText: 'At least 8 characters',
|
||||||
),
|
hintStyle: Theme.of(context)
|
||||||
const SizedBox(height: 20.0),
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment:
|
|
||||||
CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Password",
|
|
||||||
style: Theme.of(context)
|
|
||||||
.textTheme
|
.textTheme
|
||||||
.bodySmall!
|
.bodySmall!
|
||||||
.copyWith(
|
.copyWith(
|
||||||
fontSize: 14,
|
color:
|
||||||
fontWeight: FontWeight.w400),
|
ColorsManager.grayColor,
|
||||||
),
|
fontWeight:
|
||||||
const SizedBox(height: 10),
|
FontWeight.w400),
|
||||||
SizedBox(
|
|
||||||
child: TextFormField(
|
|
||||||
validator: forgetBloc.passwordValidator,
|
|
||||||
keyboardType: TextInputType.visiblePassword,
|
|
||||||
controller: forgetBloc.forgetPasswordController,
|
|
||||||
decoration: textBoxDecoration()!.copyWith(
|
|
||||||
hintText: 'At least 8 characters',
|
|
||||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
|
||||||
color: ColorsManager.grayColor,
|
|
||||||
fontWeight: FontWeight.w400),
|
|
||||||
),
|
|
||||||
style: const TextStyle(color: Colors.black),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20.0),
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment:
|
|
||||||
CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: size.width * 0.2,
|
|
||||||
child: DefaultButton(
|
|
||||||
backgroundColor:
|
|
||||||
ColorsManager.btnColor,
|
|
||||||
child: const Text('Submit'),
|
|
||||||
onPressed: () {
|
|
||||||
if (forgetBloc.forgetFormKey.currentState!.validate()) {
|
|
||||||
forgetBloc.add(ChangePasswordEvent());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Center(
|
|
||||||
child: SizedBox(
|
|
||||||
child: Text(
|
|
||||||
forgetBloc.validate,
|
|
||||||
style: const TextStyle(
|
|
||||||
fontWeight: FontWeight.w700,
|
|
||||||
color: ColorsManager.red),
|
|
||||||
),
|
),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
child: Center(
|
|
||||||
child: Wrap(
|
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
"Do you have an account? ",
|
|
||||||
style: TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
forgetBloc.add(StopTimerEvent());
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
child: const Text(
|
|
||||||
"Sign in",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15.0),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20.0),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: size.width * 0.2,
|
||||||
|
child: DefaultButton(
|
||||||
|
backgroundColor:
|
||||||
|
ColorsManager.btnColor,
|
||||||
|
child: const Text('Submit'),
|
||||||
|
onPressed: () {
|
||||||
|
if (forgetBloc.forgetFormKey.currentState!.validate() ||
|
||||||
|
forgetBloc.forgetEmailKey.currentState!.validate() ) {
|
||||||
|
if( forgetBloc.forgetEmailKey.currentState!.validate()
|
||||||
|
&&forgetBloc.forgetFormKey.currentState!.validate() ){
|
||||||
|
forgetBloc.add(ChangePasswordEvent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Center(
|
||||||
|
child: SizedBox(
|
||||||
|
child: Text(
|
||||||
|
forgetBloc.validate,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
color: ColorsManager.red),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
child: Center(
|
||||||
|
child: Wrap(
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
"Do you have an account? ",
|
||||||
|
style:
|
||||||
|
TextStyle(color: Colors.white),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
forgetBloc.add(StopTimerEvent());
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: const Text(
|
||||||
|
"Sign in",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15.0),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
const Spacer(),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
));
|
],
|
||||||
|
),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Widget _buildDropdownField(
|
Widget _buildDropdownField(
|
||||||
BuildContext context, AuthBloc loginBloc, Size size) {
|
BuildContext context, AuthBloc loginBloc, Size size) {
|
||||||
final TextEditingController textEditingController = TextEditingController();
|
final TextEditingController textEditingController = TextEditingController();
|
||||||
@ -378,100 +423,149 @@ class ForgetPasswordWebPage extends StatelessWidget {
|
|||||||
Text(
|
Text(
|
||||||
"Country/Region",
|
"Country/Region",
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w400,
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
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: DropdownButtonHideUnderline(
|
child: FormField<String>(
|
||||||
child: DropdownButton2<String>(
|
validator: (value) {
|
||||||
style: TextStyle(color: Colors.black),
|
if (value == null || value.isEmpty) {
|
||||||
isExpanded: true,
|
return 'Please select a country/region';
|
||||||
hint: Text(
|
}
|
||||||
'Select your region/country',
|
return null;
|
||||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
},
|
||||||
color: ColorsManager.grayColor,
|
builder: (FormFieldState<String> field) {
|
||||||
fontWeight: FontWeight.w400,
|
return InputDecorator(
|
||||||
),
|
decoration: InputDecoration(
|
||||||
overflow: TextOverflow.ellipsis,
|
contentPadding:
|
||||||
),
|
const EdgeInsets.symmetric(horizontal: 2, vertical: 10),
|
||||||
items: loginBloc.regionList!.map((RegionModel region) {
|
errorText: field.errorText,
|
||||||
return DropdownMenuItem<String>(
|
filled:
|
||||||
value: region.id, // Use region.id as the value
|
true, // Ensure the dropdown is filled with the background color
|
||||||
child: Text(
|
fillColor: ColorsManager
|
||||||
region.name,
|
.boxColor, // Match the dropdown container color
|
||||||
overflow: TextOverflow.ellipsis,
|
border: OutlineInputBorder(
|
||||||
maxLines: 1,
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: field.hasError ? Colors.red : Colors.transparent,
|
||||||
|
width: 1.5,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
enabledBorder: OutlineInputBorder(
|
||||||
}).toList(),
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
value: loginBloc.regionList!.any(
|
borderSide: BorderSide(
|
||||||
(region) => region.id == loginBloc.regionUuid,)
|
color:
|
||||||
? loginBloc.regionUuid
|
field.hasError ? Colors.red : ColorsManager.grayColor,
|
||||||
: null,
|
width: 1.5,
|
||||||
onChanged: (String? value) {
|
),
|
||||||
if (value != null) {
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
loginBloc.add(SelectRegionEvent(
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
val: value,
|
borderSide: BorderSide(
|
||||||
));
|
color:
|
||||||
}
|
field.hasError ? Colors.red : ColorsManager.grayColor,
|
||||||
},
|
width: 1.5,
|
||||||
buttonStyleData: const ButtonStyleData(
|
),
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
),
|
||||||
height: 40,
|
errorBorder: OutlineInputBorder(
|
||||||
width: double.infinity,
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
),
|
borderSide: BorderSide(
|
||||||
dropdownStyleData: DropdownStyleData(
|
color: Colors.red,
|
||||||
maxHeight: size.height * 0.70,
|
width: 1.5,
|
||||||
),
|
|
||||||
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) {
|
child: DropdownButtonHideUnderline(
|
||||||
// Use the item's child text (region name) for searching.
|
child: DropdownButton2<String>(
|
||||||
final regionName = (item.child as Text).data?.toLowerCase() ?? '';
|
isExpanded: true,
|
||||||
final search = searchValue.toLowerCase().trim();
|
hint: Text(
|
||||||
// Debugging print statement to ensure values are captured correctly.
|
'Select your region/country',
|
||||||
// Return true if the region name contains the search term.
|
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||||
return regionName.contains(search);
|
color: ColorsManager.grayColor,
|
||||||
},
|
fontWeight: FontWeight.w400,
|
||||||
),
|
),
|
||||||
onMenuStateChange: (isOpen) {
|
overflow: TextOverflow.ellipsis,
|
||||||
if (!isOpen) {
|
),
|
||||||
textEditingController.clear();
|
items: loginBloc.regionList!.map((RegionModel region) {
|
||||||
}
|
return DropdownMenuItem<String>(
|
||||||
},
|
value: region.id,
|
||||||
),
|
child: Text(
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
|
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,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ColorsManager
|
||||||
|
.boxColor, // Match dropdown background color to the container
|
||||||
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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