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.
 
 
 
 
 
 

149 lines
4.3 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. style: TextStyle(
  79. fontSize: 10, color: const Color(0xFF777777)),
  80. ),
  81. SizedBox(height: 9),
  82. ],
  83. ),
  84. ),
  85. Container(
  86. decoration: BoxDecoration(
  87. borderRadius: BorderRadius.circular(6),
  88. color: nums == 0
  89. ? Colors.black.withOpacity(0.45)
  90. : Colors.transparent,
  91. ),
  92. width: 63,
  93. height: 71,
  94. )
  95. ],
  96. ),
  97. SizedBox(height: 9),
  98. Text(
  99. nums.toString() + I18n.of(context).one,
  100. style: TextStyle(fontSize: 12.5, color: const Color(0xFF515151)),
  101. ),
  102. ],
  103. ),
  104. );
  105. }
  106. @override
  107. Widget build(BuildContext context) {
  108. Widget appBar = new AppBar(
  109. elevation: 1,
  110. title: new Text(
  111. I18n.of(context).Goddess_heat,
  112. textScaleFactor: 1.0,
  113. ),
  114. leading: CustomUI.buildCustomLeading(context),
  115. centerTitle: true,
  116. );
  117. return Scaffold(
  118. appBar: appBar,
  119. backgroundColor: Colors.white,
  120. body: SafeArea(
  121. child: Column(
  122. crossAxisAlignment: CrossAxisAlignment.start,
  123. children: <Widget>[
  124. _buildTips(),
  125. SizedBox(height: 22.5),
  126. Row(
  127. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  128. children: giftList
  129. .map((gift) => _buildGift(gift.id, gift.name, gift.amount))
  130. .toList(),
  131. )
  132. ],
  133. ),
  134. ),
  135. );
  136. }
  137. }