RoomItem.dart 4.0 KB

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