Skip to content

Commit

Permalink
Merge pull request #562 from Lay523/v3
Browse files Browse the repository at this point in the history
ClassicHeader、ClassicFooter add IconThemeData
  • Loading branch information
xuelongqy authored Jul 10, 2022
2 parents a531eb6 + 2b41bbe commit b701136
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions example/lib/page/style/classical_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ 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 @@ -71,6 +72,7 @@ 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
11 changes: 9 additions & 2 deletions lib/src/styles/classic/classic_indicator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class _ClassicIndicator extends StatefulWidget {
/// Link [Stack.clipBehavior].
final Clip clipBehavior;

/// Icon style.
final IconThemeData? iconTheme;

const _ClassicIndicator({
Key? key,
required this.state,
Expand Down Expand Up @@ -126,6 +129,7 @@ class _ClassicIndicator extends StatefulWidget {
this.messageStyle,
this.messageBuilder,
this.clipBehavior = Clip.hardEdge,
this.iconTheme
}) : assert(
mainAxisAlignment == MainAxisAlignment.start ||
mainAxisAlignment == MainAxisAlignment.center ||
Expand Down Expand Up @@ -246,6 +250,7 @@ class _ClassicIndicatorState extends State<_ClassicIndicator>
/// Build icon.
Widget _buildIcon() {
Widget icon;
final iconTheme = widget.iconTheme ?? Theme.of(context).iconTheme;
if (_result == IndicatorResult.noMore) {
icon = SizedBox(
key: const ValueKey(IndicatorResult.noMore),
Expand All @@ -262,7 +267,7 @@ class _ClassicIndicatorState extends State<_ClassicIndicator>
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Theme.of(context).iconTheme.color,
color: iconTheme.color,
),
);
} else if (_mode == IndicatorMode.processed ||
Expand Down Expand Up @@ -304,6 +309,8 @@ class _ClassicIndicatorState extends State<_ClassicIndicator>
),
);
}


return AnimatedSwitcher(
key: _iconAnimatedSwitcherKey,
duration: const Duration(milliseconds: 300),
Expand All @@ -317,7 +324,7 @@ class _ClassicIndicatorState extends State<_ClassicIndicator>
opacity: animation,
);
},
child: icon,
child: IconTheme.merge(data: iconTheme, child: icon),
);
}

Expand Down
6 changes: 6 additions & 0 deletions lib/src/styles/classic/footer/classic_footer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class ClassicFooter extends Footer {
/// Link [Stack.clipBehavior].
final Clip clipBehavior;

/// Icon style.
final IconThemeData? iconTheme;


const ClassicFooter({
this.key,
double triggerOffset = 70,
Expand Down Expand Up @@ -119,6 +123,7 @@ class ClassicFooter extends Footer {
this.messageStyle,
this.messageBuilder,
this.clipBehavior = Clip.hardEdge,
this.iconTheme
}) : super(
triggerOffset: triggerOffset,
clamping: clamping,
Expand Down Expand Up @@ -165,6 +170,7 @@ class ClassicFooter extends Footer {
messageStyle: messageStyle,
messageBuilder: messageBuilder,
clipBehavior: clipBehavior,
iconTheme: iconTheme
);
}
}
5 changes: 5 additions & 0 deletions lib/src/styles/classic/header/classic_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class ClassicHeader extends Header {
/// Link [Stack.clipBehavior].
final Clip clipBehavior;

/// Icon style.
final IconThemeData? iconTheme;

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

0 comments on commit b701136

Please sign in to comment.