Support map, video and quiz

This commit is contained in:
Thomas Fransolet 2023-01-26 17:08:26 +01:00
parent fbaf6d4b8c
commit 47056aec7c
10 changed files with 154 additions and 118 deletions

View File

@ -46,7 +46,6 @@ class _MainViewWidget extends State<MainViewWidget> {
if(sectionSelected != null) {
var elementToShow;
print(sectionSelected!.type);
switch (sectionSelected!.type) {
case SectionType.map : // MAP
elementToShow = ChangeNotifierProvider<MapContext>(
@ -282,9 +281,6 @@ class _MainViewWidget extends State<MainViewWidget> {
try {
List<SectionDTO>? sections = await tabletAppContext.clientAPI!.sectionApi!.sectionGetFromConfiguration(tabletAppContext.configuration!.id!);
sections!.sort((a, b) => a.order!.compareTo(b.order!));
print("Sections");
print(sections);
return sections;
} catch (e) {
print(e);

View File

@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:typed_data';
import 'package:enum_to_string/enum_to_string.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:manager_api/api.dart';
@ -53,7 +54,7 @@ class _GoogleMapViewState extends State<GoogleMapView> {
double.tryParse(element.latitude!)!,
double.tryParse(element.longitude!)!,
),
icon: BitmapDescriptor.fromBytes(widget.selectedMarkerIcon!),
icon: widget.selectedMarkerIcon != null ? BitmapDescriptor.fromBytes(widget.selectedMarkerIcon!) : BitmapDescriptor.defaultMarker,
/*icon: BitmapDescriptor.defaultMarkerWithHue(
BitmapDescriptor.hueYellow,
),*/
@ -69,10 +70,9 @@ class _GoogleMapViewState extends State<GoogleMapView> {
));
//});
},
infoWindow: InfoWindow(title: element.title)));
infoWindow: kIsWeb ? InfoWindow.noText : InfoWindow(title: element.title)));
}
});
return markers;
}
@ -90,17 +90,21 @@ class _GoogleMapViewState extends State<GoogleMapView> {
@override
Widget build(BuildContext context) {
final mapContext = Provider.of<MapContext>(context);
Size size = MediaQuery.of(context).size;
//Size size = MediaQuery.of(context).size;
return GoogleMap(
mapType: widget.mapDTO!.mapType != null ? EnumToString.fromString(MapType.values, widget.mapDTO!.mapType.toString())!: MapType.hybrid,
mapToolbarEnabled: false,
initialCameraPosition: CameraPosition(
target: LatLng(50.416639, 4.879169),
target: LatLng(50.465503, 4.865105), // MDLF 50.416639, 4.879169 / Namur 50.465503, 4.865105
zoom: widget.mapDTO!.zoom != null ? widget.mapDTO!.zoom!.toDouble() : 18,
),
onMapCreated: (GoogleMapController controller) {
if(kIsWeb) {
//_controllerWeb.complete(controller);
} else {
_controller.complete(controller);
}
},
markers: getMarkers(widget.language, mapContext),
onTap: (LatLng location) {

View File

@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
@ -11,9 +12,11 @@ import 'package:tablet_app/Models/map-marker.dart';
import 'dart:ui' as ui;
import 'package:flutter/widgets.dart';
import 'package:tablet_app/Screens/Map/marker_view.dart';
import 'package:http/http.dart' as http;
import '../../app_context.dart';
import 'google_map_view.dart';
import 'package:image/image.dart' as IMG;
Set<Marker> markers = {};
List<MapMarker> markersList = [];
@ -28,7 +31,7 @@ class MapViewWidget extends StatefulWidget {
class _MapViewWidget extends State<MapViewWidget> {
MapDTO? mapDTO;
Completer<GoogleMapController> _controller = Completer();
//Completer<GoogleMapController> _controller = Completer();
Uint8List? selectedMarkerIcon;
Future<Uint8List> getBytesFromAsset(ByteData data, int width) async {
@ -43,10 +46,7 @@ class _MapViewWidget extends State<MapViewWidget> {
@override
void initState() {
print(widget.section!.data);
mapDTO = MapDTO.fromJson(jsonDecode(widget.section!.data!));
print(mapDTO);
super.initState();
}
@ -69,9 +69,12 @@ class _MapViewWidget extends State<MapViewWidget> {
return Stack(
children: <Widget>[
FutureBuilder(
future: getByteIcon(mapDTO!.iconSource!),
future: getByteIcon(mapDTO!.iconSource),
builder: (context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
print("snapshot");
print(snapshot.data);
print(selectedMarkerIcon);
return GoogleMapView(language: appContext.getContext().language, mapDTO: mapDTO!, selectedMarkerIcon: selectedMarkerIcon);
} else if (snapshot.connectionState == ConnectionState.none) {
return Text("No data");
@ -94,10 +97,25 @@ class _MapViewWidget extends State<MapViewWidget> {
);
}
getByteIcon(String source) async {
getByteIcon(String? source) async {
if(source != null) {
if(kIsWeb) {
Uint8List fileData = await http.readBytes(Uri.parse(source));
selectedMarkerIcon = resizeImage(fileData, 40);
} else {
final ByteData imageData = await NetworkAssetBundle(Uri.parse(source)).load("");
selectedMarkerIcon = await getBytesFromAsset(imageData, 50);
}
}
}
Uint8List resizeImage(Uint8List data, int width) {
Uint8List resizedData = data;
IMG.Image img = IMG.decodeImage(data)!;
IMG.Image resized = IMG.copyResize(img, width: width);
resizedData = Uint8List.fromList(IMG.encodeJpg(resized));
return resizedData;
}
/*Future<void> _goToTheLake() async {
final GoogleMapController controller = await _controller.future;

View File

@ -1,4 +1,5 @@
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
import 'package:provider/provider.dart';
@ -98,7 +99,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
alignment: Alignment.topCenter,
child: Padding(
padding: const EdgeInsets.only(top: 20),
child: Text(mapContext.getSelectedMarker().title, style: TextStyle(fontWeight: FontWeight.w600, fontSize: kTitleSize)),
child: Text(mapContext.getSelectedMarker().title, style: TextStyle(fontWeight: FontWeight.w600, fontSize: kIsWeb ? kWebTitleSize : kTitleSize)),
),
),
Padding(
@ -152,7 +153,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
child: AspectRatio(
aspectRatio: 16 / 9,
child: ClipRect(
child: PhotoView(
child: i.imageSource != null ? PhotoView(
imageProvider: new NetworkImage(
i.imageSource,
),
@ -163,7 +164,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(15.0),
),
),
) : Center(child: Text('No data')),
),
)
),
@ -192,7 +193,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Text(mapContext.getSelectedMarker().description, textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize)),
child: Text(mapContext.getSelectedMarker().description, textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? kWebDescriptionSize : kDescriptionSize)),
),
),
),
@ -209,7 +210,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
},
child: Icon(
Icons.chevron_right,
size: 150,
size: kIsWeb ? 100 : 150,
color: kMainRed,
),
)
@ -225,7 +226,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
},
child: Icon(
Icons.chevron_left,
size: 150,
size: kIsWeb ? 100 : 150,
color: kMainRed,
),
)

View File

@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:developer';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:confetti/confetti.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:manager_api/api.dart';
@ -113,8 +114,8 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
//height: size.height * 0.2,
//width: size.width * 0.25,
constraints: BoxConstraints(
maxHeight: size.height * 0.25,
maxWidth: size.width * 0.25,
maxHeight: kIsWeb ? size.height * 0.20 : size.height * 0.25,
maxWidth: kIsWeb ? size.width * 0.20 : size.width * 0.25,
),
alignment: Alignment.center,
decoration: BoxDecoration(
@ -150,14 +151,14 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
),
),
Container(
child: Text('$goodResponses/${quizzDTO.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: 150, color: kBackgroundSecondGrey)),
child: Text('$goodResponses/${quizzDTO.questions!.length}', textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? (showResponses ? 60 : 100) : 150, color: kBackgroundSecondGrey)),
),
Container(
child: Padding(
padding: const EdgeInsets.only(bottom: 10),
child: Container(
width: MediaQuery.of(context).size.width *0.75,
height: MediaQuery.of(context).size.height *0.25,
height: kIsWeb ? (showResponses ? MediaQuery.of(context).size.height *0.10 : MediaQuery.of(context).size.height *0.20) : MediaQuery.of(context).size.height *0.25,
decoration: BoxDecoration(
color: kBackgroundLight,
shape: BoxShape.rectangle,
@ -177,7 +178,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: levelToShow != null ? Text(levelToShow.label.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? levelToShow.label.firstWhere((translation) => translation.language == appContext.getContext().language).value : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize)): Text("No data"),
child: levelToShow != null ? Text(levelToShow.label.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? levelToShow.label.firstWhere((translation) => translation.language == appContext.getContext().language).value : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? kWebDescriptionSize : kDescriptionSize)): Text("No data"),
),
),
),
@ -187,9 +188,8 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
),
if(showResponses)
Container(
child: Container(
width: MediaQuery.of(context).size.width *0.75,
height: MediaQuery.of(context).size.height *0.35,
height: kIsWeb ? MediaQuery.of(context).size.height *0.35 : MediaQuery.of(context).size.height *0.35,
decoration: BoxDecoration(
color: kBackgroundLight,
shape: BoxShape.rectangle,
@ -210,7 +210,6 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
),
),
),
),
// Buttons
Container(
child: Row(
@ -218,7 +217,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
height: 85,
height: kIsWeb ? 50 : 85,
child: RoundedButton(
text: "Recommencer",
color: kBackgroundSecondGrey,
@ -232,14 +231,14 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
_questionsSubDTO = QuestionSubDTO().fromJSON(quizzDTO.questions!);
});
},
fontSize: 30,
fontSize: kIsWeb ? kWebDescriptionSize : 30,
horizontal: 30,
vertical: 10
),
),
if(!showResponses)
Container(
height: 85,
height: kIsWeb ? 50 : 85,
child: RoundedButton(
text: "Voir les réponses",
color: kBackgroundSecondGrey,
@ -250,7 +249,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
showResponses = true;
});
},
fontSize: 30,
fontSize: kIsWeb ? kWebDescriptionSize : 30,
horizontal: 30,
vertical: 10
),
@ -343,7 +342,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Text(i.label!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.label!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize)),
child: Text(i.label!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.label!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? kWebDescriptionSize : kDescriptionSize)),
),
),
),
@ -368,9 +367,9 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisExtent: 150,
mainAxisSpacing: 150,
crossAxisSpacing: 150,
mainAxisExtent: kIsWeb ? 75 : 150, // TODO depends on percentage
mainAxisSpacing: kIsWeb ? 75 : 150, // TODO depends on percentage
crossAxisSpacing: kIsWeb ? 75 : 150, // TODO depends on percentage
),
itemCount: i.responsesSubDTO!.length,
itemBuilder: (BuildContext ctx, index) {
@ -381,7 +380,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
if(currentIndex == _questionsSubDTO.length && i.chosen == index)
{
showResult = true;
_controllerCenter!.play();
_controllerCenter!.play(); // TODO Maybe show only confetti on super score ..
} else {
sliderController!.nextPage(duration: new Duration(milliseconds: 650), curve: Curves.fastOutSlowIn);
}
@ -391,7 +390,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
padding: const EdgeInsets.all(8.0),
child: Container(
alignment: Alignment.center,
child: Text(i.responsesSubDTO![index].label!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.responsesSubDTO![index].label!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize, color: i.chosen == index ? Colors.white : Colors.black)),
child: Text(i.responsesSubDTO![index].label!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.responsesSubDTO![index].label!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? kWebDescriptionSize : kDescriptionSize, color: i.chosen == index ? Colors.white : Colors.black)),
decoration: BoxDecoration(
color: i.chosen == index ? kTestSecondColor : kBackgroundLight,
shape: BoxShape.rectangle,
@ -444,7 +443,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
},
child: Icon(
Icons.chevron_right,
size: 150,
size: kIsWeb ? 100 : 150,
color: kMainRed,
),
)
@ -460,7 +459,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
},
child: Icon(
Icons.chevron_left,
size: 150,
size: kIsWeb ? 100 : 150,
color: kMainRed,
),
)

View File

@ -1,6 +1,7 @@
import 'dart:convert';
import 'dart:developer';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:manager_api/api.dart';
@ -42,7 +43,7 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
Widget build(BuildContext context) {
Size sizeAll = MediaQuery.of(context).size;
Size size = Size(sizeAll.width * 0.65, sizeAll.height * 0.32);
Size size = Size(sizeAll.width * 0.65, kIsWeb ? sizeAll.height * 0.5 : sizeAll.height * 0.32);
final appContext = Provider.of<AppContext>(context);
return Stack(
@ -98,7 +99,8 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
padding: const EdgeInsets.all(10.0),
child: Container(
//width: MediaQuery.of(context).size.width *0.65,
height: size.height *0.25,
//color: Colors.pink,
height: kIsWeb ? size.height *0.25 : size.height *0.25,
child: Stack(
children: [
Center(
@ -122,7 +124,7 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(1.0),
child: Text(i.label!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.label!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize)),
child: Text(i.label!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.label!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? kWebDescriptionSize : kDescriptionSize)),
),
),
),
@ -144,8 +146,8 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisExtent: 125,
mainAxisSpacing: 15,
mainAxisExtent: kIsWeb ? 65 : 125, // TODO depends on percentage
mainAxisSpacing: kIsWeb ? 10: 15, // TODO depends on percentage
crossAxisSpacing: 5,
),
itemCount: i.responsesSubDTO!.length,
@ -154,7 +156,7 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
padding: const EdgeInsets.all(5.0),
child: Container(
alignment: Alignment.center,
child: Text(i.responsesSubDTO![index].label!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.responsesSubDTO![index].label!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize, color: i.chosen == index ? Colors.white : Colors.black)),
child: Text(i.responsesSubDTO![index].label!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.responsesSubDTO![index].label!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? kWebDescriptionSize : kDescriptionSize, color: i.chosen == index ? Colors.white : Colors.black)),
decoration: BoxDecoration(
color: i.responsesSubDTO![index].isGood! ? kGreen : i.chosen == index ? kMainRed : kBackgroundLight,
shape: BoxShape.rectangle,
@ -185,8 +187,8 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
),
if(_questionsSubDTO != null && _questionsSubDTO.length > 1 && currentIndex != _questionsSubDTO.length && _questionsSubDTO[currentIndex-1].chosen != null && widget.questionsSubDTO!.length > 0)
Positioned(
top: size.height * 0.35,
right: 60,
top: kIsWeb ? size.height * 0.3 : size.height * 0.35, // TODO depends on screen' percentage
right: kIsWeb ? 45 : 60, // TODO depends on screen' percentage
child: InkWell(
onTap: () {
if(_questionsSubDTO[currentIndex-1].chosen != null && widget.questionsSubDTO!.length > 0) {
@ -204,15 +206,15 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
},
child: Icon(
Icons.chevron_right,
size: 150,
size: kIsWeb ? 100 : 150, // TODO depends on screen' percentage
color: kMainRed,
),
)
),
if(_questionsSubDTO != null && _questionsSubDTO.length > 1 && currentIndex != 1)
Positioned(
top: size.height * 0.35,
left: 60,
top: kIsWeb ? size.height * 0.3 : size.height * 0.35, // TODO depends on screen' percentage
left: kIsWeb ? 45 : 60, // TODO depends on screen' percentage
child: InkWell(
onTap: () {
if(currentIndex > 1)
@ -220,7 +222,7 @@ class _ShowReponsesWidget extends State<ShowReponsesWidget> {
},
child: Icon(
Icons.chevron_left,
size: 150,
size: kIsWeb ? 100 : 150, // TODO depends on screen' percentage
color: kMainRed,
),
)

View File

@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:manager_api/api.dart';
@ -131,7 +132,7 @@ class _SliderViewWidget extends State<SliderViewWidget> {
right: 0,
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Text(i.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kTitleSize, color: kBackgroundLight)),
child: Text(i.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? kWebTitleSize : kTitleSize, color: kBackgroundLight)),
)
)
]
@ -160,7 +161,7 @@ class _SliderViewWidget extends State<SliderViewWidget> {
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: Text(i.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize)),
child: Text(i.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "", textAlign: TextAlign.center, style: TextStyle(fontSize: kIsWeb ? kWebDescriptionSize : kDescriptionSize)),
),
),
),

View File

@ -1,10 +1,11 @@
import 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:manager_api/api.dart';
import 'package:tablet_app/constants.dart';
import 'package:youtube_player_iframe/youtube_player_iframe.dart';
//import 'package:youtube_player_flutter/youtube_player_flutter.dart';
import 'package:youtube_player_iframe/youtube_player_iframe.dart' as iframe;
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
class VideoViewWidget extends StatefulWidget {
final SectionDTO? section;
@ -15,6 +16,7 @@ class VideoViewWidget extends StatefulWidget {
}
class _VideoViewWidget extends State<VideoViewWidget> {
iframe.YoutubePlayer? _videoViewWeb;
YoutubePlayer? _videoView;
VideoDTO? videoDTO;
@ -26,29 +28,36 @@ class _VideoViewWidget extends State<VideoViewWidget> {
String? videoId;
if (videoDTO!.source_ != null && videoDTO!.source_!.length > 0 ) {
//videoId = YoutubePlayer.convertUrlToId(videoDTO!.source_!);
videoId = YoutubePlayer.convertUrlToId(videoDTO!.source_!);
final _controller = YoutubePlayerController(
params: YoutubePlayerParams(
if (kIsWeb) {
final _controllerWeb = iframe.YoutubePlayerController(
params: iframe.YoutubePlayerParams(
mute: false,
showControls: true,
showFullscreenButton: false,
loop: true,
showVideoAnnotations: false,
strictRelatedVideos: true,
pointerEvents: PointerEvents.auto
strictRelatedVideos: false,
enableKeyboard: false,
enableCaption: false,
pointerEvents: iframe.PointerEvents.auto
),
);
_controller.loadVideo(videoDTO!.source_!);//.loadVideoById(videoId: "3vBwRfQbXkg"); // Auto Play
_controllerWeb.loadVideo(videoDTO!.source_!);
// If the requirement is just to play a single video.
/*final _controller = YoutubePlayerController.fromVideoId(
videoId: '<video-id>',
autoPlay: false,
params: const YoutubePlayerParams(showFullscreenButton: true),
);*/
/*YoutubePlayerController _controller = YoutubePlayerController(
_videoViewWeb = iframe.YoutubePlayer(
controller: _controllerWeb,
//showVideoProgressIndicator: false,
/*progressIndicatorColor: Colors.amber,
progressColors: ProgressBarColors(
playedColor: Colors.amber,
handleColor: Colors.amberAccent,
),*/
);
} else {
YoutubePlayerController _controller = YoutubePlayerController(
initialVideoId: videoId!,
flags: YoutubePlayerFlags(
autoPlay: true,
@ -57,30 +66,32 @@ class _VideoViewWidget extends State<VideoViewWidget> {
hideControls: false,
hideThumbnail: false,
),
);*/
);
_videoView = YoutubePlayer(
controller: _controller,
//showVideoProgressIndicator: false,
/*progressIndicatorColor: Colors.amber,
progressIndicatorColor: Colors.amber,
progressColors: ProgressBarColors(
playedColor: Colors.amber,
handleColor: Colors.amberAccent,
),*/
),
);
}
super.initState();
}
}
@override
void dispose() {
_videoView = null;
_videoViewWeb = null;
super.dispose();
}
@override
Widget build(BuildContext context) => videoDTO!.source_ != null && videoDTO!.source_!.length > 0 ?
_videoView! :
(kIsWeb ? _videoViewWeb! : _videoView!):
Center(child: Text("La vidéo ne peut pas être affichée, l'url est incorrecte", style: new TextStyle(fontSize: kNoneInfoOrIncorrect)));
}

View File

@ -32,6 +32,9 @@ const kWebMenuDescriptionDetailSize = 14.0;
const kWebSectionTitleDetailSize = 35.0;
const kWebSectionDescriptionDetailSize = 20.0;
const kWebTitleSize = 30.0;
const kWebDescriptionSize = 14.0;
const kNoneInfoOrIncorrect = 35.0;
/*

View File

@ -28,6 +28,7 @@
<title>tablet_app</title>
<link rel="manifest" href="manifest.json">
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDg6ApuZb6TRsauIyHJ9-XVwGYeh7MsWXE"></script>
</head>
<body>
<!-- This script installs service_worker.js to provide PWA functionality to