Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed dawood committed Dec 28, 2021
1 parent 1d904d9 commit 73c3d11
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions ready/lib/src/ready_list/config.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
part of ready_list;

typedef ShrinkWrapCallback = bool Function(ReadyListState controller);
typedef ReadyListWidgetBuilder<T> = List<Widget> Function(
ReadyListState<T> state);
typedef ReadyListWidgetBuilder<T> = List<Widget> Function(ReadyListState<T> state);
typedef GridDelegateCallback = SliverStaggeredGridDelegate Function({
required double width,
required int? length,
Expand Down Expand Up @@ -65,22 +64,47 @@ abstract class ReadyListConfigOptions {
/// whether to allow infinite scroll or not
bool? get allowLoadNext;

/// The text to displayed when no more items
String? get noMoreText;

/// The text to display when items loaded but not fill the screen
String? get loadMoreText;

/// padding of the list
EdgeInsetsGeometry? get padding;

/// whether to reverse the list or not
bool? get reverse;

/// gradient of shimmer scope
GradientGetterCallback? get shimmerScopeGradient;

/// if this is true the the item that passed to builder item may be null
/// useful to display shimmer
bool? get allowFakeItems;

/// whether to shrink-wrap or not
ShrinkWrapCallback? get shrinkWrap;

/// axis of the list
Axis? get axis;

/// physics of the list
ScrollPhysics? get physics;

/// The first items in the list
/// This can be configured globally
List<Widget>? get topLevelFooterSlivers;

/// The last items in the list
/// This can be configured globally
List<Widget>? get topLevelHeaderSlivers;

/// page size to be passed to controller loadData
int? get pageSize;
}

class ReadyListConfig extends InheritedWidget
implements ReadyListConfigOptions {
class ReadyListConfig extends InheritedWidget implements ReadyListConfigOptions {
@override
final PlaceholdersConfig? placeholdersConfig;
@override
Expand Down Expand Up @@ -212,27 +236,21 @@ class _ReadyListConfigOptionsDefauls implements ReadyListConfigOptions {
required this.allowFakeItems,
});

static _ReadyListConfigOptionsDefauls effective(
ReadyListConfigOptions? options, BuildContext context) {
static _ReadyListConfigOptionsDefauls effective(ReadyListConfigOptions? options, BuildContext context) {
var tr = Ready.localization(context);
var cofig = ReadyListConfig.of(context);
return _ReadyListConfigOptionsDefauls(
placeholdersConfig: options?.placeholdersConfig ??
cofig?.placeholdersConfig ??
PlaceholdersConfig(),
topLevelFooterSlivers:
options?.topLevelFooterSlivers ?? cofig?.topLevelFooterSlivers,
topLevelHeaderSlivers:
options?.topLevelHeaderSlivers ?? cofig?.topLevelHeaderSlivers,
placeholdersConfig: options?.placeholdersConfig ?? cofig?.placeholdersConfig ?? PlaceholdersConfig(),
topLevelFooterSlivers: options?.topLevelFooterSlivers ?? cofig?.topLevelFooterSlivers,
topLevelHeaderSlivers: options?.topLevelHeaderSlivers ?? cofig?.topLevelHeaderSlivers,
showNoMoreText: options?.showNoMoreText ?? cofig?.showNoMoreText ?? true,
allowRefresh: options?.allowRefresh ?? cofig?.allowRefresh ?? true,
allowLoadNext: options?.allowLoadNext ?? cofig?.allowLoadNext ?? true,
noMoreText: options?.noMoreText ?? cofig?.noMoreText ?? tr.noMoreItems,
loadMoreText: options?.loadMoreText ?? cofig?.loadMoreText ?? tr.loadMore,
padding: options?.padding ?? cofig?.padding,
reverse: options?.reverse ?? cofig?.reverse ?? false,
shimmerScopeGradient:
options?.shimmerScopeGradient ?? cofig?.shimmerScopeGradient,
shimmerScopeGradient: options?.shimmerScopeGradient ?? cofig?.shimmerScopeGradient,
shrinkWrap: options?.shrinkWrap ?? cofig?.shrinkWrap ?? (_) => false,
axis: options?.axis ?? cofig?.axis ?? Axis.vertical,
physics: options?.physics ?? cofig?.physics,
Expand Down

0 comments on commit 73c3d11

Please sign in to comment.