mirror of https://github.com/flutter/pinball.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
3 years ago
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||
|
import 'package:pinball/game/game.dart';
|
||
|
|
||
3 years ago
|
/// {@template game_hud}
|
||
3 years ago
|
/// Overlay of a [PinballGame] that displays the current [GameState.score] and
|
||
3 years ago
|
/// [GameState.balls].
|
||
|
/// {@endtemplate}
|
||
3 years ago
|
class GameHud extends StatelessWidget {
|
||
3 years ago
|
/// {@macro game_hud}
|
||
3 years ago
|
const GameHud({Key? key}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
final state = context.watch<GameBloc>().state;
|
||
|
|
||
|
return Container(
|
||
|
color: Colors.redAccent,
|
||
|
width: 200,
|
||
|
height: 100,
|
||
|
padding: const EdgeInsets.all(16),
|
||
|
child: Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
|
children: [
|
||
|
Text(
|
||
|
'${state.score}',
|
||
|
style: Theme.of(context).textTheme.headline3,
|
||
|
),
|
||
3 years ago
|
Wrap(
|
||
|
direction: Axis.vertical,
|
||
3 years ago
|
children: [
|
||
|
for (var i = 0; i < state.balls; i++)
|
||
|
const Padding(
|
||
3 years ago
|
padding: EdgeInsets.only(top: 6, right: 6),
|
||
3 years ago
|
child: CircleAvatar(
|
||
|
radius: 8,
|
||
|
backgroundColor: Colors.black,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|