prepareView method

Widget prepareView(
  1. EnxController obj,
  2. BuildContext context
)

Implementation

Widget prepareView(EnxController obj, BuildContext context) {
  final MediaQueryData mediaQueryData = MediaQuery.of(context);
  final double heightOfDevice = mediaQueryData.size.height;

  return Stack(
    alignment: Alignment.center,
    children: [
     obj.isAudience?obj.isHlsStarted.value?AspectRatio(
         aspectRatio: 3/2,
         child:VideoPlayer(obj.videoController!),
         )
     :Text(
       'Please wait, getting you connected...',
       style: TextStyle(color: Colors.white, fontSize: 16.sp),
     ): obj.activeTalkerList.isEmpty
          ? Text(
              'Wait for others to join',
              style: TextStyle(color: Colors.white, fontSize: 16.sp),
            )
          : Align(
              alignment: Alignment.center,
              child: obj.isScreenShareStarted
                  ? SizedBox(
                      width: MediaQuery.of(context).size.width,
                      height: MediaQuery.of(context).size.height / 2.5,
                      child: Platform.isAndroid
                          ? obj.isScreenShareStarted
                              ? EnxPlayerWidget(
                                  obj.screenShareStream.toInt(),
                                  local: false,
                                  mScalingType: ScalingType.SCALE_ASPECT_FIT,
                                  zMediaOverlay: false,
                                  width: MediaQuery.of(context).size.width.toInt(),
                                  height:
                                      MediaQuery.of(context).size.height ~/
                                          2.5,
                                )
                              : Container()
                          : AspectRatio(
                              aspectRatio: 3 / 2,
                              child: EnxPlayerWidget(
                                obj.screenShareStream,
                                local: false,
                                height:
                                    MediaQuery.of(context).size.height ~/ 2.5,
                                width:
                                    MediaQuery.of(context).size.width.toInt(),
                              )),
                    )
                  : SizedBox(
                      height: MediaQuery.of(context).size.height,
                      child: obj.isShowAnnotationView
                          ? Platform.isAndroid
                              ? SizedBox(
                                  height: MediaQuery.of(context).size.height,
                                  child: EnxPlayerWidget(
                                    obj.streamIdForAnnotation,
                                    local: false,
                                    zMediaOverlay: false,
                                    height: 300,
                                  ))
                              : AspectRatio(
                                  aspectRatio: 3 / 2,
                                  child: EnxPlayerWidget(
                                    obj.streamIdForAnnotation,
                                    local: false,
                                    height: MediaQuery.of(context)
                                        .size
                                        .height
                                        .toInt(),
                                    width: MediaQuery.of(context)
                                        .size
                                        .width
                                        .toInt(),
                                  ))
                          : obj.isGridView
                              ? MediaQuery.of(context).orientation ==
                                      Orientation.portrait
                                  ? Column(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceEvenly,
                                      children: renderStreamsGrid(
                                          obj,
                                          obj.activeTalkerList,
                                          MediaQuery.of(context),
                                          context))
                                  : Row(
                                      mainAxisAlignment:
                                          MainAxisAlignment.spaceEvenly,
                                      children: renderStreamsGrid(
                                          obj,
                                          obj.activeTalkerList,
                                          MediaQuery.of(context),
                                          context))
                              : viewFloat(context, obj),
                    ),
            ),
      Align(
          alignment: Alignment.bottomCenter,
          child: obj.isShowAnnotationView
              ? EnxToolbarWidget(width: 100, height: 50)
              : Container()),

      TranslationAnimatedWidget(
        enabled: obj.isShowHide, //will forward/reverse the animation
        curve: Curves.easeIn,
        duration: const Duration(seconds: 1),

        child:  Align(
          alignment: Alignment.bottomCenter,
          child: ConstrainedBox(

            constraints: BoxConstraints(
              maxHeight:
              MediaQuery.of(context).orientation == Orientation.portrait
                  ? MediaQuery.of(context).size.height / 1.58
                  : MediaQuery.of(context).size.height / 1.3,
              //maximum height set to 100% of vertical height

              //maximum width set to 100% of width
            ),
            child: SnappingSheet(
                grabbingHeight: MediaQuery.of(context).orientation==Orientation.portrait?110:100,
                lockOverflowDrag: true,
                onSheetMoved: (sheetPosition) {
                  if (kDebugMode) {
                    print("Current position ${sheetPosition.pixels}");
                  }
                },
                onSnapCompleted: (sheetPosition, snappingPosition) {
                  if (kDebugMode) {
                    print("compl position ${sheetPosition.pixels}");
                    print("compl snapping position ${snappingPosition}");
                  }
                  obj.positionCom.value = sheetPosition.pixels;
                },
                onSnapStart: (sheetPosition, snappingPosition) {
                  if (kDebugMode) {
                    print("Current position ${sheetPosition.pixels}");
                    print("Next snapping position $snappingPosition");
                  }
                },

                // TODO: Add your grabbing widget here,
                grabbing: Wrap(children: [
                  Center(
                    child: Container(
                      height: MediaQuery.of(context).orientation==Orientation.portrait?MediaQuery.of(context).size.height/22:MediaQuery.of(context).size.height/13,
                      width: MediaQuery.of(context).orientation==Orientation.portrait?MediaQuery.of(context).size.width:MediaQuery.of(context).size.height,
                      decoration: const BoxDecoration(
                          borderRadius: BorderRadius.only(topLeft: Radius.circular(15.0),topRight:Radius.circular(15.0)), color: Colors.white),
                      child: Center(
                          child: Icon(
                            obj.positionUpdate > 70
                                ? Icons.keyboard_arrow_down
                                : Icons.keyboard_arrow_up,
                            size: 40,
                            color: Colors.grey,
                          )),
                    ),
                  ),
                  Center(
                    child: EnxVideoButtons(
                      enxController: obj,
                    ),
                  ),
                ]),
                sheetBelow: SnappingSheetContent(
                  // TODO: Add your sheet content here
                  child: obj.isAudience?Container():Align(
                    alignment: Alignment.topCenter,
                    child: Container(
                        width: MediaQuery.of(context).orientation==Orientation.portrait?MediaQuery.of(context).size.width:MediaQuery.of(context).size.height,
                        color: Colors.white,
                        child: ParticipantScreenNew(obj, context)),
                  ),
                )),
          ),
        ),
      ),

      Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          // TranslationAnimatedWidget(
          //   enabled: obj.isShowHide,
          //   //will forward/reverse the animation
          //   curve: Curves.easeIn,
          //   duration: const Duration(seconds: 1),
          //   values: const [Offset(0, 0), Offset(0, -150)],
          //   child: Align(
          //       alignment: Alignment.topCenter,
          //       child: Padding(
          //         padding: const EdgeInsets.only(top: 5.0),
          //         child: CustomAppBar(
          //           appMode: obj.mode,
          //           role: obj.isRole,
          //           floorAction: obj.floorAction,
          //           moreCallbacks: (String map) {
          //             showMoreDialog(context, obj);
          //           },
          //
          //           raiseHandCallbacks: () {
          //             switch (obj.floorAction) {
          //               case 0:
          //                 if (obj.isRole) {
          //                   setupAlertDialogContainer(context, obj);
          //                 } else {
          //                   obj.requestFloors();
          //                 }
          //                 break;
          //               case 1:
          //                 var baseDialog = BaseAlertDialog(
          //                     title: "Cancel Floor",
          //                     content: "You want to cancel floor request",
          //                     yesOnPressed: () {
          //                       obj.cancelFloors();
          //                       obj.participantFloorAction.value = 0;
          //                       Get.back();
          //                     },
          //                     noOnPressed: () {
          //                       Get.back();
          //                     },
          //                     yes: "Yes",
          //                     no: "Cancel");
          //                 showDialog(
          //                     context: context,
          //                     builder: (BuildContext context) => baseDialog);
          //
          //                 break;
          //               case 2:
          //                 var baseDialog = BaseAlertDialog(
          //                     title: "Finish Floor",
          //                     content: "You want to finish floor request",
          //                     yesOnPressed: () {
          //                       obj.finishFloors();
          //                       obj.participantFloorAction.value = 0;
          //                       Get.back();
          //                     },
          //                     noOnPressed: () {
          //                       Get.back();
          //                     },
          //                     yes: "Finish",
          //                     no: "Cancel");
          //                 showDialog(
          //                     context: context,
          //                     builder: (BuildContext context) => baseDialog);
          //                 break;
          //             }
          //           },
          //         ),
          //       )),
          // ),
          Visibility(
            visible:  obj.isShowConnectedTime ,
            child: Align(
              alignment: Alignment.topLeft,
              child: Padding(
                padding: EdgeInsets.only(top: 5.h, right: 20.h),
                child:Container(
                  margin: EdgeInsets.only(left: 20.w,top: 20.w),
                  padding: EdgeInsets.all(8.w),
                  decoration: BoxDecoration(
                      color: Colors.white, borderRadius: BorderRadius.circular(15.w)),
                  child: Text(
                    obj.timerData(),
                    style: TextStyle(
                        fontWeight: FontWeight.bold,
                        color: Colors.black,
                        fontSize: 15.h),
                  ),
                ),
              ),
            ),
          ),
          Visibility(
            visible: obj.isRecord ? true : false,
            child: Align(
              alignment: Alignment.topCenter,
              child: Padding(
                padding: EdgeInsets.only(top: 5.h, right: 20.h),
                child: BlinkingPoint(
                  xCoor: 20.0, // The x coordinate of the point
                  yCoor: 20.0, // The y coordinate of the point
                  pointColor:
                      CustomColors.themeColor, // The color of the point
                  pointSize: 8.0.w, // The size of the point)
                ),
              ),
            ),
          ),
        ],
      ),
      obj.isAudience?Container(): Visibility(
        visible: !obj.isVideoMute,
        child: DraggableWidget(
            bottomMargin: 50.w,
            topMargin: 80.w,
            intialVisibility: true,
            horizontalSpace: 20.w,
            shadowBorderRadius: 10.w,
            initialPosition: AnchoringPosition.topRight,
            child: localView(100, 100,obj,context)),
      ),
    ],
  );
}