import 'package:chat/data/constants.dart';
import 'package:chat/models/ChatMsg.dart';
import 'package:chat/utils/msgHandler.dart';
import 'package:flutter/material.dart';

class SendMsgState extends StatefulWidget {
  final int sessionId;
  final int time;
  SendMsgState({this.sessionId,this.time});
  @override
  _SendMsgStateState createState() => _SendMsgStateState();
}

class _SendMsgStateState extends State<SendMsgState> {
  @override
  Widget build(BuildContext context) {
   var sendCache = MsgHandler.sendCache;
    for (var msg in sendCache) {
      if (msg.sessionId == widget.sessionId &&
          msg.time == widget.time) {
   
        if (msg.state == MsgState.SendingFailed) {
          return Padding(
              padding: EdgeInsets.only(right: 10),
              child: Icon(Icons.error_outline,
                  size: 12, color: Color(0xFFc0c0c0)));
        } else if (msg.state <= MsgState.Sending) {
          return Padding(
              padding: EdgeInsets.only(right: 10),
              child: Icon(
                  IconData(0xe657, fontFamily: Constants.IconFontFamily),
                  size: 12,
                  color: Color(0xFFc0c0c0)));
        }
      }
    }

    return SizedBox(width: 0);
  }
}