Skip to content

Commit

Permalink
Add Steam Play enable tile to UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ashuntu committed Sep 16, 2024
1 parent dfb0fcc commit 4069323
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 22 deletions.
2 changes: 2 additions & 0 deletions packages/game_center/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
"launcherPageLabel": "Apps",

"steamPageLabel": "Steam",
"steamPageTitle": "Steam Tweaks",
"steamGlobalConfigTitle": "Steam Global Config",
"steamUserConfigTitle": "Steam User Configs",
"steamEnableProton": "Enable Steam Play (Proton) for all titles",

"settingsPageLabel": "Settings",

Expand Down
20 changes: 10 additions & 10 deletions packages/game_center/lib/layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ import 'package:flutter/widgets.dart';
const kPagePadding = 24.0;

class AppScrollView extends StatelessWidget {
AppScrollView({required this.children});
AppScrollView({required this.slivers});

final List<Widget> children;
final List<Widget> slivers;

@override
Widget build(BuildContext context) {
return CustomScrollView(
slivers: [
SliverPadding(
padding: EdgeInsets.all(kPagePadding),
sliver: SliverList.list(
children: children,
),
)
],
slivers: slivers
.map(
(s) => SliverPadding(
padding: EdgeInsets.all(kPagePadding),
sliver: s,
),
)
.toList(),
);
}
}
58 changes: 46 additions & 12 deletions packages/game_center/lib/steam/steam_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,35 @@ class SteamPage extends ConsumerWidget {

return steam.when(
data: (data) => AppScrollView(
children: [
Text(
l10n.steamGlobalConfigTitle,
style: Theme.of(context).textTheme.headlineSmall,
slivers: [
SliverList.list(
children: [
Text(
l10n.steamPageTitle,
style: Theme.of(context).textTheme.headlineMedium,
),
const SizedBox(height: kPagePadding),
],
),
const SizedBox(height: kPagePadding),
_SteamGlobalConfigText(),
const SizedBox(height: kPagePadding),
Text(
l10n.steamUserConfigTitle,
style: Theme.of(context).textTheme.headlineSmall,
_SteamSimpleSettings(),
SliverList.list(
children: [
const SizedBox(height: kPagePadding),
Text(
l10n.steamGlobalConfigTitle,
style: Theme.of(context).textTheme.headlineSmall,
),
const SizedBox(height: kPagePadding),
_SteamGlobalConfigText(),
const SizedBox(height: kPagePadding),
Text(
l10n.steamUserConfigTitle,
style: Theme.of(context).textTheme.headlineSmall,
),
const SizedBox(height: kPagePadding),
_SteamUserConfigs(),
],
),
const SizedBox(height: kPagePadding),
_SteamUserConfigs(),
],
),
loading: () => Center(
Expand All @@ -47,6 +62,25 @@ class SteamPage extends ConsumerWidget {
}
}

class _SteamSimpleSettings extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final steam = ref.watch(steamModelProvider().notifier);
final checked = steam.steamPlayEnabled();
final l10n = AppLocalizations.of(context);

return SliverList.list(children: [
YaruSwitchListTile(
title: Text(l10n.steamEnableProton),
value: checked,
onChanged: (value) async {
await steam.enableSteamPlay(enable: value);
},
),
]);
}
}

class _SteamGlobalConfigText extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
Expand Down

0 comments on commit 4069323

Please sign in to comment.