add notification page filter
This commit is contained in:
parent
23e01c7a0d
commit
6ca9b2a948
2 changed files with 89 additions and 44 deletions
|
|
@ -33,7 +33,10 @@ class NotificationController
|
||||||
if (navigatorKey.currentContext case final context?) {
|
if (navigatorKey.currentContext case final context?) {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (_) => NotificationsPage(eventId: eventId),
|
builder: (_) => NotificationsPage(
|
||||||
|
eventId: eventId,
|
||||||
|
defaultToAllNotifications: true,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
|
import "package:m3e_buttons/m3e_buttons.dart";
|
||||||
import "package:material_ui/material_ui.dart";
|
import "package:material_ui/material_ui.dart";
|
||||||
import "package:flutter_hooks/flutter_hooks.dart";
|
import "package:flutter_hooks/flutter_hooks.dart";
|
||||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||||
import "package:nexus/controllers/notifications.dart";
|
import "package:nexus/controllers/notifications.dart";
|
||||||
|
import "package:nexus/models/event.dart";
|
||||||
import "package:nexus/widgets/appbar.dart";
|
import "package:nexus/widgets/appbar.dart";
|
||||||
import "package:nexus/widgets/error_dialog.dart";
|
import "package:nexus/widgets/error_dialog.dart";
|
||||||
import "package:nexus/widgets/highlight_wrapper.dart";
|
import "package:nexus/widgets/highlight_wrapper.dart";
|
||||||
|
|
@ -9,11 +11,29 @@ import "package:nexus/widgets/loading.dart";
|
||||||
import "package:nexus/widgets/renderers/event.dart";
|
import "package:nexus/widgets/renderers/event.dart";
|
||||||
import "package:super_sliver_list/super_sliver_list.dart";
|
import "package:super_sliver_list/super_sliver_list.dart";
|
||||||
|
|
||||||
class const NotificationsPage({final String? eventId, super.key})
|
class const NotificationsPage({
|
||||||
extends HookConsumerWidget {
|
final String? eventId,
|
||||||
|
final bool defaultToAllNotifications = false,
|
||||||
|
super.key,
|
||||||
|
}) extends HookConsumerWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final provider = NotificationsController.provider(null);
|
final options = <M3EToggleButtonGroupAction, UnreadType>{
|
||||||
|
M3EToggleButtonGroupAction(
|
||||||
|
label: Text("Mentions"),
|
||||||
|
icon: Icon(Icons.alternate_email),
|
||||||
|
): .highlight,
|
||||||
|
M3EToggleButtonGroupAction(
|
||||||
|
label: Text("All Notifications"),
|
||||||
|
icon: Icon(Icons.notifications),
|
||||||
|
): .notify,
|
||||||
|
};
|
||||||
|
final unreadTypeIndex = useState(defaultToAllNotifications ? 1 : 0);
|
||||||
|
|
||||||
|
final provider = NotificationsController.provider((
|
||||||
|
options.values.toList()[unreadTypeIndex.value],
|
||||||
|
null,
|
||||||
|
));
|
||||||
final notifications = ref.watch(provider);
|
final notifications = ref.watch(provider);
|
||||||
final notifier = ref.watch(provider.notifier);
|
final notifier = ref.watch(provider.notifier);
|
||||||
|
|
||||||
|
|
@ -35,7 +55,9 @@ class const NotificationsPage({final String? eventId, super.key})
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: Appbar(title: Text("Notifications")),
|
appBar: Appbar(title: Text("Notifications")),
|
||||||
body: Column(
|
body: Stack(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
children: [
|
children: [
|
||||||
if (notifications is AsyncLoading && notifications.value != null)
|
if (notifications is AsyncLoading && notifications.value != null)
|
||||||
const LinearProgressIndicator(minHeight: 2),
|
const LinearProgressIndicator(minHeight: 2),
|
||||||
|
|
@ -61,7 +83,9 @@ class const NotificationsPage({final String? eventId, super.key})
|
||||||
final event = value[index];
|
final event = value[index];
|
||||||
final isHighlighted = event.eventId == eventId;
|
final isHighlighted = event.eventId == eventId;
|
||||||
|
|
||||||
return HighlightWrapper(
|
return Padding(
|
||||||
|
padding: .only(top: 8),
|
||||||
|
child: HighlightWrapper(
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
//TODO
|
//TODO
|
||||||
|
|
@ -69,6 +93,7 @@ class const NotificationsPage({final String? eventId, super.key})
|
||||||
child: EventRenderer(event),
|
child: EventRenderer(event),
|
||||||
),
|
),
|
||||||
isHighlighted: isHighlighted,
|
isHighlighted: isHighlighted,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
@ -81,6 +106,23 @@ class const NotificationsPage({final String? eventId, super.key})
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
Align(
|
||||||
|
alignment: .topRight,
|
||||||
|
child: Card(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
child: Padding(
|
||||||
|
padding: .all(12),
|
||||||
|
child: M3EToggleButtonGroup(
|
||||||
|
selectedIndex: unreadTypeIndex.value,
|
||||||
|
onSelectedIndexChanged: (index) =>
|
||||||
|
unreadTypeIndex.value = index ?? unreadTypeIndex.value,
|
||||||
|
actions: options.keys.toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue