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.
 
 
 
 
 
 

48 lines
1.5 KiB

  1. import 'package:chat/generated/i18n.dart';
  2. import 'package:chat/proto/all.pbserver.dart';
  3. import 'package:chat/utils/screen.dart';
  4. import 'package:flutter/material.dart';
  5. class GiftMsgItem extends StatelessWidget {
  6. final bool isMe;
  7. final List<int> msgContent;
  8. GiftMsgItem(this.msgContent, this.isMe);
  9. @override
  10. Widget build(BuildContext context) {
  11. GiftChat giftChat = GiftChat.fromBuffer(msgContent);
  12. var str = '';
  13. if (isMe) {
  14. str = I18n.of(context)
  15. .send_gift1
  16. .replaceFirst('/s1', giftChat.giftAmount.toString());
  17. } else {
  18. str = I18n.of(context)
  19. .receive_gift1
  20. .replaceFirst('/s1', giftChat.giftAmount.toString());
  21. }
  22. var imgPath = 'assets/images/gift_${giftChat.giftId}.png';
  23. return Container(
  24. padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5),
  25. constraints: BoxConstraints(maxWidth: Screen.width - 120),
  26. child: Row(
  27. mainAxisSize: MainAxisSize.min,
  28. children: <Widget>[
  29. Container(
  30. child: fixedText(str, fontSize: 14, color: Colors.white),
  31. constraints: BoxConstraints(maxWidth: Screen.width - 175),
  32. ),
  33. SizedBox(width: 10),
  34. Image.asset(imgPath, height: 25, width: 25, fit: BoxFit.contain),
  35. ],
  36. ),
  37. decoration: BoxDecoration(
  38. color: Color(0xFFF92222).withAlpha(60),
  39. border: Border.all(color: Color(0xFFB9CBD7), width: 0.6),
  40. borderRadius: BorderRadius.all(Radius.circular(7.5))),
  41. );
  42. }
  43. }