|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter_ui_nice/const/color_const.dart'; |
| 3 | +import 'package:flutter_ui_nice/const/shadow_const.dart'; |
| 4 | +import 'package:flutter_ui_nice/page/feed/feed_const.dart'; |
| 5 | +import 'package:flutter_ui_nice/page/feed/top_title.dart'; |
| 6 | +import 'package:flutter_ui_nice/util/SizeUtil.dart'; |
| 7 | + |
| 8 | +const cardConsts = [ |
| 9 | + { |
| 10 | + "author": "Hristo", |
| 11 | + "action": "added 127 new photos to Lorem ipsum dolr sit amet.", |
| 12 | + "time": "1 MINUTE", |
| 13 | + "like": "123", |
| 14 | + "chat": "67", |
| 15 | + "share": "12", |
| 16 | + "images_number": "+126", |
| 17 | + "avatar_image": FeedImage.feed1_avatar2, |
| 18 | + "images": [ |
| 19 | + FeedImage.feed13_pic1, |
| 20 | + FeedImage.feed13_pic2, |
| 21 | + FeedImage.feed13_pic3, |
| 22 | + ] |
| 23 | + }, |
| 24 | + { |
| 25 | + "author": "Mila", |
| 26 | + "action": "added 3 new photos to Lorem ipsum dolr sit amet.", |
| 27 | + "time": "12 HOURS", |
| 28 | + "like": "123", |
| 29 | + "chat": "67", |
| 30 | + "share": "12", |
| 31 | + "images_number": '0', |
| 32 | + "avatar_image": FeedImage.feed1_avatar1, |
| 33 | + "images": [ |
| 34 | + FeedImage.feed13_pic1, |
| 35 | + FeedImage.feed13_pic2, |
| 36 | + FeedImage.feed13_pic3, |
| 37 | + ] |
| 38 | + }, |
| 39 | +]; |
| 40 | + |
| 41 | +class FeedPageFour extends StatefulWidget { |
| 42 | + @override |
| 43 | + _FeedPageFourState createState() => _FeedPageFourState(); |
| 44 | +} |
| 45 | + |
| 46 | +var deviceHeight; |
| 47 | +var deviceWidth; |
| 48 | +Icon favIcon = Icon(Icons.favorite_border); |
| 49 | +Icon chatIcon = Icon(Icons.chat); |
| 50 | +Icon shareIcon = Icon(Icons.share); |
| 51 | + |
| 52 | +class _FeedPageFourState extends State<FeedPageFour> { |
| 53 | + |
| 54 | + Widget _cardAction(Icon icon, int number) { |
| 55 | + return Container( |
| 56 | + margin: EdgeInsets.only(bottom: 20), |
| 57 | + child: Row( |
| 58 | + children: <Widget>[ |
| 59 | + icon, |
| 60 | + SizedBox(width: 5), |
| 61 | + Text( |
| 62 | + '$number', |
| 63 | + style: TextStyle( |
| 64 | + color: Colors.black38, |
| 65 | + fontSize: SizeUtil.getAxisBoth(TEXT_NORMAL_SIZE)), |
| 66 | + ) |
| 67 | + ], |
| 68 | + ), |
| 69 | + ); |
| 70 | + } |
| 71 | + |
| 72 | + Widget _avatar() { |
| 73 | + return (Container( |
| 74 | + margin: EdgeInsets.only(top: 18, left: deviceWidth * 0.22), |
| 75 | + height: 50.0, |
| 76 | + width: 50.0, |
| 77 | + decoration: BoxDecoration( |
| 78 | + image: DecorationImage(image: AssetImage(FeedImage.feed1_avatar2))), |
| 79 | + )); |
| 80 | + } |
| 81 | + |
| 82 | + Widget _feedCardImages() { |
| 83 | + return Positioned( |
| 84 | + top: 180.0, |
| 85 | + left: 26, |
| 86 | + child: Container( |
| 87 | + height: 230, |
| 88 | + width: 350, |
| 89 | + decoration: BoxDecoration(boxShadow: [ |
| 90 | + BoxShadow( |
| 91 | + color: Colors.black12, |
| 92 | + blurRadius: 20.0, |
| 93 | + spreadRadius: 5.0, |
| 94 | + offset: Offset( |
| 95 | + 10.0, // horizontal, move right 10 |
| 96 | + 10.0, // vertical, move down 10 |
| 97 | + ), |
| 98 | + ) |
| 99 | + ], color: Colors.red, borderRadius: BorderRadius.circular(22.0)), |
| 100 | + ), |
| 101 | + ); |
| 102 | + } |
| 103 | + |
| 104 | + Widget _feedCard() { |
| 105 | + return Container( |
| 106 | + width: double.infinity, |
| 107 | + child: Stack( |
| 108 | + children: <Widget>[_pinkCard(), _avatar(), _feedCardImages()], |
| 109 | + ), |
| 110 | + ); |
| 111 | + } |
| 112 | + |
| 113 | + @override |
| 114 | + Widget build(BuildContext context) { |
| 115 | + deviceWidth = MediaQuery.of(context).size.width; |
| 116 | + deviceHeight = MediaQuery.of(context).size.height; |
| 117 | + return Scaffold( |
| 118 | + body: Container( |
| 119 | + decoration: |
| 120 | + BoxDecoration(gradient: LinearGradient(colors: [YELLOW, GREEN])), |
| 121 | + child: Stack( |
| 122 | + //crossAxisAlignment: CrossAxisAlignment.center, |
| 123 | + children: <Widget>[ |
| 124 | + _cardClipper(), |
| 125 | + TopTitleBar(), |
| 126 | + ], |
| 127 | + ), |
| 128 | + ), |
| 129 | + ); |
| 130 | + } |
| 131 | + |
| 132 | + |
| 133 | + Widget timeText () => Container( |
| 134 | + width: double.infinity, |
| 135 | + margin: EdgeInsets.all(20), |
| 136 | + child: Text( |
| 137 | + cardConsts[0]['time'], |
| 138 | + textAlign: TextAlign.right, |
| 139 | + style: TextStyle( |
| 140 | + color: Colors.black38, |
| 141 | + fontSize: SizeUtil.getAxisBoth(TEXT_SMALL_2_SIZE) |
| 142 | + ), |
| 143 | + ), |
| 144 | + ); |
| 145 | + |
| 146 | + Widget descriptionText () => Container( |
| 147 | + margin: EdgeInsets.symmetric(horizontal: 20), |
| 148 | + child: RichText( |
| 149 | + text: TextSpan( |
| 150 | + text: '${cardConsts[0]['author']} ', |
| 151 | + style: TextStyle( |
| 152 | + fontSize: SizeUtil.getAxisBoth(TEXT_NORMAL_SIZE), |
| 153 | + fontWeight: FontWeight.bold, |
| 154 | + color: TEXT_BLACK |
| 155 | + ), |
| 156 | + children: <TextSpan> [ |
| 157 | + TextSpan( |
| 158 | + text: cardConsts[0]['action'], |
| 159 | + style: TextStyle( |
| 160 | + fontWeight: FontWeight.normal, |
| 161 | + color: TEXT_BLACK_LIGHT |
| 162 | + ) |
| 163 | + ) |
| 164 | + ] |
| 165 | + ), |
| 166 | + ), |
| 167 | + ); |
| 168 | + |
| 169 | + Widget _socialAction (Icon icon, String number) => Container( |
| 170 | + child: Row( |
| 171 | + children: <Widget>[ |
| 172 | + icon, |
| 173 | + SizedBox(width: 7), |
| 174 | + Text( |
| 175 | + '$number', |
| 176 | + style: TextStyle( |
| 177 | + color: Colors.black45, |
| 178 | + fontSize: SizeUtil.getAxisBoth(TEXT_SMALL_2_SIZE) |
| 179 | + ), |
| 180 | + ) |
| 181 | + ], |
| 182 | + ), |
| 183 | + ); |
| 184 | + |
| 185 | + Widget _socialActionRow() { |
| 186 | + return Container( |
| 187 | + margin: EdgeInsets.symmetric(vertical: 20), |
| 188 | + child: Row( |
| 189 | + mainAxisAlignment: MainAxisAlignment.spaceEvenly, |
| 190 | + children: <Widget>[ |
| 191 | + _socialAction(favIcon, cardConsts[0]['like']), |
| 192 | + _socialAction(chatIcon, cardConsts[0]['chat']), |
| 193 | + _socialAction(shareIcon, cardConsts[0]['share']) |
| 194 | + ], |
| 195 | + ), |
| 196 | + ); |
| 197 | + } |
| 198 | + |
| 199 | + Widget _cardDetails() { |
| 200 | + return Column( |
| 201 | + children: <Widget>[ |
| 202 | + timeText(), |
| 203 | + Expanded( |
| 204 | + child: descriptionText() |
| 205 | + ), |
| 206 | + _socialActionRow() |
| 207 | + ], |
| 208 | + ); |
| 209 | + } |
| 210 | + |
| 211 | + Widget _pinkCard() { |
| 212 | + return Center( |
| 213 | + child: Container( |
| 214 | + margin: EdgeInsets.only(top: 50), |
| 215 | + height: deviceHeight * 0.6, |
| 216 | + width: deviceWidth * 0.75, |
| 217 | + decoration: BoxDecoration( |
| 218 | + borderRadius: BorderRadius.circular(22.0), |
| 219 | + boxShadow: SHADOW, |
| 220 | + gradient: LinearGradient(colors: [RED_LIGHT, RED])), |
| 221 | + child: _cardDetails(), |
| 222 | + ), |
| 223 | + ); |
| 224 | + } |
| 225 | + |
| 226 | + Widget _avatarCard() { |
| 227 | + return Positioned( |
| 228 | + top: deviceHeight * 0.027, |
| 229 | + left: deviceWidth * 0.2, |
| 230 | + child: Container( |
| 231 | + height: 60, |
| 232 | + width: 60, |
| 233 | + decoration: BoxDecoration( |
| 234 | + borderRadius: BorderRadius.circular(7), |
| 235 | + image: DecorationImage( |
| 236 | + image: AssetImage(cardConsts[0]['avatar_image']) |
| 237 | + ), |
| 238 | + boxShadow: SHADOW, |
| 239 | + ), |
| 240 | + ) |
| 241 | + ); |
| 242 | + } |
| 243 | + |
| 244 | + Widget _imagesCard() { |
| 245 | + return Positioned( |
| 246 | + top: deviceHeight * 0.25, |
| 247 | + left: deviceWidth * 0.05, |
| 248 | + child: Container( |
| 249 | + height: 250, |
| 250 | + width: 370, |
| 251 | + decoration: BoxDecoration( |
| 252 | + color: Colors.red, |
| 253 | + borderRadius: BorderRadius.circular(22), |
| 254 | + boxShadow: SHADOW, |
| 255 | + ), |
| 256 | + ), |
| 257 | + ); |
| 258 | + } |
| 259 | + |
| 260 | + Widget _stackClipperCard() { |
| 261 | + return Stack( |
| 262 | + children: <Widget>[ |
| 263 | + _pinkCard(), |
| 264 | + _avatarCard(), |
| 265 | + _imagesCard() |
| 266 | + ], |
| 267 | + ); |
| 268 | + } |
| 269 | + |
| 270 | + Widget _cardClipper() { |
| 271 | + return ListView( |
| 272 | + children: <Widget>[ |
| 273 | + SizedBox( |
| 274 | + height: 100, |
| 275 | + ), |
| 276 | + _stackClipperCard(), |
| 277 | + ], |
| 278 | + ); |
| 279 | + } |
| 280 | +} |
0 commit comments