CreateRoom.dart 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'OpenRoom.dart'; //创建房间
  4. class CreateRoom extends StatelessWidget {
  5. @override
  6. Widget build(BuildContext context) {
  7. return GestureDetector(
  8. onTap: () {
  9. Navigator.of(context).pop();
  10. },
  11. child: Scaffold(
  12. backgroundColor: Color(0xCC000000),
  13. body: Container(
  14. child: SizedBox.expand(
  15. child: Column(
  16. mainAxisAlignment: MainAxisAlignment.center,
  17. children: <Widget>[
  18. _CreateRoomBtn("创建普通房间",0),
  19. SizedBox(
  20. height: 36,
  21. ),
  22. _CreateRoomBtn("创建官方房间", 1)
  23. ],
  24. ),
  25. ),
  26. ),
  27. ),
  28. );
  29. }
  30. }
  31. class _CreateRoomBtn extends StatelessWidget {
  32. final String title;
  33. final int btnIndex;
  34. _CreateRoomBtn(this.title, this.btnIndex);
  35. List<Color> colorList=[Color(0xFFC2524D),Color(0xFFFDC372)];
  36. List<List<String>> imageList=[[
  37. 'images/tancuang_shang.png',
  38. 'images/tancuang_xia.png'
  39. ],[
  40. 'images/tancuang_huang_shang.png',
  41. 'images/tancuang_huang_xia.png'
  42. ]];
  43. @override
  44. Widget build(BuildContext context) {
  45. return GestureDetector(
  46. onTap: () {
  47. Navigator.pushReplacement(
  48. context,
  49. new CupertinoPageRoute(
  50. builder: (context) => new OpenRoom(
  51. roomFlag: this.title == '创建普通房间' ? '0' : '1')));
  52. },
  53. child: Container(
  54. width: 250,
  55. height: 96,
  56. decoration: BoxDecoration(
  57. border: Border.all(width: 1, color: colorList[btnIndex]),
  58. image: DecorationImage(
  59. image: AssetImage('images/img_guangmang.png'),
  60. fit: BoxFit.cover)),
  61. child: Stack(
  62. children: <Widget>[
  63. Center(
  64. child: Text(
  65. title,
  66. style: TextStyle(color: colorList[btnIndex], fontSize: 22),
  67. ),
  68. ),
  69. Positioned(
  70. top: 0,
  71. left: 0,
  72. child: Image.asset(
  73. imageList[btnIndex][0],
  74. width: 131,
  75. ),
  76. ),
  77. Positioned(
  78. bottom: 0,
  79. right: 4,
  80. child: Image.asset(
  81. imageList[btnIndex][1],
  82. width: 148,
  83. ),
  84. )
  85. ],
  86. ),
  87. ),
  88. );
  89. }
  90. }