mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 06:13:42 +00:00
Merge PR #1499: fix Windows notification icon
# Conflicts: # ui/flutter/test/features/tasks/presentation/create_task_window_page_test.dart
This commit is contained in:
commit
71d7d96cc0
1 file changed
+22
-8
@@ -2,14 +2,14 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
import '../../core/common/task_event.dart';
|
import '../../core/common/task_event.dart';
|
||||||
import '../../core/libgopeed_boot.dart';
|
import '../../core/libgopeed_boot.dart';
|
||||||
import '../../l10n/l10n.dart';
|
import '../../l10n/l10n.dart';
|
||||||
|
import '../../util/log_util.dart';
|
||||||
import '../../util/util.dart';
|
import '../../util/util.dart';
|
||||||
import 'app_runtime_controller.dart';
|
import 'app_runtime_controller.dart';
|
||||||
|
|
||||||
@@ -56,13 +56,27 @@ class AppNotificationController extends AsyncNotifier<AppNotificationState> {
|
|||||||
String? windowsIconPath;
|
String? windowsIconPath;
|
||||||
try {
|
try {
|
||||||
if (Util.isWindows()) {
|
if (Util.isWindows()) {
|
||||||
final byteData = await rootBundle.load('assets/icon/icon.ico');
|
// Windows requires a file path for IconUri, so use the bundled PNG
|
||||||
final tempDir = await getTemporaryDirectory();
|
// beside the executable rather than copying it to another directory.
|
||||||
final file = File('${tempDir.path}/notification_icon.ico');
|
final file = File(
|
||||||
await file.writeAsBytes(byteData.buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));
|
path.join(
|
||||||
windowsIconPath = file.path;
|
path.dirname(Platform.resolvedExecutable),
|
||||||
|
'data',
|
||||||
|
'flutter_assets',
|
||||||
|
'assets',
|
||||||
|
'icon',
|
||||||
|
'icon_512.png',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (await file.exists()) {
|
||||||
|
windowsIconPath = file.absolute.path;
|
||||||
|
} else {
|
||||||
|
logger.w('Windows notification icon not found: ${file.path}');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
} catch (error, stackTrace) {
|
||||||
|
logger.w('prepare Windows notification icon failed', error, stackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
final windows = WindowsInitializationSettings(
|
final windows = WindowsInitializationSettings(
|
||||||
appName: 'Gopeed',
|
appName: 'Gopeed',
|
||||||
|
|||||||
Reference in new issue
Block a user