Massive overhaul

- The project was restarted using Android Studio.
- Adoptive platform-specific widgets has been removed due to build issues with Android.
- Dual-licensed under the BSD-3-Clause license and UNLICENSE.
This commit is contained in:
Tony Bark 2022-09-05 13:56:05 -04:00
parent dd34e59e94
commit cacbfc5fda
78 changed files with 612 additions and 619 deletions

View file

@ -1,6 +1,5 @@
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, @required this.model}) : super(key: key);
@ -20,12 +19,12 @@ class _ControlState extends State<Control> {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(PADDING),
child: PlatformText("1"),
const Padding(
padding: EdgeInsets.all(PADDING),
child: Text("1"),
),
Expanded(
child: PlatformSlider(
child: Slider(
value: currentValue!.toDouble(),
onChanged: (newValue) {
setState(() {
@ -36,9 +35,9 @@ class _ControlState extends State<Control> {
max: 100.0,
),
),
Padding(
padding: const EdgeInsets.all(PADDING),
child: PlatformText("100"),
const Padding(
padding: EdgeInsets.all(PADDING),
child: Text("100"),
)
],
);

View file

@ -9,7 +9,6 @@ import 'package:bullseye/prompt.dart';
import 'package:bullseye/control.dart';
import 'package:bullseye/score.dart';
import 'package:bullseye/game_model.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
const gameTitle = "Bullseye";
@ -19,7 +18,7 @@ void main() {
if (isDesktop) {
doWhenWindowReady(() {
final win = appWindow;
final minSize = Size(600, 450);
const minSize = Size(600, 450);
win.minSize = minSize;
win.size = minSize;
@ -37,7 +36,7 @@ class BullsEyeApp extends StatelessWidget {
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
return PlatformApp(
return MaterialApp(
title: gameTitle,
// debugShowCheckedModeBanner: false,
home: GamePage());
@ -77,11 +76,11 @@ class _GamePageState extends State<GamePage> {
children: [
Prompt(targetValue: _model.target),
Control(model: _model),
PlatformTextButton(
child: PlatformText('Hit me!'),
TextButton(
child: const Text('Hit me!'),
onPressed: () {
_showAlert(context);
this._alertIsVisable = true;
_alertIsVisable = true;
})
],
);
@ -122,20 +121,21 @@ class _GamePageState extends State<GamePage> {
Widget build(BuildContext context) {
return Scaffold(
body: LayoutBuilder(builder: (context, constraints) {
if (isDesktop)
if (isDesktop) {
return desktopContainer();
else
} else {
return mobileContainer();
}
}),
);
}
void _showAlert(BuildContext context) {
var okButton = PlatformTextButton(
child: PlatformText("Awesome!"),
var okButton = TextButton(
child: const Text("Awesome!"),
onPressed: () {
Navigator.of(context).pop();
this._alertIsVisable = false;
_alertIsVisable = false;
setState(() {
_model.totalScore += _pointsForCurrentRound();
var rng = Random();
@ -143,12 +143,12 @@ class _GamePageState extends State<GamePage> {
});
});
showPlatformDialog(
showDialog(
context: context,
builder: (BuildContext context) {
return PlatformAlertDialog(
title: PlatformText("Hello There."),
content: PlatformText("The slider's value is ${_sliderValue()}\n" +
return AlertDialog(
title: const Text("Hello There."),
content: Text("The slider's value is ${_sliderValue()}\n" +
"You scored ${_pointsForCurrentRound()} points this round."),
actions: <Widget>[okButton],
);

View file

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
class Prompt extends StatelessWidget {
Prompt({@required this.targetValue});
@ -9,8 +8,8 @@ class Prompt extends StatelessWidget {
Widget build(BuildContext context) {
return Column(
children: <Widget>[
PlatformText("PUT THE BULLSEYE AS CLOSE YOU CAN TO"),
PlatformText("$targetValue")
const Text("PUT THE BULLSEYE AS CLOSE YOU CAN TO"),
Text("$targetValue")
],
);
}

View file

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
class Score extends StatelessWidget {
Score({Key? key, @required this.totalScore, @required this.round})
@ -13,16 +12,16 @@ class Score extends StatelessWidget {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PlatformTextButton(
child: PlatformText("Start Over"),
TextButton(
child: Text("Start Over"),
onPressed: () {},
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
PlatformText("Score:"),
PlatformText("$totalScore"),
Text("Score:"),
Text("$totalScore"),
],
),
),
@ -30,13 +29,13 @@ class Score extends StatelessWidget {
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
PlatformText("Round:"),
PlatformText("$round"),
Text("Round:"),
Text("$round"),
],
),
),
PlatformTextButton(
child: PlatformText("Info"),
TextButton(
child: Text("Info"),
onPressed: () {},
)
],