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,78 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import 'processing_resource_repository.dart';
|
||||
|
||||
part 'processing_resource_state.g.dart';
|
||||
part 'processing_resource_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class ProcessingResourcesSnapshot with _$ProcessingResourcesSnapshot {
|
||||
const factory ProcessingResourcesSnapshot({
|
||||
@Default([]) List<ProcessingResourceInstall> installs,
|
||||
@Default({}) Set<ProcessingCapability> paused,
|
||||
@Default({}) Map<ProcessingCapability, int> rates,
|
||||
@Default(false) bool subtitleDownloading,
|
||||
@Default(false) bool subtitlePaused,
|
||||
@Default(0) int subtitleDownloadedBytes,
|
||||
@Default(0) int subtitleTotalBytes,
|
||||
@Default(0) int subtitleBytesPerSecond,
|
||||
}) = _ProcessingResourcesSnapshot;
|
||||
}
|
||||
|
||||
/// Resource ownership stays in the repository; observers receive value snapshots.
|
||||
@riverpod
|
||||
class ProcessingResources extends _$ProcessingResources {
|
||||
@override
|
||||
ProcessingResourcesSnapshot build(ProcessingResourceRepository repository) {
|
||||
void changed() {
|
||||
if (ref.mounted) state = _snapshot();
|
||||
}
|
||||
|
||||
repository.addListener(changed);
|
||||
ref.onDispose(() => repository.removeListener(changed));
|
||||
return _snapshot();
|
||||
}
|
||||
|
||||
ProcessingResourcesSnapshot _snapshot() => ProcessingResourcesSnapshot(
|
||||
installs: List.of(repository.installs),
|
||||
paused: {
|
||||
for (final package in repository.catalog)
|
||||
if (repository.downloadPausedFor(package.capability))
|
||||
package.capability,
|
||||
},
|
||||
rates: {
|
||||
for (final package in repository.catalog)
|
||||
package.capability: repository.downloadBytesPerSecondFor(
|
||||
package.capability,
|
||||
),
|
||||
},
|
||||
subtitleDownloading: repository.subtitleDownloading,
|
||||
subtitlePaused: repository.subtitlePaused,
|
||||
subtitleDownloadedBytes:
|
||||
repository.catalog.any(
|
||||
(p) => p.capability == ProcessingCapability.transcription,
|
||||
) &&
|
||||
repository.catalog.any(
|
||||
(p) => p.capability == ProcessingCapability.translation,
|
||||
)
|
||||
? repository.subtitleDownloadedBytes
|
||||
: 0,
|
||||
subtitleTotalBytes: repository.catalog
|
||||
.where(
|
||||
(p) => ProcessingResourceRepository.subtitleCapabilities.contains(
|
||||
p.capability,
|
||||
),
|
||||
)
|
||||
.fold(0, (bytes, p) => bytes + p.bytes),
|
||||
subtitleBytesPerSecond:
|
||||
repository.catalog.any(
|
||||
(p) => p.capability == ProcessingCapability.transcription,
|
||||
) &&
|
||||
repository.catalog.any(
|
||||
(p) => p.capability == ProcessingCapability.translation,
|
||||
)
|
||||
? repository.subtitleDownloadBytesPerSecond
|
||||
: 0,
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user