Skip to content

Commit

Permalink
fix(linux): tray icon not showing #541
Browse files Browse the repository at this point in the history
upgrade old packages
  • Loading branch information
KRTirtho committed Apr 17, 2024
1 parent 6907f9c commit 7ac7917
Show file tree
Hide file tree
Showing 48 changed files with 840 additions and 722 deletions.
2 changes: 1 addition & 1 deletion .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutterSdkVersion": "3.19.1",
"flutterSdkVersion": "3.19.5",
"flavors": {}
}
2 changes: 1 addition & 1 deletion .github/workflows/spotube-publish-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
inputs:
version:
description: Version to publish (x.x.x)
default: 3.1.0
default: 3.6.0
required: true
dry_run:
description: Dry run
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spotube-release-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ on:
default: true

env:
FLUTTER_VERSION: '3.19.1'
FLUTTER_VERSION: '3.19.5'

jobs:
windows:
Expand Down
4 changes: 2 additions & 2 deletions lib/collections/env.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:envied/envied.dart';
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
import 'package:spotube/utils/platform.dart';

part 'env.g.dart';

Expand All @@ -26,7 +26,7 @@ abstract class Env {
static final String _enableUpdateChecker = _Env._enableUpdateChecker;

static bool get enableUpdateChecker =>
DesktopTools.platform.isFlatpak || _enableUpdateChecker == "1";
kIsFlatpak || _enableUpdateChecker == "1";

static String discordAppId = "1176718791388975124";
}
5 changes: 3 additions & 2 deletions lib/collections/initializers.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'dart:io';
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';

import 'package:spotube/utils/platform.dart';
import 'package:win32_registry/win32_registry.dart';

Future<void> registerWindowsScheme(String scheme) async {
if (!DesktopTools.platform.isWindows) return;
if (!kIsWindows) return;
String appPath = Platform.resolvedExecutable;

String protocolRegKey = 'Software\\Classes\\$scheme';
Expand Down
18 changes: 9 additions & 9 deletions lib/components/root/bottom_player.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:ui';

import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand All @@ -24,6 +23,7 @@ import 'package:spotube/provider/user_preferences/user_preferences_provider.dart
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
import 'package:spotube/provider/volume_provider.dart';
import 'package:spotube/utils/platform.dart';
import 'package:window_manager/window_manager.dart';

class BottomPlayer extends HookConsumerWidget {
BottomPlayer({super.key});
Expand Down Expand Up @@ -95,19 +95,19 @@ class BottomPlayer extends HookConsumerWidget {
tooltip: context.l10n.mini_player,
icon: const Icon(SpotubeIcons.miniPlayer),
onPressed: () async {
final prevSize =
await DesktopTools.window.getSize();
await DesktopTools.window.setMinimumSize(
if (!kIsDesktop) return;

final prevSize = await windowManager.getSize();
await windowManager.setMinimumSize(
const Size(300, 300),
);
await DesktopTools.window.setAlwaysOnTop(true);
await windowManager.setAlwaysOnTop(true);
if (!kIsLinux) {
await DesktopTools.window.setHasShadow(false);
await windowManager.setHasShadow(false);
}
await DesktopTools.window
await windowManager
.setAlignment(Alignment.topRight);
await DesktopTools.window
.setSize(const Size(400, 500));
await windowManager.setSize(const Size(400, 500));
await Future.delayed(
const Duration(milliseconds: 100),
() async {
Expand Down
4 changes: 2 additions & 2 deletions lib/components/shared/inter_scrollbar/inter_scrollbar.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:draggable_scrollbar/draggable_scrollbar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:spotube/utils/platform.dart';

class InterScrollbar extends HookWidget {
final Widget child;
Expand All @@ -15,7 +15,7 @@ class InterScrollbar extends HookWidget {

@override
Widget build(BuildContext context) {
if (DesktopTools.platform.isDesktop) return child;
if (kIsDesktop) return child;

return DraggableScrollbar.semicircle(
controller: controller,
Expand Down
35 changes: 14 additions & 21 deletions lib/components/shared/page_window_title_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import 'package:titlebar_buttons/titlebar_buttons.dart';
import 'dart:math';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'dart:io' show Platform;
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';

import 'package:window_manager/window_manager.dart';

class PageWindowTitleBar extends StatefulHookConsumerWidget
implements PreferredSizeWidget {
Expand Down Expand Up @@ -89,7 +90,7 @@ class _PageWindowTitleBarState extends ConsumerState<PageWindowTitleBar> {
final systemTitleBar =
ref.read(userPreferencesProvider.select((s) => s.systemTitleBar));
if (kIsDesktop && !systemTitleBar) {
DesktopTools.window.startDragging();
windowManager.startDragging();
}
}

Expand All @@ -107,11 +108,7 @@ class _PageWindowTitleBarState extends ConsumerState<PageWindowTitleBar> {

return SliverPadding(
padding: EdgeInsets.only(
left: DesktopTools.platform.isMacOS &&
hasFullscreen &&
hasLeadingOrCanPop
? 65
: 0,
left: kIsMacOS && hasFullscreen && hasLeadingOrCanPop ? 65 : 0,
),
sliver: SliverAppBar(
leading: widget.leading,
Expand Down Expand Up @@ -149,11 +146,7 @@ class _PageWindowTitleBarState extends ConsumerState<PageWindowTitleBar> {
onVerticalDragStart: onDrag,
child: Padding(
padding: EdgeInsets.only(
left: DesktopTools.platform.isMacOS &&
hasFullscreen &&
hasLeadingOrCanPop
? 65
: 0,
left: kIsMacOS && hasFullscreen && hasLeadingOrCanPop ? 65 : 0,
),
child: AppBar(
leading: widget.leading,
Expand Down Expand Up @@ -193,12 +186,12 @@ class WindowTitleBarButtons extends HookConsumerWidget {
const type = ThemeType.auto;

Future<void> onClose() async {
await DesktopTools.window.close();
await windowManager.close();
}

useEffect(() {
if (kIsDesktop) {
DesktopTools.window.isMaximized().then((value) {
windowManager.isMaximized().then((value) {
isMaximized.value = value;
});
}
Expand Down Expand Up @@ -235,22 +228,22 @@ class WindowTitleBarButtons extends HookConsumerWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
MinimizeWindowButton(
onPressed: DesktopTools.window.minimize,
onPressed: windowManager.minimize,
colors: colors,
),
if (isMaximized.value != true)
MaximizeWindowButton(
colors: colors,
onPressed: () {
DesktopTools.window.maximize();
windowManager.maximize();
isMaximized.value = true;
},
)
else
RestoreWindowButton(
colors: colors,
onPressed: () {
DesktopTools.window.unmaximize();
windowManager.unmaximize();
isMaximized.value = false;
},
),
Expand All @@ -270,16 +263,16 @@ class WindowTitleBarButtons extends HookConsumerWidget {
children: [
DecoratedMinimizeButton(
type: type,
onPressed: DesktopTools.window.minimize,
onPressed: windowManager.minimize,
),
DecoratedMaximizeButton(
type: type,
onPressed: () async {
if (await DesktopTools.window.isMaximized()) {
await DesktopTools.window.unmaximize();
if (await windowManager.isMaximized()) {
await windowManager.unmaximize();
isMaximized.value = false;
} else {
await DesktopTools.window.maximize();
await windowManager.maximize();
isMaximized.value = true;
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';

import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/collections/assets.gen.dart';
import 'package:spotube/components/shared/image/universal_image.dart';
Expand All @@ -12,6 +12,7 @@ import 'package:spotube/components/shared/tracks_view/track_view_props.dart';
import 'package:gap/gap.dart';
import 'package:spotube/extensions/constrains.dart';
import 'package:spotube/hooks/utils/use_palette_color.dart';
import 'package:spotube/utils/platform.dart';

class TrackViewFlexHeader extends HookConsumerWidget {
const TrackViewFlexHeader({super.key});
Expand Down Expand Up @@ -53,7 +54,7 @@ class TrackViewFlexHeader extends HookConsumerWidget {
floating: false,
pinned: true,
expandedHeight: 450,
automaticallyImplyLeading: DesktopTools.platform.isMobile,
automaticallyImplyLeading: kIsMobile,
backgroundColor: palette.color,
title: isExpanded ? null : Text(props.title, style: headingStyle),
flexibleSpace: FlexibleSpaceBar(
Expand Down
5 changes: 3 additions & 2 deletions lib/components/shared/tracks_view/track_view.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';

import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:sliver_tools/sliver_tools.dart';
Expand All @@ -8,6 +8,7 @@ import 'package:spotube/components/shared/page_window_title_bar.dart';
import 'package:spotube/components/shared/tracks_view/sections/header/flexible_header.dart';
import 'package:spotube/components/shared/tracks_view/sections/body/track_view_body.dart';
import 'package:spotube/components/shared/tracks_view/track_view_props.dart';
import 'package:spotube/utils/platform.dart';

class TrackView extends HookConsumerWidget {
const TrackView({super.key});
Expand All @@ -18,7 +19,7 @@ class TrackView extends HookConsumerWidget {
final controller = useScrollController();

return Scaffold(
appBar: DesktopTools.platform.isDesktop
appBar: kIsDesktop
? const PageWindowTitleBar(
backgroundColor: Colors.transparent,
foregroundColor: Colors.white,
Expand Down
26 changes: 14 additions & 12 deletions lib/hooks/configurators/use_close_behavior.dart
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import 'dart:io';

import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:spotube/hooks/configurators/use_window_listener.dart';
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
// ignore: depend_on_referenced_packages
import 'package:local_notifier/local_notifier.dart';
import 'package:spotube/utils/platform.dart';
import 'package:window_manager/window_manager.dart';

final closeNotification = DesktopTools.createNotification(
title: 'Spotube',
message: 'Running in background. Minimized to System Tray',
actions: [
LocalNotificationAction(text: 'Close The App'),
],
)?..onClickAction = (value) {
exit(0);
};
final closeNotification = !kIsDesktop
? null
: (LocalNotification(
title: 'Spotube',
body: 'Running in background. Minimized to System Tray',
actions: [
LocalNotificationAction(text: 'Close The App'),
],
)..onClickAction = (value) {
exit(0);
});

void useCloseBehavior(WidgetRef ref) {
useWindowListener(
onWindowClose: () async {
final preferences = ref.read(userPreferencesProvider);
if (preferences.closeBehavior == CloseBehavior.minimizeToTray) {
await DesktopTools.window.hide();
await windowManager.hide();
closeNotification?.show();
} else {
exit(0);
Expand Down
4 changes: 2 additions & 2 deletions lib/hooks/configurators/use_deep_linking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:spotube/collections/routes.dart';
import 'package:spotube/provider/spotify_provider.dart';
import 'package:flutter_sharing_intent/flutter_sharing_intent.dart';
import 'package:flutter_sharing_intent/model/sharing_file.dart';
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';
import 'package:spotube/utils/platform.dart';

final appLinks = AppLinks();
final linkStream = appLinks.allStringLinkStream.asBroadcastStream();
Expand Down Expand Up @@ -53,7 +53,7 @@ void useDeepLinking(WidgetRef ref) {

StreamSubscription? mediaStream;

if (DesktopTools.platform.isMobile) {
if (kIsMobile) {
FlutterSharingIntent.instance.getInitialSharing().then(uriListener);

mediaStream =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'package:disable_battery_optimization/disable_battery_optimization.dart';
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';

import 'package:spotube/hooks/utils/use_async_effect.dart';
import 'package:spotube/services/kv_store/kv_store.dart';
import 'package:spotube/utils/platform.dart';

void useDisableBatteryOptimizations() {
useAsyncEffect(() async {
if (!DesktopTools.platform.isAndroid ||
KVStoreService.askedForBatteryOptimization) return;
if (!kIsAndroid || KVStoreService.askedForBatteryOptimization) return;

await DisableBatteryOptimization.showDisableBatteryOptimizationSettings();

Expand Down
5 changes: 3 additions & 2 deletions lib/hooks/configurators/use_get_storage_perms.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter_desktop_tools/flutter_desktop_tools.dart';

import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:spotube/components/library/user_local_tracks.dart';
import 'package:spotube/hooks/utils/use_async_effect.dart';
import 'package:spotube/utils/platform.dart';

void useGetStoragePermissions(WidgetRef ref) {
final context = useContext();

useAsyncEffect(
() async {
if (!DesktopTools.platform.isMobile) return;
if (!kIsMobile) return;

final androidInfo = await DeviceInfoPlugin().androidInfo;

Expand Down
Loading

0 comments on commit 7ac7917

Please sign in to comment.