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