Skip to content

Commit

Permalink
fix: update system notify filter
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Jun 16, 2024
1 parent 610e255 commit fcf933a
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 115 deletions.
271 changes: 156 additions & 115 deletions lib/view/pages/notification_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_multi_select_items/flutter_multi_select_items.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:multi_select_flutter/dialog/multi_select_dialog_field.dart';
import 'package:multi_select_flutter/util/multi_select_item.dart';
import 'package:smooth_scroll_multiplatform/smooth_scroll_multiplatform.dart';
import 'package:tuihub_protos/librarian/sephirah/v1/netzach.pb.dart';

import '../../bloc/netzach/netzach_bloc.dart';
Expand Down Expand Up @@ -35,97 +35,131 @@ class NotificationPage extends StatelessWidget {
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
child: Column(
children: [
DecoratedBox(
decoration: BoxDecoration(
border: Border.all(color: Theme.of(context).primaryColor),
borderRadius: SpacingHelper.defaultBorderRadius,
),
child: MultiSelectDialogField(
title: const Text('按通知级别筛选'),
buttonText: const Text('级别'),
buttonIcon: const Icon(Icons.filter_alt_outlined),
items: [
MultiSelectItem(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_ERROR,
systemNotificationLevelString(SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_ERROR),
),
MultiSelectItem(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_WARNING,
systemNotificationLevelString(SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_WARNING),
),
MultiSelectItem(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_INFO,
systemNotificationLevelString(SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_INFO),
),
MultiSelectItem(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_ONGOING,
systemNotificationLevelString(SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_ONGOING),
Row(
children: [
const Text('级别'),
const SizedBox(width: 8),
MultiSelectContainer(
prefix: MultiSelectPrefix(
selectedPrefix: const Padding(
padding: EdgeInsets.only(right: 5),
child: Icon(
Icons.check,
color: Colors.white,
size: 14,
),
),
),
],
onConfirm: (values) {
context.read<NetzachBloc>().add(
NetzachSystemNotificationFilterSetEvent(
SystemNotificationFilter(
levelFilter:
values.cast<SystemNotificationLevel>(),
typeFilter: filter.typeFilter,
items: [
MultiSelectCard(
value: SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_ONGOING,
label: systemNotificationLevelString(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_ONGOING),
selected: filter.levelFilter.contains(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_ONGOING),
),
MultiSelectCard(
value: SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_ERROR,
label: systemNotificationLevelString(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_ERROR),
selected: filter.levelFilter.contains(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_ERROR),
),
MultiSelectCard(
value: SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_WARNING,
label: systemNotificationLevelString(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_WARNING),
selected: filter.levelFilter.contains(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_WARNING),
),
MultiSelectCard(
value: SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_INFO,
label: systemNotificationLevelString(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_INFO),
selected: filter.levelFilter.contains(
SystemNotificationLevel
.SYSTEM_NOTIFICATION_LEVEL_INFO),
),
],
onChange: (allSelectedItems, selectedItem) {
context.read<NetzachBloc>().add(
NetzachSystemNotificationFilterSetEvent(
SystemNotificationFilter(
levelFilter: allSelectedItems,
typeFilter: filter.typeFilter,
),
),
),
);
},
decoration: BoxDecoration(
borderRadius: SpacingHelper.defaultBorderRadius,
),
),
);
},
)
],
),
const SizedBox(width: 8),
DecoratedBox(
decoration: BoxDecoration(
border: Border.all(color: Theme.of(context).primaryColor),
borderRadius: SpacingHelper.defaultBorderRadius,
),
child: MultiSelectDialogField(
title: const Text('按通知类型筛选'),
buttonText: const Text('类型'),
buttonIcon: const Icon(Icons.filter_alt_outlined),
items: [
MultiSelectItem(
SystemNotificationType
.SYSTEM_NOTIFICATION_TYPE_SYSTEM,
systemNotificationTypeString(SystemNotificationType
.SYSTEM_NOTIFICATION_TYPE_SYSTEM),
),
MultiSelectItem(
SystemNotificationType.SYSTEM_NOTIFICATION_TYPE_USER,
systemNotificationTypeString(SystemNotificationType
.SYSTEM_NOTIFICATION_TYPE_USER),
const SizedBox(
width: 8,
height: 8,
),
Row(
children: [
const Text('类型'),
const SizedBox(width: 8),
MultiSelectContainer(
prefix: MultiSelectPrefix(
selectedPrefix: const Padding(
padding: EdgeInsets.only(right: 5),
child: Icon(
Icons.check,
color: Colors.white,
size: 14,
),
),
),
],
onConfirm: (values) {
context.read<NetzachBloc>().add(
NetzachSystemNotificationFilterSetEvent(
SystemNotificationFilter(
levelFilter: filter.levelFilter,
typeFilter:
values.cast<SystemNotificationType>(),
items: [
MultiSelectCard(
value: SystemNotificationType
.SYSTEM_NOTIFICATION_TYPE_USER,
label: systemNotificationTypeString(
SystemNotificationType
.SYSTEM_NOTIFICATION_TYPE_USER),
selected: filter.typeFilter.contains(
SystemNotificationType
.SYSTEM_NOTIFICATION_TYPE_USER),
),
MultiSelectCard(
value: SystemNotificationType
.SYSTEM_NOTIFICATION_TYPE_SYSTEM,
label: systemNotificationTypeString(
SystemNotificationType
.SYSTEM_NOTIFICATION_TYPE_SYSTEM),
selected: filter.typeFilter.contains(
SystemNotificationType
.SYSTEM_NOTIFICATION_TYPE_SYSTEM),
),
],
onChange: (allSelectedItems, selectedItem) {
context.read<NetzachBloc>().add(
NetzachSystemNotificationFilterSetEvent(
SystemNotificationFilter(
levelFilter: filter.levelFilter,
typeFilter: allSelectedItems,
),
),
),
);
},
decoration: BoxDecoration(
borderRadius: SpacingHelper.defaultBorderRadius,
);
},
),
),
],
),
],
),
Expand All @@ -146,37 +180,44 @@ class NotificationPage extends StatelessWidget {
child: Text('暂无通知'),
)
else
ListView.builder(
itemCount: listData.length,
itemBuilder: (context, index) {
final item = listData.elementAt(index);
DynMouseScroll(
builder: (context, controller, physics) {
return ListView.builder(
controller: controller,
physics: physics,
itemCount: listData.length,
itemBuilder: (context, index) {
final item = listData.elementAt(index);

return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Card(
margin: EdgeInsets.zero,
shadowColor:
_systemNotificationLevelColor(item.level),
child: ExpansionTile(
leading: _systemNotificationLevelIcon(item.level),
title: Text(item.title),
subtitle: Text(
'${item.id.id.toHexString()} · ${DurationHelper.recentString(item.createTime.toDateTime())}',
style: TextStyle(
overflow: TextOverflow.ellipsis,
fontSize: 10,
color: Theme.of(context).disabledColor),
maxLines: 2,
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Card(
margin: EdgeInsets.zero,
shadowColor:
_systemNotificationLevelColor(item.level),
child: ExpansionTile(
leading:
_systemNotificationLevelIcon(item.level),
title: Text(item.title),
subtitle: Text(
'${item.id.id.toHexString()} · ${DurationHelper.recentString(item.createTime.toDateTime())}',
style: TextStyle(
overflow: TextOverflow.ellipsis,
fontSize: 10,
color: Theme.of(context).disabledColor),
maxLines: 2,
),
expandedAlignment: Alignment.centerLeft,
children: [
Container(
padding: const EdgeInsets.all(8),
child: Text(item.message),
)
],
),
),
expandedAlignment: Alignment.centerLeft,
children: [
Container(
padding: const EdgeInsets.all(8),
child: Text(item.message),
)
],
),
),
);
},
);
},
),
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ dependencies:
local_hero: ^0.3.0
auto_size_text: ^3.0.0
flip_card: ^0.7.0
flutter_multi_select_items: ^0.4.3

# rust bridge
ffi: ^2.0.1
Expand Down

0 comments on commit fcf933a

Please sign in to comment.