RoomItem.dart 3.7 KB

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