mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 16:41:19 +00:00
Clean code + enhance quiz layout + fix version iframe
This commit is contained in:
parent
25f5213940
commit
e59b00251d
@ -72,7 +72,7 @@ class _GoogleMapViewState extends State<GoogleMapView> {
|
|||||||
));
|
));
|
||||||
//});
|
//});
|
||||||
},
|
},
|
||||||
infoWindow: kIsWeb ? InfoWindow.noText : InfoWindow(title: element.title)));
|
infoWindow: InfoWindow.noText));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return markers;
|
return markers;
|
||||||
|
|||||||
@ -3,9 +3,13 @@ import 'package:carousel_slider/carousel_slider.dart';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
|
||||||
|
import 'package:manager_api/api.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';
|
||||||
|
import 'package:tablet_app/Components/show_element_for_resource.dart';
|
||||||
import 'package:tablet_app/Models/map-marker.dart';
|
import 'package:tablet_app/Models/map-marker.dart';
|
||||||
|
import 'package:tablet_app/Screens/Quizz/quizz_view.dart';
|
||||||
|
import 'package:tablet_app/app_context.dart';
|
||||||
|
|
||||||
import '../../constants.dart';
|
import '../../constants.dart';
|
||||||
import 'map_context.dart';
|
import 'map_context.dart';
|
||||||
@ -20,7 +24,7 @@ class MarkerViewWidget extends StatefulWidget {
|
|||||||
class _MarkerInfoWidget extends State<MarkerViewWidget> {
|
class _MarkerInfoWidget extends State<MarkerViewWidget> {
|
||||||
Size sizeScreen = new Size(1080.0, 1920.0); // Tablet resolution
|
Size sizeScreen = new Size(1080.0, 1920.0); // Tablet resolution
|
||||||
CarouselController? sliderController;
|
CarouselController? sliderController;
|
||||||
int currentIndex = 1;
|
ValueNotifier<int> currentIndex = ValueNotifier<int>(1);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -39,19 +43,20 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
|
|||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
final mapContext = Provider.of<MapContext>(context);
|
final mapContext = Provider.of<MapContext>(context);
|
||||||
|
|
||||||
|
Size sizeMarker = Size(size.width * 0.42, size.height * 0.8);
|
||||||
return new AnimatedPositioned(
|
return new AnimatedPositioned(
|
||||||
duration: const Duration(milliseconds: 1500),
|
duration: const Duration(milliseconds: 1500),
|
||||||
curve: Curves.easeInOutSine,
|
curve: Curves.easeInOutSine,
|
||||||
right: 120, // 140
|
right: 25, // 140
|
||||||
top: 50, // 150
|
top: 10, // 150
|
||||||
child: Visibility(
|
child: Visibility(
|
||||||
visible: mapContext.getSelectedMarker().longitude != null,
|
visible: (mapContext.getSelectedMarker() as MapMarker).longitude != null,
|
||||||
child: Container(
|
child: Container(
|
||||||
width: size.width * 0.37,
|
width: sizeMarker.width,
|
||||||
height: size.height * 0.75,
|
height: sizeMarker.height,
|
||||||
margin: EdgeInsets.symmetric(vertical: 3, horizontal: 4),
|
margin: EdgeInsets.symmetric(vertical: 3, horizontal: 4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: kBackgroundLight,
|
color: kBackgroundLight, // Colors.amberAccent //kBackgroundLight,
|
||||||
shape: BoxShape.rectangle,
|
shape: BoxShape.rectangle,
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
@ -102,7 +107,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(top: 20),
|
padding: const EdgeInsets.only(top: 20),
|
||||||
child: HtmlWidget(
|
child: HtmlWidget(
|
||||||
mapContext.getSelectedMarker().title,
|
(mapContext.getSelectedMarker() as MapMarker).title!,
|
||||||
customStylesBuilder: (element) {
|
customStylesBuilder: (element) {
|
||||||
return {'text-align': 'center'};
|
return {'text-align': 'center'};
|
||||||
},
|
},
|
||||||
@ -119,72 +124,66 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
if(mapContext.getSelectedMarker().images != null && mapContext.getSelectedMarker().images.length > 0)
|
if((mapContext.getSelectedMarker() as MapMarker).contents != null && (mapContext.getSelectedMarker() as MapMarker).contents!.length > 0)
|
||||||
CarouselSlider(
|
Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
//color: Colors.green,
|
||||||
|
child: CarouselSlider(
|
||||||
carouselController: sliderController,
|
carouselController: sliderController,
|
||||||
options: CarouselOptions(
|
options: CarouselOptions(
|
||||||
onPageChanged: (int index, CarouselPageChangedReason reason) {
|
onPageChanged: (int index, CarouselPageChangedReason reason) {
|
||||||
setState(() {
|
currentIndex.value = index + 1;
|
||||||
currentIndex = index + 1;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
height: size.height *0.3,
|
height: size.height *0.35,
|
||||||
enlargeCenterPage: true,
|
enlargeCenterPage: true,
|
||||||
pageSnapping: true,
|
pageSnapping: true,
|
||||||
reverse: false,
|
reverse: false,
|
||||||
),
|
),
|
||||||
items: mapContext.getSelectedMarker().images.map<Widget>((i) {
|
items: (mapContext.getSelectedMarker() as MapMarker).contents!.map<Widget>((ContentGeoPoint i) {
|
||||||
return Builder(
|
return Builder(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
AppContext appContext = Provider.of<AppContext>(context);
|
||||||
|
var resourcetoShow = getElementForResource(context, appContext, i);
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Container(
|
child: resourcetoShow,
|
||||||
//width: MediaQuery.of(context).size.width *0.9,
|
|
||||||
/*decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(20.0),
|
|
||||||
border: Border.all(width: 0.3, color: kSecondGrey),
|
|
||||||
image: i.imageSource != null ? new DecorationImage(
|
|
||||||
fit: BoxFit.contain,
|
|
||||||
image: new NetworkImage(
|
|
||||||
i.imageSource,
|
|
||||||
),
|
|
||||||
): null,
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: kBackgroundSecondGrey,
|
|
||||||
spreadRadius: 0.3,
|
|
||||||
blurRadius: 3,
|
|
||||||
offset: Offset(0, 1.1), // changes position of shadow
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),*/
|
|
||||||
child: AspectRatio(
|
|
||||||
aspectRatio: 16 / 9,
|
|
||||||
child: ClipRect(
|
|
||||||
child: i.imageSource != null ? PhotoView(
|
|
||||||
imageProvider: CachedNetworkImageProvider(i.imageSource), /*new NetworkImage(
|
|
||||||
i.imageSource,
|
|
||||||
),*/
|
|
||||||
minScale: PhotoViewComputedScale.contained * 0.8,
|
|
||||||
maxScale: PhotoViewComputedScale.contained * 3.0,
|
|
||||||
backgroundDecoration: BoxDecoration(
|
|
||||||
color: kBackgroundSecondGrey,
|
|
||||||
shape: BoxShape.rectangle,
|
|
||||||
borderRadius: BorderRadius.circular(15.0),
|
|
||||||
),
|
|
||||||
) : Center(child: Text('No data')),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 0,
|
||||||
|
child: Container(
|
||||||
|
//color: Colors.red,
|
||||||
|
height: 25,
|
||||||
|
width: sizeMarker.width,
|
||||||
|
//color: Colors.amber,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 0),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
child: ValueListenableBuilder<int>(
|
||||||
|
valueListenable: currentIndex,
|
||||||
|
builder: (context, value, _) {
|
||||||
|
return Text(
|
||||||
|
value.toString()+'/'+(mapContext.getSelectedMarker() as MapMarker).contents!.length.toString(),
|
||||||
|
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
// Description
|
// Description
|
||||||
Container(
|
Container(
|
||||||
height: mapContext.getSelectedMarker().images != null && mapContext.getSelectedMarker().images.length > 0 ? size.height *0.3 : size.height *0.6,
|
height: (mapContext.getSelectedMarker() as MapMarker).contents != null && (mapContext.getSelectedMarker() as MapMarker).contents!.length > 0 ? size.height *0.3 : size.height *0.6,
|
||||||
width: MediaQuery.of(context).size.width *0.35,
|
width: MediaQuery.of(context).size.width *0.4,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: kBackgroundColor,
|
color: kBackgroundColor,
|
||||||
shape: BoxShape.rectangle,
|
shape: BoxShape.rectangle,
|
||||||
@ -202,7 +201,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(15.0),
|
padding: const EdgeInsets.all(15.0),
|
||||||
child: HtmlWidget(
|
child: HtmlWidget(
|
||||||
mapContext.getSelectedMarker().description,
|
(mapContext.getSelectedMarker() as MapMarker).description!,
|
||||||
customStylesBuilder: (element) {
|
customStylesBuilder: (element) {
|
||||||
return {'text-align': 'center'};
|
return {'text-align': 'center'};
|
||||||
},
|
},
|
||||||
@ -213,13 +212,13 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
|
|||||||
),
|
),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
if(mapContext.getSelectedMarker().images != null && mapContext.getSelectedMarker().images.length > 1)
|
if((mapContext.getSelectedMarker() as MapMarker).contents != null && (mapContext.getSelectedMarker() as MapMarker).contents!.length > 1)
|
||||||
Positioned(
|
Positioned(
|
||||||
top: MediaQuery.of(context).size.height * 0.125,
|
top: MediaQuery.of(context).size.height * 0.125,
|
||||||
right: -10,
|
right: -10,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (mapContext.getSelectedMarker().images.length > 0)
|
if ((mapContext.getSelectedMarker() as MapMarker).contents!.length > 0)
|
||||||
sliderController!.nextPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
|
sliderController!.nextPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
|
||||||
},
|
},
|
||||||
child: Icon(
|
child: Icon(
|
||||||
@ -229,13 +228,13 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
if(mapContext.getSelectedMarker().images != null && mapContext.getSelectedMarker().images.length > 1)
|
if((mapContext.getSelectedMarker() as MapMarker).contents != null && (mapContext.getSelectedMarker() as MapMarker).contents!.length > 1)
|
||||||
Positioned(
|
Positioned(
|
||||||
top: MediaQuery.of(context).size.height * 0.125,
|
top: MediaQuery.of(context).size.height * 0.125,
|
||||||
left: -10,
|
left: -10,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (mapContext.getSelectedMarker().images.length > 0)
|
if ((mapContext.getSelectedMarker() as MapMarker).contents!.length > 0)
|
||||||
sliderController!.previousPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
|
sliderController!.previousPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
|
||||||
},
|
},
|
||||||
child: Icon(
|
child: Icon(
|
||||||
@ -256,3 +255,53 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getElementForResource(BuildContext context, AppContext appContext, ContentGeoPoint i) {
|
||||||
|
var widgetToInclude;
|
||||||
|
|
||||||
|
switch(i.resourceType) {
|
||||||
|
case ResourceType.Image:
|
||||||
|
case ResourceType.ImageUrl:
|
||||||
|
widgetToInclude = AspectRatio(
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
child: ClipRect(
|
||||||
|
child: i.resourceUrl != null ? PhotoView(
|
||||||
|
imageProvider: CachedNetworkImageProvider(i.resourceUrl!), /*new NetworkImage(
|
||||||
|
i.imageSource,
|
||||||
|
),*/
|
||||||
|
minScale: PhotoViewComputedScale.contained * 0.8,
|
||||||
|
maxScale: PhotoViewComputedScale.contained * 3.0,
|
||||||
|
backgroundDecoration: BoxDecoration(
|
||||||
|
color: kBackgroundSecondGrey,
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(15.0),
|
||||||
|
),
|
||||||
|
) : Center(child: Text('No data')),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case ResourceType.Video:
|
||||||
|
case ResourceType.VideoUrl:
|
||||||
|
case ResourceType.Audio:
|
||||||
|
widgetToInclude = Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: kBackgroundSecondGrey,
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(15.0),
|
||||||
|
),
|
||||||
|
child: showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext, false, true),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Center(
|
||||||
|
child: Container(
|
||||||
|
child: AspectRatio(
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
child: ClipRect(
|
||||||
|
child: widgetToInclude,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,9 @@ class _PDFViewWidget extends State<PDFViewWidget> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => pdfDTO.resourceUrl != null && pdfDTO.resourceUrl!.length > 0 ?
|
Widget build(BuildContext context) => pdfDTO.resourceUrl != null && pdfDTO.resourceUrl!.length > 0 ?
|
||||||
FutureBuilder(
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(12.5),
|
||||||
|
child: FutureBuilder(
|
||||||
future: createFileOfPdfUrl(pdfDTO.resourceUrl!),
|
future: createFileOfPdfUrl(pdfDTO.resourceUrl!),
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
print("snapshot.data");
|
print("snapshot.data");
|
||||||
@ -142,6 +144,7 @@ class _PDFViewWidget extends State<PDFViewWidget> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
),
|
||||||
) :
|
) :
|
||||||
Center(child: Text("Le PDF ne peut pas être affiché, il n'existe pas"));
|
Center(child: Text("Le PDF ne peut pas être affiché, il n'existe pas"));
|
||||||
} //_webView
|
} //_webView
|
||||||
@ -304,13 +304,13 @@ class _QuizzView extends State<QuizzView> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
//width: MediaQuery.of(context).size.width *0.65,
|
//width: MediaQuery.of(context).size.width *0.65,
|
||||||
height: MediaQuery.of(context).size.height *0.3,
|
height: MediaQuery.of(context).size.height *0.3,
|
||||||
color: Colors.green,
|
//color: Colors.green,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.orange,// kBackgroundLight,
|
color: kBackgroundLight, // Colors.orange,// kBackgroundLight,
|
||||||
shape: BoxShape.rectangle,
|
shape: BoxShape.rectangle,
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
|
|||||||
@ -32,7 +32,7 @@ dependencies:
|
|||||||
|
|
||||||
# Specific Web
|
# Specific Web
|
||||||
google_maps_flutter_web: ^0.5.4+2 # Specific WEB
|
google_maps_flutter_web: ^0.5.4+2 # Specific WEB
|
||||||
youtube_player_iframe: ^5.0.0 # Handle mobile and web here => TO TEST
|
youtube_player_iframe: ^4.0.4 # Handle mobile and web here => TO TEST
|
||||||
|
|
||||||
flare_flutter: ^3.0.2
|
flare_flutter: ^3.0.2
|
||||||
provider: ^6.0.5
|
provider: ^6.0.5
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user