Commit 21a291b9 authored by Benjamin LEROUX's avatar Benjamin LEROUX

exo5 commit

parent 5dfaca3c
...@@ -5,35 +5,26 @@ import 'Tile.dart'; ...@@ -5,35 +5,26 @@ import 'Tile.dart';
class Plateau{ class Plateau{
List<Tile> listTile; List<Tile> listTile;
double size;
Plateau({this.listTile}); Plateau({this.listTile,this.size});
List<Tile> getListTile(){ List<Tile> getListTile(){
return listTile; return listTile;
} }
} }
Tile tile = new Tile( int size=5;
imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(-1, -1));
Tile tile2 = new Tile(
imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(0, -1));
Tile tile3 = new Tile(
imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(1, -1));
Tile tile4 = new Tile(
imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(-1, 0));
Tile tile5 = new Tile(
imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(0, 0));
Tile tile6 = new Tile(
imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(1, 0));
Tile tile7 = new Tile(
imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(-1, 1));
Tile tile8 = new Tile(
imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(0, 1));
Tile tile9 = new Tile(
imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(1, 1));
class DisplayPlateauWidget extends StatefulWidget {
@override
_DisplayPlateauWidgetState createState() => _DisplayPlateauWidgetState();
}
class _DisplayPlateauWidgetState extends State<DisplayPlateauWidget> {
double _currentSliderValue=4;
TextStyle textStyle = TextStyle(fontSize: 16, fontWeight: FontWeight.bold,);
class DisplayPlateauWidget extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
...@@ -49,6 +40,20 @@ class DisplayPlateauWidget extends StatelessWidget { ...@@ -49,6 +40,20 @@ class DisplayPlateauWidget extends StatelessWidget {
child: Container( child: Container(
margin: EdgeInsets.all(20.0), margin: EdgeInsets.all(20.0),
child: createGridView())), child: createGridView())),
Row(mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(width: 90,child:Text('Taille:', style: textStyle,textAlign: TextAlign.center,),padding: EdgeInsets.fromLTRB(8, 0, 0, 0),),
Container(width: MediaQuery.of(context).size.width-90,child: Slider(
value: _currentSliderValue,
min: 1, max: 10, divisions: 9,
label: _currentSliderValue.round().toString(),
onChanged: (double value) {
setState(() {_currentSliderValue = value;});
}
),
),
]
),
])), ])),
); );
} }
...@@ -58,8 +63,8 @@ class DisplayPlateauWidget extends StatelessWidget { ...@@ -58,8 +63,8 @@ class DisplayPlateauWidget extends StatelessWidget {
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
mainAxisSpacing: 5, mainAxisSpacing: 5,
crossAxisSpacing: 5, crossAxisSpacing: 5,
crossAxisCount: 3, crossAxisCount: _currentSliderValue.toInt(),
children: getAllCroppedImage(createListTile()), children: getAllCroppedImage(createListTile(_currentSliderValue)),
); );
} }
...@@ -71,17 +76,16 @@ class DisplayPlateauWidget extends StatelessWidget { ...@@ -71,17 +76,16 @@ class DisplayPlateauWidget extends StatelessWidget {
return res; return res;
} }
List<Tile> createListTile(){ List<Tile> createListTile(double size){
List<Tile> res=<Tile>[]; List<Tile> res=<Tile>[];
res.add(tile);
res.add(tile2); for(double i=-1.0;i<=1.0;){
res.add(tile3); for(double j=-1.0;j<=1.0;){
res.add(tile4); res.add(new Tile(imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(j, i),size: size));
res.add(tile5); j+=(1/((size-1)/2));
res.add(tile6); }
res.add(tile7); i+=(1/((size-1)/2));
res.add(tile8); }
res.add(tile9);
return res; return res;
} }
} }
......
...@@ -3,8 +3,9 @@ import 'package:flutter/material.dart'; ...@@ -3,8 +3,9 @@ import 'package:flutter/material.dart';
class Tile { class Tile {
String imageURL; String imageURL;
Alignment alignment; Alignment alignment;
double size;
Tile({this.imageURL, this.alignment}); Tile({this.imageURL, this.alignment,this.size});
Widget croppedImageTile() { Widget croppedImageTile() {
return FittedBox( return FittedBox(
...@@ -13,8 +14,8 @@ class Tile { ...@@ -13,8 +14,8 @@ class Tile {
child: Container( child: Container(
child: Align( child: Align(
alignment: this.alignment, alignment: this.alignment,
widthFactor: 0.3333, widthFactor: 1/size,
heightFactor: 0.3333, heightFactor: 1/size,
child: Image.network(this.imageURL), child: Image.network(this.imageURL),
), ),
), ),
...@@ -24,7 +25,7 @@ class Tile { ...@@ -24,7 +25,7 @@ class Tile {
} }
Tile tile = new Tile( Tile tile = new Tile(
imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(0, 0)); imageURL: 'https://picsum.photos/512/1024', alignment: Alignment(0, 0),size: 3);
class DisplayTileWidget extends StatelessWidget { class DisplayTileWidget extends StatelessWidget {
@override @override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment