Merge pull request 'web show notification when push notification is recieved' (#161) from web_notification into main
Reviewed-on: https://repo.ravanertebat.com/TM/tm_app/pulls/161
This commit is contained in:
@@ -101,7 +101,9 @@ List<SingleChildWidget> get repositories {
|
|||||||
create: (context) => ProfileRepository(profileService: context.read()),
|
create: (context) => ProfileRepository(profileService: context.read()),
|
||||||
),
|
),
|
||||||
Provider(
|
Provider(
|
||||||
create: (context) => NotificationsRepository(notificationsService: context.read()),
|
create:
|
||||||
|
(context) =>
|
||||||
|
NotificationsRepository(notificationsService: context.read()),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,4 +21,19 @@ class AppToast {
|
|||||||
autoCloseDuration: const Duration(seconds: 3),
|
autoCloseDuration: const Duration(seconds: 3),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void notification(
|
||||||
|
BuildContext context,
|
||||||
|
String title,
|
||||||
|
String description,
|
||||||
|
) {
|
||||||
|
toastification.show(
|
||||||
|
context: context,
|
||||||
|
type: ToastificationType.info,
|
||||||
|
style: ToastificationStyle.flatColored,
|
||||||
|
title: Text(title),
|
||||||
|
description: Text(description),
|
||||||
|
autoCloseDuration: const Duration(seconds: 6),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-1
@@ -13,6 +13,8 @@ import 'package:tm_app/core/config/web_url_strategy.dart';
|
|||||||
import 'package:tm_app/core/services/cache_init.dart';
|
import 'package:tm_app/core/services/cache_init.dart';
|
||||||
import 'package:tm_app/core/services/firebase_service.dart';
|
import 'package:tm_app/core/services/firebase_service.dart';
|
||||||
import 'package:tm_app/core/theme/theme_provider.dart';
|
import 'package:tm_app/core/theme/theme_provider.dart';
|
||||||
|
import 'package:tm_app/core/utils/app_toast.dart';
|
||||||
|
import 'package:toastification/toastification.dart';
|
||||||
|
|
||||||
import 'core/routes/app_routes.dart';
|
import 'core/routes/app_routes.dart';
|
||||||
import 'core/theme/colors.dart';
|
import 'core/theme/colors.dart';
|
||||||
@@ -61,6 +63,21 @@ class _MyAppState extends State<MyApp> {
|
|||||||
_handleMessage(initialMessage);
|
_handleMessage(initialMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (kIsWeb) {
|
||||||
|
FirebaseMessaging.onMessage.listen((event) {
|
||||||
|
final overlayCtx = rootNavigatorKey.currentContext;
|
||||||
|
if (overlayCtx != null) {
|
||||||
|
if (overlayCtx.mounted) {
|
||||||
|
AppToast.notification(
|
||||||
|
overlayCtx,
|
||||||
|
event.notification?.title ?? 'New Notification',
|
||||||
|
event.notification?.body ?? 'New Notification',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
FirebaseMessaging.onMessageOpenedApp.listen(_handleMessage);
|
FirebaseMessaging.onMessageOpenedApp.listen(_handleMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +90,9 @@ class _MyAppState extends State<MyApp> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
setupInteractedMessage();
|
setupInteractedMessage();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -88,7 +107,8 @@ class _MyAppState extends State<MyApp> {
|
|||||||
// Listen to theme changes
|
// Listen to theme changes
|
||||||
final themeProvider = context.watch<ThemeProvider>();
|
final themeProvider = context.watch<ThemeProvider>();
|
||||||
|
|
||||||
return MaterialApp.router(
|
return ToastificationWrapper(
|
||||||
|
child: MaterialApp.router(
|
||||||
title: 'OppLens',
|
title: 'OppLens',
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
||||||
@@ -120,6 +140,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
routerConfig: appRouter,
|
routerConfig: appRouter,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ class _MobileTendersPageState extends State<MobileTendersPage> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: AppColors.backgroundColor,
|
backgroundColor: AppColors.backgroundColor,
|
||||||
appBar: tenderMobileAppBar(title: TendersStrings.tendersTitle),
|
appBar: tenderMobileAppBar(title: TendersStrings.tendersTitle),
|
||||||
body: Consumer<TendersViewModel>(
|
body: SingleChildScrollView(
|
||||||
|
child: Consumer<TendersViewModel>(
|
||||||
builder: (context, viewModel, child) {
|
builder: (context, viewModel, child) {
|
||||||
if (viewModel.isLoading) {
|
if (viewModel.isLoading) {
|
||||||
return const Center(
|
return const Center(
|
||||||
@@ -70,6 +71,7 @@ class _MobileTendersPageState extends State<MobileTendersPage> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ class _MainTendersSliderState extends State<MainTendersSlider> {
|
|||||||
|
|
||||||
Widget _nextPreviousArrows({required bool isLtr}) {
|
Widget _nextPreviousArrows({required bool isLtr}) {
|
||||||
return PositionedDirectional(
|
return PositionedDirectional(
|
||||||
top: 607.0.h(),
|
top: 558.0.h(),
|
||||||
bottom: 52.0.h(),
|
bottom: 52.0.h(),
|
||||||
start: 9.0.w(),
|
start: 9.0.w(),
|
||||||
end: 9.0.w(),
|
end: 9.0.w(),
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class TenderCard extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: isDesktop ? 20.0.h() : 72.0.h()),
|
SizedBox(height: isDesktop ? 20.0.h() : 52.0.h()),
|
||||||
if (!isDesktop) TenderActionButtonsRow(tender: tender),
|
if (!isDesktop) TenderActionButtonsRow(tender: tender),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user