mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 00:21:19 +00:00
Slider + change image layout in marker view (cover instead of contain)
This commit is contained in:
parent
880f717004
commit
65d6c648cd
@ -86,7 +86,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
||||
child: Container(
|
||||
/*width: 125,
|
||||
height: 125,*/
|
||||
decoration: boxDecoration(sectionSelected),
|
||||
decoration: boxDecoration(sectionSelected, true),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -126,11 +126,11 @@ class _MainViewWidget extends State<MainViewWidget> {
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 15.0, right: 15.0, top: 15.0),
|
||||
padding: sectionSelected.type != SectionType.slider ? const EdgeInsets.only(left: 15.0, right: 15.0, top: 15.0) : const EdgeInsets.only(top: 15.0),
|
||||
child: Container(
|
||||
width: size.width,
|
||||
height: size.height * 0.85,
|
||||
decoration: sectionSelected.type != SectionType.video && sectionSelected.type != SectionType.web ? BoxDecoration(
|
||||
decoration: sectionSelected.type != SectionType.video && sectionSelected.type != SectionType.web && sectionSelected.type != SectionType.slider && sectionSelected.type != SectionType.map ? BoxDecoration(
|
||||
color: kBackgroundLight,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(30.0),
|
||||
@ -151,10 +151,10 @@ class _MainViewWidget extends State<MainViewWidget> {
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
|
||||
floatingActionButton: Container(
|
||||
height: 130.0,
|
||||
width: 130.0,
|
||||
height: 150.0,
|
||||
width: 150.0,
|
||||
child: FittedBox(
|
||||
child: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
@ -184,10 +184,9 @@ class _MainViewWidget extends State<MainViewWidget> {
|
||||
child: FutureBuilder(
|
||||
future: getSections(appContext),
|
||||
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||
print('helloo test');
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.data == null) {
|
||||
return Text("ERROR CALL 0498/07.95.35");
|
||||
return Text("ERROR");
|
||||
}
|
||||
else {
|
||||
return GridView.builder(
|
||||
@ -202,7 +201,7 @@ class _MainViewWidget extends State<MainViewWidget> {
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
decoration: boxDecoration(snapshot.data[index]),
|
||||
decoration: boxDecoration(snapshot.data[index], false),
|
||||
padding: const EdgeInsets.all(25),
|
||||
margin: EdgeInsets.symmetric(vertical: 25, horizontal: 25),
|
||||
child: Align(
|
||||
@ -265,14 +264,14 @@ class _MainViewWidget extends State<MainViewWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
boxDecoration(SectionDTO section) {
|
||||
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: new ColorFilter.mode(Colors.black.withOpacity(0.6), BlendMode.dstATop),
|
||||
colorFilter: !isSelected? new ColorFilter.mode(Colors.black.withOpacity(0.35), BlendMode.dstATop) : null,
|
||||
image: new NetworkImage(
|
||||
section.imageSource,
|
||||
),
|
||||
|
||||
@ -105,17 +105,29 @@ class _MarkerInfoWidget extends State<MarkerViewWidget> {
|
||||
items: mapContext.getSelectedMarker().images.map<Widget>((i) {
|
||||
return Builder(
|
||||
builder: (BuildContext context) {
|
||||
return Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
margin: EdgeInsets.symmetric(horizontal: 5.0),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
border: Border.all(width: 0.3, color: kSecondGrey),
|
||||
),
|
||||
child: Image.network(
|
||||
i.imageSource,
|
||||
fit: BoxFit.contain
|
||||
)
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
border: Border.all(width: 0.3, color: kSecondGrey),
|
||||
image: i.imageSource != null ? new DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: new NetworkImage(
|
||||
i.imageSource,
|
||||
),
|
||||
): null,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: kBackgroundSecondGrey,
|
||||
spreadRadius: 0.3,
|
||||
blurRadius: 3,
|
||||
offset: Offset(0, 1.1), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
import 'dart:convert';
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:managerapi/api.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tablet_app/app_context.dart';
|
||||
import 'package:tablet_app/constants.dart';
|
||||
|
||||
class SliderViewWidget extends StatefulWidget {
|
||||
@ -14,11 +17,13 @@ class SliderViewWidget extends StatefulWidget {
|
||||
|
||||
class _SliderViewWidget extends State<SliderViewWidget> {
|
||||
SliderDTO sliderDTO;
|
||||
CarouselController sliderController;
|
||||
int currentIndex = 1;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
print(widget.section.data);
|
||||
sliderController = CarouselController();
|
||||
sliderDTO = SliderDTO.fromJson(jsonDecode(widget.section.data));
|
||||
print(sliderDTO);
|
||||
|
||||
sliderDTO.images.sort((a, b) => a.order.compareTo(b.order));
|
||||
|
||||
@ -27,24 +32,31 @@ class _SliderViewWidget extends State<SliderViewWidget> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
sliderController = null;
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
final appContext = Provider.of<AppContext>(context);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 75),
|
||||
child: Center(
|
||||
child: Column(
|
||||
return Stack(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
if(sliderDTO.images != null && sliderDTO.images.length > 0)
|
||||
CarouselSlider(
|
||||
carouselController: sliderController,
|
||||
options: CarouselOptions(
|
||||
height: size.height *0.3,
|
||||
onPageChanged: (int index, CarouselPageChangedReason reason) {
|
||||
setState(() {
|
||||
currentIndex = index + 1;
|
||||
});
|
||||
},
|
||||
height: MediaQuery.of(context).size.height * 0.8,
|
||||
enlargeCenterPage: true,
|
||||
reverse: false,
|
||||
),
|
||||
@ -53,47 +65,155 @@ class _SliderViewWidget extends State<SliderViewWidget> {
|
||||
builder: (BuildContext context) {
|
||||
return Container(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: MediaQuery.of(context).size.height,
|
||||
margin: EdgeInsets.symmetric(horizontal: 5.0),
|
||||
decoration: BoxDecoration(
|
||||
color: kBackgroundGrey,
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
border: Border.all(width: 0.3, color: kSecondGrey),
|
||||
//border: Border.all(width: 0.3, color: kSecondGrey),
|
||||
),
|
||||
child: Image.network(
|
||||
i.source_,
|
||||
fit: BoxFit.contain
|
||||
child: Column(
|
||||
//crossAxisAlignment: CrossAxisAlignment.center,
|
||||
//mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height * 0.6,
|
||||
width: MediaQuery.of(context).size.width * 0.72,
|
||||
decoration: BoxDecoration(
|
||||
color: kBackgroundLight,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
image: i.source_ != null ? new DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: new NetworkImage(
|
||||
i.source_,
|
||||
),
|
||||
): null,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: kBackgroundSecondGrey,
|
||||
spreadRadius: 0.5,
|
||||
blurRadius: 5,
|
||||
offset: Offset(0, 1.5), // changes position of shadow
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Align(
|
||||
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)),
|
||||
)),
|
||||
),
|
||||
),
|
||||
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: Text(i.description.firstWhere((translation) => translation.language == appContext.getContext().language).value, textAlign: TextAlign.center, style: TextStyle(fontSize: 15)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
);
|
||||
},
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
// Description
|
||||
/*Container(
|
||||
height: sliderDTO.images != null && sliderDTO.images.length > 0 ? size.height *0.3 : size.height *0.6,
|
||||
width: MediaQuery.of(context).size.width *0.35,
|
||||
decoration: BoxDecoration(
|
||||
color: kBackgroundLight,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: kBackgroundSecondGrey,
|
||||
spreadRadius: 0.5,
|
||||
blurRadius: 1.1,
|
||||
offset: Offset(0, 1.1), // changes position of shadow
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
top: MediaQuery.of(context).size.height * 0.35,
|
||||
right: 60,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
sliderController.nextPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.chevron_right,
|
||||
size: 150,
|
||||
color: kMainRed,
|
||||
),
|
||||
)
|
||||
),
|
||||
Positioned(
|
||||
top: MediaQuery.of(context).size.height * 0.35,
|
||||
left: 60,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
sliderController.previousPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
|
||||
},
|
||||
child: Icon(
|
||||
Icons.chevron_left,
|
||||
size: 150,
|
||||
color: kMainRed,
|
||||
),
|
||||
)
|
||||
),
|
||||
if(sliderDTO.images != null && sliderDTO.images.length > 0)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 0),
|
||||
child: Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
sliderController.previousPage(duration: new Duration(milliseconds: 500), curve: Curves.fastOutSlowIn);
|
||||
},
|
||||
child: Text(
|
||||
currentIndex.toString()+'/'+sliderDTO.images.length.toString(),
|
||||
style: TextStyle(fontSize: 30, fontWeight: FontWeight.w500),
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
),
|
||||
// Description
|
||||
/*Container(
|
||||
height: sliderDTO.images != null && sliderDTO.images.length > 0 ? size.height *0.3 : size.height *0.6,
|
||||
width: MediaQuery.of(context).size.width *0.35,
|
||||
decoration: BoxDecoration(
|
||||
color: kBackgroundLight,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: kBackgroundSecondGrey,
|
||||
spreadRadius: 0.5,
|
||||
blurRadius: 1.1,
|
||||
offset: Offset(0, 1.1), // changes position of shadow
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Text(sliderDTO., textAlign: TextAlign.center, style: TextStyle(fontSize: 15)),
|
||||
),
|
||||
),
|
||||
),*/
|
||||
]
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Text(sliderDTO., textAlign: TextAlign.center, style: TextStyle(fontSize: 15)),
|
||||
),
|
||||
),
|
||||
),*/
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user