-
-
Save MarcinusX/601059ae42f82e9ea9ff87f6cb064e6d to your computer and use it in GitHub Desktop.
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
const double minHeight = 120; | |
const double iconStartSize = 44; //<-- add edge values | |
const double iconEndSize = 120; //<-- add edge values | |
const double iconStartMarginTop = 36; //<-- add edge values | |
const double iconEndMarginTop = 80; //<-- add edge values | |
const double iconsVerticalSpacing = 24; //<-- add edge values | |
const double iconsHorizontalSpacing = 16; //<-- add edge values | |
class _ExhibitionBottomSheetState extends State<ExhibitionBottomSheet> | |
with SingleTickerProviderStateMixin { | |
double get itemBorderRadius => lerp(8, 24); //<-- increase item border radius | |
double get iconSize => lerp(iconStartSize, iconEndSize); //<-- increase icon size | |
double iconTopMargin(int index) => | |
lerp(iconStartMarginTop, | |
iconEndMarginTop + index * (iconsVerticalSpacing + iconEndSize)) + | |
headerTopMargin; //<-- calculate top margin based on header margin, and size of all of icons above (from small to big) | |
double iconLeftMargin(int index) => | |
lerp(index * (iconsHorizontalSpacing + iconStartSize), 0); //<-- calculate left margin (from big to small) | |
double lerp(double min, double max) => | |
lerpDouble(min, max, _controller.value); | |
@override | |
Widget build(BuildContext context) { | |
return ... | |
child: Stack( | |
children: <Widget>[ | |
MenuButton(), | |
SheetHeader( | |
fontSize: headerFontSize, | |
topMargin: headerTopMargin, | |
), | |
for (Event event in events) _buildIcon(event), //<-- Add icons to the stack | |
], | |
), | |
... | |
} | |
Widget _buildIcon(Event event) { | |
int index = events.indexOf(event); //<-- Get index of the event | |
return Positioned( | |
height: iconSize, //<-- Specify icon's size | |
width: iconSize, //<-- Specify icon's size | |
top: iconTopMargin(index), //<-- Specify icon's top margin | |
left: iconLeftMargin(index), //<-- Specify icon's left margin | |
child: ClipRRect( | |
borderRadius: BorderRadius.horizontal( | |
left: Radius.circular(itemBorderRadius), //<-- Set the rounded corners | |
right: Radius.circular(itemBorderRadius), | |
), | |
child: Image.asset( | |
'assets/${event.assetName}', | |
fit: BoxFit.cover, | |
alignment: Alignment(lerp(1, 0), 0), //<-- Play with alignment for extra style points | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment