getHeader method

dynamic getHeader(
  1. ChatMessageModel chatList,
  2. BuildContext context
)

Implementation

getHeader(ChatMessageModel chatList, BuildContext context) {
  return FutureBuilder(
      future: getProfile(),
      builder: (context, d) {
        var userProfile = d.data;
        if (userProfile != null) {
          if (chatList.isMessageSentByMe) {
            return Row(
              // mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                getChatTime(chatList.messageSentTime.toInt()),
                const SizedBox(
                  width: 10,
                ),
                Expanded(
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      Flexible(
                        child: Text(
                          userProfile.name.checkNull(),
                          style: TextStyle(
                              fontWeight: FontWeight.bold,
                              fontSize: 15,
                              color:
                                  MirrorflyUikit.getTheme?.textPrimaryColor),
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                        ),
                      ),
                      Container(
                          decoration: BoxDecoration(
                            color: MirrorflyUikit.getTheme?.secondaryColor,
                            borderRadius:
                                const BorderRadius.all(Radius.circular(2)),
                          ),
                          margin: const EdgeInsets.all(5),
                          // padding: const EdgeInsets.all(1),
                          child: Icon(
                            Icons.arrow_left,
                            color: MirrorflyUikit.getTheme?.textPrimaryColor,
                            size: 14,
                          )),
                      Text(AppConstants.you,
                          style: TextStyle(
                              fontWeight: FontWeight.bold,
                              fontSize: 15,
                              color:
                                  MirrorflyUikit.getTheme?.textPrimaryColor)),
                      const SizedBox(
                        width: 10,
                      ),
                    ],
                  ),
                ),
                getProfileImage(userProfile),
              ],
            );
          } else {
            return Row(
              // mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                getProfileImage(userProfile),
                const SizedBox(
                  width: 10,
                ),
                Expanded(
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      Flexible(
                        child: Text(
                          userProfile.isGroupProfile.checkNull()
                              ? chatList.senderNickName
                              : userProfile.name.checkNull(),
                          style: TextStyle(
                              fontWeight: FontWeight.bold,
                              fontSize: 15,
                              color:
                                  MirrorflyUikit.getTheme?.textPrimaryColor),
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                        ),
                      ),
                      Container(
                          decoration: BoxDecoration(
                            color: MirrorflyUikit.getTheme?.secondaryColor,
                            borderRadius:
                                const BorderRadius.all(Radius.circular(2)),
                          ),
                          margin: const EdgeInsets.all(5),
                          child: Icon(
                            Icons.arrow_right,
                            color: MirrorflyUikit.getTheme?.textPrimaryColor,
                            size: 14,
                          )),
                      userProfile.isGroupProfile.checkNull()
                          ? Flexible(
                              child: Text(
                                userProfile.name.checkNull(),
                                style: TextStyle(
                                    fontWeight: FontWeight.bold,
                                    color: MirrorflyUikit
                                        .getTheme?.textPrimaryColor,
                                    fontSize: 15),
                                maxLines: 1,
                                overflow: TextOverflow.ellipsis,
                              ),
                            )
                          : Text(AppConstants.you,
                              style: TextStyle(
                                  fontWeight: FontWeight.bold,
                                  fontSize: 15,
                                  color: MirrorflyUikit
                                      .getTheme?.textPrimaryColor)),
                      const SizedBox(
                        width: 10,
                      ),
                    ],
                  ),
                ),
                getChatTime(chatList.messageSentTime.toInt()),
              ],
            );
          }
        } else {
          return const SizedBox.shrink();
        }
      });
}