import 'dart:io'; import 'dart:math'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:sport/bean/jog/detail.dart'; import 'package:sport/pages/run/run_page.dart'; import 'package:sport/provider/user_model.dart'; import 'package:sport/utils/DateFormat.dart'; import 'package:sport/utils/sport_utils.dart'; import 'package:sport/widgets/image.dart'; import 'package:sport/widgets/misc.dart'; List inspirationalPhrases = [ "坚韧不拔,奋力拼搏", "生无所息,斗无所止", "一张一弛,文武之道", "青春最美,青春无悔", "含泪播种,含笑收获", "博观细取,厚积薄发", "慎而思之,勤而行之", "分分秒秒,构筑辉煌", "参与运动,逐梦未来", "超越自己,永不放弃", "坚持到底,至死不渝", "锲而不舍,存义精思", "志存高远,心系天下", "点燃梦想,铸就辉煌", "超越极限,展现自我", "十年树人,百年树木", "力求有功,方能无过", "团结一心,勇往直前", "奋力拼搏,负重奋进", "锲而不舍,金石可镂", "挥动激情,放飞梦想", "发奋进取,勇夺第一", "顽强拼搏,超越自我", "奋勇拼搏,披荆斩棘", "磨练意志,强健体魄", "凌翅九霄,问鼎苍穹", "锲而舍之,朽木不折", "一鼓作气,挑战佳绩", "勤奋踏实,诚实守信", "海纳百川,厚积薄发", "砥砺精神,团结奋进", "团结奋进,自律自强", "放飞理想,勇于高攀", "物我两忘,勇往直前", "头雁先飞,群雁齐追", "坚持不懈,永不放弃", "快乐运动,健康同行", "我若为王,谁敢争雄!", "正因自信,因此成功", "积极进步,奋力拼搏", "比出风采,超越自我", "逆水行舟,不进则退", "力挫群雄,舍我其谁", "英勇顽强,一往无前", "良性竞争,超越自己", "天行健,君子以自强不息", "吃得苦中苦,方为人上人", "站得更高才能看得更远", "懒惰包含着永久的失望", "相信你行,你就活力无穷", "勇士的心胸,能容下大海", "努力拼搏,尽力做到最好", "喜欢做别人不愿做的事", "只要功夫深,铁杵磨成针", "积土而为山,积水而为海", "你可以平凡,但不能平庸", "每天进一步,踏上成功路", "苦想没盼头,苦干有奔头", "不努力的梦想都是瞎想", "征服自己,就能征服一切", "只要我想赢,你就是个渣", "你有多努力,就有多幸运", "心有多大,舞台就有多大", "胸有凌云志,无高不可攀", "成功由大量的失望铸就", "一个今天胜过两个明天", "拼一载春秋,搏一生无悔", "有志登山顶,无志站山脚", "博观而约取,厚积而薄发", "人生志气立,所贵功业昌", "火把倒下,火焰依然向上", "你不勇敢,没人替你坚强!", "丈夫志不大,何以佐乾坤", "前不见古人,后不见来者", "只要有斗志,不怕没战场", "不经历风雨,怎么见彩虹", "耐得住寂寞,守得住繁华!", "试试就能行,争争就能赢", "不辜负生活,不迷失方向", "志高山峰矮,路从脚下伸", "烂麻搓成绳,也能拉千斤", "时光不回头,当下最重要", "命运从来不会同情弱者", "穷且益坚,不坠青云之志", "每天早上,记得鼓励自己", "要学惊人艺,须下苦功夫", "再努一把力,发奋再发奋!", "人活一天就要努力一天", "钟不敲不鸣,人不学不灵", "世上无难事,只要肯攀登", "事常与人违,事总在人为", "我们各自努力,最高处见", "争分夺秒,赢得最后胜利", "先一步失败,早一步成功", "坚持努力,才能获得成功", "胸有千里志,脚有万里路", "时光不回头,当下才重要", "前方无绝路,希望在转角", "我成功,因为我志在成功", "不是没有用,而是没去用", "加油,相信自己是可以的", "脚是大地上飞翔的翅膀", "生命在于运动", "运动是一切生命的源泉", "人的健全,不但靠饮食,尤靠运动", "运动是健康的源泉,也是长寿的秘诀" ]; class RunShareSimple extends StatefulWidget { final JogDetail detail; final File map; final GlobalKey repaintWidgetKey; const RunShareSimple({Key? key, required this.detail, required this.map, required this.repaintWidgetKey}) : super(key: key); @override State createState() { return _PageState(); } } class _PageState extends State with AutomaticKeepAliveClientMixin { late String title; @override void initState() { super.initState(); title = inspirationalPhrases[Random().nextInt(inspirationalPhrases.length)]; } _init(){ setState(() { title = inspirationalPhrases[Random().nextInt(inspirationalPhrases.length)]; }); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { List images = [ "http://static.ouj.com/shoes/share/2a5a923a279f40e6b748738567201122.jpg", "http://static.ouj.com/shoes/share/8b114b50bb304c47b24e208a6178834b.jpg", "http://static.ouj.com/shoes/share/e29353f9d5d44e5d84470b847e97edda.jpg", "http://static.ouj.com/shoes/share/43333533ac544f258c6b956ebae3d113.jpg", "http://static.ouj.com/shoes/share/17517327f9484bf5a424af6b0575ed97.jpg", "http://static.ouj.com/shoes/share/134f84afaac341a2b7ad78e685f5f7c8.jpg", "http://static.ouj.com/shoes/share/7e29848e3b454d138761f42dd4aebd2e.jpg", "http://static.ouj.com/shoes/share/e0c8a740684249a2a01de2d38f764976.jpg", "http://static.ouj.com/shoes/share/160d3d44c3e94d7b8b7a3877795d3382.jpg", "http://static.ouj.com/shoes/share/77ca189000874d659fb7dd74fcbb5c31.jpg", "http://static.ouj.com/shoes/share/ac9ea19959144ec49fa9c71920a0c2eb.jpg", "http://static.ouj.com/shoes/share/43737b5a01244a54a9d9fca33f6dd4fc.jpg", "http://static.ouj.com/shoes/share/64eefb9e07d0459f863e1cefe5bc3f6e.jpg", "http://static.ouj.com/shoes/share/2fabe655df5b4506b21e863f55ab7fcc.jpg", "http://static.ouj.com/shoes/share/0977c4f9600e4246a53ed74b4be54c1c.jpg", "http://static.ouj.com/shoes/share/f08b46054b96456e975b2bff7e0164d2.jpg", "http://static.ouj.com/shoes/share/069b6df74d6e4637a296ebc6280931b0.jpg", "http://static.ouj.com/shoes/share/188ab172885044dead5a03941538e197.jpg", "http://static.ouj.com/shoes/share/cf67cc513cb547dc954849cc3f32b59f.jpg", "http://static.ouj.com/shoes/share/54c8e8d58a3442c9ad08618cb683a796.jpg" ]; return Column( mainAxisSize: MainAxisSize.min, children: [ GestureDetector( onTap: _init, child: RepaintBoundary( key: widget.repaintWidgetKey, child: ClipRRect( borderRadius: BorderRadius.circular(10), child: Container( height: 375.0, child: Stack( fit: StackFit.expand, children: [ Image.network( images[Random().nextInt(images.length)], fit: BoxFit.cover, ), Positioned( left: 0, right: 16.0, top: 20.0, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Consumer( builder: (_, model, __) => Row( children: [ Container( margin: const EdgeInsets.fromLTRB(20.0, 0, 12, 0), padding: const EdgeInsets.all(2), decoration: BoxDecoration(color: Colors.white, shape: BoxShape.circle), child: CircleAvatar( backgroundColor: Colors.black26, backgroundImage: userAvatarProvider(model.user.avatar), radius: 20.0, ), ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(model.user.name, style: Theme.of(context).textTheme.headline4!), const SizedBox( height: 4, ), Text( "${SportUtils.toDateTimeFullCh(DateTime.parse(widget.detail.begin ?? ""))}", style: Theme.of(context).textTheme.subtitle2!.copyWith(color: Colors.white), ), ], ), Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Image.asset( "lib/assets/img/logo_img_white_30.png", width: 30.0, height: 30.0, ), const SizedBox(width: 7), Text("趣动", style: Theme.of(context).textTheme.subtitle1!.copyWith(color: Colors.white)), ], ), ), ], ), ), Padding( padding: const EdgeInsets.fromLTRB(20.0, 30, 0, 0), child: Text( "$title", style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 18.0), ), ), ], ), ), Positioned( left: 0.0, right: 0, bottom: 0, child: Container( color: Colors.black.withOpacity(.46), width: double.infinity, padding: const EdgeInsets.all(16.0), child: Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ ClipRRect( child: Container( color: Colors.grey, child: Image.file( widget.map, fit: BoxFit.cover, width: 70.0, height: 70.0, ), ), borderRadius: BorderRadius.circular(6), ), const SizedBox(width: 16.0,), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Text( "${formatNum((widget.detail.distance ?? 0) / 1000.0, 2)}", style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 40.0, fontFamily: "DIN"), strutStyle: fixedLine, ), Text( "公里", style: Theme.of(context).textTheme.bodyText2!.copyWith(color: Colors.white), ) ], crossAxisAlignment: CrossAxisAlignment.end, ), const SizedBox(height: 8,), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Image.asset("lib/assets/img/trajectory_icon_1.png"), const SizedBox(width: 7,), Text( "${DateFormat.toTime(widget.detail.duration ?? 0)}", style: Theme.of(context).textTheme.headline4!.copyWith(fontFamily: "DIN"), ) ], ), Row( children: [ Image.asset("lib/assets/img/trajectory_icon_2.png"), const SizedBox(width: 7,), Row( children: [ Text( "${SportUtils.pace11(SportUtils.calPace(widget.detail.duration ?? 0, (widget.detail.distance ?? 0) / 1000))}", style: Theme.of(context).textTheme.headline4!.copyWith(fontFamily: "DIN"), ), Text( "′", style: Theme.of(context).textTheme.headline4!, ), Text( "${SportUtils.pace12(SportUtils.calPace(widget.detail.duration ?? 0, (widget.detail.distance ?? 0) / 1000))}", style: Theme.of(context).textTheme.headline4!.copyWith(fontFamily: "DIN"), ), Text( "″", style: Theme.of(context).textTheme.headline4!, ), ], ), ], ), Row( children: [ Image.asset("lib/assets/img/trajectory_icon_3.png"), const SizedBox(width: 7,), Text( "${widget.detail.consume ?? 0}", style: Theme.of(context).textTheme.headline4!.copyWith(fontFamily: "DIN"), ), Text( " 大卡", style: Theme.of(context).textTheme.bodyText1!.copyWith(fontSize: 10.0), ), ], ), ], ), ], ), ), ], ), )), ], ), ), ), ), ), ], ); } @override bool get wantKeepAlive => true; }