diff --git a/CHANGELOG.md b/CHANGELOG.md index 22edb153..2cc6f3d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - 支持筛选积分变更历史。 - 帖子内按页数显示分组。 - 现在在安卓和IOS上尝试使用和当前语言的应用标题。 +- 现在发送回复后会提示发送成功。 ### Fixed diff --git a/lib/features/thread/view/thread_page.dart b/lib/features/thread/view/thread_page.dart index 8099bc5e..706869a3 100644 --- a/lib/features/thread/view/thread_page.dart +++ b/lib/features/thread/view/thread_page.dart @@ -190,122 +190,128 @@ class _ThreadPageState extends State create: (context) => JumpPageCubit(), ), ], - child: BlocListener( - listener: (context, state) { - // Update reply parameters to reply bar. - context - .read() - .add(ReplyParametersUpdated(state.replyParameters)); - - // Update thread closed state to reply bar. - if (state.threadClosed) { - context - .read() - .add(const ReplyThreadClosed(closed: true)); - } else { - context - .read() - .add(const ReplyThreadClosed(closed: false)); - } - }, - child: BlocListener( - listener: (context, state) { - if (state.status == ThreadStatus.failed) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text(context.t.general.failedToLoad)), - ); - } - }, - child: BlocBuilder( - builder: (context, state) { - // Update jump page state. - context.read().setPageInfo( - currentPage: state.currentPage, - totalPages: state.totalPages, - ); + child: MultiBlocListener( + listeners: [ + BlocListener( + listener: (context, state) { + // Update reply parameters to reply bar. + context + .read() + .add(ReplyParametersUpdated(state.replyParameters)); - String? title; - - // Reset jump page state when every build. - if (state.status == ThreadStatus.loading || - state.status == ThreadStatus.initial) { - context.read().markLoading(); - title = widget.title; + // Update thread closed state to reply bar. + if (state.threadClosed) { + context + .read() + .add(const ReplyThreadClosed(closed: true)); } else { - context.read().markSuccess(); + context + .read() + .add(const ReplyThreadClosed(closed: false)); } - - var threadUrl = - RepositoryProvider.of(context).threadUrl; - if (widget.threadID != null) { - threadUrl ??= '$baseUrl/forum.php?mod=viewthread&' - 'tid=${widget.threadID}&extra=page%3D1'; - } else { - // Here we don;t have threadID, thus the findPostID is - // definitely not null. - threadUrl ??= '$baseUrl/forum.php?mode=redirect&goto=findpost&' - 'pid=${widget.findPostID}'; + if (state.status == ThreadStatus.failed) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(context.t.general.failedToLoad)), + ); + } + }, + ), + BlocListener( + listener: (context, state) { + if (state.status == ReplyStatus.success) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text(context.t.threadPage.replySuccess)), + ); } + }, + ), + ], + child: BlocBuilder( + builder: (context, state) { + // Update jump page state. + context.read().setPageInfo( + currentPage: state.currentPage, + totalPages: state.totalPages, + ); + + String? title; + + // Reset jump page state when every build. + if (state.status == ThreadStatus.loading || + state.status == ThreadStatus.initial) { + context.read().markLoading(); + title = widget.title; + } else { + context.read().markSuccess(); + } - return Scaffold( - appBar: ListAppBar( - title: title, - showReverseOrderAction: true, - onSearch: () async { - await context.pushNamed(ScreenPaths.search); - }, - onJumpPage: (pageNumber) async { - if (!mounted) { - return; - } - // Mark loading here. - // Mark state will be removed when loading finishes - // in next build. - context.read().markLoading(); - context - .read() - .add(ThreadJumpPageRequested(pageNumber)); - }, - onSelected: (value) async { - switch (value) { - case MenuActions.refresh: - context - .read() - .add(ThreadRefreshRequested()); + var threadUrl = + RepositoryProvider.of(context).threadUrl; + if (widget.threadID != null) { + threadUrl ??= '$baseUrl/forum.php?mod=viewthread&' + 'tid=${widget.threadID}&extra=page%3D1'; + } else { + // Here we don;t have threadID, thus the findPostID is + // definitely not null. + threadUrl ??= '$baseUrl/forum.php?mode=redirect&goto=findpost&' + 'pid=${widget.findPostID}'; + } - case MenuActions.copyUrl: - await Clipboard.setData( - ClipboardData(text: threadUrl!), - ); - if (!context.mounted) { - return; - } - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - context.t.aboutPage.copiedToClipboard, - ), + return Scaffold( + appBar: ListAppBar( + title: title, + showReverseOrderAction: true, + onSearch: () async { + await context.pushNamed(ScreenPaths.search); + }, + onJumpPage: (pageNumber) async { + if (!mounted) { + return; + } + // Mark loading here. + // Mark state will be removed when loading finishes + // in next build. + context.read().markLoading(); + context + .read() + .add(ThreadJumpPageRequested(pageNumber)); + }, + onSelected: (value) async { + switch (value) { + case MenuActions.refresh: + context.read().add(ThreadRefreshRequested()); + case MenuActions.copyUrl: + await Clipboard.setData( + ClipboardData(text: threadUrl!), + ); + if (!context.mounted) { + return; + } + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + context.t.aboutPage.copiedToClipboard, ), - ); - case MenuActions.openInBrowser: - await context.dispatchAsUrl(threadUrl!, external: true); - case MenuActions.backToTop: - await _listScrollController.animateTo( - 0, - curve: Curves.ease, - duration: const Duration(milliseconds: 500), - ); - case MenuActions.reverseOrder: - context - .readOrNull() - ?.add(const ThreadChangeViewOrderRequested()); - } - }, - ), - body: _buildBody(context, state), - ); - }, - ), + ), + ); + case MenuActions.openInBrowser: + await context.dispatchAsUrl(threadUrl!, external: true); + case MenuActions.backToTop: + await _listScrollController.animateTo( + 0, + curve: Curves.ease, + duration: const Duration(milliseconds: 500), + ); + case MenuActions.reverseOrder: + context + .readOrNull() + ?.add(const ThreadChangeViewOrderRequested()); + } + }, + ), + body: _buildBody(context, state), + ); + }, ), ), );