Hibok
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

89 行
3.0 KiB

  1. import 'dart:math';
  2. import 'package:chat/data/constants.dart';
  3. import 'package:chat/models/gift_item_model.dart';
  4. import 'package:chat/r.dart';
  5. import 'package:chat/utils/screen.dart';
  6. import 'package:flutter/material.dart';
  7. class GiftItem extends StatelessWidget {
  8. final GiftItemModel itemModel;
  9. final isSelected;
  10. GiftItem({this.isSelected = false, this.itemModel});
  11. @override
  12. Widget build(BuildContext context) {
  13. var imgPath = 'assets/images/gift_${itemModel.id}.png';
  14. if (isSelected) {
  15. imgPath = 'assets/images/gift_anim_${itemModel.id}.gif';
  16. }
  17. var curAmount = '0';
  18. if (itemModel.amount >= 100) {
  19. curAmount = '99+';
  20. } else {
  21. curAmount = itemModel.amount.toString();
  22. }
  23. return ClipRRect(
  24. borderRadius: BorderRadius.circular(10),
  25. child: Container(
  26. width: 85,
  27. height: 110,
  28. decoration: BoxDecoration(
  29. color: Colors.transparent,
  30. border: Border.all(
  31. color: isSelected ? Colors.orangeAccent : Colors.grey[200],
  32. width: 1),
  33. borderRadius: BorderRadius.circular(10),
  34. ),
  35. child: Stack(
  36. children: <Widget>[
  37. Column(
  38. mainAxisAlignment: MainAxisAlignment.spaceAround,
  39. children: <Widget>[
  40. SizedBox(height: 10),
  41. Image.asset(imgPath,
  42. fit: BoxFit.contain, width: 75, height: 40),
  43. Text(
  44. itemModel.name,
  45. textScaleFactor: 1.0,
  46. maxLines: 1,
  47. overflow: TextOverflow.ellipsis,
  48. style: TextStyle(fontSize: 10),
  49. ),
  50. Row(
  51. mainAxisAlignment: MainAxisAlignment.center,
  52. children: <Widget>[
  53. Image.asset(
  54. R.assetsImagesCoin,
  55. scale: 5,
  56. ),
  57. SizedBox(width: 3),
  58. fixedText(itemModel.price.toString(),
  59. color: Constants.GreyTextColor),
  60. ],
  61. ),
  62. SizedBox(height: 5)
  63. ],
  64. ),
  65. Positioned(
  66. left: -30,
  67. top: 30,
  68. child: Container(
  69. height: 25,
  70. width: 80,
  71. transform: Matrix4.rotationZ(-pi / 4),
  72. color: Color(0xFFFD6E8F),
  73. ),
  74. ),
  75. Container(
  76. width: 25,
  77. height: 25,
  78. alignment: Alignment.center,
  79. child: fixedText(curAmount,
  80. fontSize: 12, color: Colors.white)),
  81. ],
  82. )));
  83. }
  84. }