Chat Call Widget with Unread Message Indicator

mail@pastecode.io avatar
unknown
dart
a month ago
1.4 kB
1
Indexable
Never
Widget chatCallWidget(IconData icon, {UserData? data}) {
  if(data!=null && data.uid!=null){
    return Stack(
      children: [
        Container(
          padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
          decoration: BoxDecoration(border: Border.all(color: dividerColor), color: appStore.isDarkMode ? scaffoldColorDark : scaffoldColorLight, borderRadius: BorderRadius.circular(defaultRadius)),
          child: Icon(icon, size: 18, color: primaryColor),
        ),
        StreamBuilder<int>(
            stream: chatMessageService.getUnReadCount(receiverId: "${data!.uid}",senderId: "${sharedPref.getString(UID)}"),
            builder: (context, snapshot) {
              if(snapshot.hasData && snapshot.data!=null && snapshot.data!>0){
                return Positioned(
                    top: -2,
                    right: 0,
                    child:Lottie.asset(messageDetect, width: 18, height: 18, fit: BoxFit.cover));
              }
              return SizedBox();
            }
        )
      ],
    );
  }else{
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
      decoration: BoxDecoration(border: Border.all(color: dividerColor), color: appStore.isDarkMode ? scaffoldColorDark : scaffoldColorLight, borderRadius: BorderRadius.circular(defaultRadius)),
      child: Icon(icon, size: 18, color: primaryColor),
    );
  }
}
Leave a Comment