build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Implementation

@override
Widget build(BuildContext context) {
  return Theme(
    data: Theme.of(context)
        .copyWith(appBarTheme: AppStyleConfig.chatPageStyle.appBarTheme),
    child: Scaffold(
        appBar: !((controller.arguments?.disableAppBar).checkNull())
            ? getAppBar(context)
            : null,
        body: SafeArea(
          child: Container(
            width: NavUtils.width,
            height: NavUtils.height,
            decoration: AppStyleConfig
                    .chatPageStyle.chatPageBackgroundDecoration ??
                BoxDecoration(
                  image: DecorationImage(
                    image: AssetImage(chatBgIcon, package: iconPackageName),
                    fit: BoxFit.cover,
                  ),
                ),
            child: PopScope(
              canPop: false,
              onPopInvokedWithResult: (didPop, result) {
                if (didPop) {
                  return;
                }
                LogMessage.d("viewInsets",
                    "${NavUtils.defaultRouteName} : ${MediaQuery.of(context).viewInsets.bottom}");
                if (controller.showEmoji.value) {
                  controller.showEmoji(false);
                } else if (MediaQuery.of(context).viewInsets.bottom > 0.0) {
                  //FocusManager.instance.primaryFocus?.unfocus();
                  controller.focusNode.unfocus();
                } else if (!NavUtils.canPop) {
                  // controller.saveUnsentMessage();
                  NavUtils.offAllNamed(NavUtils.defaultRouteName);
                  // Navigator.pop(context);
                  // NavUtils.back();
                } else if (controller.isSelected.value) {
                  controller.clearAllChatSelection();
                } else {
                  NavUtils.back();
                }
              },
              child: Column(
                children: [
                  Obx(() {
                    return Visibility(
                        visible: controller.topic.value.topicName != null &&
                            (controller.arguments?.showTopicName).checkNull(),
                        child: Container(
                            width: NavUtils.width,
                            decoration: BoxDecoration(
                              color:
                                  controller.arguments?.topicTitleBgColor ??
                                      Theme.of(context).primaryColor,
                              borderRadius: const BorderRadius.only(
                                  bottomLeft: Radius.circular(8),
                                  bottomRight: Radius.circular(8)),
                            ),
                            padding: const EdgeInsets.all(2),
                            child: Text(
                              controller.topic.value.topicName.checkNull(),
                              textAlign: TextAlign.center,
                              style: controller.arguments?.topicTitleColor !=
                                      null
                                  ? TextStyle(
                                      color: controller
                                          .arguments?.topicTitleColor)
                                  : const TextStyle(color: Colors.black),
                            )));
                  }),
                  Expanded(
                      child: Stack(
                    children: [
                      Obx(() {
                        return controller.chatLoading.value
                            ? const Center(
                                child: CircularProgressIndicator(),
                              )
                            : LayoutBuilder(builder: (context, constraints) {
                                debugPrint(
                                    "list view constraints $constraints");
                                controller.screenWidth(constraints.maxWidth);
                                controller
                                    .screenHeight(constraints.maxHeight);
                                return ChatListView(
                                  chatController: controller,
                                  chatList: controller.chatList,
                                  senderChatStyle: AppStyleConfig
                                      .chatPageStyle.senderChatBubbleStyle,
                                  receiverChatStyle: AppStyleConfig
                                      .chatPageStyle.receiverChatBubbleStyle,
                                  chatSelectedColor: AppStyleConfig
                                      .chatPageStyle.chatSelectionBgColor,
                                  notificationMessageViewStyle: AppStyleConfig
                                      .chatPageStyle
                                      .notificationMessageViewStyle,
                                );
                              });
                      }),
                      // FloatingFab(
                      //   fabTheme: AppStyleConfig.chatPageStyle.instantScheduleMeetStyle.meetFabStyle,
                      //   parentWidgetWidth: controller.screenWidth,
                      //   parentWidgetHeight: controller.screenHeight,
                      //   onFabTap: (){
                      //     controller.showMeetBottomSheet(AppStyleConfig.chatPageStyle.instantScheduleMeetStyle.meetBottomSheetStyle);
                      //   },
                      // ),
                      Obx(() {
                        return Visibility(
                          visible: controller.showHideRedirectToLatest.value,
                          child: Positioned(
                            bottom: 20,
                            right: 0,
                            child: Row(
                              mainAxisSize: MainAxisSize.min,
                              children: [
                                controller.unreadCount.value != 0
                                    ? CircleAvatar(
                                        radius: 8,
                                        child: Text(
                                          returnFormattedCount(
                                              controller.unreadCount.value),
                                          style: const TextStyle(
                                              fontSize: 9,
                                              color: Colors.white),
                                        ),
                                      )
                                    : const SizedBox.shrink(),
                                IconButton(
                                  icon: AppUtils.assetIcon(
                                    assetName: redirectLastMessage,
                                    width: 32,
                                    height: 32,
                                  ),
                                  onPressed: () {
                                    //scroll to end
                                    controller.scrollToEnd();
                                  },
                                ),
                              ],
                            ),
                          ),
                        );
                      }),
                      if (Constants.enableContactSync) ...[
                        Obx(() {
                          return !controller.profile.isItSavedContact
                                  .checkNull()
                              ? Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    const SizedBox(
                                      width: 8,
                                    ),
                                    buttonNotSavedContact(
                                        text: getTranslated("add"),
                                        onClick: () {
                                          controller.saveContact();
                                        }),
                                    const SizedBox(
                                      width: 8,
                                    ),
                                    buttonNotSavedContact(
                                        text: controller.profile.isBlocked
                                                .checkNull()
                                            ? getTranslated("unblock")
                                            : getTranslated("block"),
                                        onClick: () {
                                          if (controller.profile.isBlocked
                                              .checkNull()) {
                                            controller.unBlockUser();
                                          } else {
                                            controller.blockUser();
                                          }
                                        }),
                                    const SizedBox(
                                      width: 8,
                                    ),
                                  ],
                                )
                              : const SizedBox.shrink();
                        })
                      ],
                    ],
                  )),
                  Align(
                    alignment: Alignment.bottomCenter,
                    child: Obx(() {
                      return Container(
                        color: AppStyleConfig.chatPageStyle
                            .messageTypingAreaStyle.bgColor, //Colors.white,
                        child: controller.isBlocked.value
                            ? userBlocked(context)
                            : controller.isChatClosed.value
                                ? chatClosed(context)
                                : controller.isMemberOfGroup
                                    ? Column(
                                        mainAxisAlignment:
                                            MainAxisAlignment.end,
                                        children: [
                                          Obx(() {
                                            if (controller.isReplying.value) {
                                              return ReplyingMessageHeader(
                                                chatMessage: controller
                                                    .replyChatMessage,
                                                onCancel: () => controller
                                                    .cancelReplyMessage(),
                                                onClick: () {
                                                  controller.navigateToMessage(
                                                      controller
                                                          .replyChatMessage);
                                                },
                                                replyBgColor: AppStyleConfig
                                                    .chatPageStyle
                                                    .messageTypingAreaStyle
                                                    .replyBgColor,
                                              );
                                            } else {
                                              return const Offstage();
                                            }
                                          }),
                                          Divider(
                                              height: 1,
                                              thickness: 0.29,
                                              color: AppStyleConfig
                                                  .chatPageStyle
                                                  .messageTypingAreaStyle
                                                  .dividerColor //textBlackColor,
                                              ),
                                          /*const SizedBox(
                                        height: 10,
                                      ),*/
                                          IntrinsicHeight(
                                            child: Row(
                                              crossAxisAlignment:
                                                  CrossAxisAlignment.stretch,
                                              children: [
                                                Flexible(
                                                  child: Container(
                                                    margin:
                                                        const EdgeInsets.all(
                                                            10),
                                                    width: double.infinity,
                                                    decoration: AppStyleConfig
                                                        .chatPageStyle
                                                        .messageTypingAreaStyle
                                                        .decoration,
                                                    // decoration: BoxDecoration(
                                                    //   border: Border.all(
                                                    //     color: textColor,
                                                    //   ),
                                                    //   borderRadius: const BorderRadius.all(Radius.circular(40)),
                                                    //   color: Colors.white,
                                                    // ),
                                                    child: Obx(() {
                                                      return messageTypingView(
                                                          context);
                                                    }),
                                                  ),
                                                ),
                                                Obx(() {
                                                  return controller
                                                              .isUserTyping
                                                              .value ||
                                                          controller
                                                                  .isAudioRecording
                                                                  .value ==
                                                              Constants
                                                                  .audioRecordDone
                                                      ? InkWell(
                                                          onTap: () {
                                                            controller.isAudioRecording
                                                                        .value ==
                                                                    Constants
                                                                        .audioRecordDone
                                                                ? controller
                                                                    .sendRecordedAudioMessage()
                                                                : controller.sendMessage(
                                                                    controller
                                                                        .profile);
                                                          },
                                                          child: AppUtils.svgIcon(
                                                              icon: sendIcon,
                                                              colorFilter: ColorFilter.mode(
                                                                  AppStyleConfig
                                                                      .chatPageStyle
                                                                      .messageTypingAreaStyle
                                                                      .sentIconColor,
                                                                  BlendMode
                                                                      .srcIn)))
                                                      : const Offstage();
                                                }),
                                                Obx(() {
                                                  return controller
                                                              .isAudioRecording
                                                              .value ==
                                                          Constants
                                                              .audioRecording
                                                      ? InkWell(
                                                          onTap: () {
                                                            controller
                                                                .stopRecording();
                                                          },
                                                          child: RippleWidget(
                                                            size: 50,
                                                            rippleColor: AppStyleConfig
                                                                .chatPageStyle
                                                                .messageTypingAreaStyle
                                                                .rippleColor,
                                                            child:
                                                                CircleAvatar(
                                                              backgroundColor: AppStyleConfig
                                                                  .chatPageStyle
                                                                  .messageTypingAreaStyle
                                                                  .audioRecordIcon
                                                                  .bgColor, //const Color(0xff3276E2),
                                                              radius: 48 / 2,
                                                              child: AppUtils
                                                                  .svgIcon(
                                                                icon:
                                                                    audioMic,
                                                                colorFilter: ColorFilter.mode(
                                                                    AppStyleConfig
                                                                        .chatPageStyle
                                                                        .messageTypingAreaStyle
                                                                        .audioRecordIcon
                                                                        .iconColor,
                                                                    BlendMode
                                                                        .srcIn),
                                                              ),
                                                            ),
                                                          ),
                                                          /*child: const Padding(
                                                        padding: EdgeInsets.only(bottom: 8.0),
                                                        child: LottieAnimation(
                                                          lottieJson: audioJson1,
                                                          showRepeat: true,
                                                          width: 54,
                                                          height: 54,
                                                        ),
                                                      )*/
                                                        )
                                                      : const Offstage();
                                                }),
                                                const SizedBox(
                                                  width: 5,
                                                ),
                                              ],
                                            ),
                                          ),
                                          controller.emojiLayout(
                                              textEditingController:
                                                  controller
                                                      .messageController,
                                              sendTypingStatus: true),
                                        ],
                                      )
                                    : !controller.availableFeatures.value
                                            .isGroupChatAvailable
                                            .checkNull()
                                        ? featureNotAvailable(context)
                                        : userNoLonger(context),
                      );
                    }),
                  ),
                ],
              ),
            ),
          ),
        )),
  );
}