CreateRoom.dart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. @override
  36. Widget build(BuildContext context) {
  37. List<Color> colorList=[Theme.of(context).primaryColor,Color(0xFFFDC372)];
  38. List<List<String>> imageList=[[
  39. 'images/tancuang_shang.png',
  40. 'images/tancuang_xia.png'
  41. ],[
  42. 'images/tancuang_huang_shang.png',
  43. 'images/tancuang_huang_xia.png'
  44. ]];
  45. return GestureDetector(
  46. onTap: () {
  47. Navigator.pushReplacement(
  48. context,
  49. CupertinoPageRoute(
  50. builder: (context) => OpenRoom(
  51. roomFlag: 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. ),
  75. ),
  76. Positioned(
  77. bottom: 0,
  78. right: 4,
  79. child: Image.asset(
  80. imageList[btnIndex][1],
  81. ),
  82. )
  83. ],
  84. ),
  85. ),
  86. );
  87. }
  88. }