Commit 6e0d510b authored by Lila NICKLER's avatar Lila NICKLER

Restructuraction

parent 87185dec
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class DisplayImage extends StatelessWidget {
Widget build(BuildContext context) {
var mediaQueryData = MediaQuery.of(context);
return Scaffold(
appBar: AppBar(
title: Text("Exercice 1"),
),
body: Center(
child: Container(
height: mediaQueryData.size.height - 200,
child: Image.network("https://picsum.photos/512/1024")),
)
);
}
}
\ No newline at end of file
...@@ -2,26 +2,6 @@ import 'package:flutter/cupertino.dart'; ...@@ -2,26 +2,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:math' as math; import 'dart:math' as math;
import 'Tile.dart';
class DisplayImage extends StatelessWidget {
Widget build(BuildContext context) {
var mediaQueryData = MediaQuery.of(context);
return Scaffold(
appBar: AppBar(
title: Text("Exercice 1"),
),
body: Center(
child: Container(
height: mediaQueryData.size.height - 200,
child: Image.network("https://picsum.photos/512/1024")),
)
);
}
}
class RotateResizeMirrorWidget extends StatefulWidget { class RotateResizeMirrorWidget extends StatefulWidget {
@override @override
...@@ -156,51 +136,3 @@ class _RotateResizeMirrorWidgetState extends State<RotateResizeMirrorWidget> { ...@@ -156,51 +136,3 @@ class _RotateResizeMirrorWidgetState extends State<RotateResizeMirrorWidget> {
)); ));
} }
} }
class DisplayExercice extends StatelessWidget{
@override
Widget build(BuildContext context) {
return ListView(
children: [
Card(child:
ListTile(
title: Text("Exercice 1"),
subtitle: Text("Affichage d'une image"),
leading: Icon(Icons.wb_sunny_outlined),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>DisplayImage()));
},)),
Card(child:
ListTile(
leading: Icon(Icons.wb_sunny_outlined),
title: Text("Exercice 2"),
subtitle: Text("Rotation, taille et mode miroir"),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>RotateResizeMirrorWidget()));
},)),
Card(child:
ListTile(
leading: Icon(Icons.wb_sunny_outlined),
title: Text("Exercice 4"),
subtitle: Text("Affichage d'une tuile a a partir d'une image"),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>DisplayTileWidget()));
},)),
Card(child:
ListTile(
leading: Icon(Icons.wb_sunny_outlined),
title: Text("Exercice 5"),
subtitle: Text("Affichage d'une tuile a a partir d'une image"),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>ImageGridViewTile()));
},))
],
);
}
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'Exercice 1.dart';
import 'Exercice 2.dart';
import 'Exercice 4.dart';
import 'Exercice 5.dart';
class DisplayExercice extends StatelessWidget{
@override
Widget build(BuildContext context) {
return ListView(
children: [
Card(child:
ListTile(
title: Text("Exercice 1"),
subtitle: Text("Affichage d'une image"),
leading: Icon(Icons.wb_sunny_outlined),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>DisplayImage()));
},)),
Card(child:
ListTile(
leading: Icon(Icons.wb_sunny_outlined),
title: Text("Exercice 2"),
subtitle: Text("Rotation, taille et mode miroir"),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>RotateResizeMirrorWidget()));
},)),
Card(child:
ListTile(
leading: Icon(Icons.wb_sunny_outlined),
title: Text("Exercice 4"),
subtitle: Text("Affichage d'une tuile a a partir d'une image"),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>DisplayTileWidget()));
},)),
Card(child:
ListTile(
leading: Icon(Icons.wb_sunny_outlined),
title: Text("Exercice 5"),
subtitle: Text("Affichage d'une tuile a a partir d'une image"),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>ImageGridViewTile()));
},))
],
);
}
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class Tile {
String imageURL;
Alignment alignment;
String imageGenerator = "https://picsum.photos/512";
Tile({this.imageURL, this.alignment});
Widget croppedImageTile() {
return FittedBox(
fit: BoxFit.fitWidth,
child: ClipRect(
child: Container(
child: Align(
alignment: this.alignment,
widthFactor: 0.3,
heightFactor: 0.3,
child: Image.network(this.imageURL),
),
),
),
);
}
}
Tile tile = new Tile(
imageURL: "https://picsum.photos/512", alignment: Alignment(0, 0));
class DisplayTileWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Exercice 4'),
),
body: Center(
child: Column(children: [
SizedBox(
width: 150.0,
height: 150.0,
child: Container(
margin: EdgeInsets.all(20.0),
child: this.createTileWidgetFrom(tile))),
Container(
height: 200,
child: Image.network("https://picsum.photos/512",
fit: BoxFit.cover))
])),
);
}
Widget createTileWidgetFrom(Tile tile) {
return InkWell(
child: tile.croppedImageTile(),
onTap: () {
print("tapped on tile");
},
);
}
}
\ No newline at end of file
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class Tile {
String imageURL;
Alignment alignment;
String imageGenerator = "https://picsum.photos/512";
Tile({this.imageURL, this.alignment});
Widget croppedImageTile() {
return FittedBox(
fit: BoxFit.fitWidth,
child: ClipRect(
child: Container(
child: Align(
alignment: this.alignment,
widthFactor: 0.3,
heightFactor: 0.3,
child: Image.network(this.imageURL),
),
),
),
);
}
}
Tile tile = new Tile(
imageURL: "https://picsum.photos/512", alignment: Alignment(0, 0));
class DisplayTileWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Exercice 4'),
),
body: Center(
child: Column(children: [
SizedBox(
width: 150.0,
height: 150.0,
child: Container(
margin: EdgeInsets.all(20.0),
child: this.createTileWidgetFrom(tile))),
Container(
height: 200,
child: Image.network("https://picsum.photos/512",
fit: BoxFit.cover))
])),
);
}
Widget createTileWidgetFrom(Tile tile) {
return InkWell(
child: tile.croppedImageTile(),
onTap: () {
print("tapped on tile");
},
);
}
}
////////////////////////////////////////////////////////////////////////Exo5//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TileUp { class TileUp {
String imageURL; String imageURL;
Alignment alignment; Alignment alignment;
...@@ -106,9 +44,9 @@ class _ImageGridViewTileState extends State<ImageGridViewTile> { ...@@ -106,9 +44,9 @@ class _ImageGridViewTileState extends State<ImageGridViewTile> {
for(i = -1 ; i <=1; i+=pas) for(i = -1 ; i <=1; i+=pas)
{ {
for (j=-1; j<=1; j +=pas) { for (j=-1; j<=1; j +=pas) {
_listTile.add(new TileUp( _listTile.add(new TileUp(
imageURL: imageURL, imageURL: imageURL,
alignment:Alignment(j, i))); alignment:Alignment(j, i)));
} }
} }
return _listTile; return _listTile;
...@@ -140,39 +78,39 @@ class _ImageGridViewTileState extends State<ImageGridViewTile> { ...@@ -140,39 +78,39 @@ class _ImageGridViewTileState extends State<ImageGridViewTile> {
title: Text("Exercice 5"), title: Text("Exercice 5"),
), ),
body: Center( body: Center(
child: ListView( child: ListView(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
shrinkWrap: true, shrinkWrap: true,
children: [ children: [
SizedBox( SizedBox(
height: 500, height: 500,
width: 400, width: 400,
child:Container( child:Container(
child: GridView.count( child: GridView.count(
children: createWidgetList(_listTile, _currentSliderValue), children: createWidgetList(_listTile, _currentSliderValue),
mainAxisSpacing: 2, mainAxisSpacing: 2,
crossAxisSpacing: 2, crossAxisSpacing: 2,
crossAxisCount: _currentSliderValue, crossAxisCount: _currentSliderValue,
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
shrinkWrap: true, shrinkWrap: true,
),
), ),
), ),
), Container(
Container( width: mediaQueryData.size.width * (7 / 8),
width: mediaQueryData.size.width * (7 / 8), child: Slider(
child: Slider( value: _currentSliderValue.toDouble(),
value: _currentSliderValue.toDouble(), min: 1,
min: 1, max: 10,
max: 10, divisions: 10,
divisions: 10, label: _currentSliderValue.round().toString(),
label: _currentSliderValue.round().toString(), onChanged: (double value) {
onChanged: (double value) { setState(() {
setState(() { _currentSliderValue = value.toInt();
_currentSliderValue = value.toInt(); });
}); }),)
}),) ],
], )
)
) )
); );
} }
......
import 'package:flutter/material.dart';
import 'dart:math' as math;
// ==============
// Models
// ==============
math.Random random = new math.Random();
class Tile {
Color color;
Tile(this.color);
Tile.randomColor() {
this.color = Color.fromARGB(
255, random.nextInt(255), random.nextInt(255), random.nextInt(255));
}
}
// ==============
// Widgets
// ==============
class TileWidget extends StatelessWidget {
final Tile tile;
TileWidget(this.tile);
@override
Widget build(BuildContext context) {
return this.coloredBox();
}
Widget coloredBox() {
return Container(
color: tile.color,
child: Padding(
padding: EdgeInsets.all(70.0),
));
}
}
void main() => runApp(new MaterialApp(home: PositionedTiles()));
class PositionedTiles extends StatefulWidget {
@override
State<StatefulWidget> createState() => PositionedTilesState();
}
class PositionedTilesState extends State<PositionedTiles> {
List<Widget> tiles =
List<Widget>.generate(2, (index) => TileWidget(Tile.randomColor()));
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Moving Tiles'),
centerTitle: true,
),
body: Row(children: tiles),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.sentiment_very_satisfied), onPressed: swapTiles),
);
}
swapTiles() {
setState(() {
tiles.insert(1, tiles.removeAt(0));
});
}
}
\ No newline at end of file
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'Exercice 3.dart';
import 'Exo.dart';
void main() { void main() {
runApp(MyApp()); runApp(MyApp());
} }
...@@ -33,7 +31,6 @@ class MyHomePage extends StatefulWidget { ...@@ -33,7 +31,6 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> { class _MyHomePageState extends State<MyHomePage> {
@override @override
//static Exercice1 exo1 = new Exercice1();
static DisplayExercice exo3 = new DisplayExercice(); static DisplayExercice exo3 = new DisplayExercice();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
......
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