Nikolas Rimikis
1 year ago
committed by
GitHub
3 changed files with 94 additions and 67 deletions
@ -1,53 +1,41 @@ |
|||||||
|
import 'dart:async'; |
||||||
import 'dart:io'; |
import 'dart:io'; |
||||||
|
|
||||||
|
import 'package:meta/meta.dart'; |
||||||
import 'package:neon/src/platform/android.dart'; |
import 'package:neon/src/platform/android.dart'; |
||||||
import 'package:neon/src/platform/linux.dart'; |
import 'package:neon/src/platform/linux.dart'; |
||||||
|
|
||||||
Future<NeonPlatform> getNeonPlatform() async { |
Future<NeonPlatform> getNeonPlatform() async { |
||||||
NeonPlatform? platform; |
final NeonPlatform platform; |
||||||
if (Platform.isAndroid) { |
if (Platform.isAndroid) { |
||||||
platform = AndroidNeonPlatform(); |
platform = const AndroidNeonPlatform(); |
||||||
} |
} else if (Platform.isLinux) { |
||||||
if (Platform.isLinux) { |
platform = const LinuxNeonPlatform(); |
||||||
platform = LinuxNeonPlatform(); |
} else { |
||||||
} |
|
||||||
|
|
||||||
if (platform == null) { |
|
||||||
throw UnimplementedError('No implementation for platform ${Platform.operatingSystem} found'); |
throw UnimplementedError('No implementation for platform ${Platform.operatingSystem} found'); |
||||||
} |
} |
||||||
|
|
||||||
await platform.init?.call(); |
await platform.init.call(); |
||||||
return platform; |
return platform; |
||||||
} |
} |
||||||
|
|
||||||
abstract class NeonPlatform { |
@immutable |
||||||
NeonPlatform({ |
abstract interface class NeonPlatform { |
||||||
required this.canUseWebView, |
abstract final bool canUseWebView; |
||||||
required this.canUseQuickActions, |
|
||||||
required this.canUseSystemTray, |
|
||||||
required this.canUseWindowManager, |
|
||||||
required this.canUseCamera, |
|
||||||
required this.canUsePushNotifications, |
|
||||||
required this.getApplicationCachePath, |
|
||||||
required this.getUserAccessibleAppDataPath, |
|
||||||
this.init, |
|
||||||
}); |
|
||||||
|
|
||||||
final bool canUseWebView; |
|
||||||
|
|
||||||
final bool canUseQuickActions; |
abstract final bool canUseQuickActions; |
||||||
|
|
||||||
final bool canUseSystemTray; |
abstract final bool canUseSystemTray; |
||||||
|
|
||||||
final bool canUseWindowManager; |
abstract final bool canUseWindowManager; |
||||||
|
|
||||||
final bool canUseCamera; |
abstract final bool canUseCamera; |
||||||
|
|
||||||
final bool canUsePushNotifications; |
abstract final bool canUsePushNotifications; |
||||||
|
|
||||||
final Future<String> Function() getApplicationCachePath; |
FutureOr<String> getApplicationCachePath(); |
||||||
|
|
||||||
final Future<String> Function() getUserAccessibleAppDataPath; |
FutureOr<String> getUserAccessibleAppDataPath(); |
||||||
|
|
||||||
final Future Function()? init; |
FutureOr init(); |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue