Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 23-add-timer
  • 65-update-icons
  • 82-fix-colors
  • 84-improve-app-metadata
  • master
  • Release_0.0.16_16
  • Release_0.0.17_17
  • Release_0.0.18_18
  • Release_0.0.19_19
  • Release_0.0.20_20
  • Release_0.0.21_21
  • Release_0.0.22_22
  • Release_0.0.23_23
  • Release_0.0.24_24
  • Release_0.0.25_25
  • Release_0.0.26_26
  • Release_0.0.27_27
  • Release_0.0.28_28
  • Release_0.0.29_29
  • Release_0.0.30_30
  • Release_0.0.31_31
  • Release_0.0.32_32
  • Release_0.0.33_33
  • Release_0.0.34_34
  • Release_0.0.35_35
  • Release_0.0.36_36
  • Release_0.0.37_37
  • Release_0.0.38_38
  • Release_0.0.39_39
  • Release_0.0.40_40
  • Release_0.0.41_41
  • Release_0.0.42_42
  • Release_0.0.43_43
  • Release_0.0.44_44
  • Release_0.0.45_45
  • Release_0.0.46_46
  • Release_0.0.47_47
  • Release_0.0.48_48
  • Release_0.1.0_49
  • Release_0.1.10_59
  • Release_0.1.11_60
  • Release_0.1.12_61
  • Release_0.1.13_62
  • Release_0.1.14_63
  • Release_0.1.15_64
  • Release_0.1.16_65
  • Release_0.1.17_66
  • Release_0.1.18_67
  • Release_0.1.19_68
  • Release_0.1.1_50
  • Release_0.1.20_69
  • Release_0.1.21_70
  • Release_0.1.22_71
  • Release_0.1.2_51
  • Release_0.1.3_52
  • Release_0.1.4_53
  • Release_0.1.5_54
  • Release_0.1.6_55
  • Release_0.1.7_56
  • Release_0.1.8_57
  • Release_0.1.9_58
  • Release_0.10.0_87
  • Release_0.2.0_72
  • Release_0.2.1_73
  • Release_0.3.0_74
  • Release_0.3.1_75
  • Release_0.4.0_76
  • Release_0.4.1_77
  • Release_0.5.0_78
  • Release_0.5.1_79
  • Release_0.5.2_80
  • Release_0.6.0_81
  • Release_0.7.0_82
  • Release_0.8.0_83
  • Release_0.9.0_84
  • Release_0.9.1_85
  • Release_0.9.2_86
77 results

Target

Select target project
  • android/org.benoitharrault.sudoku
1 result
Select Git revision
  • 23-add-timer
  • 65-update-icons
  • 82-fix-colors
  • 84-improve-app-metadata
  • master
  • Release_0.0.16_16
  • Release_0.0.17_17
  • Release_0.0.18_18
  • Release_0.0.19_19
  • Release_0.0.20_20
  • Release_0.0.21_21
  • Release_0.0.22_22
  • Release_0.0.23_23
  • Release_0.0.24_24
  • Release_0.0.25_25
  • Release_0.0.26_26
  • Release_0.0.27_27
  • Release_0.0.28_28
  • Release_0.0.29_29
  • Release_0.0.30_30
  • Release_0.0.31_31
  • Release_0.0.32_32
  • Release_0.0.33_33
  • Release_0.0.34_34
  • Release_0.0.35_35
  • Release_0.0.36_36
  • Release_0.0.37_37
  • Release_0.0.38_38
  • Release_0.0.39_39
  • Release_0.0.40_40
  • Release_0.0.41_41
  • Release_0.0.42_42
  • Release_0.0.43_43
  • Release_0.0.44_44
  • Release_0.0.45_45
  • Release_0.0.46_46
  • Release_0.0.47_47
  • Release_0.0.48_48
  • Release_0.1.0_49
  • Release_0.1.10_59
  • Release_0.1.11_60
  • Release_0.1.12_61
  • Release_0.1.13_62
  • Release_0.1.14_63
  • Release_0.1.15_64
  • Release_0.1.16_65
  • Release_0.1.17_66
  • Release_0.1.18_67
  • Release_0.1.19_68
  • Release_0.1.1_50
  • Release_0.1.20_69
  • Release_0.1.21_70
  • Release_0.1.22_71
  • Release_0.1.2_51
  • Release_0.1.3_52
  • Release_0.1.4_53
  • Release_0.1.5_54
  • Release_0.1.6_55
  • Release_0.1.7_56
  • Release_0.1.8_57
  • Release_0.1.9_58
  • Release_0.10.0_87
  • Release_0.2.0_72
  • Release_0.2.1_73
  • Release_0.3.0_74
  • Release_0.3.1_75
  • Release_0.4.0_76
  • Release_0.4.1_77
  • Release_0.5.0_78
  • Release_0.5.1_79
  • Release_0.5.2_80
  • Release_0.6.0_81
  • Release_0.7.0_82
  • Release_0.8.0_83
  • Release_0.9.0_84
  • Release_0.9.1_85
  • Release_0.9.2_86
77 results
Show changes
Commits on Source (8)
Showing
with 200 additions and 207 deletions
image: ghcr.io/cirruslabs/flutter:latest
stages:
- update
- build-debug
- build-release
- release
- deploy
update:
stage: update
except:
- tags
script:
- flutter packages get
- flutter packages upgrade
interruptible: true
android:build-debug:
stage: build-debug
except:
- tags
- master
script:
# Flutter local configuration
- echo flutter.sdk=$FLUTTER_PATH > android/local.properties
......@@ -49,8 +40,6 @@ android:build-release:
- master
except:
- tags
dependencies:
- android:build-debug
script:
# Flutter local configuration
- echo flutter.sdk=$FLUTTER_PATH > android/local.properties
......@@ -121,4 +110,4 @@ android:deploy:
dependencies:
- application:release
script:
- curl "${REPOSITORY_UPDATE_WEBHOOK}?token=${REPOSITORY_TOKEN}"
- curl "${REPOSITORY_UPDATE_WEBHOOK}?token=${REPOSITORY_TOKEN}" --fail
include: package:flutter_lints/flutter.yaml
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
......@@ -14,11 +20,6 @@ if (gradlePropertiesFile.exists()) {
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def appVersionCode = gradleProperties.getProperty('app.versionCode')
if (appVersionCode == null) {
appVersionCode = '1'
......@@ -29,9 +30,6 @@ if (appVersionName == null) {
appVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
......@@ -44,7 +42,7 @@ android {
defaultConfig {
applicationId "org.benoitharrault.sudoku"
minSdkVersion 16
minSdkVersion flutter.minSdkVersion
targetSdkVersion 30
versionCode appVersionCode.toInteger()
versionName appVersionName
......
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
......
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.1.12
app.versionCode=61
app.versionName=0.1.16
app.versionCode=65
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}
settings.ext.flutterSdkPath = flutterSdkPath()
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.2.2" apply false
id "org.jetbrains.kotlin.android" version "1.9.22" apply false
}
include ":app"
Add automatic flutter linter. Apply code lints. Update dependencies.
Update flutter gradle plugin.
Avoid print calls in production code.
Improve CI/CD, remove "update" step, disable "build-debug" in master branch.
Ajout d'un correcteur automatique de code. Application des corrections. Mise à jour des dépendances.
Mise à jour du plugin gradle pour flutter.
Supprime les appels à print dans le code de production.
Amélioration de la CI/CD. Suppression de "update" et désactivation de "build-debug" sur master.
......@@ -5,15 +5,15 @@ import sys
from random import randint, shuffle
if (len(sys.argv) != 3):
print('Usage: generate.py block-size difficulty')
print('block-size: [2x2|3x2|3x3|4x4]')
print('difficulty: [easy|medium|hard|nightmare]')
printlog('Usage: generate.py block-size difficulty')
printlog('block-size: [2x2|3x2|3x3|4x4]')
printlog('difficulty: [easy|medium|hard|nightmare]')
exit()
blocksize, difficulty = sys.argv[1], sys.argv[2]
if blocksize not in ['2x2', '3x2', '3x3', '4x4']:
print('wrong size given')
printlog('wrong size given')
exit()
splitted_blocksize = blocksize.split('x')
......@@ -23,7 +23,7 @@ size_vertical = int(splitted_blocksize[1])
boardSize = size_horizontal * size_vertical
if difficulty not in ['easy', 'medium', 'hard', 'nightmare']:
print('wrong difficulty given')
printlog('wrong difficulty given')
exit()
debugFillGrid = False
......
......@@ -14,14 +14,14 @@
import sys
if (len(sys.argv) != 3):
print('Usage: solve.py block-size grid')
print('block-size: [2x2|3x2|3x3|4x4]')
printlog('Usage: solve.py block-size grid')
printlog('block-size: [2x2|3x2|3x3|4x4]')
exit()
blocksize, gridTemplate = sys.argv[1], sys.argv[2]
if blocksize not in ['2x2', '3x2', '3x3', '4x4']:
print('wrong size given')
printlog('wrong size given')
exit()
splitted_blocksize = blocksize.split('x')
......@@ -31,7 +31,7 @@ size_vertical = int(splitted_blocksize[1])
boardSize = size_horizontal * size_vertical
if (len(gridTemplate) != boardSize * boardSize):
print('wrong grid length (should be ' + str(boardSize * boardSize) + ')')
printlog('wrong grid length (should be ' + str(boardSize * boardSize) + ')')
exit()
debugSolveGrid = False
......@@ -112,7 +112,7 @@ def hasConflict(grid, size_horizontal, size_vertical):
if value != 0:
values.append(value)
if containsDuplicates(values):
# print('Horizontal conflict found')
# printlog('Horizontal conflict found')
return True
# Check vertical conflicts
......@@ -123,7 +123,7 @@ def hasConflict(grid, size_horizontal, size_vertical):
if value != 0:
values.append(value)
if containsDuplicates(values):
# print('Vertical conflict found')
# printlog('Vertical conflict found')
return True
# Check sub-blocks conflicts
......@@ -139,7 +139,7 @@ def hasConflict(grid, size_horizontal, size_vertical):
if value != 0:
values.append(value)
if containsDuplicates(values):
# print('Sub-block conflict found')
# printlog('Sub-block conflict found')
return True
return False
......@@ -176,18 +176,18 @@ def solve(grid, size_horizontal, size_vertical):
break
if debugSolveGrid:
print('===================================')
print('Iteration: ' + str(iterations))
printlog('===================================')
printlog('Iteration: ' + str(iterations))
# Get first/next cell with only one allowed value
candidates = []
if debugSolveGrid:
print('Searching for empty cells...')
printlog('Searching for empty cells...')
for row in range(len(grid)):
for col in range(len(grid[row])):
if grid[row][col] == 0:
if debugSolveGrid:
print(
printlog(
'Found empty cell [' + str(col) + ',' + str(row) + ']')
candidates.append([row, col])
......@@ -198,16 +198,16 @@ def solve(grid, size_horizontal, size_vertical):
allowedValues = findAllowedValuesForCell(
grid, size_horizontal, size_vertical, candidateRow, candidateCol)
if debugSolveGrid:
print('Allowed values for cell [' + str(candidateCol) + ',' + str(
printlog('Allowed values for cell [' + str(candidateCol) + ',' + str(
candidateRow) + ']: ' + str(allowedValues))
if len(allowedValues) != 1:
if debugSolveGrid:
print(' Non unique allowed value for cell. Skip to next cell')
printlog(' Non unique allowed value for cell. Skip to next cell')
else:
value = allowedValues[0]
grid[candidateRow][candidateCol] = value
if debugSolveGrid:
print(' Found unique allowed value for cell [' + str(
printlog(' Found unique allowed value for cell [' + str(
candidateCol) + ',' + str(candidateRow) + ']: ' + str(value))
drawGrid(grid)
......
import 'package:flutter/material.dart';
import '../provider/data.dart';
import '../utils/board_animate.dart';
import '../utils/board_utils.dart';
import 'package:sudoku/provider/data.dart';
import 'package:sudoku/utils/board_animate.dart';
import 'package:sudoku/utils/board_utils.dart';
class Cell {
int value;
......@@ -20,18 +20,18 @@ class Cell {
* Build widget for board cell, with interactions
*/
Container widget(Data myProvider, int row, int col) {
String imageAsset = this.getImageAssetName(myProvider);
final String imageAsset = getImageAssetName(myProvider);
return Container(
decoration: BoxDecoration(
color: this.getBackgroundColor(myProvider),
border: this.getCellBorders(myProvider, row, col),
color: getBackgroundColor(myProvider),
border: getCellBorders(myProvider, row, col),
),
child: GestureDetector(
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 100),
transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(child: child, scale: animation);
return ScaleTransition(scale: animation, child: child);
},
child: Image(
image: AssetImage(imageAsset),
......@@ -54,22 +54,22 @@ class Cell {
* Build widget for select/update value cell, with interactions
*/
Container widgetUpdateValue(Data myProvider) {
if (this.value < 0) {
if (value < 0) {
return Container();
}
String imageAsset = this.getImageAssetName(myProvider);
final String imageAsset = getImageAssetName(myProvider);
Color backgroundColor = Colors.grey.shade200;
if (myProvider.showConflicts &&
myProvider.currentCellCol != null &&
myProvider.currentCellRow != null) {
List cells = myProvider.cells;
int blockSizeHorizontal = myProvider.blockSizeHorizontal;
int blockSizeVertical = myProvider.blockSizeVertical;
final List<List<Cell>> cells = myProvider.cells;
final int blockSizeHorizontal = myProvider.blockSizeHorizontal;
final int blockSizeVertical = myProvider.blockSizeVertical;
if (!BoardUtils.isValueAllowed(cells, blockSizeHorizontal, blockSizeVertical,
myProvider.currentCellCol, myProvider.currentCellRow, this.value)) {
myProvider.currentCellCol, myProvider.currentCellRow, value)) {
backgroundColor = Colors.pink.shade100;
}
}
......@@ -87,7 +87,7 @@ class Cell {
onTap: () {
if (myProvider.currentCellCol != null && myProvider.currentCellRow != null) {
myProvider.updateCellValue(
myProvider.currentCellCol, myProvider.currentCellRow, this.value);
myProvider.currentCellCol, myProvider.currentCellRow, value);
}
myProvider.selectCell(null, null);
if (BoardUtils.checkBoardIsSolved(myProvider)) {
......@@ -101,51 +101,49 @@ class Cell {
* Compute image asset name, from skin and cell value/state
*/
String getImageAssetName(Data myProvider) {
String imageAsset = 'assets/icons/cell_empty.png';
if (this.value > 0) {
int cellValue = myProvider.getTranslatedValueForDisplay(this.value);
imageAsset =
'assets/skins/' + myProvider.parameterSkin + '_' + cellValue.toString() + '.png';
if (value > 0) {
int cellValue = myProvider.getTranslatedValueForDisplay(value);
return 'assets/skins/${myProvider.parameterSkin}_$cellValue.png';
}
return imageAsset;
return 'assets/icons/cell_empty.png';
}
// Compute cell background color, from cell state
Color getBackgroundColor(Data myProvider) {
Color editableCellColor = Colors.grey.shade100;
Color editableCellColorConflict = Colors.pink.shade100;
Color fixedCellColor = Colors.grey.shade300;
Color fixedCellColorConflict = Colors.pink.shade200;
Color editableSelectedValueColor = Colors.green.shade100;
Color fixedSelectedValueColor = Colors.green.shade300;
Color editableAnimated = Colors.green.shade200;
Color fixedAnimated = Colors.green.shade300;
final Color editableCellColor = Colors.grey.shade100;
final Color editableCellColorConflict = Colors.pink.shade100;
final Color fixedCellColor = Colors.grey.shade300;
final Color fixedCellColorConflict = Colors.pink.shade200;
final Color editableSelectedValueColor = Colors.green.shade100;
final Color fixedSelectedValueColor = Colors.green.shade300;
final Color editableAnimated = Colors.green.shade200;
final Color fixedAnimated = Colors.green.shade300;
Color backgroundColor = editableCellColor;
if (this.isFixed) {
if (isFixed) {
backgroundColor = fixedCellColor;
}
if (myProvider.showConflicts && (this.conflictsCount != 0)) {
if (this.isFixed) {
if (myProvider.showConflicts && (conflictsCount != 0)) {
if (isFixed) {
backgroundColor = fixedCellColorConflict;
} else {
backgroundColor = editableCellColorConflict;
}
}
if (myProvider.showConflicts && (this.value == myProvider.currentCellValue)) {
if (this.isFixed) {
if (myProvider.showConflicts && (value == myProvider.currentCellValue)) {
if (isFixed) {
backgroundColor = fixedSelectedValueColor;
} else {
backgroundColor = editableSelectedValueColor;
}
}
if (this.isAnimated) {
if (this.isFixed) {
if (isAnimated) {
if (isFixed) {
backgroundColor = fixedAnimated;
} else {
backgroundColor = editableAnimated;
......@@ -157,18 +155,18 @@ class Cell {
// Compute cell borders, from board size and cell state
Border getCellBorders(Data myProvider, int row, int col) {
int blockSizeHorizontal = myProvider.blockSizeHorizontal;
int blockSizeVertical = myProvider.blockSizeVertical;
final int blockSizeHorizontal = myProvider.blockSizeHorizontal;
final int blockSizeVertical = myProvider.blockSizeVertical;
Color cellBorderDarkColor = Colors.black;
Color cellBorderLightColor = Colors.grey;
Color cellBorderSelectedColor = Colors.red;
const Color cellBorderDarkColor = Colors.black;
const Color cellBorderLightColor = Colors.grey;
const Color cellBorderSelectedColor = Colors.red;
Color cellBorderColor = cellBorderSelectedColor;
double cellBorderWidth = 4;
// Reduce cell border width on big boards
int boardSize = blockSizeVertical * blockSizeHorizontal;
final int boardSize = blockSizeVertical * blockSizeHorizontal;
if (boardSize > 8) {
cellBorderWidth = 2;
if (boardSize > 10) {
......
import 'package:flutter/material.dart';
import '../provider/data.dart';
import 'package:sudoku/entities/cell.dart';
import 'package:sudoku/provider/data.dart';
class Board {
static Container buildGameBoard(Data myProvider) {
Color borderColor = Colors.black;
const Color borderColor = Colors.black;
return Container(
margin: EdgeInsets.all(2),
padding: EdgeInsets.all(2),
margin: const EdgeInsets.all(2),
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
color: borderColor,
borderRadius: BorderRadius.circular(2),
......@@ -25,14 +26,14 @@ class Board {
);
}
static Table buildGameTileset(Data myProvider) {
int boardSize = myProvider.blockSizeHorizontal * myProvider.blockSizeVertical;
List cells = myProvider.cells;
static Widget buildGameTileset(Data myProvider) {
final int boardSize = myProvider.blockSizeHorizontal * myProvider.blockSizeVertical;
final List<List<Cell>> cells = myProvider.cells;
return Table(defaultColumnWidth: IntrinsicColumnWidth(), children: [
for (var row = 0; row < boardSize; row++)
return Table(defaultColumnWidth: const IntrinsicColumnWidth(), children: [
for (int row = 0; row < boardSize; row++)
TableRow(children: [
for (var col = 0; col < boardSize; col++)
for (int col = 0; col < boardSize; col++)
Column(children: [cells[row][col].widget(myProvider, row, col)]),
]),
]);
......
......@@ -2,55 +2,53 @@ import 'dart:math';
import 'package:flutter/material.dart';
import '../entities/cell.dart';
import '../layout/board.dart';
import '../provider/data.dart';
import '../utils/board_utils.dart';
import '../utils/game_utils.dart';
import 'package:sudoku/entities/cell.dart';
import 'package:sudoku/layout/board.dart';
import 'package:sudoku/provider/data.dart';
import 'package:sudoku/utils/board_utils.dart';
import 'package:sudoku/utils/game_utils.dart';
class Game {
static Container buildGameWidget(Data myProvider) {
bool gameIsFinished = BoardUtils.checkBoardIsSolved(myProvider);
static Widget buildGameWidget(Data myProvider) {
final bool gameIsFinished = BoardUtils.checkBoardIsSolved(myProvider);
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Board.buildGameBoard(myProvider),
SizedBox(height: 2),
gameIsFinished
? Game.buildEndGameMessage(myProvider)
: Game.buildSelectCellValueBar(myProvider),
],
),
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Board.buildGameBoard(myProvider),
const SizedBox(height: 2),
gameIsFinished
? Game.buildEndGameMessage(myProvider)
: Game.buildSelectCellValueBar(myProvider),
],
);
}
static Container buildSelectCellValueBar(Data myProvider) {
List cells = myProvider.cells;
final List<List<Cell>> cells = myProvider.cells;
bool isCellSelected =
final bool isCellSelected =
(myProvider.currentCellCol != null && myProvider.currentCellRow != null);
bool isUpdatableCellSelected = isCellSelected
final bool isUpdatableCellSelected = isCellSelected
? !cells[myProvider.currentCellRow ?? 0][myProvider.currentCellCol ?? 0].isFixed
: false;
int maxValue = myProvider.blockSizeHorizontal * myProvider.blockSizeVertical;
final int maxValue = myProvider.blockSizeHorizontal * myProvider.blockSizeVertical;
int maxItemsPerLine = 10;
int linesCount = (maxValue / maxItemsPerLine).floor() + 1;
int itemsCountPerLine = min(maxItemsPerLine, maxValue + 1);
const int maxItemsPerLine = 10;
final int linesCount = (maxValue / maxItemsPerLine).floor() + 1;
final int itemsCountPerLine = min(maxItemsPerLine, maxValue + 1);
return Container(
margin: EdgeInsets.all(2),
padding: EdgeInsets.all(2),
margin: const EdgeInsets.all(2),
padding: const EdgeInsets.all(2),
child: Table(
defaultColumnWidth: IntrinsicColumnWidth(),
defaultColumnWidth: const IntrinsicColumnWidth(),
children: [
for (var lineIndex = 0; lineIndex < linesCount; lineIndex++)
for (int lineIndex = 0; lineIndex < linesCount; lineIndex++)
TableRow(
children: [
for (var value = lineIndex * itemsCountPerLine;
for (int value = lineIndex * itemsCountPerLine;
value < (lineIndex + 1) * itemsCountPerLine;
value++)
Column(
......@@ -67,33 +65,31 @@ class Game {
);
}
static TextButton buildRestartGameButton(Data myProvider) {
static Widget buildRestartGameButton(Data myProvider) {
return TextButton(
child: Container(
child: Image(
image: AssetImage('assets/icons/button_back.png'),
fit: BoxFit.fill,
),
child: const Image(
image: AssetImage('assets/icons/button_back.png'),
fit: BoxFit.fill,
),
onPressed: () => GameUtils.quitGame(myProvider),
);
}
static Container buildEndGameMessage(Data myProvider) {
Image decorationImage = Image(
const Image decorationImage = Image(
image: AssetImage('assets/icons/game_win.png'),
fit: BoxFit.fill,
);
return Container(
margin: EdgeInsets.all(2),
padding: EdgeInsets.all(2),
margin: const EdgeInsets.all(2),
padding: const EdgeInsets.all(2),
child: Table(
defaultColumnWidth: IntrinsicColumnWidth(),
defaultColumnWidth: const IntrinsicColumnWidth(),
children: [
TableRow(
children: [
Column(
const Column(
children: [decorationImage],
),
Column(
......@@ -103,7 +99,7 @@ class Game {
: buildRestartGameButton(myProvider)
],
),
Column(
const Column(
children: [decorationImage],
),
],
......
import 'package:flutter/material.dart';
import '../provider/data.dart';
import '../utils/game_utils.dart';
import 'package:sudoku/provider/data.dart';
import 'package:sudoku/utils/game_utils.dart';
class Parameters {
static double separatorHeight = 2.0;
static double blockMargin = 3.0;
static double blockPadding = 2.0;
static Color buttonBackgroundColor = Colors.white;
static Color buttonBorderColorActive = Colors.blue;
static Color buttonBorderColorInactive = Colors.white;
static double buttonBorderWidth = 10.0;
static double buttonBorderRadius = 8.0;
static double buttonPadding = 0.0;
static double buttonMargin = 0.0;
static Container buildParametersSelector(Data myProvider) {
static const double separatorHeight = 2.0;
static const double blockMargin = 3.0;
static const double blockPadding = 2.0;
static const Color buttonBackgroundColor = Colors.white;
static const Color buttonBorderColorActive = Colors.blue;
static const Color buttonBorderColorInactive = Colors.white;
static const double buttonBorderWidth = 10.0;
static const double buttonBorderRadius = 8.0;
static const double buttonPadding = 0.0;
static const double buttonMargin = 0.0;
static Widget buildParametersSelector(Data myProvider) {
List<Widget> lines = [];
List parameters = myProvider.availableParameters;
for (var index = 0; index < parameters.length; index++) {
List<String> parameters = myProvider.availableParameters;
for (int index = 0; index < parameters.length; index++) {
lines.add(buildParameterSelector(myProvider, parameters[index]));
lines.add(SizedBox(height: separatorHeight));
lines.add(const SizedBox(height: separatorHeight));
}
myProvider.loadCurrentSavedState();
......@@ -29,31 +29,29 @@ class Parameters {
? buildResumeGameButton(myProvider)
: buildStartNewGameButton(myProvider);
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: separatorHeight),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: lines,
),
),
SizedBox(height: separatorHeight),
Container(
child: buttonsBlock,
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: separatorHeight),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: lines,
),
],
),
),
const SizedBox(height: separatorHeight),
Container(
child: buttonsBlock,
),
],
);
}
static Image buildImageWidget(String imageAssetCode) {
return Image(
image: AssetImage('assets/icons/' + imageAssetCode + '.png'),
image: AssetImage('assets/icons/$imageAssetCode.png'),
fit: BoxFit.fill,
);
}
......@@ -69,7 +67,7 @@ class Parameters {
children: [
TextButton(
child: buildImageContainerWidget('placeholder'),
onPressed: () => null,
onPressed: () {},
),
],
);
......@@ -77,10 +75,10 @@ class Parameters {
static Container buildStartNewGameButton(Data myProvider) {
return Container(
margin: EdgeInsets.all(blockMargin),
padding: EdgeInsets.all(blockPadding),
margin: const EdgeInsets.all(blockMargin),
padding: const EdgeInsets.all(blockPadding),
child: Table(
defaultColumnWidth: IntrinsicColumnWidth(),
defaultColumnWidth: const IntrinsicColumnWidth(),
children: [
TableRow(
children: [
......@@ -103,10 +101,10 @@ class Parameters {
static Container buildResumeGameButton(Data myProvider) {
return Container(
margin: EdgeInsets.all(blockMargin),
padding: EdgeInsets.all(blockPadding),
margin: const EdgeInsets.all(blockMargin),
padding: const EdgeInsets.all(blockPadding),
child: Table(
defaultColumnWidth: IntrinsicColumnWidth(),
defaultColumnWidth: const IntrinsicColumnWidth(),
children: [
TableRow(
children: [
......@@ -135,18 +133,18 @@ class Parameters {
}
static Widget buildParameterSelector(Data myProvider, String parameterCode) {
List availableValues = myProvider.getParameterAvailableValues(parameterCode);
List<String> availableValues = myProvider.getParameterAvailableValues(parameterCode);
if (availableValues.length == 1) {
return SizedBox(height: 0.0);
return const SizedBox(height: 0.0);
}
return Table(
defaultColumnWidth: IntrinsicColumnWidth(),
defaultColumnWidth: const IntrinsicColumnWidth(),
children: [
TableRow(
children: [
for (var index = 0; index < availableValues.length; index++)
for (int index = 0; index < availableValues.length; index++)
Column(
children: [
_buildParameterButton(myProvider, parameterCode, availableValues[index])
......@@ -163,12 +161,12 @@ class Parameters {
String currentValue = myProvider.getParameterValue(parameterCode).toString();
bool isActive = (parameterValue == currentValue);
String imageAsset = parameterCode + '_' + parameterValue;
String imageAsset = '${parameterCode}_$parameterValue';
return TextButton(
child: Container(
margin: EdgeInsets.all(buttonMargin),
padding: EdgeInsets.all(buttonPadding),
margin: const EdgeInsets.all(buttonMargin),
padding: const EdgeInsets.all(buttonPadding),
decoration: BoxDecoration(
color: buttonBackgroundColor,
borderRadius: BorderRadius.circular(buttonBorderRadius),
......