feature: HTPC mode startup argument (#358)

Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
PartyDonut 2025-06-01 15:30:34 +02:00 committed by GitHub
parent a8795cf0c9
commit 69a5e3db7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 416 additions and 151 deletions

View file

@ -25,7 +25,6 @@ import 'package:fladder/util/adaptive_layout/adaptive_layout.dart';
import 'package:fladder/util/bitrate_helper.dart';
import 'package:fladder/util/box_fit_extension.dart';
import 'package:fladder/util/localization_helper.dart';
import 'package:fladder/util/option_dialogue.dart';
import 'package:fladder/widgets/shared/enum_selection.dart';
@RoutePage()
@ -74,22 +73,18 @@ class _PlayerSettingsPageState extends ConsumerState<PlayerSettingsPage> {
],
),
SettingsListTile(
label: Text(context.localized.videoScalingFillScreenTitle),
subLabel: Text(videoSettings.videoFit.label(context)),
onTap: () => openMultiSelectOptions(
context,
label: context.localized.videoScalingFillScreenTitle,
items: BoxFit.values,
selected: [ref.read(videoPlayerSettingsProvider.select((value) => value.videoFit))],
onChanged: (values) => ref.read(videoPlayerSettingsProvider.notifier).setFitType(values.first),
itemBuilder: (type, selected, tap) => RadioListTile(
groupValue: ref.read(videoPlayerSettingsProvider.select((value) => value.videoFit)),
title: Text(type.label(context)),
value: type,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
contentPadding: EdgeInsets.zero,
onChanged: (value) => tap(),
),
label: Text(context.localized.videoScaling),
trailing: EnumBox(
current: videoSettings.videoFit.label(context),
itemBuilder: (context) => BoxFit.values
.map(
(entry) => PopupMenuItem(
value: entry,
child: Text(entry.label(context)),
onTap: () => ref.read(videoPlayerSettingsProvider.notifier).setFitType(entry),
),
)
.toList(),
),
),
SettingsListTile(
@ -363,7 +358,7 @@ class _StatusIndicator extends StatelessWidget {
),
const SizedBox(width: 6),
],
label,
Flexible(child: label),
],
);
}

View file

@ -8,7 +8,7 @@ class SettingsListTile extends StatelessWidget {
final Widget? trailing;
final bool selected;
final IconData? icon;
final Widget? suffix;
final Widget? leading;
final Color? contentColor;
final Function()? onTap;
const SettingsListTile({
@ -16,7 +16,7 @@ class SettingsListTile extends StatelessWidget {
this.subLabel,
this.trailing,
this.selected = false,
this.suffix,
this.leading,
this.icon,
this.contentColor,
this.onTap,
@ -27,7 +27,7 @@ class SettingsListTile extends StatelessWidget {
Widget build(BuildContext context) {
final iconWidget = icon != null ? Icon(icon) : null;
final leadingWidget = (suffix ?? iconWidget) != null
final leadingWidget = (leading ?? iconWidget) != null
? Padding(
padding: const EdgeInsets.only(left: 8, right: 16.0),
child: AnimatedContainer(
@ -38,11 +38,11 @@ class SettingsListTile extends StatelessWidget {
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 12),
child: (suffix ?? iconWidget),
child: (leading ?? iconWidget),
),
),
)
: suffix ?? const SizedBox();
: leading ?? const SizedBox();
return Card(
elevation: selected ? 2 : 0,
color: selected ? Theme.of(context).colorScheme.surfaceContainerLow : Colors.transparent,
@ -57,7 +57,7 @@ class SettingsListTile extends StatelessWidget {
horizontal: 16,
vertical: 12,
).copyWith(
left: (suffix ?? iconWidget) != null ? 0 : null,
left: (leading ?? iconWidget) != null ? 0 : null,
),
child: ConstrainedBox(
constraints: const BoxConstraints(

View file

@ -3,7 +3,9 @@ import 'package:flutter/material.dart';
import 'package:auto_route/auto_route.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:iconsax_plus/iconsax_plus.dart';
import 'package:window_manager/window_manager.dart';
import 'package:fladder/providers/arguments_provider.dart';
import 'package:fladder/providers/auth_provider.dart';
import 'package:fladder/providers/user_provider.dart';
import 'package:fladder/routes/auto_router.gr.dart';
@ -11,6 +13,7 @@ import 'package:fladder/screens/settings/quick_connect_window.dart';
import 'package:fladder/screens/settings/settings_list_tile.dart';
import 'package:fladder/screens/settings/settings_scaffold.dart';
import 'package:fladder/screens/shared/fladder_icon.dart';
import 'package:fladder/screens/shared/fladder_snackbar.dart';
import 'package:fladder/util/adaptive_layout/adaptive_layout.dart';
import 'package:fladder/util/localization_helper.dart';
import 'package:fladder/util/theme_extensions.dart';
@ -137,7 +140,7 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
label: Text(context.localized.about),
subLabel: const Text("Fladder"),
selected: containsRoute(const AboutSettingsRoute()),
suffix: Opacity(
leading: Opacity(
opacity: 1,
child: FladderIconOutlined(
size: 24,
@ -146,6 +149,20 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
),
onTap: () => navigateTo(const AboutSettingsRoute()),
),
if (ref.watch(argumentsStateProvider.select((value) => value.htpcMode))) ...[
SettingsListTile(
label: Text(context.localized.exitFladderTitle),
icon: IconsaxPlusLinear.close_square,
onTap: () async {
final manager = WindowManager.instance;
if (await manager.isClosable()) {
manager.close();
} else {
fladderSnackbar(context, title: context.localized.somethingWentWrong);
}
},
),
],
],
floatingActionButton: Padding(
padding: EdgeInsets.symmetric(horizontal: MediaQuery.paddingOf(context).horizontal),