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

Toggle show/hide tip image

parent 188196ac
No related branches found
No related tags found
1 merge request!21Resolve "Show/hide tip image"
Pipeline #1282 passed
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.16
app.versionCode=16
app.versionName=0.0.18
app.versionCode=18
assets/ui/tip-hidden.png

9.9 KiB

......@@ -14,6 +14,7 @@ class Data extends ChangeNotifier {
// application state
bool _shuffling = false;
bool _displayTipImage = false;
String get image => _image;
......@@ -50,6 +51,13 @@ class Data extends ChangeNotifier {
notifyListeners();
}
bool get displayTipImage => _displayTipImage;
set updateDisplayTipImage(bool value) {
_displayTipImage = value;
notifyListeners();
}
void swapTiles(List<int> tile1, List<int> tile2) {
int indexTile1 = _tiles.indexWhere((tile) => ((tile.currentCol == tile1[0]) && (tile.currentRow == tile1[1])));
int indexTile2 = _tiles.indexWhere((tile) => ((tile.currentCol == tile2[0]) && (tile.currentRow == tile2[1])));
......
......@@ -20,6 +20,10 @@ class Home extends StatelessWidget {
myProvider.updateImage = '';
}
void toggleDisplayTipImage(Data myProvider) {
myProvider.updateDisplayTipImage = !myProvider.displayTipImage;
}
String getImageAssetName(String imageCode) {
return 'assets/images/'+imageCode+'.png';
}
......@@ -230,21 +234,30 @@ class Home extends StatelessWidget {
Container _buildTipWidget(Data myProvider) {
return Container(
margin: EdgeInsets.all(4),
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(4),
border: Border.all(
color: Colors.blue,
width: 4,
child: FlatButton(
child: Container(
margin: EdgeInsets.all(4),
padding: EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(4),
border: Border.all(
color: Colors.blue,
width: 4,
),
),
child: Image(
image: AssetImage(
myProvider.displayTipImage
? getImageAssetName(myProvider.image)
: 'assets/ui/tip-hidden.png'
),
width: _tipImageSize,
height: _tipImageSize,
fit: BoxFit.fill
),
),
),
child: Image(
image: AssetImage(getImageAssetName(myProvider.image)),
width: _tipImageSize,
height: _tipImageSize,
fit: BoxFit.fill
onPressed: () => toggleDisplayTipImage(myProvider),
),
);
}
......
......@@ -21,3 +21,4 @@ flutter:
assets:
- assets/files/
- assets/images/
- assets/ui/
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