diff --git a/lib/pages/access_management/bloc/access_bloc.dart b/lib/pages/access_management/bloc/access_bloc.dart index 26b3efc4..55b525b4 100644 --- a/lib/pages/access_management/bloc/access_bloc.dart +++ b/lib/pages/access_management/bloc/access_bloc.dart @@ -5,7 +5,6 @@ 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/common/hour_picker_dialog.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/snack_bar.dart'; diff --git a/lib/pages/access_management/view/access_management.dart b/lib/pages/access_management/view/access_management.dart index 74221f47..8a6fa022 100644 --- a/lib/pages/access_management/view/access_management.dart +++ b/lib/pages/access_management/view/access_management.dart @@ -24,7 +24,6 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { @override Widget build(BuildContext context) { - final isLargeScreen = isLargeScreenSize(context); final isSmallScreen = isSmallScreenSize(context); final isHalfMediumScreen = isHafMediumScreenSize(context); @@ -86,7 +85,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { _buildVisitorAdminPasswords(context, accessBloc), const SizedBox(height: 20), Expanded( - child: DynamicTable( + child: DynamicTable( tableName: 'AccessManagement', uuidIndex: 1, withSelectAll: true, @@ -169,7 +168,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { } Row _buildNormalSearchWidgets(BuildContext context, AccessBloc accessBloc) { - TimeOfDay _selectedTime = TimeOfDay.now(); + // TimeOfDay _selectedTime = TimeOfDay.now(); return Row( mainAxisSize: MainAxisSize.min, @@ -205,7 +204,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { title: 'Access Time', size: MediaQuery.of(context).size, endTime: () { - accessBloc.add(SelectTime(context: context, isStart: false)); + accessBloc.add(SelectTime(context: context, isStart: false)); }, startTime: () { accessBloc.add(SelectTime(context: context, isStart: true)); @@ -218,7 +217,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { SearchResetButtons( onSearch: () { accessBloc.add(FilterDataEvent( - emailAuthorizer:accessBloc.emailAuthorizer.text.toLowerCase() , + emailAuthorizer: accessBloc.emailAuthorizer.text.toLowerCase(), selectedTabIndex: BlocProvider.of(context).selectedIndex, passwordName: accessBloc.passwordName.text.toLowerCase(), startTime: accessBloc.effectiveTimeTimeStamp, @@ -264,12 +263,11 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { SearchResetButtons( onSearch: () { accessBloc.add(FilterDataEvent( - emailAuthorizer:accessBloc.emailAuthorizer.text.toLowerCase() , + emailAuthorizer: accessBloc.emailAuthorizer.text.toLowerCase(), selectedTabIndex: BlocProvider.of(context).selectedIndex, passwordName: accessBloc.passwordName.text.toLowerCase(), startTime: accessBloc.effectiveTimeTimeStamp, - endTime: accessBloc.expirationTimeTimeStamp - )); + endTime: accessBloc.expirationTimeTimeStamp)); }, onReset: () { accessBloc.add(ResetSearch()); @@ -278,6 +276,4 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { ], ); } - - } diff --git a/lib/pages/auth/bloc/auth_bloc.dart b/lib/pages/auth/bloc/auth_bloc.dart index a8a32f54..5b269141 100644 --- a/lib/pages/auth/bloc/auth_bloc.dart +++ b/lib/pages/auth/bloc/auth_bloc.dart @@ -108,20 +108,9 @@ class AuthBloc extends Bloc { } } 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 errorMessage = errorData['error']['message'] ?? 'something went wrong'; + validate = errorMessage; + emit(AuthInitialState()); } } diff --git a/lib/pages/auth/view/forget_password_web_page.dart b/lib/pages/auth/view/forget_password_web_page.dart index e89b9361..c04e7ee0 100644 --- a/lib/pages/auth/view/forget_password_web_page.dart +++ b/lib/pages/auth/view/forget_password_web_page.dart @@ -48,8 +48,7 @@ class ForgetPasswordWebPage extends StatelessWidget { 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), @@ -66,8 +65,7 @@ class ForgetPasswordWebPage extends StatelessWidget { second: Center( child: Stack( children: [ - if (state is AuthLoading) - const Center(child: CircularProgressIndicator()), + if (state is AuthLoading) const Center(child: CircularProgressIndicator()), ListView( shrinkWrap: true, controller: _scrollController, @@ -97,21 +95,16 @@ class ForgetPasswordWebPage extends StatelessWidget { 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: forgetBloc.forgetFormKey, child: Padding( padding: EdgeInsets.symmetric( - horizontal: size.width * 0.02, - vertical: size.width * 0.003), + horizontal: size.width * 0.02, vertical: size.width * 0.003), child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 10), @@ -128,66 +121,55 @@ class ForgetPasswordWebPage extends StatelessWidget { style: Theme.of(context) .textTheme .bodySmall! - .copyWith( - fontSize: 14, - fontWeight: FontWeight.w400), + .copyWith(fontSize: 14, fontWeight: FontWeight.w400), ), const SizedBox(height: 10), Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ const SizedBox(height: 10), - Form( - key: forgetBloc.forgetRegionKey, - child: SizedBox( - child: _buildDropdownField( - context, forgetBloc, size))) + Form( + key: forgetBloc.forgetRegionKey, + child: SizedBox( + child: + _buildDropdownField(context, forgetBloc, size))) ], ), const SizedBox(height: 20), Form( key: forgetBloc.forgetEmailKey, child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ Text( "Account", - 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), SizedBox( child: TextFormField( controller: forgetBloc.forgetEmailController, validator: forgetBloc.validateEmail, - decoration: - textBoxDecoration()!.copyWith( + decoration: textBoxDecoration()!.copyWith( hintText: 'Enter your email', hintStyle: Theme.of(context) - .textTheme.bodySmall!.copyWith( - color: ColorsManager.grayColor, - fontWeight: FontWeight.w400), + .textTheme + .bodySmall! + .copyWith( + color: ColorsManager.grayColor, + fontWeight: FontWeight.w400), ), - style: const TextStyle( - color: Colors.black), + style: const TextStyle(color: Colors.black), ), ), ], )), const SizedBox(height: 20.0), Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ Text( @@ -195,35 +177,40 @@ class ForgetPasswordWebPage extends StatelessWidget { style: Theme.of(context) .textTheme .bodySmall! - .copyWith( - fontSize: 14, - fontWeight: FontWeight.w400), + .copyWith(fontSize: 14, fontWeight: FontWeight.w400), ), const SizedBox(height: 10), SizedBox( child: TextFormField( validator: forgetBloc.validateCode, - keyboardType: - TextInputType.visiblePassword, + keyboardType: TextInputType.visiblePassword, controller: forgetBloc.forgetOtp, - decoration: - textBoxDecoration()!.copyWith( + decoration: textBoxDecoration()!.copyWith( hintText: 'Enter Code', - hintStyle: Theme.of(context).textTheme - .bodySmall!.copyWith( - color: ColorsManager.grayColor, - fontWeight: FontWeight.w400), + hintStyle: Theme.of(context) + .textTheme + .bodySmall! + .copyWith( + color: ColorsManager.grayColor, + fontWeight: FontWeight.w400), suffixIcon: SizedBox( width: 100, child: Center( child: InkWell( onTap: state is TimerState && - !state.isButtonEnabled && - state.remainingTime != 1 + !state.isButtonEnabled && + state.remainingTime != 1 ? null : () { - if (forgetBloc.forgetEmailKey.currentState!.validate()||forgetBloc.forgetRegionKey.currentState!.validate()) { - if(forgetBloc.forgetRegionKey.currentState!.validate()){ + if (forgetBloc + .forgetEmailKey.currentState! + .validate() || + forgetBloc + .forgetRegionKey.currentState! + .validate()) { + if (forgetBloc + .forgetRegionKey.currentState! + .validate()) { forgetBloc.add(StartTimerEvent()); } } @@ -231,28 +218,23 @@ class ForgetPasswordWebPage extends StatelessWidget { child: Text( 'Get Code ${state is TimerState && !state.isButtonEnabled && state.remainingTime != 1 ? "(${forgetBloc.formattedTime(state.remainingTime)}) " : ""}', style: TextStyle( - color: state - is TimerState && - !state - .isButtonEnabled + color: state is TimerState && + !state.isButtonEnabled ? Colors.grey - : ColorsManager - .btnColor, + : ColorsManager.btnColor, ), ), ), ), ), ), - style: const TextStyle( - color: Colors.black), + style: const TextStyle(color: Colors.black), ), ), if (forgetBloc.forgetValidate != '') // Check if there is a validation message Padding( - padding: - const EdgeInsets.only(top: 8.0), + padding: const EdgeInsets.only(top: 8.0), child: Text( forgetBloc.forgetValidate, style: const TextStyle( @@ -265,8 +247,7 @@ class ForgetPasswordWebPage extends StatelessWidget { ), const SizedBox(height: 20.0), Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ Text( @@ -274,35 +255,26 @@ class ForgetPasswordWebPage extends StatelessWidget { style: Theme.of(context) .textTheme .bodySmall! - .copyWith( - fontSize: 14, - fontWeight: FontWeight.w400), + .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( + keyboardType: TextInputType.visiblePassword, + validator: forgetBloc.passwordValidator, + controller: forgetBloc.forgetPasswordController, + decoration: textBoxDecoration()!.copyWith( suffixIcon: IconButton( onPressed: () { - forgetBloc.add( - PasswordVisibleEvent( - newValue: forgetBloc - .obscureText)); + forgetBloc.add(PasswordVisibleEvent( + newValue: forgetBloc.obscureText)); }, icon: SizedBox( child: SvgPicture.asset( forgetBloc.obscureText ? Assets.visiblePassword - : Assets - .invisiblePassword, + : Assets.invisiblePassword, height: 15, width: 15, ), @@ -313,13 +285,10 @@ class ForgetPasswordWebPage extends StatelessWidget { .textTheme .bodySmall! .copyWith( - color: - ColorsManager.grayColor, - fontWeight: - FontWeight.w400), + color: ColorsManager.grayColor, + fontWeight: FontWeight.w400), ), - style: const TextStyle( - color: Colors.black), + style: const TextStyle(color: Colors.black), ), ), ], @@ -329,21 +298,22 @@ class ForgetPasswordWebPage extends StatelessWidget { ), const SizedBox(height: 20.0), Row( - crossAxisAlignment: - CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( width: size.width * 0.2, child: DefaultButton( - backgroundColor: - ColorsManager.btnColor, + 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.forgetEmailKey.currentState! + .validate()) { + if (forgetBloc.forgetEmailKey.currentState! + .validate() && + forgetBloc.forgetFormKey.currentState! + .validate()) { forgetBloc.add(ChangePasswordEvent()); } } @@ -358,8 +328,7 @@ class ForgetPasswordWebPage extends StatelessWidget { child: Text( forgetBloc.validate, style: const TextStyle( - fontWeight: FontWeight.w700, - color: ColorsManager.red), + fontWeight: FontWeight.w700, color: ColorsManager.red), ), ), ), @@ -372,8 +341,7 @@ class ForgetPasswordWebPage extends StatelessWidget { children: [ const Text( "Do you have an account? ", - style: - TextStyle(color: Colors.white), + style: TextStyle(color: Colors.white), ), InkWell( onTap: () { @@ -407,8 +375,7 @@ class ForgetPasswordWebPage extends StatelessWidget { )); } - Widget _buildDropdownField( - BuildContext context, AuthBloc loginBloc, Size size) { + Widget _buildDropdownField(BuildContext context, AuthBloc loginBloc, Size size) { final TextEditingController textEditingController = TextEditingController(); return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -434,13 +401,10 @@ class ForgetPasswordWebPage extends StatelessWidget { builder: (FormFieldState field) { return InputDecorator( decoration: InputDecoration( - contentPadding: - const EdgeInsets.symmetric(horizontal: 2, vertical: 10), + contentPadding: const EdgeInsets.symmetric(horizontal: 2, vertical: 10), errorText: field.errorText, - filled: - true, // Ensure the dropdown is filled with the background color - fillColor: ColorsManager - .boxColor, // Match the dropdown container color + filled: true, // Ensure the dropdown is filled with the background color + fillColor: ColorsManager.boxColor, // Match the dropdown container color border: OutlineInputBorder( borderRadius: BorderRadius.circular(8.0), borderSide: BorderSide( @@ -451,22 +415,20 @@ class ForgetPasswordWebPage extends StatelessWidget { enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(8.0), borderSide: BorderSide( - color: - field.hasError ? Colors.red : ColorsManager.grayColor, + color: field.hasError ? Colors.red : ColorsManager.grayColor, width: 1.5, ), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(8.0), borderSide: BorderSide( - color: - field.hasError ? Colors.red : ColorsManager.grayColor, + color: field.hasError ? Colors.red : ColorsManager.grayColor, width: 1.5, ), ), errorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(8.0), - borderSide: BorderSide( + borderSide: const BorderSide( color: Colors.red, width: 1.5, ), @@ -488,24 +450,22 @@ class ForgetPasswordWebPage extends StatelessWidget { value: region.id, child: Text( style: Theme.of(context).textTheme.bodyMedium!.copyWith( - fontSize: 14, - fontWeight: FontWeight.w400, - ), + fontSize: 14, + fontWeight: FontWeight.w400, + ), region.name, overflow: TextOverflow.ellipsis, maxLines: 1, ), ); }).toList(), - value: loginBloc.regionList! - .any((region) => region.id == loginBloc.regionUuid) + 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 + field.didChange(value); // Notify the form field of the change } }, buttonStyleData: const ButtonStyleData( @@ -529,8 +489,7 @@ class ForgetPasswordWebPage extends StatelessWidget { searchInnerWidgetHeight: 50, searchInnerWidget: Container( height: 50, - padding: const EdgeInsets.symmetric( - horizontal: 8, vertical: 4), + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), child: TextFormField( style: const TextStyle(color: Colors.black), controller: textEditingController, @@ -544,8 +503,7 @@ class ForgetPasswordWebPage extends StatelessWidget { ), ), searchMatchFn: (item, searchValue) { - final regionName = - (item.child as Text).data?.toLowerCase() ?? ''; + final regionName = (item.child as Text).data?.toLowerCase() ?? ''; final search = searchValue.toLowerCase().trim(); return regionName.contains(search); }, @@ -564,6 +522,4 @@ class ForgetPasswordWebPage extends StatelessWidget { ], ); } - - } diff --git a/lib/pages/auth/view/login_web_page.dart b/lib/pages/auth/view/login_web_page.dart index a728e850..555f8f4a 100644 --- a/lib/pages/auth/view/login_web_page.dart +++ b/lib/pages/auth/view/login_web_page.dart @@ -24,8 +24,7 @@ class LoginWebPage extends StatefulWidget { State createState() => _LoginWebPageState(); } -class _LoginWebPageState extends State - with HelperResponsiveLayout { +class _LoginWebPageState extends State with HelperResponsiveLayout { @override Widget build(BuildContext context) { return Scaffold( @@ -60,8 +59,7 @@ class _LoginWebPageState extends State _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), @@ -123,8 +121,7 @@ class _LoginWebPageState extends State const Spacer(), Expanded( flex: 2, - child: _buildLoginFormFields( - context, loginBloc, size), + child: _buildLoginFormFields(context, loginBloc, size), ), const Spacer(), ], @@ -135,14 +132,12 @@ class _LoginWebPageState extends State ), ), ), - if (state is AuthLoading) - const Center(child: CircularProgressIndicator()) + if (state is AuthLoading) const Center(child: CircularProgressIndicator()) ], ); } - Widget _buildLoginFormFields( - BuildContext context, AuthBloc loginBloc, Size size) { + Widget _buildLoginFormFields(BuildContext context, AuthBloc loginBloc, Size size) { return Container( decoration: BoxDecoration( color: Colors.white.withOpacity(0.1), @@ -152,8 +147,8 @@ class _LoginWebPageState extends State 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, @@ -181,9 +176,7 @@ class _LoginWebPageState extends State ); } - - Widget _buildDropdownField( - BuildContext context, AuthBloc loginBloc, Size size) { + Widget _buildDropdownField(BuildContext context, AuthBloc loginBloc, Size size) { final TextEditingController textEditingController = TextEditingController(); return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -192,9 +185,9 @@ class _LoginWebPageState extends State Text( "Country/Region", style: Theme.of(context).textTheme.bodySmall!.copyWith( - fontSize: 14, - fontWeight: FontWeight.w400, - ), + fontSize: 14, + fontWeight: FontWeight.w400, + ), ), const SizedBox(height: 10), Container( @@ -211,9 +204,9 @@ class _LoginWebPageState extends State hint: Text( 'Select your region/country', style: Theme.of(context).textTheme.bodySmall!.copyWith( - color: ColorsManager.grayColor, - fontWeight: FontWeight.w400, - ), + color: ColorsManager.grayColor, + fontWeight: FontWeight.w400, + ), overflow: TextOverflow.ellipsis, ), items: loginBloc.regionList!.map((RegionModel region) { @@ -227,7 +220,8 @@ class _LoginWebPageState extends State ); }).toList(), value: loginBloc.regionList!.any( - (region) => region.id == loginBloc.regionUuid,) + (region) => region.id == loginBloc.regionUuid, + ) ? loginBloc.regionUuid : null, onChanged: (String? value) { @@ -286,7 +280,6 @@ class _LoginWebPageState extends State ); } - Widget _buildEmailField(BuildContext context, AuthBloc loginBloc) { return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -310,9 +303,10 @@ class _LoginWebPageState extends State decoration: textBoxDecoration()!.copyWith( errorStyle: const TextStyle(height: 0), hintText: 'Enter your email address', - hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith( - color: ColorsManager.grayColor, - fontWeight: FontWeight.w400)), + hintStyle: Theme.of(context) + .textTheme + .bodySmall! + .copyWith(color: ColorsManager.grayColor, fontWeight: FontWeight.w400)), style: const TextStyle(color: Colors.black), ), ), @@ -344,18 +338,17 @@ class _LoginWebPageState extends State controller: loginBloc.loginPasswordController, decoration: textBoxDecoration()!.copyWith( hintText: 'At least 8 characters', - hintStyle: Theme.of(context).textTheme.bodySmall!.copyWith( - color: ColorsManager.grayColor, fontWeight: FontWeight.w400), + hintStyle: Theme.of(context) + .textTheme + .bodySmall! + .copyWith(color: ColorsManager.grayColor, fontWeight: FontWeight.w400), suffixIcon: IconButton( onPressed: () { - loginBloc.add( - PasswordVisibleEvent(newValue: loginBloc.obscureText)); + loginBloc.add(PasswordVisibleEvent(newValue: loginBloc.obscureText)); }, icon: SizedBox( child: SvgPicture.asset( - loginBloc.obscureText - ? Assets.visiblePassword - : Assets.invisiblePassword, + loginBloc.obscureText ? Assets.visiblePassword : Assets.invisiblePassword, height: 15, width: 15, ), @@ -383,10 +376,10 @@ class _LoginWebPageState extends State }, 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), ), ), ], @@ -450,8 +443,7 @@ class _LoginWebPageState extends State ); } - Widget _buildSignInButton( - BuildContext context, AuthBloc loginBloc, Size size) { + Widget _buildSignInButton(BuildContext context, AuthBloc loginBloc, Size size) { return Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, @@ -492,8 +484,7 @@ class _LoginWebPageState extends State SizedBox( child: Text( loginBloc.validate, - style: const TextStyle( - fontWeight: FontWeight.w700, color: ColorsManager.red), + style: const TextStyle(fontWeight: FontWeight.w700, color: ColorsManager.red), ), ) ], diff --git a/lib/pages/device_managment/all_devices/bloc/device_managment_bloc.dart b/lib/pages/device_managment/all_devices/bloc/device_managment_bloc.dart index 94659941..cb5b427f 100644 --- a/lib/pages/device_managment/all_devices/bloc/device_managment_bloc.dart +++ b/lib/pages/device_managment/all_devices/bloc/device_managment_bloc.dart @@ -14,10 +14,9 @@ class DeviceManagementBloc extends Bloc _selectedDevices = []; List _filteredDevices = []; - String productName = ''; + String currentProductName = ''; String? currentCommunity; String? currentUnitName; - String? currentProductName; DeviceManagementBloc() : super(DeviceManagementInitial()) { on(_onFetchDevices); @@ -77,14 +76,14 @@ class DeviceManagementBloc extends Bloc _onResetFilters(ResetFilters event, Emitter emit) async { - productName = ''; + currentProductName = ''; _selectedDevices.clear(); _filteredDevices = List.from(_devices); _selectedIndex = 0; @@ -238,20 +237,10 @@ class DeviceManagementBloc extends Bloc emit) { - if (event.productName == currentProductName && - event.community == currentCommunity && - event.unitName == currentUnitName) { - return; - } - - currentProductName = event.productName; - currentCommunity = event.community; - currentUnitName = event.unitName; - if ((event.community == null || event.community!.isEmpty) && (event.unitName == null || event.unitName!.isEmpty) && (event.productName == null || event.productName!.isEmpty)) { - productName = ''; + currentProductName = ''; if (state is DeviceManagementFiltered) { add(FilterDevices(_getFilterFromIndex(_selectedIndex))); } else { @@ -259,7 +248,17 @@ class DeviceManagementBloc extends Bloc devicesToSearch = _filteredDevices; if (devicesToSearch.isNotEmpty) { diff --git a/lib/pages/device_managment/all_devices/bloc/device_managment_event.dart b/lib/pages/device_managment/all_devices/bloc/device_managment_event.dart index bd27f2a6..c7509080 100644 --- a/lib/pages/device_managment/all_devices/bloc/device_managment_event.dart +++ b/lib/pages/device_managment/all_devices/bloc/device_managment_event.dart @@ -31,11 +31,13 @@ class SearchDevices extends DeviceManagementEvent { final String? community; final String? unitName; final String? productName; + final bool searchField; const SearchDevices({ this.community, this.unitName, this.productName, + this.searchField = false, }); @override diff --git a/lib/pages/device_managment/all_devices/widgets/device_search_filters.dart b/lib/pages/device_managment/all_devices/widgets/device_search_filters.dart index 4690a810..ddb2bc19 100644 --- a/lib/pages/device_managment/all_devices/widgets/device_search_filters.dart +++ b/lib/pages/device_managment/all_devices/widgets/device_search_filters.dart @@ -67,9 +67,10 @@ class _DeviceSearchFiltersState extends State with HelperRe controller: controller, onSubmitted: () { context.read().add(SearchDevices( - productName: productNameController.text, - unitName: unitNameController.text, - )); + productName: productNameController.text, + unitName: unitNameController.text, + community: communityController.text, + searchField: true)); }, ); } @@ -78,10 +79,10 @@ class _DeviceSearchFiltersState extends State with HelperRe return SearchResetButtons( onSearch: () { context.read().add(SearchDevices( - community: communityController.text, - unitName: unitNameController.text, - productName: productNameController.text, - )); + community: communityController.text, + unitName: unitNameController.text, + productName: productNameController.text, + searchField: true)); }, onReset: () { communityController.clear(); diff --git a/lib/pages/device_managment/main_door_sensor/widgets/notification_dialog.dart b/lib/pages/device_managment/main_door_sensor/widgets/notification_dialog.dart index 83ba41bc..ac66b315 100644 --- a/lib/pages/device_managment/main_door_sensor/widgets/notification_dialog.dart +++ b/lib/pages/device_managment/main_door_sensor/widgets/notification_dialog.dart @@ -23,7 +23,7 @@ class _NotificationDialogState extends State { borderRadius: BorderRadius.circular(20), ), child: SizedBox( - width: 798, + width: 660, child: SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(20.0), @@ -70,41 +70,53 @@ class _NotificationDialogState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - ToggleWidget( - value: true, - code: 'notification', - deviceId: '', - label: 'Low Battery', - onChange: (v) { - setState(() { - isLowBatteryNotificationEnabled = v; - }); - }, - icon: '-1', + SizedBox( + width: 170, + height: 135, + child: ToggleWidget( + value: isLowBatteryNotificationEnabled, + code: 'notification', + deviceId: '', + label: 'Low Battery', + onChange: (v) { + setState(() { + isLowBatteryNotificationEnabled = v; + }); + }, + icon: '-1', + ), ), - ToggleWidget( - value: true, - code: 'notification', - deviceId: '', - label: 'Closing\nReminders', - onChange: (v) { - setState(() { - isClosingRemindersEnabled = v; - }); - }, - icon: '-1', + SizedBox( + width: 170, + height: 135, + child: ToggleWidget( + value: isClosingRemindersEnabled, + code: 'notification', + deviceId: '', + label: 'Closing\nReminders', + onChange: (v) { + setState(() { + isClosingRemindersEnabled = v; + }); + }, + icon: '-1', + ), ), - ToggleWidget( - value: true, - code: 'notification', - deviceId: '', - label: 'Door Alarm', - onChange: (v) { - setState(() { - isDoorAlarmEnabled = v; - }); - }, - icon: '-1', + SizedBox( + width: 170, + height: 135, + child: ToggleWidget( + value: isDoorAlarmEnabled, + code: 'notification', + deviceId: '', + label: 'Door Alarm', + onChange: (v) { + setState(() { + isDoorAlarmEnabled = v; + }); + }, + icon: '-1', + ), ), ], ), diff --git a/lib/pages/device_managment/water_leak/widgets/water_leak_notifi_dialog.dart b/lib/pages/device_managment/water_leak/widgets/water_leak_notifi_dialog.dart index c8aca44e..0e3e325f 100644 --- a/lib/pages/device_managment/water_leak/widgets/water_leak_notifi_dialog.dart +++ b/lib/pages/device_managment/water_leak/widgets/water_leak_notifi_dialog.dart @@ -6,12 +6,13 @@ class WaterLeakNotificationDialog extends StatefulWidget { const WaterLeakNotificationDialog({super.key}); @override - State createState() => _WaterLeakNotificationDialogState(); + State createState() => _NotificationDialogState(); } -class _WaterLeakNotificationDialogState extends State { +class _NotificationDialogState extends State { bool isLowBatteryNotificationEnabled = true; - bool isWaterLeakageNotificationEnabled = true; + bool isClosingRemindersEnabled = true; + bool isWaterLeakage = true; @override Widget build(BuildContext context) { @@ -22,7 +23,7 @@ class _WaterLeakNotificationDialogState extends State[ Container( width: size.width, - padding: EdgeInsets.all(15), + padding: const EdgeInsets.all(15), decoration: containerDecoration.copyWith( color: ColorsManager.worningColor, border: Border.all(color: Color(0xffFFD22F)), @@ -69,13 +68,10 @@ class AddDeviceDialog extends StatelessWidget { ), Text( 'Only online accessible devices can be added', - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - fontWeight: FontWeight.w400, - fontSize: 12, - color: ColorsManager.grayColor), + style: Theme.of(context).textTheme.bodySmall!.copyWith( + fontWeight: FontWeight.w400, + fontSize: 12, + color: ColorsManager.grayColor), ), ], )), @@ -156,8 +152,7 @@ class AddDeviceDialog extends StatelessWidget { visitorBloc.deviceNameController.clear(); visitorBloc.deviceIdController.clear(); visitorBloc.unitNameController.clear(); - visitorBloc.add( - FetchDevice()); // Reset to original list + visitorBloc.add(FetchDevice()); // Reset to original list }, ), ), @@ -177,8 +172,7 @@ class AddDeviceDialog extends StatelessWidget { selectAll: (p0) { visitorBloc.selectedDeviceIds.clear(); for (var item in state.data) { - visitorBloc - .add(SelectDeviceEvent(item.uuid)); + visitorBloc.add(SelectDeviceEvent(item.uuid)); } }, onRowSelected: (index, isSelected, row) {