From 314e32eaa9853dc7cabdad0b7db80ea3a857717a Mon Sep 17 00:00:00 2001 From: anhtunz Date: Fri, 28 Feb 2025 09:47:29 +0700 Subject: [PATCH] fix(ui): Fix some ui bugs --- android/app/src/main/AndroidManifest.xml | 2 +- .../auth/login/screen/login_screen.dart | 2 + lib/feature/home/home_screen.dart | 2 +- lib/feature/main/main_screen.dart | 15 +++++++ lib/feature/map/map_screen.dart | 11 ++++- .../notification_bloc.dart | 11 +++++ .../notification_screen.dart | 40 +++++++++++++++++++ lib/main.dart | 1 - .../navigation/navigation_router.dart | 10 +++++ pubspec.lock | 4 +- pubspec.yaml | 2 +- 11 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 lib/feature/sound_notification_test/notification_bloc.dart create mode 100644 lib/feature/sound_notification_test/notification_screen.dart diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index db85996..0f2efd2 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/lib/feature/auth/login/screen/login_screen.dart b/lib/feature/auth/login/screen/login_screen.dart index 8cccba8..ebce4bc 100644 --- a/lib/feature/auth/login/screen/login_screen.dart +++ b/lib/feature/auth/login/screen/login_screen.dart @@ -177,6 +177,8 @@ class _LoginScreenState extends State { _formKey.currentState!.save(); var data = await apiServices.login(APIPathConstants.LOGIN_PATH, loginRequest); + log("Data: $data"); + // log(message) if (data != "") { Map tokenData = jsonDecode(data); String token = tokenData['token']; diff --git a/lib/feature/home/home_screen.dart b/lib/feature/home/home_screen.dart index 7726ddb..b47aba7 100644 --- a/lib/feature/home/home_screen.dart +++ b/lib/feature/home/home_screen.dart @@ -48,7 +48,7 @@ class _HomeScreenState extends State { super.initState(); homeBloc = BlocProvider.of(context); getOwnerAndJoinedDevices(); - const duration = Duration(seconds: 20); + const duration = Duration(seconds: 10); getAllDevicesTimer = Timer.periodic(duration, (Timer t) => getOwnerAndJoinedDevices()); } diff --git a/lib/feature/main/main_screen.dart b/lib/feature/main/main_screen.dart index 36b843b..2292610 100644 --- a/lib/feature/main/main_screen.dart +++ b/lib/feature/main/main_screen.dart @@ -8,6 +8,7 @@ import 'package:go_router/go_router.dart'; // import 'package:persistent_bottom_nav_bar_v2/persistent-tab-view.dart'; import 'package:badges/badges.dart' as badges; import 'package:persistent_bottom_nav_bar/persistent_bottom_nav_bar.dart'; +import 'package:sfm_app/feature/sound_notification_test/notification_screen.dart'; import '../settings/profile/profile_model.dart'; import '../../product/extention/context_extention.dart'; import '../../bloc/home_bloc.dart'; @@ -33,6 +34,7 @@ import '../../product/constant/icon/icon_constants.dart'; import '../../product/constant/lang/language_constants.dart'; import '../../product/services/language_services.dart'; import '../bell/bell_model.dart'; +import '../sound_notification_test/notification_bloc.dart'; class MainScreen extends StatefulWidget { const MainScreen({super.key}); @@ -146,6 +148,15 @@ class _MainScreenState extends State with WidgetsBindingObserver { inactiveIcon: IconConstants.instance.getMaterialIcon(Icons.group_outlined), ), + PersistentBottomNavBarItem( + icon: IconConstants.instance + .getMaterialIcon(Icons.notifications_outlined), + title: appLocalization(context).notification, + activeColorPrimary: Colors.blue, + inactiveColorPrimary: Colors.grey, + inactiveIcon: IconConstants.instance + .getMaterialIcon(Icons.notifications_outlined), + ), ]; } @@ -170,6 +181,10 @@ class _MainScreenState extends State with WidgetsBindingObserver { child: const InterFamilyScreen(), blocBuilder: () => InterFamilyBloc(), ), + BlocProvider( + child: const NotificationScreen(), + blocBuilder: () => NotificationBloc(), + ), ]; } diff --git a/lib/feature/map/map_screen.dart b/lib/feature/map/map_screen.dart index c830c3d..5949936 100644 --- a/lib/feature/map/map_screen.dart +++ b/lib/feature/map/map_screen.dart @@ -54,6 +54,8 @@ class _MapScreenState extends State with WidgetsBindingObserver { // LatLng myLocation = const LatLng(213761, 123123); // Position? position; // bool isAllowLocationPermission = false; + Timer? checkThemeTimer; + Timer? getMarker; String themeMode = ''; @override void initState() { @@ -62,11 +64,17 @@ class _MapScreenState extends State with WidgetsBindingObserver { _loadIcons(); getAllMarkers(); clusterManager = _initClusterManager(); + const duration = Duration(seconds: 2); + checkThemeTimer = Timer.periodic(duration, (Timer t) => checkTheme()); + const Duration markerDuration = Duration(seconds: 5); + getMarker = Timer.periodic(markerDuration, (Timer t) => getAllMarkers()); } @override void dispose() { super.dispose(); + checkThemeTimer?.cancel(); + getMarker?.cancel(); _controller = Completer(); streamController.close(); } @@ -142,7 +150,6 @@ class _MapScreenState extends State with WidgetsBindingObserver { return rootBundle.loadString(path); } - Future _loadIcons() async { List> iconFutures = imageAssets.map((asset) { return BitmapDescriptor.asset( @@ -245,7 +252,7 @@ class _MapScreenState extends State with WidgetsBindingObserver { hasOtherState = true; } } - + if (hasStateOne) { return true; // flameIcon } else if (hasOtherState) { diff --git a/lib/feature/sound_notification_test/notification_bloc.dart b/lib/feature/sound_notification_test/notification_bloc.dart new file mode 100644 index 0000000..8252afb --- /dev/null +++ b/lib/feature/sound_notification_test/notification_bloc.dart @@ -0,0 +1,11 @@ +import 'package:sfm_app/product/base/bloc/base_bloc.dart'; + +class NotificationBloc extends BlocBase{ + + + @override + void dispose() { + // TODO: implement dispose + } + +} \ No newline at end of file diff --git a/lib/feature/sound_notification_test/notification_screen.dart b/lib/feature/sound_notification_test/notification_screen.dart new file mode 100644 index 0000000..0e29cf3 --- /dev/null +++ b/lib/feature/sound_notification_test/notification_screen.dart @@ -0,0 +1,40 @@ +import 'dart:developer'; + +import 'package:flutter/material.dart'; +import 'notification_bloc.dart'; +import '../../product/base/bloc/base_bloc.dart'; +import '../../product/services/notification_services.dart'; + +class NotificationScreen extends StatefulWidget { + const NotificationScreen({super.key}); + + @override + State createState() => _NotificationScreenState(); +} + +class _NotificationScreenState extends State { + late NotificationBloc notificationBloc; + NotificationServices notificationServices = NotificationServices(); + + @override + void initState() { + super.initState(); + notificationBloc = BlocProvider.of(context); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + TextButton( + onPressed: () { + log("Token: ${notificationServices.getDeviceToken()}"); + }, + child: Text("Get Notification Token")) + ], + )); + } +} diff --git a/lib/main.dart b/lib/main.dart index 64425fb..95c2b3a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -17,7 +17,6 @@ void main() async { ), ); } - class MyApp extends StatefulWidget { const MyApp({super.key}); diff --git a/lib/product/constant/navigation/navigation_router.dart b/lib/product/constant/navigation/navigation_router.dart index 0838db6..d4f6333 100644 --- a/lib/product/constant/navigation/navigation_router.dart +++ b/lib/product/constant/navigation/navigation_router.dart @@ -1,4 +1,6 @@ import 'package:go_router/go_router.dart'; +import 'package:sfm_app/feature/sound_notification_test/notification_bloc.dart'; +import 'package:sfm_app/feature/sound_notification_test/notification_screen.dart'; import '../../../bloc/device_detail_bloc.dart'; import '../../../feature/devices/device_detail/device_detail_screen.dart'; import '../../../bloc/device_notification_settings_bloc.dart'; @@ -151,6 +153,14 @@ GoRouter goRouter() { ), transitionsBuilder: transitionsRightToLeft), ), + GoRoute( + path: "/notification", + name: 'notification', + builder: (context, state) => BlocProvider( + child: const NotificationScreen(), + blocBuilder: () => NotificationBloc(), + ), + ), ], ); } diff --git a/pubspec.lock b/pubspec.lock index 212d513..3c12476 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -433,10 +433,10 @@ packages: dependency: "direct main" description: name: http - sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" + sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.3.0" http_parser: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 6b990f4..4ddf658 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -45,7 +45,7 @@ dependencies: # flex_color_scheme: ^7.2.0 flex_color_scheme: ^8.1.0 go_router: ^13.1.0 - http: ^1.1.0 + http: ^1.3.0 top_snackbar_flutter: ^3.1.0 badges: ^3.1.2 # google_maps_cluster_manager: ^3.1.0