Skip to content

Commit 8d2980f

Browse files
committed
fix: minor corrections to the envelope indicator
1 parent 26422c8 commit 8d2980f

File tree

3 files changed

+51
-38
lines changed

3 files changed

+51
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- The drag details have been exposed to allow animations based on the position of the pointer.
33
- Example app:
44
- The checkmark indicator example has been simplified.
5+
- Minor corrections to the envelope indicator.
56
- Removed unused code.
67
## 2.2.1
78
- Fixed typos in documentation

example/lib/indicators/check_mark_indicator.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ class CheckMarkStyle {
2323

2424
static const defaultStyle = CheckMarkStyle(
2525
loading: CheckMarkColors(content: Colors.white, background: Colors.black),
26-
completed: CheckMarkColors(content: Colors.white, background: Colors.greenAccent),
26+
completed:
27+
CheckMarkColors(content: Colors.white, background: Colors.greenAccent),
2728
);
2829
}
2930

@@ -41,7 +42,8 @@ class CheckMarkIndicator extends StatefulWidget {
4142
State<CheckMarkIndicator> createState() => _CheckMarkIndicatorState();
4243
}
4344

44-
class _CheckMarkIndicatorState extends State<CheckMarkIndicator> with SingleTickerProviderStateMixin {
45+
class _CheckMarkIndicatorState extends State<CheckMarkIndicator>
46+
with SingleTickerProviderStateMixin {
4547
/// Whether to render check mark instead of spinner
4648
bool _renderCompleteState = false;
4749

@@ -72,7 +74,9 @@ class _CheckMarkIndicatorState extends State<CheckMarkIndicator> with SingleTick
7274
BuildContext context,
7375
IndicatorController controller,
7476
) {
75-
final style = _renderCompleteState ? widget.style.completed : widget.style.loading;
77+
final style = _renderCompleteState
78+
? widget.style.completed
79+
: widget.style.loading;
7680
return AnimatedContainer(
7781
duration: const Duration(milliseconds: 150),
7882
alignment: Alignment.center,
@@ -91,7 +95,9 @@ class _CheckMarkIndicatorState extends State<CheckMarkIndicator> with SingleTick
9195
child: CircularProgressIndicator(
9296
strokeWidth: 2,
9397
color: style.content,
94-
value: controller.isDragging || controller.isArmed ? controller.value.clamp(0.0, 1.0) : null,
98+
value: controller.isDragging || controller.isArmed
99+
? controller.value.clamp(0.0, 1.0)
100+
: null,
95101
),
96102
),
97103
);

example/lib/indicators/envelope_indicator.dart

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ class EnvelopRefreshIndicator extends StatelessWidget {
1010

1111
static const _circleSize = 70.0;
1212

13+
static const _blurRadius = 10.0;
1314
static const _defaultShadow = [
14-
BoxShadow(blurRadius: 10, color: Colors.black26)
15+
BoxShadow(blurRadius: _blurRadius, color: Colors.black26)
1516
];
1617

1718
const EnvelopRefreshIndicator({
@@ -34,51 +35,59 @@ class EnvelopRefreshIndicator extends StatelessWidget {
3435
final widgetHeight = constraints.maxHeight;
3536
final letterTopWidth = (widgetWidth / 2) + 50;
3637

37-
final leftValue =
38-
(widgetWidth - (letterTopWidth * controller.value / 1))
39-
.clamp(letterTopWidth - 100, double.infinity);
38+
final leftValue = (widgetWidth +
39+
_blurRadius -
40+
((letterTopWidth + _blurRadius) * controller.value / 1))
41+
.clamp(letterTopWidth - 100, double.infinity);
4042

41-
final rightValue = (widgetWidth - (widgetWidth * controller.value / 1))
43+
final rightShift = widgetWidth + _blurRadius;
44+
final rightValue = (rightShift - (rightShift * controller.value / 1))
4245
.clamp(0.0, double.infinity);
4346

4447
final opacity = (controller.value - 1).clamp(0, 0.5) / 0.5;
48+
49+
final isNotIdle = !controller.isIdle;
4550
return Stack(
4651
children: <Widget>[
4752
Transform.scale(
4853
scale: 1 - 0.1 * controller.value.clamp(0.0, 1.0),
4954
child: child,
5055
),
51-
Positioned(
52-
right: rightValue,
53-
child: Container(
54-
height: widgetHeight,
55-
width: widgetWidth,
56-
decoration: const BoxDecoration(
57-
color: Colors.white,
58-
boxShadow: _defaultShadow,
56+
if (isNotIdle)
57+
Positioned(
58+
right: rightValue,
59+
child: Container(
60+
height: widgetHeight,
61+
width: widgetWidth,
62+
decoration: const BoxDecoration(
63+
color: Colors.white,
64+
boxShadow: _defaultShadow,
65+
),
5966
),
6067
),
61-
),
62-
Positioned(
63-
left: leftValue,
64-
child: CustomPaint(
65-
painter: TrianglePainter(
66-
strokeColor: Colors.white,
67-
paintingStyle: PaintingStyle.fill,
68-
),
69-
child: SizedBox(
70-
height: widgetHeight,
71-
width: letterTopWidth,
68+
if (isNotIdle)
69+
Positioned(
70+
left: leftValue,
71+
child: CustomPaint(
72+
size: Size(
73+
letterTopWidth,
74+
widgetHeight,
75+
),
76+
painter: TrianglePainter(
77+
strokeColor: Colors.white,
78+
paintingStyle: PaintingStyle.fill,
79+
),
7280
),
7381
),
74-
),
7582
if (controller.value >= 1)
7683
Container(
7784
padding: const EdgeInsets.only(right: 100),
7885
child: Transform.scale(
7986
scale: controller.value,
8087
child: Opacity(
81-
opacity: controller.isLoading ? 1 : opacity,
88+
opacity: controller.isLoading || controller.state.isSettling
89+
? 1
90+
: opacity,
8291
child: Align(
8392
alignment: Alignment.center,
8493
child: Container(
@@ -91,16 +100,13 @@ class EnvelopRefreshIndicator extends StatelessWidget {
91100
shape: BoxShape.circle,
92101
),
93102
child: Stack(
103+
fit: StackFit.expand,
94104
alignment: Alignment.center,
95105
children: <Widget>[
96-
SizedBox(
97-
height: double.infinity,
98-
width: double.infinity,
99-
child: CircularProgressIndicator(
100-
valueColor:
101-
const AlwaysStoppedAnimation(Colors.black),
102-
value: controller.isLoading ? null : 0,
103-
),
106+
CircularProgressIndicator(
107+
valueColor:
108+
const AlwaysStoppedAnimation(Colors.black),
109+
value: controller.isLoading ? null : 0,
104110
),
105111
const Icon(
106112
Icons.mail_outline,

0 commit comments

Comments
 (0)