mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
linting
This commit is contained in:
@ -12,7 +12,12 @@ void main() async {
|
|||||||
final nineTileBoxImage = await Flame.images.load('nine_tile_box.png');
|
final nineTileBoxImage = await Flame.images.load('nine_tile_box.png');
|
||||||
await Flame.images.load('buttons.png');
|
await Flame.images.load('buttons.png');
|
||||||
|
|
||||||
final _buttons = SpriteSheet(imageName: 'buttons.png', textureHeight: 20, textureWidth: 60, columns: 1, rows: 2);
|
final _buttons = SpriteSheet(
|
||||||
|
imageName: 'buttons.png',
|
||||||
|
textureHeight: 20,
|
||||||
|
textureWidth: 60,
|
||||||
|
columns: 1,
|
||||||
|
rows: 2);
|
||||||
|
|
||||||
final dashbook = Dashbook();
|
final dashbook = Dashbook();
|
||||||
|
|
||||||
@ -37,16 +42,19 @@ void main() async {
|
|||||||
));
|
));
|
||||||
|
|
||||||
dashbook.storiesOf('SpriteButton').decorator(CenterDecorator()).add(
|
dashbook.storiesOf('SpriteButton').decorator(CenterDecorator()).add(
|
||||||
'default',
|
'default',
|
||||||
(ctx) => Container(padding: const EdgeInsets.all(20), child: SpriteButton(
|
(ctx) => Container(
|
||||||
onPressed: () {
|
padding: const EdgeInsets.all(20),
|
||||||
print('Pressed');
|
child: SpriteButton(
|
||||||
},
|
onPressed: () {
|
||||||
label: const Text('Sprite Button', style: const TextStyle(color: const Color(0xFF5D275D))),
|
print('Pressed');
|
||||||
sprite: _buttons.getSprite(0, 0),
|
},
|
||||||
pressedSprite: _buttons.getSprite(1, 0),
|
label: const Text('Sprite Button',
|
||||||
)),
|
style: const TextStyle(color: const Color(0xFF5D275D))),
|
||||||
);
|
sprite: _buttons.getSprite(0, 0),
|
||||||
|
pressedSprite: _buttons.getSprite(1, 0),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
|
||||||
runApp(dashbook);
|
runApp(dashbook);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@ class SpriteButton extends StatefulWidget {
|
|||||||
@required this.label,
|
@required this.label,
|
||||||
@required this.sprite,
|
@required this.sprite,
|
||||||
@required this.pressedSprite,
|
@required this.pressedSprite,
|
||||||
|
|
||||||
this.width,
|
this.width,
|
||||||
this.height,
|
this.height,
|
||||||
});
|
});
|
||||||
@ -33,31 +32,32 @@ class _ButtonState extends State<SpriteButton> {
|
|||||||
final height = widget.height ?? 50;
|
final height = widget.height ?? 50;
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTapDown: (_) {
|
onTapDown: (_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_pressed = true;
|
_pressed = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onTapUp: (_) {
|
onTapUp: (_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_pressed = false;
|
_pressed = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.onPressed?.call();
|
widget.onPressed?.call();
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
painter: _ButtonPainer(_pressed ? widget.pressedSprite : widget.sprite),
|
painter:
|
||||||
child: Center(
|
_ButtonPainer(_pressed ? widget.pressedSprite : widget.sprite),
|
||||||
child: Container(
|
child: Center(
|
||||||
padding: _pressed ? const EdgeInsets.only(top: 5) : null,
|
child: Container(
|
||||||
child: widget.label,
|
padding: _pressed ? const EdgeInsets.only(top: 5) : null,
|
||||||
),
|
child: widget.label,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user