showQuickProfilePopup function

void showQuickProfilePopup({
  1. required dynamic context,
  2. required dynamic chatTap(),
  3. dynamic callTap()?,
  4. dynamic videoTap()?,
  5. bool callEnable = false,
  6. required dynamic infoTap(),
  7. required Rx<ProfileDetails> profile,
  8. required Rx<AvailableFeatures> availableFeatures,
})

Implementation

void showQuickProfilePopup(
    {required context,
    required Function() chatTap,
    Function()? callTap,
    Function()? videoTap,
    bool callEnable = false,
    required Function() infoTap,
    required Rx<ProfileDetails> profile,
    required Rx<AvailableFeatures> availableFeatures}) {
  var isAudioCallAvailable =
      profile.value.isGroupProfile.checkNull() || !callEnable
          ? false
          : availableFeatures.value.isOneToOneCallAvailable.checkNull();
  var isVideoCallAvailable =
      profile.value.isGroupProfile.checkNull() || !callEnable
          ? false
          : availableFeatures.value.isOneToOneCallAvailable.checkNull();

  showDialog(
    context: context,
    builder: (BuildContext context) {
      return Obx(() {
        return Dialog(
          shape: const RoundedRectangleBorder(
              borderRadius: BorderRadius.all(Radius.circular(20.0))),
          child: SizedBox(
            width: MediaQuery.of(context).size.width * 0.7,
            height: 300,
            child: Column(
              children: [
                Expanded(
                  child: InkWell(
                    onTap: () {
                      mirrorFlyLog('image click', 'true');
                      // debugPrint(
                      //     "quick profile click--> ${profile.toJson().toString()}");
                      if (profile.value.image!.isNotEmpty &&
                          !(profile.value.isBlockedMe.checkNull() ||
                              profile.value.isAdminBlocked.checkNull()) &&
                          !( //!profile.value.isItSavedContact.checkNull() || //This is commented because Android side received as true and iOS side false
                              profile.value.isDeletedContact())) {
                        Navigator.pop(context);
                        Navigator.push(
                            context,
                            MaterialPageRoute(
                                builder: (con) => ImageViewView(
                                      imageName: getName(profile.value),
                                      imageUrl: profile.value.image,
                                    )));
                        /*Get.back();
                      Get.toNamed(Routes.imageView, arguments: {
                        'imageName': getName(profile.value),
                        'imageUrl': profile.value.image.checkNull()
                      });*/
                      }
                    },
                    child: Stack(
                      fit: StackFit.expand,
                      children: [
                        ClipRRect(
                            borderRadius: const BorderRadius.only(
                                topLeft: Radius.circular(20),
                                topRight: Radius.circular(20)),
                            child: ImageNetwork(
                              url: profile.value.image.toString(),
                              width: MediaQuery.of(context).size.width * 0.7,
                              height: 250,
                              clipOval: false,
                              errorWidget: profile.value.isGroupProfile!
                                  ? Image.asset(
                                      groupImg,
                                      package: package,
                                      height: 250,
                                      width: MediaQuery.of(context).size.width *
                                          0.72,
                                      fit: BoxFit.cover,
                                    )
                                  : ProfileTextImage(
                                      text: getName(profile.value),
                                      fontSize: 75,
                                      radius: 0,
                                    ),
                              isGroup: profile.value.isGroupProfile.checkNull(),
                              blocked: profile.value.isBlockedMe.checkNull() ||
                                  profile.value.isAdminBlocked.checkNull(),
                              unknown: (!profile.value.isItSavedContact
                                      .checkNull() ||
                                  profile.value.isDeletedContact()),
                            )),
                        Padding(
                          padding: const EdgeInsets.symmetric(
                              vertical: 10.0, horizontal: 20),
                          child: Text(
                            profile.value.isGroupProfile!
                                ? profile.value.name.checkNull()
                                : !Constants.enableContactSync
                                    ? profile.value.mobileNumber.checkNull()
                                    : profile.value.nickName.checkNull(),
                            style: const TextStyle(color: Colors.white),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
                SizedBox(
                  height: 50,
                  child: Row(
                    // mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Expanded(
                        child: InkWell(
                          onTap: chatTap,
                          child: SvgPicture.asset(
                            package: package,
                            quickMessage,
                            fit: BoxFit.contain,
                            width: 30,
                            height: 30,
                          ),
                        ),
                      ),
                      isAudioCallAvailable
                          ? Expanded(
                              child: InkWell(
                                onTap: () {
                                  Navigator.pop(context);
                                  makeVoiceCall(profile.value.jid.checkNull(),
                                      availableFeatures, context);
                                },
                                child: SvgPicture.asset(
                                  package: package,
                                  quickCall,
                                  fit: BoxFit.contain,
                                ),
                              ),
                            )
                          : const SizedBox.shrink(),
                      isVideoCallAvailable
                          ? Expanded(
                              child: InkWell(
                                onTap: () {
                                  Navigator.pop(context);
                                  makeVideoCall(profile.value.jid.checkNull(),
                                      availableFeatures, context);
                                },
                                child: SvgPicture.asset(
                                  package: package,
                                  quickVideo,
                                  fit: BoxFit.contain,
                                ),
                              ),
                            )
                          : const SizedBox.shrink(),
                      Expanded(
                        child: InkWell(
                          onTap: infoTap,
                          child: SvgPicture.asset(
                            package: package,
                            quickInfo,
                            fit: BoxFit.contain,
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        );
      });
    },
  );
}