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,70 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../../persistence/app_database.dart';
|
||||
import '../project_state.dart';
|
||||
|
||||
part 'recent_projects.g.dart';
|
||||
|
||||
@Riverpod(keepAlive: true)
|
||||
RecentProjectsRepository recentProjects(Ref ref) =>
|
||||
DriftRecentProjectsRepository(ref.watch(appDatabaseProvider));
|
||||
|
||||
abstract interface class RecentProjectsRepository {
|
||||
Future<String?> lastTimeline(String projectId);
|
||||
Future<void> rememberTimeline(String projectId, String timelineId);
|
||||
Future<List<RecentProject>> load();
|
||||
Future<void> save(List<RecentProject> projects);
|
||||
}
|
||||
|
||||
class DriftRecentProjectsRepository implements RecentProjectsRepository {
|
||||
DriftRecentProjectsRepository(this._database);
|
||||
|
||||
final AppDatabase _database;
|
||||
|
||||
@override
|
||||
Future<String?> lastTimeline(String projectId) =>
|
||||
(_database.select(_database.lastOpenedTimelines)
|
||||
..where((table) => table.projectId.equals(projectId)))
|
||||
.getSingleOrNull()
|
||||
.then((row) => row?.timelineId);
|
||||
|
||||
@override
|
||||
Future<void> rememberTimeline(String projectId, String timelineId) =>
|
||||
_database
|
||||
.into(_database.lastOpenedTimelines)
|
||||
.insertOnConflictUpdate(
|
||||
LastOpenedTimelinesCompanion.insert(
|
||||
projectId: projectId,
|
||||
timelineId: timelineId,
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
Future<List<RecentProject>> load() async {
|
||||
final rows = await (_database.select(
|
||||
_database.recentProjectRecords,
|
||||
)..orderBy([(table) => OrderingTerm.asc(table.position)])).get();
|
||||
return [
|
||||
for (final row in rows)
|
||||
RecentProject(id: row.id, name: row.name, path: row.path),
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> save(List<RecentProject> projects) =>
|
||||
_database.transaction(() async {
|
||||
await _database.delete(_database.recentProjectRecords).go();
|
||||
await _database.batch((batch) {
|
||||
batch.insertAll(_database.recentProjectRecords, [
|
||||
for (final (position, project) in projects.indexed)
|
||||
RecentProjectRecordsCompanion.insert(
|
||||
id: project.id,
|
||||
name: project.name,
|
||||
path: project.path,
|
||||
position: position,
|
||||
),
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user