feat: initial Cutdex application
Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
This commit is contained in:
commit
27e77fff39
718 files changed
+183958
No files matched your search
@@ -0,0 +1,81 @@
|
||||
import 'dart:async';
|
||||
|
||||
import '../diagnostics/app_diagnostics.dart';
|
||||
|
||||
import 'package:deskup/deskup.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
export 'package:deskup/deskup.dart' show UpdateStatus, UpdatePhase;
|
||||
|
||||
part 'app_update_bridge.g.dart';
|
||||
|
||||
const appUpdatesChannel = MethodChannel('deskup');
|
||||
const appLifecycleChannel = MethodChannel('cutdex/lifecycle');
|
||||
|
||||
bool get supportsAppUpdates => Deskup.isSupported;
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
AppUpdateBridge appUpdateBridge(Ref ref) {
|
||||
final bridge = AppUpdateBridge();
|
||||
ref.onDispose(bridge.dispose);
|
||||
return bridge;
|
||||
}
|
||||
|
||||
// Application adapter: Riverpod ownership and the macOS workspace quit gate.
|
||||
class AppUpdateBridge {
|
||||
AppUpdateBridge([MethodChannel channel = appUpdatesChannel])
|
||||
: _updater = Deskup(channel: channel);
|
||||
|
||||
final Deskup _updater;
|
||||
Stream<UpdateStatus> get events => _updater.events;
|
||||
bool _started = false;
|
||||
bool _disposed = false;
|
||||
Future<void> Function()? _prepareToQuit;
|
||||
|
||||
void start(Future<void> Function() prepareToQuit) {
|
||||
if (_disposed) return;
|
||||
_prepareToQuit = prepareToQuit;
|
||||
if (_started) return;
|
||||
_started = true;
|
||||
if (defaultTargetPlatform == TargetPlatform.macOS) {
|
||||
appLifecycleChannel.setMethodCallHandler((call) async {
|
||||
if (_disposed) return null;
|
||||
if (call.method != 'prepareToQuit') throw MissingPluginException();
|
||||
await _prepareToQuit!();
|
||||
return true;
|
||||
});
|
||||
unawaited(
|
||||
appLifecycleChannel
|
||||
.invokeMethod<void>('ready')
|
||||
.catchError(_initializationError),
|
||||
);
|
||||
}
|
||||
unawaited(_updater.initialize().catchError(_initializationError));
|
||||
}
|
||||
|
||||
void _initializationError(Object error, StackTrace stack) {
|
||||
if (!_disposed && error is! MissingPluginException) {
|
||||
AppDiagnostics.failure('updates', 'initialize', error, stack);
|
||||
}
|
||||
}
|
||||
|
||||
Future<UpdateStatus> status() => _updater.status();
|
||||
Future<void> check() => _updater.check();
|
||||
Future<void> download() => _updater.download();
|
||||
Future<void> validateInstall() => _updater.validateInstall();
|
||||
Future<void> install() => _updater.install();
|
||||
Future<void> setAutomaticChecks(bool enabled) =>
|
||||
_updater.setAutomaticChecks(enabled);
|
||||
|
||||
void dispose() {
|
||||
if (_disposed) return;
|
||||
_disposed = true;
|
||||
_prepareToQuit = null;
|
||||
if (_started && defaultTargetPlatform == TargetPlatform.macOS) {
|
||||
appLifecycleChannel.setMethodCallHandler(null);
|
||||
}
|
||||
_updater.dispose();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user