import 'dart:math';
import 'dart:ui';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

import 'package:sport/widgets/appbar.dart';
import 'package:sport/widgets/menu_share_bottom.dart';
import 'package:sport/widgets/space.dart';

import 'chat_page.dart';

class ShareAchievementPage extends StatelessWidget {
  final GlobalKey poster = new GlobalKey();

  @override
  Widget build(BuildContext context) {
//    print("${DateTime.now().millisecondsSinceEpoch}");
    // TODO: implement build
    return Scaffold(
        appBar: AppBar(
          title: Text(
            "成就分享",
            style: titleStyle,
          ),
          actions: <Widget>[
            IconButton(
              icon: Image.asset("lib/assets/img/bbs_icon_share.png"),
              onPressed: () async {
                await menuShareBottom(context, "Img",
                    poster: poster, hasDownload: true);
              },
            )
          ],
        ),
        body: Container(
            color: Color(0xff999999),
            width: MediaQuery.of(context).size.width * 1,
            child: Column(
              children: <Widget>[
                Expanded(
                    child: Column(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: <Widget>[
                      Space(
                        height: 40.0,
                      ),
                      RepaintBoundary(
                        key: poster,
                        child: Container(
                          width: MediaQuery.of(context).size.width * 0.65,
                          decoration: BoxDecoration(
                            borderRadius:
                                BorderRadius.all(Radius.circular(20.0)),
                            color: Colors.white,
                          ),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: <Widget>[
                              Space(
                                height: 35.0,
                              ),
                              Text(
                                "恭喜您达到新成就",
                                style: Theme.of(context).textTheme.headline3,
                              ),
                              Space(
                                height: 5.0,
                              ),
                              Text(
                                "您是第100位获得者",
                                style: Theme.of(context).textTheme.bodyText1,
                              ),
                              Space(
                                height: 16.0,
                              ),
                              CachedNetworkImage(
                                imageUrl: avatarList[Random().nextInt(10) % 11],
                                width: 120.0,
                                height: 120.0,
                              ),
                              Space(
                                height: 8.0,
                              ),
                              Text(
                                "燃脂达人Ⅱ",
                                style: Theme.of(context).textTheme.headline1,
                              ),
                              Space(
                                height: 16.0,
                              ),
                              Text(
                                "使用智能鞋运动消耗1000kal",
                                style: Theme.of(context).textTheme.bodyText1,
                              ),
                              Space(
                                height: 5.0,
                              ),
                              Container(
                                height: 25.0,
                                width: MediaQuery.of(context).size.width * 0.6,
                                color: Color(0xffFFC400).withOpacity(0.3),
                                alignment: Alignment.center,
                                child: Text(
                                  "经验值+5  积分+1",
                                  style: Theme.of(context)
                                      .textTheme
                                      .subtitle2
                                      .copyWith(
                                          color: Theme.of(context).accentColor),
                                ),
                              ),
                              Space(
                                height: 14.0,
                              ),
                              Row(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: <Widget>[
                                  Expanded(
                                    child: Divider(
                                      indent: 50.0,
                                      endIndent: 10.0,
                                    ),
                                  ),
                                  Text(
                                    "2020.07.14",
                                    style:
                                        Theme.of(context).textTheme.bodyText1,
                                  ),
                                  Expanded(
                                    child: Divider(
                                      indent: 10.0,
                                      endIndent: 50.0,
                                    ),
                                  ),
                                ],
                              ),
                              Container(
                                margin: EdgeInsets.only(top: 8.0),
                                width: MediaQuery.of(context).size.width * 1,
                                padding: EdgeInsets.fromLTRB(12, 9, 8, 9),
//                                color: Colors.black,
                                decoration: BoxDecoration(
                                    color: Colors.black,
                                    borderRadius: BorderRadius.only(
                                        bottomLeft: Radius.circular(20),
                                        bottomRight: Radius.circular(20))),
                                child: Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: <Widget>[
                                    Column(
                                      crossAxisAlignment:
                                          CrossAxisAlignment.start,
                                      children: <Widget>[
                                        Container(
                                            width: 36,
                                            height: 36,
                                            color: Color(0xFFFFC400)),
                                        Space(
                                          height: 4.0,
                                        ),
                                        Text(
                                          "这是一段产品sloagn",
                                          style: Theme.of(context)
                                              .textTheme
                                              .bodyText2,
                                        )
                                      ],
                                    ),
                                    Container(
                                      width: 60.0,
                                      height: 60.0,
                                      child: Center(
                                        child: Text("二维码"),
                                      ),
                                      color: Colors.white,
                                    ),
                                  ],
                                ),
                              )
                            ],
                          ),
                        ),
                      )
                    ])),
              ],
            )));
  }
}
