xLayout_Builder_VideoArea method

Widget xLayout_Builder_VideoArea(
  1. List? liVideo,
  2. XFDataItem? xclItem
)

Builder del Widget per la visualizzazione dei VIDEO sulla riga degli Items

Implementation

Widget xLayout_Builder_VideoArea(List<dynamic>? liVideo, XFDataItem? xclItem) {
  return Container(
      margin: EdgeInsets.only(bottom: 7),
      child: SingleChildScrollView(
          scrollDirection: Axis.horizontal,
          child: Row(
              children: liVideo!.where((element) => element.xDocID == xclItem!.id).map((element) {
            return GestureDetector(
                onTap: () async {
                  File x = await File.fromUri(Uri.parse(element.blobURL!));
                  VideoPlayerController? videoPlayerController = await VideoPlayerController.file(x);
                  bool _isPlaying = false;
                  Future<void> _playVideo() async => await videoPlayerController.play().then((value) => setState(() {}));
                  Future<void> _pauseVideo() async => await videoPlayerController.pause().then((value) => setState(() {}));

                  return showDialog(
                      context: context,
                      builder: (context) {
                        videoPlayerController
                          ..addListener(() {
                            final bool isPlaying = videoPlayerController.value.isPlaying;
                            if (isPlaying != _isPlaying) setState(() => _isPlaying = isPlaying);
                          })
                          ..initialize().then((_) => setState(() {}));
                        var i;
                        i = liVideo.firstWhereOrNull((element) => element.xDocID == element.id) != null;

                        return XAlertDialog(
                          content_insetPadding: EdgeInsets.all(0),
                          title_TextAlign: TextAlign.center,
                          title_Text: i != null ? "Video del Lavoro" : "Video del Dettaglio",
                          actionsBTNarea_Child: Row(children: [
                            Expanded(
                                child: XBtnbase(
                              label: "Pausa",
                              onPressed: () => _pauseVideo(),
                              label_Style: XStyles.xStyTextForLabel(textColor: Colors.yellow),
                            )),
                            Expanded(
                                child: XBtnbase(
                              label: "Play",
                              onPressed: () => _playVideo(),
                              label_Style: XStyles.xStyTextForLabel(textColor: Colors.green),
                            ))
                          ]),
                          child: Stack(children: [Container(width: MediaQuery.of(context).size.width - 10, child: VideoPlayer(videoPlayerController))]),
                        );
                      }).then((value) => videoPlayerController.dispose());
                },
                child: Container(
                  margin: EdgeInsets.symmetric(horizontal: 5),
                  decoration: BoxDecoration(color: Colors.grey[800], image: DecorationImage(image: MemoryImage(element.miniatura!))),
                  width: 100,
                  height: 100,
                  child: Container(child: Icon(Icons.play_arrow, size: 28)),
                ));
          }).toList())));
}