diff --git a/assets/icons/bathroom.svg b/assets/icons/bathroom.svg index 51fc8b6a..8a75f646 100644 --- a/assets/icons/bathroom.svg +++ b/assets/icons/bathroom.svg @@ -1,29 +1,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/bedroom.svg b/assets/icons/bedroom.svg index d579b003..6797009c 100644 --- a/assets/icons/bedroom.svg +++ b/assets/icons/bedroom.svg @@ -1,34 +1,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - + + + + + + diff --git a/assets/icons/dyi.svg b/assets/icons/dyi.svg index 7da61e8e..938d2ba2 100644 --- a/assets/icons/dyi.svg +++ b/assets/icons/dyi.svg @@ -1,14 +1,13 @@ - - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/assets/icons/office.svg b/assets/icons/office.svg index 03a2badd..479352c6 100644 --- a/assets/icons/office.svg +++ b/assets/icons/office.svg @@ -1,40 +1,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/parlour.svg b/assets/icons/parlour.svg index 3298393a..52562dd2 100644 --- a/assets/icons/parlour.svg +++ b/assets/icons/parlour.svg @@ -1,30 +1,29 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/main.dart b/lib/main.dart index eeaa4685..3b861d10 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:syncrow_web/pages/auth/bloc/auth_bloc.dart'; import 'package:syncrow_web/pages/home/bloc/home_bloc.dart'; +import 'package:syncrow_web/pages/home/bloc/home_event.dart'; import 'package:syncrow_web/pages/visitor_password/bloc/visitor_password_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:syncrow_web/services/locator.dart'; @@ -13,7 +14,8 @@ import 'package:syncrow_web/utils/theme/theme.dart'; Future main() async { try { - const environment = String.fromEnvironment('FLAVOR', defaultValue: 'production'); + const environment = + String.fromEnvironment('FLAVOR', defaultValue: 'development'); await dotenv.load(fileName: '.env.$environment'); WidgetsFlutterBinding.ensureInitialized(); initialSetup(); @@ -43,9 +45,11 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { + //HomeBloc.fetchUserInfo(); return MultiBlocProvider( providers: [ - BlocProvider(create: (context) => HomeBloc()), + BlocProvider( + create: (context) => HomeBloc()..add(const FetchUserInfo())), BlocProvider( create: (context) => VisitorPasswordBloc(), ) diff --git a/lib/pages/access_management/view/access_management.dart b/lib/pages/access_management/view/access_management.dart index 0d4e3a19..f66c8a99 100644 --- a/lib/pages/access_management/view/access_management.dart +++ b/lib/pages/access_management/view/access_management.dart @@ -59,7 +59,6 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { builder: (context, state) { final accessBloc = BlocProvider.of(context); final filteredData = accessBloc.filteredData; - return state is AccessLoaded ? const Center(child: CircularProgressIndicator()) : Container( @@ -87,6 +86,7 @@ class AccessManagementPage extends StatelessWidget with HelperResponsiveLayout { const SizedBox(height: 20), Expanded( child: DynamicTable( + tableName: 'AccessManagement', uuidIndex: 1, withSelectAll: true, isEmpty: filteredData.isEmpty, diff --git a/lib/pages/auth/bloc/auth_bloc.dart b/lib/pages/auth/bloc/auth_bloc.dart index 4e4a7b0e..2d18d8e3 100644 --- a/lib/pages/auth/bloc/auth_bloc.dart +++ b/lib/pages/auth/bloc/auth_bloc.dart @@ -132,7 +132,6 @@ class AuthBloc extends Bloc { void _login(LoginButtonPressed event, Emitter emit) async { emit(AuthLoading()); - if (isChecked) { try { if (event.username.isEmpty || event.password.isEmpty) { @@ -149,7 +148,7 @@ class AuthBloc extends Bloc { ); } catch (failure) { validate = 'Invalid Credentials!'; - emit(const LoginFailure(error: 'Invalid Credentials!')); + emit(LoginInitial()); return; } diff --git a/lib/pages/auth/view/forget_password_web_page.dart b/lib/pages/auth/view/forget_password_web_page.dart index efc580b3..a342a9a3 100644 --- a/lib/pages/auth/view/forget_password_web_page.dart +++ b/lib/pages/auth/view/forget_password_web_page.dart @@ -138,15 +138,6 @@ class ForgetPasswordWebPage extends StatelessWidget { CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - Text( - "Country/Region", - style: Theme.of(context) - .textTheme - .bodySmall! - .copyWith( - fontSize: 14, - fontWeight: FontWeight.w400), - ), const SizedBox(height: 10), SizedBox( child: _buildDropdownField(context, forgetBloc, size) @@ -171,6 +162,7 @@ class ForgetPasswordWebPage extends StatelessWidget { const SizedBox(height: 10), SizedBox( child: TextFormField( + controller:forgetBloc.forgetEmailController , validator: forgetBloc.validateEmail, decoration: textBoxDecoration()! .copyWith( diff --git a/lib/pages/auth/view/login_web_page.dart b/lib/pages/auth/view/login_web_page.dart index af211308..a728e850 100644 --- a/lib/pages/auth/view/login_web_page.dart +++ b/lib/pages/auth/view/login_web_page.dart @@ -410,38 +410,39 @@ class _LoginWebPageState extends State }, ), ), - SizedBox( - width: 220, - child: RichText( - text: TextSpan( - text: 'Agree to ', - style: const TextStyle(color: Colors.white), - children: [ - TextSpan( - text: '(Terms of Service)', - style: const TextStyle(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)', - style: const TextStyle(color: Colors.black), - recognizer: TapGestureRecognizer() - ..onTap = () { - loginBloc.launchURL('https://example.com/privacy'); - }, - ), - ], + Expanded( + child: SizedBox( + child: RichText( + text: TextSpan( + text: 'Agree to ', + style: const TextStyle(color: Colors.white), + children: [ + TextSpan( + text: '(Terms of Service)', + style: const TextStyle(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)', + style: const TextStyle(color: Colors.black), + recognizer: TapGestureRecognizer() + ..onTap = () { + loginBloc.launchURL('https://example.com/privacy'); + }, + ), + ], + ), ), ), ), 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 d64599f1..c11e05e1 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 @@ -134,11 +134,27 @@ class DeviceManagementBloc void _onSearchDevices( SearchDevices event, Emitter emit) { - if (_devices.isNotEmpty) { - _selectedDevices.clear(); - _selectedIndex = 0; + // If the search fields are all empty, restore the last filtered devices + if ((event.community == null || event.community!.isEmpty) && + (event.unitName == null || event.unitName!.isEmpty) && + (event.productName == null || event.productName!.isEmpty)) { + // If the current state is filtered, re-emit the filtered state + if (state is DeviceManagementFiltered) { + add(FilterDevices(_getFilterFromIndex(_selectedIndex))); + } + } - final filteredDevices = _devices.where((device) { + List devicesToSearch = _devices; + + if (state is DeviceManagementFiltered) { + devicesToSearch = (state as DeviceManagementFiltered).filteredDevices; + } + + if (devicesToSearch.isNotEmpty) { + _selectedDevices.clear(); + _selectedIndex = _selectedIndex; + + final filteredDevices = devicesToSearch.where((device) { final matchesCommunity = event.community == null || event.community!.isEmpty || (device.room?.name @@ -157,11 +173,21 @@ class DeviceManagementBloc ?.toLowerCase() .contains(event.productName!.toLowerCase()) ?? false); - return matchesCommunity && matchesUnit && matchesProductName; + final matchesDeviceName = event.productName == null || + event.productName!.isEmpty || + (device.categoryName + ?.toLowerCase() + .contains(event.productName!.toLowerCase()) ?? + false); + + return matchesCommunity && + matchesUnit && + (matchesProductName || matchesDeviceName); }).toList(); + emit(DeviceManagementFiltered( filteredDevices: filteredDevices, - selectedIndex: 0, + selectedIndex: _selectedIndex, onlineCount: _onlineCount, offlineCount: _offlineCount, lowBatteryCount: _lowBatteryCount, diff --git a/lib/pages/device_managment/all_devices/models/devices_model.dart b/lib/pages/device_managment/all_devices/models/devices_model.dart index 48e99a1a..13d3dd2e 100644 --- a/lib/pages/device_managment/all_devices/models/devices_model.dart +++ b/lib/pages/device_managment/all_devices/models/devices_model.dart @@ -119,7 +119,7 @@ class AllDevicesModel { timeZone = json['timeZone']?.toString(); updateTime = int.tryParse(json['updateTime']?.toString() ?? ''); uuid = json['uuid']?.toString(); - batteryLevel = int.tryParse(json['batteryLevel']?.toString() ?? ''); + batteryLevel = int.tryParse(json['battery']?.toString() ?? ''); } Map toJson() { final data = {}; @@ -151,7 +151,7 @@ class AllDevicesModel { data['timeZone'] = timeZone; data['updateTime'] = updateTime; data['uuid'] = uuid; - data['batteryLevel'] = batteryLevel; + data['battery'] = batteryLevel; return data; } } diff --git a/lib/pages/device_managment/shared/sensors_widgets/presence_space_type.dart b/lib/pages/device_managment/shared/sensors_widgets/presence_space_type.dart index 2f593abe..e1ca0586 100644 --- a/lib/pages/device_managment/shared/sensors_widgets/presence_space_type.dart +++ b/lib/pages/device_managment/shared/sensors_widgets/presence_space_type.dart @@ -53,18 +53,19 @@ class PresenceSpaceType extends StatelessWidget { return GestureDetector( onTap: () => action(spaceType.name), child: Container( + width: 40, + height: 40, + padding: const EdgeInsets.all(8), decoration: BoxDecoration( borderRadius: BorderRadius.circular(100), - border: Border.all( - color: value == spaceType - ? ColorsManager.blueColor - : Colors.transparent, - ), + color: value == spaceType + ? ColorsManager.primaryColorWithOpacity + : ColorsManager.textGray, ), child: SvgPicture.asset( icon, - width: 40, - height: 40, + width: 25, + height: 22, ), ), ); diff --git a/lib/pages/home/bloc/home_bloc.dart b/lib/pages/home/bloc/home_bloc.dart index cc40b8fe..98320a88 100644 --- a/lib/pages/home/bloc/home_bloc.dart +++ b/lib/pages/home/bloc/home_bloc.dart @@ -50,6 +50,16 @@ class HomeBloc extends Bloc { } } +// static Future fetchUserInfo() async { +// try { +// var uuid = +// await const FlutterSecureStorage().read(key: UserModel.userUuidKey); +// user = await HomeApi().fetchUserInfo(uuid); +// } catch (e) { +// return; +// } +// } + List homeItems = [ HomeItemModel( title: 'Access', diff --git a/lib/pages/home/view/home_page.dart b/lib/pages/home/view/home_page.dart index 75107e84..9159011f 100644 --- a/lib/pages/home/view/home_page.dart +++ b/lib/pages/home/view/home_page.dart @@ -1,25 +1,11 @@ import 'package:flutter/cupertino.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:syncrow_web/pages/home/bloc/home_bloc.dart'; -import 'package:syncrow_web/pages/home/bloc/home_event.dart'; import 'package:syncrow_web/pages/home/view/home_page_mobile.dart'; import 'package:syncrow_web/pages/home/view/home_page_web.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class HomePage extends StatefulWidget { +class HomePage extends StatelessWidget with HelperResponsiveLayout { const HomePage({super.key}); - @override - State createState() => _HomePageState(); -} - -class _HomePageState extends State with HelperResponsiveLayout { - @override - void initState() { - super.initState(); - context.read().add(const FetchUserInfo()); - } - @override Widget build(BuildContext context) { final isSmallScreen = isSmallScreenSize(context); diff --git a/lib/services/auth_api.dart b/lib/services/auth_api.dart index 44a4e7cf..6fd34050 100644 --- a/lib/services/auth_api.dart +++ b/lib/services/auth_api.dart @@ -37,13 +37,17 @@ class AuthenticationAPI { expectedResponseModel: (json) { return json['data']['cooldown']; }); - return response; } on DioException catch (e) { + final errorData = e.response!.data; + String errorMessage = errorData['message']; + print('sendOtp=$errorMessage'); if (e.response != null) { if (e.response!.statusCode == 400) { final errorData = e.response!.data; String errorMessage = errorData['message']; + print('sendOtp=$errorMessage'); + if (errorMessage == 'User not found') { return 1; } else { diff --git a/lib/web_layout/web_app_bar.dart b/lib/web_layout/web_app_bar.dart index 69f88f09..b3236aae 100644 --- a/lib/web_layout/web_app_bar.dart +++ b/lib/web_layout/web_app_bar.dart @@ -5,13 +5,23 @@ import 'package:syncrow_web/pages/home/bloc/home_state.dart'; import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart'; -class WebAppBar extends StatelessWidget with HelperResponsiveLayout { +class WebAppBar extends StatefulWidget { final Widget? title; final Widget? centerBody; final Widget? rightBody; const WebAppBar({super.key, this.title, this.centerBody, this.rightBody}); + @override + State createState() => _WebAppBarState(); +} + +class _WebAppBarState extends State with HelperResponsiveLayout { + @override + void initState() { + super.initState(); + } + @override Widget build(BuildContext context) { bool isSmallScreen = isSmallScreenSize(context); @@ -26,21 +36,21 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout { ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (title != null) + if (widget.title != null) Align( alignment: Alignment.centerLeft, - child: title!, + child: widget.title!, ), - if (centerBody != null) + if (widget.centerBody != null) Padding( padding: const EdgeInsets.only(top: 8.0), - child: centerBody, + child: widget.centerBody, ), - if (rightBody != null || user != null) + if (widget.rightBody != null || user != null) Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - if (rightBody != null) rightBody!, + if (widget.rightBody != null) widget.rightBody!, Row( children: [ const SizedBox.square( @@ -77,11 +87,11 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout { Expanded( child: Row( children: [ - title!, - if (centerBody != null) + widget.title!, + if (widget.centerBody != null) Padding( padding: const EdgeInsets.only(left: 80), - child: centerBody!, + child: widget.centerBody!, ), ], ), @@ -89,10 +99,10 @@ class WebAppBar extends StatelessWidget with HelperResponsiveLayout { Row( mainAxisSize: MainAxisSize.min, children: [ - if (rightBody != null) + if (widget.rightBody != null) Align( alignment: Alignment.centerRight, - child: rightBody, + child: widget.rightBody, ), const SizedBox( width: 10,