Commit 87185dec authored by Lila NICKLER's avatar Lila NICKLER

Exercice 4 +5

parent 3b2c642c
...@@ -2,7 +2,9 @@ import 'package:flutter/cupertino.dart'; ...@@ -2,7 +2,9 @@ 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;
class Exercice1 extends StatelessWidget { import 'Tile.dart';
class DisplayImage extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var mediaQueryData = MediaQuery.of(context); var mediaQueryData = MediaQuery.of(context);
...@@ -20,19 +22,18 @@ class Exercice1 extends StatelessWidget { ...@@ -20,19 +22,18 @@ class Exercice1 extends StatelessWidget {
} }
} }
class Exercice2 extends StatefulWidget { class RotateResizeMirrorWidget extends StatefulWidget {
@override @override
_Exercice2State createState() => _Exercice2State(); _RotateResizeMirrorWidgetState createState() => _RotateResizeMirrorWidgetState();
} }
class _Exercice2State extends State<Exercice2> { class _RotateResizeMirrorWidgetState extends State<RotateResizeMirrorWidget> {
double _currentSlider1Value = 0.0; double _currentSlider1Value = 0.0;
double _currentSlider2Value = 0.0; double _currentSlider2Value = 0.0;
double _currentSlider3Value = 100.0; double _currentSlider3Value = 100.0;
bool _mirror = false; bool _mirror = false;
Image image = Image.network("https://picsum.photos/512/1024"); Image image = Image.network("https://picsum.photos/512/1024");
double _size;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -156,7 +157,7 @@ class _Exercice2State extends State<Exercice2> { ...@@ -156,7 +157,7 @@ class _Exercice2State extends State<Exercice2> {
} }
} }
class Exercice3 extends StatelessWidget{ class DisplayExercice extends StatelessWidget{
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListView( return ListView(
...@@ -165,18 +166,34 @@ class _Exercice2State extends State<Exercice2> { ...@@ -165,18 +166,34 @@ class _Exercice2State extends State<Exercice2> {
ListTile( ListTile(
title: Text("Exercice 1"), title: Text("Exercice 1"),
subtitle: Text("Affichage d'une image"), subtitle: Text("Affichage d'une image"),
leading: Icon(Icons.play_arrow_rounded), leading: Icon(Icons.wb_sunny_outlined),
onTap: (){ onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>Exercice1())); Navigator.push(context, MaterialPageRoute(builder: (context)=>DisplayImage()));
},)), },)),
Card(child: Card(child:
ListTile( ListTile(
leading: Icon(Icons.play_arrow_rounded), leading: Icon(Icons.wb_sunny_outlined),
title: Text("Exercice 2"), title: Text("Exercice 2"),
subtitle: Text("Rotation, taille et mode miroir"), subtitle: Text("Rotation, taille et mode miroir"),
onTap: (){ onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>Exercice2())); 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()));
},))
], ],
); );
...@@ -185,22 +202,5 @@ class _Exercice2State extends State<Exercice2> { ...@@ -185,22 +202,5 @@ class _Exercice2State extends State<Exercice2> {
} }
class Exercice4 extends StatelessWidget{
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Exercice 1"),
),
body: Center(
child: Container(
child: Image.network("https://picsum.photos/512/1024")),
)
);
}
}
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");
},
);
}
}
////////////////////////////////////////////////////////////////////////Exo5//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TileUp {
String imageURL;
Alignment alignment;
TileUp({this.imageURL, this.alignment});
Widget croppedImageTile(int size) {
return FittedBox(
fit: BoxFit.fill,
child: ClipRect(
child: Container(
child: Align(
alignment: this.alignment,
widthFactor: 1/size,
heightFactor: 1/size,
child: Image.network(this.imageURL),
),
),
),
);
}
}
class ImageGridViewTile extends StatefulWidget{
@override
_ImageGridViewTileState createState() => _ImageGridViewTileState();
}
class _ImageGridViewTileState extends State<ImageGridViewTile> {
int _currentSliderValue = 3;
String imageURL = "https://picsum.photos/512";
List <TileUp> _listTile = <TileUp>[];
List <TileUp> createListTile ()
{
double pas = (2/((_currentSliderValue-1)));
List <TileUp> _listTile = <TileUp>[];
double i;
double j;
for(i = -1 ; i <=1; i+=pas)
{
for (j=-1; j<=1; j +=pas) {
_listTile.add(new TileUp(
imageURL: imageURL,
alignment:Alignment(j, i)));
}
}
return _listTile;
}
Widget createTileUpWidgetFrom(TileUp tile, int size) {
return InkWell(
child: tile.croppedImageTile(size),
onTap: () {
print("tapped on tile");
},
);
}
List<Widget> createWidgetList(List<TileUp> lt,int size){
List<Widget> lw =<Widget>[];
for(int i=0;i<lt.length;i++){
lw.add(createTileUpWidgetFrom(lt[i], size));
}
return lw;
}
Widget build(BuildContext context) {
var mediaQueryData = MediaQuery.of(context);
_listTile = createListTile();
return Scaffold(
appBar: AppBar(
title: Text("Exercice 5"),
),
body: Center(
child: ListView(
scrollDirection: Axis.vertical,
shrinkWrap: true,
children: [
SizedBox(
height: 500,
width: 400,
child:Container(
child: GridView.count(
children: createWidgetList(_listTile, _currentSliderValue),
mainAxisSpacing: 2,
crossAxisSpacing: 2,
crossAxisCount: _currentSliderValue,
scrollDirection: Axis.vertical,
shrinkWrap: true,
),
),
),
Container(
width: mediaQueryData.size.width * (7 / 8),
child: Slider(
value: _currentSliderValue.toDouble(),
min: 1,
max: 10,
divisions: 10,
label: _currentSliderValue.round().toString(),
onChanged: (double value) {
setState(() {
_currentSliderValue = value.toInt();
});
}),)
],
)
)
);
}
}
\ No newline at end of file
...@@ -34,7 +34,7 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -34,7 +34,7 @@ class _MyHomePageState extends State<MyHomePage> {
@override @override
//static Exercice1 exo1 = new Exercice1(); //static Exercice1 exo1 = new Exercice1();
static Exercice3 exo3 = new Exercice3(); static DisplayExercice exo3 = new DisplayExercice();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
......
...@@ -7,42 +7,42 @@ packages: ...@@ -7,42 +7,42 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.5.0-nullsafety.1" version: "2.5.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.1.0"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0-nullsafety.3" version: "1.1.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.1.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.0-nullsafety.3" version: "1.15.0"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -56,7 +56,7 @@ packages: ...@@ -56,7 +56,7 @@ packages:
name: fake_async name: fake_async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
...@@ -73,21 +73,21 @@ packages: ...@@ -73,21 +73,21 @@ packages:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.10-nullsafety.1" version: "0.12.10"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0-nullsafety.1" version: "1.8.0"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
...@@ -99,55 +99,55 @@ packages: ...@@ -99,55 +99,55 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0-nullsafety.2" version: "1.8.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.0-nullsafety.1" version: "1.10.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0-nullsafety.1" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0-nullsafety.1" version: "1.1.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0-nullsafety.1" version: "1.2.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.19-nullsafety.2" version: "0.2.19"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0-nullsafety.3" version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0-nullsafety.3" version: "2.1.0"
sdks: sdks:
dart: ">=2.10.0-110 <2.11.0" dart: ">=2.12.0-0.0 <3.0.0"
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