buildListItem function
Implementation
Widget buildListItem(CallController controller) {
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: AppColors.callerTitleBackground,
profileSize: 50,
onClick: () {
//swap View
controller.swap(index);
},
).setBorderRadius(
const BorderRadius.all(Radius.circular(10))),
Obx(() {
return Positioned(
top: 0,
right: 8,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// SizedBox(
// width: 20,
// child: CircleAvatar(
// backgroundColor: AppColors.audioMutedIconBgColor,
// child: SvgPicture.asset(package: package,unpinUser),
// ),
// ),
if (controller
.callList[index].isAudioMuted.value) ...[
Padding(
padding: const EdgeInsets.only(left: 4.0),
child: SizedBox(
width: 20,
child: CircleAvatar(
backgroundColor:
AppColors.audioMutedIconBgColor,
child: SvgPicture.asset(
package: package, callMutedIcon),
),
),
),
],
AnimatedCrossFade(
firstCurve: Curves.fastOutSlowIn,
alignment: Alignment.center,
duration: const Duration(milliseconds: 300),
firstChild: Padding(
padding: const EdgeInsets.only(
top: 8.0, bottom: 8.0, left: 4.0),
child: SpeakingDots(
radius: 9,
audioLevel: controller.audioLevel(
controller
.callList[index].userJid!.value),
bgColor: AppColors.speakingBg,
),
),
secondChild: const SizedBox.shrink(),
crossFadeState:
(controller.speakingUsers.isNotEmpty &&
!controller.callList[index]
.isAudioMuted.value &&
!controller
.audioLevel(controller
.callList[index]
.userJid!
.value)
.isNegative)
? CrossFadeState.showFirst
: CrossFadeState.showSecond)
],
),
);
}),
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: 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: const TextStyle(color: Colors.white),
)),
)
: const SizedBox.shrink();
}),
/*Obx(() {
return controller.callList.isNotEmpty
? (getTileCallStatus(controller.callList[index + 1].callStatus?.value) != "" &&
controller.callList[index + 1].userJid != SessionManagement.getUserJID())
? Center(
child: Text(
getTileCallStatus(controller.callList[index + 1].callStatus?.value),
style: const TextStyle(color: Colors.white),
))
: const SizedBox.shrink()
: const SizedBox.shrink();
}),*/
],
))
: const SizedBox.shrink();
}),
);
}