message_notice_detail_page.dart 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import 'package:flutter/material.dart';
  2. import 'package:sport/bean/notice.dart';
  3. import 'package:sport/services/api/inject_api.dart';
  4. import 'package:sport/utils/toast.dart';
  5. import 'package:sport/widgets/appbar.dart';
  6. import 'package:sport/widgets/button_primary.dart';
  7. import 'package:sport/widgets/dialog/request_dialog.dart';
  8. class MessageNoticeDetailPage extends StatefulWidget {
  9. final Notice notice;
  10. MessageNoticeDetailPage(this.notice);
  11. @override
  12. State<StatefulWidget> createState() => _PageState();
  13. }
  14. class _PageState extends State<MessageNoticeDetailPage> with InjectApi {
  15. @override
  16. void initState() {
  17. super.initState();
  18. }
  19. @override
  20. void dispose() {
  21. super.dispose();
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. return Scaffold(
  26. backgroundColor: Colors.white,
  27. body: CustomScrollView(
  28. slivers: <Widget>[
  29. buildSliverAppBar(context, "通知详情"),
  30. SliverToBoxAdapter(
  31. child: Padding(
  32. padding: const EdgeInsets.all(12.0),
  33. child: Column(
  34. crossAxisAlignment: CrossAxisAlignment.start,
  35. children: <Widget>[
  36. Text(
  37. "${widget.notice.title}",
  38. style: Theme.of(context).textTheme.headline3,
  39. ),
  40. SizedBox(
  41. height: 12,
  42. ),
  43. Text(
  44. "${widget.notice.createdAt}",
  45. style: Theme.of(context).textTheme.bodyText1,
  46. ),
  47. SizedBox(
  48. height: 5,
  49. ),
  50. Divider(),
  51. SizedBox(
  52. height: 5,
  53. ),
  54. Text("${widget.notice.content}", style: Theme.of(context).textTheme.bodyText2.copyWith(color: Color(0xff666666))),
  55. if (widget.notice.type == "receive")
  56. Padding(
  57. padding: const EdgeInsets.only(top: 40.0),
  58. child: Text("注:邮件超过7天未查收将自动领取奖励", style: Theme.of(context).textTheme.bodyText2.copyWith(color: Color(0xff666666))),
  59. ),
  60. if (widget.notice.type == "receive" && widget.notice.receiveDetail != null)
  61. Column(
  62. children: <Widget>[
  63. SizedBox(
  64. height: 10,
  65. ),
  66. Divider(
  67. height: 32,
  68. ),
  69. Row(
  70. children: <Widget>[
  71. Expanded(
  72. child: Column(
  73. crossAxisAlignment: CrossAxisAlignment.start,
  74. children: (widget.notice.receiveDetail.thing ?? []).map((e) => Text("${e.type == "score" ? '积分' : '经验'} +${e.value}", style: Theme.of(context).textTheme.bodyText2.copyWith(color: Theme.of(context).accentColor))).toList(),
  75. ),
  76. ),
  77. PrimaryButton(
  78. width: 75,
  79. height: 35,
  80. content: widget.notice.isRead == 1 ? "已领取" : "领取",
  81. callback: widget.notice.isRead == 1
  82. ? null
  83. : () async {
  84. await request(context, () async {
  85. await api.postNoticeRead(widget.notice.id).catchError((err) {});
  86. ToastUtil.show("领取成功");
  87. });
  88. Navigator.pop(context, true);
  89. },
  90. )
  91. ],
  92. ),
  93. // Divider(
  94. // height: 32,
  95. // ),
  96. ],
  97. )
  98. ],
  99. ),
  100. )),
  101. ],
  102. ));
  103. }
  104. String _getName() {
  105. Notice _notice = widget.notice;
  106. if (_notice.type == "rank") {
  107. return "排名变更";
  108. } else if (_notice.type == "receive") {
  109. return "榜单通知";
  110. } else {
  111. return "系统通知";
  112. }
  113. }
  114. }