run_share_simple.dart 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. import 'dart:io';
  2. import 'dart:math';
  3. import 'package:cached_network_image/cached_network_image.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:provider/provider.dart';
  6. import 'package:sport/bean/jog/detail.dart';
  7. import 'package:sport/pages/run/run_page.dart';
  8. import 'package:sport/provider/user_model.dart';
  9. import 'package:sport/utils/DateFormat.dart';
  10. import 'package:sport/utils/sport_utils.dart';
  11. import 'package:sport/widgets/image.dart';
  12. import 'package:sport/widgets/misc.dart';
  13. List<String> inspirationalPhrases = [
  14. "坚韧不拔,奋力拼搏",
  15. "生无所息,斗无所止",
  16. "一张一弛,文武之道",
  17. "青春最美,青春无悔",
  18. "含泪播种,含笑收获",
  19. "博观细取,厚积薄发",
  20. "慎而思之,勤而行之",
  21. "分分秒秒,构筑辉煌",
  22. "参与运动,逐梦未来",
  23. "超越自己,永不放弃",
  24. "坚持到底,至死不渝",
  25. "锲而不舍,存义精思",
  26. "志存高远,心系天下",
  27. "点燃梦想,铸就辉煌",
  28. "超越极限,展现自我",
  29. "十年树人,百年树木",
  30. "力求有功,方能无过",
  31. "团结一心,勇往直前",
  32. "奋力拼搏,负重奋进",
  33. "锲而不舍,金石可镂",
  34. "挥动激情,放飞梦想",
  35. "发奋进取,勇夺第一",
  36. "顽强拼搏,超越自我",
  37. "奋勇拼搏,披荆斩棘",
  38. "磨练意志,强健体魄",
  39. "凌翅九霄,问鼎苍穹",
  40. "锲而舍之,朽木不折",
  41. "一鼓作气,挑战佳绩",
  42. "勤奋踏实,诚实守信",
  43. "海纳百川,厚积薄发",
  44. "砥砺精神,团结奋进",
  45. "团结奋进,自律自强",
  46. "放飞理想,勇于高攀",
  47. "物我两忘,勇往直前",
  48. "头雁先飞,群雁齐追",
  49. "坚持不懈,永不放弃",
  50. "快乐运动,健康同行",
  51. "我若为王,谁敢争雄!",
  52. "正因自信,因此成功",
  53. "积极进步,奋力拼搏",
  54. "比出风采,超越自我",
  55. "逆水行舟,不进则退",
  56. "力挫群雄,舍我其谁",
  57. "英勇顽强,一往无前",
  58. "良性竞争,超越自己",
  59. "天行健,君子以自强不息",
  60. "吃得苦中苦,方为人上人",
  61. "站得更高才能看得更远",
  62. "懒惰包含着永久的失望",
  63. "相信你行,你就活力无穷",
  64. "勇士的心胸,能容下大海",
  65. "努力拼搏,尽力做到最好",
  66. "喜欢做别人不愿做的事",
  67. "只要功夫深,铁杵磨成针",
  68. "积土而为山,积水而为海",
  69. "你可以平凡,但不能平庸",
  70. "每天进一步,踏上成功路",
  71. "苦想没盼头,苦干有奔头",
  72. "不努力的梦想都是瞎想",
  73. "征服自己,就能征服一切",
  74. "只要我想赢,你就是个渣",
  75. "你有多努力,就有多幸运",
  76. "心有多大,舞台就有多大",
  77. "胸有凌云志,无高不可攀",
  78. "成功由大量的失望铸就",
  79. "一个今天胜过两个明天",
  80. "拼一载春秋,搏一生无悔",
  81. "有志登山顶,无志站山脚",
  82. "博观而约取,厚积而薄发",
  83. "人生志气立,所贵功业昌",
  84. "火把倒下,火焰依然向上",
  85. "你不勇敢,没人替你坚强!",
  86. "丈夫志不大,何以佐乾坤",
  87. "前不见古人,后不见来者",
  88. "只要有斗志,不怕没战场",
  89. "不经历风雨,怎么见彩虹",
  90. "耐得住寂寞,守得住繁华!",
  91. "试试就能行,争争就能赢",
  92. "不辜负生活,不迷失方向",
  93. "志高山峰矮,路从脚下伸",
  94. "烂麻搓成绳,也能拉千斤",
  95. "时光不回头,当下最重要",
  96. "命运从来不会同情弱者",
  97. "穷且益坚,不坠青云之志",
  98. "每天早上,记得鼓励自己",
  99. "要学惊人艺,须下苦功夫",
  100. "再努一把力,发奋再发奋!",
  101. "人活一天就要努力一天",
  102. "钟不敲不鸣,人不学不灵",
  103. "世上无难事,只要肯攀登",
  104. "事常与人违,事总在人为",
  105. "我们各自努力,最高处见",
  106. "争分夺秒,赢得最后胜利",
  107. "先一步失败,早一步成功",
  108. "坚持努力,才能获得成功",
  109. "胸有千里志,脚有万里路",
  110. "时光不回头,当下才重要",
  111. "前方无绝路,希望在转角",
  112. "我成功,因为我志在成功",
  113. "不是没有用,而是没去用",
  114. "加油,相信自己是可以的",
  115. "脚是大地上飞翔的翅膀",
  116. "生命在于运动",
  117. "运动是一切生命的源泉",
  118. "人的健全,不但靠饮食,尤靠运动",
  119. "运动是健康的源泉,也是长寿的秘诀"
  120. ];
  121. class RunShareSimple extends StatefulWidget {
  122. final JogDetail detail;
  123. final File map;
  124. final GlobalKey repaintWidgetKey;
  125. const RunShareSimple({Key? key, required this.detail, required this.map, required this.repaintWidgetKey}) : super(key: key);
  126. @override
  127. State<StatefulWidget> createState() {
  128. return _PageState();
  129. }
  130. }
  131. class _PageState extends State<RunShareSimple> with AutomaticKeepAliveClientMixin {
  132. late String title;
  133. @override
  134. void initState() {
  135. super.initState();
  136. title = inspirationalPhrases[Random().nextInt(inspirationalPhrases.length)];
  137. }
  138. _init(){
  139. setState(() {
  140. title = inspirationalPhrases[Random().nextInt(inspirationalPhrases.length)];
  141. });
  142. }
  143. @override
  144. void dispose() {
  145. super.dispose();
  146. }
  147. @override
  148. Widget build(BuildContext context) {
  149. List<String> images = [
  150. "http://static.ouj.com/shoes/share/2a5a923a279f40e6b748738567201122.jpg",
  151. "http://static.ouj.com/shoes/share/8b114b50bb304c47b24e208a6178834b.jpg",
  152. "http://static.ouj.com/shoes/share/e29353f9d5d44e5d84470b847e97edda.jpg",
  153. "http://static.ouj.com/shoes/share/43333533ac544f258c6b956ebae3d113.jpg",
  154. "http://static.ouj.com/shoes/share/17517327f9484bf5a424af6b0575ed97.jpg",
  155. "http://static.ouj.com/shoes/share/134f84afaac341a2b7ad78e685f5f7c8.jpg",
  156. "http://static.ouj.com/shoes/share/7e29848e3b454d138761f42dd4aebd2e.jpg",
  157. "http://static.ouj.com/shoes/share/e0c8a740684249a2a01de2d38f764976.jpg",
  158. "http://static.ouj.com/shoes/share/160d3d44c3e94d7b8b7a3877795d3382.jpg",
  159. "http://static.ouj.com/shoes/share/77ca189000874d659fb7dd74fcbb5c31.jpg",
  160. "http://static.ouj.com/shoes/share/ac9ea19959144ec49fa9c71920a0c2eb.jpg",
  161. "http://static.ouj.com/shoes/share/43737b5a01244a54a9d9fca33f6dd4fc.jpg",
  162. "http://static.ouj.com/shoes/share/64eefb9e07d0459f863e1cefe5bc3f6e.jpg",
  163. "http://static.ouj.com/shoes/share/2fabe655df5b4506b21e863f55ab7fcc.jpg",
  164. "http://static.ouj.com/shoes/share/0977c4f9600e4246a53ed74b4be54c1c.jpg",
  165. "http://static.ouj.com/shoes/share/f08b46054b96456e975b2bff7e0164d2.jpg",
  166. "http://static.ouj.com/shoes/share/069b6df74d6e4637a296ebc6280931b0.jpg",
  167. "http://static.ouj.com/shoes/share/188ab172885044dead5a03941538e197.jpg",
  168. "http://static.ouj.com/shoes/share/cf67cc513cb547dc954849cc3f32b59f.jpg",
  169. "http://static.ouj.com/shoes/share/54c8e8d58a3442c9ad08618cb683a796.jpg"
  170. ];
  171. return Column(
  172. mainAxisSize: MainAxisSize.min,
  173. children: [
  174. GestureDetector(
  175. onTap: _init,
  176. child: RepaintBoundary(
  177. key: widget.repaintWidgetKey,
  178. child: ClipRRect(
  179. borderRadius: BorderRadius.circular(10),
  180. child: Container(
  181. height: 375.0,
  182. child: Stack(
  183. fit: StackFit.expand,
  184. children: [
  185. Image.network(
  186. images[Random().nextInt(images.length)],
  187. fit: BoxFit.cover,
  188. ),
  189. Positioned(
  190. left: 0,
  191. right: 16.0,
  192. top: 20.0,
  193. child: Column(
  194. crossAxisAlignment: CrossAxisAlignment.start,
  195. children: [
  196. Consumer<UserModel>(
  197. builder: (_, model, __) => Row(
  198. children: [
  199. Container(
  200. margin: const EdgeInsets.fromLTRB(20.0, 0, 12, 0),
  201. padding: const EdgeInsets.all(2),
  202. decoration: BoxDecoration(color: Colors.white, shape: BoxShape.circle),
  203. child: CircleAvatar(
  204. backgroundColor: Colors.black26,
  205. backgroundImage: userAvatarProvider(model.user.avatar),
  206. radius: 20.0,
  207. ),
  208. ),
  209. Column(
  210. crossAxisAlignment: CrossAxisAlignment.start,
  211. children: [
  212. Text(model.user.name, style: Theme.of(context).textTheme.headline4!),
  213. const SizedBox(
  214. height: 4,
  215. ),
  216. Text(
  217. "${SportUtils.toDateTimeFullCh(DateTime.parse(widget.detail.begin ?? ""))}",
  218. style: Theme.of(context).textTheme.subtitle2!.copyWith(color: Colors.white),
  219. ),
  220. ],
  221. ),
  222. Expanded(
  223. child: Row(
  224. mainAxisAlignment: MainAxisAlignment.end,
  225. children: [
  226. Image.asset(
  227. "lib/assets/img/logo_img_white_30.png",
  228. width: 30.0,
  229. height: 30.0,
  230. ),
  231. const SizedBox(width: 7),
  232. Text("趣动", style: Theme.of(context).textTheme.subtitle1!.copyWith(color: Colors.white)),
  233. ],
  234. ),
  235. ),
  236. ],
  237. ),
  238. ),
  239. Padding(
  240. padding: const EdgeInsets.fromLTRB(20.0, 30, 0, 0),
  241. child: Text(
  242. "$title",
  243. style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 18.0),
  244. ),
  245. ),
  246. ],
  247. ),
  248. ),
  249. Positioned(
  250. left: 0.0,
  251. right: 0,
  252. bottom: 0,
  253. child: Container(
  254. color: Colors.black.withOpacity(.46),
  255. width: double.infinity,
  256. padding: const EdgeInsets.all(16.0),
  257. child: Row(
  258. crossAxisAlignment: CrossAxisAlignment.end,
  259. children: [
  260. ClipRRect(
  261. child: Container(
  262. color: Colors.grey,
  263. child: Image.file(
  264. widget.map,
  265. fit: BoxFit.cover,
  266. width: 70.0,
  267. height: 70.0,
  268. ),
  269. ),
  270. borderRadius: BorderRadius.circular(6),
  271. ),
  272. const SizedBox(width: 16.0,),
  273. Expanded(
  274. child: Column(
  275. crossAxisAlignment: CrossAxisAlignment.start,
  276. children: [
  277. Row(
  278. children: [
  279. Text(
  280. "${formatNum((widget.detail.distance ?? 0) / 1000.0, 2)}",
  281. style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 40.0, fontFamily: "DIN"),
  282. strutStyle: fixedLine,
  283. ),
  284. Text(
  285. "公里",
  286. style: Theme.of(context).textTheme.bodyText2!.copyWith(color: Colors.white),
  287. )
  288. ],
  289. crossAxisAlignment: CrossAxisAlignment.end,
  290. ),
  291. const SizedBox(height: 8,),
  292. Row(
  293. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  294. children: [
  295. Row(
  296. children: [
  297. Image.asset("lib/assets/img/trajectory_icon_1.png"),
  298. const SizedBox(width: 7,),
  299. Text(
  300. "${DateFormat.toTime(widget.detail.duration ?? 0)}",
  301. style: Theme.of(context).textTheme.headline4!.copyWith(fontFamily: "DIN"),
  302. )
  303. ],
  304. ),
  305. Row(
  306. children: [
  307. Image.asset("lib/assets/img/trajectory_icon_2.png"),
  308. const SizedBox(width: 7,),
  309. Row(
  310. children: [
  311. Text(
  312. "${SportUtils.pace11(SportUtils.calPace(widget.detail.duration ?? 0, (widget.detail.distance ?? 0) / 1000))}",
  313. style: Theme.of(context).textTheme.headline4!.copyWith(fontFamily: "DIN"),
  314. ),
  315. Text(
  316. "′",
  317. style: Theme.of(context).textTheme.headline4!,
  318. ),
  319. Text(
  320. "${SportUtils.pace12(SportUtils.calPace(widget.detail.duration ?? 0, (widget.detail.distance ?? 0) / 1000))}",
  321. style: Theme.of(context).textTheme.headline4!.copyWith(fontFamily: "DIN"),
  322. ),
  323. Text(
  324. "″",
  325. style: Theme.of(context).textTheme.headline4!,
  326. ),
  327. ],
  328. ),
  329. ],
  330. ),
  331. Row(
  332. children: [
  333. Image.asset("lib/assets/img/trajectory_icon_3.png"),
  334. const SizedBox(width: 7,),
  335. Text(
  336. "${widget.detail.consume ?? 0}",
  337. style: Theme.of(context).textTheme.headline4!.copyWith(fontFamily: "DIN"),
  338. ),
  339. Text(
  340. " 大卡",
  341. style: Theme.of(context).textTheme.bodyText1!.copyWith(fontSize: 10.0),
  342. ),
  343. ],
  344. ),
  345. ],
  346. ),
  347. ],
  348. ),
  349. ),
  350. ],
  351. ),
  352. )),
  353. ],
  354. ),
  355. ),
  356. ),
  357. ),
  358. ),
  359. ],
  360. );
  361. }
  362. @override
  363. bool get wantKeepAlive => true;
  364. }