|
- import 'dart:math';
-
- import 'package:chat/data/constants.dart';
- import 'package:chat/models/gift_item_model.dart';
- import 'package:chat/r.dart';
- import 'package:chat/utils/screen.dart';
- import 'package:flutter/material.dart';
-
- class GiftItem extends StatelessWidget {
- final GiftItemModel itemModel;
- final isSelected;
-
- GiftItem({this.isSelected = false, this.itemModel});
- @override
- Widget build(BuildContext context) {
- var imgPath = 'assets/images/gift_${itemModel.id}.png';
- if (isSelected) {
- imgPath = 'assets/images/gift_anim_${itemModel.id}.gif';
- }
-
- var curAmount = '0';
- if (itemModel.amount >= 100) {
- curAmount = '99+';
- } else {
- curAmount = itemModel.amount.toString();
- }
- return ClipRRect(
- borderRadius: BorderRadius.circular(10),
- child: Container(
- width: 85,
- height: 110,
- decoration: BoxDecoration(
- color: Colors.transparent,
- border: Border.all(
- color: isSelected ? Colors.orangeAccent : Colors.grey[200],
- width: 1),
- borderRadius: BorderRadius.circular(10),
- ),
- child: Stack(
- children: <Widget>[
- Column(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: <Widget>[
- SizedBox(height: 10),
- Image.asset(imgPath,
- fit: BoxFit.contain, width: 75, height: 40),
- Text(
- itemModel.name,
- textScaleFactor: 1.0,
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(fontSize: 10),
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Image.asset(
- R.assetsImagesCoin,
- scale: 5,
- ),
- SizedBox(width: 3),
- fixedText(itemModel.price.toString(),
- color: Constants.GreyTextColor),
- ],
- ),
- SizedBox(height: 5)
- ],
- ),
- Positioned(
- left: -30,
- top: 30,
- child: Container(
- height: 25,
- width: 80,
- transform: Matrix4.rotationZ(-pi / 4),
- color: Color(0xFFFD6E8F),
- ),
- ),
- Container(
- width: 25,
- height: 25,
- alignment: Alignment.center,
- child: fixedText(curAmount,
- fontSize: 12, color: Colors.white)),
- ],
- )));
- }
- }
|