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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,7 @@ import 'dart:convert';
import 'dart:developer'; import 'dart:developer';
import 'package:carousel_slider/carousel_slider.dart'; import 'package:carousel_slider/carousel_slider.dart';
import 'package:confetti/confetti.dart'; import 'package:confetti/confetti.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
@ -113,8 +114,8 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
//height: size.height * 0.2, //height: size.height * 0.2,
//width: size.width * 0.25, //width: size.width * 0.25,
constraints: BoxConstraints( constraints: BoxConstraints(
maxHeight: size.height * 0.25, maxHeight: kIsWeb ? size.height * 0.20 : size.height * 0.25,
maxWidth: size.width * 0.25, maxWidth: kIsWeb ? size.width * 0.20 : size.width * 0.25,
), ),
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -150,14 +151,14 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
), ),
), ),
Container( 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( Container(
child: Padding( child: Padding(
padding: const EdgeInsets.only(bottom: 10), padding: const EdgeInsets.only(bottom: 10),
child: Container( child: Container(
width: MediaQuery.of(context).size.width *0.75, 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( decoration: BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
@ -177,7 +178,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
child: SingleChildScrollView( child: SingleChildScrollView(
child: Padding( child: Padding(
padding: const EdgeInsets.all(15.0), 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,27 +188,25 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
), ),
if(showResponses) if(showResponses)
Container( Container(
child: Container( width: MediaQuery.of(context).size.width *0.75,
width: MediaQuery.of(context).size.width *0.75, height: kIsWeb ? MediaQuery.of(context).size.height *0.35 : MediaQuery.of(context).size.height *0.35,
height: MediaQuery.of(context).size.height *0.35, decoration: BoxDecoration(
decoration: BoxDecoration( color: kBackgroundLight,
color: kBackgroundLight, shape: BoxShape.rectangle,
shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(10.0),
borderRadius: BorderRadius.circular(10.0), boxShadow: [
boxShadow: [ BoxShadow(
BoxShadow( color: kBackgroundSecondGrey,
color: kBackgroundSecondGrey, spreadRadius: 0.3,
spreadRadius: 0.3, blurRadius: 4,
blurRadius: 4, offset: Offset(0, 2), // changes position of shadow
offset: Offset(0, 2), // changes position of shadow
),
],
),
child: Center(
child: Container(
width: double.infinity,
child: ShowReponsesWidget(questionsSubDTO: _questionsSubDTO),
), ),
],
),
child: Center(
child: Container(
width: double.infinity,
child: ShowReponsesWidget(questionsSubDTO: _questionsSubDTO),
), ),
), ),
), ),
@ -218,7 +217,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Container( Container(
height: 85, height: kIsWeb ? 50 : 85,
child: RoundedButton( child: RoundedButton(
text: "Recommencer", text: "Recommencer",
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -232,14 +231,14 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
_questionsSubDTO = QuestionSubDTO().fromJSON(quizzDTO.questions!); _questionsSubDTO = QuestionSubDTO().fromJSON(quizzDTO.questions!);
}); });
}, },
fontSize: 30, fontSize: kIsWeb ? kWebDescriptionSize : 30,
horizontal: 30, horizontal: 30,
vertical: 10 vertical: 10
), ),
), ),
if(!showResponses) if(!showResponses)
Container( Container(
height: 85, height: kIsWeb ? 50 : 85,
child: RoundedButton( child: RoundedButton(
text: "Voir les réponses", text: "Voir les réponses",
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -250,7 +249,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
showResponses = true; showResponses = true;
}); });
}, },
fontSize: 30, fontSize: kIsWeb ? kWebDescriptionSize : 30,
horizontal: 30, horizontal: 30,
vertical: 10 vertical: 10
), ),
@ -343,7 +342,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
child: SingleChildScrollView( child: SingleChildScrollView(
child: Padding( child: Padding(
padding: const EdgeInsets.all(15.0), 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( child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, crossAxisCount: 2,
mainAxisExtent: 150, mainAxisExtent: kIsWeb ? 75 : 150, // TODO depends on percentage
mainAxisSpacing: 150, mainAxisSpacing: kIsWeb ? 75 : 150, // TODO depends on percentage
crossAxisSpacing: 150, crossAxisSpacing: kIsWeb ? 75 : 150, // TODO depends on percentage
), ),
itemCount: i.responsesSubDTO!.length, itemCount: i.responsesSubDTO!.length,
itemBuilder: (BuildContext ctx, index) { itemBuilder: (BuildContext ctx, index) {
@ -381,7 +380,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
if(currentIndex == _questionsSubDTO.length && i.chosen == index) if(currentIndex == _questionsSubDTO.length && i.chosen == index)
{ {
showResult = true; showResult = true;
_controllerCenter!.play(); _controllerCenter!.play(); // TODO Maybe show only confetti on super score ..
} else { } else {
sliderController!.nextPage(duration: new Duration(milliseconds: 650), curve: Curves.fastOutSlowIn); 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), padding: const EdgeInsets.all(8.0),
child: Container( child: Container(
alignment: Alignment.center, 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( decoration: BoxDecoration(
color: i.chosen == index ? kTestSecondColor : kBackgroundLight, color: i.chosen == index ? kTestSecondColor : kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
@ -444,7 +443,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
}, },
child: Icon( child: Icon(
Icons.chevron_right, Icons.chevron_right,
size: 150, size: kIsWeb ? 100 : 150,
color: kMainRed, color: kMainRed,
), ),
) )
@ -460,7 +459,7 @@ class _QuizzViewWidget extends State<QuizzViewWidget> {
}, },
child: Icon( child: Icon(
Icons.chevron_left, Icons.chevron_left,
size: 150, size: kIsWeb ? 100 : 150,
color: kMainRed, color: kMainRed,
), ),
) )

View File

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

View File

@ -1,5 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:carousel_slider/carousel_slider.dart'; import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
@ -131,7 +132,7 @@ class _SliderViewWidget extends State<SliderViewWidget> {
right: 0, right: 0,
child: Padding( child: Padding(
padding: const EdgeInsets.all(15.0), 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: SingleChildScrollView(
child: Padding( child: Padding(
padding: const EdgeInsets.all(15.0), 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 'dart:convert';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:manager_api/api.dart'; import 'package:manager_api/api.dart';
import 'package:tablet_app/constants.dart'; import 'package:tablet_app/constants.dart';
import 'package:youtube_player_iframe/youtube_player_iframe.dart'; import 'package:youtube_player_iframe/youtube_player_iframe.dart' as iframe;
//import 'package:youtube_player_flutter/youtube_player_flutter.dart'; import 'package:youtube_player_flutter/youtube_player_flutter.dart';
class VideoViewWidget extends StatefulWidget { class VideoViewWidget extends StatefulWidget {
final SectionDTO? section; final SectionDTO? section;
@ -15,6 +16,7 @@ class VideoViewWidget extends StatefulWidget {
} }
class _VideoViewWidget extends State<VideoViewWidget> { class _VideoViewWidget extends State<VideoViewWidget> {
iframe.YoutubePlayer? _videoViewWeb;
YoutubePlayer? _videoView; YoutubePlayer? _videoView;
VideoDTO? videoDTO; VideoDTO? videoDTO;
@ -26,61 +28,70 @@ class _VideoViewWidget extends State<VideoViewWidget> {
String? videoId; String? videoId;
if (videoDTO!.source_ != null && videoDTO!.source_!.length > 0 ) { if (videoDTO!.source_ != null && videoDTO!.source_!.length > 0 ) {
//videoId = YoutubePlayer.convertUrlToId(videoDTO!.source_!); videoId = YoutubePlayer.convertUrlToId(videoDTO!.source_!);
final _controller = YoutubePlayerController( if (kIsWeb) {
params: YoutubePlayerParams( final _controllerWeb = iframe.YoutubePlayerController(
mute: false, params: iframe.YoutubePlayerParams(
showControls: true, mute: false,
showFullscreenButton: false, showControls: true,
showVideoAnnotations: false, showFullscreenButton: false,
strictRelatedVideos: true, loop: true,
pointerEvents: PointerEvents.auto showVideoAnnotations: false,
), 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. _videoViewWeb = iframe.YoutubePlayer(
/*final _controller = YoutubePlayerController.fromVideoId( controller: _controllerWeb,
videoId: '<video-id>', //showVideoProgressIndicator: false,
autoPlay: false, /*progressIndicatorColor: Colors.amber,
params: const YoutubePlayerParams(showFullscreenButton: true), progressColors: ProgressBarColors(
);*/ playedColor: Colors.amber,
handleColor: Colors.amberAccent,
),*/
);
} else {
YoutubePlayerController _controller = YoutubePlayerController(
initialVideoId: videoId!,
flags: YoutubePlayerFlags(
autoPlay: true,
controlsVisibleAtStart: false,
loop: true,
hideControls: false,
hideThumbnail: false,
),
);
/*YoutubePlayerController _controller = YoutubePlayerController(
initialVideoId: videoId!,
flags: YoutubePlayerFlags(
autoPlay: true,
controlsVisibleAtStart: false,
loop: true,
hideControls: false,
hideThumbnail: false,
),
);*/
_videoView = YoutubePlayer( _videoView = YoutubePlayer(
controller: _controller, controller: _controller,
//showVideoProgressIndicator: false, //showVideoProgressIndicator: false,
/*progressIndicatorColor: Colors.amber, progressIndicatorColor: Colors.amber,
progressColors: ProgressBarColors( progressColors: ProgressBarColors(
playedColor: Colors.amber, playedColor: Colors.amber,
handleColor: Colors.amberAccent, handleColor: Colors.amberAccent,
),*/ ),
); );
}
super.initState();
} }
super.initState();
} }
@override @override
void dispose() { void dispose() {
_videoView = null; _videoView = null;
_videoViewWeb = null;
super.dispose(); super.dispose();
} }
@override @override
Widget build(BuildContext context) => videoDTO!.source_ != null && videoDTO!.source_!.length > 0 ? 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))); 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 kWebSectionTitleDetailSize = 35.0;
const kWebSectionDescriptionDetailSize = 20.0; const kWebSectionDescriptionDetailSize = 20.0;
const kWebTitleSize = 30.0;
const kWebDescriptionSize = 14.0;
const kNoneInfoOrIncorrect = 35.0; const kNoneInfoOrIncorrect = 35.0;
/* /*

View File

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