share_popup.dart 11 KB

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