-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
leonardo.gabriel
committed
Apr 9, 2024
1 parent
8405071
commit ad9564b
Showing
46 changed files
with
1,507 additions
and
645 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
lib/controllers/grx_animated_loading_button.controller.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:rounded_loading_button_plus/rounded_loading_button.dart'; | ||
|
||
class GrxAnimatedLoadingButtonController | ||
extends RoundedLoadingButtonController { | ||
GrxAnimatedLoadingButtonController({ | ||
this.resetStateDuration = const Duration(seconds: 3), | ||
}); | ||
|
||
final Duration? resetStateDuration; | ||
|
||
@override | ||
void success() { | ||
super.success(); | ||
|
||
_resetButtonState(); | ||
} | ||
|
||
@override | ||
void error() { | ||
super.error(); | ||
|
||
_resetButtonState(); | ||
} | ||
|
||
void _resetButtonState() { | ||
if (resetStateDuration != null && resetStateDuration!.inMilliseconds > 0) { | ||
Future.delayed(resetStateDuration!, () { | ||
reset(); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import 'dart:math' as math; | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
import '../animations/grx_fade_transition.animation.dart'; | ||
|
||
const double _kToolbarExtent = 60.0; | ||
|
||
class GrxAnimatedSliverHeaderDelegate extends SliverPersistentHeaderDelegate { | ||
GrxAnimatedSliverHeaderDelegate({ | ||
required this.animationController, | ||
required this.builder, | ||
this.topSafePadding = 0.0, | ||
this.toolbarExtent, | ||
}); | ||
|
||
final AnimationController animationController; | ||
final Widget Function(double progress) builder; | ||
final double topSafePadding; | ||
final double? toolbarExtent; | ||
|
||
late final Animation<double> topBarAnimation = | ||
Tween<double>(begin: 0, end: 1).animate( | ||
CurvedAnimation( | ||
parent: animationController, | ||
curve: const Interval(0, 0.6, curve: Curves.fastOutSlowIn), | ||
), | ||
); | ||
|
||
@override | ||
Widget build( | ||
BuildContext context, | ||
double shrinkOffset, | ||
bool overlapsContent, | ||
) { | ||
final progress = clampDouble(shrinkOffset / maxExtent, 0.0, 1.0); | ||
|
||
return FlexibleSpaceBar.createSettings( | ||
minExtent: minExtent, | ||
maxExtent: maxExtent, | ||
currentExtent: math.max(minExtent, maxExtent - shrinkOffset), | ||
toolbarOpacity: progress, | ||
isScrolledUnder: shrinkOffset > maxExtent - minExtent, | ||
child: AnimatedBuilder( | ||
animation: animationController, | ||
child: builder(progress), | ||
builder: (context, child) { | ||
return GrxFadeTransition( | ||
animation: topBarAnimation, | ||
child: child!, | ||
); | ||
}, | ||
), | ||
); | ||
} | ||
|
||
@override | ||
double get maxExtent => (toolbarExtent ?? _kToolbarExtent) + topSafePadding; | ||
|
||
@override | ||
double get minExtent => (toolbarExtent ?? _kToolbarExtent) + topSafePadding; | ||
|
||
@override | ||
bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) => | ||
true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:flutter/widgets.dart'; | ||
|
||
import '../themes/colors/grx_colors.dart'; | ||
|
||
class GrxButtonOptions { | ||
const GrxButtonOptions({ | ||
required this.title, | ||
this.onPressed, | ||
this.icon, | ||
this.backgroundColor, | ||
this.foregroundColor = GrxColors.cffffffff, | ||
}); | ||
|
||
final String title; | ||
final Color foregroundColor; | ||
final VoidCallback? onPressed; | ||
final IconData? icon; | ||
final Color? backgroundColor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.