Add loading
This commit is contained in:
parent
ec4f9160ce
commit
6a31a039a0
@ -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<Loading> createState() => _LoadingState();
|
||||
}
|
||||
|
||||
class _LoadingState extends State<Loading> 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),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -17,15 +17,6 @@ class _ScannerBoutonState extends State<ScannerBouton> {
|
||||
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(),
|
||||
));
|
||||
}*/
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ class _ScannerTESTState extends State<ScannerTEST> {
|
||||
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<ScannerTEST> {
|
||||
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<ScannerTEST> {
|
||||
key: qrKey,
|
||||
onQRViewCreated: _onQRViewCreated,
|
||||
overlay: QrScannerOverlayShape(
|
||||
borderColor: kMainColor,
|
||||
borderColor: kBlue1,
|
||||
borderRadius: 10,
|
||||
borderLength: 25,
|
||||
borderWidth: 5,
|
||||
|
||||
@ -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<ResourceModel?> resources;
|
||||
@ -34,7 +31,6 @@ class _SliderImagesWidget extends State<SliderImagesWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
return Stack(
|
||||
children: [
|
||||
@ -51,7 +47,7 @@ class _SliderImagesWidget extends State<SliderImagesWidget> {
|
||||
currentIndex = index + 1;
|
||||
});
|
||||
},
|
||||
height: widget.height * 0.95,
|
||||
// height: widget.height * 0.95,
|
||||
enlargeCenterPage: true,
|
||||
reverse: false,
|
||||
),
|
||||
@ -59,20 +55,11 @@ class _SliderImagesWidget extends State<SliderImagesWidget> {
|
||||
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,
|
||||
//color: Colors.red,
|
||||
//height: widget.height * 1,
|
||||
//width: size.width * 0.95,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(35.0),
|
||||
borderRadius: BorderRadius.circular(15.0),
|
||||
child: Image.memory(base64Decode(i!.data!))/*PhotoView(
|
||||
imageProvider: Image.memory(base64Decode(i!.data!)).image,
|
||||
minScale: PhotoViewComputedScale.contained * 0.8,
|
||||
@ -84,45 +71,6 @@ class _SliderImagesWidget extends State<SliderImagesWidget> {
|
||||
),
|
||||
)*/,
|
||||
),
|
||||
),
|
||||
),/*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<SliderImagesWidget> {
|
||||
child: const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 45,
|
||||
color: kMainColor,
|
||||
color: kBlue2,
|
||||
),
|
||||
)
|
||||
),
|
||||
@ -158,7 +106,7 @@ class _SliderImagesWidget extends State<SliderImagesWidget> {
|
||||
child: const Icon(
|
||||
Icons.chevron_left,
|
||||
size: 45,
|
||||
color: kMainColor,
|
||||
color: kBlue2,
|
||||
),
|
||||
)
|
||||
),
|
||||
@ -173,7 +121,7 @@ class _SliderImagesWidget extends State<SliderImagesWidget> {
|
||||
},
|
||||
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),
|
||||
),
|
||||
)
|
||||
),
|
||||
|
||||
@ -28,7 +28,6 @@ class ArticlePage extends StatefulWidget {
|
||||
class _ArticlePageState extends State<ArticlePage> {
|
||||
SectionDTO? sectionDTO;
|
||||
ArticleDTO? articleDTO;
|
||||
ResourceModel? mainResource;
|
||||
List<ResourceModel?> resourcesModel = <ResourceModel?>[];
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
|
||||
@ -132,11 +131,11 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||
|
||||
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<ArticlePage> {
|
||||
|
||||
|
||||
|
||||
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,24 +177,23 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||
}
|
||||
|
||||
Widget getContent(Size size, AppContext appContext) {
|
||||
return SizedBox(
|
||||
return Expanded(
|
||||
child: Container(
|
||||
width: size.width,
|
||||
height: size.height * 0.49,
|
||||
//height: size.height * 0.65,
|
||||
//color: Colors.blueAccent,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0),
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0, top: 8.0, bottom: 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: SingleChildScrollView(
|
||||
child: Padding(
|
||||
@ -212,6 +207,7 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -228,20 +224,24 @@ class _ArticlePageState extends State<ArticlePage> {
|
||||
});
|
||||
if(sectionDTO!.imageId != null) {
|
||||
await DatabaseHelper.instance.queryWithId(DatabaseTableType.resources, sectionDTO!.imageId!).then((value) {
|
||||
mainResource = DatabaseHelper.instance.getResourceFromDB(value.first);
|
||||
});
|
||||
}
|
||||
if(articleDTO!.images!.isNotEmpty) {
|
||||
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));
|
||||
});
|
||||
}
|
||||
if(articleDTO!.images!.isNotEmpty) {
|
||||
print(articleDTO!.images!.length);
|
||||
print("LOADING IMAGES !!!");
|
||||
|
||||
for (var image in articleDTO!.images!) {
|
||||
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) {
|
||||
mainResource = resourcesModel.first;
|
||||
}
|
||||
|
||||
/*if(mainResource == null && resourcesModel.isNotEmpty) {
|
||||
mainResource = resourcesModel.first;
|
||||
}*/
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
@ -35,11 +35,11 @@ class _HomePageState extends State<HomePage> {
|
||||
final appContext = Provider.of<AppContext>(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<HomePage> {
|
||||
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<HomePage> {
|
||||
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<HomePage> {
|
||||
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<HomePage> {
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@ -81,7 +81,7 @@ class _BodyState extends State<Body> {
|
||||
builder: (context, AsyncSnapshot<dynamic> 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(
|
||||
|
||||
@ -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,
|
||||
),*/
|
||||
)
|
||||
),
|
||||
//),
|
||||
),
|
||||
|
||||
@ -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
|
||||
);
|
||||
|
||||
/*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user