This repository has been archived by the owner on Dec 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathreadonly_rank_pair_grid.dart
78 lines (69 loc) · 2.91 KB
/
readonly_rank_pair_grid.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import "package:aqua/src/common_widgets/aqua_theme.dart";
import "package:aqua/src/constants/card.dart";
import "package:flutter/widgets.dart";
import "package:poker/poker.dart";
class ReadonlyRankPairGrid extends StatelessWidget {
ReadonlyRankPairGrid({required this.rankPairs, Key? key}) : super(key: key);
final Set<RankPair> rankPairs;
@override
Widget build(BuildContext context) {
final style = AquaTheme.of(context).rankPairGridStyle;
return LayoutBuilder(
builder: (context, constraints) => DecoratedBox(
decoration: BoxDecoration(
color: style.backgroundColor,
borderRadius: BorderRadius.circular(constraints.maxWidth * 0.05),
),
child: Table(
children: List.generate(ranksInStrongnessOrder.length, (row) {
return TableRow(
children: List.generate(ranksInStrongnessOrder.length, (column) {
final high = row < column ? row : column;
final kicker = high == row ? column : row;
final rankPairsPart = row < column
? RankPair.suited(
high: ranksInStrongnessOrder[high],
kicker: ranksInStrongnessOrder[kicker],
)
: RankPair.ofsuit(
high: ranksInStrongnessOrder[high],
kicker: ranksInStrongnessOrder[kicker],
);
BorderRadius? borderRadius;
if (row == 0 && column == 0) {
borderRadius = BorderRadius.only(
topLeft: Radius.circular(constraints.maxWidth * 0.05));
}
if (row == 0 && column == ranksInStrongnessOrder.length - 1) {
borderRadius = BorderRadius.only(
topRight: Radius.circular(constraints.maxWidth * 0.05));
}
if (row == ranksInStrongnessOrder.length - 1 && column == 0) {
borderRadius = BorderRadius.only(
bottomLeft: Radius.circular(constraints.maxWidth * 0.05));
}
if (row == ranksInStrongnessOrder.length - 1 &&
column == ranksInStrongnessOrder.length - 1) {
borderRadius = BorderRadius.only(
bottomRight:
Radius.circular(constraints.maxWidth * 0.05));
}
return TableCell(
child: Container(
height: constraints.maxWidth / 13,
decoration: BoxDecoration(
color: rankPairs.contains(rankPairsPart)
? style.selectedForegroundColor
: null,
borderRadius: borderRadius,
),
),
);
}),
);
}),
),
),
);
}
}