|
1 | 1 | import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter_mobile_2school/src/resources/hard/hard_post.dart'; |
| 3 | +import 'package:flutter_mobile_2school/src/themes/app_colors.dart'; |
| 4 | +import 'package:flutter_mobile_2school/src/themes/app_decorations.dart'; |
| 5 | +import 'package:flutter_mobile_2school/src/themes/font_family.dart'; |
| 6 | +import 'package:flutter_mobile_2school/src/ui/classes/widgets/recommend_class_card.dart'; |
| 7 | +import 'package:phosphor_flutter/phosphor_flutter.dart'; |
| 8 | +import 'package:sizer/sizer.dart'; |
2 | 9 |
|
3 | 10 | class ProfileScreen extends StatefulWidget { |
4 | 11 | @override |
5 | 12 | State<StatefulWidget> createState() => _ProfileScreenState(); |
6 | 13 | } |
7 | 14 |
|
8 | 15 | class _ProfileScreenState extends State<ProfileScreen> { |
| 16 | + ScrollController scrollController = ScrollController(); |
| 17 | + bool _showInfo = true; |
| 18 | + |
| 19 | + @override |
| 20 | + void initState() { |
| 21 | + super.initState(); |
| 22 | + scrollController.addListener(() { |
| 23 | + if (scrollController.offset < 8.0) { |
| 24 | + if (!_showInfo) { |
| 25 | + setState(() { |
| 26 | + _showInfo = true; |
| 27 | + }); |
| 28 | + } |
| 29 | + } else { |
| 30 | + if (_showInfo) { |
| 31 | + setState(() { |
| 32 | + _showInfo = false; |
| 33 | + }); |
| 34 | + } |
| 35 | + } |
| 36 | + }); |
| 37 | + } |
| 38 | + |
9 | 39 | @override |
10 | 40 | Widget build(BuildContext context) { |
11 | 41 | return Scaffold( |
12 | | - body: Container(), |
| 42 | + appBar: AppBar( |
| 43 | + brightness: Theme.of(context).brightness, |
| 44 | + backgroundColor: Colors.transparent, |
| 45 | + elevation: .0, |
| 46 | + centerTitle: true, |
| 47 | + leading: IconButton( |
| 48 | + splashColor: colorPrimary, |
| 49 | + splashRadius: 5.0, |
| 50 | + icon: Icon( |
| 51 | + PhosphorIcons.slidersHorizontal, |
| 52 | + size: 22.5.sp, |
| 53 | + ), |
| 54 | + onPressed: () => null, |
| 55 | + ), |
| 56 | + title: Text( |
| 57 | + _showInfo ? '' : 'Đào Hồng Vinh', |
| 58 | + style: TextStyle( |
| 59 | + fontSize: 15.sp, |
| 60 | + fontWeight: FontWeight.w400, |
| 61 | + fontFamily: FontFamily.lato, |
| 62 | + color: Theme.of(context).textTheme.bodyText1!.color, |
| 63 | + ), |
| 64 | + ), |
| 65 | + actions: [ |
| 66 | + IconButton( |
| 67 | + splashRadius: 10.0, |
| 68 | + icon: Icon( |
| 69 | + PhosphorIcons.rows, |
| 70 | + size: 22.5.sp, |
| 71 | + ), |
| 72 | + onPressed: () => null, |
| 73 | + ), |
| 74 | + ], |
| 75 | + ), |
| 76 | + body: Container( |
| 77 | + height: 100.h, |
| 78 | + width: 100.w, |
| 79 | + child: Column( |
| 80 | + children: [ |
| 81 | + GestureDetector( |
| 82 | + onTap: () => null, |
| 83 | + child: Container( |
| 84 | + width: 100.w, |
| 85 | + alignment: Alignment.center, |
| 86 | + child: Container( |
| 87 | + height: 108.sp, |
| 88 | + width: 108.sp, |
| 89 | + decoration: BoxDecoration( |
| 90 | + shape: BoxShape.circle, |
| 91 | + border: Border.all( |
| 92 | + color: colorPrimary, |
| 93 | + width: 3.sp, |
| 94 | + ), |
| 95 | + ), |
| 96 | + alignment: Alignment.center, |
| 97 | + child: Container( |
| 98 | + height: 96.sp, |
| 99 | + width: 96.sp, |
| 100 | + decoration: BoxDecoration( |
| 101 | + shape: BoxShape.circle, |
| 102 | + image: DecorationImage( |
| 103 | + image: NetworkImage( |
| 104 | + 'https://avatars.githubusercontent.com/u/60530946?v=4', |
| 105 | + ), |
| 106 | + fit: BoxFit.cover, |
| 107 | + ), |
| 108 | + ), |
| 109 | + ), |
| 110 | + ), |
| 111 | + ), |
| 112 | + ), |
| 113 | + _showInfo |
| 114 | + ? Column( |
| 115 | + children: [ |
| 116 | + SizedBox(height: 10.sp), |
| 117 | + Text( |
| 118 | + 'Đào Hồng Vinh', |
| 119 | + maxLines: 1, |
| 120 | + overflow: TextOverflow.ellipsis, |
| 121 | + style: TextStyle( |
| 122 | + fontSize: 14.sp, |
| 123 | + fontFamily: FontFamily.lato, |
| 124 | + fontWeight: FontWeight.w600, |
| 125 | + ), |
| 126 | + ), |
| 127 | + SizedBox(height: 6.sp), |
| 128 | + Container( |
| 129 | + padding: EdgeInsets.symmetric(horizontal: 10.w), |
| 130 | + alignment: Alignment.center, |
| 131 | + child: Text( |
| 132 | + 'Mobile App Developer (lambiengcode)', |
| 133 | + maxLines: 2, |
| 134 | + overflow: TextOverflow.ellipsis, |
| 135 | + style: TextStyle( |
| 136 | + fontSize: 11.5.sp, |
| 137 | + fontFamily: FontFamily.lato, |
| 138 | + fontWeight: FontWeight.w500, |
| 139 | + ), |
| 140 | + textAlign: TextAlign.center, |
| 141 | + ), |
| 142 | + ), |
| 143 | + SizedBox(height: 18.sp), |
| 144 | + _buildInfoBar(), |
| 145 | + ], |
| 146 | + ) |
| 147 | + : Container(), |
| 148 | + SizedBox(height: 12.sp), |
| 149 | + _buildTitle( |
| 150 | + 'Archive', |
| 151 | + PhosphorIcons.starFill, |
| 152 | + Colors.amberAccent.shade700, |
| 153 | + ), |
| 154 | + SizedBox(height: 4.sp), |
| 155 | + Expanded( |
| 156 | + child: ListView.builder( |
| 157 | + controller: scrollController, |
| 158 | + padding: EdgeInsets.only(bottom: 12.sp), |
| 159 | + physics: ClampingScrollPhysics(), |
| 160 | + itemCount: posts.length, |
| 161 | + itemBuilder: (context, index) { |
| 162 | + return RecommendClassCard( |
| 163 | + imageClass: posts[index].imageGroup, |
| 164 | + className: posts[index].groupName, |
| 165 | + star: '4.5 / 5.0', |
| 166 | + teacher: posts[index].authorName, |
| 167 | + ); |
| 168 | + }, |
| 169 | + ), |
| 170 | + ), |
| 171 | + ], |
| 172 | + ), |
| 173 | + ), |
| 174 | + ); |
| 175 | + } |
| 176 | + |
| 177 | + Widget _buildInfoBar() { |
| 178 | + return Container( |
| 179 | + width: 100.w, |
| 180 | + margin: EdgeInsets.symmetric(horizontal: 20.sp), |
| 181 | + padding: EdgeInsets.symmetric(vertical: 14.sp), |
| 182 | + decoration: AppDecoration.buttonActionBorder(context, 6.sp).decoration, |
| 183 | + child: Row( |
| 184 | + children: [ |
| 185 | + _buildInfo(context, 'Archive', '88'), |
| 186 | + _buildCustomDivider(), |
| 187 | + _buildInfo(context, 'Learning', '593'), |
| 188 | + _buildCustomDivider(), |
| 189 | + _buildInfo(context, 'Friend', '241'), |
| 190 | + ], |
| 191 | + ), |
| 192 | + ); |
| 193 | + } |
| 194 | + |
| 195 | + Widget _buildInfo(context, title, value) { |
| 196 | + return Expanded( |
| 197 | + child: GestureDetector( |
| 198 | + onTap: () => null, |
| 199 | + child: Container( |
| 200 | + color: Colors.transparent, |
| 201 | + child: Column( |
| 202 | + children: [ |
| 203 | + Text( |
| 204 | + title, |
| 205 | + style: TextStyle( |
| 206 | + fontFamily: FontFamily.lato, |
| 207 | + fontSize: 10.75.sp, |
| 208 | + fontWeight: FontWeight.w400, |
| 209 | + color: Theme.of(context) |
| 210 | + .textTheme |
| 211 | + .bodyText1! |
| 212 | + .color! |
| 213 | + .withOpacity(.9), |
| 214 | + ), |
| 215 | + ), |
| 216 | + SizedBox(height: 6.5.sp), |
| 217 | + Text( |
| 218 | + value, |
| 219 | + style: TextStyle( |
| 220 | + fontSize: 13.5.sp, |
| 221 | + fontWeight: FontWeight.w500, |
| 222 | + color: Theme.of(context).textTheme.bodyText1!.color, |
| 223 | + ), |
| 224 | + ), |
| 225 | + ], |
| 226 | + ), |
| 227 | + ), |
| 228 | + ), |
| 229 | + ); |
| 230 | + } |
| 231 | + |
| 232 | + Widget _buildCustomDivider() { |
| 233 | + return Container( |
| 234 | + height: 40.sp, |
| 235 | + child: VerticalDivider( |
| 236 | + width: .25, |
| 237 | + thickness: .25, |
| 238 | + color: colorPrimary, |
| 239 | + ), |
| 240 | + ); |
| 241 | + } |
| 242 | + |
| 243 | + _buildTitle(title, icon, color) { |
| 244 | + return Container( |
| 245 | + padding: EdgeInsets.only(left: 16.sp, right: 8.sp), |
| 246 | + child: Row( |
| 247 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 248 | + children: [ |
| 249 | + Row( |
| 250 | + children: [ |
| 251 | + Icon( |
| 252 | + icon, |
| 253 | + size: 16.sp, |
| 254 | + color: color, |
| 255 | + ), |
| 256 | + SizedBox(width: 6.sp), |
| 257 | + Text( |
| 258 | + title, |
| 259 | + style: TextStyle( |
| 260 | + fontSize: 14.sp, |
| 261 | + fontWeight: FontWeight.w600, |
| 262 | + fontFamily: FontFamily.lato, |
| 263 | + color: color, |
| 264 | + ), |
| 265 | + ), |
| 266 | + ], |
| 267 | + ), |
| 268 | + IconButton( |
| 269 | + onPressed: () => null, |
| 270 | + icon: Icon( |
| 271 | + PhosphorIcons.pushPinFill, |
| 272 | + size: 20.sp, |
| 273 | + ), |
| 274 | + ), |
| 275 | + ], |
| 276 | + ), |
13 | 277 | ); |
14 | 278 | } |
15 | 279 | } |
0 commit comments