| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- import 'package:flutter/material.dart';
- import '../styles/colors.dart';
- import 'package:flutter/cupertino.dart';
- import 'dart:ui';
- import '../styles/totast.dart';
- import '../model/SystemNotice.dart';
- import '../net/HttpManager.dart';
- import '../net/Result.dart';
- import '../model/HouseInfo.dart';
- import '../model/GameInfo.dart';
- import '../pages/RoomInfo.dart';
- class TipInfo extends StatefulWidget {
- TipInfo({Key key, this.tipId}) : super(key: key);
- final int tipId;
- @override
- TipInfoState createState() => TipInfoState();
- }
- class TipInfoState extends State<TipInfo> {
- SystemNotice tipInfo = SystemNotice.fromJson(
- {'content': '', "createTime": DateTime.now().microsecondsSinceEpoch});
- HouseInfo houseInfo;
- getInfo() async {
- Toast.show(context, '加载中', -1, 'loading');
- Result res = await HttpManager.get("systemNotice/getOne",
- data: {'id': widget.tipId});
- Toast.hide();
- if (res.success) {
- setState(() {
- tipInfo = SystemNotice.fromJson(res.data);
- });
- }
- if (tipInfo.statusFlag == 0 && tipInfo.typeFlag != 2) {
- HttpManager.post("systemNotice/update",
- data: {'id': tipInfo.id, "statusFlag": 1});
- }
- Result res2 = await HttpManager.get("houseInfo/getOne",
- data: {'id': tipInfo.houseId});
- if (res2.success) {
- setState(() {
- houseInfo = HouseInfo.fromJson(res2.data);
- });
- }
-
- }
- void updateHousInfo() {}
- @override
- void initState() {
-
- super.initState();
- Future.delayed(Duration(milliseconds: 100), () => getInfo());
- }
- @override
- Widget build(BuildContext context) {
- int type = tipInfo.typeFlag != null ? tipInfo.typeFlag : 0;
- int status = tipInfo.statusFlag ?? 0;
- GameInfo gameInfo;
- if (tipInfo.gameInfo != null) {
- gameInfo = tipInfo.gameInfo;
- }
- return new WillPopScope(
- child: Scaffold(
- appBar: AppBar(
- backgroundColor: PRIMARY_COLOR,
- title: Text('通知详情'),
- centerTitle: true,
- elevation: 0,
- ),
- body: Container(
- color: Color(0xFF2B2B42),
- width: double.infinity,
- height: double.infinity,
- child: Column(
- children: <Widget>[
- Padding(
- padding: EdgeInsets.only(left: 15, right: 45),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Padding(
- padding: EdgeInsets.symmetric(vertical: 12),
- child: Text(
- readTimestamp(
- tipInfo.createTime, 'yyyy.MM.dd HH:mm:ss'),
- style:
- TextStyle(color: Colors.white24, fontSize: 13)),
- ),
- Container(
- height: 1,
- color: Colors.black26,
- ),
- Padding(
- padding: EdgeInsets.only(top: 10, bottom: 17),
- child: Text(
- tipInfo.content,
- style: TextStyle(color: Colors.white, fontSize: 14),
- ),
- )
- ],
- ),
- ),
- houseInfo != null
- ? houseItem(roomInfo: houseInfo, gameInfo: gameInfo)
- : Container(),
- type == 2 && status == 0
- ? Container(
- width: double.infinity,
- height: 48,
- padding: EdgeInsets.symmetric(horizontal: 15),
- child: RaisedButton(
- textColor: Colors.white,
- child: Text('立即领取'),
- onPressed: () async {
- Toast.show(context, '加载中', -1, 'loading');
- Result res = await HttpManager.post(
- "playerInfo/receive",
- data: {"id": tipInfo.playerId});
- Toast.hide();
- print(res.data);
- if (res.success) {
- Toast.show(context, '领取成功', 1000, 'success');
- Future.delayed(Duration(milliseconds: 1000),
- () => getInfo());
- } else {
- Toast.show(context, res.error, 1000, 'info');
- }
- },
- ),
- )
- : Container()
- ],
- ),
- )),
- onWillPop: () {
- Navigator.of(context).pop(true);
- Toast.hide();
- return Future.value(false);
- },
- );
- }
- }
- class houseItem extends StatelessWidget {
- houseItem({Key key, this.roomInfo, this.gameInfo}) : super(key: key);
- final HouseInfo roomInfo;
- final GameInfo gameInfo;
- @override
- Widget build(BuildContext context) {
- return Container(
- margin: EdgeInsets.only(bottom: 50),
- decoration: BoxDecoration(
- gradient: LinearGradient(
- colors: [Color(0xFF3F4261), Color(0xFF323456)],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- ),
- border: Border(bottom: BorderSide(color: Colors.black, width: 1))),
- child: Material(
- color: Colors.transparent,
- child: InkWell(
- child: Padding(
- padding: EdgeInsets.all(15),
- child: Row(
- children: <Widget>[
- Image.network(
- gameInfo.icon,
- width: 48,
- height: 48,
- ),
- Container(
- width: 10,
- ),
- Expanded(
- flex: 1,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Row(
- children: <Widget>[
- LimitedBox(
- maxWidth: 170,
- child: Text(
- roomInfo.houseName,
- style: TextStyle(
- color: Colors.white,
- fontSize: 14,
- fontWeight: FontWeight.w500),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 6),
- child: Image.network(roomInfo.houseLevel.icon,
- width: 14),
- ),
- Container(
- margin: EdgeInsets.only(left: 1),
- child: Text(
- roomInfo.houseLevel.levelName,
- style: TextStyle(
- color: Color(0xFFF9D881), fontSize: 9),
- )),
- ],
- ),
- Text(
- roomInfo.houseAbstract,
- style: TextStyle(
- fontSize: 12,
- fontWeight: FontWeight.w400,
- color: Color(0xFF9BA0AE)),
- maxLines: 2,
- overflow: TextOverflow.ellipsis,
- )
- ],
- ),
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Image.asset('images/icon_renshu.png', width: 20),
- Text(
- (roomInfo.playerNumber != null
- ? roomInfo.playerNumber.toString()
- : '0') +
- '/' +
- roomInfo.maxNumber.toString(),
- style: TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.w500,
- color: Color(0xFFB1B2C0)),
- )
- ],
- )
- ],
- ),
- ),
- onTap: () {
- Navigator.push(
- context,
- new CupertinoPageRoute(
- builder: (context) =>
- new RoomInfo(roomId: roomInfo.id.toString())));
- },
- ),
- ),
- );
- }
- }
|