import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'OpenRoom.dart'; //创建房间

class CreateRoom extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        Navigator.of(context).pop();
      },
      child: Scaffold(
        backgroundColor: Color(0xCC000000),
        body: Container(
          child: SizedBox.expand(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                _CreateRoomBtn('创建普通房间',0),
                SizedBox(
                  height: 36,
                ),
                _CreateRoomBtn('创建官方房间', 1)
              ],
            ),
          ),
        ),
      ),
    );
  }
}

class _CreateRoomBtn extends StatelessWidget {
  final String title;
  final int btnIndex;
  _CreateRoomBtn(this.title, this.btnIndex);

  

  @override
  Widget build(BuildContext context) {
    List<Color> colorList=[Theme.of(context).primaryColor,Color(0xFFFDC372)];
  List<List<String>> imageList=[[
    'images/tancuang_shang.png',
    'images/tancuang_xia.png'
  ],[
    'images/tancuang_huang_shang.png',
    'images/tancuang_huang_xia.png'
  ]];
    return GestureDetector(
      onTap: () {
        Navigator.pushReplacement(
            context,
            CupertinoPageRoute(
                builder: (context) => OpenRoom(
                    roomFlag: title == '创建普通房间' ? '0' : '1')));
      },
      child: Container(
        width: 250,
        height: 96,
        decoration: BoxDecoration(
            border: Border.all(width: 1, color: colorList[btnIndex]),
            image: DecorationImage(
                image: AssetImage('images/img_guangmang.png'),
                fit: BoxFit.cover)),
        child: Stack(
          children: <Widget>[
            Center(
              child: Text(
                title,
                style: TextStyle(color: colorList[btnIndex], fontSize: 22),
              ),
            ),
            Positioned(
              top: 0,
              left: 0,
              child: Image.asset(
                imageList[btnIndex][0],
              ),
            ),
            Positioned(
              bottom: 0,
              right: 4,
              child: Image.asset(
                imageList[btnIndex][1],
              ),
            )
          ],
        ),
      ),
    );
  }
}
