mirror of
https://github.com/tonytins/bullseye.git
synced 2025-06-26 02:44:42 -04:00
Game model
This commit is contained in:
parent
9c707d1e47
commit
36c7e3d59b
4 changed files with 78 additions and 23 deletions
|
@ -1,34 +1,45 @@
|
|||
import 'package:bullseye/game_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||
|
||||
class Control extends StatefulWidget {
|
||||
Control({Key? key}) : super(key: key);
|
||||
Control({Key? key, @required this.model}) : super(key: key);
|
||||
final GameModel? model;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _ControlState();
|
||||
}
|
||||
|
||||
class _ControlState extends State<Control> {
|
||||
double _currentValue = 50.0;
|
||||
static const double PADDING = 45;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var currentValue = widget.model?.current;
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
PlatformText("1"),
|
||||
PlatformSlider(
|
||||
value: _currentValue,
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
_currentValue = newValue;
|
||||
print(_currentValue);
|
||||
});
|
||||
},
|
||||
min: 1.0,
|
||||
max: 100.0,
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(PADDING),
|
||||
child: PlatformText("1"),
|
||||
),
|
||||
PlatformText("100")
|
||||
Expanded(
|
||||
child: PlatformSlider(
|
||||
value: currentValue!.toDouble(),
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
widget.model!.current = newValue.toInt();
|
||||
});
|
||||
},
|
||||
min: 1.0,
|
||||
max: 100.0,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(PADDING),
|
||||
child: PlatformText("100"),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue