share_popup.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. import 'dart:math';
  2. import 'package:cached_network_image/cached_network_image.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:sport/bean/user.dart';
  6. import 'package:sport/pages/social/chat_page.dart';
  7. import 'package:sport/pages/social/share_achievement.dart';
  8. import 'package:sport/router/navigator_util.dart';
  9. import 'package:sport/widgets/button_primary.dart';
  10. import '../space.dart';
  11. //Future<bool> showSharePopup(BuildContext context) {
  12. //
  13. // return showGeneralDialog<bool>(
  14. // context: context,
  15. // barrierDismissible: true,
  16. // barrierLabel: '',
  17. // barrierColor: Colors.black.withOpacity(0.5),
  18. // transitionDuration: Duration(milliseconds: 200),
  19. //// useRootNavigator: false,
  20. // pageBuilder: (BuildContext context, Animation<double> animation,
  21. // Animation<double> secondaryAnimation) {
  22. // return Center(
  23. // child: Material(
  24. // color: Colors.transparent,
  25. // child: Center(
  26. // child: Stack(
  27. // children: data.map((e) {
  28. // if (e != 0) {
  29. // print(
  30. // "--------------------------------------------------------------");
  31. // print(e);
  32. // print(e * 10.0);
  33. // return Positioned.fill(
  34. // left: e * 10.0, top: e * 10.0, child: content(e));
  35. // } else {
  36. // return Positioned.fill(child: content(e));
  37. // }
  38. // }).toList(),
  39. // ),
  40. // ),
  41. // ),
  42. // );
  43. // });
  44. //}
  45. // 换成这种 自定义PopRoute
  46. class sharePopup extends StatefulWidget {
  47. List<Achievement> list;
  48. sharePopup(this.list);
  49. @override
  50. State<StatefulWidget> createState() {
  51. // TODO: implement createState
  52. return _sharePopupState();
  53. }
  54. }
  55. class _sharePopupState extends State<sharePopup> {
  56. bool showCloseButton = true;
  57. Widget content(Achievement e, int index, int length) {
  58. print("${index}-------------------------");
  59. return Column(
  60. mainAxisAlignment: MainAxisAlignment.center,
  61. children: <Widget>[
  62. Container(
  63. padding: EdgeInsets.only(bottom: 20.0),
  64. // height: MediaQuery.of(context).size.height * 0.7,
  65. width: MediaQuery.of(context).size.width * 0.7,
  66. decoration: BoxDecoration(
  67. borderRadius: BorderRadius.all(Radius.circular(10.0)),
  68. boxShadow: [
  69. BoxShadow(
  70. offset: Offset(0.0, 0),
  71. blurRadius: 5,
  72. spreadRadius: 0,
  73. color: Color.fromRGBO(0, 0, 0, 0.1))
  74. ],
  75. color: Colors.white.withOpacity(1 - index * 0.12),
  76. // border: Border.all(color: Color(0xf2f2f2f2))
  77. // image: DecorationImage(
  78. // image:
  79. // AssetImage("lib/assets/img/bg_pop_achievement.png"))
  80. ),
  81. child: Column(
  82. crossAxisAlignment: CrossAxisAlignment.center,
  83. children: <Widget>[
  84. Space(
  85. height: 30.0,
  86. ),
  87. Text(
  88. "恭喜您达到新成就",
  89. style: Theme.of(context).textTheme.headline3,
  90. ),
  91. Space(
  92. height: 5.0,
  93. ),
  94. Text(
  95. "您是第${e.userCount}位获得者",
  96. style: Theme.of(context).textTheme.bodyText1,
  97. ),
  98. Space(
  99. height: 16.0,
  100. ),
  101. Container(
  102. width: double.infinity,
  103. decoration: BoxDecoration(
  104. image: DecorationImage(
  105. image: AssetImage(
  106. "lib/assets/img/bg_pop_achievement.png"))),
  107. child: CachedNetworkImage(
  108. imageUrl: e.logo,
  109. width: 120.0,
  110. height: 120.0,
  111. ),
  112. ),
  113. Space(
  114. height: 8.0,
  115. ),
  116. Text(
  117. "${e.name}",
  118. style: Theme.of(context).textTheme.headline1,
  119. ),
  120. Space(
  121. height: 16.0,
  122. ),
  123. Text(
  124. "${e.conditionDetail}",
  125. style: Theme.of(context).textTheme.bodyText1,
  126. ),
  127. Space(
  128. height: 5.0,
  129. ),
  130. Container(
  131. height: 25.0,
  132. width: MediaQuery.of(context).size.width * 0.6,
  133. // color: Color(0xffFFC400).withOpacity(0.3),
  134. alignment: Alignment.center,
  135. decoration: BoxDecoration(
  136. // gradient: new RadialGradient(radius: 4, colors: [
  137. // Color.fromRGBO(255, 196, 0, 1).withAlpha(80),
  138. // Color(0x00ffffff),
  139. // ]),
  140. image: DecorationImage(
  141. image: AssetImage(
  142. "lib/assets/img/bg1_pop_achievement.png"))),
  143. child: Text(
  144. "经验值+${e.rewardExp} 积分+${e.rewardScore}",
  145. style: Theme.of(context)
  146. .textTheme
  147. .subtitle2
  148. .copyWith(color: Theme.of(context).accentColor),
  149. ),
  150. ),
  151. Space(
  152. height: 16.0,
  153. ),
  154. Container(
  155. width: 132.0,
  156. height: 35.0,
  157. alignment: Alignment.center,
  158. decoration: BoxDecoration(
  159. borderRadius: BorderRadius.all(Radius.circular(20.0)),
  160. border: new Border.all(
  161. width: 1, color: Theme.of(context).accentColor),
  162. gradient: new LinearGradient(
  163. begin: Alignment.centerLeft,
  164. end: Alignment.centerRight,
  165. colors: [
  166. Color.fromRGBO(255, 196, 0, 1),
  167. Color.fromRGBO(255, 170, 0, 1),
  168. ]),
  169. ),
  170. // child: InkWell(
  171. // child: Text(
  172. // "成就分享",
  173. // style: Theme.of(context).textTheme.headline6,
  174. // ),
  175. // onTap: () {
  176. // if (widget.list.length != 1) {
  177. // setState(() {
  178. // widget.list =
  179. // widget.list.sublist(0, widget.list.length - 1);
  180. // });
  181. // } else {
  182. // Navigator.pop(context);
  183. // }
  184. // NavigatorUtil.goPage(
  185. // context, (context) => ShareAchievementPage(e));
  186. // },
  187. // ),
  188. child: PrimaryButton(
  189. content: "成就分享",
  190. callback: () {
  191. if (widget.list.length != 1) {
  192. setState(() {
  193. widget.list =
  194. widget.list.sublist(0, widget.list.length - 1);
  195. });
  196. } else {
  197. Navigator.pop(context);
  198. }
  199. NavigatorUtil.goPage(
  200. context, (context) => ShareAchievementPage(e));
  201. },
  202. height: 35,
  203. // fontSize: 12.0,
  204. ),
  205. ),
  206. Space(
  207. height: 8.0,
  208. ),
  209. Row(
  210. mainAxisAlignment: MainAxisAlignment.center,
  211. children: <Widget>[
  212. Expanded(
  213. child: Divider(
  214. indent: 50.0,
  215. endIndent: 10.0,
  216. ),
  217. ),
  218. Text(
  219. "${e.createdAt.split(" ")[0]}",
  220. style: Theme.of(context)
  221. .textTheme
  222. .bodyText1
  223. .copyWith(fontSize: 11.0),
  224. ),
  225. Expanded(
  226. child: Divider(
  227. indent: 10.0,
  228. endIndent: 50.0,
  229. ),
  230. ),
  231. ],
  232. ),
  233. ],
  234. ),
  235. // padding: EdgeInsets.only(bottom: 20.0),
  236. ),
  237. Padding(
  238. padding: EdgeInsets.only(top: 20.0),
  239. child: widget.list.length > 0 && 0 == widget.list.indexOf(e)
  240. ? InkWell(
  241. child: Image.asset("lib/assets/img/pop_share_chose.png"),
  242. onTap: () {
  243. if (widget.list.length != 1) {
  244. widget.list.removeAt(0);
  245. setState(() {
  246. widget.list = widget.list;
  247. });
  248. } else {
  249. Navigator.of(context).pop();
  250. }
  251. },
  252. )
  253. : Container(
  254. width: 35.0,
  255. height: 35.0,
  256. ),
  257. )
  258. ],
  259. );
  260. }
  261. @override
  262. Widget build(BuildContext context) {
  263. print(widget.list);
  264. // TODO: implement build
  265. return Material(
  266. color: Colors.black.withOpacity(0.5),
  267. child: Column(
  268. mainAxisAlignment: MainAxisAlignment.start,
  269. children: <Widget>[
  270. Expanded(
  271. child: Center(
  272. // stack 需要一个高度进行搞一搞
  273. child: Stack(
  274. children: widget.list.reversed.map((e) {
  275. return Transform.translate(
  276. offset: Offset((widget.list.indexOf(e) + 1) * 5.0,
  277. -(widget.list.indexOf(e)) * 5.0),
  278. // padding: EdgeInsets.only(
  279. // right: (data.indexOf(e)) * 10.0,
  280. // top: (data.indexOf(e)) * 10.0),
  281. child: content(
  282. e, widget.list.indexOf(e), widget.list.length));
  283. }).toList(),
  284. ),
  285. ),
  286. ),
  287. // if (data.length > 0)
  288. // InkWell(
  289. // child: Image.asset("lib/assets/img/pop_share_chose.png"),
  290. // onTap: () {
  291. // if (data.length != 1) {
  292. // setState(() {
  293. // data = data.sublist(0, data.length - 1);
  294. // });
  295. // } else {
  296. // Navigator.of(context).pop();
  297. // }
  298. // },
  299. // )
  300. ],
  301. ),
  302. );
  303. }
  304. }