RoomItem.dart 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'dart:ui';
  4. import 'package:cached_network_image/cached_network_image.dart';
  5. import '../model/HouseInfo.dart';
  6. import '../model/GameInfo.dart';
  7. import '../pages/RoomInfo.dart';
  8. import 'ScoreType.dart';
  9. class HouseItem extends StatelessWidget {
  10. HouseItem({Key key, this.roomInfo, this.gameInfo}) : super(key: key);
  11. final HouseInfo roomInfo;
  12. final GameInfo gameInfo;
  13. @override
  14. @override
  15. Widget build(BuildContext context) {
  16. // if(roomInfo==null){
  17. // return Container();
  18. // }
  19. return Container(
  20. margin: EdgeInsets.symmetric(horizontal: 15),
  21. decoration: BoxDecoration(
  22. color: Color(0xFF363759),
  23. // gradient: LinearGradient(
  24. // colors: [Color(0xFF3F4261), Color(0xFF323456)],
  25. // begin: Alignment.topCenter,
  26. // end: Alignment.bottomCenter,
  27. // ),
  28. border: Border(bottom: BorderSide(color: Color(0xFF2F304B), width: 1))),
  29. child: Material(
  30. color: Colors.transparent,
  31. child: InkWell(
  32. child: Padding(
  33. padding: EdgeInsets.symmetric(vertical: 15),
  34. child: Row(
  35. children: <Widget>[
  36. Image.network(
  37. gameInfo.icon,
  38. width: 48,
  39. height: 48,
  40. ),
  41. Container(
  42. width: 10,
  43. ),
  44. Expanded(
  45. flex: 1,
  46. child: Column(
  47. crossAxisAlignment: CrossAxisAlignment.start,
  48. children: <Widget>[
  49. Row(
  50. children: <Widget>[
  51. LimitedBox(
  52. maxWidth: 170,
  53. child: Text(
  54. roomInfo.houseName,
  55. style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
  56. maxLines: 1,
  57. overflow: TextOverflow.ellipsis,
  58. ),
  59. ),
  60. Container(width: 5,),
  61. ScoreType(roomInfo.scoreType)
  62. // roomInfo.houseLevel.icon != null
  63. // ? Container(
  64. // margin: EdgeInsets.only(left: 6),
  65. // child: Image.network(roomInfo.houseLevel.icon, width: 14),
  66. // )
  67. // : null,
  68. // Container(
  69. // margin: EdgeInsets.only(left: 1),
  70. // child: Text(
  71. // roomInfo.houseLevel.levelName,
  72. // style: TextStyle(color: Color(0xFFF9D881), fontSize: 9),
  73. // )),
  74. ],
  75. ),
  76. Text(
  77. roomInfo.houseAbstract ?? '',
  78. style: TextStyle(fontSize: 12, fontWeight: FontWeight.w400, color: Color(0xFF9BA0AE)),
  79. maxLines: 2,
  80. overflow: TextOverflow.ellipsis,
  81. )
  82. ],
  83. ),
  84. ),
  85. Row(
  86. mainAxisAlignment: MainAxisAlignment.center,
  87. children: <Widget>[
  88. Image.asset(roomInfo.statusFlag==0?'images/icon_renshu_hong.png':'images/icon_renshu.png', width: 20),
  89. Text(
  90. (roomInfo.playerNumber != null ? roomInfo.playerNumber.toString() : '0') + '/' + roomInfo.maxNumber.toString(),
  91. style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color:roomInfo.statusFlag==0? Theme.of(context).primaryColor: Color(0xFFB1B2C0)),
  92. )
  93. ],
  94. )
  95. ],
  96. ),
  97. ),
  98. onTap: () {
  99. Navigator.push(context, CupertinoPageRoute(builder: (context) => RoomInfo(roomId: roomInfo.id.toString())));
  100. },
  101. ),
  102. ),
  103. );
  104. }
  105. }