buildListItem function
Implementation
Widget buildListItem(CallController controller, CallUserTileStyle style) {
var callListLength = controller.callList.length;
debugPrint("callListLength --> $callListLength");
return SizedBox(
height: 135,
width: double.infinity,
child: ListView.builder(
padding: const EdgeInsets.symmetric(horizontal: 10),
scrollDirection: Axis.horizontal,
physics: const AlwaysScrollableScrollPhysics(),
itemCount: controller.callList.length,
reverse: controller.callList.length <= 2 ? true : false,
shrinkWrap: true,
itemBuilder: (context, index) {
debugPrint(
"ListBuilder ${controller.callList.length} userJid ${controller.callList[index].userJid} pinned ${controller.pinnedUserJid.value}");
return controller.callList[index].userJid!.value !=
controller.pinnedUserJid.value
? Container(
height: 135,
width: 100,
margin: const EdgeInsets.only(left: 10),
child: Stack(
children: [
MirrorFlyView(
key: UniqueKey(),
userJid:
controller.callList[index].userJid?.value ?? "",
viewBgColor: style
.backgroundColor, //AppColors.callerTitleBackground,
profileSize: style.profileImageSize,
onClick: () {
//swap View
controller.swap(index);
},
).setBorderRadius(style.borderRadius),
Obx(() {
return Positioned(
top: 8,
right: 8,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
if (controller
.callList[index].isAudioMuted.value) ...[
CircleAvatar(
radius: 10,
backgroundColor: style.muteActionStyle
.activeBgColor, //AppColors.audioMutedIconBgColor,
child: AppUtils.svgIcon(
icon: callMutedIcon,
colorFilter: ColorFilter.mode(
style.muteActionStyle.activeIconColor,
BlendMode.srcIn),
),
),
],
if (controller.speakingUsers.isNotEmpty &&
!controller
.callList[index].isAudioMuted.value &&
!controller
.audioLevel(controller
.callList[index].userJid!.value)
.isNegative) ...[
AudioLevelAnimation(
radius: 9,
audioLevel: controller.audioLevel(controller
.callList[index].userJid!.value),
bgColor: style.speakingIndicatorStyle
.activeBgColor, //AppColors.speakingBg,
dotsColor: style
.speakingIndicatorStyle.activeIconColor,
)
],
],
),
);
}),
Positioned(
left: 8,
bottom: 8,
right: 8,
child: Obx(() {
return FutureBuilder<String>(
future: CallUtils.getNameOfJid(controller
.callList[index].userJid!.value
.checkNull()),
builder: (context, snapshot) {
if (!snapshot.hasError &&
snapshot.data.checkNull().isNotEmpty) {
return Text(
snapshot.data.checkNull(),
style: style.nameTextStyle,
/*style: const TextStyle(
color: Colors.white,
fontSize: 14,
),*/
overflow: TextOverflow.ellipsis,
maxLines: 1,
);
}
return const SizedBox.shrink();
});
}),
),
Obx(() {
debugPrint(
"getUserJID ${controller.callList[index].userJid} ${controller.callList[index].callStatus} current user ${controller.callList[index].userJid!.value == SessionManagement.getUserJID()}");
return (getTileCallStatus(
controller
.callList[index].callStatus?.value,
controller.callList[index].userJid!.value
.checkNull(),
controller.isOneToOneCall)
.isNotEmpty)
? Container(
decoration: BoxDecoration(
color: Colors.black.withOpacity(
0.5), // Adjust the color and opacity as needed
borderRadius: BorderRadius.circular(10.0),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
blurRadius: 8,
offset: const Offset(0, 3),
),
],
),
width: 100,
height: 135,
child: Center(
child: Text(
getTileCallStatus(
controller
.callList[index].callStatus?.value,
controller.callList[index].userJid!.value
.checkNull(),
controller.isOneToOneCall),
style: style.callStatusTextStyle,
// style: const TextStyle(color: Colors.white),
)),
)
: const Offstage();
}),
],
))
: const Offstage();
}),
);
}