web show notification when push notification is recieved
This commit is contained in:
@@ -60,7 +60,7 @@ List<SingleChildWidget> get apiClients {
|
|||||||
Provider(
|
Provider(
|
||||||
create: (context) => ProfileService(networkManager: context.read()),
|
create: (context) => ProfileService(networkManager: context.read()),
|
||||||
),
|
),
|
||||||
Provider(
|
Provider(
|
||||||
create: (context) => NotificationsService(networkManager: context.read()),
|
create: (context) => NotificationsService(networkManager: context.read()),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
@@ -100,8 +100,10 @@ List<SingleChildWidget> get repositories {
|
|||||||
Provider(
|
Provider(
|
||||||
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()),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -155,7 +157,7 @@ List<SingleChildWidget> get viewModels {
|
|||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(
|
||||||
create: (context) => FinalCompletionOfDocumentsViewModel(),
|
create: (context) => FinalCompletionOfDocumentsViewModel(),
|
||||||
),
|
),
|
||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(
|
||||||
create:
|
create:
|
||||||
(context) =>
|
(context) =>
|
||||||
NotificationViewModel(repositoryViewModel: context.read()),
|
NotificationViewModel(repositoryViewModel: 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),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+48
-27
@@ -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();
|
||||||
setupInteractedMessage();
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
setupInteractedMessage();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -88,38 +107,40 @@ 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(
|
||||||
title: 'OppLens',
|
child: MaterialApp.router(
|
||||||
debugShowCheckedModeBanner: false,
|
title: 'OppLens',
|
||||||
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
debugShowCheckedModeBanner: false,
|
||||||
dragDevices: {
|
scrollBehavior: const MaterialScrollBehavior().copyWith(
|
||||||
PointerDeviceKind.mouse,
|
dragDevices: {
|
||||||
PointerDeviceKind.touch,
|
PointerDeviceKind.mouse,
|
||||||
PointerDeviceKind.stylus,
|
PointerDeviceKind.touch,
|
||||||
PointerDeviceKind.unknown,
|
PointerDeviceKind.stylus,
|
||||||
},
|
PointerDeviceKind.unknown,
|
||||||
),
|
|
||||||
theme: ThemeData(
|
|
||||||
pageTransitionsTheme: PageTransitionsTheme(
|
|
||||||
builders: {
|
|
||||||
for (final platform in TargetPlatform.values)
|
|
||||||
platform:
|
|
||||||
kIsWeb
|
|
||||||
? const FadeUpwardsPageTransitionsBuilder()
|
|
||||||
: const CupertinoPageTransitionsBuilder(),
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
brightness:
|
theme: ThemeData(
|
||||||
themeProvider.isDarkMode ? Brightness.dark : Brightness.light,
|
pageTransitionsTheme: PageTransitionsTheme(
|
||||||
primaryColor: AppColors.primaryColor,
|
builders: {
|
||||||
scaffoldBackgroundColor: AppColors.backgroundColor,
|
for (final platform in TargetPlatform.values)
|
||||||
colorScheme: ColorScheme.fromSeed(
|
platform:
|
||||||
seedColor: AppColors.primaryColor,
|
kIsWeb
|
||||||
|
? const FadeUpwardsPageTransitionsBuilder()
|
||||||
|
: const CupertinoPageTransitionsBuilder(),
|
||||||
|
},
|
||||||
|
),
|
||||||
brightness:
|
brightness:
|
||||||
themeProvider.isDarkMode ? Brightness.dark : Brightness.light,
|
themeProvider.isDarkMode ? Brightness.dark : Brightness.light,
|
||||||
|
primaryColor: AppColors.primaryColor,
|
||||||
|
scaffoldBackgroundColor: AppColors.backgroundColor,
|
||||||
|
colorScheme: ColorScheme.fromSeed(
|
||||||
|
seedColor: AppColors.primaryColor,
|
||||||
|
brightness:
|
||||||
|
themeProvider.isDarkMode ? Brightness.dark : Brightness.light,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
routerConfig: appRouter,
|
||||||
),
|
),
|
||||||
routerConfig: appRouter,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,32 +43,34 @@ 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(
|
||||||
builder: (context, viewModel, child) {
|
child: Consumer<TendersViewModel>(
|
||||||
if (viewModel.isLoading) {
|
builder: (context, viewModel, child) {
|
||||||
return const Center(
|
if (viewModel.isLoading) {
|
||||||
child: CircularProgressIndicator(color: AppColors.jellyBean),
|
return const Center(
|
||||||
);
|
child: CircularProgressIndicator(color: AppColors.jellyBean),
|
||||||
}
|
);
|
||||||
if (viewModel.errorMessage != null) {
|
}
|
||||||
return Center(child: Text(viewModel.errorMessage!));
|
if (viewModel.errorMessage != null) {
|
||||||
}
|
return Center(child: Text(viewModel.errorMessage!));
|
||||||
|
}
|
||||||
|
|
||||||
if ((viewModel.tendersResponse?.data?.tenders == null ||
|
if ((viewModel.tendersResponse?.data?.tenders == null ||
|
||||||
viewModel.tendersResponse!.data!.tenders!.isEmpty) &&
|
viewModel.tendersResponse!.data!.tenders!.isEmpty) &&
|
||||||
viewModel.isLoading == false) {
|
viewModel.isLoading == false) {
|
||||||
return const Center(child: Text(CommonStrings.noData));
|
return const Center(child: Text(CommonStrings.noData));
|
||||||
}
|
}
|
||||||
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 18.0.h()),
|
padding: EdgeInsets.symmetric(vertical: 18.0.h()),
|
||||||
child: MainTendersSlider(
|
child: MainTendersSlider(
|
||||||
tenders: viewModel.tendersResponse?.data?.tenders ?? [],
|
tenders: viewModel.tendersResponse?.data?.tenders ?? [],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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