bullseye/lib/main.dart

79 lines
2.1 KiB
Dart
Raw Normal View History

2021-04-28 06:07:43 -04:00
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:bullseye/prompt.dart';
import 'package:bullseye/control.dart';
import 'package:bullseye/score.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
2021-04-28 06:07:43 -04:00
void main() => runApp(BullsEyeApp());
class BullsEyeApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
2021-04-28 06:07:43 -04:00
return MaterialApp(
title: 'BullsEye',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: GamePage(title: 'BullsEye'),
);
}
}
class GamePage extends StatefulWidget {
2021-05-08 19:00:08 -04:00
GamePage({Key? key, this.title}) : super(key: key);
final String? title;
2021-04-28 06:07:43 -04:00
@override
_GamePageState createState() => _GamePageState();
}
class _GamePageState extends State<GamePage> {
2021-05-08 19:41:13 -04:00
bool _alertIsVisable = false;
2021-04-28 06:07:43 -04:00
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Prompt(targetValue: 100),
Control(),
PlatformTextButton(
child: PlatformText('Hit me!'),
2021-05-08 19:41:13 -04:00
onPressed: () {
this._alertIsVisable = true;
_showAlert(context);
}),
Score()
2021-04-28 06:07:43 -04:00
],
),
),
);
}
2021-05-08 19:41:13 -04:00
void _showAlert(BuildContext context) {
Widget okButton = TextButton(
child: PlatformText("Awesome!"),
2021-05-08 19:41:13 -04:00
onPressed: () {
Navigator.of(context).pop();
this._alertIsVisable = false;
print("Awesome Pressed! $_alertIsVisable");
});
showDialog(
context: context,
builder: (BuildContext context) {
return PlatformAlertDialog(
2021-05-08 19:41:13 -04:00
title: Text("Hello There."),
content: Text("This is my first pop-up."),
actions: <Widget>[okButton],
);
});
}
2021-04-28 06:07:43 -04:00
}