getBottomSheet method

void getBottomSheet(
  1. int num,
  2. BuildContext context
)

Implementation

void getBottomSheet(int num, BuildContext context) {
  controller.tabController.index = num;
  showModalBottomSheet(
    // backgroundColor: Colors.black,
    // title: "Settings",
    // titleStyle: TextStyle(
    //     color: Colors.white,
    //     fontWeight: FontWeight400),
    constraints: BoxConstraints(minWidth: MediaQuery.of(context).size.width),
    context: context,
    builder: (context) => Container(
        // height: 180,
        color: Colors.transparent,
        margin: Platform.isIOS
            ? EdgeInsets.zero
            : const EdgeInsets.only(left: 200, right: 200),
        height: 310,
        child: Container(
          padding: const EdgeInsets.all(5),
          decoration: BoxDecoration(
              borderRadius: const BorderRadius.only(
                  topLeft: Radius.circular(20),
                  topRight: Radius.circular(20)),
              color: textColor),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  const Text(
                    " Settings",
                    style: TextStyle(
                        color: Colors.white,
                        fontWeight: FontWeight.bold,
                        fontSize: 10),
                  ),
                  IconButton(
                      onPressed: () {
                        Navigator.pop(context);
                      },
                      icon: const Icon(
                        Icons.close,
                        // color: Colors.white,
                      ))
                ],
              ),
              const SizedBox(
                height: 2,
              ),
              TabBar(
                labelColor: primaryColor,
                unselectedLabelColor: Colors.white,
                labelStyle:
                    const TextStyle(fontWeight: FontWeight.w600, fontSize: 8),
                indicatorColor: Colors.white,
                indicator: const BoxDecoration(
                    image: DecorationImage(
                        alignment: Alignment.bottomCenter,
                        image: AssetImage("assets/icons/indicator.png"))),
                indicatorSize: TabBarIndicatorSize.tab,
                padding: EdgeInsets.zero,
                tabs: [
                  Tab(
                    text: "Quality".tr,
                  ),
                  Tab(
                    text: "Playback Speed".tr,
                  ),
                  // Tab(
                  //   text: "Subtitle",
                  // ),
                ],
                controller: controller.tabController,
              ),
              SizedBox(
                  height: 150,
                  child: TabBarView(
                      controller: controller.tabController,
                      children: [
                        SingleChildScrollView(
                          child: Obx(
                            () => Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              // children: [
                              //   RadioListTile(
                              //       // onPressed: () {},
                              //       controlAffinity:
                              //           ListTileControlAffinity.leading,
                              //       groupValue:
                              //           controller.qualityGroupValue.value,
                              //       onChanged: (val) {
                              //         controller.qualityGroupValue.value =
                              //             val!;
                              //       },
                              //       activeColor: primaryColor,
                              //       value: "Full HD upto 1080p",
                              //       title: Text.rich(
                              //         TextSpan(text: "Full HD ", children: [
                              //           TextSpan(
                              //               text: "upto 1080p",
                              //               style: kTextStylePoppinsMedium
                              //                   .copyWith(
                              //                 fontWeight: FontWeight300,
                              //                 color: controller
                              //                             .qualityGroupValue
                              //                             .value ==
                              //                         "Full HD upto 1080p"
                              //                     ? primaryColor
                              //                         ithOpacity(0.5)
                              //                     : Colors.black
                              //                         ithOpacity(0.5),
                              //               ))
                              //         ]),
                              //         style:
                              //             kTextStylePoppinsRegular.copyWith(
                              //                 color: controller
                              //                             .qualityGroupValue
                              //                             .value ==
                              //                         "Full HD upto 1080p"
                              //                     ? primaryColor
                              //                     : Colors.black,
                              //                 fontWeight: FontWeight600),
                              //       )),
                              //   RadioListTile(
                              //       // onPressed: () {},
                              //       controlAffinity:
                              //           ListTileControlAffinity.leading,
                              //       groupValue:
                              //           controller.qualityGroupValue.value,
                              //       onChanged: (val) {
                              //         controller.qualityGroupValue.value =
                              //             val!;
                              //       },
                              //       activeColor: primaryColor,
                              //       value: "HD upto 1080p",
                              //       title: Text.rich(
                              //         TextSpan(text: "HD ", children: [
                              //           TextSpan(
                              //               text: "upto 720p",
                              //               style: kTextStylePoppinsMedium
                              //                   .copyWith(
                              //                 fontWeight: FontWeight300,
                              //                 color: controller
                              //                             .qualityGroupValue
                              //                             .value ==
                              //                         "HD upto 720p"
                              //                     ? primaryColor
                              //                         ithOpacity(0.5)
                              //                     : Colors.black
                              //                         ithOpacity(0.5),
                              //               ))
                              //         ]),
                              //         style:
                              //             kTextStylePoppinsRegular.copyWith(
                              //                 color: controller
                              //                             .qualityGroupValue
                              //                             .value ==
                              //                         "HD upto 720p"
                              //                     ? primaryColor
                              //                     : Colors.black,
                              //                 fontWeight: FontWeight600),
                              //       )),
                              //   RadioListTile(
                              //       // onPressed: () {},
                              //       controlAffinity:
                              //           ListTileControlAffinity.leading,
                              //       groupValue:
                              //           controller.qualityGroupValue.value,
                              //       onChanged: (val) {
                              //         controller.qualityGroupValue.value =
                              //             val!;
                              //       },
                              //       activeColor: primaryColor,
                              //       value: "SD upto 480p",
                              //       title: Text.rich(
                              //         TextSpan(text: "SD ", children: [
                              //           TextSpan(
                              //               text: "upto 480p",
                              //               style: kTextStylePoppinsMedium
                              //                   .copyWith(
                              //                 fontWeight: FontWeight300,
                              //                 color: controller
                              //                             .qualityGroupValue
                              //                             .value ==
                              //                         "SD upto 480p"
                              //                     ? primaryColor
                              //                         ithOpacity(0.5)
                              //                     : Colors.black
                              //                         ithOpacity(0.5),
                              //               ))
                              //         ]),
                              //         style:
                              //             kTextStylePoppinsRegular.copyWith(
                              //                 color: controller
                              //                             .qualityGroupValue
                              //                             .value ==
                              //                         "SD upto 480p"
                              //                     ? primaryColor
                              //                     : Colors.black,
                              //                 fontWeight: FontWeight600),
                              //       )),
                              //   RadioListTile(
                              //       // onPressed: () {},
                              //       controlAffinity:
                              //           ListTileControlAffinity.leading,
                              //       groupValue:
                              //           controller.qualityGroupValue.value,
                              //       onChanged: (val) {
                              //         controller.qualityGroupValue.value =
                              //             val!;
                              //       },
                              //       activeColor: primaryColor,
                              //       value: "Low Data Saver",
                              //       title: Text.rich(
                              //         TextSpan(text: "Low ", children: [
                              //           TextSpan(
                              //               text: "Data Saver",
                              //               style: kTextStylePoppinsMedium
                              //                   .copyWith(
                              //                 fontWeight: FontWeight300,
                              //                 color: controller
                              //                             .qualityGroupValue
                              //                             .value ==
                              //                         "Low Data Saver"
                              //                     ? primaryColor
                              //                         ithOpacity(0.5)
                              //                     : Colors.black
                              //                         ithOpacity(0.5),
                              //               ))
                              //         ]),
                              //         style:
                              //             kTextStylePoppinsRegular.copyWith(
                              //                 color: controller
                              //                             .qualityGroupValue
                              //                             .value ==
                              //                         "Low Data Saver"
                              //                     ? primaryColor
                              //                     : Colors.black,
                              //                 fontWeight: FontWeight600),
                              //       )),
                              //   SizedBox(
                              //     height: 20,
                              //   )
                              // ],
                              children: controller.qualities.map((element) {
                                var quality = element.qualityLabel == "144p"
                                    ? "Low "
                                    : element.qualityLabel == "240p"
                                        ? "Low "
                                        : element.qualityLabel == "360p"
                                            ? "SD "
                                            : element.qualityLabel == "480p"
                                                ? "SD "
                                                : element.qualityLabel ==
                                                        "720p"
                                                    ? "HD "
                                                    : "Full HD ";
                                quality += "upto ${element.qualityLabel}";
                                return RadioListTile(
                                    // onPressed: () {},
                                    controlAffinity:
                                        ListTileControlAffinity.leading,
                                    groupValue:
                                        controller.qualityGroupValue.value,
                                    onChanged: (val) {
                                      controller.controller.pause();
                                      controller.qualityGroupValue.value =
                                          val!;
                                      Duration position = controller
                                          .controller.value.position;
                                      controller.isPlaying.value = false;
                                      controller.isInitialized.value = false;
                                      controller.controller =
                                          VideoPlayerController.contentUri(
                                              element.url,
                                              videoPlayerOptions:
                                                  VideoPlayerOptions())
                                            ..initialize().then((value) {
                                              controller.controller
                                                  .seekTo(position);
                                              controller.isInitialized.value =
                                                  true;
                                              controller.controller.play();
                                              controller.isPlaying.value =
                                                  true;
                                            });
                                      controller.controller.addListener(() {
                                        controller.position.value = controller
                                            .controller.value.position;
                                        controller.sliderVal.value =
                                            controller.position.value
                                                    .inSeconds /
                                                controller
                                                    .duration.value.inSeconds;
                                      });
                                    },
                                    visualDensity: const VisualDensity(
                                        vertical:
                                            VisualDensity.minimumDensity,
                                        horizontal:
                                            VisualDensity.minimumDensity),
                                    activeColor: primaryColor,
                                    value: quality,
                                    title: Text.rich(
                                      TextSpan(
                                          text: element.qualityLabel == "144p"
                                              ? "Low "
                                              : element.qualityLabel == "240p"
                                                  ? "Low "
                                                  : element.qualityLabel ==
                                                          "360p"
                                                      ? "SD "
                                                      : element.qualityLabel ==
                                                              "480p"
                                                          ? "SD "
                                                          : element.qualityLabel ==
                                                                  "720p"
                                                              ? "HD "
                                                              : "Full HD ",
                                          style: const TextStyle(
                                            fontWeight: FontWeight.w600,
                                            fontSize: 8,
                                          ),
                                          children: [
                                            TextSpan(
                                                text:
                                                    "upto ${element.qualityLabel}",
                                                style: const TextStyle()
                                                    .copyWith(
                                                  fontWeight: FontWeight.w300,
                                                  fontSize: 9,
                                                  color: controller
                                                              .qualityGroupValue
                                                              .value ==
                                                          quality
                                                      ? primaryColor!
                                                          .withOpacity(0.5)
                                                      : Colors.black
                                                          .withOpacity(0.5),
                                                ))
                                          ]),
                                      style: const TextStyle().copyWith(
                                          color: controller.qualityGroupValue
                                                      .value ==
                                                  quality
                                              ? primaryColor
                                              : Colors.black,
                                          fontSize: 10,
                                          fontWeight: FontWeight.w600),
                                    ));
                              }).toList(),
                            ),
                          ),
                        ),
                        Obx(
                          () => SingleChildScrollView(
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                RadioListTile(
                                  onChanged: (val) {
                                    controller.playback.value = 4;
                                    controller.controller.setPlaybackSpeed(1);
                                  },
                                  groupValue: controller.playback.value,
                                  value: 4,
                                  activeColor: primaryColor,
                                  title: Text("Normal",
                                      style: TextStyle(
                                          color:
                                              controller.playback.value == 4
                                                  ? primaryColor
                                                  : Colors.black)),
                                ),
                                RadioListTile(
                                  onChanged: (val) {
                                    controller.controller
                                        .setPlaybackSpeed(0.25);
                                    controller.playback.value = val!;
                                  },
                                  value: 1,
                                  groupValue: controller.playback.value,
                                  title: Text("0.25x",
                                      style: TextStyle(
                                          color:
                                              controller.playback.value == 1
                                                  ? primaryColor
                                                  : Colors.black)),
                                ),
                                RadioListTile(
                                  onChanged: (val) {
                                    controller.playback.value = val!;
                                    controller.controller
                                        .setPlaybackSpeed(0.5);
                                  },
                                  activeColor: primaryColor,
                                  value: 2,
                                  groupValue: controller.playback.value,
                                  title: Text("0.5x",
                                      style: TextStyle(
                                          color:
                                              controller.playback.value == 2
                                                  ? primaryColor
                                                  : Colors.black)),
                                ),
                                RadioListTile(
                                  onChanged: (val) {
                                    controller.playback.value = 3;
                                    controller.controller
                                        .setPlaybackSpeed(0.75);
                                  },
                                  groupValue: controller.playback.value,
                                  value: 3,
                                  controlAffinity:
                                      ListTileControlAffinity.leading,
                                  activeColor: primaryColor,
                                  title: Text("0.75x",
                                      style: TextStyle(
                                          color:
                                              controller.playback.value == 3
                                                  ? primaryColor
                                                  : Colors.black)),
                                ),
                                RadioListTile(
                                  onChanged: (val) {
                                    controller.controller
                                        .setPlaybackSpeed(1.25);
                                    controller.playback.value = 5;
                                  },
                                  groupValue: controller.playback.value,
                                  value: 5,
                                  activeColor: primaryColor,
                                  title: Text("1.25x",
                                      style: TextStyle(
                                          color:
                                              controller.playback.value == 5
                                                  ? primaryColor
                                                  : Colors.black)),
                                ),
                                RadioListTile(
                                  onChanged: (val) {
                                    controller.playback.value = 6;
                                    controller.controller
                                        .setPlaybackSpeed(1.5);
                                  },
                                  groupValue: controller.playback.value,
                                  value: 6,
                                  activeColor: primaryColor,
                                  title: Text("1.5x",
                                      style: TextStyle(
                                          color:
                                              controller.playback.value == 6
                                                  ? primaryColor
                                                  : Colors.black)),
                                ),
                                RadioListTile(
                                  onChanged: (val) {
                                    controller.playback.value = 7;
                                    controller.controller
                                        .setPlaybackSpeed(1.75);
                                  },
                                  groupValue: controller.playback.value,
                                  value: 7,
                                  activeColor: primaryColor,
                                  title: Text("1.75x",
                                      style: TextStyle(
                                          color:
                                              controller.playback.value == 7
                                                  ? primaryColor
                                                  : Colors.black)),
                                ),
                                RadioListTile(
                                  onChanged: (val) {
                                    controller.playback.value = 8;
                                    controller.controller.setPlaybackSpeed(2);
                                  },
                                  groupValue: controller.playback.value,
                                  value: 8,
                                  activeColor: primaryColor,
                                  title: Text("2x",
                                      style: TextStyle(
                                          color:
                                              controller.playback.value == 8
                                                  ? primaryColor
                                                  : Colors.black)),
                                ),
                                const SizedBox(
                                  height: 20,
                                )
                              ],
                            ),
                          ),
                        ),
                      ])),
            ],
          ),
        )),
    isScrollControlled: true,
  );
}