Skip to content

Commit 5f24279

Browse files
committed
fix: Fix notification pagination logic and adjust icon text alignment
- `NotifyPage`: Update pagination to start at index 1, implement `_hasMore` state tracking to prevent unnecessary load requests, and fix refresh logic. - `GSYIconText`: Change `Row` alignment to `CrossAxisAlignment.center` and remove baseline configuration. - `pubspec.lock`: Downgrade `meta` dependency version.
1 parent 2351bd5 commit 5f24279

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

lib/page/notify/notify_page.dart

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class _NotifyPageState extends State<NotifyPage>
3737

3838
late Completer<bool> isLoading;
3939

40+
bool _hasMore = true;
41+
4042
late var notifySignal = createListSignal<Model.Notification>([]);
4143
late var notifyIndexSignal = createSignal<int>(0);
4244
late var signalPage = createSignal<int>(-1);
@@ -58,12 +60,13 @@ class _NotifyPageState extends State<NotifyPage>
5860
DataResult res = await _getDataLogic(signalPage.value);
5961
if (res.result && res.data is List<Model.Notification>) {
6062
var data = res.data as List<Model.Notification>;
61-
if (data.length < Config.PAGE_SIZE) {
62-
controller.finishLoad(IndicatorResult.noMore);
63-
} else {
63+
_hasMore = data.length >= Config.PAGE_SIZE;
64+
if (_hasMore) {
6465
controller.finishLoad(IndicatorResult.success);
66+
} else {
67+
controller.finishLoad(IndicatorResult.noMore);
6568
}
66-
if (signalPage.value == 0) {
69+
if (signalPage.value == 1) {
6770
notifySignal.value = data;
6871
} else {
6972
notifySignal.addAll(data);
@@ -142,15 +145,20 @@ class _NotifyPageState extends State<NotifyPage>
142145
}
143146

144147
requestLoadMore() async {
148+
if (!_hasMore) {
149+
controller.finishLoad(IndicatorResult.noMore);
150+
return;
151+
}
145152
isLoading = Completer<bool>();
146153
signalPage.value++;
147154
await isLoading.future;
148155
}
149156

150157
requestRefresh() async {
151158
isLoading = Completer<bool>();
159+
_hasMore = true;
152160
controller.finishLoad(IndicatorResult.none);
153-
signalPage.value = 0;
161+
signalPage.value = 1;
154162
await isLoading.future;
155163
}
156164

lib/widget/gsy_icon_text.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ class GSYIConText extends StatelessWidget {
6161
));
6262

6363
return Row(
64-
textBaseline: TextBaseline.alphabetic,
6564
mainAxisAlignment: mainAxisAlignment,
6665
mainAxisSize: mainAxisSize,
67-
crossAxisAlignment: CrossAxisAlignment.baseline,
66+
crossAxisAlignment: CrossAxisAlignment.center,
6867
children: <Widget>[
6968
Icon(
7069
iconData,

pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,10 +770,10 @@ packages:
770770
dependency: "direct main"
771771
description:
772772
name: meta
773-
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
773+
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
774774
url: "https://pub.flutter-io.cn"
775775
source: hosted
776-
version: "1.17.0"
776+
version: "1.16.0"
777777
mime:
778778
dependency: transitive
779779
description:

0 commit comments

Comments
 (0)