Files
umbrix/lib/utils/uri_utils.dart
Umbrix Developer 76a374950f feat: mobile-like window size and always-visible stats
- Changed window size to mobile phone format (400x800)
- Removed width condition for ActiveProxyFooter - now always visible
- Added run-umbrix.sh launch script with icon copying
- Stats cards now display on all screen sizes
2026-01-17 13:09:20 +03:00

45 lines
1.3 KiB
Dart

import 'dart:io';
import 'package:umbrix/utils/custom_loggers.dart';
import 'package:loggy/loggy.dart';
import 'package:share_plus/share_plus.dart';
import 'package:url_launcher/url_launcher.dart';
abstract class UriUtils {
static final loggy = Loggy<InfraLogger>("UriUtils");
static Future<bool> tryShareOrLaunchFile(Uri uri, {Uri? fileOrDir}) async {
if (Platform.isWindows || Platform.isLinux) {
return tryLaunch(fileOrDir ?? uri);
}
return tryShareFile(uri);
}
static Future<bool> tryLaunch(Uri uri) async {
try {
loggy.debug("launching [$uri]");
if (!await canLaunchUrl(uri)) {
loggy.warning("can't launch [$uri]");
return false;
}
return launchUrl(uri, mode: LaunchMode.externalApplication);
} catch (e, stackTrace) {
loggy.warning("error launching [$uri]", e, stackTrace);
return false;
}
}
static Future<bool> tryShareFile(Uri uri, {String? mimeType}) async {
try {
loggy.debug("sharing [$uri]");
final file = XFile(uri.path, mimeType: mimeType);
final result = await Share.shareXFiles([file]);
loggy.debug("share result: ${result.raw}");
return result.status == ShareResultStatus.success;
} catch (e, stackTrace) {
loggy.warning("error sharing file [$uri]", e, stackTrace);
return false;
}
}
}