Closed webMing closed 1 year ago
EasyRefresh.defaultFooterBuilder = () => const ClassicFooter(
iconDimension: 100,
showMessage: false,
showText: false,
pullIconBuilder: _buildIcon,
);
final GlobalKey iconAnimatedSwitcherKey = GlobalKey();
Widget _buildIcon(
BuildContext context, IndicatorState state, double animation) {
const double defaultProgressIndicatorSize = 20;
const double defaultProgressIndicatorStrokeWidth = 2;
final result = state.result;
final mode = state.mode;
final axis = state.axis;
Widget icon;
final iconTheme = Theme.of(context).iconTheme;
ValueKey iconKey;
if (result == IndicatorResult.noMore) {
iconKey = const ValueKey(IndicatorResult.noMore);
icon = const Text('~已经到底啦~');
} else if (mode == IndicatorMode.processing || mode == IndicatorMode.ready) {
iconKey = const ValueKey(IndicatorMode.processing);
icon = Row(
children: [
SizedBox(
width: defaultProgressIndicatorSize,
height: defaultProgressIndicatorSize,
child: CircularProgressIndicator(
strokeWidth: defaultProgressIndicatorStrokeWidth,
color: iconTheme.color,
),
),
const SizedBox(
width: 15,
),
const Text('加载中'),
],
);
} else if (mode == IndicatorMode.processed || mode == IndicatorMode.done) {
if (result == IndicatorResult.fail) {
iconKey = const ValueKey(IndicatorResult.fail);
icon = const SizedBox(
child: Text('加载失败'),
);
} else {
iconKey = const ValueKey(IndicatorResult.success);
icon = SizedBox(
child: Transform.rotate(
angle: axis == Axis.vertical ? 0 : -math.pi / 2,
child: const Text('加载完成'),
),
);
}
} else {
iconKey = const ValueKey(IndicatorMode.drag);
icon = SizedBox(
child: Transform.rotate(
angle: -math.pi * animation,
child: Icon((axis == Axis.vertical
? Icons.arrow_downward
: Icons.arrow_forward)),
),
);
}
return AnimatedSwitcher(
key: iconAnimatedSwitcherKey,
duration: const Duration(milliseconds: 300),
reverseDuration: const Duration(milliseconds: 200),
transitionBuilder: (child, animation) {
return FadeTransition(
opacity: animation,
child: ScaleTransition(
scale: animation,
child: child,
),
);
},
child: IconTheme(
key: iconKey,
data: iconTheme,
child: icon,
),
);
}
这是我的尝试 , 我把源代码里面的buildIcon 抄了一遍,但感觉这样也不好, 除了这个方法还有其他的方法吗?
目前不支持,也暂时没有计划实现。请自行修改
描述
ClassicFooter 组件在其他状态时保留icon的显示;但在noMore状态下去掉noMoreIcon的显示 如果设置ClassicFooter的 iconDimension 为0;那么所有的icon都不显示,有没有更好的解决方法? 在 classic_indicator.dart 文件中的 _buildIcon 方法中,看到部分代码如下:
所以设置 ClassicFooter的 noMoreIcon为null 也不行, CircularProgressIndicator 也是通过icon显示
在 classic_indicator.dart 文件中的 _buildVerticalBody 方法中,看到部分代码如下:
设置ClassicFooter的 iconDimension 为0;那么所有的icon都不显示;设置 ClassicFooter的 noMoreIcon为SizedBox ;显示的文字会发生偏移,没有剧中显示,
有其他方式解决这个问题吗?