mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 08:46:18 +01:00
Refactor: use the platform package
This commit is contained in:
parent
cd525f5168
commit
0f129f839d
39 changed files with 116 additions and 114 deletions
|
@ -43,9 +43,9 @@ import 'package:nc_photos/mobile/platform.dart'
|
|||
if (dart.library.html) 'package:nc_photos/web/platform.dart' as platform;
|
||||
import 'package:nc_photos/mobile/self_signed_cert_manager.dart';
|
||||
import 'package:nc_photos/platform/features.dart' as features;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/touch_manager.dart';
|
||||
import 'package:np_log/np_log.dart' as np_log;
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:visibility_detector/visibility_detector.dart';
|
||||
|
||||
enum InitIsolateType {
|
||||
|
@ -80,7 +80,7 @@ Future<void> init(InitIsolateType isolateType) async {
|
|||
await _initDiContainer(isolateType);
|
||||
_initVisibilityDetector();
|
||||
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
if (isolateType == InitIsolateType.main) {
|
||||
try {
|
||||
_isNewGMapsRenderer = await Activity.isNewGMapsRenderer();
|
||||
|
@ -109,7 +109,7 @@ void initDrift() {
|
|||
}
|
||||
|
||||
Future<void> _initDriftWorkaround() async {
|
||||
if (platform_k.isAndroid && AndroidInfo().sdkInt < 24) {
|
||||
if (getRawPlatform() == NpPlatform.android && AndroidInfo().sdkInt < 24) {
|
||||
_log.info("[_initDriftWorkaround] Workaround Android 6- bug");
|
||||
// see: https://github.com/flutter/flutter/issues/73318 and
|
||||
// https://github.com/simolus3/drift/issues/895
|
||||
|
@ -146,7 +146,7 @@ Future<void> _initAccountPrefs() async {
|
|||
}
|
||||
|
||||
Future<void> _initDeviceInfo() async {
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
await AndroidInfo.init();
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ Future<void> _initDiContainer(InitIsolateType isolateType) async {
|
|||
|
||||
c.touchManager = TouchManager(c);
|
||||
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
// local file currently only supported on Android
|
||||
c.localFileRepo = const LocalFileRepo(LocalFileMediaStoreDataSource());
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ Future<sql.SqliteDb> _createDb(InitIsolateType isolateType) async {
|
|||
switch (isolateType) {
|
||||
case InitIsolateType.main:
|
||||
// use driftIsolate to prevent DB blocking the UI thread
|
||||
if (platform_k.isWeb) {
|
||||
if (getRawPlatform() == NpPlatform.web) {
|
||||
// no isolate support on web
|
||||
return sql.SqliteDb();
|
||||
} else {
|
||||
|
|
|
@ -16,7 +16,6 @@ import 'package:nc_photos/entity/pref.dart';
|
|||
import 'package:nc_photos/event/event.dart';
|
||||
import 'package:nc_photos/event/native_event.dart';
|
||||
import 'package:nc_photos/exception.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/progress_util.dart';
|
||||
import 'package:nc_photos/throttler.dart';
|
||||
import 'package:nc_photos/use_case/ls.dart';
|
||||
|
@ -24,6 +23,7 @@ import 'package:nc_photos/use_case/scan_dir.dart';
|
|||
import 'package:nc_photos/use_case/scan_dir_offline.dart';
|
||||
import 'package:nc_photos/use_case/sync_dir.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:to_string/to_string.dart';
|
||||
|
||||
part 'scan_account_dir.g.dart';
|
||||
|
@ -523,13 +523,14 @@ class ScanAccountDirBloc
|
|||
late final _accountPrefUpdatedEventListener =
|
||||
AppEventListener<AccountPrefUpdatedEvent>(_onAccountPrefUpdatedEvent);
|
||||
|
||||
late final _nativeFileExifUpdatedListener = platform_k.isWeb
|
||||
late final _nativeFileExifUpdatedListener = getRawPlatform() == NpPlatform.web
|
||||
? null
|
||||
: NativeEventListener<FileExifUpdatedEvent>(_onNativeFileExifUpdated);
|
||||
late final _imageProcessorUploadSuccessListener = platform_k.isWeb
|
||||
? null
|
||||
: NativeEventListener<ImageProcessorUploadSuccessEvent>(
|
||||
_onImageProcessorUploadSuccessEvent);
|
||||
late final _imageProcessorUploadSuccessListener =
|
||||
getRawPlatform() == NpPlatform.web
|
||||
? null
|
||||
: NativeEventListener<ImageProcessorUploadSuccessEvent>(
|
||||
_onImageProcessorUploadSuccessEvent);
|
||||
|
||||
late final _refreshThrottler = Throttler(
|
||||
onTriggered: (_) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
Future<bool> isWifi() async {
|
||||
if (platform_k.isWeb) {
|
||||
if (getRawPlatform() == NpPlatform.web) {
|
||||
// connectivity does NOT work on web, currently it will always return mobile
|
||||
// on Blink, and none on Gecko
|
||||
return true;
|
||||
|
|
|
@ -15,12 +15,12 @@ import 'package:nc_photos/mobile/android/download.dart';
|
|||
import 'package:nc_photos/mobile/notification.dart';
|
||||
import 'package:nc_photos/mobile/platform.dart'
|
||||
if (dart.library.html) 'package:nc_photos/web/platform.dart' as platform;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/use_case/download_file.dart';
|
||||
import 'package:nc_photos/use_case/inflate_file_descriptor.dart';
|
||||
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
part 'download_handler.g.dart';
|
||||
|
@ -39,7 +39,7 @@ class DownloadHandler {
|
|||
}) async {
|
||||
final files = await InflateFileDescriptor(_c)(account, fds);
|
||||
final _DownloadHandlerBase handler;
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
handler = _DownlaodHandlerAndroid();
|
||||
} else {
|
||||
handler = _DownloadHandlerWeb();
|
||||
|
|
|
@ -3,9 +3,9 @@ import 'package:nc_photos/account.dart';
|
|||
import 'package:nc_photos/api/api_util.dart' as api_util;
|
||||
import 'package:nc_photos/entity/file.dart';
|
||||
import 'package:nc_photos/entity/file_descriptor.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
||||
import 'package:np_api/np_api.dart' as api;
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:np_string/np_string.dart';
|
||||
import 'package:path/path.dart' as path_lib;
|
||||
|
||||
|
@ -119,7 +119,8 @@ final supportedFormatMimes = [
|
|||
"image/gif",
|
||||
"video/mp4",
|
||||
"video/quicktime",
|
||||
if (platform_k.isAndroid || platform_k.isWeb) "video/webm",
|
||||
if ([NpPlatform.android, NpPlatform.web].contains(getRawPlatform()))
|
||||
"video/webm",
|
||||
];
|
||||
|
||||
final supportedImageFormatMimes =
|
||||
|
|
|
@ -14,10 +14,10 @@ import 'package:nc_photos/k.dart' as k;
|
|||
import 'package:nc_photos/mobile/platform.dart'
|
||||
if (dart.library.html) 'package:nc_photos/web/platform.dart' as platform;
|
||||
import 'package:nc_photos/object_extension.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_collection/np_collection.dart';
|
||||
import 'package:np_platform_lock/np_platform_lock.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
part 'database.g.dart';
|
||||
part 'database/nc_album_extension.dart';
|
||||
|
|
|
@ -148,7 +148,7 @@ extension SqliteDbExtension on SqliteDb {
|
|||
return await PlatformLock.synchronized(k.appDbLockId, () async {
|
||||
// in unit tests we use an in-memory db, which mean there's no way to
|
||||
// access it in other isolates
|
||||
if (platform_k.isUnitTest) {
|
||||
if (isUnitTest) {
|
||||
return await callback(this, args);
|
||||
} else {
|
||||
return await computeWithDb(callback, args);
|
||||
|
|
|
@ -9,7 +9,7 @@ import 'package:nc_photos/di_container.dart';
|
|||
import 'package:nc_photos/entity/sqlite/database.dart';
|
||||
import 'package:nc_photos/mobile/platform.dart'
|
||||
if (dart.library.html) 'package:nc_photos/web/platform.dart' as platform;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
typedef ComputeWithDbCallback<T, U> = Future<U> Function(
|
||||
SqliteDb db, T message);
|
||||
|
@ -26,7 +26,7 @@ Future<SqliteDb> createDb() async {
|
|||
|
||||
Future<U> computeWithDb<T, U>(
|
||||
ComputeWithDbCallback<T, U> callback, T args) async {
|
||||
if (platform_k.isWeb) {
|
||||
if (getRawPlatform() == NpPlatform.web) {
|
||||
final c = KiwiContainer().resolve<DiContainer>();
|
||||
return await callback(c.sqliteDb, args);
|
||||
} else {
|
||||
|
|
|
@ -11,13 +11,13 @@ import 'package:nc_photos/entity/pref_util.dart' as pref_util;
|
|||
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
|
||||
import 'package:nc_photos/help_utils.dart' as help_utils;
|
||||
import 'package:nc_photos/legacy/connect.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/theme.dart';
|
||||
import 'package:nc_photos/url_launcher_util.dart';
|
||||
import 'package:nc_photos/widget/home.dart';
|
||||
import 'package:nc_photos/widget/root_picker.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_collection/np_collection.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:np_string/np_string.dart';
|
||||
|
||||
part 'sign_in.g.dart';
|
||||
|
@ -122,7 +122,8 @@ class _SignInState extends State<SignIn> {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (!platform_k.isWeb) Expanded(child: Container()),
|
||||
if (getRawPlatform() != NpPlatform.web)
|
||||
Expanded(child: Container()),
|
||||
Container(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth:
|
||||
|
|
|
@ -7,9 +7,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||
import 'package:logging/logging.dart';
|
||||
import 'package:nc_photos/app_init.dart' as app_init;
|
||||
import 'package:nc_photos/bloc_util.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/widget/my_app.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
part 'main.g.dart';
|
||||
|
||||
|
@ -17,7 +17,7 @@ void main() async {
|
|||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await app_init.init(app_init.InitIsolateType.main);
|
||||
|
||||
if (platform_k.isMobile) {
|
||||
if (getRawPlatform().isMobile) {
|
||||
// reset orientation override just in case, see #59
|
||||
unawaited(SystemChrome.setPreferredOrientations([]));
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import 'package:http/http.dart' as http;
|
|||
import 'package:logging/logging.dart';
|
||||
import 'package:nc_photos/exception.dart';
|
||||
import 'package:nc_photos/platform/download.dart' as itf;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
|
@ -23,7 +23,7 @@ class DownloadBuilder extends itf.DownloadBuilder {
|
|||
String? parentDir,
|
||||
bool? shouldNotify,
|
||||
}) {
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
return _AndroidDownload(
|
||||
url: url,
|
||||
headers: headers,
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:nc_photos/platform/file_saver.dart' as itf;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
class FileSaver extends itf.FileSaver {
|
||||
@override
|
||||
saveFile(String filename, Uint8List content) {
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
return _saveFileAndroid(filename, content);
|
||||
} else {
|
||||
throw UnimplementedError();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
final isSupportMapView = platform_k.isWeb || platform_k.isAndroid;
|
||||
final isSupportSelfSignedCert = platform_k.isAndroid;
|
||||
final isSupportEnhancement = platform_k.isAndroid;
|
||||
final isSupportMapView =
|
||||
[NpPlatform.android, NpPlatform.web].contains(getRawPlatform());
|
||||
final isSupportSelfSignedCert = getRawPlatform() == NpPlatform.android;
|
||||
final isSupportEnhancement = getRawPlatform() == NpPlatform.android;
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
const isWeb = kIsWeb;
|
||||
// Platform n/a on web, need checking kIsWeb first
|
||||
final isMobile = !kIsWeb && (Platform.isAndroid || Platform.isIOS);
|
||||
final isAndroid = !kIsWeb && Platform.isAndroid;
|
||||
final isDesktop =
|
||||
!kIsWeb && (Platform.isLinux || Platform.isMacOS || Platform.isWindows);
|
||||
final isUnitTest = !kIsWeb && Platform.environment.containsKey("FLUTTER_TEST");
|
|
@ -10,11 +10,11 @@ import 'package:nc_photos/exception_util.dart' as exception_util;
|
|||
import 'package:nc_photos/internal_download_handler.dart';
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/mobile/share.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/use_case/inflate_file_descriptor.dart';
|
||||
import 'package:nc_photos/widget/set_as_method_dialog.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
part 'set_as_handler.g.dart';
|
||||
|
||||
|
@ -60,7 +60,7 @@ class SetAsHandler {
|
|||
}
|
||||
|
||||
Future<void> _setAsAsPreview(Account account, File file) async {
|
||||
assert(platform_k.isAndroid);
|
||||
assert(getRawPlatform() == NpPlatform.android);
|
||||
final results = await InternalDownloadHandler(account)
|
||||
.downloadPreviews(context, [file]);
|
||||
final share = AndroidFileShare(results.entries
|
||||
|
@ -70,7 +70,7 @@ class SetAsHandler {
|
|||
}
|
||||
|
||||
Future<void> _setAsAsFile(Account account, File file) async {
|
||||
assert(platform_k.isAndroid);
|
||||
assert(getRawPlatform() == NpPlatform.android);
|
||||
final results =
|
||||
await InternalDownloadHandler(account).downloadFiles(context, [file]);
|
||||
final share = AndroidFileShare(results.entries
|
||||
|
|
|
@ -20,7 +20,6 @@ import 'package:nc_photos/exception_util.dart' as exception_util;
|
|||
import 'package:nc_photos/internal_download_handler.dart';
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/mobile/share.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/use_case/copy.dart';
|
||||
|
@ -32,6 +31,7 @@ import 'package:nc_photos/widget/share_link_multiple_files_dialog.dart';
|
|||
import 'package:nc_photos/widget/share_method_dialog.dart';
|
||||
import 'package:nc_photos/widget/simple_input_dialog.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
part 'share_handler.g.dart';
|
||||
|
||||
|
@ -112,7 +112,7 @@ class ShareHandler {
|
|||
}
|
||||
|
||||
Future<void> _shareAsPreview(Account account, List<File> files) async {
|
||||
assert(platform_k.isAndroid);
|
||||
assert(getRawPlatform() == NpPlatform.android);
|
||||
final results =
|
||||
await InternalDownloadHandler(account).downloadPreviews(context, files);
|
||||
final share = AndroidFileShare(results.entries
|
||||
|
@ -122,7 +122,7 @@ class ShareHandler {
|
|||
}
|
||||
|
||||
Future<void> _shareAsFile(Account account, List<File> files) async {
|
||||
assert(platform_k.isAndroid);
|
||||
assert(getRawPlatform() == NpPlatform.android);
|
||||
final results =
|
||||
await InternalDownloadHandler(account).downloadFiles(context, files);
|
||||
final share = AndroidFileShare(results.entries
|
||||
|
@ -189,7 +189,7 @@ class ShareHandler {
|
|||
duration: k.snackBarDurationNormal,
|
||||
));
|
||||
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
final textShare = AndroidTextShare(share.url!);
|
||||
await textShare.share();
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@ import 'package:nc_photos/cache_manager_util.dart';
|
|||
import 'package:nc_photos/entity/file_descriptor.dart';
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/np_api_util.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
class DownloadPreview {
|
||||
Future<dynamic> call(Account account, FileDescriptor file) async {
|
||||
assert(platform_k.isAndroid);
|
||||
assert(getRawPlatform() == NpPlatform.android);
|
||||
final previewUrl = api_util.getFilePreviewUrl(
|
||||
account,
|
||||
file,
|
||||
|
|
|
@ -10,12 +10,12 @@ import 'package:nc_photos/app_init.dart' as app_init;
|
|||
import 'package:nc_photos/di_container.dart';
|
||||
import 'package:nc_photos/entity/person.dart';
|
||||
import 'package:nc_photos/event/event.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/use_case/person/sync_person.dart';
|
||||
import 'package:nc_photos/use_case/sync_favorite.dart';
|
||||
import 'package:nc_photos/use_case/sync_tag.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_common/type.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
part 'startup_sync.g.dart';
|
||||
|
||||
|
@ -31,7 +31,7 @@ class StartupSync {
|
|||
static Future<SyncResult> runInIsolate(
|
||||
Account account, PersonProvider personProvider) async {
|
||||
return _mutex.protect(() async {
|
||||
if (platform_k.isWeb) {
|
||||
if (getRawPlatform() == NpPlatform.web) {
|
||||
// not supported on web
|
||||
final c = KiwiContainer().resolve<DiContainer>();
|
||||
return await StartupSync(c)(account, personProvider);
|
||||
|
|
|
@ -15,7 +15,6 @@ import 'package:nc_photos/k.dart' as k;
|
|||
import 'package:nc_photos/mobile/android/android_info.dart';
|
||||
import 'package:nc_photos/mobile/android/permission_util.dart';
|
||||
import 'package:nc_photos/object_extension.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/share_handler.dart';
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/widget/empty_list_indicator.dart';
|
||||
|
@ -28,6 +27,7 @@ import 'package:nc_photos/widget/selection_app_bar.dart';
|
|||
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_collection/np_collection.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
part 'enhanced_photo_browser.g.dart';
|
||||
|
||||
|
@ -337,7 +337,7 @@ class _EnhancedPhotoBrowserState extends State<EnhancedPhotoBrowser>
|
|||
}
|
||||
|
||||
Future<bool> _ensurePermission() async {
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
if (AndroidInfo().sdkInt >= AndroidVersion.R) {
|
||||
if (!await Permission.hasReadExternalStorage()) {
|
||||
final results = await requestPermissionsForResult([
|
||||
|
|
|
@ -19,7 +19,6 @@ import 'package:nc_photos/exception_event.dart';
|
|||
import 'package:nc_photos/exception_util.dart' as exception_util;
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/mobile/share.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util;
|
||||
import 'package:nc_photos/toast.dart';
|
||||
import 'package:nc_photos/use_case/copy.dart';
|
||||
|
@ -34,6 +33,7 @@ import 'package:nc_photos/widget/simple_input_dialog.dart';
|
|||
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_collection/np_collection.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:to_string/to_string.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
|
@ -153,7 +153,7 @@ class _ShareMethodDialog extends StatelessWidget {
|
|||
return SimpleDialog(
|
||||
title: Text(L10n.global().shareMethodDialogTitle),
|
||||
children: [
|
||||
if (platform_k.isAndroid) ...[
|
||||
if (getRawPlatform() == NpPlatform.android) ...[
|
||||
if (isSupportPerview)
|
||||
SimpleDialogOption(
|
||||
child: ListTile(
|
||||
|
|
|
@ -70,7 +70,7 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
|||
}
|
||||
|
||||
Future<void> _doShareFile(Emitter<_State> emit) async {
|
||||
assert(platform_k.isAndroid);
|
||||
assert(getRawPlatform() == NpPlatform.android);
|
||||
emit(state.copyWith(
|
||||
previewState: _PreviewState(index: 0, count: files.length),
|
||||
));
|
||||
|
@ -103,7 +103,7 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
|||
}
|
||||
|
||||
Future<void> _doSharePreview(Emitter<_State> emit) async {
|
||||
assert(platform_k.isAndroid);
|
||||
assert(getRawPlatform() == NpPlatform.android);
|
||||
emit(state.copyWith(
|
||||
previewState: _PreviewState(index: 0, count: files.length),
|
||||
));
|
||||
|
@ -186,7 +186,7 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
|||
);
|
||||
await Clipboard.setData(ClipboardData(text: share.url));
|
||||
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
final textShare = AndroidTextShare(share.url!);
|
||||
unawaited(textShare.share());
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import 'package:nc_photos/app_init.dart' as app_init;
|
|||
import 'package:nc_photos/entity/pref.dart';
|
||||
import 'package:nc_photos/mobile/platform.dart'
|
||||
if (dart.library.html) 'package:nc_photos/web/platform.dart' as platform;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/url_launcher_util.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
enum GpsMapProvider {
|
||||
|
@ -39,7 +39,8 @@ class GpsMap extends StatelessWidget {
|
|||
build(BuildContext context) {
|
||||
if (GpsMapProvider.values[Pref().getGpsMapProviderOr(0)] ==
|
||||
GpsMapProvider.osm ||
|
||||
(platform_k.isAndroid && !app_init.isNewGMapsRenderer())) {
|
||||
(getRawPlatform() == NpPlatform.android &&
|
||||
!app_init.isNewGMapsRenderer())) {
|
||||
return _OsmGpsMap(
|
||||
center: center,
|
||||
zoom: zoom,
|
||||
|
|
|
@ -3,16 +3,16 @@ import 'package:nc_photos/app_localizations.dart';
|
|||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/mobile/android/android_info.dart';
|
||||
import 'package:nc_photos/mobile/android/permission_util.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
/// Handle platform permissions
|
||||
class PermissionHandler {
|
||||
const PermissionHandler();
|
||||
|
||||
Future<bool> ensureStorageWritePermission() async {
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
if (AndroidInfo().sdkInt < AndroidVersion.R &&
|
||||
!await Permission.hasWriteExternalStorage()) {
|
||||
final results = await requestPermissionsForResult([
|
||||
|
|
|
@ -29,7 +29,6 @@ import 'package:nc_photos/k.dart' as k;
|
|||
import 'package:nc_photos/language_util.dart' as language_util;
|
||||
import 'package:nc_photos/metadata_task_manager.dart';
|
||||
import 'package:nc_photos/object_extension.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/service.dart' as service;
|
||||
import 'package:nc_photos/share_handler.dart';
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
|
@ -53,6 +52,7 @@ import 'package:nc_photos/widget/settings.dart';
|
|||
import 'package:nc_photos/widget/viewer.dart';
|
||||
import 'package:nc_photos/widget/zoom_menu_button.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:visibility_detector/visibility_detector.dart';
|
||||
|
||||
part 'home_photos.g.dart';
|
||||
|
@ -726,14 +726,16 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
|
||||
late final _prefUpdatedListener =
|
||||
AppEventListener<PrefUpdatedEvent>(_onPrefUpdated);
|
||||
late final _imageProcessorUploadSuccessListener = platform_k.isWeb
|
||||
? null
|
||||
: NativeEventListener<ImageProcessorUploadSuccessEvent>(
|
||||
_onImageProcessorUploadSuccessEvent);
|
||||
late final _imageProcessorUploadSuccessListener =
|
||||
getRawPlatform() == NpPlatform.web
|
||||
? null
|
||||
: NativeEventListener<ImageProcessorUploadSuccessEvent>(
|
||||
_onImageProcessorUploadSuccessEvent);
|
||||
late final _onBackToTopListener =
|
||||
AppEventListener<HomePhotosBackToTopEvent>(_onBackToTop);
|
||||
|
||||
late final _Web? _web = platform_k.isWeb ? _Web(this) : null;
|
||||
late final _Web? _web =
|
||||
getRawPlatform() == NpPlatform.web ? _Web(this) : null;
|
||||
|
||||
var _isScrollbarVisible = false;
|
||||
var _isRefreshIndicatorActive = false;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/widget/page_changed_listener.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
class HorizontalPageViewer extends StatefulWidget {
|
||||
HorizontalPageViewer({
|
||||
|
@ -54,7 +54,7 @@ class _HorizontalPageViewerState extends State<HorizontalPageViewer> {
|
|||
_updateNavigationState(widget.initialPage);
|
||||
_hasInit = true;
|
||||
}
|
||||
return platform_k.isWeb
|
||||
return getRawPlatform() == NpPlatform.web
|
||||
? _buildWebContent(context)
|
||||
: _buildContent(context);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class _HorizontalPageViewerState extends State<HorizontalPageViewer> {
|
|||
}
|
||||
|
||||
Widget _buildWebContent(BuildContext context) {
|
||||
assert(platform_k.isWeb);
|
||||
assert(getRawPlatform() == NpPlatform.web);
|
||||
// support switching pages with keyboard on web
|
||||
return RawKeyboardListener(
|
||||
onKey: (ev) {
|
||||
|
@ -91,11 +91,13 @@ class _HorizontalPageViewerState extends State<HorizontalPageViewer> {
|
|||
controller: widget.controller._pageController,
|
||||
itemCount: widget.pageCount,
|
||||
itemBuilder: widget.pageBuilder,
|
||||
physics: !platform_k.isWeb && widget.canSwitchPage
|
||||
? null
|
||||
: const NeverScrollableScrollPhysics(),
|
||||
physics:
|
||||
getRawPlatform() != NpPlatform.web && widget.canSwitchPage
|
||||
? null
|
||||
: const NeverScrollableScrollPhysics(),
|
||||
),
|
||||
if (platform_k.isWeb) ..._buildNavigationButtons(context),
|
||||
if (getRawPlatform() == NpPlatform.web)
|
||||
..._buildNavigationButtons(context),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -221,7 +223,7 @@ class _HorizontalPageViewerState extends State<HorizontalPageViewer> {
|
|||
/// Update the navigation state for [page]
|
||||
void _updateNavigationState(int page) {
|
||||
// currently useless to run on non-web platform
|
||||
if (!platform_k.isWeb) {
|
||||
if (getRawPlatform() != NpPlatform.web) {
|
||||
return;
|
||||
}
|
||||
final hasNext = widget.pageCount == null || page < widget.pageCount! - 1;
|
||||
|
|
|
@ -20,7 +20,6 @@ import 'package:nc_photos/mobile/android/content_uri_image_provider.dart';
|
|||
import 'package:nc_photos/mobile/android/k.dart' as android;
|
||||
import 'package:nc_photos/np_api_util.dart';
|
||||
import 'package:nc_photos/object_extension.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/theme.dart';
|
||||
import 'package:nc_photos/url_launcher_util.dart';
|
||||
|
@ -30,6 +29,7 @@ import 'package:nc_photos/widget/selectable.dart';
|
|||
import 'package:nc_photos/widget/settings/enhancement_settings.dart';
|
||||
import 'package:nc_photos_plugin/nc_photos_plugin.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:np_ui/np_ui.dart';
|
||||
|
||||
part 'image_enhancer.g.dart';
|
||||
|
@ -525,7 +525,7 @@ class _ImageEnhancerState extends State<ImageEnhancer> {
|
|||
}
|
||||
|
||||
late final _options = [
|
||||
if (platform_k.isAndroid) ...[
|
||||
if (getRawPlatform() == NpPlatform.android) ...[
|
||||
_Option(
|
||||
title: L10n.global().enhanceRetouchTitle,
|
||||
description: L10n.global().enhanceRetouchDescription,
|
||||
|
|
|
@ -6,12 +6,12 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
|||
import 'package:logging/logging.dart';
|
||||
import 'package:nc_photos/app_localizations.dart';
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/session_storage.dart';
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/widget/selectable.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_collection/np_collection.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
part 'selectable_item_list.g.dart';
|
||||
|
||||
|
@ -75,7 +75,7 @@ class _SelectableItemListState<T extends SelectableItemMetadata>
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (platform_k.isWeb) {
|
||||
if (getRawPlatform() == NpPlatform.web) {
|
||||
// support shift+click group selection on web
|
||||
return RawKeyboardListener(
|
||||
onKey: (ev) {
|
||||
|
@ -178,7 +178,7 @@ class _SelectableItemListState<T extends SelectableItemMetadata>
|
|||
if (!SessionStorage().hasShowRangeSelectNotification) {
|
||||
SnackBarManager().showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(platform_k.isWeb
|
||||
content: Text(getRawPlatform() == NpPlatform.web
|
||||
? L10n.global().webSelectRangeNotification
|
||||
: L10n.global().mobileSelectRangeNotification),
|
||||
duration: k.snackBarDurationNormal,
|
||||
|
|
|
@ -6,13 +6,13 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
|||
import 'package:logging/logging.dart';
|
||||
import 'package:nc_photos/app_localizations.dart';
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/session_storage.dart';
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/widget/measurable_item_list.dart';
|
||||
import 'package:nc_photos/widget/selectable.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_collection/np_collection.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:visibility_detector/visibility_detector.dart';
|
||||
|
||||
|
@ -47,7 +47,7 @@ mixin SelectableItemStreamListMixin<T extends StatefulWidget> on State<T> {
|
|||
BuildContext context, {
|
||||
required Widget child,
|
||||
}) {
|
||||
if (platform_k.isWeb) {
|
||||
if (getRawPlatform() == NpPlatform.web) {
|
||||
// support shift+click group selection on web
|
||||
return RawKeyboardListener(
|
||||
onKey: (ev) {
|
||||
|
@ -105,7 +105,7 @@ mixin SelectableItemStreamListMixin<T extends StatefulWidget> on State<T> {
|
|||
mainAxisSpacing: mainAxisSpacing,
|
||||
);
|
||||
}
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
return WillPopScope(
|
||||
onWillPop: onBackButtonPressed,
|
||||
child: content,
|
||||
|
@ -182,7 +182,7 @@ mixin SelectableItemStreamListMixin<T extends StatefulWidget> on State<T> {
|
|||
childBorderRadius: childBorderRadius,
|
||||
indicatorAlignment: indicatorAlignment,
|
||||
onTap: () => _onItemTap(item, index),
|
||||
onLongPress: isSelectionMode && platform_k.isWeb
|
||||
onLongPress: isSelectionMode && getRawPlatform() == NpPlatform.web
|
||||
? null
|
||||
: () => _onItemLongPress(item, index),
|
||||
child: content,
|
||||
|
@ -242,7 +242,9 @@ mixin SelectableItemStreamListMixin<T extends StatefulWidget> on State<T> {
|
|||
return;
|
||||
}
|
||||
final wasSelectionMode = isSelectionMode;
|
||||
if (!platform_k.isWeb && wasSelectionMode && _lastSelectPosition != null) {
|
||||
if (getRawPlatform() != NpPlatform.web &&
|
||||
wasSelectionMode &&
|
||||
_lastSelectPosition != null) {
|
||||
setState(() {
|
||||
_selectedItems.addAll(_items
|
||||
.sublist(math.min(_lastSelectPosition!, index),
|
||||
|
@ -262,7 +264,7 @@ mixin SelectableItemStreamListMixin<T extends StatefulWidget> on State<T> {
|
|||
if (!SessionStorage().hasShowRangeSelectNotification) {
|
||||
SnackBarManager().showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(platform_k.isWeb
|
||||
content: Text(getRawPlatform() == NpPlatform.web
|
||||
? L10n.global().webSelectRangeNotification
|
||||
: L10n.global().mobileSelectRangeNotification),
|
||||
duration: k.snackBarDurationNormal,
|
||||
|
|
|
@ -14,11 +14,11 @@ import 'package:nc_photos/k.dart' as k;
|
|||
import 'package:nc_photos/mobile/platform.dart'
|
||||
if (dart.library.html) 'package:nc_photos/web/platform.dart' as platform;
|
||||
import 'package:nc_photos/mobile/self_signed_cert_manager.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/widget/page_visibility_mixin.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_lock/np_platform_lock.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:to_string/to_string.dart';
|
||||
|
||||
part 'developer/bloc.dart';
|
||||
|
@ -105,7 +105,7 @@ class _WrappedDeveloperSettingsState extends State<_WrappedDeveloperSettings>
|
|||
context.read<_Bloc>().add(const _ExportDb());
|
||||
},
|
||||
),
|
||||
if (platform_k.isMobile)
|
||||
if (getRawPlatform().isMobile)
|
||||
ListTile(
|
||||
title: const Text("Clear whitelisted certs"),
|
||||
onTap: () {
|
||||
|
|
|
@ -8,11 +8,11 @@ import 'package:nc_photos/controller/pref_controller.dart';
|
|||
import 'package:nc_photos/exception_event.dart';
|
||||
import 'package:nc_photos/exception_util.dart' as exception_util;
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/service.dart';
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/widget/page_visibility_mixin.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:to_string/to_string.dart';
|
||||
|
||||
part 'metadata/bloc.dart';
|
||||
|
@ -93,7 +93,7 @@ class _WrappedMetadataSettingsState extends State<_WrappedMetadataSettings>
|
|||
);
|
||||
},
|
||||
),
|
||||
if (platform_k.isMobile)
|
||||
if (getRawPlatform().isMobile)
|
||||
_BlocBuilder(
|
||||
buildWhen: (previous, current) =>
|
||||
previous.isEnable != current.isEnable ||
|
||||
|
|
|
@ -13,12 +13,12 @@ import 'package:nc_photos/exception_util.dart' as exception_util;
|
|||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/mobile/android/android_info.dart';
|
||||
import 'package:nc_photos/object_extension.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/session_storage.dart';
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/theme.dart';
|
||||
import 'package:nc_photos/widget/page_visibility_mixin.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:to_string/to_string.dart';
|
||||
|
||||
part 'theme/bloc.dart';
|
||||
|
@ -87,7 +87,7 @@ class _WrappedThemeSettingsState extends State<_WrappedThemeSettings>
|
|||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
const _SeedColorOption(),
|
||||
if (platform_k.isAndroid &&
|
||||
if (getRawPlatform() == NpPlatform.android &&
|
||||
AndroidInfo().sdkInt >= AndroidVersion.Q)
|
||||
_BlocSelector<bool>(
|
||||
selector: (state) => state.isFollowSystemTheme,
|
||||
|
|
|
@ -8,12 +8,12 @@ import 'package:nc_photos/controller/pref_controller.dart';
|
|||
import 'package:nc_photos/exception_event.dart';
|
||||
import 'package:nc_photos/exception_util.dart' as exception_util;
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/widget/fancy_option_picker.dart';
|
||||
import 'package:nc_photos/widget/gps_map.dart';
|
||||
import 'package:nc_photos/widget/page_visibility_mixin.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:np_ui/np_ui.dart';
|
||||
import 'package:screen_brightness/screen_brightness.dart';
|
||||
import 'package:to_string/to_string.dart';
|
||||
|
@ -82,7 +82,7 @@ class _WrappedViewerSettingsState extends State<_WrappedViewerSettings>
|
|||
SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
if (platform_k.isMobile)
|
||||
if (getRawPlatform().isMobile)
|
||||
_BlocSelector<int>(
|
||||
selector: (state) => state.screenBrightness,
|
||||
builder: (context, state) {
|
||||
|
@ -97,7 +97,7 @@ class _WrappedViewerSettingsState extends State<_WrappedViewerSettings>
|
|||
);
|
||||
},
|
||||
),
|
||||
if (platform_k.isMobile)
|
||||
if (getRawPlatform().isMobile)
|
||||
_BlocSelector<bool>(
|
||||
selector: (state) => state.isForceRotation,
|
||||
builder: (context, state) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:nc_photos/app_localizations.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
|
||||
enum ShareMethod {
|
||||
file,
|
||||
|
@ -20,7 +20,7 @@ class ShareMethodDialog extends StatelessWidget {
|
|||
return SimpleDialog(
|
||||
title: Text(L10n.global().shareMethodDialogTitle),
|
||||
children: [
|
||||
if (platform_k.isAndroid) ...[
|
||||
if (getRawPlatform() == NpPlatform.android) ...[
|
||||
if (isSupportPerview)
|
||||
SimpleDialogOption(
|
||||
child: ListTile(
|
||||
|
|
|
@ -11,7 +11,6 @@ import 'package:nc_photos/entity/pref.dart';
|
|||
import 'package:nc_photos/entity/sqlite/database.dart' as sql;
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/mobile/android/activity.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/use_case/compat/v29.dart';
|
||||
import 'package:nc_photos/use_case/compat/v46.dart';
|
||||
import 'package:nc_photos/use_case/compat/v55.dart';
|
||||
|
@ -20,6 +19,7 @@ import 'package:nc_photos/widget/home.dart';
|
|||
import 'package:nc_photos/widget/setup.dart';
|
||||
import 'package:nc_photos/widget/sign_in.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:to_string/to_string.dart';
|
||||
|
||||
part 'splash.g.dart';
|
||||
|
@ -141,7 +141,7 @@ class _SplashState extends State<Splash> {
|
|||
Navigator.pushReplacementNamed(context, Home.routeName,
|
||||
arguments: HomeArguments(account)),
|
||||
);
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
final initialRoute = await Activity.consumeInitialRoute();
|
||||
if (initialRoute != null) {
|
||||
unawaited(Navigator.pushNamed(context, initialRoute));
|
||||
|
|
|
@ -12,12 +12,12 @@ import 'package:nc_photos/entity/pref.dart';
|
|||
import 'package:nc_photos/exception_util.dart' as exception_util;
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/np_api_util.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/use_case/request_public_link.dart';
|
||||
import 'package:nc_photos/widget/disposable.dart';
|
||||
import 'package:nc_photos/widget/wakelock_util.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:np_ui/np_ui.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
|
||||
|
@ -286,7 +286,7 @@ class _VideoViewerState extends State<VideoViewer>
|
|||
}
|
||||
|
||||
Future<String> _getVideoUrl() async {
|
||||
if (platform_k.isWeb) {
|
||||
if (getRawPlatform() == NpPlatform.web) {
|
||||
return RequestPublicLink()(widget.account, widget.file);
|
||||
} else {
|
||||
return api_util.getFileUrl(widget.account, widget.file);
|
||||
|
|
|
@ -22,7 +22,6 @@ import 'package:nc_photos/k.dart' as k;
|
|||
import 'package:nc_photos/location_util.dart' as location_util;
|
||||
import 'package:nc_photos/object_extension.dart';
|
||||
import 'package:nc_photos/platform/features.dart' as features;
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/set_as_handler.dart';
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/theme.dart';
|
||||
|
@ -36,6 +35,7 @@ import 'package:nc_photos/widget/list_tile_center_leading.dart';
|
|||
import 'package:nc_photos/widget/photo_date_time_edit_dialog.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_common/or_null.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:np_string/np_string.dart';
|
||||
import 'package:np_ui/np_ui.dart';
|
||||
import 'package:path/path.dart' as path_lib;
|
||||
|
@ -171,7 +171,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
|||
label: L10n.global().addItemToCollectionTooltip,
|
||||
onPressed: () => _onAddToAlbumPressed(context),
|
||||
),
|
||||
if (platform_k.isAndroid &&
|
||||
if (getRawPlatform() == NpPlatform.android &&
|
||||
file_util.isSupportedImageFormat(_file!))
|
||||
_DetailPaneButton(
|
||||
icon: Icons.launch,
|
||||
|
@ -433,7 +433,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
|||
}
|
||||
|
||||
void _onMapTap() {
|
||||
if (platform_k.isAndroid) {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
final intent = AndroidIntent(
|
||||
action: "action_view",
|
||||
data: Uri.encodeFull("geo:${_gps!.item1},${_gps!.item2}?z=16"),
|
||||
|
|
|
@ -5,10 +5,10 @@ import 'package:flutter/widgets.dart';
|
|||
import 'package:logging/logging.dart';
|
||||
import 'package:native_device_orientation/native_device_orientation.dart';
|
||||
import 'package:nc_photos/entity/pref.dart';
|
||||
import 'package:nc_photos/platform/k.dart' as platform_k;
|
||||
import 'package:nc_photos/throttler.dart';
|
||||
import 'package:nc_photos/widget/disposable.dart';
|
||||
import 'package:np_codegen/np_codegen.dart';
|
||||
import 'package:np_platform_util/np_platform_util.dart';
|
||||
import 'package:screen_brightness/screen_brightness.dart';
|
||||
|
||||
part 'viewer_mixin.g.dart';
|
||||
|
@ -19,9 +19,9 @@ mixin ViewerControllersMixin<T extends StatefulWidget>
|
|||
initDisposables() {
|
||||
return [
|
||||
...super.initDisposables(),
|
||||
if (platform_k.isMobile) _ViewerBrightnessController(),
|
||||
if (getRawPlatform().isMobile) _ViewerBrightnessController(),
|
||||
_ViewerSystemUiResetter(),
|
||||
if (platform_k.isMobile && Pref().isViewerForceRotationOr(false))
|
||||
if (getRawPlatform().isMobile && Pref().isViewerForceRotationOr(false))
|
||||
_ViewerOrientationController(
|
||||
onChanged: _onOrientationChanged,
|
||||
),
|
||||
|
|
|
@ -1005,7 +1005,7 @@ packages:
|
|||
source: path
|
||||
version: "0.0.1"
|
||||
np_platform_util:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "../np_platform_util"
|
||||
relative: true
|
||||
|
|
|
@ -111,6 +111,8 @@ dependencies:
|
|||
path: ../np_math
|
||||
np_platform_lock:
|
||||
path: ../np_platform_lock
|
||||
np_platform_util:
|
||||
path: ../np_platform_util
|
||||
np_string:
|
||||
path: ../np_string
|
||||
np_ui:
|
||||
|
|
Loading…
Reference in a new issue