From f5cd8eb8ef97da03538bacbc3a11316a773a5f81 Mon Sep 17 00:00:00 2001 From: MinhDV Date: Tue, 3 Oct 2023 20:08:59 +0700 Subject: [PATCH] fixup! TW-732 Load more in add member in group need support mouse scroll --- .../same_type_events_list_builder_view.dart | 21 +++++-------- .../center_loading_indicator.dart | 13 ++++++++ .../twake_smart_refresher.dart | 30 +++++++------------ 3 files changed, 31 insertions(+), 33 deletions(-) create mode 100644 lib/widgets/twake_components/twake_loading/center_loading_indicator.dart diff --git a/lib/pages/chat_details/chat_details_page_view/same_type_events_list_builder_view.dart b/lib/pages/chat_details/chat_details_page_view/same_type_events_list_builder_view.dart index 4f357fe159..9e92cbdef7 100644 --- a/lib/pages/chat_details/chat_details_page_view/same_type_events_list_builder_view.dart +++ b/lib/pages/chat_details/chat_details_page_view/same_type_events_list_builder_view.dart @@ -1,4 +1,5 @@ import 'package:fluffychat/pages/chat_details/chat_details_page_view/same_type_events_list_controller.dart'; +import 'package:fluffychat/widgets/twake_components/twake_loading/center_loading_indicator.dart'; import 'package:flutter/material.dart'; class SameTypeEventsListBuilderView extends StatelessWidget { @@ -19,7 +20,9 @@ class SameTypeEventsListBuilderView extends StatelessWidget { ValueListenableBuilder( valueListenable: controller.refreshing, builder: (context, refreshing, child) => SliverToBoxAdapter( - child: refreshing ? const _LoadingIndicator() : const SizedBox(), + child: refreshing + ? const CenterLoadingIndicator() + : const SizedBox(), ), ), ValueListenableBuilder( @@ -30,7 +33,9 @@ class SameTypeEventsListBuilderView extends StatelessWidget { ValueListenableBuilder( valueListenable: controller.loadingMore, builder: (context, loadingMore, child) => SliverToBoxAdapter( - child: loadingMore ? const _LoadingIndicator() : const SizedBox(), + child: loadingMore + ? const CenterLoadingIndicator() + : const SizedBox(), ), ) ], @@ -38,15 +43,3 @@ class SameTypeEventsListBuilderView extends StatelessWidget { ); } } - -class _LoadingIndicator extends StatelessWidget { - const _LoadingIndicator(); - - @override - Widget build(BuildContext context) { - return const Padding( - padding: EdgeInsets.all(16), - child: Center(child: CircularProgressIndicator()), - ); - } -} diff --git a/lib/widgets/twake_components/twake_loading/center_loading_indicator.dart b/lib/widgets/twake_components/twake_loading/center_loading_indicator.dart new file mode 100644 index 0000000000..2f2e2a9b4c --- /dev/null +++ b/lib/widgets/twake_components/twake_loading/center_loading_indicator.dart @@ -0,0 +1,13 @@ +import 'package:flutter/material.dart'; + +class CenterLoadingIndicator extends StatelessWidget { + const CenterLoadingIndicator({super.key}); + + @override + Widget build(BuildContext context) { + return const Padding( + padding: EdgeInsets.all(16), + child: Center(child: CircularProgressIndicator()), + ); + } +} diff --git a/lib/widgets/twake_components/twake_smart_refresher.dart b/lib/widgets/twake_components/twake_smart_refresher.dart index ba43eafb47..25700d7dc1 100644 --- a/lib/widgets/twake_components/twake_smart_refresher.dart +++ b/lib/widgets/twake_components/twake_smart_refresher.dart @@ -1,3 +1,4 @@ +import 'package:fluffychat/widgets/twake_components/twake_loading/center_loading_indicator.dart'; import 'package:flutter/material.dart'; import 'package:fluffychat/utils/scroll_controller_extension.dart'; @@ -22,11 +23,11 @@ class TwakeSmartRefresher extends StatefulWidget { class TwakeRefreshController { final refreshNotifier = ValueNotifier(false); - final loadNotifier = ValueNotifier(false); + final loadingNotifier = ValueNotifier(false); final scrollController = ScrollController(); bool get isRefeshing => refreshNotifier.value; - bool get isLoading => loadNotifier.value; + bool get isLoading => loadingNotifier.value; void onRefresh() { refreshNotifier.value = true; @@ -37,11 +38,11 @@ class TwakeRefreshController { } void onLoading() { - loadNotifier.value = true; + loadingNotifier.value = true; } void loadComplete() { - loadNotifier.value = false; + loadingNotifier.value = false; } } @@ -102,14 +103,17 @@ class _TwakeSmartRefresherView extends StatelessWidget { ValueListenableBuilder( valueListenable: refreshController.refreshNotifier, builder: (context, refreshing, child) => SliverToBoxAdapter( - child: refreshing ? const _LoadingIndicator() : const SizedBox(), + child: refreshing + ? const CenterLoadingIndicator() + : const SizedBox(), ), ), ...slivers, ValueListenableBuilder( - valueListenable: refreshController.loadNotifier, + valueListenable: refreshController.loadingNotifier, builder: (context, loading, child) => SliverToBoxAdapter( - child: loading ? const _LoadingIndicator() : const SizedBox(), + child: + loading ? const CenterLoadingIndicator() : const SizedBox(), ), ) ], @@ -117,15 +121,3 @@ class _TwakeSmartRefresherView extends StatelessWidget { ); } } - -class _LoadingIndicator extends StatelessWidget { - const _LoadingIndicator(); - - @override - Widget build(BuildContext context) { - return const Padding( - padding: EdgeInsets.all(16), - child: Center(child: CircularProgressIndicator()), - ); - } -}