room_item.dart 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import '../pages/RoomInfo.dart';
  5. class RommItem extends StatelessWidget {
  6. RommItem({this.roomInfo, this.hasBorder, this.isRage});
  7. final Map roomInfo;
  8. bool hasBorder = true;
  9. bool isRage = false;
  10. @override
  11. Widget build(BuildContext context) {
  12. ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
  13. Map houseLevelInfo =
  14. roomInfo["houseLevelInfo"].isNotEmpty ? roomInfo["houseLevelInfo"] : {};
  15. Map useRoomInfo=roomInfo.isNotEmpty?roomInfo:{};
  16. Map gameInfo=roomInfo.containsKey('gameInfo')?roomInfo['gameInfo']:{};
  17. Map imageInfo = {
  18. "黄金": Image.asset('images/dengji_icon_huangjin.png',
  19. width: ScreenUtil().setWidth(14)),
  20. "白银": Image.asset('images/dengji_icon_baiyin.png',
  21. width: ScreenUtil().setWidth(14)),
  22. "青铜": Image.asset('images/dengji_icon_qingtong.png',
  23. width: ScreenUtil().setWidth(14))
  24. };
  25. Map colorInfo = {
  26. "黄金": Color(0xFFF9D881),
  27. "白银": Color(0xFFAFCAD8),
  28. "青铜": Color(0xFFE18D50),
  29. };
  30. DecorationImage myIcon=DecorationImage(
  31. image: NetworkImage( gameInfo.containsKey('icon')?gameInfo["icon"]:''),
  32. fit: BoxFit.cover);
  33. return FlatButton(
  34. color: Color(0xFF464B6A),
  35. highlightColor: Color(0xFF35395E),
  36. textColor: Colors.white,
  37. padding: EdgeInsets.all(0),
  38. child: Container(
  39. padding: EdgeInsets.all(ScreenUtil().setWidth(15)),
  40. height: ScreenUtil().setWidth(78),
  41. decoration: BoxDecoration(
  42. gradient: LinearGradient(
  43. begin: Alignment
  44. .bottomRight,
  45. colors: [Color(0xFF35395E), Color(0xFF464B6A).withOpacity(0)],
  46. )),
  47. child: Row(
  48. children: <Widget>[
  49. Container(
  50. width: ScreenUtil().setWidth(48),
  51. decoration: BoxDecoration(
  52. borderRadius: BorderRadius.all(Radius.circular(2)),
  53. image:myIcon,
  54. ),
  55. ),
  56. Expanded(
  57. flex: 1,
  58. child: Container(
  59. margin: EdgeInsets.only(left: 10, right: 10),
  60. child: Column(
  61. crossAxisAlignment: CrossAxisAlignment.start,
  62. children: <Widget>[
  63. Row(
  64. children: <Widget>[
  65. LimitedBox(
  66. maxWidth: ScreenUtil().setWidth(170),
  67. child: Text(
  68. roomInfo['houseName'],
  69. style: TextStyle(
  70. color: Colors.white,
  71. fontSize: 14,
  72. fontWeight: FontWeight.w500),
  73. maxLines:1,
  74. overflow:TextOverflow.ellipsis,
  75. ),
  76. ),
  77. Container(
  78. margin: EdgeInsets.only(left: 6),
  79. child: imageInfo[houseLevelInfo['levelName']],
  80. ),
  81. Container(
  82. margin: EdgeInsets.only(left: 1),
  83. child: Text(
  84. houseLevelInfo['levelName'],
  85. style: TextStyle(
  86. color: colorInfo[houseLevelInfo['levelName']],
  87. fontSize: 9),
  88. )),
  89. ],
  90. ),
  91. Text(
  92. roomInfo['houseAbstract'],
  93. style: TextStyle(
  94. fontSize: 12,
  95. fontWeight: FontWeight.w400,
  96. color: Color(0xFF9BA0AE)),
  97. maxLines:2,
  98. overflow:TextOverflow.ellipsis,
  99. )
  100. ],
  101. ),
  102. ),
  103. ),
  104. Row(
  105. mainAxisAlignment: MainAxisAlignment.center,
  106. children: <Widget>[
  107. Image.asset('images/icon_renshu.png', width: 20),
  108. Text((roomInfo.containsKey('playerNumber')?roomInfo['playerNumber'].toString():'0')+'/'+roomInfo['maxNumber'].toString(),
  109. style: TextStyle(
  110. fontSize: 14,
  111. fontWeight: FontWeight.w500,
  112. color: Color(0xFFB1B2C0)
  113. ),)
  114. ],
  115. )
  116. ],
  117. ),
  118. ),
  119. onPressed: () {
  120. Navigator.push(context,
  121. new CupertinoPageRoute(builder: (context) => new RoomInfo(
  122. roomId:roomInfo['id'].toString()
  123. )));
  124. },
  125. );
  126. }
  127. }