WIP Setup screen

This commit is contained in:
ALEZ-DEV 2024-05-21 22:26:06 +02:00
parent 338d359432
commit a94215284a
6 changed files with 121 additions and 26 deletions

View File

@ -22,6 +22,15 @@ class Settings {
return Settings(prefs: prefs);
}
String firstTimeKey = 'first_time';
bool? get firstTime {
return prefs.getBool(firstTimeKey);
}
set firstTime(bool? value) {
prefs.setBool(firstTimeKey, value!);
}
BackgroundType? _backgroundType;
String backgroundTypeKey = 'background_type';

View File

@ -5,6 +5,10 @@ class GameStateProvider with ChangeNotifier {
States? _gameState;
bool isUpdating = false;
get gameState {
return _gameState;
}
Future updateGameState() async {
if (!isUpdating) {
isUpdating = true;

View File

@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import './../models/settings.dart';
@ -8,9 +9,25 @@ class SettingsProvider with ChangeNotifier {
Future init() async {
_settings = await Settings.create();
if (kDebugMode) {
_settings.firstTime = true;
}
await Config.update();
}
bool get firstTime {
final result = _settings.firstTime;
if (result == null) {
_settings.firstTime = true;
}
return _settings.firstTime!;
}
set firstTime(bool value) {
_settings.firstTime = value;
notifyListeners();
}
set setSelectedBackgroundType(BackgroundType selectedBackground) {
_settings.selectedBackgroundType = selectedBackground;
notifyListeners();

View File

@ -1,42 +1,39 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import './../widgets/serious_lee_widget.dart';
import './../widgets/simple_button.dart';
import './../messages/game_state.pb.dart';
import './../providers/game_state_provider.dart';
import './../providers/settings_provider.dart';
import './setups/welcome_screen.dart';
import './setups/proton_screen.dart';
class SetupScreen extends StatelessWidget {
const SetupScreen({super.key});
@override
Widget build(BuildContext context) {
final gameStateProvider = Provider.of<GameStateProvider>(context);
final settingsProvider = Provider.of<SettingsProvider>(context);
final Widget content;
if (settingsProvider.firstTime) {
content = const WelcomeScreen();
} else {
switch (gameStateProvider.gameState) {
case States.ProtonNotInstalled:
content = const ProtonScreen();
case States.DXVKNotInstalled:
content = const Text('DXVK');
default:
content = const Text('???');
}
}
return Scaffold(
appBar: AppBar(
title: const Text("Babylonia Terminal"),
centerTitle: true,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SeriousLeeWidget(title: 'Welcome to Babylonia Terminal!'),
const Text(
'We have to setup some things first',
style: TextStyle(
fontSize: 20,
),
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: SizedBox(
width: 200,
child: SimpleButton(
onPressed: () {},
child: const Text('Start'),
),
),
)
],
),
),
body: content,
);
}
}

View File

@ -0,0 +1,28 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:yaru/yaru.dart';
class ProtonScreen extends StatelessWidget {
const ProtonScreen({super.key});
@override
Widget build(BuildContext context) {
return Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxHeight: 600,
maxWidth: 750,
),
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 25.0),
child: YaruSection(
headline: Center(
child: Text('Proton'),
),
child: Text('Some content'),
),
),
),
);
}
}

View File

@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import './../../providers/settings_provider.dart';
import './../../widgets/serious_lee_widget.dart';
import './../../widgets/simple_button.dart';
class WelcomeScreen extends StatelessWidget {
const WelcomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SeriousLeeWidget(title: 'Welcome to Babylonia Terminal!'),
const Text(
'We have to setup some things first',
style: TextStyle(
fontSize: 20,
),
),
Padding(
padding: const EdgeInsets.only(top: 15.0),
child: SizedBox(
width: 200,
child: SimpleButton(
onPressed: () =>
Provider.of<SettingsProvider>(context, listen: false)
.firstTime = false,
child: const Text('Start'),
),
),
)
],
),
);
}
}