import 'package:chat/generated/i18n.dart';
import 'package:chat/proto/all.pbserver.dart';
import 'package:chat/utils/screen.dart';
import 'package:flutter/material.dart';

class GiftMsgItem extends StatelessWidget {
  final bool isMe;
  final List<int> msgContent;
  GiftMsgItem(this.msgContent, this.isMe);
  @override
  Widget build(BuildContext context) {
    GiftChat giftChat = GiftChat.fromBuffer(msgContent);

    var str = '';
    if (isMe) {
      str = I18n.of(context)
          .send_gift1
          .replaceFirst('/s1', giftChat.giftAmount.toString());
    } else {
      str = I18n.of(context)
          .receive_gift1
          .replaceFirst('/s1', giftChat.giftAmount.toString());
    }

    var imgPath = 'assets/images/gift_${giftChat.giftId}.png';

    return Container(
      padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5),
      constraints: BoxConstraints(maxWidth: Screen.width - 120),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          Container(
            child: fixedText(str, fontSize: 14, color: Colors.white),
            constraints: BoxConstraints(maxWidth: Screen.width - 175),
          ),
          SizedBox(width: 10),
          Image.asset(imgPath, height: 25, width: 25, fit: BoxFit.contain),
        ],
      ),
      decoration: BoxDecoration(
          color: Color(0xFFF92222).withAlpha(60),
          border: Border.all(color: Color(0xFFB9CBD7), width: 0.6),
          borderRadius: BorderRadius.all(Radius.circular(7.5))),
    );
  }
}
