feat : new UI
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/utils/network/resource.dart';
|
||||
|
||||
import 'r_shimmer_list.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
enum ListType { builder, separated }
|
||||
|
||||
@@ -21,7 +19,9 @@ class RPaginatedListView<T> extends StatelessWidget {
|
||||
this.emptyWidget,
|
||||
this.errorWidget,
|
||||
this.scrollController,
|
||||
this.padding = const EdgeInsets.all(8.0),
|
||||
this.listType = ListType.builder,
|
||||
this.physics = const BouncingScrollPhysics(),
|
||||
});
|
||||
|
||||
final Resource<List<T>> resource;
|
||||
@@ -37,11 +37,17 @@ class RPaginatedListView<T> extends StatelessWidget {
|
||||
final Widget? errorWidget;
|
||||
final ScrollController? scrollController;
|
||||
final ListType listType;
|
||||
final EdgeInsets padding;
|
||||
final ScrollPhysics physics;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (resource.isLoading) {
|
||||
/* if (resource.isLoading) {
|
||||
return loadingWidget ?? RShimmerList(isSeparated: listType == ListType.separated);
|
||||
}*/
|
||||
|
||||
if (resource.isLoading) {
|
||||
return loadingWidget ?? const LoadingWidget();
|
||||
}
|
||||
|
||||
if (resource.isError) {
|
||||
@@ -49,23 +55,28 @@ class RPaginatedListView<T> extends StatelessWidget {
|
||||
}
|
||||
|
||||
if (resource.isEmpty || resource.data?.isEmpty == true) {
|
||||
return emptyWidget ?? const Center(child: Text('آیتمی یافت نشد'));
|
||||
return emptyWidget ?? const EmptyWidget();
|
||||
}
|
||||
|
||||
final controller = scrollController ?? ScrollController();
|
||||
|
||||
return NotificationListener<ScrollNotification>(
|
||||
onNotification: (ScrollNotification scrollInfo) {
|
||||
if (!isPaginating && hasMore && scrollInfo.metrics.pixels >= scrollInfo.metrics.maxScrollExtent - 100) {
|
||||
if (!isPaginating &&
|
||||
hasMore &&
|
||||
scrollInfo.metrics.pixels >= scrollInfo.metrics.maxScrollExtent - 100) {
|
||||
onLoadMore();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: RefreshIndicator(
|
||||
color: AppColor.blueNormal,
|
||||
onRefresh: onRefresh ?? () async {},
|
||||
child: listType == ListType.separated
|
||||
? ListView.separated(
|
||||
padding: padding,
|
||||
controller: controller,
|
||||
shrinkWrap: true,
|
||||
itemCount: itemCount + (isPaginating ? 1 : 0),
|
||||
itemBuilder: (context, index) {
|
||||
if (isPaginating && index == itemCount) {
|
||||
@@ -79,7 +90,9 @@ class RPaginatedListView<T> extends StatelessWidget {
|
||||
separatorBuilder: separatorBuilder ?? (_, __) => const SizedBox(height: 8),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: padding,
|
||||
controller: controller,
|
||||
shrinkWrap: true,
|
||||
itemCount: itemCount + (isPaginating ? 1 : 0),
|
||||
itemBuilder: (context, index) {
|
||||
if (isPaginating && index == itemCount) {
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
export 'app_bar/r_app_bar.dart';
|
||||
export 'bottom_navigation/r_bottom_navigation.dart';
|
||||
export 'bottom_navigation/wave_bottom_navigation.dart';
|
||||
export 'bottom_sheet/base_bottom_sheet.dart';
|
||||
export 'buttons/elevated.dart';
|
||||
export 'buttons/fab.dart';
|
||||
export 'buttons/outline_elevated.dart';
|
||||
export 'buttons/outline_elevated_icon.dart';
|
||||
export 'buttons/text_button.dart';
|
||||
export 'card/card_with_icon_with_border.dart';
|
||||
export 'chips/r_chips.dart';
|
||||
export 'draggable_bottom_sheet/bottom_sheet_manger.dart';
|
||||
export 'draggable_bottom_sheet/draggable_bottom_sheet.dart';
|
||||
export 'draggable_bottom_sheet/draggable_bottom_sheet2.dart';
|
||||
export 'draggable_bottom_sheet/draggable_bottom_sheet_controller.dart';
|
||||
export 'draggable_bottom_sheet/bottom_sheet_manger.dart';
|
||||
export 'inputs/input_fixed_hint.dart';
|
||||
export 'inputs/r_input.dart';
|
||||
export 'list_view/list_view.dart';
|
||||
export 'overlay_dropdown_widget/view.dart';
|
||||
export 'pagination/pagination_from_until.dart';
|
||||
export 'pagination/show_more.dart';
|
||||
export 'tabs/new_tab.dart';
|
||||
export 'tabs/tab.dart';
|
||||
export 'vec_widget.dart';
|
||||
export 'card/card_with_icon_with_border.dart';
|
||||
export 'chips/r_chips.dart';
|
||||
export 'overlay_dropdown_widget/view.dart';
|
||||
export 'inputs/input_fixed_hint.dart';
|
||||
export 'bottom_sheet/base_bottom_sheet.dart';
|
||||
export 'buttons/fab.dart';
|
||||
export 'empty_widget.dart';
|
||||
export 'loading_widget.dart';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user