Skip to content

Commit

Permalink
feat(*): Use SnackBar instead of toast
Browse files Browse the repository at this point in the history
  • Loading branch information
realth000 committed Jan 21, 2024
1 parent 7803b0f commit fe8d1d3
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- 更新隐藏区域卡片上的按钮样式,更明显。
- 如果帖子的评分消息中评分理由为空,不显示评分理由。
- 登录后,加载首页的时机推迟到访问首页时,而不是登录后直接加载。
- 帖子已经加载完时不再显示toast,而是显示snack bar。

## [0.3.0] - 2023-12-30

Expand Down
2 changes: 1 addition & 1 deletion lib/features/forum/view/forum_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class _ForumPageState extends State<ForumPage>
if (state.currentPage >= state.totalPages) {
debug('already in last page');
_refreshController.finishLoad(IndicatorResult.noMore);
await showNoMoreToast(context);
await showNoMoreSnackBar(context);
return;
}
// Load the next page.
Expand Down
2 changes: 1 addition & 1 deletion lib/features/thread/widgets/post_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class _PostListState<T> extends State<PostList> {
return;
}
if (!widget.canLoadMore) {
await showNoMoreToast(context);
await showNoMoreSnackBar(context);
_refreshController.finishLoad();
return;
}
Expand Down
22 changes: 5 additions & 17 deletions lib/utils/show_toast.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
import 'package:flutter/cupertino.dart';
import 'package:toastification/toastification.dart';
import 'package:flutter/material.dart';
import 'package:tsdm_client/generated/i18n/strings.g.dart';

Future<void> showRetryToast(BuildContext context) async {
toastification.show(
context: context,
title: context.t.general.loadFailedAndRetry,
autoCloseDuration: const Duration(seconds: 3),
);
await Future.wait([Future.delayed(const Duration(milliseconds: 400), () {})]);
}

Future<void> showNoMoreToast(BuildContext context) async {
toastification.show(
context: context,
title: context.t.general.noMoreData,
autoCloseDuration: const Duration(seconds: 3),
);
Future<void> showNoMoreSnackBar(BuildContext context) async {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(context.t.general.noMoreData),
));
}
24 changes: 0 additions & 24 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.2"
iconsax_flutter:
dependency: transitive
description:
name: iconsax_flutter
sha256: "95b65699da8ea98f87c5d232f06b0debaaf1ec1332b697e4d90969ec9a93037d"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.0"
image:
dependency: transitive
description:
Expand Down Expand Up @@ -710,14 +702,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.1"
pausable_timer:
dependency: transitive
description:
name: pausable_timer
sha256: "35b1f77eb2fb0f42e823360321fbed9b9a8b1c7043a07a58aeda17d01f84659a"
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.0+1"
permission_handler:
dependency: "direct main"
description:
Expand Down Expand Up @@ -987,14 +971,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.1"
toastification:
dependency: "direct main"
description:
name: toastification
sha256: "14e7f9178db0393df00509cd921de3d3db310d06c7c122e873f31d3c8d18cf4e"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
typed_data:
dependency: transitive
description:
Expand Down
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ dependencies:
slang_flutter: ^3.28.0
stream_transform: ^2.1.0
surf_lint_rules: ^3.0.0
toastification: ^1.1.0
universal_html: ^2.2.4
url_launcher: ^6.2.3
uuid: ^4.3.3
Expand Down

0 comments on commit fe8d1d3

Please sign in to comment.