Skip to content
Snippets Groups Projects
Commit e5ac2049 authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Merge branch '9-improve-select-image-layout' into 'master'

Resolve "Improve select image layout"

Closes #9

See merge request !13
parents 2b0050ba 61adbc23
No related branches found
No related tags found
1 merge request!13Resolve "Improve select image layout"
Pipeline #1248 passed
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.9
app.versionCode=9
app.versionName=0.0.10
app.versionCode=10
......@@ -12,7 +12,6 @@ import '../utils/get_images_list.dart';
class Home extends StatelessWidget {
static const String id = 'home';
double _selectorImageSize = 200;
double _tipImageSize = 100;
double _tileImageSize = 80;
......@@ -30,6 +29,7 @@ class Home extends StatelessWidget {
await getImagesList.init();
if (getImagesList.images != null) {
myProvider.updateImages = getImagesList.images;
shuffleImages(myProvider);
}
}
......@@ -40,7 +40,13 @@ class Home extends StatelessWidget {
myProvider.updateShuffling = false;
}
Container _buildImageSelectorItem(Data myProvider, String image) {
void shuffleImages(Data myProvider) {
List images = myProvider.images;
images.shuffle();
myProvider.updateImages = images;
}
Container _buildImageSelectorItem(Data myProvider, String image, double size) {
return Container(
child: FlatButton(
child: Container(
......@@ -54,8 +60,8 @@ class Home extends StatelessWidget {
margin: EdgeInsets.all(2),
child: Image(
image: AssetImage(getImageAssetName(image)),
width: _selectorImageSize,
height: _selectorImageSize,
width: size,
height: size,
fit: BoxFit.fill
),
),
......@@ -64,7 +70,7 @@ class Home extends StatelessWidget {
);
}
Container _buildImageSelector(Data myProvider) {
Container _buildImageSelector(Data myProvider, double size) {
if (myProvider.images.length == 0) {
getImagesList(myProvider);
}
......@@ -74,8 +80,27 @@ class Home extends StatelessWidget {
padding: EdgeInsets.all(5),
child: ListView(
children: [
for (var image in images)
_buildImageSelectorItem(myProvider, image),
Table(
defaultColumnWidth: IntrinsicColumnWidth(),
children: [
for (var imageIndex = 0; imageIndex < images.length; imageIndex+=2)
TableRow(
children: [
Column(
children: [
_buildImageSelectorItem(myProvider, images[imageIndex], size)
]
),
Column(
children: [
if (imageIndex+1 < images.length)
_buildImageSelectorItem(myProvider, images[imageIndex+1], size)
]
),
]
),
],
),
],
),
);
......@@ -253,29 +278,37 @@ class Home extends StatelessWidget {
var content;
double _selectorImageSize = MediaQuery.of(context).size.width / 3;
if (_myProvider.shuffling) {
content = _buildShufflingIndicatorWidget();
} else {
if (_myProvider.image == '') {
content = _buildImageSelector(_myProvider);
content = _buildImageSelector(_myProvider, _selectorImageSize);
} else {
content = _buildGameWidget(_myProvider);
}
}
List<Widget> menuActions = [
IconButton(
icon: const Icon(Icons.shuffle),
onPressed: () => shuffleImages(_myProvider),
),
_buildTilesetSizeSelector(_myProvider),
];
List<Widget> gameActions = [
IconButton(
icon: const Icon(Icons.arrow_left_outlined),
onPressed: () => resetGame(_myProvider),
)
];
return Scaffold(
appBar: AppBar(
title: Text('Puzzle'),
actions: <Widget>[
_myProvider.image == ''
? Text('')
: IconButton(
icon: const Icon(Icons.arrow_left_outlined),
onPressed: () => resetGame(_myProvider),
)
,
_myProvider.image == '' ? _buildTilesetSizeSelector(_myProvider) : Text(''),
],
actions: _myProvider.image == '' ? menuActions : gameActions,
),
body: SafeArea(
child: Center(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment