OpenRoom.dart 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_picker/flutter_picker.dart';
  3. import 'package:cached_network_image/cached_network_image.dart';
  4. import 'package:flutter/cupertino.dart';
  5. import 'package:file_picker/file_picker.dart';
  6. import '../styles/colors.dart';
  7. import 'dart:io';
  8. import 'dart:async';
  9. import 'dart:convert';
  10. import 'dart:ui';
  11. import '../styles/totast.dart';
  12. import '../pages/RoomInfo.dart';
  13. import 'package:flutter_redux/flutter_redux.dart';
  14. import '../redux/AppState.dart';
  15. import '../net/HttpManager.dart';
  16. import '../net/Result.dart';
  17. import 'package:dio/dio.dart';
  18. import '../model/GameInfo.dart';
  19. import '../model/HouseLevel.dart';
  20. import '../plugins/ScreenStramPlugin.dart';
  21. import '../widget/Dialog.dart';
  22. import '../widget/LinearButton.dart';
  23. class OpenRoom extends StatefulWidget {
  24. OpenRoom({Key key, this.roomFlag}) : super(key: key);
  25. final String roomFlag; // 用来储存传递过来的值
  26. @override
  27. OpenRoomState createState() => OpenRoomState();
  28. }
  29. class OpenRoomState extends State<OpenRoom> {
  30. TextStyle titleStyle = TextStyle(color: Colors.white, fontSize: 14);
  31. TextStyle valStyle = TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500);
  32. Map<String, dynamic> editRoomInfo = {'gameId': 1, 'houseLevel': 1, 'maxNumber': 5, 'killnumber': 3};
  33. List<GameInfo> gameList = [];
  34. List<HouseLevel> levelList = [];
  35. Future<void> getFilePath() async {
  36. File file = await FilePicker.getFile(type: FileType.ANY);
  37. if (file == null) {
  38. return;
  39. }
  40. print(file.statSync());
  41. Toast.show(context, '加载中', -1, 'loading');
  42. Result res = await HttpManager.post('assets/uploadFile', data: {
  43. 'file': UploadFileInfo(file, file.path),
  44. });
  45. Toast.hide();
  46. if (res.success) {
  47. setState(() {
  48. editRoomInfo['video'] = res.data[0];
  49. });
  50. }
  51. }
  52. Future<void> showSysDialog(id) async {
  53. Toast.show(context, '加载中', -1, 'loading');
  54. Result res = await HttpManager.get('alertMessage/getOne', data: {'id': id});
  55. Toast.hide();
  56. if (res.success) {
  57. MyDialog.showDialog(context, res.data['remark']);
  58. }
  59. }
  60. Future<void> saveInfo() async {
  61. if (!StoreProvider.of<AppState>(context).state.userInfo.createFlag) {
  62. showSysDialog(1);
  63. return;
  64. }
  65. if (!editRoomInfo.containsKey('gameId')) {
  66. Toast.show(context, '请选择游戏', 1500, 'info');
  67. return;
  68. }
  69. if (editRoomInfo['houseName'] == null || editRoomInfo['houseName'] == '') {
  70. Toast.show(context, '请输入房间标题', 1500, 'info');
  71. return;
  72. }
  73. // if (!editRoomInfo.containsKey('houseLevel')) {
  74. // Toast.show(context, '请选择房间等级', 1500, 'info');
  75. // return;
  76. // }
  77. if (editRoomInfo['houseType'] == '1' && (editRoomInfo['gameHouseId'] == null || editRoomInfo['gameHouseId'] == '')) {
  78. Toast.show(context, '请录入游戏房间号', 1500, 'info');
  79. return;
  80. }
  81. if (editRoomInfo['houseType'] == '1' && (editRoomInfo['gameHousePassword'] == null || editRoomInfo['gameHousePassword'] == '')) {
  82. Toast.show(context, '请录入游戏房间密码', 1500, 'info');
  83. return;
  84. }
  85. if (StoreProvider.of<AppState>(context).state.userInfo.moneyCoin != null) {
  86. HouseLevel chooseLevelInfo = HouseLevel.empty();
  87. for (var item in levelList) {
  88. if (item.id.toString() == editRoomInfo['houseLevel'].toString()) {
  89. chooseLevelInfo = item;
  90. }
  91. }
  92. if (StoreProvider.of<AppState>(context).state.userInfo.moneyCoin < chooseLevelInfo.entryCoin) {
  93. return;
  94. }
  95. } else {
  96. return;
  97. }
  98. bool hasPermission = await ScreenStreamPlugin.checkPermission();
  99. if (!hasPermission) {
  100. showDialog(
  101. context: context,
  102. builder: (context) => AlertDialog(
  103. title: Text('需要悬浮窗权限'),
  104. contentTextStyle: TextStyle(color: Colors.black87),
  105. content: Text('请在点击确定后,勾选"允许显示在其他应用的上层"'),
  106. actions: <Widget>[
  107. FlatButton(
  108. child: Text('确定'),
  109. onPressed: () {
  110. Navigator.of(context).pop();
  111. ScreenStreamPlugin.requestPermission();
  112. },
  113. ),
  114. ],
  115. ),
  116. );
  117. return;
  118. }
  119. editRoomInfo['createUser'] = StoreProvider.of<AppState>(context).state.userInfo.id;
  120. editRoomInfo['userId'] = StoreProvider.of<AppState>(context).state.userInfo.id;
  121. Toast.show(context, '加载中', -1, 'loading');
  122. Result res = await HttpManager.post('houseInfo/save', data: editRoomInfo);
  123. Toast.hide();
  124. if (res.success) {
  125. // HttpManager.post('houseInfo/join', data: {
  126. // 'houseId': res.data,
  127. // 'userId': StoreProvider.of<AppState>(context).state.userInfo.id
  128. // });
  129. Toast.show(context, '创建成功', 1500, 'success');
  130. Future.delayed(Duration(milliseconds: 1500), () {
  131. Navigator.pushReplacement(context, CupertinoPageRoute(builder: (context) => RoomInfo(roomId: res.data.toString())));
  132. });
  133. } else {
  134. Toast.show(context, res.error, 1500, 'info');
  135. }
  136. }
  137. Future<void> getInfo() async {
  138. Toast.show(context, '加载中', -1, 'loading');
  139. Result res = await HttpManager.get('gameInfo/all');
  140. if (res.success) {
  141. List<GameInfo> _list = [];
  142. for (var item in res.data) {
  143. _list.add(GameInfo.fromJson(item));
  144. }
  145. setState(() {
  146. gameList = _list;
  147. if (res.data.length > 0) {
  148. editRoomInfo['gameId'] = res.data[0]['id'];
  149. String name = StoreProvider.of<AppState>(context).state.userInfo.nickname;
  150. editRoomInfo['houseName'] = (name.length > 5 ? name.substring(0, 5) : name) + '的' + res.data[0]['shortName'] + '房间';
  151. editRoomInfo['houseAbstract'] = res.data[0]['profile'] ?? '';
  152. }
  153. });
  154. } else {}
  155. Result res2 = await HttpManager.get('houseLevel/all');
  156. Toast.hide();
  157. if (res2.success) {
  158. List<HouseLevel> _list = [];
  159. for (var item in res2.data) {
  160. _list.add(HouseLevel.fromJson(item));
  161. }
  162. setState(() {
  163. levelList = _list;
  164. if (levelList.isNotEmpty) {
  165. editRoomInfo['houseLevel'] = res2.data[0]['id'];
  166. }
  167. });
  168. } else {}
  169. }
  170. @override
  171. void initState() {
  172. super.initState();
  173. editRoomInfo['houseType'] = widget.roomFlag;
  174. Future.delayed(Duration.zero, () {
  175. getInfo();
  176. });
  177. }
  178. @override
  179. Widget build(BuildContext context) {
  180. GameInfo chooseGameInfo = GameInfo.empty();
  181. for (var item in gameList) {
  182. if (item.id.toString() == editRoomInfo['gameId'].toString()) {
  183. chooseGameInfo = item;
  184. }
  185. }
  186. HouseLevel chooseLevelInfo = HouseLevel.empty();
  187. for (var item in levelList) {
  188. if (item.id.toString() == editRoomInfo['houseLevel'].toString()) {
  189. chooseLevelInfo = item;
  190. }
  191. }
  192. return WillPopScope(
  193. child: Scaffold(
  194. appBar: AppBar(
  195. title: Text('发起赛事'),
  196. centerTitle: true,
  197. elevation: 0,
  198. // actions: <Widget>[
  199. // Container(
  200. // width: 60,
  201. // child: FlatButton(
  202. // highlightColor: PRIMARY_COLOR,
  203. // padding: EdgeInsets.only(right: 0),
  204. // child: Text('规则',
  205. // style: TextStyle(color: Colors.white, fontSize: 13)),
  206. // onPressed: () {},
  207. // ),
  208. // )
  209. // ],
  210. ),
  211. body: Container(
  212. color: Color(0xFF2E3049),
  213. width: double.infinity,
  214. height: double.infinity,
  215. child: SingleChildScrollView(
  216. child: Container(
  217. child: Column(
  218. children: <Widget>[
  219. Container(
  220. width: double.infinity,
  221. color: Color(0xFF1D1E2E),
  222. height: 210,
  223. child: Column(
  224. mainAxisAlignment: MainAxisAlignment.center,
  225. children: <Widget>[
  226. Container(
  227. width: 160,
  228. height: 38,
  229. child: LinearButton(
  230. radius: 38.0,
  231. colorList: [Color(0xFF3A3E61), Color(0xFF3A3E61)],
  232. childWidget: Row(
  233. mainAxisAlignment: MainAxisAlignment.center,
  234. children: <Widget>[
  235. Padding(
  236. padding: EdgeInsets.only(right: 8),
  237. child: Image.asset(
  238. 'images/icon_shipin.png',
  239. width: 20,
  240. )),
  241. Text('上传图片或视频', style: titleStyle)
  242. ],
  243. ),
  244. onTapHomeMenu: () {
  245. getFilePath();
  246. },
  247. ),
  248. ),
  249. Padding(
  250. padding: EdgeInsets.only(top: 12),
  251. child: Text(
  252. editRoomInfo.containsKey('video') ? '已选择' : '不上传则自动使用官方默认视频',
  253. style: TextStyle(color: Color(0xFF9BA0AE), fontSize: 13),
  254. ),
  255. )
  256. ],
  257. ),
  258. ),
  259. //房间标题
  260. // Container(
  261. // height: 60,
  262. // color: BG_COLOR,
  263. // padding:
  264. // EdgeInsets.symmetric(horizontal: 15, vertical: 8),
  265. // child: TextField(
  266. // textAlign: TextAlign.end,
  267. // style: valStyle,
  268. // maxLength: 10,
  269. // decoration: InputDecoration(
  270. // hintText: '请输入房间标题',
  271. // hintStyle: TextStyle(
  272. // color: Color(0xFF727785), fontSize: 13),
  273. // prefixIcon: Padding(
  274. // padding: EdgeInsets.symmetric(vertical: 12),
  275. // child: Text('房间标题', style: titleStyle),
  276. // ),
  277. // border: InputBorder.none,
  278. // counterStyle: TextStyle(fontSize: 0)),
  279. // onChanged: (value) {
  280. // editRoomInfo['houseName'] = value;
  281. // },
  282. // ),
  283. // ),
  284. ChooseContent(
  285. title: '选择游戏',
  286. val: chooseGameInfo.gameName,
  287. onTapHomeMenu: () {
  288. showPicker(context);
  289. },
  290. ),
  291. Container(
  292. margin: EdgeInsets.symmetric(horizontal: 15),
  293. height: 1,
  294. color: BG_SUB_COLOR,
  295. ),
  296. InputContent(
  297. title: '房间标题',
  298. value: editRoomInfo['houseName'],
  299. onTextChange: (value) {
  300. editRoomInfo['houseName'] = value;
  301. }),
  302. Container(
  303. margin: EdgeInsets.symmetric(horizontal: 15),
  304. height: 1,
  305. color: BG_SUB_COLOR,
  306. ),
  307. // //房间简介
  308. // InputContent(
  309. // title: '房间简介',
  310. // value: editRoomInfo['houseAbstract'],
  311. // onTextChange: (value) {
  312. // editRoomInfo['houseAbstract'] = value;
  313. // }),
  314. // Container(
  315. // height: 60,
  316. // color: BG_COLOR,
  317. // padding:
  318. // EdgeInsets.symmetric(horizontal: 15, vertical: 8),
  319. // child: TextField(
  320. // textAlign: TextAlign.end,
  321. // style: valStyle,
  322. // maxLength: 15,
  323. // decoration: InputDecoration(
  324. // hintText: '请输入房间简介',
  325. // hintStyle: TextStyle(
  326. // color: Color(0xFF727785), fontSize: 13),
  327. // prefixIcon: Padding(
  328. // padding: EdgeInsets.symmetric(vertical: 12),
  329. // child: Text('房间简介', style: titleStyle),
  330. // ),
  331. // border: InputBorder.none,
  332. // counterStyle: TextStyle(fontSize: 0)),
  333. // onChanged: (value) {
  334. // editRoomInfo['houseAbstract'] = value;
  335. // },
  336. // ),
  337. // ),
  338. //房间等级
  339. // ChooseContent(
  340. // title: '房间等级',
  341. // chooseLevelInfo: chooseLevelInfo,
  342. // isLevel: true,
  343. // onTapHomeMenu: () {
  344. // showLevelPicker(context);
  345. // },
  346. // ),
  347. Container(
  348. margin: EdgeInsets.symmetric(horizontal: 15),
  349. height: 1,
  350. color: BG_SUB_COLOR,
  351. ),
  352. //房间人数
  353. ChooseContent(
  354. title: '房卡人数',
  355. val: editRoomInfo['maxNumber'].toString() + '人次房卡',
  356. icon: Image.asset('images/icon_yiwen.png'),
  357. onTapHomeMenu: () {
  358. showNumPicker(context);
  359. },
  360. ),
  361. Container(
  362. margin: EdgeInsets.symmetric(horizontal: 15),
  363. height: 1,
  364. color: BG_SUB_COLOR,
  365. ),
  366. //房间人数
  367. ChooseContent(
  368. title: '胜利条件',
  369. val:"杀戮${editRoomInfo['killnumber']}人模式",
  370. onTapHomeMenu: () {
  371. showScoreType(context);
  372. },
  373. ),
  374. _bottomWidget(),
  375. ],
  376. ),
  377. ),
  378. ),
  379. ),
  380. floatingActionButton: Padding(
  381. padding: EdgeInsets.fromLTRB(15, 39, 15, 10),
  382. child: LinearButton(
  383. onTapHomeMenu: () {
  384. saveInfo();
  385. },
  386. childWidget: Row(
  387. mainAxisAlignment: MainAxisAlignment.center,
  388. children: <Widget>[
  389. Padding(
  390. padding: EdgeInsets.only(right: 6),
  391. child: Image.asset('images/icon_renci.png'),
  392. ),
  393. Text(
  394. '×${editRoomInfo["maxNumber"]}',
  395. style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
  396. ),
  397. Padding(
  398. padding: EdgeInsets.only(left: 20),
  399. child: Text(
  400. '创建房间',
  401. style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
  402. ),
  403. )
  404. ],
  405. ),
  406. ),
  407. ),
  408. floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
  409. ),
  410. onWillPop: () {
  411. Toast.hide();
  412. Navigator.pop(context);
  413. return Future.value(false);
  414. },
  415. );
  416. }
  417. Widget _bottomWidget() {
  418. if (widget.roomFlag == '1')
  419. return Column(
  420. children: <Widget>[
  421. Container(
  422. height: 10,
  423. color: BG_SUB_COLOR,
  424. ),
  425. //游戏房间号
  426. Container(
  427. height: 60,
  428. color: BG_COLOR,
  429. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 8),
  430. child: TextField(
  431. textAlign: TextAlign.end,
  432. style: valStyle,
  433. maxLength: 15,
  434. decoration: InputDecoration(
  435. hintText: '请输入游戏房间号',
  436. hintStyle: TextStyle(color: Color(0xFF727785), fontSize: 13),
  437. prefixIcon: Padding(
  438. padding: EdgeInsets.symmetric(vertical: 12),
  439. child: Text('游戏房间号', style: titleStyle),
  440. ),
  441. border: InputBorder.none,
  442. counterStyle: TextStyle(fontSize: 0)),
  443. onChanged: (value) {
  444. editRoomInfo['gameHouseId'] = value;
  445. },
  446. ),
  447. ),
  448. Container(
  449. height: 1,
  450. color: BG_SUB_COLOR,
  451. ),
  452. //游戏中房间密��
  453. Container(
  454. height: 60,
  455. color: BG_COLOR,
  456. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 8),
  457. child: TextField(
  458. textAlign: TextAlign.end,
  459. style: valStyle,
  460. maxLength: 10,
  461. decoration: InputDecoration(
  462. hintText: '请输入密码',
  463. hintStyle: TextStyle(color: Color(0xFF727785), fontSize: 13),
  464. prefixIcon: Padding(
  465. padding: EdgeInsets.symmetric(vertical: 12),
  466. child: Text('游戏中房间密码', style: titleStyle),
  467. ),
  468. border: InputBorder.none,
  469. counterStyle: TextStyle(fontSize: 0)),
  470. onChanged: (value) {
  471. editRoomInfo['gameHousePassword'] = value;
  472. },
  473. ),
  474. ),
  475. ],
  476. );
  477. else {
  478. return Container();
  479. }
  480. }
  481. void showPicker(BuildContext context) {
  482. List<String> _list = [];
  483. for (var item in gameList) {
  484. _list.add(item.gameName);
  485. }
  486. String PickerData = json.encode(_list);
  487. Picker(
  488. confirmText: '确定',
  489. cancelText: '取消',
  490. adapter: PickerDataAdapter<String>(pickerdata: JsonDecoder().convert(PickerData)),
  491. changeToFirst: true,
  492. textAlign: TextAlign.left,
  493. columnPadding: const EdgeInsets.all(8.0),
  494. onConfirm: (Picker picker, List value) {
  495. setState(() {
  496. editRoomInfo['gameId'] = gameList[value[0]].id;
  497. editRoomInfo['houseName'] = StoreProvider.of<AppState>(context).state.userInfo.nickname + '的' + gameList[value[0]].shortName + '房间';
  498. editRoomInfo['houseAbstract'] = gameList[value[0]].profile ?? '';
  499. });
  500. }).showModal(this.context);
  501. }
  502. void showNumPicker(BuildContext context) {
  503. List _list = [];
  504. List _listName = [];
  505. List _member = [5, 10, 15, 20, 25, 50, 100];
  506. for (var item in _member) {
  507. _list.add(item);
  508. _listName.add(item.toString() + '人次房卡');
  509. }
  510. String pickerData = json.encode(_listName);
  511. Picker(
  512. confirmText: '确定',
  513. cancelText: '取消',
  514. adapter: PickerDataAdapter<String>(pickerdata: JsonDecoder().convert(pickerData)),
  515. changeToFirst: true,
  516. textAlign: TextAlign.left,
  517. columnPadding: const EdgeInsets.all(8.0),
  518. onConfirm: (Picker picker, List value) {
  519. setState(() {
  520. editRoomInfo['maxNumber'] = _list[value[0]];
  521. });
  522. }).showModal(this.context);
  523. }
  524. void showScoreType(BuildContext context) {
  525. List _list = ['杀戮3人模式', '杀戮5人模式', '杀戮10人模式'];
  526. List _val = [3, 5, 10];
  527. String PickerData = json.encode(_list);
  528. Picker(
  529. confirmText: '确定',
  530. cancelText: '取消',
  531. adapter: PickerDataAdapter<String>(pickerdata: JsonDecoder().convert(PickerData)),
  532. changeToFirst: true,
  533. textAlign: TextAlign.left,
  534. columnPadding: const EdgeInsets.all(8.0),
  535. onConfirm: (Picker picker, List value) {
  536. setState(() {
  537. editRoomInfo['killnumber'] = _val[value[0]];
  538. });
  539. }).showModal(this.context);
  540. }
  541. void showLevelPicker(BuildContext context) {
  542. List<String> _list = [];
  543. for (var item in levelList) {
  544. _list.add(item.levelName);
  545. }
  546. String PickerData = json.encode(_list);
  547. Picker(
  548. confirmText: '确定',
  549. cancelText: '取消',
  550. adapter: PickerDataAdapter<String>(pickerdata: JsonDecoder().convert(PickerData)),
  551. changeToFirst: true,
  552. textAlign: TextAlign.left,
  553. columnPadding: const EdgeInsets.all(8.0),
  554. onConfirm: (Picker picker, List value) {
  555. setState(() {
  556. editRoomInfo['houseLevel'] = levelList[value[0]].id;
  557. });
  558. }).showModal(this.context);
  559. }
  560. }
  561. typedef void OnTapHomeMenu();
  562. typedef ValueChanged<T> = void Function(T value);
  563. class ChooseContent extends StatelessWidget {
  564. ChooseContent({Key key, this.title, this.val, this.chooseLevelInfo, this.isLevel = false, this.icon, this.onTapHomeMenu}) : super(key: key);
  565. final String title;
  566. final String val;
  567. final OnTapHomeMenu onTapHomeMenu;
  568. final HouseLevel chooseLevelInfo;
  569. final Image icon;
  570. final bool isLevel;
  571. GlobalKey anchorKey = GlobalKey();
  572. @override
  573. Widget build(BuildContext context) {
  574. return Container(
  575. child: InkWell(
  576. child: Container(
  577. height: 60,
  578. padding: EdgeInsets.symmetric(horizontal: 15),
  579. child: Row(
  580. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  581. children: <Widget>[
  582. Text(title, style: TextStyle(fontSize: 14, color: Colors.white)),
  583. icon != null
  584. ? InkWell(
  585. onTap: () {
  586. //弹出
  587. RenderBox renderBox = anchorKey.currentContext.findRenderObject();
  588. var offset = renderBox.localToGlobal(Offset.zero);
  589. print(offset.dx.toString() + ',' + offset.dy.toString());
  590. Navigator.of(context).push(PageRouteBuilder(
  591. opaque: false,
  592. transitionDuration: Duration(milliseconds: 300),
  593. transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  594. return FadeTransition(
  595. opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
  596. child: child,
  597. );
  598. },
  599. pageBuilder: (BuildContext context, _, __) {
  600. return FloatTextContent(dx: offset.dx, dy: offset.dy);
  601. }));
  602. },
  603. child: Padding(padding: EdgeInsets.all(9), child: icon, key: anchorKey))
  604. : Container(),
  605. Expanded(
  606. flex: 1,
  607. child: isLevel
  608. ? Row(
  609. mainAxisAlignment: MainAxisAlignment.end,
  610. children: <Widget>[
  611. chooseLevelInfo.icon != null
  612. ? Image.network(
  613. chooseLevelInfo.icon,
  614. width: 22,
  615. )
  616. : Container(),
  617. Text(
  618. chooseLevelInfo.levelName ?? '',
  619. style: TextStyle(color: Color(0xFFF9D881)),
  620. ),
  621. Padding(
  622. padding: EdgeInsets.only(left: 20, right: 2),
  623. child: Image.asset('images/icon_jinbi_da_bai.png', width: 20),
  624. ),
  625. Text(
  626. '×' + (chooseLevelInfo.entryCoin ?? 0).toString(),
  627. style: TextStyle(color: Colors.white, fontSize: 15, fontWeight: FontWeight.w500),
  628. )
  629. ],
  630. )
  631. : Text(val ?? '', style: TextStyle(fontSize: 15, color: Colors.white, fontWeight: FontWeight.w500), textAlign: TextAlign.right),
  632. ),
  633. Image.asset('images/icon_inter.png', width: 24)
  634. ],
  635. ),
  636. ),
  637. onTap: onTapHomeMenu,
  638. ));
  639. }
  640. }
  641. class InputContent extends StatefulWidget {
  642. InputContent({Key key, this.title, this.value, this.onTextChange}) : super(key: key);
  643. final String title;
  644. final String value;
  645. final ValueChanged onTextChange;
  646. @override
  647. InputContentState createState() => InputContentState();
  648. }
  649. class InputContentState extends State<InputContent> {
  650. TextEditingController _controller;
  651. @override
  652. void initState() {
  653. super.initState();
  654. _controller = TextEditingController();
  655. }
  656. @override
  657. void didUpdateWidget(InputContent oldWidget) {
  658. super.didUpdateWidget(oldWidget);
  659. _controller.text = widget.value ?? '';
  660. }
  661. @override
  662. Widget build(BuildContext context) {
  663. return Container(
  664. height: 60,
  665. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 8),
  666. child: TextField(
  667. controller: _controller,
  668. textAlign: TextAlign.end,
  669. style: TextStyle(fontSize: 15, color: Colors.white, fontWeight: FontWeight.w500),
  670. maxLength: 10,
  671. decoration: InputDecoration(
  672. hintText: '请输入' + widget.title,
  673. hintStyle: TextStyle(color: Color(0xFF727785), fontSize: 13),
  674. prefixIcon: Padding(
  675. padding: EdgeInsets.symmetric(vertical: 12),
  676. child: Text(widget.title, style: TextStyle(fontSize: 14, color: Colors.white)),
  677. ),
  678. border: InputBorder.none,
  679. counterStyle: TextStyle(fontSize: 0)),
  680. onChanged: widget.onTextChange,
  681. ),
  682. );
  683. }
  684. }
  685. class FloatTextContent extends StatelessWidget {
  686. final num dx;
  687. final num dy;
  688. FloatTextContent({this.dx, this.dy});
  689. @override
  690. Widget build(BuildContext context) {
  691. return GestureDetector(
  692. onTap: () {
  693. Navigator.of(context).pop();
  694. },
  695. child: Container(
  696. color: Colors.transparent,
  697. child: Stack(
  698. children: <Widget>[
  699. Positioned(
  700. left: dx + 31,
  701. top: dy + 9,
  702. child: Container(
  703. padding: EdgeInsets.all(10),
  704. decoration: BoxDecoration(
  705. borderRadius: BorderRadius.only(topRight: Radius.circular(8), bottomLeft: Radius.circular(8), bottomRight: Radius.circular(8)),
  706. color: Color(0xFF3A3E61),
  707. ),
  708. constraints: BoxConstraints(maxWidth: 241),
  709. child: Text('房主可以选择不同人次的房卡进行开始比赛,同步消耗自己相应的参赛名额,比如选择50人次房卡,系统从我的账号上扣除50人次参赛名额,房间内最多可进入50人参加比赛',
  710. style: TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w400, decoration: TextDecoration.none)),
  711. ),
  712. )
  713. ],
  714. ),
  715. ),
  716. );
  717. }
  718. }