mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Bug fixes
This commit is contained in:
@ -4,7 +4,6 @@ import 'package:syncrow_web/pages/access_management/bloc/access_event.dart';
|
|||||||
import 'package:syncrow_web/pages/access_management/bloc/access_state.dart';
|
import 'package:syncrow_web/pages/access_management/bloc/access_state.dart';
|
||||||
import 'package:syncrow_web/pages/access_management/model/password_model.dart';
|
import 'package:syncrow_web/pages/access_management/model/password_model.dart';
|
||||||
import 'package:syncrow_web/services/access_mang_api.dart';
|
import 'package:syncrow_web/services/access_mang_api.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
|
||||||
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
import 'package:syncrow_web/utils/snack_bar.dart';
|
import 'package:syncrow_web/utils/snack_bar.dart';
|
||||||
|
|
||||||
|
@ -36,18 +36,14 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Physical Access',
|
'Physical Access',
|
||||||
style: Theme.of(context)
|
style: Theme.of(context).textTheme.headlineMedium!.copyWith(color: Colors.white),
|
||||||
.textTheme
|
|
||||||
.headlineMedium!
|
|
||||||
.copyWith(color: Colors.white),
|
|
||||||
),
|
),
|
||||||
const NavigateHomeGridView(),
|
const NavigateHomeGridView(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
scaffoldBody: BlocProvider(
|
scaffoldBody: BlocProvider(
|
||||||
create: (BuildContext context) =>
|
create: (BuildContext context) => AccessBloc()..add(FetchTableData()),
|
||||||
AccessBloc()..add(FetchTableData()),
|
|
||||||
child: BlocConsumer<AccessBloc, AccessState>(
|
child: BlocConsumer<AccessBloc, AccessState>(
|
||||||
listener: (context, state) {},
|
listener: (context, state) {},
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
@ -56,7 +52,7 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
return state is AccessLoaded
|
return state is AccessLoaded
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: Container(
|
: Container(
|
||||||
padding: EdgeInsets.all(30),
|
padding: const EdgeInsets.all(30),
|
||||||
height: size.height,
|
height: size.height,
|
||||||
width: size.width,
|
width: size.width,
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -65,64 +61,47 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
Container(
|
Container(
|
||||||
decoration: containerDecoration,
|
decoration: containerDecoration,
|
||||||
height: size.height * 0.05,
|
height: size.height * 0.05,
|
||||||
child: Flexible(
|
child: ListView.builder(
|
||||||
child: ListView.builder(
|
scrollDirection: Axis.horizontal,
|
||||||
scrollDirection: Axis.horizontal,
|
itemCount: BlocProvider.of<AccessBloc>(context).tabs.length,
|
||||||
itemCount:
|
shrinkWrap: true,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final isSelected =
|
||||||
|
index == BlocProvider.of<AccessBloc>(context).selectedIndex;
|
||||||
|
return InkWell(
|
||||||
|
onTap: () {
|
||||||
BlocProvider.of<AccessBloc>(context)
|
BlocProvider.of<AccessBloc>(context)
|
||||||
.tabs
|
.add(TabChangedEvent(index));
|
||||||
.length,
|
},
|
||||||
shrinkWrap: true,
|
child: Container(
|
||||||
itemBuilder: (context, index) {
|
decoration: BoxDecoration(
|
||||||
final isSelected = index ==
|
color: ColorsManager.boxColor,
|
||||||
BlocProvider.of<AccessBloc>(context)
|
border: Border.all(
|
||||||
.selectedIndex;
|
color: isSelected ? Colors.blue : Colors.transparent,
|
||||||
return InkWell(
|
width: 2.0,
|
||||||
onTap: () {
|
|
||||||
BlocProvider.of<AccessBloc>(context)
|
|
||||||
.add(TabChangedEvent(index));
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: ColorsManager.boxColor,
|
|
||||||
border: Border.all(
|
|
||||||
color: isSelected
|
|
||||||
? Colors.blue
|
|
||||||
: Colors.transparent,
|
|
||||||
width: 2.0,
|
|
||||||
),
|
|
||||||
borderRadius: index == 0
|
|
||||||
? const BorderRadius.only(
|
|
||||||
topLeft:
|
|
||||||
Radius.circular(10),
|
|
||||||
bottomLeft:
|
|
||||||
Radius.circular(10))
|
|
||||||
: index == 3
|
|
||||||
? const BorderRadius.only(
|
|
||||||
topRight:
|
|
||||||
Radius.circular(10),
|
|
||||||
bottomRight:
|
|
||||||
Radius.circular(10))
|
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.only(
|
borderRadius: index == 0
|
||||||
left: 10, right: 10),
|
? const BorderRadius.only(
|
||||||
child: Center(
|
topLeft: Radius.circular(10),
|
||||||
child: Text(
|
bottomLeft: Radius.circular(10))
|
||||||
BlocProvider.of<AccessBloc>(
|
: index == 3
|
||||||
context)
|
? const BorderRadius.only(
|
||||||
.tabs[index],
|
topRight: Radius.circular(10),
|
||||||
style: TextStyle(
|
bottomRight: Radius.circular(10))
|
||||||
color: isSelected
|
: null,
|
||||||
? Colors.blue
|
),
|
||||||
: Colors.black,
|
padding: const EdgeInsets.only(left: 10, right: 10),
|
||||||
),
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
BlocProvider.of<AccessBloc>(context).tabs[index],
|
||||||
|
style: TextStyle(
|
||||||
|
color: isSelected ? Colors.blue : Colors.black,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
);
|
||||||
),
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@ -151,19 +130,13 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
title: 'Access Time',
|
title: 'Access Time',
|
||||||
size: size,
|
size: size,
|
||||||
endTime: () {
|
endTime: () {
|
||||||
accessBloc.add(SelectTime(
|
accessBloc.add(SelectTime(context: context, isStart: false));
|
||||||
context: context, isStart: false));
|
|
||||||
},
|
},
|
||||||
startTime: () {
|
startTime: () {
|
||||||
accessBloc.add(SelectTime(
|
accessBloc.add(SelectTime(context: context, isStart: true));
|
||||||
context: context, isStart: true));
|
|
||||||
},
|
},
|
||||||
firstString:
|
firstString: BlocProvider.of<AccessBloc>(context).startTime,
|
||||||
BlocProvider.of<AccessBloc>(context)
|
secondString: BlocProvider.of<AccessBloc>(context).endTime,
|
||||||
.startTime,
|
|
||||||
secondString:
|
|
||||||
BlocProvider.of<AccessBloc>(context)
|
|
||||||
.endTime,
|
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 15,
|
width: 15,
|
||||||
@ -175,17 +148,13 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
accessBloc.add(FilterDataEvent(
|
accessBloc.add(FilterDataEvent(
|
||||||
selectedTabIndex: BlocProvider
|
selectedTabIndex: BlocProvider.of<AccessBloc>(
|
||||||
.of<AccessBloc>(
|
context)
|
||||||
context)
|
|
||||||
.selectedIndex, // Pass the selected tab index
|
.selectedIndex, // Pass the selected tab index
|
||||||
passwordName: accessBloc
|
passwordName:
|
||||||
.passwordName.text
|
accessBloc.passwordName.text.toLowerCase(),
|
||||||
.toLowerCase(),
|
startTime: accessBloc.effectiveTimeTimeStamp,
|
||||||
startTime: accessBloc
|
endTime: accessBloc.expirationTimeTimeStamp));
|
||||||
.effectiveTimeTimeStamp,
|
|
||||||
endTime: accessBloc
|
|
||||||
.expirationTimeTimeStamp));
|
|
||||||
},
|
},
|
||||||
borderRadius: 9,
|
borderRadius: 9,
|
||||||
child: const Text('Search'))),
|
child: const Text('Search'))),
|
||||||
@ -201,8 +170,7 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
accessBloc.add(ResetSearch());
|
accessBloc.add(ResetSearch());
|
||||||
},
|
},
|
||||||
backgroundColor:
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
ColorsManager.whiteColors,
|
|
||||||
borderRadius: 9,
|
borderRadius: 9,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Reset',
|
'Reset',
|
||||||
@ -239,8 +207,7 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
child: const Text(
|
child: const Text('+ Create Visitor Password ')),
|
||||||
'+ Create Visitor Password ')),
|
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 10,
|
width: 10,
|
||||||
@ -250,8 +217,7 @@ class AccessManagementPage extends StatelessWidget {
|
|||||||
decoration: containerDecoration,
|
decoration: containerDecoration,
|
||||||
child: DefaultButton(
|
child: DefaultButton(
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
backgroundColor:
|
backgroundColor: ColorsManager.whiteColors,
|
||||||
ColorsManager.whiteColors,
|
|
||||||
child: Text(
|
child: Text(
|
||||||
'Admin Password',
|
'Admin Password',
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
abstract class AuthEvent extends Equatable {
|
abstract class AuthEvent extends Equatable {
|
||||||
const AuthEvent();
|
const AuthEvent();
|
||||||
@ -47,8 +46,7 @@ class StopTimerEvent extends AuthEvent {}
|
|||||||
class UpdateTimerEvent extends AuthEvent {
|
class UpdateTimerEvent extends AuthEvent {
|
||||||
final int remainingTime;
|
final int remainingTime;
|
||||||
final bool isButtonEnabled;
|
final bool isButtonEnabled;
|
||||||
const UpdateTimerEvent(
|
const UpdateTimerEvent({required this.remainingTime, required this.isButtonEnabled});
|
||||||
{required this.remainingTime, required this.isButtonEnabled});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChangePasswordEvent extends AuthEvent {}
|
class ChangePasswordEvent extends AuthEvent {}
|
||||||
|
@ -56,8 +56,7 @@ class TimerState extends AuthState {
|
|||||||
final bool isButtonEnabled;
|
final bool isButtonEnabled;
|
||||||
final int remainingTime;
|
final int remainingTime;
|
||||||
|
|
||||||
const TimerState(
|
const TimerState({required this.isButtonEnabled, required this.remainingTime});
|
||||||
{required this.isButtonEnabled, required this.remainingTime});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [isButtonEnabled, remainingTime];
|
List<Object> get props => [isButtonEnabled, remainingTime];
|
||||||
@ -65,12 +64,12 @@ class TimerState extends AuthState {
|
|||||||
|
|
||||||
class AuthError extends AuthState {
|
class AuthError extends AuthState {
|
||||||
final String message;
|
final String message;
|
||||||
String? code;
|
final String? code;
|
||||||
AuthError({required this.message, this.code});
|
const AuthError({required this.message, this.code});
|
||||||
}
|
}
|
||||||
|
|
||||||
class AuthTokenError extends AuthError {
|
class AuthTokenError extends AuthError {
|
||||||
AuthTokenError({required super.message, super.code});
|
const AuthTokenError({required super.message, super.code});
|
||||||
}
|
}
|
||||||
|
|
||||||
class AuthSuccess extends AuthState {}
|
class AuthSuccess extends AuthState {}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/auth/view/forget_password_mobile_page.dart';
|
|
||||||
import 'package:syncrow_web/pages/auth/view/forget_password_web_page.dart';
|
import 'package:syncrow_web/pages/auth/view/forget_password_web_page.dart';
|
||||||
import 'package:syncrow_web/utils/responsive_layout.dart';
|
import 'package:syncrow_web/utils/responsive_layout.dart';
|
||||||
|
|
||||||
@ -9,7 +8,6 @@ class ForgetPasswordPage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const ResponsiveLayout(
|
return const ResponsiveLayout(
|
||||||
desktopBody: ForgetPasswordWebPage(),
|
desktopBody: ForgetPasswordWebPage(), mobileBody: ForgetPasswordWebPage());
|
||||||
mobileBody: ForgetPasswordWebPage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import 'dart:ui';
|
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/auth/bloc/auth_event.dart';
|
import 'package:syncrow_web/pages/auth/bloc/auth_event.dart';
|
||||||
import 'package:syncrow_web/pages/auth/bloc/auth_state.dart';
|
import 'package:syncrow_web/pages/auth/bloc/auth_state.dart';
|
||||||
@ -11,7 +11,7 @@ import 'package:syncrow_web/pages/auth/view/forget_password_page.dart';
|
|||||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/pages/home/view/home_page.dart';
|
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
||||||
import 'package:syncrow_web/utils/style.dart';
|
import 'package:syncrow_web/utils/style.dart';
|
||||||
|
|
||||||
class LoginMobilePage extends StatelessWidget {
|
class LoginMobilePage extends StatelessWidget {
|
||||||
@ -25,10 +25,7 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is LoginSuccess) {
|
if (state is LoginSuccess) {
|
||||||
// Navigate to home screen after successful login
|
// Navigate to home screen after successful login
|
||||||
Navigator.pushReplacement(
|
context.go(RoutesConst.home, extra: {'clearHistory': true});
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => HomePage()),
|
|
||||||
);
|
|
||||||
} else if (state is LoginFailure) {
|
} else if (state is LoginFailure) {
|
||||||
// Show error message
|
// Show error message
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
@ -52,8 +49,6 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
|
|
||||||
Widget _buildLoginForm(BuildContext context) {
|
Widget _buildLoginForm(BuildContext context) {
|
||||||
final loginBloc = BlocProvider.of<AuthBloc>(context);
|
final loginBloc = BlocProvider.of<AuthBloc>(context);
|
||||||
final TextEditingController _usernameController = TextEditingController();
|
|
||||||
final TextEditingController _passwordController = TextEditingController();
|
|
||||||
return Center(
|
return Center(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
@ -102,11 +97,8 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white.withOpacity(0.1),
|
color: Colors.white.withOpacity(0.1),
|
||||||
borderRadius:
|
borderRadius: const BorderRadius.all(Radius.circular(30)),
|
||||||
const BorderRadius.all(Radius.circular(30)),
|
border: Border.all(color: ColorsManager.graysColor.withOpacity(0.2))),
|
||||||
border: Border.all(
|
|
||||||
color:
|
|
||||||
ColorsManager.graysColor.withOpacity(0.2))),
|
|
||||||
child: Form(
|
child: Form(
|
||||||
key: loginBloc.loginFormKey,
|
key: loginBloc.loginFormKey,
|
||||||
child: Column(
|
child: Column(
|
||||||
@ -117,9 +109,7 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
const Text(
|
const Text(
|
||||||
'Login',
|
'Login',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold),
|
||||||
fontSize: 24,
|
|
||||||
fontWeight: FontWeight.bold),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
Column(
|
Column(
|
||||||
@ -148,8 +138,7 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
items: loginBloc.regionList!
|
items: loginBloc.regionList!.map((RegionModel region) {
|
||||||
.map((RegionModel region) {
|
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: region.name,
|
value: region.name,
|
||||||
child: Text(region.name),
|
child: Text(region.name),
|
||||||
@ -173,8 +162,8 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
validator: loginBloc.validateEmail,
|
validator: loginBloc.validateEmail,
|
||||||
controller: loginBloc.loginEmailController,
|
controller: loginBloc.loginEmailController,
|
||||||
decoration: textBoxDecoration()!
|
decoration:
|
||||||
.copyWith(hintText: 'Enter your email'),
|
textBoxDecoration()!.copyWith(hintText: 'Enter your email'),
|
||||||
style: const TextStyle(color: Colors.black),
|
style: const TextStyle(color: Colors.black),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -194,8 +183,7 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
validator: loginBloc.validatePassword,
|
validator: loginBloc.validatePassword,
|
||||||
obscureText: loginBloc.obscureText,
|
obscureText: loginBloc.obscureText,
|
||||||
keyboardType: TextInputType.visiblePassword,
|
keyboardType: TextInputType.visiblePassword,
|
||||||
controller:
|
controller: loginBloc.loginPasswordController,
|
||||||
loginBloc.loginPasswordController,
|
|
||||||
decoration: textBoxDecoration()!.copyWith(
|
decoration: textBoxDecoration()!.copyWith(
|
||||||
hintText: 'At least 8 characters',
|
hintText: 'At least 8 characters',
|
||||||
),
|
),
|
||||||
@ -213,16 +201,13 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context)
|
Navigator.of(context).push(MaterialPageRoute(
|
||||||
.push(MaterialPageRoute(
|
builder: (context) => const ForgetPasswordPage(),
|
||||||
builder: (context) =>
|
|
||||||
const ForgetPasswordPage(),
|
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
"Forgot Password?",
|
"Forgot Password?",
|
||||||
style:
|
style: Theme.of(context).textTheme.bodySmall,
|
||||||
Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -233,15 +218,13 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
Transform.scale(
|
Transform.scale(
|
||||||
scale: 1.2, // Adjust the scale as needed
|
scale: 1.2, // Adjust the scale as needed
|
||||||
child: Checkbox(
|
child: Checkbox(
|
||||||
fillColor: MaterialStateProperty.all<Color>(
|
fillColor: MaterialStateProperty.all<Color>(Colors.white),
|
||||||
Colors.white),
|
|
||||||
activeColor: Colors.white,
|
activeColor: Colors.white,
|
||||||
value: loginBloc.isChecked,
|
value: loginBloc.isChecked,
|
||||||
checkColor: Colors.black,
|
checkColor: Colors.black,
|
||||||
shape: const CircleBorder(),
|
shape: const CircleBorder(),
|
||||||
onChanged: (bool? newValue) {
|
onChanged: (bool? newValue) {
|
||||||
loginBloc.add(
|
loginBloc.add(CheckBoxEvent(newValue: newValue));
|
||||||
CheckBoxEvent(newValue: newValue));
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -250,37 +233,30 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
child: RichText(
|
child: RichText(
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
text: 'Agree to ',
|
text: 'Agree to ',
|
||||||
style:
|
style: const TextStyle(color: Colors.white),
|
||||||
const TextStyle(color: Colors.white),
|
|
||||||
children: [
|
children: [
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: '(Terms of Service)',
|
text: '(Terms of Service)',
|
||||||
style: const TextStyle(
|
style: const TextStyle(color: Colors.black),
|
||||||
color: Colors.black),
|
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () {
|
..onTap = () {
|
||||||
loginBloc.launchURL(
|
loginBloc.launchURL('https://example.com/terms');
|
||||||
'https://example.com/terms');
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: ' (Legal Statement)',
|
text: ' (Legal Statement)',
|
||||||
style: const TextStyle(
|
style: const TextStyle(color: Colors.black),
|
||||||
color: Colors.black),
|
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () {
|
..onTap = () {
|
||||||
loginBloc.launchURL(
|
loginBloc.launchURL('https://example.com/legal');
|
||||||
'https://example.com/legal');
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: ' (Privacy Statement)',
|
text: ' (Privacy Statement)',
|
||||||
style: const TextStyle(
|
style: const TextStyle(color: Colors.black),
|
||||||
color: Colors.black),
|
|
||||||
recognizer: TapGestureRecognizer()
|
recognizer: TapGestureRecognizer()
|
||||||
..onTap = () {
|
..onTap = () {
|
||||||
loginBloc.launchURL(
|
loginBloc.launchURL('https://example.com/privacy');
|
||||||
'https://example.com/privacy');
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -297,15 +273,12 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
: ColorsManager.grayColor,
|
: ColorsManager.grayColor,
|
||||||
child: const Text('Sign in'),
|
child: const Text('Sign in'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (loginBloc.loginFormKey.currentState!
|
if (loginBloc.loginFormKey.currentState!.validate()) {
|
||||||
.validate()) {
|
|
||||||
loginBloc.add(
|
loginBloc.add(
|
||||||
LoginButtonPressed(
|
LoginButtonPressed(
|
||||||
regionUuid: '',
|
regionUuid: '',
|
||||||
username:
|
username: loginBloc.loginEmailController.text,
|
||||||
loginBloc.loginEmailController.text,
|
password: loginBloc.loginPasswordController.text,
|
||||||
password: loginBloc
|
|
||||||
.loginPasswordController.text,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -320,8 +293,7 @@ class LoginMobilePage extends StatelessWidget {
|
|||||||
Flexible(
|
Flexible(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Don't you have an account? ",
|
"Don't you have an account? ",
|
||||||
style: TextStyle(
|
style: TextStyle(color: Colors.white, fontSize: 13),
|
||||||
color: Colors.white, fontSize: 13),
|
|
||||||
)),
|
)),
|
||||||
Text(
|
Text(
|
||||||
"Sign up",
|
"Sign up",
|
||||||
|
@ -10,6 +10,7 @@ import 'package:syncrow_web/pages/auth/model/region_model.dart';
|
|||||||
import 'package:syncrow_web/pages/auth/view/forget_password_page.dart';
|
import 'package:syncrow_web/pages/auth/view/forget_password_page.dart';
|
||||||
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
import 'package:syncrow_web/pages/common/buttons/default_button.dart';
|
||||||
import 'package:syncrow_web/pages/common/first_layer.dart';
|
import 'package:syncrow_web/pages/common/first_layer.dart';
|
||||||
|
import 'package:syncrow_web/pages/home/view/home_page.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
import 'package:syncrow_web/utils/constants/routes_const.dart';
|
||||||
@ -31,7 +32,7 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
|||||||
child: BlocConsumer<AuthBloc, AuthState>(
|
child: BlocConsumer<AuthBloc, AuthState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state is LoginSuccess) {
|
if (state is LoginSuccess) {
|
||||||
context.go(RoutesConst.home);
|
context.replace(RoutesConst.home);
|
||||||
} else if (state is LoginFailure) {
|
} else if (state is LoginFailure) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
@ -201,7 +202,6 @@ class _LoginWebPageState extends State<LoginWebPage> {
|
|||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
loginBloc.add(CheckEnableEvent());
|
loginBloc.add(CheckEnableEvent());
|
||||||
// print(loginBloc.checkEnable());
|
|
||||||
},
|
},
|
||||||
validator: loginBloc.loginValidateEmail,
|
validator: loginBloc.loginValidateEmail,
|
||||||
controller: loginBloc.loginEmailController,
|
controller: loginBloc.loginEmailController,
|
||||||
|
@ -5,7 +5,7 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_mo
|
|||||||
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/view/ceiling_sensor_controls.dart';
|
import 'package:syncrow_web/pages/device_managment/ceiling_sensor/view/ceiling_sensor_controls.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/door_lock/view/door_lock_status_view.dart';
|
import 'package:syncrow_web/pages/device_managment/door_lock/view/door_lock_status_view.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/gateway/view/gateway_view.dart';
|
import 'package:syncrow_web/pages/device_managment/gateway/view/gateway_view.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/view/living_room_device_control.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/view/living_room_device_control.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/wall_sensor/view/wall_sensor_conrtols.dart';
|
import 'package:syncrow_web/pages/device_managment/wall_sensor/view/wall_sensor_conrtols.dart';
|
||||||
|
|
||||||
mixin RouteControlsBasedCode {
|
mixin RouteControlsBasedCode {
|
||||||
|
@ -4,7 +4,7 @@ import 'dart:async';
|
|||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/models/living_room_model.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/models/living_room_model.dart';
|
||||||
import 'package:syncrow_web/services/devices_mang_api.dart';
|
import 'package:syncrow_web/services/devices_mang_api.dart';
|
||||||
|
|
||||||
part 'living_room_event.dart';
|
part 'living_room_event.dart';
|
||||||
@ -24,18 +24,15 @@ class LivingRoomBloc extends Bloc<LivingRoomEvent, LivingRoomState> {
|
|||||||
LivingRoomFetchDeviceStatus event, Emitter<LivingRoomState> emit) async {
|
LivingRoomFetchDeviceStatus event, Emitter<LivingRoomState> emit) async {
|
||||||
emit(LivingRoomDeviceStatusLoading());
|
emit(LivingRoomDeviceStatusLoading());
|
||||||
try {
|
try {
|
||||||
final status =
|
final status = await DevicesManagementApi().getDeviceStatus(event.deviceId);
|
||||||
await DevicesManagementApi().getDeviceStatus(event.deviceId);
|
deviceStatus = LivingRoomStatusModel.fromJson(event.deviceId, status.status);
|
||||||
deviceStatus =
|
|
||||||
LivingRoomStatusModel.fromJson(event.deviceId, status.status);
|
|
||||||
emit(LivingRoomDeviceStatusLoaded(deviceStatus));
|
emit(LivingRoomDeviceStatusLoaded(deviceStatus));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(LivingRoomDeviceManagementError(e.toString()));
|
emit(LivingRoomDeviceManagementError(e.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureOr<void> _livingRoomControl(
|
FutureOr<void> _livingRoomControl(LivingRoomControl event, Emitter<LivingRoomState> emit) async {
|
||||||
LivingRoomControl event, Emitter<LivingRoomState> emit) async {
|
|
||||||
final oldValue = _getValueByCode(event.code);
|
final oldValue = _getValueByCode(event.code);
|
||||||
|
|
||||||
_updateLocalValue(event.code, event.value);
|
_updateLocalValue(event.code, event.value);
|
||||||
@ -63,8 +60,8 @@ class LivingRoomBloc extends Bloc<LivingRoomEvent, LivingRoomState> {
|
|||||||
}
|
}
|
||||||
_timer = Timer(const Duration(seconds: 1), () async {
|
_timer = Timer(const Duration(seconds: 1), () async {
|
||||||
try {
|
try {
|
||||||
final response = await DevicesManagementApi()
|
final response =
|
||||||
.deviceControl(deviceId, Status(code: code, value: value));
|
await DevicesManagementApi().deviceControl(deviceId, Status(code: code, value: value));
|
||||||
if (!response) {
|
if (!response) {
|
||||||
_revertValueAndEmit(deviceId, code, oldValue, emit);
|
_revertValueAndEmit(deviceId, code, oldValue, emit);
|
||||||
}
|
}
|
||||||
@ -74,8 +71,8 @@ class LivingRoomBloc extends Bloc<LivingRoomEvent, LivingRoomState> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _revertValueAndEmit(String deviceId, String code, dynamic oldValue,
|
void _revertValueAndEmit(
|
||||||
Emitter<LivingRoomState> emit) {
|
String deviceId, String code, dynamic oldValue, Emitter<LivingRoomState> emit) {
|
||||||
_updateLocalValue(code, oldValue);
|
_updateLocalValue(code, oldValue);
|
||||||
emit(LivingRoomDeviceStatusLoaded(deviceStatus));
|
emit(LivingRoomDeviceStatusLoaded(deviceStatus));
|
||||||
emit(const LivingRoomControlError('Failed to control the device.'));
|
emit(const LivingRoomControlError('Failed to control the device.'));
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/widgets/cieling_light.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/widgets/cieling_light.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/widgets/spot_light.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/widgets/spot_light.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/widgets/wall_light.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/widgets/wall_light.dart';
|
||||||
|
|
||||||
mixin LivingRoomHelper {
|
mixin LivingRoomHelper {
|
||||||
Widget livingRoomControlWidgets(
|
Widget livingRoomControlWidgets(
|
||||||
@ -18,4 +18,3 @@ mixin LivingRoomHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/bloc/living_room_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/models/living_room_model.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/models/living_room_model.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/widgets/living_toggle_widget.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/widgets/living_toggle_widget.dart';
|
||||||
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';
|
||||||
|
|
||||||
class LivingRoomDeviceControl extends StatelessWidget
|
class LivingRoomDeviceControl extends StatelessWidget with HelperResponsiveLayout {
|
||||||
with HelperResponsiveLayout {
|
|
||||||
final String deviceId;
|
final String deviceId;
|
||||||
|
|
||||||
const LivingRoomDeviceControl({super.key, required this.deviceId});
|
const LivingRoomDeviceControl({super.key, required this.deviceId});
|
||||||
@ -14,16 +13,15 @@ class LivingRoomDeviceControl extends StatelessWidget
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => LivingRoomBloc(deviceId: deviceId)
|
create: (context) =>
|
||||||
..add(LivingRoomFetchDeviceStatus(deviceId)),
|
LivingRoomBloc(deviceId: deviceId)..add(LivingRoomFetchDeviceStatus(deviceId)),
|
||||||
child: BlocBuilder<LivingRoomBloc, LivingRoomState>(
|
child: BlocBuilder<LivingRoomBloc, LivingRoomState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is LivingRoomDeviceStatusLoading) {
|
if (state is LivingRoomDeviceStatusLoading) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
} else if (state is LivingRoomDeviceStatusLoaded) {
|
} else if (state is LivingRoomDeviceStatusLoaded) {
|
||||||
return _buildStatusControls(context, state.status);
|
return _buildStatusControls(context, state.status);
|
||||||
} else if (state is LivingRoomDeviceManagementError ||
|
} else if (state is LivingRoomDeviceManagementError || state is LivingRoomControlError) {
|
||||||
state is LivingRoomControlError) {
|
|
||||||
return const Center(child: Text('Error fetching status'));
|
return const Center(child: Text('Error fetching status'));
|
||||||
} else {
|
} else {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
@ -33,8 +31,7 @@ class LivingRoomDeviceControl extends StatelessWidget
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildStatusControls(
|
Widget _buildStatusControls(BuildContext context, LivingRoomStatusModel status) {
|
||||||
BuildContext context, LivingRoomStatusModel status) {
|
|
||||||
final isExtraLarge = isExtraLargeScreenSize(context);
|
final isExtraLarge = isExtraLargeScreenSize(context);
|
||||||
final isLarge = isLargeScreenSize(context);
|
final isLarge = isLargeScreenSize(context);
|
||||||
final isMedium = isMediumScreenSize(context);
|
final isMedium = isMediumScreenSize(context);
|
@ -2,16 +2,12 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/bloc/living_room_bloc.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class CeilingLight extends StatelessWidget {
|
class CeilingLight extends StatelessWidget {
|
||||||
const CeilingLight(
|
const CeilingLight({super.key, required this.value, required this.code, required this.deviceId});
|
||||||
{super.key,
|
|
||||||
required this.value,
|
|
||||||
required this.code,
|
|
||||||
required this.deviceId});
|
|
||||||
|
|
||||||
final bool value;
|
final bool value;
|
||||||
final String code;
|
final String code;
|
@ -2,7 +2,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/bloc/living_room_bloc.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
@ -2,16 +2,12 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/bloc/living_room_bloc.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class SpotLight extends StatelessWidget {
|
class SpotLight extends StatelessWidget {
|
||||||
const SpotLight(
|
const SpotLight({super.key, required this.value, required this.code, required this.deviceId});
|
||||||
{super.key,
|
|
||||||
required this.value,
|
|
||||||
required this.code,
|
|
||||||
required this.deviceId});
|
|
||||||
|
|
||||||
final bool value;
|
final bool value;
|
||||||
final String code;
|
final String code;
|
@ -2,16 +2,12 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/living_room_switch/bloc/living_room_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/three_gang_switch/bloc/living_room_bloc.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class WallLight extends StatelessWidget {
|
class WallLight extends StatelessWidget {
|
||||||
const WallLight(
|
const WallLight({super.key, required this.value, required this.code, required this.deviceId});
|
||||||
{super.key,
|
|
||||||
required this.value,
|
|
||||||
required this.code,
|
|
||||||
required this.deviceId});
|
|
||||||
|
|
||||||
final bool value;
|
final bool value;
|
||||||
final String code;
|
final String code;
|
@ -21,19 +21,17 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final isExtraLarge = isExtraLargeScreenSize(context);
|
||||||
final isLarge = isLargeScreenSize(context);
|
final isLarge = isLargeScreenSize(context);
|
||||||
final isMedium = isMediumScreenSize(context);
|
final isMedium = isMediumScreenSize(context);
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) =>
|
create: (context) => WallSensorBloc(deviceId: device.uuid!)..add(WallSensorInitialEvent()),
|
||||||
WallSensorBloc(deviceId: device.uuid!)..add(WallSensorInitialEvent()),
|
|
||||||
child: BlocBuilder<WallSensorBloc, WallSensorState>(
|
child: BlocBuilder<WallSensorBloc, WallSensorState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is WallSensorLoadingInitialState ||
|
if (state is WallSensorLoadingInitialState || state is DeviceReportsLoadingState) {
|
||||||
state is DeviceReportsLoadingState) {
|
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
} else if (state is WallSensorUpdateState) {
|
} else if (state is WallSensorUpdateState) {
|
||||||
return _buildGridView(
|
return _buildGridView(context, state.wallSensorModel, isExtraLarge, isLarge, isMedium);
|
||||||
context, state.wallSensorModel, isLarge, isMedium);
|
|
||||||
} else if (state is DeviceReportsState) {
|
} else if (state is DeviceReportsState) {
|
||||||
return ReportsTable(
|
return ReportsTable(
|
||||||
report: state.deviceReport,
|
report: state.deviceReport,
|
||||||
@ -51,7 +49,7 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
);
|
);
|
||||||
} else if (state is DeviceReportsFailedState) {
|
} else if (state is DeviceReportsFailedState) {
|
||||||
final model = context.read<WallSensorBloc>().deviceStatus;
|
final model = context.read<WallSensorBloc>().deviceStatus;
|
||||||
return _buildGridView(context, model, isLarge, isMedium);
|
return _buildGridView(context, model, isExtraLarge, isLarge, isMedium);
|
||||||
}
|
}
|
||||||
return const Center(child: Text('Error fetching status'));
|
return const Center(child: Text('Error fetching status'));
|
||||||
},
|
},
|
||||||
@ -59,14 +57,14 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildGridView(BuildContext context, WallSensorModel model,
|
Widget _buildGridView(
|
||||||
bool isLarge, bool isMedium) {
|
BuildContext context, WallSensorModel model, bool isExtraLarge, bool isLarge, bool isMedium) {
|
||||||
return GridView(
|
return GridView(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 50),
|
padding: const EdgeInsets.symmetric(horizontal: 50),
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: isLarge
|
crossAxisCount: isLarge || isExtraLarge
|
||||||
? 3
|
? 3
|
||||||
: isMedium
|
: isMedium
|
||||||
? 2
|
? 2
|
||||||
@ -129,11 +127,10 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
maxValue: 10000,
|
maxValue: 10000,
|
||||||
steps: 1,
|
steps: 1,
|
||||||
description: 'hr',
|
description: 'hr',
|
||||||
action: (int value) =>
|
action: (int value) => context.read<WallSensorBloc>().add(WallSensorChangeValueEvent(
|
||||||
context.read<WallSensorBloc>().add(WallSensorChangeValueEvent(
|
code: 'no_one_time',
|
||||||
code: 'no_one_time',
|
value: value,
|
||||||
value: value,
|
))),
|
||||||
))),
|
|
||||||
PresenceUpdateData(
|
PresenceUpdateData(
|
||||||
value: model.farDetection.toDouble(),
|
value: model.farDetection.toDouble(),
|
||||||
title: 'Far Detection:',
|
title: 'Far Detection:',
|
||||||
@ -150,8 +147,9 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<WallSensorBloc>().add(GetDeviceReportsEvent(
|
context
|
||||||
code: 'illuminance_value', deviceUuid: device.uuid!));
|
.read<WallSensorBloc>()
|
||||||
|
.add(GetDeviceReportsEvent(code: 'illuminance_value', deviceUuid: device.uuid!));
|
||||||
},
|
},
|
||||||
child: const PresenceStaticWidget(
|
child: const PresenceStaticWidget(
|
||||||
icon: Assets.illuminanceRecordIcon,
|
icon: Assets.illuminanceRecordIcon,
|
||||||
@ -160,8 +158,9 @@ class WallSensorControls extends StatelessWidget with HelperResponsiveLayout {
|
|||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<WallSensorBloc>().add(GetDeviceReportsEvent(
|
context
|
||||||
code: 'presence_state', deviceUuid: device.uuid!));
|
.read<WallSensorBloc>()
|
||||||
|
.add(GetDeviceReportsEvent(code: 'presence_state', deviceUuid: device.uuid!));
|
||||||
},
|
},
|
||||||
child: const PresenceStaticWidget(
|
child: const PresenceStaticWidget(
|
||||||
icon: Assets.presenceRecordIcon,
|
icon: Assets.presenceRecordIcon,
|
||||||
|
@ -39,11 +39,10 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
|||||||
emit(HomeUpdateTree(graph: graph, builder: builder));
|
emit(HomeUpdateTree(graph: graph, builder: builder));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future fetchUserInfo() async {
|
static Future fetchUserInfo() async {
|
||||||
try {
|
try {
|
||||||
var uuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
var uuid = await const FlutterSecureStorage().read(key: UserModel.userUuidKey);
|
||||||
user = await HomeApi().fetchUserInfo(uuid);
|
user = await HomeApi().fetchUserInfo(uuid);
|
||||||
emit(HomeUserInfoLoaded(user!)); // Emit state after fetching user info
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:graphview/GraphView.dart';
|
import 'package:graphview/GraphView.dart';
|
||||||
import 'package:syncrow_web/pages/auth/model/user_model.dart';
|
|
||||||
|
|
||||||
abstract class HomeState extends Equatable {
|
abstract class HomeState extends Equatable {
|
||||||
const HomeState();
|
const HomeState();
|
||||||
@ -25,9 +24,3 @@ class HomeUpdateTree extends HomeState {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [graph, builder];
|
List<Object> get props => [graph, builder];
|
||||||
}
|
}
|
||||||
|
|
||||||
class HomeUserInfoLoaded extends HomeState {
|
|
||||||
final UserModel user;
|
|
||||||
|
|
||||||
HomeUserInfoLoaded(this.user);
|
|
||||||
}
|
|
||||||
|
@ -8,6 +8,6 @@ class HomePage extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ResponsiveLayout(desktopBody: HomeWebPage(), mobileBody: HomeMobilePage());
|
return ResponsiveLayout(desktopBody: const HomeWebPage(), mobileBody: HomeMobilePage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
import 'package:syncrow_web/pages/home/bloc/home_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/home/bloc/home_state.dart';
|
||||||
import 'package:syncrow_web/pages/home/view/home_card.dart';
|
import 'package:syncrow_web/pages/home/view/home_card.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
@ -22,51 +23,51 @@ class HomeMobilePage extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
scaffoldBody: BlocProvider(
|
scaffoldBody: BlocConsumer<HomeBloc, HomeState>(
|
||||||
create: (context) => HomeBloc(),
|
listener: (context, state) {},
|
||||||
child: SizedBox(
|
builder: (context, state) {
|
||||||
height: size.height,
|
return SizedBox(
|
||||||
width: size.width,
|
height: size.height,
|
||||||
child: Column(
|
width: size.width,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
SizedBox(height: size.height * 0.05),
|
children: [
|
||||||
const Text(
|
SizedBox(height: size.height * 0.05),
|
||||||
'ACCESS YOUR APPS',
|
const Text(
|
||||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700),
|
'ACCESS YOUR APPS',
|
||||||
),
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700),
|
||||||
const SizedBox(height: 30),
|
|
||||||
Expanded(
|
|
||||||
flex: 4,
|
|
||||||
child: SizedBox(
|
|
||||||
height: size.height * 0.6,
|
|
||||||
width: size.width * 0.68,
|
|
||||||
child: GridView.builder(
|
|
||||||
itemCount: 8,
|
|
||||||
gridDelegate:
|
|
||||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: 2,
|
|
||||||
crossAxisSpacing: 20.0,
|
|
||||||
mainAxisSpacing: 20.0,
|
|
||||||
childAspectRatio: 1.5,
|
|
||||||
),
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return HomeCard(
|
|
||||||
index: index,
|
|
||||||
active: homeItems[index]['active'],
|
|
||||||
name: homeItems[index]['title'],
|
|
||||||
img: homeItems[index]['icon'],
|
|
||||||
onTap: () {},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 30),
|
||||||
|
Expanded(
|
||||||
|
flex: 4,
|
||||||
|
child: SizedBox(
|
||||||
|
height: size.height * 0.6,
|
||||||
|
width: size.width * 0.68,
|
||||||
|
child: GridView.builder(
|
||||||
|
itemCount: 8,
|
||||||
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: 2,
|
||||||
|
crossAxisSpacing: 20.0,
|
||||||
|
mainAxisSpacing: 20.0,
|
||||||
|
childAspectRatio: 1.5,
|
||||||
|
),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return HomeCard(
|
||||||
|
index: index,
|
||||||
|
active: homeItems[index]['active'],
|
||||||
|
name: homeItems[index]['title'],
|
||||||
|
img: homeItems[index]['icon'],
|
||||||
|
onTap: () {},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
),
|
}),
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,78 +8,72 @@ import 'package:syncrow_web/utils/constants/assets.dart';
|
|||||||
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
||||||
|
|
||||||
class HomeWebPage extends StatelessWidget {
|
class HomeWebPage extends StatelessWidget {
|
||||||
HomeWebPage({super.key});
|
const HomeWebPage({super.key});
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: false,
|
canPop: false,
|
||||||
onPopInvoked: (didPop) => false,
|
onPopInvoked: (didPop) => false,
|
||||||
child:
|
child: WebScaffold(
|
||||||
WebScaffold(
|
enableMenuSideba: false,
|
||||||
enableMenuSideba: false,
|
appBarTitle: Row(
|
||||||
appBarTitle: Row(
|
children: [
|
||||||
children: [
|
SvgPicture.asset(
|
||||||
SvgPicture.asset(
|
Assets.loginLogo,
|
||||||
Assets.loginLogo,
|
width: 150,
|
||||||
width: 150,
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
scaffoldBody: BlocConsumer<HomeBloc, HomeState>(
|
||||||
),
|
listener: (BuildContext context, state) {},
|
||||||
scaffoldBody: BlocProvider(
|
builder: (context, state) {
|
||||||
create: (context) => HomeBloc(),
|
final homeBloc = BlocProvider.of<HomeBloc>(context);
|
||||||
child: BlocConsumer<HomeBloc, HomeState>(
|
return SizedBox(
|
||||||
listener: (BuildContext context, state) {},
|
height: size.height,
|
||||||
builder: (context, state) {
|
width: size.width,
|
||||||
final homeBloc = BlocProvider.of<HomeBloc>(context);
|
child: Column(
|
||||||
return SizedBox(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
height: size.height,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
width: size.width,
|
children: [
|
||||||
child: Column(
|
SizedBox(height: size.height * 0.1),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
Text(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
'ACCESS YOUR APPS',
|
||||||
children: [
|
style: Theme.of(context)
|
||||||
SizedBox(height: size.height * 0.1),
|
.textTheme
|
||||||
Text(
|
.headlineLarge!
|
||||||
'ACCESS YOUR APPS',
|
.copyWith(color: Colors.black, fontSize: 40),
|
||||||
style: Theme.of(context)
|
),
|
||||||
.textTheme
|
const SizedBox(height: 30),
|
||||||
.headlineLarge!
|
Expanded(
|
||||||
.copyWith(color: Colors.black, fontSize: 40),
|
flex: 4,
|
||||||
),
|
child: SizedBox(
|
||||||
const SizedBox(height: 30),
|
height: size.height * 0.6,
|
||||||
Expanded(
|
width: size.width * 0.68,
|
||||||
flex: 4,
|
child: GridView.builder(
|
||||||
child: SizedBox(
|
itemCount: 8,
|
||||||
height: size.height * 0.6,
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
width: size.width * 0.68,
|
crossAxisCount: 4,
|
||||||
child: GridView.builder(
|
crossAxisSpacing: 20.0,
|
||||||
itemCount: 8,
|
mainAxisSpacing: 20.0,
|
||||||
gridDelegate:
|
childAspectRatio: 1.5,
|
||||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
),
|
||||||
crossAxisCount: 4,
|
itemBuilder: (context, index) {
|
||||||
crossAxisSpacing: 20.0,
|
return HomeCard(
|
||||||
mainAxisSpacing: 20.0,
|
index: index,
|
||||||
childAspectRatio: 1.5,
|
active: homeBloc.homeItems[index].active!,
|
||||||
|
name: homeBloc.homeItems[index].title!,
|
||||||
|
img: homeBloc.homeItems[index].icon!,
|
||||||
|
onTap: () => homeBloc.homeItems[index].onPress(context),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return HomeCard(
|
|
||||||
index: index,
|
|
||||||
active: homeBloc.homeItems[index].active!,
|
|
||||||
name: homeBloc.homeItems[index].title!,
|
|
||||||
img: homeBloc.homeItems[index].icon!,
|
|
||||||
onTap: () =>
|
|
||||||
homeBloc.homeItems[index].onPress(context),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
)));
|
||||||
),
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,6 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
|||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorData = e.response!.data;
|
final errorData = e.response!.data;
|
||||||
String errorMessage = errorData['message'];
|
String errorMessage = errorData['message'];
|
||||||
print('errorMessage==$errorData');
|
|
||||||
emit(FailedState(errorMessage.toString()));
|
emit(FailedState(errorMessage.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,7 +238,6 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
|||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorData = e.response!.data;
|
final errorData = e.response!.data;
|
||||||
String errorMessage = errorData['message'];
|
String errorMessage = errorData['message'];
|
||||||
print('errorMessage==$errorData');
|
|
||||||
emit(FailedState(errorMessage.toString()));
|
emit(FailedState(errorMessage.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,7 +258,6 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
|||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorData = e.response!.data;
|
final errorData = e.response!.data;
|
||||||
String errorMessage = errorData['message'];
|
String errorMessage = errorData['message'];
|
||||||
print('errorMessage==$errorData');
|
|
||||||
emit(FailedState(errorMessage.toString()));
|
emit(FailedState(errorMessage.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,7 +282,6 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
|||||||
} on DioException catch (e) {
|
} on DioException catch (e) {
|
||||||
final errorData = e.response!.data;
|
final errorData = e.response!.data;
|
||||||
String errorMessage = errorData['message'];
|
String errorMessage = errorData['message'];
|
||||||
print('errorMessage==$errorData');
|
|
||||||
emit(FailedState(errorMessage.toString()));
|
emit(FailedState(errorMessage.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +318,7 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
|||||||
void filterDevices() {
|
void filterDevices() {
|
||||||
final deviceName = deviceNameController.text.toLowerCase();
|
final deviceName = deviceNameController.text.toLowerCase();
|
||||||
final deviceId = deviceIdController.text.toLowerCase();
|
final deviceId = deviceIdController.text.toLowerCase();
|
||||||
final unitName = unitNameController.text.toLowerCase();
|
// final unitName = unitNameController.text.toLowerCase();
|
||||||
final filteredData = data.where((device) {
|
final filteredData = data.where((device) {
|
||||||
final matchesDeviceName = device.name.toLowerCase().contains(deviceName);
|
final matchesDeviceName = device.name.toLowerCase().contains(deviceName);
|
||||||
final matchesDeviceId = device.uuid.toLowerCase().contains(deviceId);
|
final matchesDeviceId = device.uuid.toLowerCase().contains(deviceId);
|
||||||
@ -332,7 +328,6 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
|||||||
add(UpdateFilteredDevicesEvent(filteredData));
|
add(UpdateFilteredDevicesEvent(filteredData));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Stream<VisitorPasswordState> mapEventToState(VisitorPasswordEvent event) async* {
|
Stream<VisitorPasswordState> mapEventToState(VisitorPasswordEvent event) async* {
|
||||||
if (event is FetchDevice) {
|
if (event is FetchDevice) {
|
||||||
} else if (event is UpdateFilteredDevicesEvent) {
|
} else if (event is UpdateFilteredDevicesEvent) {
|
||||||
@ -417,7 +412,6 @@ class VisitorPasswordBloc extends Bloc<VisitorPasswordEvent, VisitorPasswordStat
|
|||||||
DateTime dateTime = inputFormat.parse(dateTimeString);
|
DateTime dateTime = inputFormat.parse(dateTimeString);
|
||||||
return dateTime;
|
return dateTime;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Error parsing date: $e");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -529,7 +529,6 @@ class VisitorPasswordDialog extends StatelessWidget {
|
|||||||
visitorBloc.accessTypeSelected == 'Offline Password') {
|
visitorBloc.accessTypeSelected == 'Offline Password') {
|
||||||
setPasswordFunction(context, size, visitorBloc);
|
setPasswordFunction(context, size, visitorBloc);
|
||||||
} else if (visitorBloc.accessTypeSelected == 'Dynamic Password') {
|
} else if (visitorBloc.accessTypeSelected == 'Dynamic Password') {
|
||||||
print('objectobjectobjectobject');
|
|
||||||
setPasswordFunction(context, size, visitorBloc);
|
setPasswordFunction(context, size, visitorBloc);
|
||||||
} else {
|
} else {
|
||||||
if (visitorBloc.effectiveTimeTimeStamp != null &&
|
if (visitorBloc.effectiveTimeTimeStamp != null &&
|
||||||
|
@ -123,13 +123,6 @@ class AccessMangApi {
|
|||||||
String? effectiveTime,
|
String? effectiveTime,
|
||||||
String? invalidTime,
|
String? invalidTime,
|
||||||
List<String>? devicesUuid}) async {
|
List<String>? devicesUuid}) async {
|
||||||
print(jsonEncode({
|
|
||||||
"email": email,
|
|
||||||
"devicesUuid": devicesUuid,
|
|
||||||
"passwordName": passwordName,
|
|
||||||
"effectiveTime": effectiveTime,
|
|
||||||
"invalidTime": invalidTime,
|
|
||||||
}));
|
|
||||||
final response = await HTTPService().post(
|
final response = await HTTPService().post(
|
||||||
path: ApiEndpoints.sendOffLineMultipleTime,
|
path: ApiEndpoints.sendOffLineMultipleTime,
|
||||||
body: jsonEncode({
|
body: jsonEncode({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class RoutesConst {
|
class RoutesConst {
|
||||||
static const String auth = '/';
|
static const String auth = '/auth';
|
||||||
static const String home = '/home';
|
static const String home = '/home';
|
||||||
static const String visitorPassword = '/visitor-password';
|
static const String visitorPassword = '/visitor-password';
|
||||||
static const String accessManagementPage = '/access-management-page';
|
static const String accessManagementPage = '/access-management-page';
|
||||||
|
Reference in New Issue
Block a user