TipInfo.dart 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. import 'package:flutter/material.dart';
  2. import '../styles/colors.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'dart:ui';
  5. import '../styles/totast.dart';
  6. import '../model/SystemNotice.dart';
  7. import '../net/HttpManager.dart';
  8. import '../net/Result.dart';
  9. import '../model/HouseInfo.dart';
  10. import '../model/GameInfo.dart';
  11. import '../pages/RoomInfo.dart';
  12. import '../widget/SuccessfulReception.dart';
  13. class TipInfo extends StatefulWidget {
  14. TipInfo({Key key, this.tipId}) : super(key: key);
  15. final int tipId;
  16. @override
  17. TipInfoState createState() => TipInfoState();
  18. }
  19. class TipInfoState extends State<TipInfo> {
  20. SystemNotice tipInfo = SystemNotice.fromJson(
  21. {'content': '', 'createTime': DateTime.now().microsecondsSinceEpoch});
  22. HouseInfo houseInfo;
  23. Future<void> getInfo() async {
  24. Toast.show(context, '加载中', -1, 'loading');
  25. Result res = await HttpManager.get('systemNotice/getOne',
  26. data: {'id': widget.tipId});
  27. Toast.hide();
  28. if (res.success) {
  29. setState(() {
  30. tipInfo = SystemNotice.fromJson(res.data);
  31. });
  32. }
  33. print(tipInfo.bonus);
  34. if (tipInfo.statusFlag == 0 &&
  35. tipInfo.typeFlag != 2 &&
  36. tipInfo.typeFlag != 3) {
  37. HttpManager.post('systemNotice/update',
  38. data: {'id': tipInfo.id, 'statusFlag': 1});
  39. }
  40. if (tipInfo.typeFlag == 3) {
  41. return;
  42. }
  43. Result res2 = await HttpManager.get('houseInfo/getOne',
  44. data: {'id': tipInfo.houseId});
  45. if (res2.success) {
  46. setState(() {
  47. houseInfo = HouseInfo.fromJson(res2.data);
  48. });
  49. }
  50. }
  51. void showSuccess(money) {
  52. Navigator.of(context).push(
  53. PageRouteBuilder(
  54. opaque: false,
  55. transitionDuration: Duration(milliseconds: 300),
  56. transitionsBuilder: (BuildContext context, Animation<double> animation,
  57. Animation<double> secondaryAnimation, Widget child) {
  58. return FadeTransition(
  59. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  60. child: child,
  61. );
  62. },
  63. pageBuilder: (BuildContext context, _, __) {
  64. return SuccessfulReception(money: money);
  65. },
  66. ),
  67. );
  68. }
  69. @override
  70. void initState() {
  71. super.initState();
  72. Future.delayed(Duration.zero, () => getInfo());
  73. }
  74. @override
  75. Widget build(BuildContext context) {
  76. int type = tipInfo.typeFlag != null ? tipInfo.typeFlag : 0;
  77. int status = tipInfo.statusFlag ?? 0;
  78. GameInfo gameInfo;
  79. if (tipInfo.gameInfo != null) {
  80. gameInfo = tipInfo.gameInfo;
  81. }
  82. return WillPopScope(
  83. child: Scaffold(
  84. appBar: AppBar(
  85. backgroundColor: PRIMARY_COLOR,
  86. title: Text('通知详情'),
  87. centerTitle: true,
  88. elevation: 0,
  89. ),
  90. body: Container(
  91. color: Color(0xFF2B2B42),
  92. width: double.infinity,
  93. height: double.infinity,
  94. child: Column(
  95. children: <Widget>[
  96. Padding(
  97. padding: EdgeInsets.only(left: 15, right: 45),
  98. child: Column(
  99. crossAxisAlignment: CrossAxisAlignment.start,
  100. children: <Widget>[
  101. Padding(
  102. padding: EdgeInsets.symmetric(vertical: 12),
  103. child: Text(
  104. readTimestamp(
  105. tipInfo.createTime, 'yyyy.MM.dd HH:mm:ss'),
  106. style:
  107. TextStyle(color: Colors.white24, fontSize: 13)),
  108. ),
  109. Container(
  110. height: 1,
  111. color: Colors.black26,
  112. ),
  113. Padding(
  114. padding: EdgeInsets.only(top: 10, bottom: 17),
  115. child: Text(
  116. tipInfo.content,
  117. style: TextStyle(color: Colors.white, fontSize: 14),
  118. ),
  119. )
  120. ],
  121. ),
  122. ),
  123. houseInfo != null && type != 3
  124. ? houseItem(roomInfo: houseInfo, gameInfo: gameInfo)
  125. : Container(),
  126. (type == 2 || type == 3)
  127. ? Container(
  128. width: double.infinity,
  129. height: 48,
  130. padding: EdgeInsets.symmetric(horizontal: 15),
  131. child: RaisedButton(
  132. textColor: Colors.white,
  133. disabledColor: Color(0xFF763939),
  134. disabledTextColor: Color(0xFF252532),
  135. child: Text(status==0?'立即领取':'已领取'),
  136. onPressed: status==0?() async {
  137. Toast.show(context, '加载中', -1, 'loading');
  138. Result res = type == 2
  139. ? await HttpManager.post('playerInfo/receive',
  140. data: {'id': tipInfo.playerId})
  141. : await HttpManager.post('systemNotice/receive',
  142. data: {'id': widget.tipId});
  143. Toast.hide();
  144. if (res.success) {
  145. if (tipInfo.playerInfo != null) {
  146. showSuccess(tipInfo.playerInfo.bonus);
  147. } else {
  148. showSuccess(tipInfo.bonus);
  149. }
  150. getInfo();
  151. } else {
  152. Toast.show(context, res.error, 1000, 'info');
  153. }
  154. }:null,
  155. ),
  156. )
  157. : Container(),
  158. // CustomPaint(
  159. // painter: CircleProgressBarPainter(
  160. // Color(0xFFDCA659), Color(0xFFAE4945), 0.0, 270.0, 360.0, 18.0),
  161. // size: Size(108.0, 108.0),
  162. // )
  163. ],
  164. ),
  165. )),
  166. onWillPop: () {
  167. Navigator.of(context).pop(true);
  168. Toast.hide();
  169. return Future.value(false);
  170. },
  171. );
  172. }
  173. }
  174. class houseItem extends StatelessWidget {
  175. houseItem({Key key, this.roomInfo, this.gameInfo}) : super(key: key);
  176. final HouseInfo roomInfo;
  177. final GameInfo gameInfo;
  178. @override
  179. Widget build(BuildContext context) {
  180. return Container(
  181. margin: EdgeInsets.only(bottom: 50),
  182. decoration: BoxDecoration(
  183. gradient: LinearGradient(
  184. colors: [Color(0xFF3F4261), Color(0xFF323456)],
  185. begin: Alignment.topCenter,
  186. end: Alignment.bottomCenter,
  187. ),
  188. border: Border(bottom: BorderSide(color: Colors.black, width: 1))),
  189. child: Material(
  190. color: Colors.transparent,
  191. child: InkWell(
  192. child: Padding(
  193. padding: EdgeInsets.all(15),
  194. child: Row(
  195. children: <Widget>[
  196. Image.network(
  197. gameInfo.icon,
  198. width: 48,
  199. height: 48,
  200. ),
  201. Container(
  202. width: 10,
  203. ),
  204. Expanded(
  205. flex: 1,
  206. child: Column(
  207. crossAxisAlignment: CrossAxisAlignment.start,
  208. children: <Widget>[
  209. Row(
  210. children: <Widget>[
  211. LimitedBox(
  212. maxWidth: 170,
  213. child: Text(
  214. roomInfo.houseName,
  215. style: TextStyle(
  216. color: Colors.white,
  217. fontSize: 14,
  218. fontWeight: FontWeight.w500),
  219. maxLines: 1,
  220. overflow: TextOverflow.ellipsis,
  221. ),
  222. ),
  223. Container(
  224. margin: EdgeInsets.only(left: 6),
  225. child: Image.network(roomInfo.houseLevel.icon,
  226. width: 14),
  227. ),
  228. Container(
  229. margin: EdgeInsets.only(left: 1),
  230. child: Text(
  231. roomInfo.houseLevel.levelName,
  232. style: TextStyle(
  233. color: Color(0xFFF9D881), fontSize: 9),
  234. )),
  235. ],
  236. ),
  237. Text(
  238. roomInfo.houseAbstract,
  239. style: TextStyle(
  240. fontSize: 12,
  241. fontWeight: FontWeight.w400,
  242. color: Color(0xFF9BA0AE)),
  243. maxLines: 2,
  244. overflow: TextOverflow.ellipsis,
  245. )
  246. ],
  247. ),
  248. ),
  249. Row(
  250. mainAxisAlignment: MainAxisAlignment.center,
  251. children: <Widget>[
  252. Image.asset('images/icon_renshu.png', width: 20),
  253. Text(
  254. (roomInfo.playerNumber != null
  255. ? roomInfo.playerNumber.toString()
  256. : '0') +
  257. '/' +
  258. roomInfo.maxNumber.toString(),
  259. style: TextStyle(
  260. fontSize: 14,
  261. fontWeight: FontWeight.w500,
  262. color: Color(0xFFB1B2C0)),
  263. )
  264. ],
  265. )
  266. ],
  267. ),
  268. ),
  269. onTap: () {
  270. Navigator.push(
  271. context,
  272. CupertinoPageRoute(
  273. builder: (context) =>
  274. RoomInfo(roomId: roomInfo.id.toString())));
  275. },
  276. ),
  277. ),
  278. );
  279. }
  280. }