croupier: Modify Board's Tap targets to workaround Tap Bug
There's an onTap bug in Flutter (or Modroid)
https://github.com/flutter/flutter/issues/1497
I have to investigate further, but for now, we're going to workaround
it by mocking the center "Take" button with a styled Container.
Change-Id: I038121b62388a74384e2ff13cc6aaabb20f2d19d
diff --git a/lib/components/board.dart b/lib/components/board.dart
index 9f6bbfc..1e5d9ad 100644
--- a/lib/components/board.dart
+++ b/lib/components/board.dart
@@ -417,13 +417,18 @@
return false;
}
- void localAskCb() {
- // Try to increment. If it fails, be lenient! Give 0.5 seconds to check this
- // condition again.
- if (!_incrementLocalAsking()) {
- new Future.delayed(const Duration(milliseconds: 500), () {
- _incrementLocalAsking(); // give it one more shot
- });
+ void _boardLayoutTapCb() {
+ // You can tap anywhere on the board to fake "Ask" or "Take Trick".
+ if (localAsking < 4) {
+ // Try to increment. If it fails, be lenient! Give 0.5 seconds to check
+ // this condition again.
+ if (!_incrementLocalAsking()) {
+ new Future.delayed(const Duration(milliseconds: 500), () {
+ _incrementLocalAsking(); // give it one more shot
+ });
+ }
+ } else {
+ config.game.takeTrickUI();
}
}
@@ -432,16 +437,8 @@
? config.game.determineTrickWinner()
: config.game.whoseTurn;
- // You can tap anywhere on the board to fake "Ask" or "Take Trick".
- NoArgCb tapCb;
- if (localAsking < 4) {
- tapCb = localAskCb;
- } else if (localAsking == 4) {
- tapCb = config.game.takeTrickUI;
- }
-
return new GestureDetector(
- onTap: tapCb,
+ onTap: _boardLayoutTapCb,
child: new Container(
height: config.height,
width: config.width,
@@ -494,8 +491,6 @@
}
Widget _buildCenterCards() {
- //bool wide = (config.width >= config.height);
-
double height = config.cardHeight * this._centerScaleFactor;
double width = config.cardWidth * this._centerScaleFactor;
Widget centerPiece = new Container(
@@ -503,15 +498,20 @@
if (localAsking == 4) {
// If all cards played are revealed, show Take Trick button.
int rotateNum = config.game.determineTrickWinner();
+ double smaller = math.min(height, width);
+ // TODO(alexfandrianto): The Text looks great within the square
+ // container, but this is supposed to be pressable like a button.
+ // The reason why I did it this way is that the button's disappearance
+ // prevents the board's onTap handler from firing.
+ // https://github.com/flutter/flutter/issues/1497
centerPiece = _rotate(
new Container(
- height: height,
- width: width,
- child: new RaisedButton(
- child: new Text("Take", style: style.Text.largeStyle),
- onPressed: config.game.takeTrickUI,
- color: style.theme.accentColor)),
+ height: smaller,
+ width: smaller,
+ decoration: style.Box.liveBackground,
+ child: new Center(
+ child: new Text("Take", style: style.Text.largeStyle))),
rotateNum);
}
@@ -530,7 +530,11 @@
child: new Row(
children: [
new Flexible(child: new Center(child: _buildCenterCard(1))),
- new Flexible(child: new Block(children: [centerPiece])),
+ new Flexible(
+ child: new Row(
+ children: [centerPiece],
+ alignItems: FlexAlignItems.center,
+ justifyContent: FlexJustifyContent.center)),
new Flexible(child: new Center(child: _buildCenterCard(3))),
],
alignItems: FlexAlignItems.center,