Skip to content

Commit

Permalink
fixes pub.dev issues
Browse files Browse the repository at this point in the history
  • Loading branch information
maeddin committed Mar 18, 2022
1 parent cb3abee commit d071330
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 33 deletions.
37 changes: 27 additions & 10 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,43 @@ class _ExampleState extends State<Example> {
),
counterCard(Curves.easeInOutCirc),
counterCard(Curves.easeInOutCirc,
builder: (width, height) =>
Container(width: width, height: height, decoration: BoxDecoration(color: Colors.purple, borderRadius: BorderRadius.circular(5.0))),
builder: (width, height) => Container(
width: width,
height: height,
decoration: BoxDecoration(
color: Colors.purple,
borderRadius: BorderRadius.circular(5.0))),
wiperWidth: 50),
counterCard(
Curves.linear,
builder: (width, height) =>
Container(width: width, height: height, decoration: BoxDecoration(color: Colors.purple, borderRadius: BorderRadius.circular(5.0))),
builder: (width, height) => Container(
width: width,
height: height,
decoration: BoxDecoration(
color: Colors.purple,
borderRadius: BorderRadius.circular(5.0))),
wiperWidth: 10,
deformingFactor: 0.2,
direction: WiperDirection.up,
),
counterCard(Curves.easeInOutCirc, padding: EdgeInsets.symmetric(horizontal: 15.0, vertical: 30.0)),
counterCard(Curves.easeInOutCirc,
padding: EdgeInsets.symmetric(
horizontal: 15.0, vertical: 30.0)),
counterCard(Curves.easeOutSine,
builder: (width, height) => Container(
width: width,
height: height,
decoration: BoxDecoration(color: Colors.red, shape: BoxShape.circle),
decoration: BoxDecoration(
color: Colors.red, shape: BoxShape.circle),
),
wiperWidth: 20),
counterCard(Curves.easeOutSine,
builder: (width, height) =>
Container(width: width, height: height, decoration: BoxDecoration(color: Colors.purple, borderRadius: BorderRadius.circular(5.0))),
builder: (width, height) => Container(
width: width,
height: height,
decoration: BoxDecoration(
color: Colors.purple,
borderRadius: BorderRadius.circular(5.0))),
wiperWidth: 20,
direction: WiperDirection.left),
counterCardCircle(Curves.linear),
Expand Down Expand Up @@ -171,7 +186,8 @@ class _ExampleState extends State<Example> {
);

Widget counterCardCircle(Curve curve, {WiperBuilder? builder}) => InkWell(
onTap: () => Navigator.of(context).push(MaterialPageRoute(builder: (c) => LoadingScaffold())),
onTap: () => Navigator.of(context)
.push(MaterialPageRoute(builder: (c) => LoadingScaffold())),
child: Card(
elevation: 5.0,
child: CircularWidgetLoading(
Expand All @@ -180,7 +196,8 @@ class _ExampleState extends State<Example> {
rollingFactor: 0.8,
loading: loading,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 50.0),
padding: const EdgeInsets.symmetric(
horizontal: 15.0, vertical: 50.0),
child: ListTile(
leading: Text(
'Counter',
Expand Down
8 changes: 4 additions & 4 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: example
description: Example Project for the package widget_loading.

publish_to: 'none'

version: 1.0.0+1

environment:
sdk: ">=2.12.0-259.16.beta <3.0.0"
sdk: ">=2.15.0 <3.0.0"

dependencies:
flutter:
sdk: flutter

widget_loading:
path: ../

cupertino_icons: ^1.0.0
path: '..'

dev_dependencies:
flutter_test:
Expand Down
6 changes: 4 additions & 2 deletions lib/src/utils/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ extension Derivation on CurvedAnimation {
case AnimationStatus.forward:
double value = max(this.parent.value - dif, 0.0);
if (value == this.parent.value) return 0.0;
return (this.value - this.curve.transform(value)) / (this.parent.value - value);
return (this.value - this.curve.transform(value)) /
(this.parent.value - value);
case AnimationStatus.reverse:
double value = min(this.parent.value + dif, 1.0);
if (value == this.parent.value) return 0.0;
return (this.value - this.curve.transform(value)) / (value - this.parent.value);
return (this.value - this.curve.transform(value)) /
(value - this.parent.value);
case AnimationStatus.dismissed:
case AnimationStatus.completed:
break;
Expand Down
23 changes: 14 additions & 9 deletions lib/src/widgets/circular_widget_loading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ class _CircularWidgetLoadingState
_appearingController = AnimationController(
duration: widget.appearingDuration,
vsync: this,
)
..addStatusListener((status) {
)..addStatusListener((status) {
switch (status) {
case AnimationStatus.dismissed:
if (disappearing) {
Expand All @@ -136,13 +135,13 @@ class _CircularWidgetLoadingState
}
});

_appearingAnimation = CurvedAnimation(parent: _appearingController, curve: widget.appearingCurve);
_appearingAnimation = CurvedAnimation(
parent: _appearingController, curve: widget.appearingCurve);

_controller = AnimationController(
duration: widget.loadingDuration,
vsync: this,
)
..addStatusListener((status) {
)..addStatusListener((status) {
switch (status) {
case AnimationStatus.forward:
break;
Expand Down Expand Up @@ -332,17 +331,23 @@ class _DotClipper extends CustomClipper<Rect> {
final double maxLoadingCircleSize;
final double loadingCirclePadding;

_DotClipper(this.factor, this.dotRadius, this.maxLoadingCircleSize, this.loadingCirclePadding);
_DotClipper(this.factor, this.dotRadius, this.maxLoadingCircleSize,
this.loadingCirclePadding);

@override
Rect getClip(Size size) {
double radius = min(maxLoadingCircleSize, min(size.width, size.height) - 2 * loadingCirclePadding) / 2 - dotRadius;
double radius = min(maxLoadingCircleSize,
min(size.width, size.height) - 2 * loadingCirclePadding) /
2 -
dotRadius;
double x = size.width / 2;
double y = size.height / 2;

double maxAppearingRadius = sqrt(x * x + y * y);
double appearingRadius = dotRadius + factor * (maxAppearingRadius - dotRadius);
return Rect.fromCircle(center: Offset(x, y - radius), radius: appearingRadius);
double appearingRadius =
dotRadius + factor * (maxAppearingRadius - dotRadius);
return Rect.fromCircle(
center: Offset(x, y - radius), radius: appearingRadius);
}

@override
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widgets/loading_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ abstract class LoadingWidgetState<T extends StatefulWidget> extends State<T> {
setLoadingState(value);
}

void setLoadingState(LoadingState value, {bool rebuild = true}){
void setLoadingState(LoadingState value, {bool rebuild = true}) {
_loadingState = value;
if(rebuild && mounted) setState((){});
if (rebuild && mounted) setState(() {});
}

LoadingState get loadingState => _loadingState;
Expand Down
1 change: 0 additions & 1 deletion lib/src/widgets/widget_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ class WidgetWrapper extends StatelessWidget {
return child;
}
}

14 changes: 10 additions & 4 deletions lib/src/widgets/wiper_loading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class _WiperLoadingState extends LoadingWidgetState<WiperLoading>
}
});

if(loaded) _controller.value = 1.0;
if (loaded) _controller.value = 1.0;
}

@override
Expand Down Expand Up @@ -331,11 +331,13 @@ class _WiperRectClipper extends CustomClipper<Rect> {
@override
Rect getClip(Size size) {
return direction == WiperDirection.left
? Rect.fromLTWH(size.width * (1 - factor), 0, size.width * factor, size.height)
? Rect.fromLTWH(
size.width * (1 - factor), 0, size.width * factor, size.height)
: direction == WiperDirection.right
? Rect.fromLTWH(0, 0, size.width * factor, size.height)
: direction == WiperDirection.up
? Rect.fromLTWH(0, size.height * (1 - factor), size.width, size.height * factor)
? Rect.fromLTWH(0, size.height * (1 - factor), size.width,
size.height * factor)
: Rect.fromLTWH(0, 0, size.width, size.height * factor);
}

Expand All @@ -346,7 +348,11 @@ class _WiperRectClipper extends CustomClipper<Rect> {

@override
bool operator ==(Object other) =>
identical(this, other) || other is _WiperRectClipper && runtimeType == other.runtimeType && direction == other.direction && factor == other.factor;
identical(this, other) ||
other is _WiperRectClipper &&
runtimeType == other.runtimeType &&
direction == other.direction &&
factor == other.factor;

@override
int get hashCode => direction.hashCode ^ factor.hashCode;
Expand Down
2 changes: 1 addition & 1 deletion test/widget_loading_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

void main() {
//test('', () {});
}
}

0 comments on commit d071330

Please sign in to comment.