|
4 | 4 | /// Email: niebin312@gmail.com
|
5 | 5 | ///
|
6 | 6 | import "package:flutter/material.dart";
|
| 7 | +import 'feed_const.dart'; |
| 8 | +import 'top_title.dart'; |
| 9 | +import 'package:flutter_ui_nice/util/SizeUtil.dart'; |
| 10 | +import 'package:flutter_ui_nice/const/color_const.dart'; |
7 | 11 |
|
8 | 12 | class FeedPageTwelve extends StatefulWidget {
|
9 | 13 | @override
|
10 | 14 | _FeedState createState() => _FeedState();
|
11 | 15 | }
|
12 | 16 |
|
13 | 17 | class _FeedState extends State<FeedPageTwelve> {
|
| 18 | + Widget _textBack(content, {size = TEXT_SMALL_2_SIZE, isBold = false}) => Text( |
| 19 | + content, |
| 20 | + style: TextStyle( |
| 21 | + fontSize: SizeUtil.getAxisBoth(size), |
| 22 | + fontWeight: isBold ? FontWeight.w700 : null), |
| 23 | + ); |
| 24 | + |
| 25 | + Widget _listItemName() => Container( |
| 26 | + alignment: AlignmentDirectional.bottomStart, |
| 27 | + child: Column( |
| 28 | + mainAxisAlignment: MainAxisAlignment.end, |
| 29 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 30 | + children: <Widget>[ |
| 31 | + _textBack("Hristo Hristov", size: TEXT_SMALL_3_SIZE, isBold: true), |
| 32 | + SizedBox(height: SizeUtil.getAxisY(13.0)), |
| 33 | + _textBack("4 hours ago", size: TEXT_NORMAL_SIZE), |
| 34 | + ], |
| 35 | + ), |
| 36 | + ); |
| 37 | + |
| 38 | + Widget _action(icon, value) => Column( |
| 39 | + mainAxisAlignment: MainAxisAlignment.start, |
| 40 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 41 | + children: <Widget>[ |
| 42 | + Icon( |
| 43 | + icon, |
| 44 | + size: SizeUtil.getAxisBoth(30.0), |
| 45 | + color: TEXT_BLACK, |
| 46 | + ), |
| 47 | + SizedBox(height: SizeUtil.getAxisY(26.0)), |
| 48 | + _textBack(value) |
| 49 | + ], |
| 50 | + ); |
| 51 | + |
| 52 | + Widget _listItemAction() => Container( |
| 53 | + child: Column( |
| 54 | + mainAxisAlignment: MainAxisAlignment.start, |
| 55 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 56 | + children: <Widget>[ |
| 57 | + _action(Icons.favorite_border, "233"), |
| 58 | + SizedBox(height: SizeUtil.getAxisY(56.0)), |
| 59 | + _action(Icons.chat, "35"), |
| 60 | + SizedBox(height: SizeUtil.getAxisY(56.0)), |
| 61 | + _action(Icons.share, "12"), |
| 62 | + SizedBox(height: SizeUtil.getAxisY(56.0)), |
| 63 | + _action(Icons.more_vert, ""), |
| 64 | + ]), |
| 65 | + ); |
| 66 | + |
| 67 | + Widget _listItem(index) => Container( |
| 68 | + height: SizeUtil.getAxisY(740.0), |
| 69 | + decoration: BoxDecoration( |
| 70 | + gradient: index % 2 == 1 |
| 71 | + ? LinearGradient( |
| 72 | + colors: [Color(0x55FFFFFF), Colors.transparent]) |
| 73 | + : null), |
| 74 | + padding: EdgeInsets.only( |
| 75 | + top: SizeUtil.getAxisY(40.0), bottom: SizeUtil.getAxisY(20.0)), |
| 76 | + child: Container( |
| 77 | + child: Stack( |
| 78 | + children: <Widget>[ |
| 79 | + Container( |
| 80 | + height: SizeUtil.getAxisY(550.0), |
| 81 | + width: SizeUtil.getAxisX(613.0), |
| 82 | + child: Image.asset( |
| 83 | + index % 2 == 0 ? FeedImage.feed12_pic1 : FeedImage.feed12_pic2, |
| 84 | + fit: BoxFit.cover, |
| 85 | + height: SizeUtil.getAxisY(550.0), |
| 86 | + width: SizeUtil.getAxisX(613.0), |
| 87 | + ), |
| 88 | + ), |
| 89 | + Positioned( |
| 90 | + width: SizeUtil.getAxisBoth(CIRCLE_BUTTON_HEIGHT), |
| 91 | + height: SizeUtil.getAxisBoth(CIRCLE_BUTTON_HEIGHT), |
| 92 | + left: SizeUtil.getAxisX(24.0), |
| 93 | + bottom: SizeUtil.getAxisY(89.0), |
| 94 | + child: Image.asset( |
| 95 | + FeedImage.feed12_header, |
| 96 | + fit: BoxFit.cover, |
| 97 | + ), |
| 98 | + ), |
| 99 | + Positioned( |
| 100 | + left: SizeUtil.getAxisX(160.0), |
| 101 | + bottom: SizeUtil.getAxisY(10.0), |
| 102 | + child: _listItemName(), |
| 103 | + ), |
| 104 | + Positioned( |
| 105 | + right: SizeUtil.getAxisX(40.0), |
| 106 | + top: SizeUtil.getAxisY(40.0), |
| 107 | + child: _listItemAction(), |
| 108 | + ) |
| 109 | + ], |
| 110 | + )), |
| 111 | + ); |
| 112 | + |
| 113 | + Widget _body() => ListView.builder( |
| 114 | + itemBuilder: (context, index) { |
| 115 | + return _listItem(index); |
| 116 | + }, |
| 117 | + itemCount: 4, |
| 118 | + padding: EdgeInsets.only(top: 0.1), |
| 119 | + ); |
| 120 | + |
14 | 121 | @override
|
15 | 122 | Widget build(BuildContext context) {
|
16 | 123 | return Scaffold(
|
17 |
| - appBar: AppBar( |
18 |
| - title: Text("Feed Twelve"), |
| 124 | + body: Container( |
| 125 | + decoration: BoxDecoration( |
| 126 | + gradient: LinearGradient( |
| 127 | + colors: [YELLOW, GREEN], |
| 128 | + begin: Alignment.topLeft, |
| 129 | + end: Alignment.centerLeft)), |
| 130 | + child: Column( |
| 131 | + mainAxisAlignment: MainAxisAlignment.start, |
| 132 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 133 | + children: <Widget>[ |
| 134 | + TopTitleBar(), |
| 135 | + Expanded( |
| 136 | + child: Stack( |
| 137 | + children: <Widget>[ |
| 138 | + _body(), |
| 139 | + Positioned( |
| 140 | + width: SizeUtil.width, |
| 141 | + bottom: SizeUtil.getAxisY(41.0), |
| 142 | + child: Row( |
| 143 | + mainAxisAlignment: MainAxisAlignment.center, |
| 144 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 145 | + children: <Widget>[ |
| 146 | + FloatingActionButton( |
| 147 | + onPressed: () { |
| 148 | + print("you have pressed the button"); |
| 149 | + }, |
| 150 | + child: Image.asset(FeedImage.feed12_plus), |
| 151 | + ) |
| 152 | + ], |
| 153 | + ), |
| 154 | + ) |
| 155 | + ], |
| 156 | + ), |
| 157 | + ), |
| 158 | + ], |
19 | 159 | ),
|
20 |
| - body: Text("Feed page Twelve"), |
21 |
| - ); |
| 160 | + )); |
22 | 161 | }
|
23 | 162 | }
|
0 commit comments