diff --git a/lib/Components/Loading.dart b/lib/Components/Loading.dart index 4bc123a..096b0be 100644 --- a/lib/Components/Loading.dart +++ b/lib/Components/Loading.dart @@ -1,16 +1,51 @@ import 'package:flutter/material.dart'; import 'package:mymuseum_visitapp/constants.dart'; -class Loading extends StatelessWidget { +class Loading extends StatefulWidget { const Loading({Key? key}) : super(key: key); + @override + State createState() => _LoadingState(); +} + +class _LoadingState extends State with TickerProviderStateMixin { + late AnimationController _controller; + + @override + void initState() { + _controller = AnimationController( + duration: const Duration(milliseconds: 5000), + vsync: this, + )..repeat(); + /*_controller = widget.tween.animate( + CurvedAnimation(parent: _controller, curve: Curves.easeIn));*/ + + + super.initState(); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { - return Container( - height: 85.0, - width: 85.0, - child: const Center( - child: Text("Loading.."), + Size size = MediaQuery.of(context).size; + _controller.forward(from: 0.0); + _controller.addListener(() { + if (_controller.isCompleted) { + _controller.reverse(); + } + if(_controller.isDismissed){ + _controller.forward(); + } + }); + return Center( + child: RotationTransition( + turns: Tween(begin: 0.0, end: 3.0).animate(_controller), + child: Icon(Icons.museum_outlined, color: kBlue2, size: size.height*0.05), ), ); } diff --git a/lib/Components/ScannerBouton.dart b/lib/Components/ScannerBouton.dart index a96bdf6..53a0e8a 100644 --- a/lib/Components/ScannerBouton.dart +++ b/lib/Components/ScannerBouton.dart @@ -17,15 +17,6 @@ class _ScannerBoutonState extends State { void _onItemTapped() { setState(() { showScannerDialog(context); - /*if(widget.isReplacement) { - Navigator.of(context).pushReplacement(MaterialPageRoute( - builder: (context) => const ScannerPage(), - )); - } else { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) => const ScannerPage(), - )); - }*/ }); } diff --git a/lib/Components/ScannerDialog.dart b/lib/Components/ScannerDialog.dart index 13e5853..c0f43d3 100644 --- a/lib/Components/ScannerDialog.dart +++ b/lib/Components/ScannerDialog.dart @@ -52,7 +52,7 @@ class _ScannerTESTState extends State { height: 45, decoration: BoxDecoration( shape: BoxShape.rectangle, - color: kMainColor, + color: kBlue1, borderRadius: BorderRadius.circular(20.0), ), margin: const EdgeInsets.all(8), @@ -77,7 +77,7 @@ class _ScannerTESTState extends State { height: 45, decoration: BoxDecoration( shape: BoxShape.rectangle, - color: kMainColor, + color: kBlue1, borderRadius: BorderRadius.circular(20.0), ), margin: const EdgeInsets.all(8), @@ -198,7 +198,7 @@ class _ScannerTESTState extends State { key: qrKey, onQRViewCreated: _onQRViewCreated, overlay: QrScannerOverlayShape( - borderColor: kMainColor, + borderColor: kBlue1, borderRadius: 10, borderLength: 25, borderWidth: 5, diff --git a/lib/Components/SliderImages.dart b/lib/Components/SliderImages.dart index 3ffc17f..c3035eb 100644 --- a/lib/Components/SliderImages.dart +++ b/lib/Components/SliderImages.dart @@ -1,11 +1,8 @@ import 'dart:convert'; import 'package:carousel_slider/carousel_slider.dart'; -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:mymuseum_visitapp/Models/resourceModel.dart'; -import 'package:mymuseum_visitapp/app_context.dart'; import 'package:mymuseum_visitapp/constants.dart'; -import 'package:provider/provider.dart'; class SliderImagesWidget extends StatefulWidget { final List resources; @@ -34,7 +31,6 @@ class _SliderImagesWidget extends State { @override Widget build(BuildContext context) { - final appContext = Provider.of(context); Size size = MediaQuery.of(context).size; return Stack( children: [ @@ -51,7 +47,7 @@ class _SliderImagesWidget extends State { currentIndex = index + 1; }); }, - height: widget.height * 0.95, + // height: widget.height * 0.95, enlargeCenterPage: true, reverse: false, ), @@ -59,70 +55,22 @@ class _SliderImagesWidget extends State { return Builder( builder: (BuildContext context) { return Container( - width: size.width, - height: widget.height, - /*decoration: BoxDecoration( - //color: appContext.getContext().configuration == null ? kBackgroundGrey : appContext.getContext().configuration.secondaryColor != null ? new Color(int.parse(appContext.getContext().configuration.secondaryColor.split('(0x')[1].split(')')[0], radix: 16)): kBackgroundGrey, - borderRadius: BorderRadius.circular(5.0), - //border: Border.all(width: 0.3, color: kSecondGrey), - ),*/ - child: Container( - height: widget.height * 1, - width: size.width * 0.95, - child: AspectRatio( - aspectRatio: 16 / 9, - child: ClipRRect( - borderRadius: BorderRadius.circular(35.0), - child: Image.memory(base64Decode(i!.data!))/*PhotoView( - imageProvider: Image.memory(base64Decode(i!.data!)).image, - minScale: PhotoViewComputedScale.contained * 0.8, - maxScale: PhotoViewComputedScale.contained * 3.0, - backgroundDecoration: BoxDecoration( - color: Colors.transparent, - /*shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(15.0),*/ - ), - )*/, - ), + //color: Colors.red, + //height: widget.height * 1, + //width: size.width * 0.95, + child: ClipRRect( + borderRadius: BorderRadius.circular(15.0), + child: Image.memory(base64Decode(i!.data!))/*PhotoView( + imageProvider: Image.memory(base64Decode(i!.data!)).image, + minScale: PhotoViewComputedScale.contained * 0.8, + maxScale: PhotoViewComputedScale.contained * 3.0, + backgroundDecoration: BoxDecoration( + color: Colors.transparent, + /*shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(15.0),*/ ), - ),/*Column( - //crossAxisAlignment: CrossAxisAlignment.center, - //mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Padding( - padding: const EdgeInsets.all(10.0), - child: Container( - height: widget.height * 0.5, - width: size.width * 1, - child: Stack( - children: [ - Center( - child: /*Container( - height: widget.height * 1, - width: size.width * 0.95, - child: AspectRatio( - aspectRatio: 16 / 9, - child: ClipRect( - child: PhotoView( - imageProvider: Image.memory(base64Decode(i!.data!)).image, - minScale: PhotoViewComputedScale.contained * 0.8, - maxScale: PhotoViewComputedScale.contained * 3.0, - backgroundDecoration: BoxDecoration( - color: kBackgroundSecondGrey, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(15.0), - ), - ), - ), - ), - ),*/ - ), - ] - ), - ), - ), - ], - )*/ + )*/, + ), ); }, ); @@ -141,7 +89,7 @@ class _SliderImagesWidget extends State { child: const Icon( Icons.chevron_right, size: 45, - color: kMainColor, + color: kBlue2, ), ) ), @@ -158,7 +106,7 @@ class _SliderImagesWidget extends State { child: const Icon( Icons.chevron_left, size: 45, - color: kMainColor, + color: kBlue2, ), ) ), @@ -173,7 +121,7 @@ class _SliderImagesWidget extends State { }, child: Text( currentIndex.toString()+'/'+widget.resources.length.toString(), - style: const TextStyle(fontSize: kArticleContentSize, fontWeight: FontWeight.w500, color: kMainColor), + style: const TextStyle(fontSize: kArticleContentSize, fontWeight: FontWeight.w500, color: kBlue2), ), ) ), diff --git a/lib/Screens/Article/article.dart b/lib/Screens/Article/article.dart index f10f71c..ec3159f 100644 --- a/lib/Screens/Article/article.dart +++ b/lib/Screens/Article/article.dart @@ -28,7 +28,6 @@ class ArticlePage extends StatefulWidget { class _ArticlePageState extends State { SectionDTO? sectionDTO; ArticleDTO? articleDTO; - ResourceModel? mainResource; List resourcesModel = []; final GlobalKey _scaffoldKey = GlobalKey(); @@ -132,11 +131,11 @@ class _ArticlePageState extends State { if(articleDTO!.isContentTop!) getContent(size, appContext), - if(articleDTO!.isContentTop!) - getImages(size), + if(articleDTO!.isContentTop! && resourcesModel.isNotEmpty) + getImages(size, articleDTO!.isContentTop!), - if(!articleDTO!.isContentTop!) - getImages(size), + if(!articleDTO!.isContentTop! && resourcesModel.isNotEmpty) + getImages(size, articleDTO!.isContentTop!), if(!articleDTO!.isContentTop!) getContent(size, appContext), @@ -154,25 +153,22 @@ class _ArticlePageState extends State { - Widget getImages(Size size) { + Widget getImages(Size size, bool isContentTop) { return SizedBox( width: size.width, height: size.height * 0.3, child: Padding( - padding: const EdgeInsets.all(8.0), + padding: isContentTop ? const EdgeInsets.only(left: 8.0, right: 8.0, bottom: 8.0): const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0), child: Container( decoration: BoxDecoration( - color: kBackgroundGrey, + border: Border.all( + color: kBlue2, + width: 0.5, + ), + color: Colors.white, shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(5.0), - boxShadow: const [ - BoxShadow( - color: kBackgroundGrey, - spreadRadius: 0.15, - blurRadius: 3.5, - offset: Offset(0, 1), // changes position of shadow - ), - ], + boxShadow: const [kDefaultShadow], ), child: SliderImagesWidget(resources: resourcesModel, height: size.height * 0.29) ) @@ -181,37 +177,37 @@ class _ArticlePageState extends State { } Widget getContent(Size size, AppContext appContext) { - return SizedBox( - width: size.width, - height: size.height * 0.49, - child: Padding( - padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0), - child: Container( - decoration: BoxDecoration( - color: kBackgroundGrey, - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(5.0), - boxShadow: const [ - BoxShadow( - color: kBackgroundGrey, - spreadRadius: 0.15, - blurRadius: 3.5, - offset: Offset(0, 1), // changes position of shadow - ), - ], - ), - child: SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - TranslationHelper.get(articleDTO!.content, appContext), - textAlign: TextAlign.left, - style: const TextStyle(fontSize: kArticleContentSize) + return Expanded( + child: Container( + width: size.width, + //height: size.height * 0.65, + //color: Colors.blueAccent, + child: Padding( + padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0, bottom: 8.0), + child: Container( + decoration: BoxDecoration( + border: Border.all( + color: kBlue2, + width: 0.5, ), + color: Colors.white, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(5.0), + boxShadow: const [kDefaultShadow], ), - ) - ) - ) + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + TranslationHelper.get(articleDTO!.content, appContext), + textAlign: TextAlign.left, + style: const TextStyle(fontSize: kArticleContentSize) + ), + ), + ) + ) + ) + ), ); } @@ -228,20 +224,24 @@ class _ArticlePageState extends State { }); if(sectionDTO!.imageId != null) { await DatabaseHelper.instance.queryWithId(DatabaseTableType.resources, sectionDTO!.imageId!).then((value) { - mainResource = DatabaseHelper.instance.getResourceFromDB(value.first); + resourcesModel.add(DatabaseHelper.instance.getResourceFromDB(value.first)); }); } if(articleDTO!.images!.isNotEmpty) { + print(articleDTO!.images!.length); + print("LOADING IMAGES !!!"); + for (var image in articleDTO!.images!) { - print(image); await DatabaseHelper.instance.queryWithId(DatabaseTableType.resources, image.resourceId!).then((value) { resourcesModel.add(DatabaseHelper.instance.getResourceFromDB(value.first)); }); + print("LOADING DONEOJNEONEONONDONEONE !!!"); + } - if(mainResource == null && resourcesModel.isNotEmpty) { + /*if(mainResource == null && resourcesModel.isNotEmpty) { mainResource = resourcesModel.first; - } + }*/ } }); } else { diff --git a/lib/Screens/Home/home.dart b/lib/Screens/Home/home.dart index 6d22f07..66dd2db 100644 --- a/lib/Screens/Home/home.dart +++ b/lib/Screens/Home/home.dart @@ -35,11 +35,11 @@ class _HomePageState extends State { final appContext = Provider.of(context); return Scaffold( appBar: CustomAppBar( - title: "Home page - liste parcours", + title: "Liste des visites", // Todo translate isHomeButton: false, ), body: SingleChildScrollView( - child: Container( + child: SizedBox( width: size.width, height: size.height, child: FutureBuilder( @@ -96,7 +96,7 @@ class _HomePageState extends State { height: 45, decoration: BoxDecoration( shape: BoxShape.rectangle, - color: kMainColor, + color: kBlue1, borderRadius: BorderRadius.circular(20.0), ), margin: const EdgeInsets.all(8), @@ -107,11 +107,6 @@ class _HomePageState extends State { child: configurations[index].isOffline! && !alreadyDownloaded.any((c) => c == configurations[index].id) ? const Icon(Icons.download, color: Colors.white) : const Icon(Icons.refresh, color: Colors.white), ), - /*AutoSizeText( - configurations[index].isOffline.toString(), - style: const TextStyle(fontSize: kMenuDescriptionDetailSize, fontFamily: ""), - maxLines: 1, - ),*/ ) ) ], @@ -149,11 +144,10 @@ class _HomePageState extends State { alreadyDownloaded = configurations.map((c) => c.id).toList(); if(isOnline) { - //var client = new Client("http://192.168.31.140:8089"); // TODO REMOVE configurations = await client.configurationApi!.configurationGet(); return configurations ?? []; } else { - return configurations ?? []; // TODO return local list.. + return configurations ?? []; } } catch (e) { print(e); @@ -269,17 +263,21 @@ class _HomePageState extends State { } } -boxDecoration(ConfigurationDTO configuration, bool isSelected) { // TODO to change +boxDecoration(ConfigurationDTO configuration, bool isSelected) { return BoxDecoration( - color: kSecondColor, + color: Colors.white, shape: BoxShape.rectangle, borderRadius: BorderRadius.circular(20.0), - boxShadow: const [ + border: Border.all( + color: kBlue0.withOpacity(0.35), + width: 0.2, + ), + boxShadow: [ BoxShadow( - color: kSecondColor, - spreadRadius: 0.15, - blurRadius: 3.5, - offset: Offset(0, 1), // changes position of shadow + color: kBlue0.withOpacity(0.35), + //spreadRadius: 0.15, + blurRadius: 27, + offset: const Offset(0, 15), // changes position of shadow ), ], ); diff --git a/lib/Screens/Visit/components/body.dart b/lib/Screens/Visit/components/body.dart index 563be4e..b14db74 100644 --- a/lib/Screens/Visit/components/body.dart +++ b/lib/Screens/Visit/components/body.dart @@ -81,7 +81,7 @@ class _BodyState extends State { builder: (context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done) { return Padding( - padding: const EdgeInsets.only(top: 15), + padding: const EdgeInsets.only(top: 0), child: ListView.builder( itemCount: sectionsToDisplay.length, itemBuilder: (context, index) => SectionCard( diff --git a/lib/Screens/Visit/components/section_card.dart b/lib/Screens/Visit/components/section_card.dart index 9a405ac..290a40f 100644 --- a/lib/Screens/Visit/components/section_card.dart +++ b/lib/Screens/Visit/components/section_card.dart @@ -40,8 +40,10 @@ class SectionCard extends StatelessWidget { horizontal: kDefaultPadding, vertical: 0, ), - // color: Colors.blueAccent, height: 160, + decoration: const BoxDecoration( + boxShadow: [kDefaultShadow], + ), child: InkWell( onTap: press, child: Stack( @@ -53,7 +55,6 @@ class SectionCard extends StatelessWidget { decoration: BoxDecoration( borderRadius: BorderRadius.circular(22), color: itemIndex.isEven ? kBlue0 : kBlue1, - //boxShadow: const [kDefaultShadow], ), child: Container( margin: const EdgeInsets.only(right: 10), @@ -65,7 +66,6 @@ class SectionCard extends StatelessWidget { ), borderRadius: BorderRadius.circular(22), ), - ), ), // section main image @@ -103,10 +103,7 @@ class SectionCard extends StatelessWidget { ); } } - )/*Image.asset( - section.image, - fit: BoxFit.cover, - ),*/ + ) ), //), ), diff --git a/lib/constants.dart b/lib/constants.dart index 6412583..fee5101 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -51,7 +51,7 @@ const kNoneInfoOrIncorrect = 35.0; const kDefaultShadow = BoxShadow( offset: Offset(0, 15), blurRadius: 27, - color: Colors.black12, // Black color with 12% opacity + color: kBackgroundGrey, // Black color with 12% opacity ); /*