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,54 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../project_state.dart';
|
||||
|
||||
part 'project_locator.g.dart';
|
||||
part 'project_locator.freezed.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
ProjectLocator projectLocator(Ref ref) => ProjectLocator();
|
||||
|
||||
/// Resolves a persisted location without opening the project database.
|
||||
class ProjectLocator {
|
||||
Future<ProjectLocation> locate(RecentProject project) async {
|
||||
final type = await FileSystemEntity.type(project.path, followLinks: true);
|
||||
return switch (type) {
|
||||
FileSystemEntityType.directory => ProjectLocation.available(project),
|
||||
FileSystemEntityType.notFound => ProjectLocation.unavailable(
|
||||
project,
|
||||
_missingAvailability(project.path),
|
||||
),
|
||||
_ => ProjectLocation.unavailable(project, .invalid),
|
||||
};
|
||||
}
|
||||
|
||||
ProjectAvailability _missingAvailability(String path) {
|
||||
final parts = p.split(path);
|
||||
if (parts.length >= 3 && parts[1] == 'Volumes') {
|
||||
final volume = p.join(parts[0], parts[1], parts[2]);
|
||||
if (!Directory(volume).existsSync()) return .volumeOffline;
|
||||
}
|
||||
return .missing;
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class ProjectLocation with _$ProjectLocation {
|
||||
const ProjectLocation._();
|
||||
const factory ProjectLocation(RecentProject project) = _ProjectLocation;
|
||||
|
||||
factory ProjectLocation.available(RecentProject project) =>
|
||||
ProjectLocation(project.copyWith(availability: .available));
|
||||
|
||||
factory ProjectLocation.unavailable(
|
||||
RecentProject project,
|
||||
ProjectAvailability availability,
|
||||
) => ProjectLocation(project.copyWith(availability: availability));
|
||||
|
||||
ProjectAvailability get availability => project.availability;
|
||||
}
|
||||
Reference in new issue
Block a user