Skip to content

Commit

Permalink
fixup! TW-732 Load more in add member in group need support mouse scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
drminh2807 authored and hoangdat committed Oct 5, 2023
1 parent d31f6a8 commit f5cd8eb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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(
Expand All @@ -30,23 +33,13 @@ 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(),
),
)
],
),
);
}
}

class _LoadingIndicator extends StatelessWidget {
const _LoadingIndicator();

@override
Widget build(BuildContext context) {
return const Padding(
padding: EdgeInsets.all(16),
child: Center(child: CircularProgressIndicator()),
);
}
}
Original file line number Diff line number Diff line change
@@ -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()),
);
}
}
30 changes: 11 additions & 19 deletions lib/widgets/twake_components/twake_smart_refresher.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -37,11 +38,11 @@ class TwakeRefreshController {
}

void onLoading() {
loadNotifier.value = true;
loadingNotifier.value = true;
}

void loadComplete() {
loadNotifier.value = false;
loadingNotifier.value = false;
}
}

Expand Down Expand Up @@ -102,30 +103,21 @@ 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(),
),
)
],
),
);
}
}

class _LoadingIndicator extends StatelessWidget {
const _LoadingIndicator();

@override
Widget build(BuildContext context) {
return const Padding(
padding: EdgeInsets.all(16),
child: Center(child: CircularProgressIndicator()),
);
}
}

0 comments on commit f5cd8eb

Please sign in to comment.