mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 16:41:19 +00:00
Slider support all format + update to adapt (webview youtube memory issue) + hour and date main view
This commit is contained in:
parent
7afe94b564
commit
4e6c281b84
@ -30,6 +30,7 @@ class _AudioPlayerFloatingContainerState extends State<AudioPlayerFloatingContai
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
print("IN INITSTATE AUDDDIOOOO");
|
||||||
Future.delayed(Duration.zero, () async {
|
Future.delayed(Duration.zero, () async {
|
||||||
if(widget.audioBytes != null) {
|
if(widget.audioBytes != null) {
|
||||||
audiobytes = widget.audioBytes!;
|
audiobytes = widget.audioBytes!;
|
||||||
@ -99,10 +100,10 @@ class _AudioPlayerFloatingContainerState extends State<AudioPlayerFloatingContai
|
|||||||
});
|
});
|
||||||
});*/
|
});*/
|
||||||
|
|
||||||
|
await player.setUrl(widget.resourceURl);
|
||||||
if(widget.isAuto) {
|
if(widget.isAuto) {
|
||||||
//player.play(BytesSource(audiobytes));
|
//player.play(BytesSource(audiobytes));
|
||||||
//await player.setAudioSource(LoadedSource(audiobytes));
|
//await player.setAudioSource(LoadedSource(audiobytes));
|
||||||
await player.setUrl(widget.resourceURl);
|
|
||||||
player.play();
|
player.play();
|
||||||
setState(() {
|
setState(() {
|
||||||
isplaying = true;
|
isplaying = true;
|
||||||
@ -130,7 +131,7 @@ class _AudioPlayerFloatingContainerState extends State<AudioPlayerFloatingContai
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if(!isplaying && !audioplayed){
|
if(!isplaying && !audioplayed){
|
||||||
//player.play(BytesSource(audiobytes));
|
//player.play(BytesSource(audiobytes));
|
||||||
await player.setAudioSource(LoadedSource(audiobytes));
|
//await player.setUrl(widget.resourceURl);
|
||||||
player.play();
|
player.play();
|
||||||
setState(() {
|
setState(() {
|
||||||
isplaying = true;
|
isplaying = true;
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import 'package:tablet_app/Components/video_viewer_youtube.dart';
|
|||||||
import 'package:tablet_app/Models/tabletContext.dart';
|
import 'package:tablet_app/Models/tabletContext.dart';
|
||||||
import 'package:tablet_app/app_context.dart';
|
import 'package:tablet_app/app_context.dart';
|
||||||
|
|
||||||
showElementForResource(ResourceDTO resourceDTO, AppContext appContext) {
|
showElementForResource(ResourceDTO resourceDTO, AppContext appContext, bool isAuto, bool webView) {
|
||||||
TabletAppContext tabletAppContext = appContext.getContext();
|
TabletAppContext tabletAppContext = appContext.getContext();
|
||||||
Color primaryColor = new Color(int.parse(tabletAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16));
|
Color primaryColor = new Color(int.parse(tabletAppContext.configuration!.primaryColor!.split('(0x')[1].split(')')[0], radix: 16));
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ showElementForResource(ResourceDTO resourceDTO, AppContext appContext) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
case ResourceType.Audio:
|
case ResourceType.Audio:
|
||||||
return AudioPlayerFloatingContainer(audioBytes: null, resourceURl: resourceDTO.url!, isAuto: true);
|
return AudioPlayerFloatingContainer(audioBytes: null, resourceURl: resourceDTO.url!, isAuto: isAuto);
|
||||||
/*return FutureBuilder(
|
/*return FutureBuilder(
|
||||||
future: getAudio(resourceDTO.url, appContext),
|
future: getAudio(resourceDTO.url, appContext),
|
||||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
@ -94,7 +94,7 @@ showElementForResource(ResourceDTO resourceDTO, AppContext appContext) {
|
|||||||
if(resourceDTO.url == null) {
|
if(resourceDTO.url == null) {
|
||||||
return Center(child: Text("Error loading video"));
|
return Center(child: Text("Error loading video"));
|
||||||
} else {
|
} else {
|
||||||
return VideoViewerYoutube(videoUrl: resourceDTO.url!);
|
return VideoViewerYoutube(videoUrl: resourceDTO.url!, isAuto: isAuto, webView: webView);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,9 @@ import 'package:youtube_player_flutter/youtube_player_flutter.dart';
|
|||||||
|
|
||||||
class VideoViewerYoutube extends StatefulWidget {
|
class VideoViewerYoutube extends StatefulWidget {
|
||||||
final String videoUrl;
|
final String videoUrl;
|
||||||
VideoViewerYoutube({required this.videoUrl});
|
final bool isAuto;
|
||||||
|
final bool webView;
|
||||||
|
VideoViewerYoutube({required this.videoUrl, required this.isAuto, this.webView = false});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_VideoViewerYoutube createState() => _VideoViewerYoutube();
|
_VideoViewerYoutube createState() => _VideoViewerYoutube();
|
||||||
@ -25,7 +27,7 @@ class _VideoViewerYoutube extends State<VideoViewerYoutube> {
|
|||||||
if (widget.videoUrl.length > 0 ) {
|
if (widget.videoUrl.length > 0 ) {
|
||||||
videoId = YoutubePlayer.convertUrlToId(widget.videoUrl);
|
videoId = YoutubePlayer.convertUrlToId(widget.videoUrl);
|
||||||
|
|
||||||
if (kIsWeb) {
|
if (widget.webView) {
|
||||||
final _controllerWeb = iframe.YoutubePlayerController(
|
final _controllerWeb = iframe.YoutubePlayerController(
|
||||||
params: iframe.YoutubePlayerParams(
|
params: iframe.YoutubePlayerParams(
|
||||||
mute: false,
|
mute: false,
|
||||||
@ -52,11 +54,12 @@ class _VideoViewerYoutube extends State<VideoViewerYoutube> {
|
|||||||
),*/
|
),*/
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// Cause memory issue on tablet
|
||||||
videoId = YoutubePlayer.convertUrlToId(widget.videoUrl);
|
videoId = YoutubePlayer.convertUrlToId(widget.videoUrl);
|
||||||
YoutubePlayerController _controller = YoutubePlayerController(
|
YoutubePlayerController _controller = YoutubePlayerController(
|
||||||
initialVideoId: videoId!,
|
initialVideoId: videoId!,
|
||||||
flags: YoutubePlayerFlags(
|
flags: YoutubePlayerFlags(
|
||||||
autoPlay: true,
|
autoPlay: widget.isAuto,
|
||||||
controlsVisibleAtStart: false,
|
controlsVisibleAtStart: false,
|
||||||
loop: true,
|
loop: true,
|
||||||
hideControls: false,
|
hideControls: false,
|
||||||
@ -81,13 +84,13 @@ class _VideoViewerYoutube extends State<VideoViewerYoutube> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_videoView = null;
|
//_videoView = null;
|
||||||
_videoViewWeb = null;
|
_videoViewWeb = null;
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => widget.videoUrl.length > 0 ?
|
Widget build(BuildContext context) => widget.videoUrl.length > 0 ?
|
||||||
(kIsWeb ? _videoViewWeb! : _videoView!):
|
(widget.webView ? _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)));
|
||||||
}
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
@ -26,6 +27,7 @@ import 'package:tablet_app/Screens/Video/video_view.dart';
|
|||||||
import 'package:tablet_app/Screens/Web/web_view.dart';
|
import 'package:tablet_app/Screens/Web/web_view.dart';
|
||||||
import 'package:tablet_app/app_context.dart';
|
import 'package:tablet_app/app_context.dart';
|
||||||
import 'package:tablet_app/constants.dart';
|
import 'package:tablet_app/constants.dart';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import '../Quizz/quizz_view.dart';
|
import '../Quizz/quizz_view.dart';
|
||||||
import 'language_selection.dart';
|
import 'language_selection.dart';
|
||||||
@ -41,15 +43,38 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
Size sizeScreen = new Size(1080.0, 1920.0); // Tablet resolution
|
Size sizeScreen = new Size(1080.0, 1920.0); // Tablet resolution
|
||||||
SectionDTO? sectionSelected;
|
SectionDTO? sectionSelected;
|
||||||
late ConfigurationDTO configurationDTO;
|
late ConfigurationDTO configurationDTO;
|
||||||
|
ValueNotifier<DateTime?> currentHourDate = ValueNotifier<DateTime?>(DateTime.now());
|
||||||
|
late Color backgroundColor;
|
||||||
int rowCount = 4;
|
int rowCount = 4;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
final appContext = Provider.of<AppContext>(context, listen: false);
|
||||||
|
configurationDTO = appContext.getContext().configuration;
|
||||||
|
if(configurationDTO.isHour != null && configurationDTO.isHour!) {
|
||||||
|
Timer.periodic(Duration(seconds: 1), (Timer t) => _getTime(currentHourDate));
|
||||||
|
}
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _getTime(ValueNotifier<DateTime?> valueNotifier) {
|
||||||
|
//final DateTime now = DateTime.now();
|
||||||
|
//final String formattedDateTime = _formatDateTime(now);
|
||||||
|
|
||||||
|
//setState(() {
|
||||||
|
//_timeString = formattedDateTime;
|
||||||
|
valueNotifier.value = DateTime.now();
|
||||||
|
//});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final appContext = Provider.of<AppContext>(context);
|
final appContext = Provider.of<AppContext>(context);
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
||||||
Size size = MediaQuery.of(context).size;
|
Size size = MediaQuery.of(context).size;
|
||||||
configurationDTO = appContext.getContext().configuration;
|
|
||||||
|
backgroundColor = appContext.getContext().configuration != null ? new Color(int.parse(appContext.getContext().configuration.secondaryColor.split('(0x')[1].split(')')[0], radix: 16)) : Colors.white;
|
||||||
|
Color textColor = backgroundColor.computeLuminance() > 0.5 ? Colors.black : Colors.white;
|
||||||
|
|
||||||
// TODO REMOVE
|
// TODO REMOVE
|
||||||
/*if (!MQTTHelper.instance.isInstantiated)
|
/*if (!MQTTHelper.instance.isInstantiated)
|
||||||
@ -151,7 +176,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: HtmlWidget(
|
child: HtmlWidget(
|
||||||
sectionSelected!.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value!,
|
sectionSelected!.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value!,
|
||||||
textStyle: new TextStyle(fontSize: kIsWeb ? kWebSectionTitleDetailSize : kSectionTitleDetailSize, color: Colors.white),
|
textStyle: new TextStyle(fontSize: kIsWeb ? kWebSectionTitleDetailSize : kSectionTitleDetailSize, color: textColor),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -161,7 +186,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: HtmlWidget(
|
child: HtmlWidget(
|
||||||
sectionSelected!.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!,
|
sectionSelected!.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value!,
|
||||||
textStyle: new TextStyle(fontSize: kIsWeb? kWebSectionDescriptionDetailSize : kSectionDescriptionDetailSize),
|
textStyle: new TextStyle(fontSize: kIsWeb? kWebSectionDescriptionDetailSize : kSectionDescriptionDetailSize, color: textColor),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -226,7 +251,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
body: Container(
|
body: Container(
|
||||||
height: size.height,
|
height: size.height,
|
||||||
width: size.width,
|
width: size.width,
|
||||||
color: configurationDTO.imageId == null ? configurationDTO.secondaryColor != null ? new Color(int.parse(appContext.getContext().configuration.secondaryColor.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : null,
|
color: configurationDTO.imageId == null ? configurationDTO.secondaryColor != null ? backgroundColor : kBackgroundGrey : null,
|
||||||
decoration: configurationDTO.imageId != null ? BoxDecoration(
|
decoration: configurationDTO.imageId != null ? BoxDecoration(
|
||||||
image: new DecorationImage(
|
image: new DecorationImage(
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
@ -238,6 +263,35 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
) : null,
|
) : null,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
|
if(currentHourDate.value != null)
|
||||||
|
ValueListenableBuilder<DateTime?>(
|
||||||
|
valueListenable: currentHourDate,
|
||||||
|
builder: (context, value, _) {
|
||||||
|
return Positioned(
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if(value != null && configurationDTO.isHour!)
|
||||||
|
Text(DateFormat('HH:mm').format(value), style: TextStyle(fontSize: 20, color: textColor)),
|
||||||
|
if(value != null && configurationDTO.isDate!)
|
||||||
|
if(appContext.getContext().language.toString().toUpperCase() == "EN")
|
||||||
|
Text(DateFormat('MM/dd/yy').format(value), style: TextStyle(fontSize: 15, color: textColor)),
|
||||||
|
if(value != null && configurationDTO.isDate!)
|
||||||
|
if(appContext.getContext().language.toString().toUpperCase() != "EN")
|
||||||
|
Text(DateFormat('dd/MM/yy').format(value), style: TextStyle(fontSize: 15, color: textColor)),
|
||||||
|
if(configurationDTO.weatherCity != null) // TODO Weather
|
||||||
|
Text('TODO - ' + configurationDTO.weatherCity!, style: TextStyle(fontSize: 15, color: textColor))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
LanguageSelection(size: size),
|
LanguageSelection(size: size),
|
||||||
Center(
|
Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -271,35 +325,43 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.bottomRight,
|
alignment: Alignment.bottomRight,
|
||||||
child: FractionallySizedBox(
|
child: FractionallySizedBox(
|
||||||
heightFactor: 0.35,
|
heightFactor: 0.4,
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Colors.green,
|
//color: Colors.green,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
color: Colors.blue,
|
//color: Colors.orange,
|
||||||
child: LayoutBuilder(
|
child: SizedBox(
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
width: double.infinity,
|
||||||
return SizedBox(
|
child: Align(
|
||||||
width: double.infinity,
|
alignment: Alignment.centerRight,
|
||||||
child: FittedBox(
|
child: HtmlWidget(
|
||||||
fit: BoxFit.fitWidth,
|
snapshot.data[index].title.firstWhere((translation) => translation.language == appContext.getContext().language).value,
|
||||||
child: Align(
|
customStylesBuilder: (element) {
|
||||||
alignment: Alignment.centerRight,
|
return {'text-align': 'right'};
|
||||||
child: HtmlWidget(
|
},
|
||||||
snapshot.data[index].title.firstWhere((translation) => translation.language == appContext.getContext().language).value,
|
textStyle: TextStyle(fontSize: 25),//calculateFontSize(constraints.maxWidth, constraints.maxHeight, kIsWeb ? kWebMenuTitleDetailSize : kMenuTitleDetailSize)),
|
||||||
customStylesBuilder: (element) {
|
),
|
||||||
return {'text-align': 'right'};
|
),
|
||||||
},
|
),
|
||||||
textStyle: TextStyle(fontSize: calculateFontSize(constraints.maxWidth, constraints.maxHeight, kIsWeb ? kWebMenuTitleDetailSize : kMenuTitleDetailSize)),
|
),
|
||||||
),
|
Container(
|
||||||
),
|
//color: Colors.red,
|
||||||
),
|
child: SizedBox(
|
||||||
);
|
width: double.infinity,
|
||||||
},
|
child: Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: HtmlWidget(
|
||||||
|
snapshot.data[index].description.firstWhere((translation) => translation.language == appContext.getContext().language).value,
|
||||||
|
customStylesBuilder: (element) {
|
||||||
|
return {'text-align': 'right'};
|
||||||
|
},
|
||||||
|
textStyle: TextStyle(fontSize: 20),//calculateFontSize(constraints.maxWidth, constraints.maxHeight, kIsWeb ? kWebMenuTitleDetailSize : kMenuTitleDetailSize)),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(color: Colors.orange, child: Text("ds")),
|
|
||||||
|
|
||||||
/*Container(
|
/*Container(
|
||||||
color: Colors.orange,
|
color: Colors.orange,
|
||||||
@ -366,6 +428,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
|||||||
ConfigurationDTO? configurationDTO = await tabletAppContext.clientAPI!.configurationApi!.configurationGetDetail(tabletAppContext.configuration!.id!);
|
ConfigurationDTO? configurationDTO = await tabletAppContext.clientAPI!.configurationApi!.configurationGetDetail(tabletAppContext.configuration!.id!);
|
||||||
|
|
||||||
tabletAppContext.configuration = configurationDTO;
|
tabletAppContext.configuration = configurationDTO;
|
||||||
|
backgroundColor = tabletAppContext.configuration != null ? new Color(int.parse(appContext.getContext().configuration.secondaryColor.split('(0x')[1].split(')')[0], radix: 16)) : Colors.white;
|
||||||
|
|
||||||
TabletAppContext? localContext = await DatabaseHelper.instance.getData();
|
TabletAppContext? localContext = await DatabaseHelper.instance.getData();
|
||||||
if (localContext != null) { // Check if sql DB exist
|
if (localContext != null) { // Check if sql DB exist
|
||||||
@ -441,7 +504,7 @@ boxDecoration(SectionDTO section, bool isSelected) {
|
|||||||
borderRadius: BorderRadius.circular(30.0),
|
borderRadius: BorderRadius.circular(30.0),
|
||||||
image: section.imageSource != null ? new DecorationImage(
|
image: section.imageSource != null ? new DecorationImage(
|
||||||
fit: !isSelected || kIsWeb ? BoxFit.cover : BoxFit.contain,
|
fit: !isSelected || kIsWeb ? BoxFit.cover : BoxFit.contain,
|
||||||
colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(kIsWeb ? 0.3 : 0.5), BlendMode.dstATop) : null,
|
colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(kIsWeb ? 0.3 : 0.3), BlendMode.dstATop) : null,
|
||||||
image: new NetworkImage(
|
image: new NetworkImage(
|
||||||
section.imageSource!,
|
section.imageSource!,
|
||||||
),
|
),
|
||||||
|
|||||||
@ -29,7 +29,7 @@ void showMessage(TranslationAndResourceDTO translationAndResourceDTO, AppContext
|
|||||||
borderRadius: BorderRadius.circular(30),
|
borderRadius: BorderRadius.circular(30),
|
||||||
//border: Border.all(width: 3, color: Colors.black)
|
//border: Border.all(width: 3, color: Colors.black)
|
||||||
),
|
),
|
||||||
child: showElementForResource(ResourceDTO(id: translationAndResourceDTO.resourceId, type: translationAndResourceDTO.resourceType, url: translationAndResourceDTO.resourceUrl), appContext),
|
child: showElementForResource(ResourceDTO(id: translationAndResourceDTO.resourceId, type: translationAndResourceDTO.resourceType, url: translationAndResourceDTO.resourceUrl), appContext, true, false),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -27,17 +27,12 @@ class _PuzzleView extends State<PuzzleView> {
|
|||||||
|
|
||||||
int allInPlaceCount = 0;
|
int allInPlaceCount = 0;
|
||||||
bool isFinished = false;
|
bool isFinished = false;
|
||||||
|
|
||||||
GlobalKey _widgetKey = GlobalKey();
|
GlobalKey _widgetKey = GlobalKey();
|
||||||
Size? realWidgetSize;
|
Size? realWidgetSize;
|
||||||
|
|
||||||
//File? _image;
|
|
||||||
String? _imagePath;
|
|
||||||
List<Widget> pieces = [];
|
List<Widget> pieces = [];
|
||||||
|
|
||||||
bool isSplittingImage = true;
|
bool isSplittingImage = true;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
puzzleDTO = PuzzleDTO.fromJson(jsonDecode(widget.section!.data!))!;
|
puzzleDTO = PuzzleDTO.fromJson(jsonDecode(widget.section!.data!))!;
|
||||||
@ -77,7 +72,7 @@ class _PuzzleView extends State<PuzzleView> {
|
|||||||
|
|
||||||
// we need to find out the image size, to be used in the PuzzlePiece widget
|
// we need to find out the image size, to be used in the PuzzlePiece widget
|
||||||
Future<Size> getImageSize(Image image) async {
|
Future<Size> getImageSize(Image image) async {
|
||||||
final Completer<Size> completer = Completer<Size>();
|
Completer<Size> completer = Completer<Size>();
|
||||||
|
|
||||||
image.image
|
image.image
|
||||||
.resolve(const ImageConfiguration())
|
.resolve(const ImageConfiguration())
|
||||||
@ -86,7 +81,7 @@ class _PuzzleView extends State<PuzzleView> {
|
|||||||
Size(info.image.width.toDouble(), info.image.height.toDouble()));
|
Size(info.image.width.toDouble(), info.image.height.toDouble()));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
final Size imageSize = await completer.future;
|
Size imageSize = await completer.future;
|
||||||
|
|
||||||
return imageSize;
|
return imageSize;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class SliderView extends StatefulWidget {
|
|||||||
class _SliderView extends State<SliderView> {
|
class _SliderView extends State<SliderView> {
|
||||||
SliderDTO sliderDTO = SliderDTO();
|
SliderDTO sliderDTO = SliderDTO();
|
||||||
CarouselController? sliderController;
|
CarouselController? sliderController;
|
||||||
int currentIndex = 1;
|
ValueNotifier<int> currentIndex = ValueNotifier<int>(1);
|
||||||
|
|
||||||
late ConfigurationDTO configurationDTO;
|
late ConfigurationDTO configurationDTO;
|
||||||
|
|
||||||
@ -52,124 +52,116 @@ class _SliderView extends State<SliderView> {
|
|||||||
|
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Column(
|
if(sliderDTO.contents != null && sliderDTO.contents!.length > 0)
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
CarouselSlider(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
carouselController: sliderController,
|
||||||
children: [
|
options: CarouselOptions(
|
||||||
if(sliderDTO.contents != null && sliderDTO.contents!.length > 0)
|
onPageChanged: (int index, CarouselPageChangedReason reason) {
|
||||||
CarouselSlider(
|
currentIndex.value = index + 1;
|
||||||
carouselController: sliderController,
|
},
|
||||||
options: CarouselOptions(
|
height: MediaQuery.of(context).size.height * 0.8,
|
||||||
onPageChanged: (int index, CarouselPageChangedReason reason) {
|
enlargeCenterPage: true,
|
||||||
setState(() {
|
reverse: false,
|
||||||
currentIndex = index + 1;
|
),
|
||||||
});
|
items: sliderDTO.contents!.map<Widget>((i) {
|
||||||
},
|
return Builder(
|
||||||
height: MediaQuery.of(context).size.height * 0.8,
|
builder: (BuildContext context) {
|
||||||
enlargeCenterPage: true,
|
return Container(
|
||||||
reverse: false,
|
width: MediaQuery.of(context).size.width,
|
||||||
),
|
height: MediaQuery.of(context).size.height,
|
||||||
items: sliderDTO.contents!.map<Widget>((i) {
|
margin: EdgeInsets.symmetric(horizontal: 5.0),
|
||||||
return Builder(
|
decoration: BoxDecoration(
|
||||||
builder: (BuildContext context) {
|
color: configurationDTO.imageId == null ? configurationDTO.secondaryColor != null ? new Color(int.parse(configurationDTO.secondaryColor!.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : null,
|
||||||
return Container(
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
width: MediaQuery.of(context).size.width,
|
//border: Border.all(width: 0.3, color: kSecondGrey),
|
||||||
height: MediaQuery.of(context).size.height,
|
),
|
||||||
margin: EdgeInsets.symmetric(horizontal: 5.0),
|
child: Column(
|
||||||
decoration: BoxDecoration(
|
//crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
color: configurationDTO.imageId == null ? configurationDTO.secondaryColor != null ? new Color(int.parse(configurationDTO.secondaryColor!.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey : null,
|
//mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
children: [
|
||||||
//border: Border.all(width: 0.3, color: kSecondGrey),
|
Padding(
|
||||||
),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: Column(
|
child: Container(
|
||||||
//crossAxisAlignment: CrossAxisAlignment.center,
|
height: MediaQuery.of(context).size.height * 0.6,
|
||||||
//mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
width: MediaQuery.of(context).size.width * 0.72,
|
||||||
children: [
|
/*decoration: BoxDecoration(
|
||||||
Padding(
|
color: kBackgroundLight,
|
||||||
padding: const EdgeInsets.all(10.0),
|
shape: BoxShape.rectangle,
|
||||||
child: Container(
|
borderRadius: BorderRadius.circular(20.0),
|
||||||
height: MediaQuery.of(context).size.height * 0.6,
|
/*image: i.source_ != null ? new DecorationImage(
|
||||||
width: MediaQuery.of(context).size.width * 0.72,
|
fit: BoxFit.cover,
|
||||||
/*decoration: BoxDecoration(
|
image: new NetworkImage(
|
||||||
color: kBackgroundLight,
|
i.source_,
|
||||||
shape: BoxShape.rectangle,
|
),
|
||||||
borderRadius: BorderRadius.circular(20.0),
|
): null,*/
|
||||||
/*image: i.source_ != null ? new DecorationImage(
|
boxShadow: [
|
||||||
fit: BoxFit.cover,
|
BoxShadow(
|
||||||
image: new NetworkImage(
|
color: kBackgroundSecondGrey,
|
||||||
i.source_,
|
spreadRadius: 0.5,
|
||||||
),
|
blurRadius: 5,
|
||||||
): null,*/
|
offset: Offset(0, 1.5), // changes position of shadow
|
||||||
boxShadow: [
|
),
|
||||||
BoxShadow(
|
],
|
||||||
color: kBackgroundSecondGrey,
|
),*/
|
||||||
spreadRadius: 0.5,
|
child: Stack(
|
||||||
blurRadius: 5,
|
children: [
|
||||||
offset: Offset(0, 1.5), // changes position of shadow
|
getElementForResource(appContext, i),
|
||||||
),
|
Positioned(
|
||||||
],
|
bottom: 0,
|
||||||
),*/
|
right: 0,
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
getElementForResource(appContext, i),
|
|
||||||
Positioned(
|
|
||||||
bottom: 0,
|
|
||||||
right: 0,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(15.0),
|
|
||||||
child: HtmlWidget(
|
|
||||||
i.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "",
|
|
||||||
textStyle: TextStyle(fontSize: kIsWeb ? kWebTitleSize : kTitleSize, color: kBackgroundLight),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
),/**/
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 10),
|
|
||||||
child: Container(
|
|
||||||
width: MediaQuery.of(context).size.width *0.65,
|
|
||||||
height: MediaQuery.of(context).size.height *0.25,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: kBackgroundLight,
|
|
||||||
shape: BoxShape.rectangle,
|
|
||||||
borderRadius: BorderRadius.circular(10.0),
|
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: kBackgroundSecondGrey,
|
|
||||||
spreadRadius: 0.3,
|
|
||||||
blurRadius: 4,
|
|
||||||
offset: Offset(0, 2), // changes position of shadow
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(15.0),
|
padding: const EdgeInsets.all(15.0),
|
||||||
child: HtmlWidget(
|
child: HtmlWidget(
|
||||||
i.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "",
|
i.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.title!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "",
|
||||||
textStyle: TextStyle(fontSize: kIsWeb ? kWebDescriptionSize : kDescriptionSize),
|
textStyle: TextStyle(fontSize: kIsWeb ? kWebTitleSize : kTitleSize, color: kBackgroundLight),
|
||||||
customStylesBuilder: (element) {
|
|
||||||
return {'text-align': 'center'};
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
),/**/
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 10),
|
||||||
|
child: Container(
|
||||||
|
width: MediaQuery.of(context).size.width *0.65,
|
||||||
|
height: MediaQuery.of(context).size.height *0.25,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: kBackgroundLight,
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: kBackgroundSecondGrey,
|
||||||
|
spreadRadius: 0.3,
|
||||||
|
blurRadius: 4,
|
||||||
|
offset: Offset(0, 2), // changes position of shadow
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(15.0),
|
||||||
|
child: HtmlWidget(
|
||||||
|
i.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value != null ? i.description!.firstWhere((translation) => translation.language == appContext.getContext().language).value! : "",
|
||||||
|
textStyle: TextStyle(fontSize: kIsWeb ? kWebDescriptionSize : kDescriptionSize),
|
||||||
|
customStylesBuilder: (element) {
|
||||||
|
return {'text-align': 'center'};
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
)
|
),
|
||||||
);
|
],
|
||||||
},
|
)
|
||||||
);
|
);
|
||||||
}).toList(),
|
},
|
||||||
),
|
);
|
||||||
],
|
}).toList(),
|
||||||
),
|
),
|
||||||
if(sliderDTO.contents != null && sliderDTO.contents!.length > 1)
|
if(sliderDTO.contents != null && sliderDTO.contents!.length > 1)
|
||||||
Positioned(
|
Positioned(
|
||||||
top: MediaQuery.of(context).size.height * 0.35,
|
top: MediaQuery.of(context).size.height * 0.35,
|
||||||
@ -211,9 +203,14 @@ class _SliderView extends State<SliderView> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
sliderController!.previousPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
|
sliderController!.previousPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: ValueListenableBuilder<int>(
|
||||||
currentIndex.toString()+'/'+sliderDTO.contents!.length.toString(),
|
valueListenable: currentIndex,
|
||||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w500),
|
builder: (context, value, _) {
|
||||||
|
return Text(
|
||||||
|
value.toString()+'/'+sliderDTO.contents!.length.toString(),
|
||||||
|
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w500),
|
||||||
|
);
|
||||||
|
}
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -250,10 +247,6 @@ class _SliderView extends State<SliderView> {
|
|||||||
|
|
||||||
getElementForResource(AppContext appContext, ContentDTO i) {
|
getElementForResource(AppContext appContext, ContentDTO i) {
|
||||||
var widgetToInclude;
|
var widgetToInclude;
|
||||||
print("TTTTTTTTTTTTTTESSSSSSSSSSSt CONTENTR");
|
|
||||||
print(i);
|
|
||||||
print(i.resourceUrl);
|
|
||||||
print(i.resourceType);
|
|
||||||
|
|
||||||
switch(i.resourceType) {
|
switch(i.resourceType) {
|
||||||
case ResourceType.Image:
|
case ResourceType.Image:
|
||||||
@ -274,13 +267,17 @@ class _SliderView extends State<SliderView> {
|
|||||||
case ResourceType.Video:
|
case ResourceType.Video:
|
||||||
case ResourceType.VideoUrl:
|
case ResourceType.VideoUrl:
|
||||||
case ResourceType.Audio:
|
case ResourceType.Audio:
|
||||||
widgetToInclude = showElementForResource(ResourceDTO(id: i.resourceId, url: i.resourceUrl, type: i.resourceType), appContext);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
print("TTTTTTTTTTTTTTESSSSSSSSSSSt");
|
|
||||||
print(widgetToInclude);
|
|
||||||
|
|
||||||
return Center(
|
return Center(
|
||||||
child: Container(
|
child: Container(
|
||||||
height: MediaQuery.of(context).size.height * 0.6,
|
height: MediaQuery.of(context).size.height * 0.6,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user