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/bean/user.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();
  final Achievement achievement;
  ShareAchievementPage(this.achievement);
  @override
  Widget build(BuildContext context) {
//    print("${DateTime.now().millisecondsSinceEpoch}");
    // TODO: implement build
    return Scaffold(
        appBar: buildAppBar(context, title: "成就分享"),
//          actions: <Widget>[
//            IconButton(
//              icon: Image.asset("lib/assets/img/bbs_icon_share.png"),
//              onPressed: () async {
//                await menuShareBottom(context, "Img",
//                    poster: poster, hasDownload: true);
//              },
//            )
//          ],
        body: Stack(children: [
          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(10.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(
                                  "您是第${achievement.userCount}位获得者",
                                  style: Theme.of(context).textTheme.bodyText1,
                                ),
                                Space(
                                  height: 16.0,
                                ),
                                Container(
                                  width: double.infinity,
                                  decoration: BoxDecoration(
                                      image: DecorationImage(
                                          image: AssetImage(
                                              "lib/assets/img/bg_pop_achievement.png"))),
                                  child: CachedNetworkImage(
                                    imageUrl: achievement.logo,
                                    width: 120.0,
                                    height: 120.0,
                                  ),
                                ),
                                Space(
                                  height: 8.0,
                                ),
                                Text(
                                  "${achievement.name}",
                                  style: Theme.of(context).textTheme.headline1,
                                ),
                                Space(
                                  height: 12.0,
                                ),
                                Text(
                                  "使用智能鞋运动${achievement.conditionDetail}",
                                  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,
                                  decoration: BoxDecoration(
//                                  gradient: new RadialGradient(
//                                      radius: 4,
//                                      colors: [
//                                        Color.fromRGBO(255, 196, 0, 1).withAlpha(80),
//                                        Color(0x00ffffff),
//                                      ]),
                                      image: DecorationImage(
                                          image: AssetImage(
                                              "lib/assets/img/bg1_pop_achievement.png"))),
                                  child: Text(
                                    "经验值+${achievement.rewardExp}  积分+${achievement.rewardScore}",
                                    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(
                                      "${achievement.createdAt}",
                                      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, 12, 9),
//                                color: Colors.black,
                                  decoration: BoxDecoration(
                                      color: Colors.black,
                                      borderRadius: BorderRadius.only(
                                          bottomLeft: Radius.circular(10),
                                          bottomRight: Radius.circular(10))),
                                  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
                                                .bodyText1,
                                          )
                                        ],
                                      ),
                                      Container(
                                        width: 60.0,
                                        height: 60.0,
                                        child: Center(
                                          child: Text("二维码"),
                                        ),
                                        color: Colors.white,
                                      ),
                                    ],
                                  ),
                                )
                              ],
                            ),
                          ),
                        )
                      ])),
                ],
              )),
          Positioned(
              bottom: 0,
              child: Container(
//                height: 300,
//              color: Colors.white,
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(10),
                        topRight: Radius.circular(10)),
                    color: Colors.white),
                width: MediaQuery.of(context).size.width,
                child: MenuShareBottomContent(
                  "Img",
                  hasDownload: true,
                  poster: poster,
                ),
              )),
        ]));
  }
}
