123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- 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/game.dart';
- import 'package:sport/bean/sport_detail.dart';
- import 'package:sport/pages/run/run_share.dart';
- import 'package:sport/pages/run/run_share_simple.dart';
- import 'package:sport/provider/user_model.dart';
- import 'package:sport/utils/strings.dart';
- import 'package:sport/widgets/appbar.dart';
- import 'package:sport/widgets/image.dart';
- import 'package:sport/widgets/misc.dart';
- class SportHistorySharePage extends StatefulWidget {
- final Map<GameInfoData, RecordsTodaySum> gameRecord;
- final bool today;
- SportHistorySharePage(this.gameRecord, {this.today = false});
- @override
- State<StatefulWidget> createState() => _PageState();
- }
- class _PageState extends State<SportHistorySharePage> {
- late List<GlobalKey> keys;
- int _index = 0;
- @override
- void initState() {
- keys = List.filled(widget.gameRecord.length, GlobalKey());
- super.initState();
- }
- @override
- void dispose() {
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- List<GameInfoData> items = widget.gameRecord.keys.toList();
- String date = widget.gameRecord.values.first.getDate(0);
- return Scaffold(
- body: Stack(
- fit: StackFit.expand,
- children: [
- PageView.builder(
- itemCount: items.length,
- onPageChanged: (index) {
- _index = index;
- },
- itemBuilder: (context, index) {
- GameInfoData game = items[index];
- RecordsTodaySum record = widget.gameRecord[game]!;
- double duration = record.durationMin;
- int consume = record.consume;
- int step = record.step;
- int crouchCount = record.crouch;
- int jumpCount = record.jump;
- return SingleChildScrollView(
- child: RepaintBoundary(
- key: keys[index],
- child: Container(
- width: double.infinity,
- height: MediaQuery.of(context).size.width * 2.165333333333333,
- decoration: BoxDecoration(image: DecorationImage(image: CachedNetworkImageProvider(game.shareBg ?? "") , fit: BoxFit.fitHeight), color: Colors.black),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.fromLTRB(24.0, 120.0, 0, 0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- "${game.name}",
- style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 35.0),
- ),
- SizedBox(
- height: 5,
- ),
- Text(
- "${widget.today ? "今日":"$date"}共运动了${record.times}次",
- style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 18.0),
- ),
- SizedBox(
- height: 40,
- ),
- Text(
- "总消耗(大卡)",
- style: Theme.of(context).textTheme.headline6,
- ),
- SizedBox(
- height: 5,
- ),
- Text(
- "${consume}",
- style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 35.0, fontFamily: "DIN"),
- ),
- SizedBox(
- height: 40,
- ),
- Text(
- "总时长(分钟)",
- style: Theme.of(context).textTheme.headline6,
- ),
- SizedBox(
- height: 5,
- ),
- Text(
- "${toString(max(1.0, duration))}",
- style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 35.0, fontFamily: "DIN"),
- ),
- SizedBox(
- height: 30,
- ),
- Container(
- height: 120.0,
- child: Column(
- children: [
- Row(
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- Text(
- "总步数 ",
- style: Theme.of(context).textTheme.headline6,
- ),
- Text(
- "${step}",
- style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 20.0, fontFamily: "DIN"),
- strutStyle: fixedLine,
- ),
- Text(
- " 步",
- style: Theme.of(context).textTheme.headline6,
- ),
- ],
- ),
- if (crouchCount > 0)
- Padding(
- padding: const EdgeInsets.symmetric(vertical: 4.0),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- Text(
- "下蹲频率 ",
- style: Theme.of(context).textTheme.headline6,
- ),
- Text(
- "${(crouchCount / duration * 60).toStringAsFixed(1)}",
- style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 20.0, fontFamily: "DIN"),
- strutStyle: fixedLine,
- ),
- Text(
- " 次/分钟",
- style: Theme.of(context).textTheme.headline6,
- ),
- ],
- ),
- ),
- if (jumpCount > 0)
- Padding(
- padding: const EdgeInsets.symmetric(vertical: 4.0),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- Text(
- "跳跃频率 ",
- style: Theme.of(context).textTheme.headline6,
- ),
- Text(
- "${(jumpCount / duration * 60).toStringAsFixed(1)}",
- style: Theme.of(context).textTheme.headline4!.copyWith(fontSize: 20.0, fontFamily: "DIN"),
- strutStyle: fixedLine,
- ),
- Text(
- " 次/分钟",
- style: Theme.of(context).textTheme.headline6,
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- Consumer<UserModel>(builder: (_, model, __) {
- return Row(children: <Widget>[
- Container(
- width: 30,
- height: 30,
- decoration: BoxDecoration(border: Border.all(color: Colors.white, width: 1), borderRadius: BorderRadius.circular(30)),
- child: CircleAvatar(
- backgroundColor: Colors.black26,
- backgroundImage: userAvatarProvider(model.user.avatar),
- radius: 15,
- )),
- SizedBox(
- width: 12.0,
- ),
- Text(model.user.name, style: Theme.of(context).textTheme.headline4),
- ]);
- }),
- SizedBox(
- height: 10,
- ),
- // Text("$date", style: Theme.of(context).textTheme.subtitle1!.copyWith(color: Colors.white)),
- Container(
- padding: EdgeInsets.all(12),
- margin: EdgeInsets.only(top: 20),
- decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: Color(0xff0C0C0C).withOpacity(.3)),
- child: Text("${inspirationalPhrases[Random().nextInt(inspirationalPhrases.length)]}", style: Theme.of(context).textTheme.headline4!.copyWith(height: 1.1),),
- ),
- ],
- ),
- ),
- // Expanded(child: Container()),
- // Container(
- // color: Colors.black45,
- // width: double.infinity,
- // padding: EdgeInsets.all(12.0),
- // child: Row(
- // mainAxisAlignment: MainAxisAlignment.spaceBetween,
- // children: [
- // CachedNetworkImage(
- // imageUrl: "http://static.ouj.com/shoes/share/9b7dc07519f44e8286485154ee29d9c3.png",
- // width: 80,
- // ),
- // Text("趣动", style: Theme.of(context).textTheme.headline4),
- // ],
- // ),
- // )
- ],
- ),
- ),
- ),
- );
- }),
- Positioned(
- left: 0,
- right: 0,
- top: 0,
- child: SafeArea(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- buildBackButton(context, white: true),
- IconButton(
- icon: Image.asset(
- "lib/assets/img/bbs_icon_share.png",
- color: Colors.white,
- ),
- onPressed: () => _share()),
- ],
- )),
- ),
- ],
- ));
- }
- _share() async {
- runShare(context, 0, keys[_index], false, app: true);
- }
- }
|