Skip to content

Commit be577e8

Browse files
committed
revert(notification): remove search page
Several issues in search, not planned now.
1 parent 9d7d3bb commit be577e8

File tree

1 file changed

+112
-136
lines changed

1 file changed

+112
-136
lines changed

lib/features/notification/view/notification_page.dart

Lines changed: 112 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,19 @@ class _NotificationPageState extends State<NotificationPage> with SingleTickerPr
4040
return Align(
4141
child: LayoutBuilder(
4242
builder:
43-
(context, constraints) =>
44-
SingleChildScrollView(
43+
(context, constraints) => SingleChildScrollView(
4544
physics: const AlwaysScrollableScrollPhysics(),
4645
child: ConstrainedBox(
4746
constraints: BoxConstraints(
48-
minWidth: MediaQuery
49-
.sizeOf(context)
50-
.width,
47+
minWidth: MediaQuery.sizeOf(context).width,
5148
minHeight: constraints.maxHeight,
5249
),
5350
child: Center(
5451
child: Text(
5552
context.t.general.noData,
56-
style: Theme
57-
.of(
53+
style: Theme.of(
5854
context,
59-
)
60-
.textTheme
61-
.titleMedium
62-
?.copyWith(color: Theme
63-
.of(context)
64-
.colorScheme
65-
.outline),
55+
).textTheme.titleMedium?.copyWith(color: Theme.of(context).colorScheme.outline),
6656
),
6757
),
6858
),
@@ -97,15 +87,9 @@ class _NotificationPageState extends State<NotificationPage> with SingleTickerPr
9787
if (state.status == NotificationStatus.failure) {
9888
showFailedToLoadSnackBar(context);
9989
} else if (state.status == NotificationStatus.success) {
100-
final n = state.noticeList
101-
.where((e) => !e.alreadyRead)
102-
.length;
103-
final pm = state.personalMessageList
104-
.where((e) => !e.alreadyRead)
105-
.length;
106-
final bm = state.broadcastMessageList
107-
.where((e) => !e.alreadyRead)
108-
.length;
90+
final n = state.noticeList.where((e) => !e.alreadyRead).length;
91+
final pm = state.personalMessageList.where((e) => !e.alreadyRead).length;
92+
final bm = state.broadcastMessageList.where((e) => !e.alreadyRead).length;
10993
context.read<NotificationStateCubit>().setAll(
11094
noticeCount: n,
11195
personalMessageCount: pm,
@@ -116,77 +100,74 @@ class _NotificationPageState extends State<NotificationPage> with SingleTickerPr
116100
child: BlocBuilder<NotificationBloc, NotificationState>(
117101
builder: (context, state) {
118102
final (n, pm, bm) = switch (onlyShowUnread) {
119-
true =>
120-
(
121-
state.noticeList.where((e) => !e.alreadyRead),
122-
state.personalMessageList.where((e) => !e.alreadyRead),
123-
state.broadcastMessageList.where((e) => !e.alreadyRead),
103+
true => (
104+
state.noticeList.where((e) => !e.alreadyRead),
105+
state.personalMessageList.where((e) => !e.alreadyRead),
106+
state.broadcastMessageList.where((e) => !e.alreadyRead),
124107
),
125108
false => (state.noticeList, state.personalMessageList, state.broadcastMessageList),
126109
};
127110

128111
final body = switch (state.status) {
129112
NotificationStatus.initial ||
130113
NotificationStatus.loading => const Center(child: CircularProgressIndicator()),
131-
NotificationStatus.success =>
132-
TabBarView(
133-
controller: _tabController,
134-
children: [
135-
EasyRefresh.builder(
136-
controller: _noticeRefreshController,
137-
header: const MaterialHeader(),
138-
onRefresh: () => context.read<NotificationBloc>().add(NotificationUpdateAllRequested()),
139-
childBuilder:
140-
(context, physics) =>
141-
n.isEmpty
142-
? _buildEmptyBody(context)
143-
: ListView.separated(
144-
physics: physics,
145-
padding: edgeInsetsL12T4R12B4,
146-
itemCount: n.length,
147-
itemBuilder: (_, idx) => NoticeCardV2(n.elementAt(idx)),
148-
separatorBuilder: (_, __) => sizedBoxW4H4,
149-
),
150-
),
151-
EasyRefresh.builder(
152-
controller: _personalMessageRefreshController,
153-
header: const MaterialHeader(),
154-
onRefresh: () => context.read<NotificationBloc>().add(NotificationUpdateAllRequested()),
155-
childBuilder:
156-
(context, physics) =>
157-
pm.isEmpty
158-
? _buildEmptyBody(context)
159-
: ListView.separated(
160-
physics: physics,
161-
padding: edgeInsetsL12T4R12B4,
162-
itemCount: pm.length,
163-
itemBuilder: (_, idx) => PersonalMessageCardV2(pm.elementAt(idx)),
164-
separatorBuilder: (_, __) => sizedBoxW4H4,
165-
),
166-
),
167-
EasyRefresh.builder(
168-
controller: _broadcastMessageRefreshController,
169-
header: const MaterialHeader(),
170-
onRefresh: () => context.read<NotificationBloc>().add(NotificationUpdateAllRequested()),
171-
childBuilder:
172-
(context, physics) =>
173-
bm.isEmpty
174-
? _buildEmptyBody(context)
175-
: ListView.separated(
176-
physics: physics,
177-
padding: edgeInsetsL12T4R12B4,
178-
itemCount: bm.length,
179-
itemBuilder: (_, idx) => BroadcastMessageCardV2(bm.elementAt(idx)),
180-
separatorBuilder: (_, __) => sizedBoxW4H4,
181-
),
182-
),
183-
],
114+
NotificationStatus.success => TabBarView(
115+
controller: _tabController,
116+
children: [
117+
EasyRefresh.builder(
118+
controller: _noticeRefreshController,
119+
header: const MaterialHeader(),
120+
onRefresh: () => context.read<NotificationBloc>().add(NotificationUpdateAllRequested()),
121+
childBuilder:
122+
(context, physics) =>
123+
n.isEmpty
124+
? _buildEmptyBody(context)
125+
: ListView.separated(
126+
physics: physics,
127+
padding: edgeInsetsL12T4R12B4,
128+
itemCount: n.length,
129+
itemBuilder: (_, idx) => NoticeCardV2(n.elementAt(idx)),
130+
separatorBuilder: (_, __) => sizedBoxW4H4,
131+
),
184132
),
185-
NotificationStatus.failure =>
186-
buildRetryButton(
187-
context,
188-
() => context.read<NotificationBloc>().add(NotificationUpdateAllRequested()),
133+
EasyRefresh.builder(
134+
controller: _personalMessageRefreshController,
135+
header: const MaterialHeader(),
136+
onRefresh: () => context.read<NotificationBloc>().add(NotificationUpdateAllRequested()),
137+
childBuilder:
138+
(context, physics) =>
139+
pm.isEmpty
140+
? _buildEmptyBody(context)
141+
: ListView.separated(
142+
physics: physics,
143+
padding: edgeInsetsL12T4R12B4,
144+
itemCount: pm.length,
145+
itemBuilder: (_, idx) => PersonalMessageCardV2(pm.elementAt(idx)),
146+
separatorBuilder: (_, __) => sizedBoxW4H4,
147+
),
189148
),
149+
EasyRefresh.builder(
150+
controller: _broadcastMessageRefreshController,
151+
header: const MaterialHeader(),
152+
onRefresh: () => context.read<NotificationBloc>().add(NotificationUpdateAllRequested()),
153+
childBuilder:
154+
(context, physics) =>
155+
bm.isEmpty
156+
? _buildEmptyBody(context)
157+
: ListView.separated(
158+
physics: physics,
159+
padding: edgeInsetsL12T4R12B4,
160+
itemCount: bm.length,
161+
itemBuilder: (_, idx) => BroadcastMessageCardV2(bm.elementAt(idx)),
162+
separatorBuilder: (_, __) => sizedBoxW4H4,
163+
),
164+
),
165+
],
166+
),
167+
NotificationStatus.failure => buildRetryButton(
168+
context,
169+
() => context.read<NotificationBloc>().add(NotificationUpdateAllRequested()),
170+
),
190171
};
191172
return Scaffold(
192173
appBar: AppBar(
@@ -200,45 +181,45 @@ class _NotificationPageState extends State<NotificationPage> with SingleTickerPr
200181
setState(() => onlyShowUnread = !onlyShowUnread);
201182
},
202183
),
203-
IconButton(
204-
icon: const Icon(Icons.saved_search_outlined),
205-
onPressed: () => context.pushNamed(ScreenPaths.noticeSearch),
206-
),
184+
// TODO: Notification search.
185+
// IconButton(
186+
// icon: const Icon(Icons.saved_search_outlined),
187+
// onPressed: () => context.pushNamed(ScreenPaths.noticeSearch),
188+
// ),
207189
PopupMenuButton<_Actions>(
208190
itemBuilder:
209-
(_) =>
210-
[
211-
PopupMenuItem(
212-
value: _Actions.markAllNoticeAsRead,
213-
child: Row(
214-
children: [
215-
const Icon(Icons.notifications_paused_outlined),
216-
sizedBoxPopupMenuItemIconSpacing,
217-
Text(tr.cardMenu.markAllNoticeAsRead),
218-
],
219-
),
220-
),
221-
PopupMenuItem(
222-
value: _Actions.markAllPersonalMessageAsRead,
223-
child: Row(
224-
children: [
225-
const Icon(Icons.notifications_active_outlined),
226-
sizedBoxPopupMenuItemIconSpacing,
227-
Text(tr.cardMenu.markAllPersonalMessageAsRead),
228-
],
229-
),
230-
),
231-
PopupMenuItem(
232-
value: _Actions.markAllBroadcastMessageAsRead,
233-
child: Row(
234-
children: [
235-
const Icon(Icons.notification_important_outlined),
236-
sizedBoxPopupMenuItemIconSpacing,
237-
Text(tr.cardMenu.markAllBroadcastMessageAsRead),
238-
],
239-
),
240-
),
241-
],
191+
(_) => [
192+
PopupMenuItem(
193+
value: _Actions.markAllNoticeAsRead,
194+
child: Row(
195+
children: [
196+
const Icon(Icons.notifications_paused_outlined),
197+
sizedBoxPopupMenuItemIconSpacing,
198+
Text(tr.cardMenu.markAllNoticeAsRead),
199+
],
200+
),
201+
),
202+
PopupMenuItem(
203+
value: _Actions.markAllPersonalMessageAsRead,
204+
child: Row(
205+
children: [
206+
const Icon(Icons.notifications_active_outlined),
207+
sizedBoxPopupMenuItemIconSpacing,
208+
Text(tr.cardMenu.markAllPersonalMessageAsRead),
209+
],
210+
),
211+
),
212+
PopupMenuItem(
213+
value: _Actions.markAllBroadcastMessageAsRead,
214+
child: Row(
215+
children: [
216+
const Icon(Icons.notification_important_outlined),
217+
sizedBoxPopupMenuItemIconSpacing,
218+
Text(tr.cardMenu.markAllBroadcastMessageAsRead),
219+
],
220+
),
221+
),
222+
],
242223
onSelected: (value) async {
243224
final noticeType = switch (value) {
244225
_Actions.markAllNoticeAsRead => NotificationType.notice,
@@ -278,21 +259,16 @@ class _PreferredSizeComponentBottom extends StatelessWidget implements Preferred
278259
builder: (context, state) {
279260
return switch (state) {
280261
AutoNoticeStateStopped() => sizedBoxW2H2,
281-
AutoNoticeStateTicking(:final total, :final remain) =>
282-
LinearProgressIndicator(
283-
value: math.max(1 - remain.inSeconds / total.inSeconds, 0),
284-
minHeight: 2,
285-
),
262+
AutoNoticeStateTicking(:final total, :final remain) => LinearProgressIndicator(
263+
value: math.max(1 - remain.inSeconds / total.inSeconds, 0),
264+
minHeight: 2,
265+
),
286266
AutoNoticeStatePending() => const LinearProgressIndicator(minHeight: 2),
287-
AutoNoticeStatePaused(:final total, :final remain) =>
288-
LinearProgressIndicator(
289-
value: math.max(1 - remain.inSeconds / total.inSeconds, 0),
290-
minHeight: 2,
291-
color: Theme
292-
.of(context)
293-
.colorScheme
294-
.outline,
295-
),
267+
AutoNoticeStatePaused(:final total, :final remain) => LinearProgressIndicator(
268+
value: math.max(1 - remain.inSeconds / total.inSeconds, 0),
269+
minHeight: 2,
270+
color: Theme.of(context).colorScheme.outline,
271+
),
296272
};
297273
},
298274
),

0 commit comments

Comments
 (0)