mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: mobile notifications screen (#4100)
* fix: update username on mobile header on change * feat: notifications page * feat: refactor and refinement * fix: code review
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
import 'package:appflowy/mobile/application/mobile_router.dart';
|
||||
import 'package:appflowy/plugins/document/presentation/more/cubit/document_appearance_cubit.dart';
|
||||
import 'package:appflowy/startup/startup.dart';
|
||||
import 'package:appflowy/user/application/user_settings_service.dart';
|
||||
import 'package:appflowy/workspace/application/notifications/notification_action.dart';
|
||||
import 'package:appflowy/workspace/application/notifications/notification_action_bloc.dart';
|
||||
import 'package:appflowy/workspace/application/notifications/notification_service.dart';
|
||||
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
|
||||
import 'package:appflowy/workspace/application/settings/notifications/notification_settings_cubit.dart';
|
||||
@ -137,18 +140,44 @@ class _ApplicationWidgetState extends State<ApplicationWidget> {
|
||||
BlocProvider<DocumentAppearanceCubit>(
|
||||
create: (_) => DocumentAppearanceCubit()..fetch(),
|
||||
),
|
||||
BlocProvider.value(value: getIt<NotificationActionBloc>()),
|
||||
],
|
||||
child: BlocBuilder<AppearanceSettingsCubit, AppearanceSettingsState>(
|
||||
builder: (context, state) => MaterialApp.router(
|
||||
builder: overlayManagerBuilder(),
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: state.lightTheme,
|
||||
darkTheme: state.darkTheme,
|
||||
themeMode: state.themeMode,
|
||||
localizationsDelegates: context.localizationDelegates,
|
||||
supportedLocales: context.supportedLocales,
|
||||
locale: state.locale,
|
||||
routerConfig: routerConfig,
|
||||
child: BlocListener<NotificationActionBloc, NotificationActionState>(
|
||||
listener: (context, state) {
|
||||
if (state.action?.type == ActionType.openView) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final view =
|
||||
state.action!.arguments?[ActionArgumentKeys.view.name];
|
||||
if (view != null) {
|
||||
AppGlobals.rootNavKey.currentContext?.pushView(view);
|
||||
|
||||
final nodePath = state.action!
|
||||
.arguments?[ActionArgumentKeys.nodePath.name] as int?;
|
||||
|
||||
if (nodePath != null) {
|
||||
context.read<NotificationActionBloc>().add(
|
||||
NotificationActionEvent.performAction(
|
||||
action: state.action!
|
||||
.copyWith(type: ActionType.jumpToBlock),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
child: BlocBuilder<AppearanceSettingsCubit, AppearanceSettingsState>(
|
||||
builder: (context, state) => MaterialApp.router(
|
||||
builder: overlayManagerBuilder(),
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: state.lightTheme,
|
||||
darkTheme: state.darkTheme,
|
||||
themeMode: state.themeMode,
|
||||
localizationsDelegates: context.localizationDelegates,
|
||||
supportedLocales: context.supportedLocales,
|
||||
locale: state.locale,
|
||||
routerConfig: routerConfig,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -163,7 +192,6 @@ class AppGlobals {
|
||||
|
||||
class ApplicationBlocObserver extends BlocObserver {
|
||||
@override
|
||||
// ignore: unnecessary_overrides
|
||||
void onTransition(Bloc bloc, Transition transition) {
|
||||
// Log.debug("[current]: ${transition.currentState} \n\n[next]: ${transition.nextState}");
|
||||
// Log.debug("${transition.nextState}");
|
||||
|
@ -9,6 +9,7 @@ import 'package:appflowy/mobile/presentation/database/mobile_calendar_events_scr
|
||||
import 'package:appflowy/mobile/presentation/database/mobile_calendar_screen.dart';
|
||||
import 'package:appflowy/mobile/presentation/database/mobile_grid_screen.dart';
|
||||
import 'package:appflowy/mobile/presentation/favorite/mobile_favorite_page.dart';
|
||||
import 'package:appflowy/mobile/presentation/notifications/mobile_notifications_page.dart';
|
||||
import 'package:appflowy/mobile/presentation/presentation.dart';
|
||||
import 'package:appflowy/mobile/presentation/setting/cloud/appflowy_cloud_page.dart';
|
||||
import 'package:appflowy/mobile/presentation/setting/font/font_picker_screen.dart';
|
||||
@ -181,21 +182,8 @@ StatefulShellRoute _mobileHomeScreenWithNavigationBarRoute() {
|
||||
StatefulShellBranch(
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: '/e',
|
||||
builder: (BuildContext context, GoRouterState state) =>
|
||||
const RootPlaceholderScreen(
|
||||
label: 'Notification',
|
||||
detailsPath: '/e/details',
|
||||
),
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: 'details',
|
||||
builder: (BuildContext context, GoRouterState state) =>
|
||||
const DetailsPlaceholderScreen(
|
||||
label: 'Notification Page details',
|
||||
),
|
||||
),
|
||||
],
|
||||
path: MobileNotificationsScreen.routeName,
|
||||
builder: (_, __) => const MobileNotificationsScreen(),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -492,12 +480,8 @@ GoRoute _mobileEditorScreenRoute() {
|
||||
pageBuilder: (context, state) {
|
||||
final id = state.uri.queryParameters[MobileEditorScreen.viewId]!;
|
||||
final title = state.uri.queryParameters[MobileEditorScreen.viewTitle];
|
||||
return MaterialPage(
|
||||
child: MobileEditorScreen(
|
||||
id: id,
|
||||
title: title,
|
||||
),
|
||||
);
|
||||
|
||||
return MaterialPage(child: MobileEditorScreen(id: id, title: title));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user