import 'dart:convert'; import 'package:bbyyy/beans/system_information_bean_entity.dart'; import 'package:bbyyy/my_tools/my_colors.dart'; import 'package:bbyyy/my_tools/my_cookie.dart'; import 'package:bbyyy/my_tools/my_tools.dart'; import 'package:bbyyy/my_tools/my_views.dart'; import 'package:flutter/material.dart'; class SystemInformationPage extends StatefulWidget { @override _SystemInformationPageState createState() => _SystemInformationPageState(); } class _SystemInformationPageState extends State { List sysMsg = []; @override void initState() { // TODO: implement initState super.initState(); String s = MyCookie().prefs.getString('${MyCookie().getUID()}系统消息'); List sL = json.decode(s); sL.forEach((element) { SystemInformationBeanEntity entity = SystemInformationBeanEntity() .fromJson(json.decode(json.encode(element))); sysMsg.add(entity); }); setState(() {}); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: MyColors.cE7E7E7, body: Column( children: [ MyViews().myAppBar('系统消息', context, []), Container( height: 10, color: MyColors.cE7E7E7, ), Expanded( child: ListView.builder( itemBuilder: (BuildContext context, int index) { return GestureDetector( onTap: () { MyTools().toPage(context, SystemMessageDetailsPage(sysMsg[index]), (then) {}); }, behavior: HitTestBehavior.translucent, child: Column( children: [ Container( color: Colors.white, child: Column( children: [ Container( height: 40, child: Text( '${sysMsg[index].content.content}', maxLines: 2, overflow: TextOverflow.ellipsis, softWrap: true, style: TextStyle( color: MyColors.c333333, fontSize: 14), ), alignment: Alignment.topLeft, ), Padding( padding: const EdgeInsets.all(8.0), child: Row( children: [ MyViews() .myText('发布时间', MyColors.c666666, 12), MyViews().myText( sysMsg[index].content.startTime, MyColors.c666666, 12), ], mainAxisAlignment: MainAxisAlignment.spaceBetween, ), ) ], ), alignment: Alignment.centerLeft, padding: EdgeInsets.all(10), ), Container( height: 0.5, color: MyColors.cF7F7F7, ) ], ), ); }, itemCount: sysMsg.length, padding: EdgeInsets.all(0), ), ) ], ), ); } } class SystemMessageDetailsPage extends StatefulWidget { SystemInformationBeanEntity sysMsg; SystemMessageDetailsPage(this.sysMsg); @override _SystemMessageDetailsPageState createState() => _SystemMessageDetailsPageState(); } class _SystemMessageDetailsPageState extends State { @override Widget build(BuildContext context) { return Scaffold( body: Column( children: [ MyViews().myAppBar('系统消息详情', context, []), SingleChildScrollView( child: Expanded( child: Column( children: [ Container( child: Text( widget.sysMsg.content.content.split('】')[0].substring(1), style: TextStyle(color: MyColors.c333333, fontSize: 25), ), alignment: Alignment.center, margin: EdgeInsets.only(top: 20), ), Container( child: Text( widget.sysMsg.content.startTime, style: TextStyle(color: MyColors.c333333, fontSize: 12), ), alignment: Alignment.centerRight, margin: EdgeInsets.only(right: 20, top: 10), ), Container( margin: EdgeInsets.all(20), child: Text( widget.sysMsg.content.content.split('】')[1], style: TextStyle(color: MyColors.c333333, fontSize: 20), ), alignment: Alignment.topLeft, ), ], ), ), ), ], ), ); } }