system_information_page.dart 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import 'dart:convert';
  2. import 'package:bbyyy/beans/system_information_bean_entity.dart';
  3. import 'package:bbyyy/my_tools/my_colors.dart';
  4. import 'package:bbyyy/my_tools/my_cookie.dart';
  5. import 'package:bbyyy/my_tools/my_tools.dart';
  6. import 'package:bbyyy/my_tools/my_views.dart';
  7. import 'package:flutter/material.dart';
  8. class SystemInformationPage extends StatefulWidget {
  9. @override
  10. _SystemInformationPageState createState() => _SystemInformationPageState();
  11. }
  12. class _SystemInformationPageState extends State<SystemInformationPage> {
  13. List<SystemInformationBeanEntity> sysMsg = [];
  14. @override
  15. void initState() {
  16. // TODO: implement initState
  17. super.initState();
  18. String s = MyCookie().prefs.getString('${MyCookie().getUID()}系统消息');
  19. List sL = json.decode(s);
  20. sL.forEach((element) {
  21. SystemInformationBeanEntity entity = SystemInformationBeanEntity.fromJson(json.decode(json.encode(element)));
  22. sysMsg.add(entity);
  23. });
  24. setState(() {});
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. return Scaffold(
  29. backgroundColor: MyColors.cE7E7E7,
  30. body: Column(
  31. children: [
  32. MyViews().myAppBar('系统消息', context, []),
  33. Container(
  34. height: 10,
  35. color: MyColors.cE7E7E7,
  36. ),
  37. Expanded(
  38. child: ListView.builder(
  39. itemBuilder: (BuildContext context, int index) {
  40. return GestureDetector(
  41. onTap: () {
  42. MyTools().toPage(context,
  43. SystemMessageDetailsPage(sysMsg[index]), (then) {});
  44. },
  45. behavior: HitTestBehavior.translucent,
  46. child: Column(
  47. children: [
  48. Container(
  49. color: Colors.white,
  50. child: Column(
  51. children: [
  52. Container(
  53. height: 40,
  54. child: Text(
  55. '${sysMsg[index].content.content}',
  56. maxLines: 2,
  57. overflow: TextOverflow.ellipsis,
  58. softWrap: true,
  59. style: TextStyle(
  60. color: MyColors.c333333, fontSize: 14),
  61. ),
  62. alignment: Alignment.topLeft,
  63. ),
  64. Padding(
  65. padding: const EdgeInsets.all(8.0),
  66. child: Row(
  67. children: [
  68. MyViews()
  69. .myText('发布时间', MyColors.c666666, 12),
  70. MyViews().myText(
  71. sysMsg[index].content.startTime,
  72. MyColors.c666666,
  73. 12),
  74. ],
  75. mainAxisAlignment:
  76. MainAxisAlignment.spaceBetween,
  77. ),
  78. )
  79. ],
  80. ),
  81. alignment: Alignment.centerLeft,
  82. padding: EdgeInsets.all(10),
  83. ),
  84. Container(
  85. height: 0.5,
  86. color: MyColors.cF7F7F7,
  87. )
  88. ],
  89. ),
  90. );
  91. },
  92. itemCount: sysMsg.length,
  93. padding: EdgeInsets.all(0),
  94. ),
  95. )
  96. ],
  97. ),
  98. );
  99. }
  100. }
  101. class SystemMessageDetailsPage extends StatefulWidget {
  102. SystemInformationBeanEntity sysMsg;
  103. SystemMessageDetailsPage(this.sysMsg);
  104. @override
  105. _SystemMessageDetailsPageState createState() =>
  106. _SystemMessageDetailsPageState();
  107. }
  108. class _SystemMessageDetailsPageState extends State<SystemMessageDetailsPage> {
  109. @override
  110. Widget build(BuildContext context) {
  111. return Scaffold(
  112. body: Column(
  113. children: [
  114. MyViews().myAppBar('系统消息详情', context, []),
  115. SingleChildScrollView(
  116. child: Column(
  117. children: [
  118. Container(
  119. child: Text(
  120. widget.sysMsg.content.content.split('】')[0].substring(1),
  121. style: TextStyle(color: MyColors.c333333, fontSize: 25),
  122. ),
  123. alignment: Alignment.center,
  124. margin: EdgeInsets.only(top: 20),
  125. ),
  126. Container(
  127. child: Text(
  128. widget.sysMsg.content.startTime,
  129. style: TextStyle(color: MyColors.c333333, fontSize: 12),
  130. ),
  131. alignment: Alignment.centerRight,
  132. margin: EdgeInsets.only(right: 20, top: 10),
  133. ),
  134. Container(
  135. margin: EdgeInsets.all(20),
  136. child: Text(
  137. widget.sysMsg.content.content.split('】')[1],
  138. style: TextStyle(color: MyColors.c333333, fontSize: 20),
  139. ),
  140. alignment: Alignment.topLeft,
  141. ),
  142. ],
  143. ),
  144. ),
  145. ],
  146. ),
  147. );
  148. }
  149. }