Hibok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

151 line
4.4 KiB

  1. import 'package:chat/data/constants.dart';
  2. import 'package:chat/models/gift_item_model.dart';
  3. import 'package:chat/utils/CustomUI.dart';
  4. import 'package:chat/utils/HttpUtil.dart';
  5. import 'package:chat/utils/TokenMgr.dart';
  6. import 'package:dio/dio.dart';
  7. import 'package:flutter/cupertino.dart';
  8. import 'package:flutter/material.dart';
  9. import 'package:chat/generated/i18n.dart';
  10. import 'package:oktoast/oktoast.dart';
  11. class GoddessHotPage extends StatefulWidget {
  12. final int userId;
  13. GoddessHotPage({Key key, this.userId}) : super(key: key);
  14. @override
  15. State<StatefulWidget> createState() {
  16. return GoddessHotPageState();
  17. }
  18. }
  19. class GoddessHotPageState extends State<GoddessHotPage> {
  20. List<GiftItemModel> giftList = [];
  21. @override
  22. void initState() {
  23. super.initState();
  24. getGiftInfo();
  25. }
  26. Future getGiftInfo() async {
  27. Map data = {
  28. "userId": widget.userId,
  29. };
  30. data['sign'] = TokenMgr().getSign(data);
  31. Response res = await HttpUtil().post('reward/user/stage',
  32. data: data, failback: () => Navigator.of(context).pop());
  33. var resData = res.data;
  34. print(resData);
  35. if (resData['code'] == 0) {
  36. giftList = resData['data']
  37. .map<GiftItemModel>((json) => GiftItemModel.havedFromJson(json))
  38. .toList();
  39. setState(() {});
  40. } else {
  41. showToast(resData['msg']);
  42. }
  43. }
  44. Widget _buildTips() {
  45. return Container(
  46. margin: EdgeInsets.only(left: 12, top: 15),
  47. child: Text(I18n.of(context).Goddess_heat_tips,
  48. textScaleFactor: 1.0,
  49. style: TextStyle(fontSize: 13, color: Constants.BlackTextColor)),
  50. );
  51. }
  52. Widget _buildGift(int id, String name, int nums) {
  53. return Container(
  54. child: Column(
  55. children: <Widget>[
  56. Stack(
  57. children: <Widget>[
  58. Container(
  59. width: 63,
  60. height: 71,
  61. decoration: BoxDecoration(
  62. borderRadius: BorderRadius.circular(6),
  63. border: Border.all(
  64. color: nums == 0
  65. ? Colors.transparent
  66. : const Color(0xFFFD5E83))),
  67. alignment: Alignment.center,
  68. child: Column(
  69. mainAxisAlignment: MainAxisAlignment.center,
  70. children: <Widget>[
  71. Expanded(
  72. child: Image.asset(
  73. "assets/images/gift_$id.png",
  74. width: 30,
  75. )),
  76. Text(
  77. name,
  78. textScaleFactor: 1.0,
  79. style: TextStyle(
  80. fontSize: 10, color: const Color(0xFF777777)),
  81. ),
  82. SizedBox(height: 9),
  83. ],
  84. ),
  85. ),
  86. Container(
  87. decoration: BoxDecoration(
  88. borderRadius: BorderRadius.circular(6),
  89. color: nums == 0
  90. ? Colors.black.withOpacity(0.45)
  91. : Colors.transparent,
  92. ),
  93. width: 63,
  94. height: 71,
  95. )
  96. ],
  97. ),
  98. SizedBox(height: 9),
  99. Text(
  100. nums.toString() + I18n.of(context).one,
  101. textScaleFactor: 1.0,
  102. style: TextStyle(fontSize: 12.5, color: const Color(0xFF515151)),
  103. ),
  104. ],
  105. ),
  106. );
  107. }
  108. @override
  109. Widget build(BuildContext context) {
  110. Widget appBar = new AppBar(
  111. elevation: 1,
  112. title: new Text(
  113. I18n.of(context).Goddess_heat,
  114. textScaleFactor: 1.0,
  115. ),
  116. leading: CustomUI.buildCustomLeading(context),
  117. centerTitle: true,
  118. );
  119. return Scaffold(
  120. appBar: appBar,
  121. backgroundColor: Colors.white,
  122. body: SafeArea(
  123. child: Column(
  124. crossAxisAlignment: CrossAxisAlignment.start,
  125. children: <Widget>[
  126. _buildTips(),
  127. SizedBox(height: 22.5),
  128. Row(
  129. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  130. children: giftList
  131. .map((gift) => _buildGift(gift.id, gift.name, gift.amount))
  132. .toList(),
  133. )
  134. ],
  135. ),
  136. ),
  137. );
  138. }
  139. }