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
@override | |
Widget build(BuildContext context) { | |
List<Widget> stackChildren = []; | |
switch (currentScreenState) { | |
case CURRENT_SCREEN_STATE.INIT_STATE: | |
stackChildren.addAll(_getBgWidgets()); | |
stackChildren.addAll(_getDefaultWidgets()); | |
stackChildren.addAll(_getInitScreenWidgets()); | |
stackChildren.add(_getBrandTitle()); |
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
//Animation Controller for setting bounce animation for "Swipe up" text widget | |
_swipeUpBounceAnimationController = | |
AnimationController(duration: Duration(milliseconds: 800), vsync: this) | |
..repeat(reverse: true); | |
//Animation for actual bounce effect | |
_swipeUpBounceAnimation = Tween<double>(begin: 0, end: -20).animate( | |
CurvedAnimation( | |
parent: _swipeUpBounceAnimationController, | |
curve: Curves.easeOutBack)) |
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
//A simple container with a SingleChildScrollView. The trick is to set the child of SingleChildScrollView height | |
//exceed the height of parent scroll widget so it can be scrolled. The BouncingScrollPhysics helps the scroll retain its | |
//original position if it doesn't cross the threshold to play reveal animation. | |
//This widget is added by _getInitScreenWidgets() method | |
Positioned( | |
right: 0, | |
left: 0, | |
bottom: 0, | |
child: Container( | |
height: widget.height * .5, |
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
//Update scene state to "reveal" and start corresponding animation | |
//This method is called when drag excced our defined threshold | |
void _playRevealAnimation() { | |
setState(() { | |
currentScreenState = CURRENT_SCREEN_STATE.REVEALING_ANIMATING_STATE; | |
_revealAnimationController.forward(); | |
_amoebaAnimationController.forward(); | |
}); | |
} |
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
//Animation controller for showing animation after reveal | |
_postRevealAnimationController = | |
AnimationController(duration: Duration(milliseconds: 600), vsync: this); | |
//Scale animation for showing center logo after reveal is completed | |
_centerIconScale = Tween<double>(begin: 0, end: .5).animate(CurvedAnimation( | |
parent: _postRevealAnimationController, | |
curve: Curves.fastOutSlowIn, | |
)); |
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
//The paint method of "CurvePageSwitcher" to draw tab selection arc | |
void _drawSwipeAbleArc(Canvas canvas, Size size) { | |
Path path = Path(); | |
path.moveTo(-2, size.height - archBottomOffset); | |
path.cubicTo( | |
-2, | |
size.height - archBottomOffset, | |
size.width / 2, | |
size.height - arcHeight - archBottomOffset, |
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
///The background for selected tab. On the basis of tab selected, the foreground container is translated away, | |
///revealing the underlying background container. If the screen state is just set to reveal, then in the | |
///initial state no foreground container is added which is signified by _tabSelectionAnimation set to null. | |
///_tabSelectionAnimation is only set when either of the tab is pressed. | |
List<Widget> _getBgWidgets() { | |
List<Widget> widgets = []; | |
Color foreGroundColor; | |
Color backgroundColor; | |
if (isLeftTabSelected) { | |
foreGroundColor = Colors.deepPurple; |
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
abstract class BaseUseCase<P, R> { | |
Stream<R> buildUseCase(P param); | |
StreamSubscription<R> execute(P param,void Function(R) result,void Function(String) error) | |
{ | |
return buildUseCase(param).listen(result,onError: (Object exception, StackTrace stackTrace){ | |
error(exception.toString()); | |
}); | |
} |
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
//Usecase Implementation | |
class PostBillingInfoUseCase | |
extends UseCase<BillingInfoRequest, BillingInfoResponse> { | |
final BillingInfoRepository _billingInfoRepository; | |
PostBillingInfoUseCase(this._billingInfoRepository); | |
@override | |
Stream<BillingInfoResponse> buildUseCase(BillingInfoRequest param) { | |
return _billingInfoRepository.postBillingInfo(param).asStream(); |
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
//Usecase Implementation | |
class ValidateBillingAndShippingAddressUseCase extends UseCase< | |
BillingAndShippingAddressValidationRequest, | |
BillingAndShippingAddressValidationResponse> { | |
final AddressRespository _addressRespository; | |
ValidateBillingAndShippingAddressUseCase(this._addressRespository); | |
@override | |
Stream<BillingAndShippingAddressValidationResponse> buildUseCase( |
OlderNewer