system_information_page.dart 5.5 KB

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