Skip to content

Commit

Permalink
feat: ClassicIndicator add [progressIndicatorSize] and [progressIndic…
Browse files Browse the repository at this point in the history
…atorStrokeWidth].
  • Loading branch information
xuelongqy committed Jul 10, 2022
1 parent b701136 commit 938fab3
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 13 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Change log

## Next
> fix: use notifyListeners after ChangeNotifier disposed. Thanks laiiihz for [PR#555](https://github.com/xuelongqy/flutter_easy_refresh/pull/555).
> feat: ClassicHeader、ClassicFooter add IconThemeData. Thanks Lay523 for [PR#562](https://github.com/xuelongqy/flutter_easy_refresh/pull/562).
> feat: ClassicIndicator add [progressIndicatorSize] and [progressIndicatorStrokeWidth].
## V 3.0.0+3
> fix: dart >=2.13.0.
> fix: The screen is not full, [infinite] can not reset.
> feat: HeaderLocator and FooterLocator add clearExtent.
> feat: HeaderLocator and FooterLocator add [clearExtent].
> feat: Add OverrideFooter and OverrideHeader.
## V 3.0.0+2
Expand Down
2 changes: 0 additions & 2 deletions example/lib/page/style/classical_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class _ClassicPageState extends State<ClassicPage> {
body: EasyRefresh(
controller: _controller,
header: ClassicHeader(
iconTheme: IconThemeData(color: Colors.green),
clamping: _headerProperties.clamping,
backgroundColor: _headerProperties.background
? Theme.of(context).colorScheme.surfaceVariant
Expand All @@ -72,7 +71,6 @@ class _ClassicPageState extends State<ClassicPage> {
messageText: 'Last updated at %T'.tr,
),
footer: ClassicFooter(
iconTheme: IconThemeData(color: Colors.green),
clamping: _footerProperties.clamping,
backgroundColor: _footerProperties.background
? Theme.of(context).colorScheme.surfaceVariant
Expand Down
29 changes: 23 additions & 6 deletions lib/src/styles/classic/classic_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ typedef CITextBuilder = Widget Function(
typedef CIMessageBuilder = Widget Function(
BuildContext context, IndicatorState state, String text, DateTime dateTime);

/// Default progress indicator size.
const _kDefaultProgressIndicatorSize = 20.0;

/// Default progress indicator stroke width.
const _kDefaultProgressIndicatorStrokeWidth = 2.0;

/// Classic indicator.
/// Base widget for [ClassicHeader] and [ClassicFooter].
class _ClassicIndicator extends StatefulWidget {
Expand Down Expand Up @@ -101,6 +107,13 @@ class _ClassicIndicator extends StatefulWidget {
/// Icon style.
final IconThemeData? iconTheme;

/// Progress indicator size.
final double? progressIndicatorSize;

/// Progress indicator stroke width.
/// See [CircularProgressIndicator.strokeWidth].
final double? progressIndicatorStrokeWidth;

const _ClassicIndicator({
Key? key,
required this.state,
Expand Down Expand Up @@ -129,7 +142,9 @@ class _ClassicIndicator extends StatefulWidget {
this.messageStyle,
this.messageBuilder,
this.clipBehavior = Clip.hardEdge,
this.iconTheme
this.iconTheme,
this.progressIndicatorSize,
this.progressIndicatorStrokeWidth,
}) : assert(
mainAxisAlignment == MainAxisAlignment.start ||
mainAxisAlignment == MainAxisAlignment.center ||
Expand Down Expand Up @@ -233,7 +248,7 @@ class _ClassicIndicatorState extends State<_ClassicIndicator>
return widget.processedText;
}
default:
return '';
return widget.dragText;
}
}

Expand Down Expand Up @@ -261,12 +276,15 @@ class _ClassicIndicatorState extends State<_ClassicIndicator>
);
} else if (_mode == IndicatorMode.processing ||
_mode == IndicatorMode.ready) {
final progressIndicatorSize =
widget.progressIndicatorSize ?? _kDefaultProgressIndicatorSize;
icon = SizedBox(
key: const ValueKey(IndicatorMode.processing),
width: 20,
height: 20,
width: progressIndicatorSize,
height: progressIndicatorSize,
child: CircularProgressIndicator(
strokeWidth: 2,
strokeWidth: widget.progressIndicatorStrokeWidth ??
_kDefaultProgressIndicatorStrokeWidth,
color: iconTheme.color,
),
);
Expand Down Expand Up @@ -310,7 +328,6 @@ class _ClassicIndicatorState extends State<_ClassicIndicator>
);
}


return AnimatedSwitcher(
key: _iconAnimatedSwitcherKey,
duration: const Duration(milliseconds: 300),
Expand Down
14 changes: 12 additions & 2 deletions lib/src/styles/classic/footer/classic_footer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ class ClassicFooter extends Footer {
/// Icon style.
final IconThemeData? iconTheme;

/// Progress indicator size.
final double? progressIndicatorSize;

/// Progress indicator stroke width.
/// See [CircularProgressIndicator.strokeWidth].
final double? progressIndicatorStrokeWidth;

const ClassicFooter({
this.key,
Expand Down Expand Up @@ -123,7 +129,9 @@ class ClassicFooter extends Footer {
this.messageStyle,
this.messageBuilder,
this.clipBehavior = Clip.hardEdge,
this.iconTheme
this.iconTheme,
this.progressIndicatorSize,
this.progressIndicatorStrokeWidth,
}) : super(
triggerOffset: triggerOffset,
clamping: clamping,
Expand Down Expand Up @@ -170,7 +178,9 @@ class ClassicFooter extends Footer {
messageStyle: messageStyle,
messageBuilder: messageBuilder,
clipBehavior: clipBehavior,
iconTheme: iconTheme
iconTheme: iconTheme,
progressIndicatorSize: progressIndicatorSize,
progressIndicatorStrokeWidth: progressIndicatorStrokeWidth,
);
}
}
15 changes: 13 additions & 2 deletions lib/src/styles/classic/header/classic_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ class ClassicHeader extends Header {
/// Icon style.
final IconThemeData? iconTheme;

/// Progress indicator size.
final double? progressIndicatorSize;

/// Progress indicator stroke width.
/// See [CircularProgressIndicator.strokeWidth].
final double? progressIndicatorStrokeWidth;

const ClassicHeader({
this.key,
double triggerOffset = 70,
Expand Down Expand Up @@ -122,7 +129,9 @@ class ClassicHeader extends Header {
this.messageStyle,
this.messageBuilder,
this.clipBehavior = Clip.hardEdge,
this.iconTheme
this.iconTheme,
this.progressIndicatorSize,
this.progressIndicatorStrokeWidth,
}) : super(
triggerOffset: triggerOffset,
clamping: clamping,
Expand Down Expand Up @@ -169,7 +178,9 @@ class ClassicHeader extends Header {
messageStyle: messageStyle,
messageBuilder: messageBuilder,
clipBehavior: clipBehavior,
iconTheme: iconTheme
iconTheme: iconTheme,
progressIndicatorSize: progressIndicatorSize,
progressIndicatorStrokeWidth: progressIndicatorStrokeWidth,
);
}
}

0 comments on commit 938fab3

Please sign in to comment.