Skip to content

Commit 2a6db06

Browse files
authored
Updated to include icons on the buttons
Added code to put icons on the blue controller buttons to make it more obvious what the buttons do.
1 parent c3291eb commit 2a6db06

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

lib/panel/controller.dart

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ class DirectionController extends StatelessWidget {
4444
_Button(
4545
enableLongPress: false,
4646
size: _DIRECTION_BUTTON_SIZE,
47+
typeOfButton: ButtonType.RotateRight,
4748
onTap: () {
4849
Game.of(context).rotate();
4950
}),
5051
SizedBox(width: _DIRECTION_SPACE),
5152
_Button(
5253
size: _DIRECTION_BUTTON_SIZE,
54+
typeOfButton: ButtonType.MoveRight,
5355
onTap: () {
5456
Game.of(context).right();
5557
}),
@@ -61,12 +63,14 @@ class DirectionController extends StatelessWidget {
6163
children: <Widget>[
6264
_Button(
6365
size: _DIRECTION_BUTTON_SIZE,
66+
typeOfButton: ButtonType.MoveLeft,
6467
onTap: () {
6568
Game.of(context).left();
6669
}),
6770
SizedBox(width: _DIRECTION_SPACE),
6871
_Button(
6972
size: _DIRECTION_BUTTON_SIZE,
73+
typeOfButton: ButtonType.Down,
7074
onTap: () {
7175
Game.of(context).down();
7276
},
@@ -118,6 +122,7 @@ class DropButton extends StatelessWidget {
118122
return _Button(
119123
enableLongPress: false,
120124
size: Size(90, 90),
125+
typeOfButton: ButtonType.Drop,
121126
onTap: () {
122127
Game.of(context).drop();
123128
});
@@ -176,8 +181,11 @@ class _SystemButton extends StatelessWidget {
176181
}
177182
}
178183

184+
enum ButtonType { MoveLeft, RotateRight, MoveRight, Down, Drop }
185+
179186
class _Button extends StatefulWidget {
180187
final Size size;
188+
final ButtonType typeOfButton;
181189

182190
final VoidCallback onTap;
183191

@@ -190,6 +198,7 @@ class _Button extends StatefulWidget {
190198
{Key key,
191199
@required this.size,
192200
@required this.onTap,
201+
@required this.typeOfButton,
193202
this.color = Colors.blue,
194203
this.enableLongPress = true})
195204
: super(key: key);
@@ -268,7 +277,20 @@ class _ButtonState extends State<_Button> {
268277
_color = widget.color;
269278
});
270279
},
271-
child: SizedBox.fromSize(size: widget.size),
280+
child: SizedBox.fromSize(
281+
size: widget.size,
282+
child: widget.typeOfButton ==ButtonType.Drop ?
283+
Icon(Icons.file_download, color: Colors.white)
284+
: Transform.rotate(angle: - (math.pi/ 12.0) * 3,
285+
child: Icon(
286+
widget.typeOfButton ==ButtonType.Down ? Icons.arrow_downward :
287+
(widget.typeOfButton ==ButtonType.MoveLeft) ? Icons.chevron_left :
288+
(widget.typeOfButton ==ButtonType.MoveRight) ? Icons.chevron_right :
289+
(widget.typeOfButton ==ButtonType.RotateRight) ? Icons.rotate_right :
290+
Icons.not_interested
291+
, color: Colors.white),
292+
),
293+
),
272294
),
273295
);
274296
}

0 commit comments

Comments
 (0)