Select Git revision
-
Benoît Harrault authoredBenoît Harrault authored
cell.dart 3.99 KiB
import 'package:flutter/material.dart';
import '../provider/data.dart';
class Cell {
int value;
bool isFixed;
int conflictsCount = 0;
Cell(
@required this.value,
@required this.isFixed,
);
static double cellBorderWidth = 3;
static Color cellBorderDarkColor = Colors.black;
static Color cellBorderLightColor = Colors.grey;
static Color cellBorderSelectedColor = Colors.red;
Container widget(Data myProvider, Border borders, int row, int col) {
String imageAsset = 'assets/skins/empty.png';
if (this.value > 0) {
imageAsset = 'assets/skins/' + myProvider.skin + '_' + this.value.toString() + '.png';
}
return Container(
decoration: BoxDecoration(
color: this.getBackgroundColor(myProvider),
border: borders,
),
child: GestureDetector(
child: Image(
image: AssetImage(imageAsset),
fit: BoxFit.fill
),
onTap: () {
if (col != null && row != null) {
if (col != myProvider.currentCellCol || row != myProvider.currentCellRow) {
myProvider.selectCell(col, row);
} else {
myProvider.selectCell(null, null);
}
}
},
)
);
}
Color getBackgroundColor(Data myProvider) {
Color editableCellColor = Colors.grey[100];
Color editableCellColorConflict = Colors.pink[100];
Color fixedCellColor = Colors.grey[300];
Color fixedCellColorConflict = Colors.pink[200];
Color editableSelectedValueColor = Colors.green[100];
Color fixedSelectedValueColor = Colors.green[300];
Color backgroundColor = editableCellColor;
if (this.isFixed) {
backgroundColor = fixedCellColor;
}
if (myProvider.showConflicts && (this.conflictsCount != 0)) {
if (this.isFixed) {
backgroundColor = fixedCellColorConflict;
} else {
backgroundColor = editableCellColorConflict;
}
}