@@ -44,12 +44,14 @@ class DirectionController extends StatelessWidget {
44
44
_Button (
45
45
enableLongPress: false ,
46
46
size: _DIRECTION_BUTTON_SIZE ,
47
+ typeOfButton: ButtonType .RotateRight ,
47
48
onTap: () {
48
49
Game .of (context).rotate ();
49
50
}),
50
51
SizedBox (width: _DIRECTION_SPACE ),
51
52
_Button (
52
53
size: _DIRECTION_BUTTON_SIZE ,
54
+ typeOfButton: ButtonType .MoveRight ,
53
55
onTap: () {
54
56
Game .of (context).right ();
55
57
}),
@@ -61,12 +63,14 @@ class DirectionController extends StatelessWidget {
61
63
children: < Widget > [
62
64
_Button (
63
65
size: _DIRECTION_BUTTON_SIZE ,
66
+ typeOfButton: ButtonType .MoveLeft ,
64
67
onTap: () {
65
68
Game .of (context).left ();
66
69
}),
67
70
SizedBox (width: _DIRECTION_SPACE ),
68
71
_Button (
69
72
size: _DIRECTION_BUTTON_SIZE ,
73
+ typeOfButton: ButtonType .Down ,
70
74
onTap: () {
71
75
Game .of (context).down ();
72
76
},
@@ -118,6 +122,7 @@ class DropButton extends StatelessWidget {
118
122
return _Button (
119
123
enableLongPress: false ,
120
124
size: Size (90 , 90 ),
125
+ typeOfButton: ButtonType .Drop ,
121
126
onTap: () {
122
127
Game .of (context).drop ();
123
128
});
@@ -176,8 +181,11 @@ class _SystemButton extends StatelessWidget {
176
181
}
177
182
}
178
183
184
+ enum ButtonType { MoveLeft , RotateRight , MoveRight , Down , Drop }
185
+
179
186
class _Button extends StatefulWidget {
180
187
final Size size;
188
+ final ButtonType typeOfButton;
181
189
182
190
final VoidCallback onTap;
183
191
@@ -190,6 +198,7 @@ class _Button extends StatefulWidget {
190
198
{Key key,
191
199
@required this .size,
192
200
@required this .onTap,
201
+ @required this .typeOfButton,
193
202
this .color = Colors .blue,
194
203
this .enableLongPress = true })
195
204
: super (key: key);
@@ -268,7 +277,20 @@ class _ButtonState extends State<_Button> {
268
277
_color = widget.color;
269
278
});
270
279
},
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
+ ),
272
294
),
273
295
);
274
296
}
0 commit comments