add video link to tiles

This commit is contained in:
2024-11-14 10:49:23 +02:00
parent 2050bc3f57
commit fe092fda31

View File

@@ -1,9 +1,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/main.dart'; import 'package:patient_manager/main.dart';
import 'package:patient_manager/mih_components/mih_layout/mih_window.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
class MIHTile extends StatefulWidget { class MIHTile extends StatefulWidget {
final String tileName; final String tileName;
//final String tileDescription; final String? videoYTLink;
final Widget tileIcon; final Widget tileIcon;
final void Function() onTap; final void Function() onTap;
// final Widget tileIcon; // final Widget tileIcon;
@@ -14,7 +17,7 @@ class MIHTile extends StatefulWidget {
super.key, super.key,
required this.onTap, required this.onTap,
required this.tileName, required this.tileName,
//required this.tileDescription, this.videoYTLink,
required this.tileIcon, required this.tileIcon,
required this.p, required this.p,
required this.s, required this.s,
@@ -27,9 +30,28 @@ class MIHTile extends StatefulWidget {
class _MIHTileState extends State<MIHTile> { class _MIHTileState extends State<MIHTile> {
late Color mainC; late Color mainC;
late Color secondC; late Color secondC;
late YoutubePlayerController videoController;
String getVideID() {
if (widget.videoYTLink != null) {
return YoutubePlayer.convertUrlToId(widget.videoYTLink!) as String;
} else {
return "";
}
}
// void listener() {
// if (_isPlayerReady && mounted && !videoController.value.isFullScreen) {
// setState(() {
// _playerState = videoController.value.playerState;
// _videoMetaData = videoController.metadata;
// });
// }
// }
@override @override
void dispose() { void dispose() {
videoController.dispose();
super.dispose(); super.dispose();
} }
@@ -37,65 +59,50 @@ class _MIHTileState extends State<MIHTile> {
void initState() { void initState() {
mainC = widget.p; mainC = widget.p;
secondC = widget.s; secondC = widget.s;
videoController = YoutubePlayerController(
initialVideoId: getVideID(),
flags: YoutubePlayerFlags(
autoPlay: false,
mute: true,
isLive: false,
));
super.initState(); super.initState();
} }
// Widget displayTile() { void displayHint() {
// return FittedBox( if (widget.videoYTLink != null) {
// child: Column( showDialog(
// mainAxisSize: MainAxisSize.min, context: context,
// mainAxisAlignment: MainAxisAlignment.end, builder: (context) {
// children: [ return MIHWindow(
// GestureDetector( fullscreen: false,
// onTap: widget.onTap, windowTitle: widget.tileName,
// onTapDown: (_) { windowTools: const [],
// setState(() { onWindowTapClose: () {
// mainC = MzanziInnovationHub.of(context)!.theme.primaryColor(); Navigator.pop(context);
// secondC = },
// MzanziInnovationHub.of(context)!.theme.secondaryColor(); windowBody: [
// }); YoutubePlayerBuilder(
// }, player: YoutubePlayer(
// onTapUp: (_) { controller: videoController,
// setState(() { showVideoProgressIndicator: true,
// mainC = MzanziInnovationHub.of(context)!.theme.secondaryColor(); progressIndicatorColor: Colors.amber,
// secondC = MzanziInnovationHub.of(context)!.theme.primaryColor(); progressColors: ProgressBarColors(
// }); playedColor: Colors.amber,
// }, handleColor: Colors.amberAccent,
// child: Container( ),
// padding: const EdgeInsets.all(3.0), ),
// decoration: BoxDecoration( builder: (context, player) {
// color: mainC, return player;
// borderRadius: BorderRadius.circular(10.0), },
// //border: Border.all(color: MzanziInnovationHub.of(context)!.theme.secondaryColor(), width: 1.0), ),
// ), ],
// child: Icon( );
// widget.tileIcon, },
// color: secondC, );
// ), }
// ), }
// ),
// const SizedBox(height: 1),
// Row(
// children: [
// Flexible(
// child: Text(
// widget.tileName,
// textAlign: TextAlign.center,
// softWrap: true,
// overflow: TextOverflow.visible,
// style: TextStyle(
// color: mainC,
// fontSize: 5.0,
// fontWeight: FontWeight.bold,
// ),
// ),
// ),
// ],
// )
// ],
// ),
// );
// }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -123,6 +130,9 @@ class _MIHTileState extends State<MIHTile> {
borderRadius: BorderRadius.circular(80), borderRadius: BorderRadius.circular(80),
// ho // ho
onTap: widget.onTap, onTap: widget.onTap,
onLongPress: () {
displayHint();
},
// hoverDuration: , // hoverDuration: ,
splashColor: splashColor:
MzanziInnovationHub.of(context)!.theme.highlightColor(), MzanziInnovationHub.of(context)!.theme.highlightColor(),