mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
push fetch devices and connecting the filters
This commit is contained in:
@ -24,7 +24,6 @@ class LoginWebPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LoginWebPageState extends State<LoginWebPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -36,7 +35,7 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
||||
// Navigate to home screen after successful login
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => HomePage()),
|
||||
MaterialPageRoute(builder: (context) => HomePage()),
|
||||
);
|
||||
} else if (state is LoginFailure) {
|
||||
// Show error message
|
||||
@ -48,26 +47,28 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
||||
}
|
||||
},
|
||||
builder: (context, state) {
|
||||
return _buildLoginForm(context,state);
|
||||
return _buildLoginForm(context, state);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoginForm(BuildContext context,AuthState state) {
|
||||
Widget _buildLoginForm(BuildContext context, AuthState state) {
|
||||
final loginBloc = BlocProvider.of<AuthBloc>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
Size size = MediaQuery.of(context).size;
|
||||
late ScrollController _scrollController;
|
||||
_scrollController = ScrollController();
|
||||
void _scrollToCenter() {
|
||||
final double middlePosition = _scrollController.position.maxScrollExtent / 2;
|
||||
final double middlePosition =
|
||||
_scrollController.position.maxScrollExtent / 2;
|
||||
_scrollController.animateTo(
|
||||
middlePosition,
|
||||
duration: const Duration(seconds: 1),
|
||||
curve: Curves.easeInOut,
|
||||
);
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_scrollToCenter();
|
||||
});
|
||||
@ -80,14 +81,14 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(size.width*0.02) ,
|
||||
margin: EdgeInsets.all(size.width*0.09),
|
||||
padding: EdgeInsets.all(size.width * 0.02),
|
||||
margin: EdgeInsets.all(size.width * 0.09),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(20)),
|
||||
),
|
||||
child: Center(
|
||||
child:Row(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@ -101,92 +102,140 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
||||
const Spacer(),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Container(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.1),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(30)),
|
||||
border: Border.all(color: ColorsManager.graysColor.withOpacity(0.2))),
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(30)),
|
||||
border: Border.all(
|
||||
color: ColorsManager.graysColor
|
||||
.withOpacity(0.2))),
|
||||
child: Form(
|
||||
key: loginBloc.loginFormKey,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: size.width*0.02,
|
||||
vertical: size.width*0.003),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: size.width * 0.02,
|
||||
vertical: size.width * 0.003),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 40),
|
||||
Text(
|
||||
'Login',
|
||||
style:Theme.of(context).textTheme.headlineLarge),
|
||||
SizedBox(height: size.height*0.03),
|
||||
Text('Login',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineLarge),
|
||||
SizedBox(height: size.height * 0.03),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Country/Region",
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 14,fontWeight: FontWeight.w400),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
fontSize: 14,
|
||||
fontWeight:
|
||||
FontWeight.w400),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
const SizedBox(height: 10,),
|
||||
|
||||
SizedBox(
|
||||
child: DropdownButtonFormField<String>(
|
||||
child: DropdownButtonFormField<
|
||||
String>(
|
||||
padding: EdgeInsets.zero,
|
||||
value: loginBloc.regionList!.any((region) => region.id == loginBloc.regionUuid)
|
||||
value: loginBloc.regionList!
|
||||
.any((region) =>
|
||||
region.id ==
|
||||
loginBloc
|
||||
.regionUuid)
|
||||
? loginBloc.regionUuid
|
||||
: null,
|
||||
|
||||
validator: loginBloc.validateRegion,
|
||||
validator:
|
||||
loginBloc.validateRegion,
|
||||
icon: const Icon(
|
||||
Icons.keyboard_arrow_down_outlined,
|
||||
Icons
|
||||
.keyboard_arrow_down_outlined,
|
||||
),
|
||||
decoration: textBoxDecoration()!.copyWith(
|
||||
errorStyle: const TextStyle(height: 0),
|
||||
decoration: textBoxDecoration()!
|
||||
.copyWith(
|
||||
errorStyle: const TextStyle(
|
||||
height: 0),
|
||||
hintText: null,
|
||||
),
|
||||
hint: SizedBox(
|
||||
width: size.width * 0.12,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Align(
|
||||
alignment:
|
||||
Alignment.centerLeft,
|
||||
child: Text(
|
||||
'Select your region/country',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.w400),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign:
|
||||
TextAlign.center,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
color:
|
||||
ColorsManager
|
||||
.grayColor,
|
||||
fontWeight:
|
||||
FontWeight
|
||||
.w400),
|
||||
overflow:
|
||||
TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
isDense: true,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
items: loginBloc.regionList!.map((RegionModel region) {
|
||||
return DropdownMenuItem<String>(
|
||||
style: const TextStyle(
|
||||
color: Colors.black),
|
||||
items: loginBloc.regionList!
|
||||
.map((RegionModel region) {
|
||||
return DropdownMenuItem<
|
||||
String>(
|
||||
value: region.id,
|
||||
child: SizedBox(
|
||||
width: size.width*0.08,
|
||||
child: Text(region.name)),
|
||||
width:
|
||||
size.width * 0.08,
|
||||
child:
|
||||
Text(region.name)),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String? value) {
|
||||
loginBloc.add(CheckEnableEvent());
|
||||
loginBloc.add(SelectRegionEvent(val: value!));
|
||||
loginBloc
|
||||
.add(CheckEnableEvent());
|
||||
loginBloc.add(
|
||||
SelectRegionEvent(
|
||||
val: value!));
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Email",
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 14,fontWeight: FontWeight.w400),
|
||||
Text(
|
||||
"Email",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
fontSize: 14,
|
||||
fontWeight:
|
||||
FontWeight.w400),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
@ -194,30 +243,53 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
||||
SizedBox(
|
||||
child: TextFormField(
|
||||
onChanged: (value) {
|
||||
loginBloc.add(CheckEnableEvent());
|
||||
// print(loginBloc.checkEnable());
|
||||
loginBloc
|
||||
.add(CheckEnableEvent());
|
||||
// print(loginBloc.checkEnable());
|
||||
},
|
||||
validator:loginBloc.loginValidateEmail ,
|
||||
controller:loginBloc.loginEmailController,
|
||||
decoration: textBoxDecoration()!.copyWith(
|
||||
errorStyle: const TextStyle(height: 0), // Hide the error text space
|
||||
hintText: 'Enter your email address',
|
||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.w400)
|
||||
),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
validator: loginBloc
|
||||
.loginValidateEmail,
|
||||
controller: loginBloc
|
||||
.loginEmailController,
|
||||
decoration: textBoxDecoration()!
|
||||
.copyWith(
|
||||
errorStyle: const TextStyle(
|
||||
height:
|
||||
0), // Hide the error text space
|
||||
hintText:
|
||||
'Enter your email address',
|
||||
hintStyle: Theme.of(
|
||||
context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
color: ColorsManager
|
||||
.grayColor,
|
||||
fontWeight:
|
||||
FontWeight
|
||||
.w400)),
|
||||
style: const TextStyle(
|
||||
color: Colors.black),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.start,
|
||||
children: [
|
||||
Text("Password",
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(fontSize: 14,fontWeight: FontWeight.w400),
|
||||
Text(
|
||||
"Password",
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
fontSize: 14,
|
||||
fontWeight:
|
||||
FontWeight.w400),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
@ -225,33 +297,54 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
||||
SizedBox(
|
||||
child: TextFormField(
|
||||
onChanged: (value) {
|
||||
loginBloc.add(CheckEnableEvent());
|
||||
},
|
||||
validator:loginBloc.validatePassword,
|
||||
obscureText:loginBloc.obscureText,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
controller:loginBloc.loginPasswordController,
|
||||
decoration: textBoxDecoration()!.copyWith(
|
||||
hintText: 'At least 8 characters',
|
||||
hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith(
|
||||
color: ColorsManager.grayColor,
|
||||
fontWeight: FontWeight.w400),
|
||||
suffixIcon: IconButton(onPressed: () {
|
||||
loginBloc.add(PasswordVisibleEvent(newValue: loginBloc.obscureText));
|
||||
loginBloc
|
||||
.add(CheckEnableEvent());
|
||||
},
|
||||
validator:
|
||||
loginBloc.validatePassword,
|
||||
obscureText:
|
||||
loginBloc.obscureText,
|
||||
keyboardType: TextInputType
|
||||
.visiblePassword,
|
||||
controller: loginBloc
|
||||
.loginPasswordController,
|
||||
decoration: textBoxDecoration()!
|
||||
.copyWith(
|
||||
hintText:
|
||||
'At least 8 characters',
|
||||
hintStyle: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
color: ColorsManager
|
||||
.grayColor,
|
||||
fontWeight:
|
||||
FontWeight.w400),
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () {
|
||||
loginBloc.add(
|
||||
PasswordVisibleEvent(
|
||||
newValue: loginBloc
|
||||
.obscureText));
|
||||
},
|
||||
icon: SizedBox(
|
||||
child: SvgPicture.asset(
|
||||
loginBloc.obscureText?
|
||||
Assets.visiblePassword :
|
||||
Assets.invisiblePassword,
|
||||
height: 15,
|
||||
width: 15,
|
||||
),
|
||||
icon: SizedBox(
|
||||
child: SvgPicture.asset(
|
||||
loginBloc.obscureText
|
||||
? Assets
|
||||
.visiblePassword
|
||||
: Assets
|
||||
.invisiblePassword,
|
||||
height: 15,
|
||||
width: 15,
|
||||
),
|
||||
),
|
||||
errorStyle: const TextStyle(height: 0), // Hide the error text space
|
||||
),
|
||||
errorStyle: const TextStyle(
|
||||
height:
|
||||
0), // Hide the error text space
|
||||
),
|
||||
style: const TextStyle(color: Colors.black),
|
||||
style: const TextStyle(
|
||||
color: Colors.black),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -261,15 +354,27 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
||||
),
|
||||
SizedBox(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.end,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Navigator.of(context).push(MaterialPageRoute(builder: (context) => const ForgetPasswordPage(),));
|
||||
Navigator.of(context)
|
||||
.push(MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
const ForgetPasswordPage(),
|
||||
));
|
||||
},
|
||||
child: Text(
|
||||
"Forgot Password?",
|
||||
style: Theme.of(context).textTheme.bodySmall!.copyWith(color: Colors.black,fontSize: 14,fontWeight: FontWeight.w400),
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodySmall!
|
||||
.copyWith(
|
||||
color: Colors.black,
|
||||
fontSize: 14,
|
||||
fontWeight:
|
||||
FontWeight.w400),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -281,53 +386,65 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
||||
Row(
|
||||
children: [
|
||||
Transform.scale(
|
||||
scale: 1.2, // Adjust the scale as needed
|
||||
scale:
|
||||
1.2, // Adjust the scale as needed
|
||||
child: Checkbox(
|
||||
fillColor: MaterialStateProperty.all<Color>(Colors.white),
|
||||
fillColor: MaterialStateProperty
|
||||
.all<Color>(Colors.white),
|
||||
activeColor: Colors.white,
|
||||
value:loginBloc.isChecked,
|
||||
value: loginBloc.isChecked,
|
||||
checkColor: Colors.black,
|
||||
shape: const CircleBorder(),
|
||||
onChanged: (bool? newValue) {
|
||||
loginBloc.add(CheckBoxEvent(newValue: newValue));
|
||||
loginBloc.add(CheckBoxEvent(
|
||||
newValue: newValue));
|
||||
},
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width:size.width * 0.14,
|
||||
width: size.width * 0.14,
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: 'Agree to ',
|
||||
style: const TextStyle(color: Colors.white),
|
||||
style: const TextStyle(
|
||||
color: Colors.white),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '(Terms of Service)',
|
||||
text:
|
||||
'(Terms of Service)',
|
||||
style: const TextStyle(
|
||||
color: Colors.black,),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
loginBloc.launchURL(
|
||||
'https://example.com/terms');
|
||||
},
|
||||
color: Colors.black,
|
||||
),
|
||||
recognizer:
|
||||
TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
loginBloc.launchURL(
|
||||
'https://example.com/terms');
|
||||
},
|
||||
),
|
||||
TextSpan(
|
||||
text: ' (Legal Statement)',
|
||||
style: const TextStyle(color: Colors.black),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
loginBloc.launchURL(
|
||||
'https://example.com/legal');
|
||||
},
|
||||
),
|
||||
TextSpan(
|
||||
text: ' (Privacy Statement)',
|
||||
text:
|
||||
' (Legal Statement)',
|
||||
style: const TextStyle(
|
||||
color: Colors.black),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
loginBloc.launchURL(
|
||||
'https://example.com/privacy');
|
||||
},
|
||||
recognizer:
|
||||
TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
loginBloc.launchURL(
|
||||
'https://example.com/legal');
|
||||
},
|
||||
),
|
||||
TextSpan(
|
||||
text:
|
||||
' (Privacy Statement)',
|
||||
style: const TextStyle(
|
||||
color: Colors.black),
|
||||
recognizer:
|
||||
TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
loginBloc.launchURL(
|
||||
'https://example.com/privacy');
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -337,57 +454,87 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width:size.width * 0.2,
|
||||
width: size.width * 0.2,
|
||||
child: DefaultButton(
|
||||
enabled: loginBloc.checkValidate,
|
||||
child:Text('Sign in',
|
||||
style: Theme.of(context).textTheme.labelLarge !.copyWith(
|
||||
fontSize: 14,
|
||||
color:
|
||||
loginBloc.checkValidate ?
|
||||
ColorsManager.whiteColors:ColorsManager.whiteColors.withOpacity(0.2),
|
||||
)
|
||||
),
|
||||
enabled:
|
||||
loginBloc.checkValidate,
|
||||
child: Text('Sign in',
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.labelLarge!
|
||||
.copyWith(
|
||||
fontSize: 14,
|
||||
color: loginBloc
|
||||
.checkValidate
|
||||
? ColorsManager
|
||||
.whiteColors
|
||||
: ColorsManager
|
||||
.whiteColors
|
||||
.withOpacity(
|
||||
0.2),
|
||||
)),
|
||||
onPressed: () {
|
||||
if(loginBloc.loginFormKey.currentState!.validate() ){
|
||||
loginBloc.add(LoginButtonPressed(
|
||||
regionUuid:loginBloc.regionUuid,
|
||||
username: loginBloc.loginEmailController.text,
|
||||
password: loginBloc.loginPasswordController.text,
|
||||
if (loginBloc.loginFormKey
|
||||
.currentState!
|
||||
.validate()) {
|
||||
loginBloc
|
||||
.add(LoginButtonPressed(
|
||||
regionUuid:
|
||||
loginBloc.regionUuid,
|
||||
username: loginBloc
|
||||
.loginEmailController
|
||||
.text,
|
||||
password: loginBloc
|
||||
.loginPasswordController
|
||||
.text,
|
||||
));
|
||||
}else{
|
||||
loginBloc.add(ChangeValidateEvent());
|
||||
} else {
|
||||
loginBloc.add(
|
||||
ChangeValidateEvent());
|
||||
}
|
||||
},
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15.0),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [ SizedBox(child: Text(loginBloc.validate,
|
||||
style: const TextStyle(fontWeight: FontWeight.w700,color: ColorsManager.red ),),)],)
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
child: Text(
|
||||
loginBloc.validate,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: ColorsManager.red),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
)),
|
||||
))),
|
||||
const Spacer(),
|
||||
],
|
||||
),),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
if (state is AuthLoading)
|
||||
const Center(child: CircularProgressIndicator())
|
||||
if (state is AuthLoading)
|
||||
const Center(child: CircularProgressIndicator())
|
||||
],
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user