openRoom.dart 25 KB

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