|
| 1 | +import 'package:flutter_web/material.dart'; |
| 2 | +import 'package:flutter_web_challenge_googlemaps/helper/ui_helper.dart'; |
| 3 | + |
| 4 | +class ExploreContentWidget extends StatelessWidget { |
| 5 | + final double currentExplorePercent; |
| 6 | + final placeName = const ["Authentic\nrestaurant", "Famous\nmonuments", "Weekend\ngetaways"]; |
| 7 | + const ExploreContentWidget({Key key, this.currentExplorePercent}) : super(key: key); |
| 8 | + |
| 9 | + @override |
| 10 | + Widget build(BuildContext context) { |
| 11 | + if (currentExplorePercent != 0) { |
| 12 | + return Positioned( |
| 13 | + top: realH(standardHeight + (162 - standardHeight) * currentExplorePercent), |
| 14 | + width: screenWidth, |
| 15 | + child: Container( |
| 16 | + height: screenHeight, |
| 17 | + child: ListView( |
| 18 | + physics: const BouncingScrollPhysics(), |
| 19 | + shrinkWrap: true, |
| 20 | + children: <Widget>[ |
| 21 | + Opacity( |
| 22 | + opacity: currentExplorePercent, |
| 23 | + child: Row( |
| 24 | + mainAxisSize: MainAxisSize.max, |
| 25 | + children: <Widget>[ |
| 26 | + Expanded( |
| 27 | + child: Transform.translate( |
| 28 | + offset: Offset(screenWidth / 3 * (1 - currentExplorePercent), |
| 29 | + screenWidth / 3 / 2 * (1 - currentExplorePercent)), |
| 30 | + child: Image.asset( |
| 31 | + "icon_1.png", |
| 32 | + width: realH(133), |
| 33 | + height: realH(133), |
| 34 | + ), |
| 35 | + ), |
| 36 | + ), |
| 37 | + Expanded( |
| 38 | + child: Image.asset( |
| 39 | + "icon_2.png", |
| 40 | + width: realH(133), |
| 41 | + height: realH(133), |
| 42 | + ), |
| 43 | + ), |
| 44 | + Expanded( |
| 45 | + child: Transform.translate( |
| 46 | + offset: Offset(-screenWidth / 3 * (1 - currentExplorePercent), |
| 47 | + screenWidth / 3 / 2 * (1 - currentExplorePercent)), |
| 48 | + child: Image.asset( |
| 49 | + "icon_3.png", |
| 50 | + width: realH(133), |
| 51 | + height: realH(133), |
| 52 | + ), |
| 53 | + ), |
| 54 | + ) |
| 55 | + ], |
| 56 | + ), |
| 57 | + ), |
| 58 | + Transform.translate( |
| 59 | + offset: Offset(0, realH(23 + 380 * (1 - currentExplorePercent))), |
| 60 | + child: Opacity( |
| 61 | + opacity: currentExplorePercent, |
| 62 | + child: Container( |
| 63 | + width: screenWidth, |
| 64 | + height: realH(172 + (172 * 4 * (1 - currentExplorePercent))), |
| 65 | + child: ListView( |
| 66 | + physics: const BouncingScrollPhysics(), |
| 67 | + scrollDirection: Axis.horizontal, |
| 68 | + children: <Widget>[ |
| 69 | + Padding( |
| 70 | + padding: EdgeInsets.only(left: realW(22)), |
| 71 | + ), |
| 72 | + buildListItem(0, "Authentic\nrestaurant"), |
| 73 | + buildListItem(1, "Famous\nmonuments"), |
| 74 | + buildListItem(2, "Weekend\ngetaways"), |
| 75 | + buildListItem(3, "Authentic\nrestaurant"), |
| 76 | + buildListItem(4, "Famous\nmonuments"), |
| 77 | + buildListItem(5, "Weekend\ngetaways"), |
| 78 | + ], |
| 79 | + ), |
| 80 | + ))), |
| 81 | + Transform.translate( |
| 82 | + offset: Offset(0, realH(58 + 570 * (1 - currentExplorePercent))), |
| 83 | + child: Opacity( |
| 84 | + opacity: currentExplorePercent, |
| 85 | + child: Padding( |
| 86 | + padding: EdgeInsets.symmetric(horizontal: realW(22)), |
| 87 | + child: Column( |
| 88 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 89 | + mainAxisSize: MainAxisSize.max, |
| 90 | + children: <Widget>[ |
| 91 | + Padding( |
| 92 | + padding: EdgeInsets.only(left: realW(22)), |
| 93 | + child: Text("EVENTS", |
| 94 | + style: |
| 95 | + const TextStyle(color: Colors.white54, fontSize: 13, fontWeight: FontWeight.bold)), |
| 96 | + ), |
| 97 | + Stack( |
| 98 | + children: <Widget>[ |
| 99 | + Image.asset( |
| 100 | + "dj.png", |
| 101 | + ), |
| 102 | + Positioned( |
| 103 | + bottom: realH(26), |
| 104 | + left: realW(24), |
| 105 | + child: Text( |
| 106 | + "Marshmello Live in Concert", |
| 107 | + style: TextStyle(color: Colors.white, fontSize: realW(16)), |
| 108 | + )) |
| 109 | + ], |
| 110 | + ), |
| 111 | + Transform.translate( |
| 112 | + offset: Offset(0, realH(30 - 30 * (currentExplorePercent - 0.75) * 4)), |
| 113 | + child: Row( |
| 114 | + children: <Widget>[ |
| 115 | + Expanded( |
| 116 | + child: Image.asset("banner_4.png"), |
| 117 | + ), |
| 118 | + Expanded( |
| 119 | + child: Image.asset("banner_5.png"), |
| 120 | + ), |
| 121 | + ], |
| 122 | + ), |
| 123 | + ) |
| 124 | + ], |
| 125 | + ), |
| 126 | + ), |
| 127 | + )), |
| 128 | + Padding( |
| 129 | + padding: EdgeInsets.only(bottom: realH(262)), |
| 130 | + ) |
| 131 | + ], |
| 132 | + ), |
| 133 | + ), |
| 134 | + ); |
| 135 | + } else { |
| 136 | + return const Padding( |
| 137 | + padding: const EdgeInsets.all(0), |
| 138 | + ); |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + buildListItem(int index, String name) { |
| 143 | + return Transform.translate( |
| 144 | + offset: Offset(0, index * realH(127) * (1 - currentExplorePercent)), |
| 145 | + child: Column( |
| 146 | + mainAxisSize: MainAxisSize.min, |
| 147 | + children: <Widget>[ |
| 148 | + Image.asset( |
| 149 | + "banner_${index % 3 + 1}.png", |
| 150 | + width: realH(127), |
| 151 | + height: realH(127), |
| 152 | + ), |
| 153 | + Text( |
| 154 | + placeName[index % 3], |
| 155 | + style: TextStyle(color: Colors.white, fontSize: realH(16)), |
| 156 | + textAlign: TextAlign.center, |
| 157 | + ) |
| 158 | + ], |
| 159 | + ), |
| 160 | + ); |
| 161 | + } |
| 162 | +} |
0 commit comments