Add photoView to slider and marker view + set constant for font size

This commit is contained in:
Thomas Fransolet 2021-10-15 16:38:54 +02:00
parent 0e73b57312
commit 43b404c03c
9 changed files with 105 additions and 35 deletions

View File

@ -147,7 +147,8 @@ class _ConfigViewWidget extends State<ConfigViewWidget> {
text: "OK", text: "OK",
fontSize: 25, fontSize: 25,
press: () async { press: () async {
var client = Client(url); var client = new Client(url);
print(url);
var isOk = await isValidApi(client); var isOk = await isValidApi(client);
if (isOk) { if (isOk) {
Fluttertoast.showToast( Fluttertoast.showToast(
@ -254,6 +255,7 @@ class _ConfigViewWidget extends State<ConfigViewWidget> {
var configs = await client.configurationApi.configurationGet(); var configs = await client.configurationApi.configurationGet();
return configs != null; return configs != null;
} catch (ex) { } catch (ex) {
print(ex);
return false; return false;
} }
} }

View File

@ -114,7 +114,7 @@ class _MainViewWidget extends State<MainViewWidget> {
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: AutoSizeText( child: AutoSizeText(
sectionSelected.title.firstWhere((translation) => translation.language == appContext.getContext().language).value, sectionSelected.title.firstWhere((translation) => translation.language == appContext.getContext().language).value,
style: new TextStyle(fontSize: 25), style: new TextStyle(fontSize: kSectionTitleDetailSize),
maxLines: 1, maxLines: 1,
), ),
) )
@ -124,7 +124,7 @@ class _MainViewWidget extends State<MainViewWidget> {
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: AutoSizeText( child: AutoSizeText(
sectionSelected.description.firstWhere((translation) => translation.language == appContext.getContext().language).value, sectionSelected.description.firstWhere((translation) => translation.language == appContext.getContext().language).value,
style: new TextStyle(fontSize: 20), style: new TextStyle(fontSize: kSectionDescriptionDetailSize),
maxLines: 2, maxLines: 2,
), ),
) )
@ -164,8 +164,8 @@ class _MainViewWidget extends State<MainViewWidget> {
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.endTop, floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
floatingActionButton: Container( floatingActionButton: Container(
height: 150.0, height: 185.0,
width: 150.0, width: 185.0,
child: FittedBox( child: FittedBox(
child: FloatingActionButton.extended( child: FloatingActionButton.extended(
onPressed: () { onPressed: () {
@ -226,7 +226,7 @@ class _MainViewWidget extends State<MainViewWidget> {
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: AutoSizeText( child: AutoSizeText(
snapshot.data[index].title.firstWhere((translation) => translation.language == appContext.getContext().language).value, snapshot.data[index].title.firstWhere((translation) => translation.language == appContext.getContext().language).value,
style: new TextStyle(fontSize: 25), style: new TextStyle(fontSize: kMenuTitleDetailSize),
maxLines: 1, maxLines: 1,
), ),
), ),
@ -234,7 +234,7 @@ class _MainViewWidget extends State<MainViewWidget> {
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: AutoSizeText( child: AutoSizeText(
snapshot.data[index].description.firstWhere((translation) => translation.language == appContext.getContext().language).value, snapshot.data[index].description.firstWhere((translation) => translation.language == appContext.getContext().language).value,
style: new TextStyle(fontSize: 18, fontFamily: ""), style: new TextStyle(fontSize: kMenuDescriptionDetailSize, fontFamily: ""),
maxLines: 1, maxLines: 1,
), ),
), ),
@ -294,7 +294,7 @@ boxDecoration(SectionDTO section, bool isSelected) {
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(30.0), borderRadius: BorderRadius.circular(30.0),
image: section.imageSource != null ? new DecorationImage( image: section.imageSource != null ? new DecorationImage(
fit: BoxFit.cover, fit: !isSelected? BoxFit.cover : BoxFit.contain,
colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(0.5), BlendMode.dstATop) : null, colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(0.5), BlendMode.dstATop) : null,
image: new NetworkImage( image: new NetworkImage(
section.imageSource, section.imageSource,

View File

@ -1,5 +1,6 @@
import 'package:carousel_slider/carousel_slider.dart'; import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:tablet_app/Models/map-marker.dart'; import 'package:tablet_app/Models/map-marker.dart';
@ -83,7 +84,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: 30)), child: Text(mapContext.getSelectedMarker().title, style: TextStyle(fontWeight: FontWeight.w600, fontSize: kTitleSize)),
), ),
), ),
Padding( Padding(
@ -106,12 +107,12 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
return Padding( return Padding(
padding: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0),
child: Container( child: Container(
width: MediaQuery.of(context).size.width, //width: MediaQuery.of(context).size.width *0.9,
decoration: BoxDecoration( /*decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0), borderRadius: BorderRadius.circular(20.0),
border: Border.all(width: 0.3, color: kSecondGrey), border: Border.all(width: 0.3, color: kSecondGrey),
image: i.imageSource != null ? new DecorationImage( image: i.imageSource != null ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.contain,
image: new NetworkImage( image: new NetworkImage(
i.imageSource, i.imageSource,
), ),
@ -124,7 +125,24 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
offset: Offset(0, 1.1), // changes position of shadow offset: Offset(0, 1.1), // changes position of shadow
), ),
], ],
),*/
child: AspectRatio(
aspectRatio: 16 / 9,
child: ClipRect(
child: PhotoView(
imageProvider: 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),
),
),
),
)
), ),
); );
}, },
@ -136,7 +154,7 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
height: mapContext.getSelectedMarker().images != null && mapContext.getSelectedMarker().images.length > 0 ? size.height *0.3 : size.height *0.6, height: mapContext.getSelectedMarker().images != null && mapContext.getSelectedMarker().images.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.35,
decoration: BoxDecoration( decoration: BoxDecoration(
color: kBackgroundLight, color: kBackgroundColor,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(10.0), borderRadius: BorderRadius.circular(10.0),
boxShadow: [ boxShadow: [
@ -151,7 +169,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: 15)), child: Text(mapContext.getSelectedMarker().description, textAlign: TextAlign.center, style: TextStyle(fontSize: kDescriptionSize)),
), ),
), ),
), ),

View File

@ -123,7 +123,7 @@ class _MenuViewWidget extends State<MenuViewWidget> {
), ),
child: Icon( child: Icon(
Icons.arrow_back, Icons.arrow_back,
size: 70, size: 95,
color: kMainGrey, color: kMainGrey,
), ),
), ),
@ -159,7 +159,7 @@ class _MenuViewWidget extends State<MenuViewWidget> {
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: AutoSizeText( child: AutoSizeText(
menuDTO.sections[index].title.firstWhere((translation) => translation.language == appContext.getContext().language).value, menuDTO.sections[index].title.firstWhere((translation) => translation.language == appContext.getContext().language).value,
style: new TextStyle(fontSize: 25), style: new TextStyle(fontSize: kMenuTitleDetailSize),
maxLines: 1, maxLines: 1,
), ),
), ),
@ -167,7 +167,7 @@ class _MenuViewWidget extends State<MenuViewWidget> {
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: AutoSizeText( child: AutoSizeText(
menuDTO.sections[index].description.firstWhere((translation) => translation.language == appContext.getContext().language).value, menuDTO.sections[index].description.firstWhere((translation) => translation.language == appContext.getContext().language).value,
style: new TextStyle(fontSize: 18, fontFamily: ""), style: new TextStyle(fontSize: kSectionDescriptionDetailSize, fontFamily: ""),
maxLines: 1, maxLines: 1,
), ),
), ),
@ -190,7 +190,7 @@ boxDecoration(SectionDTO section, bool isSelected) {
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(30.0), borderRadius: BorderRadius.circular(30.0),
image: section.imageSource != null ? new DecorationImage( image: section.imageSource != null ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.contain,
colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(0.5), BlendMode.dstATop) : null, colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(0.5), BlendMode.dstATop) : null,
image: new NetworkImage( image: new NetworkImage(
section.imageSource, section.imageSource,

View File

@ -6,6 +6,7 @@ import 'package:managerapi/api.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.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:photo_view/photo_view.dart';
class SliderViewWidget extends StatefulWidget { class SliderViewWidget extends StatefulWidget {
final SectionDTO section; final SectionDTO section;
@ -81,16 +82,16 @@ class _SliderViewWidget extends State<SliderViewWidget> {
child: Container( child: Container(
height: MediaQuery.of(context).size.height * 0.6, height: MediaQuery.of(context).size.height * 0.6,
width: MediaQuery.of(context).size.width * 0.72, width: MediaQuery.of(context).size.width * 0.72,
decoration: BoxDecoration( /*decoration: BoxDecoration(
color: kBackgroundLight, color: kBackgroundLight,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(20.0), borderRadius: BorderRadius.circular(20.0),
image: i.source_ != null ? new DecorationImage( /*image: i.source_ != null ? new DecorationImage(
fit: BoxFit.cover, fit: BoxFit.cover,
image: new NetworkImage( image: new NetworkImage(
i.source_, i.source_,
), ),
): null, ): null,*/
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: kBackgroundSecondGrey, color: kBackgroundSecondGrey,
@ -99,13 +100,42 @@ class _SliderViewWidget extends State<SliderViewWidget> {
offset: Offset(0, 1.5), // changes position of shadow offset: Offset(0, 1.5), // changes position of shadow
), ),
], ],
),*/
child: Stack(
children: [
Center(
child: Container(
height: MediaQuery.of(context).size.height * 0.6,
width: MediaQuery.of(context).size.width * 0.72,
child: AspectRatio(
aspectRatio: 16 / 9,
child: ClipRect(
child: PhotoView(
imageProvider: new NetworkImage(
i.source_,
), ),
child: Align( minScale: PhotoViewComputedScale.contained * 0.8,
alignment: Alignment.bottomRight, maxScale: PhotoViewComputedScale.contained * 3.0,
backgroundDecoration: BoxDecoration(
color: kBackgroundSecondGrey,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(15.0),
),
),
),
),
),
),
Positioned(
bottom: 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: 35, 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: kTitleSize, color: kBackgroundLight)),
)), )
)
]
),/**/
), ),
), ),
Expanded( Expanded(
@ -130,7 +160,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: 15)), 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)),
), ),
), ),
), ),
@ -194,7 +224,7 @@ class _SliderViewWidget extends State<SliderViewWidget> {
), ),
), ),
if(sliderDTO.images == null || sliderDTO.images.length == 0) if(sliderDTO.images == null || sliderDTO.images.length == 0)
Center(child: Text("Aucune image à afficher")) Center(child: Text("Aucune image à afficher", style: TextStyle(fontSize: kNoneInfoOrIncorrect),))
// Description // Description
/*Container( /*Container(
height: sliderDTO.images != null && sliderDTO.images.length > 0 ? size.height *0.3 : size.height *0.6, height: sliderDTO.images != null && sliderDTO.images.length > 0 ? size.height *0.3 : size.height *0.6,

View File

@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:managerapi/api.dart'; import 'package:managerapi/api.dart';
import 'package:tablet_app/constants.dart';
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 {
@ -58,5 +59,5 @@ class _VideoViewWidget extends State<VideoViewWidget> {
} }
@override @override
Widget build(BuildContext context) => videoDTO.source_ != null && videoDTO.source_.length > 0 ? _videoView : Center(child: Text("La vidéo ne peut pas être affichée, l'url est incorrecte")); Widget build(BuildContext context) => videoDTO.source_ != null && videoDTO.source_.length > 0 ? _videoView : Center(child: Text("La vidéo ne peut pas être affichée, l'url est incorrecte", style: new TextStyle(fontSize: kNoneInfoOrIncorrect),));
} }

View File

@ -16,6 +16,17 @@ const kBackgroundLight = Color(0xfff3f3f3);
const List<String> languages = ["FR", "NL", "EN", "DE"]; const List<String> languages = ["FR", "NL", "EN", "DE"];
const kTitleSize = 40.0;
const kDescriptionSize = 25.0;
const kSectionTitleDetailSize = 50.0;
const kSectionDescriptionDetailSize = 35.0;
const kMenuTitleDetailSize = 45.0;
const kMenuDescriptionDetailSize = 28.0;
const kNoneInfoOrIncorrect = 35.0;
/* /*
const kTextStyle = TextStyle( const kTextStyle = TextStyle(
fontSize: 23, fontSize: 23,

View File

@ -7,7 +7,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.8.1" version: "2.8.2"
auto_size_text: auto_size_text:
dependency: "direct main" dependency: "direct main"
description: description:
@ -35,7 +35,7 @@ packages:
name: characters name: characters
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.2.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
@ -211,7 +211,7 @@ packages:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.10" version: "0.12.11"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -254,6 +254,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.11.1" version: "1.11.1"
photo_view:
dependency: "direct main"
description:
name: photo_view
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.0"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -342,7 +349,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.2" version: "0.4.3"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:

View File

@ -36,6 +36,7 @@ dependencies:
carousel_slider: ^4.0.0 carousel_slider: ^4.0.0
youtube_player_flutter: ^7.0.0+7 youtube_player_flutter: ^7.0.0+7
mqtt_client: ^8.1.0 mqtt_client: ^8.1.0
photo_view: ^0.13.0
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.