Created
June 15, 2021 09:32
-
-
Save PreyeaRegmi/b0cfad50fa8c4358ea8ddc76346a273e to your computer and use it in GitHub Desktop.
Tab selection effect that runs when either of the tab is tapped
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; | |
backgroundColor = Colors.pink; | |
} else { | |
foreGroundColor = Colors.pink; | |
backgroundColor = Colors.deepPurple; | |
} | |
widgets.add(Positioned.fill(child: Container(color: foreGroundColor))); | |
if (_tabSelectionAnimation != null) | |
widgets.add(PositionedTransition( | |
rect: _tabSelectionAnimation!, | |
child: Container( | |
decoration: BoxDecoration( | |
color: backgroundColor | |
), | |
))); | |
widgets.add(Container( | |
height: double.infinity, | |
width: double.infinity, | |
child: CustomPaint( | |
painter: AmoebaBg(_amoebaOffsetAnimation), | |
), | |
)); | |
return widgets; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment