Skip to content

Commit

Permalink
fix: band-aid fix to disallow linux video fullscreen
Browse files Browse the repository at this point in the history
Ref #1022
  • Loading branch information
Feichtmeier committed Nov 16, 2024
1 parent 6d78c2b commit 8157671
Show file tree
Hide file tree
Showing 11 changed files with 736 additions and 676 deletions.
7 changes: 7 additions & 0 deletions lib/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ bool allowDiscordRPC = kDebugMode ||
Platform.isMacOS ||
Platform.isWindows ||
bool.tryParse(const String.fromEnvironment('ALLOW_DISCORD_RPC')) == true;

bool get yaruStyled => Platform.isLinux;

bool get appleStyled => Platform.isMacOS || Platform.isIOS;

// TODO(#1022): fix linux video fullscreen
bool get allowVideoFullScreen => !Platform.isLinux;
5 changes: 1 addition & 4 deletions lib/common/view/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';

import '../../app_config.dart';
import '../../constants.dart';
import 'icons.dart';

Expand Down Expand Up @@ -70,10 +71,6 @@ Color getPlayerBg(Color? surfaceTintColor, Color fallbackColor) {
}
}

bool get yaruStyled => Platform.isLinux;

bool get appleStyled => Platform.isMacOS || Platform.isIOS;

const alphabetColors = {
'A': Colors.red,
'B': Colors.orange,
Expand Down
9 changes: 8 additions & 1 deletion lib/player/player_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,14 @@ class PlayerService {
Media? media = audio!.path != null
? Media('file://${audio!.path!}')
: (audio!.url != null)
? Media(audio!.url!)
? Media(
audio!.url!,
httpHeaders: {
'Accept': '*',
'User-Agent': '$kAppTitle ($kRepoUrl)',
'Content-Language': 'de-DE',
},
)
: null;
if (media == null) return;
_player.open(media).then((_) {
Expand Down
16 changes: 9 additions & 7 deletions lib/player/view/full_height_video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:watch_it/watch_it.dart';
import 'package:yaru/constants.dart';

import '../../app/connectivity_model.dart';
import '../../app_config.dart';
import '../../common/data/audio.dart';
import '../../common/view/icons.dart';
import '../../l10n/l10n.dart';
Expand Down Expand Up @@ -58,15 +59,16 @@ class FullHeightVideoPlayer extends StatelessWidget with WatchItMixin {
topButtonBar: [
const Spacer(),
controls,
Tooltip(
message: context.l10n.leaveFullScreen,
child: MaterialFullscreenButton(
icon: Icon(
Iconz.fullScreenExit,
color: baseColor,
if (allowVideoFullScreen)
Tooltip(
message: context.l10n.leaveFullScreen,
child: MaterialFullscreenButton(
icon: Icon(
Iconz.fullScreenExit,
color: baseColor,
),
),
),
),
],
bottomButtonBarMargin: const EdgeInsets.all(20),
bottomButtonBar: [
Expand Down
124 changes: 124 additions & 0 deletions lib/settings/view/about_section.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import 'package:flutter/material.dart';
import 'package:path/path.dart' as p;
import 'package:url_launcher/url_launcher.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../app/app_model.dart';
import '../../app/connectivity_model.dart';
import '../../common/view/global_keys.dart';
import '../../common/view/progress.dart';
import '../../common/view/snackbars.dart';
import '../../common/view/tapable_text.dart';
import '../../common/view/theme.dart';
import '../../constants.dart';
import '../../extensions/build_context_x.dart';
import '../../extensions/theme_data_x.dart';
import '../../l10n/l10n.dart';

class AboutSection extends StatelessWidget with WatchItMixin {
const AboutSection({super.key});

@override
Widget build(BuildContext context) {
final text = '${context.l10n.about} $kAppTitle';
return YaruSection(
headline: Text(text),
margin: const EdgeInsets.all(kYaruPagePadding),
child: const Column(
children: [_AboutTile(), _LicenseTile()],
),
);
}
}

class _AboutTile extends StatefulWidget with WatchItStatefulWidgetMixin {
const _AboutTile();

@override
State<_AboutTile> createState() => _AboutTileState();
}

class _AboutTileState extends State<_AboutTile> {
@override
void initState() {
super.initState();
di<AppModel>().checkForUpdate(
isOnline: di<ConnectivityModel>().isOnline == true,
onError: (e) {
if (mounted) {
showSnackBar(context: context, content: Text(e));
}
},
);
}

@override
Widget build(BuildContext context) {
final theme = context.theme;
final appModel = di<AppModel>();
final updateAvailable =
watchPropertyValue((AppModel m) => m.updateAvailable);
final onlineVersion = watchPropertyValue((AppModel m) => m.onlineVersion);
final currentVersion = watchPropertyValue((AppModel m) => m.version);

return YaruTile(
title: !di<ConnectivityModel>().isOnline == true ||
!appModel.allowManualUpdate
? Text(di<AppModel>().version ?? '')
: updateAvailable == null
? Center(
child: SizedBox.square(
dimension: yaruStyled ? kYaruTitleBarItemHeight : 40,
child: const Progress(
padding: EdgeInsets.all(10),
),
),
)
: TapAbleText(
text: updateAvailable == true
? '${context.l10n.updateAvailable}: $onlineVersion'
: currentVersion ?? context.l10n.unknown,
style: updateAvailable == true
? TextStyle(
color: context.theme.colorScheme.success
.scale(lightness: theme.isLight ? 0 : 0.3),
)
: null,
onTap: () => launchUrl(
Uri.parse(
p.join(
kRepoUrl,
'releases',
'tag',
onlineVersion,
),
),
),
),
trailing: OutlinedButton(
onPressed: () => settingsNavigatorKey.currentState?.pushNamed('/about'),
child: Text(context.l10n.contributors),
),
);
}
}

class _LicenseTile extends StatelessWidget {
const _LicenseTile();

@override
Widget build(BuildContext context) {
return YaruTile(
title: TapAbleText(
text: '${context.l10n.license}: GPL3',
),
trailing: OutlinedButton(
onPressed: () =>
settingsNavigatorKey.currentState?.pushNamed('/licenses'),
child: Text(context.l10n.dependencies),
),
enabled: true,
);
}
}
56 changes: 56 additions & 0 deletions lib/settings/view/close_action_section.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import '../../common/data/close_btn_action.dart';
import '../../common/view/drop_down_arrow.dart';
import '../../l10n/l10n.dart';
import '../settings_model.dart';
import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

// TODO(#793): figure out how to show the window from clicking the dock icon in macos, windows and linux
// Also figure out how to show the window again, when the gtk window is triggered from the outside (open with)
// if we can not figure this out, we can not land this feature.
// ignore: unused_element
class CloseActionSection extends StatelessWidget with WatchItMixin {
const CloseActionSection({super.key});

@override
Widget build(BuildContext context) {
final model = di<SettingsModel>();

final closeBtnAction =
watchPropertyValue((SettingsModel m) => m.closeBtnActionIndex);
return YaruSection(
margin: const EdgeInsets.only(
left: kYaruPagePadding,
top: kYaruPagePadding,
right: kYaruPagePadding,
),
headline: Text(context.l10n.closeBtnAction),
child: Column(
children: [
YaruTile(
title: Text(context.l10n.whenCloseBtnClicked),
trailing: YaruPopupMenuButton<CloseBtnAction>(
icon: const DropDownArrow(),
initialValue: closeBtnAction,
child: Text(closeBtnAction.localize(context.l10n)),
onSelected: (value) {
model.setCloseBtnActionIndex(value);
},
itemBuilder: (context) {
return [
for (var i = 0; i < CloseBtnAction.values.length; ++i)
PopupMenuItem(
value: CloseBtnAction.values[i],
child:
Text(CloseBtnAction.values[i].localize(context.l10n)),
),
];
},
),
),
],
),
);
}
}
Loading

0 comments on commit 8157671

Please sign in to comment.