mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 00:21:19 +00:00
Menu view ..
This commit is contained in:
parent
65d6c648cd
commit
7a80a6ff8d
@ -1,6 +1,16 @@
|
||||
import 'dart:convert';
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:managerapi/api.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tablet_app/Models/map-marker.dart';
|
||||
import 'package:tablet_app/Screens/Map/map_context.dart';
|
||||
import 'package:tablet_app/Screens/Map/map_view.dart';
|
||||
import 'package:tablet_app/Screens/Slider/slider_view.dart';
|
||||
import 'package:tablet_app/Screens/Video/video_view.dart';
|
||||
import 'package:tablet_app/Screens/Web/web_view.dart';
|
||||
import 'package:tablet_app/app_context.dart';
|
||||
import 'package:tablet_app/constants.dart';
|
||||
|
||||
class MenuViewWidget extends StatefulWidget {
|
||||
final SectionDTO section;
|
||||
@ -12,6 +22,7 @@ class MenuViewWidget extends StatefulWidget {
|
||||
|
||||
class _MenuViewWidget extends State<MenuViewWidget> {
|
||||
MenuDTO menuDTO;
|
||||
SectionDTO selectedSection;
|
||||
@override
|
||||
void initState() {
|
||||
print(widget.section.data);
|
||||
@ -28,6 +39,170 @@ class _MenuViewWidget extends State<MenuViewWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(child: new Text("TODO Menu"));
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
Size size = MediaQuery.of(context).size;
|
||||
|
||||
if (selectedSection != null) {
|
||||
var elementToShow;
|
||||
switch (selectedSection.type) {
|
||||
case SectionType.map :
|
||||
elementToShow = ChangeNotifierProvider<MapContext>(
|
||||
create: (_) =>
|
||||
MapContext(new MapMarker(
|
||||
latitude: null,
|
||||
longitude: null,
|
||||
title: '',
|
||||
description: '')),
|
||||
child: MapViewWidget(section: selectedSection) /*FutureBuilder(
|
||||
future: _url,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) => snapshot.hasData
|
||||
? WebViewWidget(url: snapshot.data,)
|
||||
: CircularProgressIndicator()),*/
|
||||
);
|
||||
break;
|
||||
case SectionType.web : // WEB
|
||||
elementToShow = WebViewWidget(section: selectedSection);
|
||||
break;
|
||||
case SectionType.video : // Video
|
||||
elementToShow = VideoViewWidget(section: selectedSection);
|
||||
break;
|
||||
case SectionType.slider : // Slider:
|
||||
elementToShow = SliderViewWidget(section: selectedSection);
|
||||
break;
|
||||
default:
|
||||
elementToShow = Text('Hellow default');
|
||||
break;
|
||||
}
|
||||
return Stack(
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
width: size.width,
|
||||
height: size.height * 0.8,
|
||||
decoration: selectedSection.type != SectionType.video && selectedSection.type != SectionType.web && selectedSection.type != SectionType.slider && selectedSection.type != SectionType.map ? BoxDecoration(
|
||||
color: kBackgroundLight,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: kBackgroundSecondGrey,
|
||||
spreadRadius: 0.5,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 1.5), // changes position of shadow
|
||||
),
|
||||
],
|
||||
) : null,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 15.0, right: 15.0),
|
||||
child: elementToShow),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 5),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedSection = null;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: kBackgroundGrey,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: kBackgroundSecondGrey,
|
||||
spreadRadius: 0.5,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 1.5), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(
|
||||
Icons.arrow_back,
|
||||
size: 70,
|
||||
color: kMainGrey,
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Center(
|
||||
child: GridView.builder(
|
||||
shrinkWrap: true,
|
||||
gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 1.4),
|
||||
itemCount: menuDTO.sections.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedSection = menuDTO.sections[index];
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
decoration: boxDecoration(menuDTO.sections[index], false),
|
||||
padding: const EdgeInsets.all(25),
|
||||
margin: EdgeInsets.symmetric(vertical: 25, horizontal: 25),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: 0.4,
|
||||
child: Column(
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: AutoSizeText(
|
||||
menuDTO.sections[index].title.firstWhere((translation) => translation.language == appContext.getContext().language).value,
|
||||
style: new TextStyle(fontSize: 25),
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: AutoSizeText(
|
||||
menuDTO.sections[index].description.firstWhere((translation) => translation.language == appContext.getContext().language).value,
|
||||
style: new TextStyle(fontSize: 18, fontFamily: ""),
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boxDecoration(SectionDTO section, bool isSelected) {
|
||||
return BoxDecoration(
|
||||
color: kBackgroundLight,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
image: section.imageSource != null ? new DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(0.35), BlendMode.dstATop) : null,
|
||||
image: new NetworkImage(
|
||||
section.imageSource,
|
||||
),
|
||||
): null,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: kBackgroundSecondGrey,
|
||||
spreadRadius: 0.5,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 1.5), // changes position of shadow
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -104,7 +104,7 @@ class _SliderViewWidget extends State<SliderViewWidget> {
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Text(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: 35, color: kBackgroundLight)),
|
||||
)),
|
||||
),
|
||||
),
|
||||
@ -130,7 +130,7 @@ class _SliderViewWidget extends State<SliderViewWidget> {
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Text(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: 15)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user