Compare commits
2
Commits
No files matched your search
+5
-11
@@ -3,24 +3,18 @@
|
|||||||
# Values are literal: no shell commands, interpolation or escape expansion.
|
# Values are literal: no shell commands, interpolation or escape expansion.
|
||||||
# Use quotes for spaces; Windows paths may use / or literal backslashes.
|
# Use quotes for spaces; Windows paths may use / or literal backslashes.
|
||||||
|
|
||||||
# Default: consume exact platform releases from cutdex_native_flutter/native-dependencies.json.
|
# Windows native source development (requires Rust and FFMPEG_DIR).
|
||||||
# Explicit pinned releases: CUTDEX_NATIVE_BUILD_MODE=artifacts (clear source overrides).
|
# CUTDEX_WINDOWS_PATH=D:/workspace/cutdex_windows
|
||||||
# CUTDEX_NATIVE_BUILD_MODE=source
|
|
||||||
|
|
||||||
# Optional Windows native source override. Rustup/LLVM must be installed;
|
|
||||||
# the plugin prepares the pinned Rust target and FFmpeg SDK automatically.
|
|
||||||
# CUTDEX_WINDOWS_PATH=D:/workspace/cutdex-windows
|
|
||||||
# FFMPEG_DIR=D:/tools/ffmpeg
|
# FFMPEG_DIR=D:/tools/ffmpeg
|
||||||
|
|
||||||
# Artifacts mode only: use an extracted Windows native package.
|
# Alternatively, use an extracted Windows native package. Choose only one path.
|
||||||
# CUTDEX_WINDOWS_PACKAGE_PATH=D:/packages/cutdex-windows
|
# CUTDEX_WINDOWS_PACKAGE_PATH=D:/packages/cutdex-windows
|
||||||
# CUTDEX_WINDOWS_PACKAGE_SHA256=<verified Windows release ZIP digest>
|
|
||||||
|
|
||||||
# macOS / iOS native source development.
|
# macOS / iOS native source development.
|
||||||
# CUTDEX_APPLE_PATH=/Users/your-name/workspace/CutdexApple
|
# CUTDEX_APPLE_PATH=/Users/your-name/workspace/cutdex_apple
|
||||||
|
|
||||||
# Android native source development (Gradle composite build).
|
# Android native source development (Gradle composite build).
|
||||||
# CUTDEX_ANDROID_PATH=D:/workspace/cutdex-project/cutdex-android
|
# CUTDEX_ANDROID_PATH=D:/workspace/cutdex-project/cutdex_android
|
||||||
|
|
||||||
# Optional processing workers directory.
|
# Optional processing workers directory.
|
||||||
# CUTDEX_PROCESSING_ROOT=D:/packages/cutdex-processing
|
# CUTDEX_PROCESSING_ROOT=D:/packages/cutdex-processing
|
||||||
|
|||||||
@@ -1,28 +1,9 @@
|
|||||||
# Gitea Windows and Android builds
|
# Gitea Windows and Android builds
|
||||||
|
|
||||||
The Windows x64 host runner needs the Flutter version pinned in `.fvmrc`, Python, Node, Visual Studio C++,
|
The Windows x64 host runner needs the Flutter version pinned in `.fvmrc`, Python, Node, Visual Studio C++,
|
||||||
JDK 21 and Android SDK 36. `dependencies.json` fixes the Core release version,
|
JDK 21 and Android SDK 36. The native cutdex_windows Release and cutdex_android
|
||||||
source commit and source ZIP SHA256, together with its bundled native Flutter
|
Maven packages must be published before building this app. The SDK Git dependency
|
||||||
version and commit. `.gitea/actions/prepare-flutter` downloads that published Core
|
is pinned to Gitea; the runner account needs SSH access to that private repository.
|
||||||
archive and verifies its SHA256 and `RELEASE.json` before extracting a job-local
|
|
||||||
`.dependencies/cutdex_core`. The app and preview package both use its
|
|
||||||
`native_flutter` directory, so Pub resolves one integration source.
|
|
||||||
Core is hosted at `lingjhf/cutdex_core`; Flutter integration is hosted at
|
|
||||||
`cutdex-native/cutdex_native_flutter`. Local source development uses the ignored
|
|
||||||
`pubspec_overrides.yaml` sibling overrides. Release CI does not follow branches or
|
|
||||||
need platform repository checkout steps.
|
|
||||||
|
|
||||||
Production Android/Windows CI defaults to `CUTDEX_NATIVE_BUILD_MODE=artifacts` and
|
|
||||||
consumes the exact platform versions and Windows archive digest recorded by the
|
|
||||||
Flutter integration. Set the repository variable to `source` only for development CI;
|
|
||||||
that mode lets the Flutter integration fetch the platform's locked SHA during the
|
|
||||||
build. Android uses its single Settings hook; Windows automatically prepares the
|
|
||||||
pinned Rust toolchain/target and verified FFmpeg SDK, then links and bundles DLLs.
|
|
||||||
Applications do not need platform checkout steps or `FFMPEG_DIR`. Source-mode
|
|
||||||
hosts need Git, Python 3.11+, Rustup/LLVM for Windows and NDK/CMake/MSYS2 for Android.
|
|
||||||
`CUTDEX_NATIVE_SOURCE_TOKEN` reads private Gitea platform source repositories;
|
|
||||||
`CUTDEX_NATIVE_SOURCE_SERVER_URL` selects the runner-reachable checkout server.
|
|
||||||
Platform publication and Flutter integration CI are owned by their independent repositories.
|
|
||||||
|
|
||||||
Set CUTDEX_GITEA_TOKEN in repository Actions Secrets with repository read and
|
Set CUTDEX_GITEA_TOKEN in repository Actions Secrets with repository read and
|
||||||
package read access. It authenticates private Gitea native package downloads.
|
package read access. It authenticates private Gitea native package downloads.
|
||||||
@@ -30,7 +11,7 @@ The Android APK includes ARM64 and x86_64, uses the production flavor and curren
|
|||||||
uses the project's debug signing configuration. Configure formal signing before
|
uses the project's debug signing configuration. Configure formal signing before
|
||||||
shipping a production signed Android release. The Windows ZIP includes the whole
|
shipping a production signed Android release. The Windows ZIP includes the whole
|
||||||
Flutter Release directory and passes the PE dependency audit. Processing workers
|
Flutter Release directory and passes the PE dependency audit. Processing workers
|
||||||
and optional models are distributed separately; these workflows do not bundle them.
|
and optional models are separate; these four repositories contain no worker bundle.
|
||||||
|
|
||||||
CI and local checks share `tool/check.py` suites for analysis, app/package tests
|
CI and local checks share `tool/check.py` suites for analysis, app/package tests
|
||||||
and repository/tool tests. Local tooling loads `.env.local` with the project FVM
|
and repository/tool tests. Local tooling loads `.env.local` with the project FVM
|
||||||
@@ -77,11 +58,7 @@ Android and Windows independently download their platform artifacts from the
|
|||||||
selected CI run and immediately upload them to the draft. These jobs run in
|
selected CI run and immediately upload them to the draft. These jobs run in
|
||||||
parallel. The final job accepts only the compact metadata artifact from that same
|
parallel. The final job accepts only the compact metadata artifact from that same
|
||||||
CI run. Complete binary archives cannot substitute for platform packages or
|
CI run. Complete binary archives cannot substitute for platform packages or
|
||||||
metadata. Gitea can retain old artifact API rows after a job rerun despite overwrite.
|
metadata. Missing, expired or duplicate required artifacts block preparation
|
||||||
Selection requires the exact CI run and source commit, and exactly one artifact
|
|
||||||
created within its current successful producer job's execution interval. Jobs
|
|
||||||
preserved during a partial rerun retain their original intervals and artifacts.
|
|
||||||
Missing, expired or ambiguous artifacts in that interval block preparation
|
|
||||||
before any draft is created. Platform uploads check attachment presence without
|
before any draft is created. Platform uploads check attachment presence without
|
||||||
reading back their bytes. Before publication, every attachment is read back once
|
reading back their bytes. Before publication, every attachment is read back once
|
||||||
and verified against trusted SHA256 checksums; the full update package also
|
and verified against trusted SHA256 checksums; the full update package also
|
||||||
@@ -98,11 +75,6 @@ operator attention. Published Releases are never overwritten. The built-in
|
|||||||
GITEA_TOKEN handles release writes and Actions artifact reads; no separate
|
GITEA_TOKEN handles release writes and Actions artifact reads; no separate
|
||||||
release-write PAT is required. Do not commit credentials or keystores.
|
release-write PAT is required. Do not commit credentials or keystores.
|
||||||
|
|
||||||
Release tools are checked out at the workflow's exact commit; tagged application
|
|
||||||
source is checked out separately in `.release-source`. A manual dispatch on main
|
|
||||||
can therefore apply a reviewed release-tool fix to an existing tag without moving
|
|
||||||
that tag or substituting another application's version or CI artifacts.
|
|
||||||
|
|
||||||
Full-pipeline CI produces Actions artifacts without creating Releases. If a tag is pushed
|
Full-pipeline CI produces Actions artifacts without creating Releases. If a tag is pushed
|
||||||
before main CI succeeds, release preparation fails without creating a draft; retry
|
before main CI succeeds, release preparation fails without creating a draft; retry
|
||||||
the Release workflow once CI has finished. This design overlaps platform uploads,
|
the Release workflow once CI has finished. This design overlaps platform uploads,
|
||||||
|
|||||||
@@ -30,18 +30,6 @@ enabled for CI. Do not clear these caches between runs. Each job must have its o
|
|||||||
checkout; do not share a Flutter `build/` or `.dart_tool/` directory between jobs.
|
checkout; do not share a Flutter `build/` or `.dart_tool/` directory between jobs.
|
||||||
With an ephemeral runner, these user directories must be persisted separately.
|
With an ephemeral runner, these user directories must be persisted separately.
|
||||||
|
|
||||||
The Windows compilation job runs `tool/windows/native_cache.py` after locked Pub
|
|
||||||
resolution. It reads the Velopack version and SHA256 from the resolved deskup
|
|
||||||
package and persists its ZIP in `%LOCALAPPDATA%/Cutdex/ci-tools/native/`, keyed by
|
|
||||||
both values. Every reuse verifies the digest; corrupt files are replaced only
|
|
||||||
after a verified download. OS file locks coordinate concurrent jobs, and atomic
|
|
||||||
replacement prevents interrupted downloads from becoming cache hits. Temporary
|
|
||||||
network failures retry at most three times. `DESKUP_VELOPACK_ARCHIVE` points CMake
|
|
||||||
at the verified local ZIP, where the SDK performs its own hash check again.
|
|
||||||
An explicitly supplied offline archive is validated and can populate this cache.
|
|
||||||
Version or hash changes use a separate file; no checkout-local `_deps` directory
|
|
||||||
is shared. Persist this user cache too when using ephemeral runners.
|
|
||||||
|
|
||||||
The local `prepare-flutter` action owns cache setup, Flutter version validation,
|
The local `prepare-flutter` action owns cache setup, Flutter version validation,
|
||||||
optional Java configuration and locked dependency resolution for the quality,
|
optional Java configuration and locked dependency resolution for the quality,
|
||||||
Android and Windows compilation jobs. `.fvmrc` is the shared local/CI Flutter
|
Android and Windows compilation jobs. `.fvmrc` is the shared local/CI Flutter
|
||||||
@@ -109,12 +97,6 @@ CI artifact ZIP download requests retain the loopback Host instead: Gitea return
|
|||||||
a signed redirect to the raw archive, and its Host must remain local for that
|
a signed redirect to the raw archive, and its Host must remain local for that
|
||||||
second request to avoid the public tunnel. Release attachment links stay public.
|
second request to avoid the public tunnel. Release attachment links stay public.
|
||||||
|
|
||||||
Core source archives are cached by their pinned SHA256 under the runner user's
|
|
||||||
`.cache/cutdex/core`. Every use verifies the bytes and both dependency identities;
|
|
||||||
the archive is freshly extracted into each job's workspace. Native Flutter is
|
|
||||||
bundled with Core and reused from that one source directory. No application build
|
|
||||||
outputs or package configurations are shared between jobs.
|
|
||||||
|
|
||||||
Compare warm CI runs after the first cache fill. Measure checks, Android compile,
|
Compare warm CI runs after the first cache fill. Measure checks, Android compile,
|
||||||
Windows compile, packaging and artifact transfer separately. Total duration follows
|
Windows compile, packaging and artifact transfer separately. Total duration follows
|
||||||
the slower platform branch, plus checks and final assembly; no fixed speedup is
|
the slower platform branch, plus checks and final assembly; no fixed speedup is
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ inputs:
|
|||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- name: Prepare verified Core source release
|
|
||||||
shell: pwsh
|
|
||||||
run: python tool/gitea/prepare_dependencies.py
|
|
||||||
- name: Configure persistent build caches
|
- name: Configure persistent build caches
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: ./tool/gitea/prepare-build-cache.ps1
|
run: ./tool/gitea/prepare-build-cache.ps1
|
||||||
|
|||||||
+1
-20
@@ -14,9 +14,7 @@ concurrency:
|
|||||||
env:
|
env:
|
||||||
CI: 'true'
|
CI: 'true'
|
||||||
PYTHONUTF8: '1'
|
PYTHONUTF8: '1'
|
||||||
CUTDEX_NATIVE_SOURCE_TOKEN: ${{ secrets.CUTDEX_NATIVE_SOURCE_TOKEN }}
|
|
||||||
CUTDEX_GITEA_INTERNAL_URL: http://127.0.0.1:3000
|
CUTDEX_GITEA_INTERNAL_URL: http://127.0.0.1:3000
|
||||||
CUTDEX_NATIVE_SOURCE_SERVER_URL: http://127.0.0.1:3000
|
|
||||||
GIT_CONFIG_COUNT: '2'
|
GIT_CONFIG_COUNT: '2'
|
||||||
GIT_CONFIG_KEY_0: core.autocrlf
|
GIT_CONFIG_KEY_0: core.autocrlf
|
||||||
GIT_CONFIG_VALUE_0: 'false'
|
GIT_CONFIG_VALUE_0: 'false'
|
||||||
@@ -80,13 +78,10 @@ jobs:
|
|||||||
$file = 'android/gradle.properties'
|
$file = 'android/gradle.properties'
|
||||||
$properties = [IO.File]::ReadAllText($file).Replace('-Xmx8G', '-Xmx3G').Replace('MaxMetaspaceSize=4G', 'MaxMetaspaceSize=768m')
|
$properties = [IO.File]::ReadAllText($file).Replace('-Xmx8G', '-Xmx3G').Replace('MaxMetaspaceSize=4G', 'MaxMetaspaceSize=768m')
|
||||||
[IO.File]::WriteAllText($file, $properties + "`norg.gradle.workers.max=4`norg.gradle.caching=true`n")
|
[IO.File]::WriteAllText($file, $properties + "`norg.gradle.workers.max=4`norg.gradle.caching=true`n")
|
||||||
- uses: ./.dependencies/cutdex_core/native_flutter/.gitea/actions/setup-android
|
|
||||||
if: vars.CUTDEX_NATIVE_BUILD_MODE == 'source'
|
|
||||||
- name: Build production Android APK
|
- name: Build production Android APK
|
||||||
env:
|
env:
|
||||||
GITEA_ACTOR: lingjhf
|
GITEA_ACTOR: lingjhf
|
||||||
run: |
|
run: |
|
||||||
$env:CUTDEX_NATIVE_BUILD_MODE = '${{ vars.CUTDEX_NATIVE_BUILD_MODE || 'artifacts' }}'
|
|
||||||
Remove-Item Env:CUTDEX_ANDROID_PATH -ErrorAction SilentlyContinue
|
Remove-Item Env:CUTDEX_ANDROID_PATH -ErrorAction SilentlyContinue
|
||||||
python tool/build.py android
|
python tool/build.py android
|
||||||
if ($LASTEXITCODE -ne 0) { throw 'Android build failed.' }
|
if ($LASTEXITCODE -ne 0) { throw 'Android build failed.' }
|
||||||
@@ -114,23 +109,9 @@ jobs:
|
|||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
- name: Prepare Flutter environment
|
- name: Prepare Flutter environment
|
||||||
uses: ./.gitea/actions/prepare-flutter
|
uses: ./.gitea/actions/prepare-flutter
|
||||||
- name: Clear inherited native build overrides
|
|
||||||
run: |
|
|
||||||
foreach ($key in @('CUTDEX_WINDOWS_PATH', 'CUTDEX_WINDOWS_PACKAGE_PATH', 'FFMPEG_DIR', 'LIBCLANG_PATH')) {
|
|
||||||
Remove-Item "Env:$key" -ErrorAction SilentlyContinue
|
|
||||||
"$key=" >> $env:GITHUB_ENV
|
|
||||||
}
|
|
||||||
- uses: ./.dependencies/cutdex_core/native_flutter/.gitea/actions/setup-windows
|
|
||||||
if: vars.CUTDEX_NATIVE_BUILD_MODE == 'source'
|
|
||||||
with:
|
|
||||||
libclang-path: ${{ vars.CUTDEX_LIBCLANG_PATH }}
|
|
||||||
- name: Reuse verified Velopack native archive
|
|
||||||
run: |
|
|
||||||
python tool/windows/native_cache.py
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw 'Windows native archive cache preparation failed.' }
|
|
||||||
- name: Build production Windows app
|
- name: Build production Windows app
|
||||||
run: |
|
run: |
|
||||||
$env:CUTDEX_NATIVE_BUILD_MODE = '${{ vars.CUTDEX_NATIVE_BUILD_MODE || 'artifacts' }}'
|
Remove-Item Env:CUTDEX_WINDOWS_PATH, Env:CUTDEX_WINDOWS_PACKAGE_PATH -ErrorAction SilentlyContinue
|
||||||
python tool/build.py windows
|
python tool/build.py windows
|
||||||
if ($LASTEXITCODE -ne 0) { throw 'Windows build failed.' }
|
if ($LASTEXITCODE -ne 0) { throw 'Windows build failed.' }
|
||||||
- name: Verify native SDK matches pinned packaging tools
|
- name: Verify native SDK matches pinned packaging tools
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ env:
|
|||||||
GIT_CONFIG_VALUE_0: 'false'
|
GIT_CONFIG_VALUE_0: 'false'
|
||||||
GIT_CONFIG_KEY_1: core.eol
|
GIT_CONFIG_KEY_1: core.eol
|
||||||
GIT_CONFIG_VALUE_1: lf
|
GIT_CONFIG_VALUE_1: lf
|
||||||
RELEASE_PUBSPEC: .release-source/pubspec.yaml
|
|
||||||
RELEASE_TAG: ${{ gitea.event.inputs.tag || gitea.ref_name }}
|
RELEASE_TAG: ${{ gitea.event.inputs.tag || gitea.ref_name }}
|
||||||
GITEA_REPOSITORY: ${{ gitea.repository }}
|
GITEA_REPOSITORY: ${{ gitea.repository }}
|
||||||
jobs:
|
jobs:
|
||||||
@@ -41,23 +40,16 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out pinned release tools
|
- name: Check out release tag
|
||||||
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
||||||
with:
|
|
||||||
ref: ${{ gitea.sha }}
|
|
||||||
persist-credentials: false
|
|
||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
||||||
- name: Check out release source separately
|
|
||||||
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||||
with:
|
with:
|
||||||
ref: ${{ gitea.event.inputs.tag || gitea.ref_name }}
|
ref: ${{ gitea.event.inputs.tag || gitea.ref_name }}
|
||||||
path: .release-source
|
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
- name: Select successful CI and prepare draft
|
- name: Select successful CI and prepare draft
|
||||||
id: draft
|
id: draft
|
||||||
run: |
|
run: |
|
||||||
$env:GITEA_SHA = git -C .release-source rev-parse HEAD
|
$env:GITEA_SHA = git rev-parse HEAD
|
||||||
if ($LASTEXITCODE -ne 0) { throw 'Release source resolution failed.' }
|
if ($LASTEXITCODE -ne 0) { throw 'Release source resolution failed.' }
|
||||||
python tool/gitea/stage-release.py prepare-ci
|
python tool/gitea/stage-release.py prepare-ci
|
||||||
if ($LASTEXITCODE -ne 0) { throw 'CI selection or draft preparation failed.' }
|
if ($LASTEXITCODE -ne 0) { throw 'CI selection or draft preparation failed.' }
|
||||||
@@ -73,17 +65,10 @@ jobs:
|
|||||||
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
|
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
|
||||||
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.android-artifact-id }}
|
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.android-artifact-id }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out pinned release tools
|
- name: Check out release commit
|
||||||
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||||
with:
|
with:
|
||||||
ref: ${{ gitea.sha }}
|
ref: ${{ needs.prepare.outputs.sha }}
|
||||||
persist-credentials: false
|
|
||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
||||||
- name: Check out release source separately
|
|
||||||
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
||||||
with:
|
|
||||||
ref: ${{ gitea.event.inputs.tag || gitea.ref_name }}
|
|
||||||
path: .release-source
|
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
- name: Download Android CI artifact
|
- name: Download Android CI artifact
|
||||||
@@ -106,17 +91,10 @@ jobs:
|
|||||||
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
|
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
|
||||||
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.windows-artifact-id }}
|
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.windows-artifact-id }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out pinned release tools
|
- name: Check out release commit
|
||||||
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||||
with:
|
with:
|
||||||
ref: ${{ gitea.sha }}
|
ref: ${{ needs.prepare.outputs.sha }}
|
||||||
persist-credentials: false
|
|
||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
||||||
- name: Check out release source separately
|
|
||||||
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
||||||
with:
|
|
||||||
ref: ${{ gitea.event.inputs.tag || gitea.ref_name }}
|
|
||||||
path: .release-source
|
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
- name: Download Windows CI artifact
|
- name: Download Windows CI artifact
|
||||||
@@ -139,17 +117,10 @@ jobs:
|
|||||||
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
|
CI_RUN_ID: ${{ needs.prepare.outputs.ci-run-id }}
|
||||||
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.artifact-id }}
|
CI_ARTIFACT_ID: ${{ needs.prepare.outputs.artifact-id }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out pinned release tools
|
- name: Check out release commit
|
||||||
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||||
with:
|
with:
|
||||||
ref: ${{ gitea.sha }}
|
ref: ${{ needs.prepare.outputs.sha }}
|
||||||
persist-credentials: false
|
|
||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
|
||||||
- name: Check out release source separately
|
|
||||||
uses: https://github.com/actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
|
||||||
with:
|
|
||||||
ref: ${{ gitea.event.inputs.tag || gitea.ref_name }}
|
|
||||||
path: .release-source
|
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
github-server-url: ${{ env.CUTDEX_GITEA_INTERNAL_URL }}
|
||||||
- name: Download release verification metadata
|
- name: Download release verification metadata
|
||||||
|
|||||||
@@ -105,7 +105,3 @@ pubspec_overrides.yaml
|
|||||||
|
|
||||||
# FVM Version Cache
|
# FVM Version Cache
|
||||||
.fvm/
|
.fvm/
|
||||||
|
|
||||||
# Core and native source checkouts prepared by CI or local development.
|
|
||||||
.dependencies/
|
|
||||||
.release-source/
|
|
||||||
@@ -17,7 +17,7 @@ Cutdex 是一款视频剪辑应用。你可以在时间线上编辑视频、音
|
|||||||
|
|
||||||
## 下载与安装
|
## 下载与安装
|
||||||
|
|
||||||
可从 [Gitea Releases](https://git.orangraph.com/lingjhf/cutdex/releases) 下载 Windows x64 安装包或便携包,以及 Android ARM64/x86_64 APK。当前 Android APK 使用开发签名;macOS 和 iOS 暂未提供安装包。
|
本仓库目前尚未发布可下载的安装包。
|
||||||
|
|
||||||
## 可以做什么
|
## 可以做什么
|
||||||
|
|
||||||
@@ -53,14 +53,6 @@ Cutdex 是一款视频剪辑应用。你可以在时间线上编辑视频、音
|
|||||||
|
|
||||||
“设置 → 通用”可以切换语言、明暗主题和存储位置。桌面版还提供软件更新入口,是否可用取决于安装包的更新配置。
|
“设置 → 通用”可以切换语言、明暗主题和存储位置。桌面版还提供软件更新入口,是否可用取决于安装包的更新配置。
|
||||||
|
|
||||||
配色方案提供石墨灰与蓝色、柔灰与紫色、暖灰与青绿三种选择。每种方案都有浅色和深色版本,也可跟随系统外观;配色方案与明暗选择分别保存。
|
|
||||||
|
|
||||||
桌面剪辑工作区采用独立的控件与布局尺寸:素材、预览和属性分别成面板,下方时间线横跨编辑区,播放栏固定在预览底部。时间线标签、编辑命令和标尺分层排列,窄面板中的次要命令收进更多菜单。顶部可展开或收起聊天,草稿会保留;聊天区域宽度和时间线高度支持拖动并保存。手机和平板继续使用各自的页面与工具面板。
|
|
||||||
|
|
||||||
桌面窗口顶部以标签页切换已打开的项目,“+”菜单可新建、打开或选择最近项目。左侧只展示当前项目的聊天,会话历史与新建聊天位于聊天区头部;素材库属于当前项目,放在编辑区内,可独立收起并保留浏览状态。关闭标签不会删除项目,切换项目会保留各自的聊天草稿。
|
|
||||||
|
|
||||||
桌面素材区提供紧凑卡片和列表视图,可按名称搜索,并按导入顺序或名称升降序排列。视频、图片和音频共用选中状态,时长来自实际素材信息;缺失素材保留名称并标明原因。搜索、排序和视图选择按项目保留。
|
|
||||||
|
|
||||||
遇到编辑、保存、预览或后台任务错误时,可在“设置 → 通用 → 诊断”中导出诊断包,协助定位问题。分享前请检查内容,移除不希望公开的信息。
|
遇到编辑、保存、预览或后台任务错误时,可在“设置 → 通用 → 诊断”中导出诊断包,协助定位问题。分享前请检查内容,移除不希望公开的信息。
|
||||||
|
|
||||||
需要连接外部 AI 工具时,可查看 [MCP 连接指南](docs/mcp-connection.md)。
|
需要连接外部 AI 工具时,可查看 [MCP 连接指南](docs/mcp-connection.md)。
|
||||||
|
|||||||
@@ -7,5 +7,3 @@ Flutter/Dart 依赖及解析版本记录在 `pubspec.yaml`、内部包的 `pubsp
|
|||||||
应用发行包捆绑的媒体处理库、推理工具和模型遵循各自的许可与再分发要求。打包时保留随附的许可证和通知文件;不能用本仓库的 MIT 许可替代。
|
应用发行包捆绑的媒体处理库、推理工具和模型遵循各自的许可与再分发要求。打包时保留随附的许可证和通知文件;不能用本仓库的 MIT 许可替代。
|
||||||
|
|
||||||
仓库中的测试不附带个人媒体或模型。新增第三方素材、字体或代码时,应一同记录来源和许可证,并保留要求的版权声明。
|
仓库中的测试不附带个人媒体或模型。新增第三方素材、字体或代码时,应一同记录来源和许可证,并保留要求的版权声明。
|
||||||
|
|
||||||
桌面属性栏使用 [Inter 4.1](https://github.com/rsms/inter/releases/tag/v4.1) 的可变字体,遵循 SIL Open Font License 1.1。原始字体与版权声明保存在 `packages/cutdex_ui/assets/fonts/InterVariable.ttf` 和 `INTER_LICENSE.txt` 中。
|
|
||||||
@@ -13,6 +13,7 @@ analyzer:
|
|||||||
- windows/**
|
- windows/**
|
||||||
- macos/**
|
- macos/**
|
||||||
- linux/**
|
- linux/**
|
||||||
|
- packages/*/example/**
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
riverpod_lint: ^3.1.9
|
riverpod_lint: ^3.1.9
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId = "com.example.cutdex"
|
applicationId = "com.example.cutdex"
|
||||||
manifestPlaceholders["cutdexPreviewReverseCacheMiB"] = "0"
|
|
||||||
manifestPlaceholders["cutdexNativeSurfacePreview"] = "false"
|
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||||
minSdk = 31
|
minSdk = 31
|
||||||
@@ -52,17 +50,7 @@ android {
|
|||||||
create("development") {
|
create("development") {
|
||||||
dimension = "environment"
|
dimension = "environment"
|
||||||
applicationIdSuffix = ".dev"
|
applicationIdSuffix = ".dev"
|
||||||
// Device validation can coexist with an app signed on another machine.
|
resValue("string", "app_name", "Cutdex Dev")
|
||||||
val validationId = providers.gradleProperty("cutdexValidationApplicationId")
|
|
||||||
.orElse(providers.environmentVariable("CUTDEX_VALIDATION_APPLICATION_ID")).orNull
|
|
||||||
if (validationId != null) applicationId = validationId
|
|
||||||
resValue("string", "app_name", if (validationId == null) "Cutdex Dev" else "Cutdex Decoder Test")
|
|
||||||
manifestPlaceholders["cutdexPreviewReverseCacheMiB"] = providers
|
|
||||||
.gradleProperty("cutdexPreviewReverseCacheMiB")
|
|
||||||
.orElse(providers.environmentVariable("CUTDEX_PREVIEW_REVERSE_CACHE_MIB")).getOrElse("0")
|
|
||||||
manifestPlaceholders["cutdexNativeSurfacePreview"] = providers
|
|
||||||
.gradleProperty("cutdexNativeSurfacePreview")
|
|
||||||
.orElse(providers.environmentVariable("CUTDEX_NATIVE_SURFACE_PREVIEW")).getOrElse("false")
|
|
||||||
}
|
}
|
||||||
create("production") {
|
create("production") {
|
||||||
dimension = "environment"
|
dimension = "environment"
|
||||||
|
|||||||
@@ -3,10 +3,6 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/cutdex_launcher">
|
android:icon="@mipmap/cutdex_launcher">
|
||||||
<meta-data android:name="dev.cutdex.previewReverseCacheMiB"
|
|
||||||
android:value="${cutdexPreviewReverseCacheMiB}" />
|
|
||||||
<meta-data android:name="dev.cutdex.nativeSurfacePreview"
|
|
||||||
android:value="${cutdexNativeSurfacePreview}" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@@ -25,5 +25,14 @@ plugins {
|
|||||||
|
|
||||||
include(":app")
|
include(":app")
|
||||||
|
|
||||||
// Register native source dependencies before Gradle creates the projects.
|
// Native source development is opt-in; default resolution uses Gitea Maven packages.
|
||||||
apply(from = project(":cutdex_native_flutter").projectDir.resolve("native-settings.gradle"))
|
val nativeAndroidPath = providers.gradleProperty("cutdex.android.path")
|
||||||
|
.orElse(providers.environmentVariable("CUTDEX_ANDROID_PATH"))
|
||||||
|
.orNull
|
||||||
|
nativeAndroidPath?.takeIf { it.isNotBlank() }?.let { nativePath ->
|
||||||
|
includeBuild(nativePath) {
|
||||||
|
dependencySubstitution {
|
||||||
|
substitute(module("dev.cutdex:cutdex-android")).using(project(":cutdex-android"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"schemaVersion": 1,
|
|
||||||
"core": {
|
|
||||||
"repository": "lingjhf/cutdex_core",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"ref": "v0.0.1",
|
|
||||||
"revision": "a9c245ada56536f1642b39b1370c6ec2bb1a2a13",
|
|
||||||
"artifact": {
|
|
||||||
"file": "cutdex-core-0.0.1.zip",
|
|
||||||
"sha256": "9fbff6317b8e4876c423c73dc0da319fad6d96523c50878687dffdb88edde979"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nativeFlutter": {
|
|
||||||
"repository": "cutdex-native/cutdex_native_flutter",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"ref": "v0.0.1",
|
|
||||||
"revision": "6349cd61676617eb1f739b37b7758a74b0a780cb"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+14
-23
@@ -12,30 +12,21 @@
|
|||||||
|
|
||||||
本地联调其他包时,可参考 `pubspec_overrides.yaml.example` 创建覆盖配置。覆盖文件只用于本机开发,不提交。
|
本地联调其他包时,可参考 `pubspec_overrides.yaml.example` 创建覆盖配置。覆盖文件只用于本机开发,不提交。
|
||||||
|
|
||||||
应用直接依赖 `cutdex_core` 和 `cutdex_native_flutter`,预览协调与时间线 UI 位于应用内部包。
|
## 运行应用
|
||||||
正式构建由 `dependencies.json` 固定 Core 的发布版本、源码提交和 ZIP SHA256,
|
|
||||||
同时记录随 Core 分发的 Flutter 集成版本与提交。运行
|
|
||||||
`python3 tool/gitea/prepare_dependencies.py` 后,验证的 Core 源码放到
|
|
||||||
`.dependencies/cutdex_core`;应用及预览包共用其中的 `native_flutter`,避免重复解析两个原生集成来源。
|
|
||||||
私有下载使用 `CUTDEX_GITEA_TOKEN`。缓存只复用校验过的 ZIP,每个 CI job 独立解压。
|
|
||||||
|
|
||||||
Core 远端为 `lingjhf/cutdex_core`,Flutter 集成远端为 `cutdex-native/cutdex_native_flutter`。
|
本地路径与原生包认证统一放在应用根目录的 `.env.local`。复制
|
||||||
本地源码联调使用 `pubspec_overrides.yaml.example` 指向同级 checkout,覆盖文件不提交。
|
[配置示例](../.env.example),按需取消注释并填写本机路径;文件已忽略,不提交、
|
||||||
发布 ZIP 包含 `RELEASE.json`,应用同时校验 Core 和 Flutter 集成的版本、提交及平台依赖元数据。
|
不作为应用资源打包。没有配置时,SDK 使用固定版本的已发布原生包。
|
||||||
|
|
||||||
原生实现位于独立的 `CutdexApple`、`cutdex-android`、`cutdex-windows` 仓库。
|
|
||||||
它们的开发提交和确切发布版本由 Flutter 集成的 `native-dependencies.json` 固定。
|
|
||||||
默认 `CUTDEX_NATIVE_BUILD_MODE=artifacts` 消费发布版本;开发设置 `source` 按完整 SHA 编译。
|
|
||||||
本地联调显式设置 `CUTDEX_APPLE_PATH`、`CUTDEX_ANDROID_PATH` 或 `CUTDEX_WINDOWS_PATH`,
|
|
||||||
可以使用未提交修改。正式构建清除这些覆盖。
|
|
||||||
|
|
||||||
源码模式需要目标平台工具链;Android 通过共享 Settings 注册 composite build,
|
|
||||||
Windows 需要 Rust、FFmpeg SDK 与 libclang,Apple 通过 SwiftPM 消费独立源码包。
|
|
||||||
发布模式使用确切 Apple Git 版本、Android Maven 版本和 Windows Release 版本及架构摘要。
|
|
||||||
切换模式后清理宿主生成目录并重新解析依赖。认证和具体构建说明见独立 Flutter 集成 README。
|
|
||||||
|
|
||||||
|
Windows 可用 `CUTDEX_WINDOWS_PATH` 联调本地源码(需要 Rust 和 `FFMPEG_DIR`),
|
||||||
|
或用 `CUTDEX_WINDOWS_PACKAGE_PATH` 指定已解压的离线包,两者只选其一。
|
||||||
|
macOS/iOS 可用 `CUTDEX_APPLE_PATH` 指定本地源码。
|
||||||
|
Android 可用 `CUTDEX_ANDROID_PATH` 指向 `cutdex_android` 工程根目录,Gradle 会用
|
||||||
|
本地源码替换 Maven 原生依赖;未配置或留空时使用已发布包。
|
||||||
|
已有 Gradle 属性 `cutdex.android.path` 优先于该环境变量,显式空属性会关闭本地替换。
|
||||||
`CUTDEX_PROCESSING_ROOT` 指定处理 worker 目录;Android 私有 Maven 认证可填写
|
`CUTDEX_PROCESSING_ROOT` 指定处理 worker 目录;Android 私有 Maven 认证可填写
|
||||||
`GITEA_ACTOR` 和 `CUTDEX_GITEA_TOKEN`,账号应属于令牌的认证用户。
|
`GITEA_ACTOR` 和 `CUTDEX_GITEA_TOKEN`。这里的 `GITEA_ACTOR` 是令牌所属的认证
|
||||||
|
账号,CI 中也按令牌账号设置,与触发工作流的用户无关。
|
||||||
|
|
||||||
VS Code 的 Debug、Profile、Release 启动项与下述命令共用
|
VS Code 的 Debug、Profile、Release 启动项与下述命令共用
|
||||||
`tool/flutter_local.dart` 加载规则。VS Code 的项目 SDK 设置由 `fvm use` 自动同步,
|
`tool/flutter_local.dart` 加载规则。VS Code 的项目 SDK 设置由 `fvm use` 自动同步,
|
||||||
@@ -86,7 +77,7 @@ python3 tool/build.py android --flavor development --split-per-abi
|
|||||||
| 设置、诊断与更新界面 | `lib/features/settings/` |
|
| 设置、诊断与更新界面 | `lib/features/settings/` |
|
||||||
| 桌面、平板与手机布局 | `lib/app/shells/` |
|
| 桌面、平板与手机布局 | `lib/app/shells/` |
|
||||||
|
|
||||||
应用根目录是 Pub workspace。`packages/cutdex_preview` 持有预览协调与画布交互,`packages/cutdex_timeline_ui` 持有时间线 UI 和示例;正式编辑计划由 core 统一编译与同步。[cutdex_ui](../packages/cutdex_ui/README.md) 维护通用组件与基础主题,[cutdex_native](../packages/cutdex_native/README.md) 维护设备信息与桌面交互。应用集成入口在 `lib/integrations/`,共享布局与业务样式在 `lib/shared/`。
|
应用根目录是 Pub workspace。[cutdex_ui](../packages/cutdex_ui/README.md) 维护通用组件与基础主题,[cutdex_native](../packages/cutdex_native/README.md) 维护设备信息与桌面交互。应用集成入口在 `lib/integrations/`,共享布局与业务样式在 `lib/shared/`。
|
||||||
|
|
||||||
修改剪辑操作时,检查预览、保存、撤销和重做;修改素材导入时,检查文件访问及项目重新打开后的可用性;修改后台任务时,检查完成、失败和取消后的界面状态。
|
修改剪辑操作时,检查预览、保存、撤销和重做;修改素材导入时,检查文件访问及项目重新打开后的可用性;修改后台任务时,检查完成、失败和取消后的界面状态。
|
||||||
|
|
||||||
@@ -112,7 +103,7 @@ python3 tool/build.py android --flavor development --split-per-abi
|
|||||||
额外 Flutter 参数放在 `--` 后。仅构建 macOS 应用时使用此入口;完整 ZIP/DMG
|
额外 Flutter 参数放在 `--` 后。仅构建 macOS 应用时使用此入口;完整 ZIP/DMG
|
||||||
打包、processing 嵌入、签名和公证使用 `build_macos_release.py`。
|
打包、processing 嵌入、签名和公证使用 `build_macos_release.py`。
|
||||||
|
|
||||||
环境文件合并时进程变量优先,包括空值。原生构建仍遵循 `cutdex_native_flutter` 的覆盖规则:
|
环境文件合并时进程变量优先,包括空值。原生构建仍遵循所属 SDK 的覆盖规则:
|
||||||
Android Gradle 属性先于环境变量;Windows CMake 已缓存的非空路径先于环境变量,
|
Android Gradle 属性先于环境变量;Windows CMake 已缓存的非空路径先于环境变量,
|
||||||
修改后需 clean;processing 的非空 Dart define 先于进程环境,再使用随包默认路径。
|
修改后需 clean;processing 的非空 Dart define 先于进程环境,再使用随包默认路径。
|
||||||
`CUTDEX_GITEA_TOKEN` 用于依赖访问,Release 的 `GITEA_TOKEN` 用于发布和 CI 产物读取。
|
`CUTDEX_GITEA_TOKEN` 用于依赖访问,Release 的 `GITEA_TOKEN` 用于发布和 CI 产物读取。
|
||||||
|
|||||||
@@ -49,17 +49,3 @@ fvm dart tool/flutter_local.dart test test/generated_code_test.dart test/localiz
|
|||||||
普通测试中的可选真实模型回归使用环境变量:`CUTDEX_ACCEPTANCE_LIVE` 和 `CUTDEX_BEAT_LIVE` 指向对应测试的配置 JSON,`CUTDEX_ASR_FIXTURE` 指定语音素材。配置字段以测试读取代码为准,素材、模型及凭据放在仓库外。
|
普通测试中的可选真实模型回归使用环境变量:`CUTDEX_ACCEPTANCE_LIVE` 和 `CUTDEX_BEAT_LIVE` 指向对应测试的配置 JSON,`CUTDEX_ASR_FIXTURE` 指定语音素材。配置字段以测试读取代码为准,素材、模型及凭据放在仓库外。
|
||||||
|
|
||||||
记录实际运行的平台、输入、失败和跳过原因。缺少模型、设备或素材时明确跳过;失败先核对夹具与当前契约,不通过放宽断言或无条件跳过掩盖问题。
|
记录实际运行的平台、输入、失败和跳过原因。缺少模型、设备或素材时明确跳过;失败先核对夹具与当前契约,不通过放宽断言或无条件跳过掩盖问题。
|
||||||
|
|
||||||
## 应用持有的编辑 UI
|
|
||||||
|
|
||||||
迁入的预览协调和时间线 UI 与应用一起验证:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
flutter test --no-pub packages/cutdex_preview/test packages/cutdex_timeline_ui/test packages/cutdex_timeline_ui/example/test
|
|
||||||
```
|
|
||||||
|
|
||||||
这两个包及时间线示例的测试由 `tool/check.py --suite flutter` 自动纳入常规 CI;示例源码也纳入静态分析。示例从时间 `0` 开始,测试手势通过实际视口和片段布局计算位置,并验证命中目标。裁剪的逐帧预览需先 `pump` 再断言;选择、提交、撤销与重做仍验证明确的编辑结果和版本。
|
|
||||||
|
|
||||||
core 的编译、求值、同步和编辑业务测试在 core 仓库使用 Dart VM 运行;native Flutter 的平台适配测试仍在 native 仓库。
|
|
||||||
|
|
||||||
应用及 UI 包的生产源码不得持有 `cutdex_runtime` 通道;原生媒体通信通过 `cutdex_native_flutter` 的公共接口进入内部 transport。`tool/check_package_boundaries.py` 检查通道名称,测试可以保留 wire mock,应用自己的窗口与生命周期通道仍由应用管理。性能诊断使用已有原生会话的 `previewDiagnostics()`,应用只负责采样、计时校准与报告。
|
|
||||||
@@ -68,10 +68,6 @@ python tool/build.py windows --flavor development -- `
|
|||||||
Gitea 开发仓库使用 `CUTDEX_WINDOWS_UPDATE_SOURCE=gitea` 和仓库 URL。
|
Gitea 开发仓库使用 `CUTDEX_WINDOWS_UPDATE_SOURCE=gitea` 和仓库 URL。
|
||||||
仅设置进程环境变量不会配置 Dart 更新源。正式版忽略开发 defines。
|
仅设置进程环境变量不会配置 Dart 更新源。正式版忽略开发 defines。
|
||||||
原生 SDK 离线缓存仍通过 `DESKUP_VELOPACK_ARCHIVE` 环境变量指定。
|
原生 SDK 离线缓存仍通过 `DESKUP_VELOPACK_ARCHIVE` 环境变量指定。
|
||||||
CI 会按已解析 deskup 的版本和 SHA256,将原生 ZIP 缓存到
|
|
||||||
`%LOCALAPPDATA%/Cutdex/ci-tools/native/`,后续构建校验后直接复用。
|
|
||||||
本地可运行 `python tool/windows/native_cache.py` 预热同一缓存;命令会输出
|
|
||||||
可供 `DESKUP_VELOPACK_ARCHIVE` 使用的文件路径。
|
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
python -m unittest discover -s tool/gitea -p 'test_*.py'
|
python -m unittest discover -s tool/gitea -p 'test_*.py'
|
||||||
|
|||||||
@@ -6,79 +6,6 @@ backends. `test_driver/integration_test.dart` is the host driver used by
|
|||||||
media, models, reports and credentials are supplied locally and stay outside
|
media, models, reports and credentials are supplied locally and stay outside
|
||||||
version control. Normal release builds use `lib/main.dart`.
|
version control. Normal release builds use `lib/main.dart`.
|
||||||
|
|
||||||
## Android navigation and playhead measurements
|
|
||||||
|
|
||||||
`android_decoder_material_performance_test.dart` extends the production workspace
|
|
||||||
benchmark to other source rates and variable timestamps. Supply
|
|
||||||
`CUTDEX_TEST_SOURCE_PTS` as an independent, sorted list of original frame PTS
|
|
||||||
(one integer source tick per line), with `CUTDEX_TEST_SOURCE_TIMESCALE` set to
|
|
||||||
that clock's denominator, such as 90000. The default timescale is 1000000 for
|
|
||||||
existing integer-microsecond fixtures; preserve original source ticks for frame
|
|
||||||
boundaries that cannot be represented in microseconds. `CUTDEX_TEST_FRAME_STEP_US`
|
|
||||||
is the nominal frame period rounded to microseconds. Its eight `matchedSeeks` use
|
|
||||||
the standalone benchmark's exact request sequence. Full-source ruler drags and
|
|
||||||
20-frame local drags use the production timeline and are reported separately;
|
|
||||||
their inputs differ from the standalone source replay.
|
|
||||||
|
|
||||||
`CUTDEX_TEST_CALIBRATE=true` explicitly runs native/software calibration before
|
|
||||||
opening the workspace and verifies both sets against the external PTS list.
|
|
||||||
It asserts the admitted backend throughout later navigation and gestures.
|
|
||||||
The application opens no calibration workload automatically.
|
|
||||||
|
|
||||||
If the device's installed application has a different signing certificate,
|
|
||||||
build the development flavor with
|
|
||||||
`CUTDEX_VALIDATION_APPLICATION_ID=com.example.cutdex.decoder_validation`.
|
|
||||||
This creates `com.example.cutdex.decoder_validation.dev`, labeled
|
|
||||||
`Cutdex Decoder Test`, while preserving the installed application and its data.
|
|
||||||
For a cache baseline, set `CUTDEX_PREVIEW_REVERSE_CACHE_MIB=24`;
|
|
||||||
set it to `0` for normal device policy. These properties affect development only.
|
|
||||||
Use matching private file paths and retain the app between runs.
|
|
||||||
|
|
||||||
`android_navigation_performance_test.dart` mounts the production `EditorWorkspace`
|
|
||||||
with real `Projects`, preview and native playback providers. Its project and
|
|
||||||
application database are isolated. Supply a complete original video through
|
|
||||||
`CUTDEX_TEST_SOURCE` and an app-writable JSON path through `CUTDEX_TEST_REPORT`.
|
|
||||||
The test keeps production audible-skimming policy and uses touch input on real
|
|
||||||
timeline tabs and the timeline ruler. It measures cold/cached selection, rapid
|
|
||||||
selection replacement, exact seeks, full-source fit-to-viewport and local
|
|
||||||
20-frame drags, and both immediate release and a one-second stationary hold.
|
|
||||||
The source-frame containment checks currently require an untrimmed CFR
|
|
||||||
2997/100 fps source.
|
|
||||||
Use `--dart-define=CUTDEX_TEST_DECODER=ffmpeg` to assert the actual decoder
|
|
||||||
from initial load through seeks, both drag directions and final release.
|
|
||||||
Reports retain per-layer backend and selection-reason diagnostics.
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
fvm dart tool/flutter_local.dart drive --profile --flavor development -d DEVICE_ID --keep-app-running `
|
|
||||||
--driver=test_driver/integration_test.dart `
|
|
||||||
--target=integration_test/android_navigation_performance_test.dart `
|
|
||||||
--dart-define=CUTDEX_TEST_SOURCE=/data/user/0/com.example.cutdex.dev/files/cutdex-validation/source.mp4 `
|
|
||||||
--dart-define=CUTDEX_TEST_REPORT=/data/user/0/com.example.cutdex.dev/files/cutdex-validation/results.json
|
|
||||||
```
|
|
||||||
|
|
||||||
The Flutter adapter uses the Android Maven version pinned in its `native-dependencies.json` by default. For unpublished changes, select `CUTDEX_NATIVE_BUILD_MODE=source` and set `CUTDEX_ANDROID_PATH` to the local native checkout. Calibration
|
|
||||||
requires a `--debug` build; profile/production hosts do not register its channel.
|
|
||||||
UI timing ends at the
|
|
||||||
target workspace's post-frame callback. Native diagnostics record queued output
|
|
||||||
frames/content timestamps and backend seek/reuse counters; those do not measure
|
|
||||||
physical display refresh. The planned drag input rate is 60 Hz; retain actual
|
|
||||||
input timestamps and report achieved input cadence. The test uses `fullyLive`
|
|
||||||
frame scheduling and does not pump a Flutter frame for every pointer input.
|
|
||||||
Native polling has at most
|
|
||||||
one outstanding request, so decoder latency cannot accumulate diagnostic reads.
|
|
||||||
Source PTS is distinct from the requested timeline sample. A stationary release
|
|
||||||
must preserve source PTS, output-frame count and seek count; the final source
|
|
||||||
frame must cover the target tick. These counters measure queued native output,
|
|
||||||
not physical scanout. A cached timeline's nonzero frame counter alone does not
|
|
||||||
prove that its new Surface has displayed the retained frame.
|
|
||||||
Rebuild/install the normal `lib/main.dart` entry point after testing. Do not clear
|
|
||||||
app data or uninstall merely to obtain a cold sample.
|
|
||||||
Always pass `--keep-app-running`: Flutter drive otherwise uninstalls the Android
|
|
||||||
application during cleanup, which also deletes its application data.
|
|
||||||
On devices that deny access to ADB-created external app directories, copy the
|
|
||||||
fixture into the installed debuggable development app's internal files using
|
|
||||||
`run-as`, and export its report with `adb exec-out run-as PACKAGE cat PATH`.
|
|
||||||
|
|
||||||
## Desktop plugin registration
|
## Desktop plugin registration
|
||||||
|
|
||||||
`native_desktop_plugins_test.dart` checks the real application's registration of
|
`native_desktop_plugins_test.dart` checks the real application's registration of
|
||||||
@@ -489,41 +416,3 @@ remove the test's own project and exports afterward.
|
|||||||
Some devices disconnect the host driver while DocumentsUI is foreground. In
|
Some devices disconnect the host driver while DocumentsUI is foreground. In
|
||||||
that case, inspect the original application's log and private JSON reports; a
|
that case, inspect the original application's log and private JSON reports; a
|
||||||
driver disconnection alone does not establish whether the import succeeded.
|
driver disconnection alone does not establish whether the import succeeded.
|
||||||
|
|
||||||
## Android native Surface preview comparison
|
|
||||||
|
|
||||||
The development build can enable the experimental native source with the Gradle
|
|
||||||
property `cutdexNativeSurfacePreview=true` or environment variable
|
|
||||||
`CUTDEX_NATIVE_SURFACE_PREVIEW=true`. Production and default development builds
|
|
||||||
leave it disabled. `android_decoder_material_performance_test.dart` uses the real
|
|
||||||
EditorWorkspace with the whole original clip fitted into the timeline viewport.
|
|
||||||
Set `CUTDEX_TEST_DECODER=media3-surface` to fail if the source falls back; use
|
|
||||||
`ffmpeg` for the paired baseline. `CUTDEX_TEST_PLAYBACK=true` additionally records
|
|
||||||
three seconds of unique frame changes, play/pause acknowledgments and a frozen
|
|
||||||
paused frame. The existing seek/drag assertions independently check every observed
|
|
||||||
frame against original rational packet PTS and require zero extra release seek
|
|
||||||
or presentation for an already precise held picture.
|
|
||||||
|
|
||||||
Use a separate validation application ID to preserve the installed development
|
|
||||||
application and its projects. Supply media and PTS files inside that validation
|
|
||||||
app's sandbox; no personal fixture or benchmark report is committed here.
|
|
||||||
For example, an explicitly admitted 60 fps / 90000 Hz source can be measured with:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
$env:CUTDEX_VALIDATION_APPLICATION_ID = 'com.example.cutdex.decoder_validation'
|
|
||||||
$env:CUTDEX_NATIVE_SURFACE_PREVIEW = 'true'
|
|
||||||
fvm dart tool/flutter_local.dart drive --profile --flavor development -d DEVICE_ID --keep-app-running `
|
|
||||||
--driver=test_driver/integration_test.dart `
|
|
||||||
--target=integration_test/android_decoder_material_performance_test.dart `
|
|
||||||
--dart-define=CUTDEX_TEST_SOURCE=/data/user/0/com.example.cutdex.decoder_validation.dev/files/source.mp4 `
|
|
||||||
--dart-define=CUTDEX_TEST_SOURCE_PTS=/data/user/0/com.example.cutdex.decoder_validation.dev/files/source-pts.txt `
|
|
||||||
--dart-define=CUTDEX_TEST_SOURCE_TIMESCALE=90000 --dart-define=CUTDEX_TEST_FRAME_STEP_US=16667 `
|
|
||||||
--dart-define=CUTDEX_TEST_DECODER=media3-surface --dart-define=CUTDEX_TEST_PLAYBACK=true `
|
|
||||||
--dart-define=CUTDEX_TEST_REPORT=/data/user/0/com.example.cutdex.decoder_validation.dev/files/native-results.json
|
|
||||||
```
|
|
||||||
|
|
||||||
Repeat with `CUTDEX_NATIVE_SURFACE_PREVIEW=false`, `CUTDEX_TEST_DECODER=ffmpeg`
|
|
||||||
and another report path for the software baseline. Restore the default environment
|
|
||||||
and normal application entry point after testing. Record first-source indexing
|
|
||||||
separately from warm seek timings. Only compare inputs with matching source clocks,
|
|
||||||
targets, drag trajectories, audio/UI workloads and achieved input cadence.
|
|
||||||
@@ -1,730 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:cutdex/app/editor_theme.dart';
|
|
||||||
import 'package:cutdex/features/editor/editor_page.dart';
|
|
||||||
import 'package:cutdex/features/preview/preview_panel.dart';
|
|
||||||
import 'package:cutdex/integrations/platform/device_experience.dart';
|
|
||||||
import 'package:cutdex/l10n/app_localizations.dart';
|
|
||||||
import 'package:cutdex/persistence/app_database.dart';
|
|
||||||
import 'package:cutdex/workspace/project_state.dart';
|
|
||||||
import 'package:cutdex/workspace/projects.dart';
|
|
||||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
|
||||||
import 'package:cutdex_core/editor.dart';
|
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
|
||||||
import 'package:cutdex_core/project.dart';
|
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
|
||||||
import 'package:cutdex_core/timeline/layout.dart';
|
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
|
||||||
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
|
|
||||||
import 'package:drift/native.dart';
|
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:integration_test/integration_test.dart';
|
|
||||||
|
|
||||||
import '../test/support/preview_fixture.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
||||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
|
||||||
const source = String.fromEnvironment('CUTDEX_TEST_SOURCE');
|
|
||||||
const output = String.fromEnvironment('CUTDEX_TEST_REPORT');
|
|
||||||
const ptsFile = String.fromEnvironment('CUTDEX_TEST_SOURCE_PTS');
|
|
||||||
const sourceStepUs = int.fromEnvironment('CUTDEX_TEST_FRAME_STEP_US');
|
|
||||||
const sourceTimescale = int.fromEnvironment(
|
|
||||||
'CUTDEX_TEST_SOURCE_TIMESCALE',
|
|
||||||
defaultValue: 1000000,
|
|
||||||
);
|
|
||||||
testWidgets(
|
|
||||||
'Android material decoder production workspace performance',
|
|
||||||
(tester) async {
|
|
||||||
expect(Platform.isAndroid, isTrue);
|
|
||||||
final file = File(source);
|
|
||||||
final before = await file.stat();
|
|
||||||
expect(before.size, greaterThan(0));
|
|
||||||
expect(sourceStepUs, greaterThan(0));
|
|
||||||
expect(sourceTimescale, greaterThan(0));
|
|
||||||
final report = File(output);
|
|
||||||
await report.parent.create(recursive: true);
|
|
||||||
final result = <String, Object?>{
|
|
||||||
'status': 'running',
|
|
||||||
'source': source,
|
|
||||||
'sourceBytes': before.size,
|
|
||||||
'buildMode': const bool.fromEnvironment('dart.vm.product')
|
|
||||||
? 'release'
|
|
||||||
: const bool.fromEnvironment('dart.vm.profile')
|
|
||||||
? 'profile'
|
|
||||||
: 'debug',
|
|
||||||
'scope': 'Production EditorWorkspace, Projects, preview and real touch ruler input; isolated project/database',
|
|
||||||
'measurement': 'Native queued-frame counters and content timestamp, not physical display scanout',
|
|
||||||
'switches': <Map<String, Object?>>[],
|
|
||||||
'seeks': <Map<String, Object?>>[],
|
|
||||||
'drags': <Map<String, Object?>>[],
|
|
||||||
'heldRelease': <Map<String, Object?>>[],
|
|
||||||
};
|
|
||||||
void save() => report.writeAsStringSync(
|
|
||||||
const JsonEncoder.withIndent(' ').convert(result),
|
|
||||||
);
|
|
||||||
save();
|
|
||||||
final runtime = CutdexRuntime();
|
|
||||||
final info = await runtime.probe(
|
|
||||||
MediaReference(id: 'media', uri: file.uri),
|
|
||||||
);
|
|
||||||
result['durationSeconds'] = info.duration.seconds;
|
|
||||||
final sourcePtsTicks = (await File(
|
|
||||||
ptsFile,
|
|
||||||
).readAsLines()).map(int.parse).toList(growable: false);
|
|
||||||
double expectedSourceUs(int numerator, int denominator) {
|
|
||||||
final target = BigInt.from(numerator) * BigInt.from(sourceTimescale);
|
|
||||||
final divisor = BigInt.from(denominator);
|
|
||||||
var low = 0;
|
|
||||||
var high = sourcePtsTicks.length;
|
|
||||||
while (low < high) {
|
|
||||||
final middle = (low + high) ~/ 2;
|
|
||||||
if (BigInt.from(sourcePtsTicks[middle]) * divisor <= target) {
|
|
||||||
low = middle + 1;
|
|
||||||
} else {
|
|
||||||
high = middle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
expectSync(low, greaterThan(0));
|
|
||||||
return sourcePtsTicks[low - 1] * 1000000 / sourceTimescale;
|
|
||||||
}
|
|
||||||
|
|
||||||
result['independentSourcePtsCount'] = sourcePtsTicks.length;
|
|
||||||
result['sourcePtsTimescale'] = sourceTimescale;
|
|
||||||
if (const bool.fromEnvironment('CUTDEX_TEST_CALIBRATE')) {
|
|
||||||
const diagnostics = MethodChannel('cutdex_decoder_diagnostics');
|
|
||||||
const stepUs = sourceStepUs;
|
|
||||||
final calibrated = (await diagnostics.invokeMapMethod<String, dynamic>(
|
|
||||||
'calibrate',
|
|
||||||
{
|
|
||||||
'source': file.uri.toString(),
|
|
||||||
'targetsMicros': [
|
|
||||||
60000000,
|
|
||||||
2000000000,
|
|
||||||
2000000000 + stepUs,
|
|
||||||
2000000000 + stepUs * 2,
|
|
||||||
2000000000 + stepUs,
|
|
||||||
2000000000 + stepUs * 3,
|
|
||||||
120000567,
|
|
||||||
60000000,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
))!;
|
|
||||||
result['calibration'] = calibrated;
|
|
||||||
save();
|
|
||||||
for (final sample in calibrated['samples'] as List) {
|
|
||||||
final requested = sample['requestedTime'] as Map;
|
|
||||||
final actual = sample['actualTime'] as Map;
|
|
||||||
final pts =
|
|
||||||
int.parse('${actual['numerator']}') /
|
|
||||||
(actual['denominator'] as num);
|
|
||||||
expect(
|
|
||||||
(pts * 1000000 -
|
|
||||||
expectedSourceUs(
|
|
||||||
int.parse('${requested['numerator']}'),
|
|
||||||
requested['denominator'] as int,
|
|
||||||
))
|
|
||||||
.abs(),
|
|
||||||
lessThanOrEqualTo(2),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final fixture = await createPreviewFixture(
|
|
||||||
file.uri,
|
|
||||||
hasAudio: info.audioTrackCount > 0,
|
|
||||||
clipDuration: RationalTime(
|
|
||||||
info.duration.numerator,
|
|
||||||
info.duration.denominator,
|
|
||||||
),
|
|
||||||
renderSize: {'width': 1280, 'height': 720},
|
|
||||||
);
|
|
||||||
final document = await fixture.workspace.project!.loadTimeline('project');
|
|
||||||
for (final id in ['cold', 'third']) {
|
|
||||||
await fixture.workspace.project!.saveTimeline(
|
|
||||||
TimelineDocument(
|
|
||||||
id: id,
|
|
||||||
name: id,
|
|
||||||
sequences: document.sequences,
|
|
||||||
defaultSequenceId: document.defaultSequenceId,
|
|
||||||
payloads: document.payloads,
|
|
||||||
settings: document.settings,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await fixture.workspace.close();
|
|
||||||
final database = AppDatabase(NativeDatabase.memory());
|
|
||||||
final container = ProviderContainer(
|
|
||||||
overrides: [appDatabaseProvider.overrideWithValue(database)],
|
|
||||||
);
|
|
||||||
final projects = container.read(projectsProvider.notifier);
|
|
||||||
Future<void> until(
|
|
||||||
bool Function() ready,
|
|
||||||
String label, {
|
|
||||||
int seconds = 60,
|
|
||||||
}) async {
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
while (!ready()) {
|
|
||||||
if (clock.elapsed.inSeconds >= seconds) throw TimeoutException(label);
|
|
||||||
await tester.pump();
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
|
||||||
}
|
|
||||||
await tester.pump();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> advance(int milliseconds) async {
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
while (clock.elapsedMilliseconds < milliseconds) {
|
|
||||||
await tester.pump();
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PreviewController? activePreview() {
|
|
||||||
final state = container.read(projectsProvider).value;
|
|
||||||
if (state?.timeline == null || state!.openingTimelineId != null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return container
|
|
||||||
.read(
|
|
||||||
editorPreviewProvider(
|
|
||||||
state.activeProject!.id,
|
|
||||||
state.timeline!.id,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const nativeChannel = MethodChannel('cutdex_runtime');
|
|
||||||
const configuredDecoder = String.fromEnvironment('CUTDEX_TEST_DECODER');
|
|
||||||
final calibration = result['calibration'] as Map?;
|
|
||||||
final expectedDecoder = configuredDecoder.isNotEmpty
|
|
||||||
? configuredDecoder
|
|
||||||
: calibration == null
|
|
||||||
? ''
|
|
||||||
: calibration['backend'] == 'NATIVE'
|
|
||||||
? 'mediaCodec'
|
|
||||||
: 'ffmpeg';
|
|
||||||
Future<Map<String, dynamic>> diagnostic(PreviewController preview) async {
|
|
||||||
final value = (await nativeChannel.invokeMapMethod<String, dynamic>(
|
|
||||||
'previewDiagnostics',
|
|
||||||
{'contractVersion': 1, 'sessionId': preview.session!.id},
|
|
||||||
))!;
|
|
||||||
if (expectedDecoder.isNotEmpty) {
|
|
||||||
final backends = value['decoderBackends'] as Map?;
|
|
||||||
// Diagnostics also run from a timer while WidgetTester.pump is active.
|
|
||||||
expectSync(value['executionBackend'], 'direct');
|
|
||||||
expectSync(backends, isNotEmpty);
|
|
||||||
expectSync(backends!.values, everyElement(expectedDecoder));
|
|
||||||
expectSync(value['decoderSelectionReasons'], isNotEmpty);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int frames(Map<String, dynamic> value) =>
|
|
||||||
int.tryParse('${value['presentedVideoFrameCount']}') ?? 0;
|
|
||||||
double sourcePts(Map<String, dynamic> value) {
|
|
||||||
final time = value['presentedSourceFrameTime'] as Map?;
|
|
||||||
expect(time, isNotNull, reason: 'Actual source PTS must be available');
|
|
||||||
return int.parse('${time!['numerator']}') /
|
|
||||||
(time['denominator'] as num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void expectExactSource(Map<String, dynamic> value, int tick) {
|
|
||||||
final pts = sourcePts(value);
|
|
||||||
expect(
|
|
||||||
(pts * 1000000 - expectedSourceUs(tick, TimelineClock.ticksPerSecond))
|
|
||||||
.abs(),
|
|
||||||
lessThanOrEqualTo(2),
|
|
||||||
reason: 'Independent packet PTS must identify the exact source frame',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await SystemChrome.setPreferredOrientations([
|
|
||||||
DeviceOrientation.landscapeLeft,
|
|
||||||
]);
|
|
||||||
expect(
|
|
||||||
await projects.open(
|
|
||||||
'${fixture.directory.path}/Preview.cutdex',
|
|
||||||
timelineId: 'project',
|
|
||||||
),
|
|
||||||
isTrue,
|
|
||||||
);
|
|
||||||
await tester.pumpWidget(
|
|
||||||
UncontrolledProviderScope(
|
|
||||||
container: container,
|
|
||||||
child: MaterialApp(
|
|
||||||
theme: EditorTheme.penDark,
|
|
||||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
||||||
supportedLocales: AppLocalizations.supportedLocales,
|
|
||||||
locale: const Locale('zh'),
|
|
||||||
home: const Scaffold(body: _Workspace()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await until(
|
|
||||||
() =>
|
|
||||||
activePreview()?.ready == true &&
|
|
||||||
activePreview()?.session != null,
|
|
||||||
'initial preview ready',
|
|
||||||
);
|
|
||||||
await until(
|
|
||||||
() =>
|
|
||||||
(activePreview()!.session!.snapshot?.presentedVideoFrameCount ??
|
|
||||||
0) >
|
|
||||||
0,
|
|
||||||
'initial native frame',
|
|
||||||
);
|
|
||||||
expect(activePreview()!.error, isNull);
|
|
||||||
result['initialNative'] = await diagnostic(activePreview()!);
|
|
||||||
save();
|
|
||||||
final projectId = container
|
|
||||||
.read(projectsProvider)
|
|
||||||
.requireValue
|
|
||||||
.activeProject!
|
|
||||||
.id;
|
|
||||||
final switches = result['switches']! as List<Map<String, Object?>>;
|
|
||||||
Future<void> switchTo(String id, String name) async {
|
|
||||||
final workspaceElement = find
|
|
||||||
.byType(EditorWorkspace)
|
|
||||||
.evaluate()
|
|
||||||
.single;
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
double? dataMs, uiMs;
|
|
||||||
final startupTrace = <Map<String, Object?>>[];
|
|
||||||
final traceTimer = Timer.periodic(const Duration(milliseconds: 100), (
|
|
||||||
_,
|
|
||||||
) {
|
|
||||||
final controller = activePreview();
|
|
||||||
final views = find.byType(RuntimePreview).evaluate();
|
|
||||||
final row = <String, Object?>{
|
|
||||||
'ms': clock.elapsedMicroseconds / 1000,
|
|
||||||
'pending': container
|
|
||||||
.read(projectsProvider)
|
|
||||||
.value
|
|
||||||
?.openingTimelineId,
|
|
||||||
'controller': controller != null,
|
|
||||||
'ready': controller?.ready,
|
|
||||||
'durationTick': controller?.durationTick,
|
|
||||||
'session': controller?.session?.id,
|
|
||||||
'views': views
|
|
||||||
.map((e) => (e.widget as RuntimePreview).session.id)
|
|
||||||
.toList(),
|
|
||||||
};
|
|
||||||
startupTrace.add(row);
|
|
||||||
});
|
|
||||||
final subscription = container.listen(projectsProvider, (_, next) {
|
|
||||||
if (next.value?.timeline?.id == id &&
|
|
||||||
next.value?.openingTimelineId == null) {
|
|
||||||
dataMs ??= clock.elapsedMicroseconds / 1000;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
void observeFrame(Duration _) {
|
|
||||||
final workspace = workspaceElement.widget as EditorWorkspace;
|
|
||||||
if (workspace.timelineId == id) {
|
|
||||||
uiMs ??= clock.elapsedMicroseconds / 1000;
|
|
||||||
}
|
|
||||||
if (uiMs == null && clock.elapsedMilliseconds < 60000) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback(observeFrame);
|
|
||||||
WidgetsBinding.instance.scheduleFrame();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback(observeFrame);
|
|
||||||
try {
|
|
||||||
await tester.tap(find.byKey(ValueKey('timeline-tab-$id')));
|
|
||||||
await until(() => uiMs != null, 'selected UI $id');
|
|
||||||
await until(
|
|
||||||
() =>
|
|
||||||
dataMs != null &&
|
|
||||||
activePreview()?.ready == true &&
|
|
||||||
activePreview()?.session != null,
|
|
||||||
'metadata/preview $id',
|
|
||||||
);
|
|
||||||
result['switchBeforeFirstFrame'] = {
|
|
||||||
'timelineId': id,
|
|
||||||
'native': await diagnostic(activePreview()!),
|
|
||||||
};
|
|
||||||
save();
|
|
||||||
await until(
|
|
||||||
() =>
|
|
||||||
(activePreview()!
|
|
||||||
.session!
|
|
||||||
.snapshot
|
|
||||||
?.presentedVideoFrameCount ??
|
|
||||||
0) >
|
|
||||||
0,
|
|
||||||
'native frame $id',
|
|
||||||
);
|
|
||||||
switches.add({
|
|
||||||
'scenario': name,
|
|
||||||
'uiPostFrameMs': uiMs,
|
|
||||||
'dataMs': dataMs,
|
|
||||||
'nativeFrameObservedMs': clock.elapsedMicroseconds / 1000,
|
|
||||||
'startupTrace': startupTrace,
|
|
||||||
});
|
|
||||||
expect(activePreview()!.error, isNull);
|
|
||||||
save();
|
|
||||||
} finally {
|
|
||||||
traceTimer.cancel();
|
|
||||||
subscription.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await switchTo('cold', 'cold');
|
|
||||||
for (var i = 0; i < 3; i++) {
|
|
||||||
await switchTo('project', 'warm-return-$i');
|
|
||||||
await switchTo('cold', 'warm-target-$i');
|
|
||||||
}
|
|
||||||
final rapid = <String>[];
|
|
||||||
final rapidSub = container.listen(projectsProvider, (_, next) {
|
|
||||||
if (next.value?.visibleTimelineId case final id?) rapid.add(id);
|
|
||||||
});
|
|
||||||
for (final id in ['third', 'project', 'cold', 'project', 'cold']) {
|
|
||||||
await tester.tap(find.byKey(ValueKey('timeline-tab-$id')));
|
|
||||||
await tester.pump();
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
|
||||||
expect(
|
|
||||||
container.read(projectsProvider).requireValue.visibleTimelineId,
|
|
||||||
id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await advance(1000);
|
|
||||||
rapidSub.close();
|
|
||||||
expect(
|
|
||||||
container.read(projectsProvider).requireValue.timeline!.id,
|
|
||||||
'cold',
|
|
||||||
);
|
|
||||||
result['rapidSelection'] = rapid;
|
|
||||||
await until(
|
|
||||||
() => activePreview()?.ready == true,
|
|
||||||
'preview after rapid selection',
|
|
||||||
);
|
|
||||||
final preview = activePreview()!;
|
|
||||||
final session = await container.read(
|
|
||||||
editorTimelineProvider(projectId, 'cold').future,
|
|
||||||
);
|
|
||||||
final sequence = session.activeSequenceId!;
|
|
||||||
final view = session.view(sequence);
|
|
||||||
Future<void> seek(int frame) => preview.controlPreview(
|
|
||||||
sequence,
|
|
||||||
PreviewAction.seek,
|
|
||||||
at: CommandTime(frame, 30),
|
|
||||||
);
|
|
||||||
final matchedSeeks = <Map<String, Object?>>[];
|
|
||||||
result['matchedSeeks'] = matchedSeeks;
|
|
||||||
for (final targetUs in [
|
|
||||||
60000000,
|
|
||||||
2000000000,
|
|
||||||
2000000000 + sourceStepUs,
|
|
||||||
2000000000 + sourceStepUs * 2,
|
|
||||||
2000000000 + sourceStepUs,
|
|
||||||
2000000000 + sourceStepUs * 3,
|
|
||||||
120000567,
|
|
||||||
60000000,
|
|
||||||
]) {
|
|
||||||
final timer = Stopwatch()..start();
|
|
||||||
await preview.session!.seek(MediaTime(targetUs, 1000000));
|
|
||||||
timer.stop();
|
|
||||||
final value = await diagnostic(preview);
|
|
||||||
matchedSeeks.add({
|
|
||||||
'targetUs': targetUs,
|
|
||||||
'latencyMs': timer.elapsedMicroseconds / 1000,
|
|
||||||
'sourcePtsUs': sourcePts(value) * 1000000,
|
|
||||||
'diagnostics': value,
|
|
||||||
});
|
|
||||||
save();
|
|
||||||
expect(
|
|
||||||
(sourcePts(value) * 1000000 - expectedSourceUs(targetUs, 1000000))
|
|
||||||
.abs(),
|
|
||||||
lessThanOrEqualTo(2),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final seeks = result['seeks']! as List<Map<String, Object?>>;
|
|
||||||
for (final frame in [1800, 60000, 60001, 60002, 60001]) {
|
|
||||||
final before = await diagnostic(preview);
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
await seek(frame);
|
|
||||||
final after = await diagnostic(preview);
|
|
||||||
seeks.add({
|
|
||||||
'frame': frame,
|
|
||||||
'acknowledgmentMs': clock.elapsedMicroseconds / 1000,
|
|
||||||
'frames': frames(after) - frames(before),
|
|
||||||
'native': after,
|
|
||||||
});
|
|
||||||
expect(preview.error, isNull);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
final drags = result['drags']! as List<Map<String, Object?>>;
|
|
||||||
for (var round = 0; round < 2; round++) {
|
|
||||||
for (final local in [false, true]) {
|
|
||||||
view.fitTimeline();
|
|
||||||
await advance(200);
|
|
||||||
final rulerFinder = find.byType(TimelineRuler);
|
|
||||||
final ruler = tester.renderObject<RenderBox>(rulerFinder);
|
|
||||||
final viewport = TimelineViewportRect(
|
|
||||||
width: ruler.size.width,
|
|
||||||
height: ruler.size.height,
|
|
||||||
);
|
|
||||||
final durationFrames = (info.duration.seconds * 30).floor();
|
|
||||||
if (local) {
|
|
||||||
view.setCamera(
|
|
||||||
TimelineCamera(
|
|
||||||
baseTick: TimelineClock.standard.toTicks(
|
|
||||||
RationalTime(59980, 30),
|
|
||||||
),
|
|
||||||
pixelsPerTick:
|
|
||||||
4 / TimelineClock.standard.toTicks(RationalTime(1, 30)),
|
|
||||||
verticalOffset: view.camera.verticalOffset,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await advance(100);
|
|
||||||
}
|
|
||||||
Offset position(int frame) => ruler.localToGlobal(
|
|
||||||
Offset(
|
|
||||||
view.camera.screenXForTick(
|
|
||||||
TimelineClock.standard.toTicks(RationalTime(frame, 30)),
|
|
||||||
viewport,
|
|
||||||
),
|
|
||||||
ruler.size.height / 2,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final startFrame = local ? 60000 : (durationFrames * .05).round();
|
|
||||||
await seek(startFrame);
|
|
||||||
await advance(150);
|
|
||||||
var initial = await diagnostic(preview);
|
|
||||||
final observations = <Map<String, Object?>>[];
|
|
||||||
final inputs = <Map<String, Object?>>[];
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
Future<void>? pending;
|
|
||||||
Object? sampleError;
|
|
||||||
void sample() {
|
|
||||||
if (pending != null) return;
|
|
||||||
pending = diagnostic(preview)
|
|
||||||
.then((d) {
|
|
||||||
observations.add({
|
|
||||||
'ms': clock.elapsedMicroseconds / 1000,
|
|
||||||
...d,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catchError((Object e) {
|
|
||||||
sampleError = e;
|
|
||||||
})
|
|
||||||
.whenComplete(() => pending = null);
|
|
||||||
}
|
|
||||||
|
|
||||||
final gesture = await tester.startGesture(
|
|
||||||
position(startFrame),
|
|
||||||
kind: PointerDeviceKind.touch,
|
|
||||||
);
|
|
||||||
// Acquire the real ruler's drag recognizer before measuring movement.
|
|
||||||
await gesture.moveBy(const Offset(30, 0));
|
|
||||||
await tester.pump();
|
|
||||||
expect(view.isScrubbing, isTrue);
|
|
||||||
await gesture.moveTo(position(startFrame));
|
|
||||||
await advance(350);
|
|
||||||
initial = await diagnostic(preview);
|
|
||||||
clock.reset();
|
|
||||||
final timer = Timer.periodic(
|
|
||||||
const Duration(milliseconds: 20),
|
|
||||||
(_) => sample(),
|
|
||||||
);
|
|
||||||
for (var i = 0; i < 120; i++) {
|
|
||||||
final dueUs = (i * 1000000 / 60).round();
|
|
||||||
final remaining = dueUs - clock.elapsedMicroseconds;
|
|
||||||
if (remaining > 0) {
|
|
||||||
await Future<void>.delayed(Duration(microseconds: remaining));
|
|
||||||
}
|
|
||||||
final phase = i < 60 ? i : 119 - i;
|
|
||||||
final target = local
|
|
||||||
? 60000 + (i % 40 < 20 ? i % 40 : 39 - i % 40)
|
|
||||||
: (durationFrames * (.05 + .9 * phase / 59)).round();
|
|
||||||
await gesture.moveTo(position(target));
|
|
||||||
inputs.add({
|
|
||||||
'ms': clock.elapsedMicroseconds / 1000,
|
|
||||||
'dueMs': dueUs / 1000,
|
|
||||||
'idealFrame': target,
|
|
||||||
'actualTick': view.playheadTick,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
final releaseAt = clock.elapsedMicroseconds / 1000;
|
|
||||||
final finalTick = view.playheadTick;
|
|
||||||
await gesture.up();
|
|
||||||
await tester.pump();
|
|
||||||
await preview.waitForPendingPreview().timeout(
|
|
||||||
const Duration(seconds: 60),
|
|
||||||
);
|
|
||||||
final settled = await diagnostic(preview);
|
|
||||||
final settledMs = clock.elapsedMicroseconds / 1000;
|
|
||||||
await advance(500);
|
|
||||||
final frozen = await diagnostic(preview);
|
|
||||||
timer.cancel();
|
|
||||||
await pending;
|
|
||||||
expect(sampleError, isNull);
|
|
||||||
expect(preview.error, isNull);
|
|
||||||
final snapshot = await preview.session!.refresh();
|
|
||||||
final clockTick =
|
|
||||||
(BigInt.from(snapshot.position.numerator) *
|
|
||||||
BigInt.from(TimelineClock.ticksPerSecond) ~/
|
|
||||||
BigInt.from(snapshot.position.denominator))
|
|
||||||
.toInt();
|
|
||||||
expectExactSource(settled, finalTick);
|
|
||||||
expect(
|
|
||||||
(clockTick - finalTick).abs(),
|
|
||||||
lessThanOrEqualTo(TimelineClock.ticksPerSecond ~/ 1000000),
|
|
||||||
);
|
|
||||||
drags.add({
|
|
||||||
'round': round,
|
|
||||||
'scenario': local ? 'local-20-frame' : 'fit-entire-source',
|
|
||||||
'viewportWidth': ruler.size.width,
|
|
||||||
'inputs': inputs,
|
|
||||||
'observations': observations,
|
|
||||||
'before': initial,
|
|
||||||
'settled': settled,
|
|
||||||
'frozen': frozen,
|
|
||||||
'releaseAtMs': releaseAt,
|
|
||||||
'settledAtMs': settledMs,
|
|
||||||
'releaseWaitMs': settledMs - releaseAt,
|
|
||||||
'finalTick': finalTick,
|
|
||||||
'clockTick': clockTick,
|
|
||||||
'postSettleFrames': frames(frozen) - frames(settled),
|
|
||||||
});
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final ruler = tester.renderObject<RenderBox>(
|
|
||||||
find.byType(TimelineRuler),
|
|
||||||
);
|
|
||||||
final viewport = TimelineViewportRect(
|
|
||||||
width: ruler.size.width,
|
|
||||||
height: ruler.size.height,
|
|
||||||
);
|
|
||||||
Offset heldPosition(int frame) => ruler.localToGlobal(
|
|
||||||
Offset(
|
|
||||||
view.camera.screenXForTick(
|
|
||||||
TimelineClock.standard.toTicks(RationalTime(frame, 30)),
|
|
||||||
viewport,
|
|
||||||
),
|
|
||||||
ruler.size.height / 2,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await seek(60000);
|
|
||||||
final hold = await tester.startGesture(
|
|
||||||
heldPosition(60000),
|
|
||||||
kind: PointerDeviceKind.touch,
|
|
||||||
);
|
|
||||||
await hold.moveBy(const Offset(30, 0));
|
|
||||||
await tester.pump();
|
|
||||||
await hold.moveTo(heldPosition(60010));
|
|
||||||
await advance(1000);
|
|
||||||
final heldTick = view.playheadTick;
|
|
||||||
final heldBefore = await diagnostic(preview);
|
|
||||||
final releaseClock = Stopwatch()..start();
|
|
||||||
await hold.up();
|
|
||||||
await tester.pump();
|
|
||||||
await preview.waitForPendingPreview().timeout(
|
|
||||||
const Duration(seconds: 60),
|
|
||||||
);
|
|
||||||
final heldAfter = await diagnostic(preview);
|
|
||||||
final heldReleaseMs = releaseClock.elapsedMicroseconds / 1000;
|
|
||||||
await advance(500);
|
|
||||||
final heldFrozen = await diagnostic(preview);
|
|
||||||
(result['heldRelease']! as List<Map<String, Object?>>).add({
|
|
||||||
'holdMilliseconds': 1000,
|
|
||||||
'targetTick': heldTick,
|
|
||||||
'before': heldBefore,
|
|
||||||
'after': heldAfter,
|
|
||||||
'frozen': heldFrozen,
|
|
||||||
'releaseWaitMs': heldReleaseMs,
|
|
||||||
});
|
|
||||||
save();
|
|
||||||
expectExactSource(heldBefore, heldTick);
|
|
||||||
expectExactSource(heldAfter, heldTick);
|
|
||||||
expect(sourcePts(heldAfter), sourcePts(heldBefore));
|
|
||||||
expect(frames(heldAfter), frames(heldBefore));
|
|
||||||
expect(heldAfter['seekRequestCount'], heldBefore['seekRequestCount']);
|
|
||||||
expect(frames(heldFrozen), frames(heldAfter));
|
|
||||||
if (const bool.fromEnvironment('CUTDEX_TEST_PLAYBACK')) {
|
|
||||||
await preview.session!.seek(MediaTime(60000000, 1000000));
|
|
||||||
final beforePlay = await diagnostic(preview);
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
await preview.session!.play();
|
|
||||||
final playAckMs = clock.elapsedMicroseconds / 1000;
|
|
||||||
await advance(3000);
|
|
||||||
final pauseClock = Stopwatch()..start();
|
|
||||||
await preview.session!.pause();
|
|
||||||
final pauseAckMs = pauseClock.elapsedMicroseconds / 1000;
|
|
||||||
final paused = await diagnostic(preview);
|
|
||||||
clock.stop();
|
|
||||||
await advance(250);
|
|
||||||
final frozen = await diagnostic(preview);
|
|
||||||
int unique(Map<String, dynamic> value) =>
|
|
||||||
int.parse('${value['uniquePresentedVideoFrameCount']}');
|
|
||||||
result['playback'] = {
|
|
||||||
'before': beforePlay,
|
|
||||||
'paused': paused,
|
|
||||||
'frozen': frozen,
|
|
||||||
'playAcknowledgmentMs': playAckMs,
|
|
||||||
'pauseAcknowledgmentMs': pauseAckMs,
|
|
||||||
'elapsedMs': clock.elapsedMicroseconds / 1000,
|
|
||||||
'uniqueFrameChanges': unique(paused) - unique(beforePlay),
|
|
||||||
'uniqueFramesPerSecond':
|
|
||||||
(unique(paused) - unique(beforePlay)) *
|
|
||||||
1000000 /
|
|
||||||
clock.elapsedMicroseconds,
|
|
||||||
};
|
|
||||||
save();
|
|
||||||
expect(unique(paused) - unique(beforePlay), greaterThan(30));
|
|
||||||
expect(frames(frozen), frames(paused));
|
|
||||||
expect(sourcePts(frozen), sourcePts(paused));
|
|
||||||
expect(paused['playbackError'], isNull);
|
|
||||||
}
|
|
||||||
expect(tester.takeException(), isNull);
|
|
||||||
final after = await file.stat();
|
|
||||||
expect(after.size, before.size);
|
|
||||||
expect(after.modified, before.modified);
|
|
||||||
result['status'] = 'passed';
|
|
||||||
result['sourceUnchanged'] = true;
|
|
||||||
save();
|
|
||||||
} catch (error, stack) {
|
|
||||||
result['status'] = 'failed';
|
|
||||||
result['error'] = '$error';
|
|
||||||
result['stack'] = '$stack';
|
|
||||||
save();
|
|
||||||
rethrow;
|
|
||||||
} finally {
|
|
||||||
await tester.pumpWidget(const SizedBox.shrink());
|
|
||||||
container.dispose();
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 300));
|
|
||||||
await database.close();
|
|
||||||
await SystemChrome.setPreferredOrientations([]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
skip: source.isEmpty || output.isEmpty,
|
|
||||||
timeout: const Timeout(Duration(minutes: 15)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
class _Workspace extends ConsumerWidget {
|
|
||||||
const _Workspace();
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final state = ref.watch(projectsProvider).requireValue;
|
|
||||||
return EditorWorkspace(
|
|
||||||
projectId: state.activeProject!.id,
|
|
||||||
projectName: state.activeProject!.name,
|
|
||||||
timelineId: state.visibleTimelineId!,
|
|
||||||
projectLoading: state.projectBusy,
|
|
||||||
timelineLoading: state.openingTimelineId != null,
|
|
||||||
integratedTitlebar: false,
|
|
||||||
headerLeading: const SizedBox.shrink(),
|
|
||||||
experience: DeviceExperience.tablet,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,8 +7,8 @@ import 'package:cutdex/workspace/external_media_import.dart';
|
|||||||
import 'package:cutdex/workspace/media_import.dart';
|
import 'package:cutdex/workspace/media_import.dart';
|
||||||
import 'package:cutdex/workspace/persistence/project_workspace.dart';
|
import 'package:cutdex/workspace/persistence/project_workspace.dart';
|
||||||
import 'package:cutdex/workspace/persistence/timeline_creation_names.dart';
|
import 'package:cutdex/workspace/persistence/timeline_creation_names.dart';
|
||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
|||||||
@@ -1,589 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:cutdex/app/editor_theme.dart';
|
|
||||||
import 'package:cutdex/features/editor/editor_page.dart';
|
|
||||||
import 'package:cutdex/features/preview/preview_panel.dart';
|
|
||||||
import 'package:cutdex/integrations/platform/device_experience.dart';
|
|
||||||
import 'package:cutdex/l10n/app_localizations.dart';
|
|
||||||
import 'package:cutdex/persistence/app_database.dart';
|
|
||||||
import 'package:cutdex/workspace/project_state.dart';
|
|
||||||
import 'package:cutdex/workspace/projects.dart';
|
|
||||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
|
||||||
import 'package:cutdex_core/editor.dart';
|
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
|
||||||
import 'package:cutdex_core/project.dart';
|
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
|
||||||
import 'package:cutdex_core/timeline/layout.dart';
|
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
|
||||||
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
|
|
||||||
import 'package:drift/native.dart';
|
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:integration_test/integration_test.dart';
|
|
||||||
|
|
||||||
import '../test/support/preview_fixture.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
||||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
|
||||||
const source = String.fromEnvironment('CUTDEX_TEST_SOURCE');
|
|
||||||
const output = String.fromEnvironment('CUTDEX_TEST_REPORT');
|
|
||||||
testWidgets(
|
|
||||||
'Android production workspace navigation and exact-stop timing',
|
|
||||||
(tester) async {
|
|
||||||
expect(Platform.isAndroid, isTrue);
|
|
||||||
final file = File(source);
|
|
||||||
final before = await file.stat();
|
|
||||||
expect(before.size, greaterThan(0));
|
|
||||||
final report = File(output);
|
|
||||||
await report.parent.create(recursive: true);
|
|
||||||
final result = <String, Object?>{
|
|
||||||
'status': 'running',
|
|
||||||
'source': source,
|
|
||||||
'sourceBytes': before.size,
|
|
||||||
'buildMode': const bool.fromEnvironment('dart.vm.product')
|
|
||||||
? 'release'
|
|
||||||
: const bool.fromEnvironment('dart.vm.profile')
|
|
||||||
? 'profile'
|
|
||||||
: 'debug',
|
|
||||||
'scope': 'Production EditorWorkspace, Projects, preview and real touch ruler input; isolated project/database',
|
|
||||||
'measurement': 'Native queued-frame counters and content timestamp, not physical display scanout',
|
|
||||||
'switches': <Map<String, Object?>>[],
|
|
||||||
'seeks': <Map<String, Object?>>[],
|
|
||||||
'drags': <Map<String, Object?>>[],
|
|
||||||
'heldRelease': <Map<String, Object?>>[],
|
|
||||||
};
|
|
||||||
void save() => report.writeAsStringSync(
|
|
||||||
const JsonEncoder.withIndent(' ').convert(result),
|
|
||||||
);
|
|
||||||
save();
|
|
||||||
final runtime = CutdexRuntime();
|
|
||||||
final info = await runtime.probe(
|
|
||||||
MediaReference(id: 'media', uri: file.uri),
|
|
||||||
);
|
|
||||||
result['durationSeconds'] = info.duration.seconds;
|
|
||||||
final fixture = await createPreviewFixture(
|
|
||||||
file.uri,
|
|
||||||
hasAudio: info.audioTrackCount > 0,
|
|
||||||
clipDuration: RationalTime(
|
|
||||||
info.duration.numerator,
|
|
||||||
info.duration.denominator,
|
|
||||||
),
|
|
||||||
renderSize: {'width': 1280, 'height': 720},
|
|
||||||
);
|
|
||||||
final document = await fixture.workspace.project!.loadTimeline('project');
|
|
||||||
for (final id in ['cold', 'third']) {
|
|
||||||
await fixture.workspace.project!.saveTimeline(
|
|
||||||
TimelineDocument(
|
|
||||||
id: id,
|
|
||||||
name: id,
|
|
||||||
sequences: document.sequences,
|
|
||||||
defaultSequenceId: document.defaultSequenceId,
|
|
||||||
payloads: document.payloads,
|
|
||||||
settings: document.settings,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await fixture.workspace.close();
|
|
||||||
final database = AppDatabase(NativeDatabase.memory());
|
|
||||||
final container = ProviderContainer(
|
|
||||||
overrides: [appDatabaseProvider.overrideWithValue(database)],
|
|
||||||
);
|
|
||||||
final projects = container.read(projectsProvider.notifier);
|
|
||||||
Future<void> until(
|
|
||||||
bool Function() ready,
|
|
||||||
String label, {
|
|
||||||
int seconds = 60,
|
|
||||||
}) async {
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
while (!ready()) {
|
|
||||||
if (clock.elapsed.inSeconds >= seconds) throw TimeoutException(label);
|
|
||||||
await tester.pump();
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
|
||||||
}
|
|
||||||
await tester.pump();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> advance(int milliseconds) async {
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
while (clock.elapsedMilliseconds < milliseconds) {
|
|
||||||
await tester.pump();
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PreviewController? activePreview() {
|
|
||||||
final state = container.read(projectsProvider).value;
|
|
||||||
if (state?.timeline == null || state!.openingTimelineId != null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return container
|
|
||||||
.read(
|
|
||||||
editorPreviewProvider(
|
|
||||||
state.activeProject!.id,
|
|
||||||
state.timeline!.id,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const nativeChannel = MethodChannel('cutdex_runtime');
|
|
||||||
const expectedDecoder = String.fromEnvironment('CUTDEX_TEST_DECODER');
|
|
||||||
Future<Map<String, dynamic>> diagnostic(PreviewController preview) async {
|
|
||||||
final value = (await nativeChannel.invokeMapMethod<String, dynamic>(
|
|
||||||
'previewDiagnostics',
|
|
||||||
{'contractVersion': 1, 'sessionId': preview.session!.id},
|
|
||||||
))!;
|
|
||||||
if (expectedDecoder.isNotEmpty) {
|
|
||||||
final backends = value['decoderBackends'] as Map?;
|
|
||||||
// Diagnostics also run from a timer while WidgetTester.pump is active.
|
|
||||||
expectSync(value['executionBackend'], 'direct');
|
|
||||||
expectSync(backends, isNotEmpty);
|
|
||||||
expectSync(backends!.values, everyElement(expectedDecoder));
|
|
||||||
expectSync(value['decoderSelectionReasons'], isNotEmpty);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int frames(Map<String, dynamic> value) =>
|
|
||||||
int.tryParse('${value['presentedVideoFrameCount']}') ?? 0;
|
|
||||||
double sourcePts(Map<String, dynamic> value) {
|
|
||||||
final time = value['presentedSourceFrameTime'] as Map?;
|
|
||||||
expect(time, isNotNull, reason: 'Actual source PTS must be available');
|
|
||||||
return int.parse('${time!['numerator']}') /
|
|
||||||
(time['denominator'] as num);
|
|
||||||
}
|
|
||||||
|
|
||||||
void expectExactSource(Map<String, dynamic> value, int tick) {
|
|
||||||
final target = tick / TimelineClock.ticksPerSecond;
|
|
||||||
final pts = sourcePts(value);
|
|
||||||
// This original is untrimmed CFR 2997/100, so the preceding source
|
|
||||||
// frame owns this sample. Allow only microsecond timestamp precision.
|
|
||||||
expect(pts, lessThanOrEqualTo(target + 0.000002));
|
|
||||||
expect(target - pts, lessThan(100 / 2997 + 0.000002));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await SystemChrome.setPreferredOrientations([
|
|
||||||
DeviceOrientation.landscapeLeft,
|
|
||||||
]);
|
|
||||||
expect(
|
|
||||||
await projects.open(
|
|
||||||
'${fixture.directory.path}/Preview.cutdex',
|
|
||||||
timelineId: 'project',
|
|
||||||
),
|
|
||||||
isTrue,
|
|
||||||
);
|
|
||||||
await tester.pumpWidget(
|
|
||||||
UncontrolledProviderScope(
|
|
||||||
container: container,
|
|
||||||
child: MaterialApp(
|
|
||||||
theme: EditorTheme.penDark,
|
|
||||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
||||||
supportedLocales: AppLocalizations.supportedLocales,
|
|
||||||
locale: const Locale('zh'),
|
|
||||||
home: const Scaffold(body: _Workspace()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await until(
|
|
||||||
() =>
|
|
||||||
activePreview()?.ready == true &&
|
|
||||||
activePreview()?.session != null,
|
|
||||||
'initial preview ready',
|
|
||||||
);
|
|
||||||
await until(
|
|
||||||
() =>
|
|
||||||
(activePreview()!.session!.snapshot?.presentedVideoFrameCount ??
|
|
||||||
0) >
|
|
||||||
0,
|
|
||||||
'initial native frame',
|
|
||||||
);
|
|
||||||
expect(activePreview()!.error, isNull);
|
|
||||||
result['initialNative'] = await diagnostic(activePreview()!);
|
|
||||||
save();
|
|
||||||
final projectId = container
|
|
||||||
.read(projectsProvider)
|
|
||||||
.requireValue
|
|
||||||
.activeProject!
|
|
||||||
.id;
|
|
||||||
final switches = result['switches']! as List<Map<String, Object?>>;
|
|
||||||
Future<void> switchTo(String id, String name) async {
|
|
||||||
final workspaceElement = find
|
|
||||||
.byType(EditorWorkspace)
|
|
||||||
.evaluate()
|
|
||||||
.single;
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
double? dataMs, uiMs;
|
|
||||||
final startupTrace = <Map<String, Object?>>[];
|
|
||||||
final traceTimer = Timer.periodic(const Duration(milliseconds: 100), (
|
|
||||||
_,
|
|
||||||
) {
|
|
||||||
final controller = activePreview();
|
|
||||||
final views = find.byType(RuntimePreview).evaluate();
|
|
||||||
final row = <String, Object?>{
|
|
||||||
'ms': clock.elapsedMicroseconds / 1000,
|
|
||||||
'pending': container
|
|
||||||
.read(projectsProvider)
|
|
||||||
.value
|
|
||||||
?.openingTimelineId,
|
|
||||||
'controller': controller != null,
|
|
||||||
'ready': controller?.ready,
|
|
||||||
'durationTick': controller?.durationTick,
|
|
||||||
'session': controller?.session?.id,
|
|
||||||
'views': views
|
|
||||||
.map((e) => (e.widget as RuntimePreview).session.id)
|
|
||||||
.toList(),
|
|
||||||
};
|
|
||||||
startupTrace.add(row);
|
|
||||||
});
|
|
||||||
final subscription = container.listen(projectsProvider, (_, next) {
|
|
||||||
if (next.value?.timeline?.id == id &&
|
|
||||||
next.value?.openingTimelineId == null) {
|
|
||||||
dataMs ??= clock.elapsedMicroseconds / 1000;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
void observeFrame(Duration _) {
|
|
||||||
final workspace = workspaceElement.widget as EditorWorkspace;
|
|
||||||
if (workspace.timelineId == id) {
|
|
||||||
uiMs ??= clock.elapsedMicroseconds / 1000;
|
|
||||||
}
|
|
||||||
if (uiMs == null && clock.elapsedMilliseconds < 60000) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback(observeFrame);
|
|
||||||
WidgetsBinding.instance.scheduleFrame();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback(observeFrame);
|
|
||||||
try {
|
|
||||||
await tester.tap(find.byKey(ValueKey('timeline-tab-$id')));
|
|
||||||
await until(() => uiMs != null, 'selected UI $id');
|
|
||||||
await until(
|
|
||||||
() =>
|
|
||||||
dataMs != null &&
|
|
||||||
activePreview()?.ready == true &&
|
|
||||||
activePreview()?.session != null,
|
|
||||||
'metadata/preview $id',
|
|
||||||
);
|
|
||||||
result['switchBeforeFirstFrame'] = {
|
|
||||||
'timelineId': id,
|
|
||||||
'native': await diagnostic(activePreview()!),
|
|
||||||
};
|
|
||||||
save();
|
|
||||||
await until(
|
|
||||||
() =>
|
|
||||||
(activePreview()!
|
|
||||||
.session!
|
|
||||||
.snapshot
|
|
||||||
?.presentedVideoFrameCount ??
|
|
||||||
0) >
|
|
||||||
0,
|
|
||||||
'native frame $id',
|
|
||||||
);
|
|
||||||
switches.add({
|
|
||||||
'scenario': name,
|
|
||||||
'uiPostFrameMs': uiMs,
|
|
||||||
'dataMs': dataMs,
|
|
||||||
'nativeFrameObservedMs': clock.elapsedMicroseconds / 1000,
|
|
||||||
'startupTrace': startupTrace,
|
|
||||||
});
|
|
||||||
expect(activePreview()!.error, isNull);
|
|
||||||
save();
|
|
||||||
} finally {
|
|
||||||
traceTimer.cancel();
|
|
||||||
subscription.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await switchTo('cold', 'cold');
|
|
||||||
for (var i = 0; i < 3; i++) {
|
|
||||||
await switchTo('project', 'warm-return-$i');
|
|
||||||
await switchTo('cold', 'warm-target-$i');
|
|
||||||
}
|
|
||||||
final rapid = <String>[];
|
|
||||||
final rapidSub = container.listen(projectsProvider, (_, next) {
|
|
||||||
if (next.value?.visibleTimelineId case final id?) rapid.add(id);
|
|
||||||
});
|
|
||||||
for (final id in ['third', 'project', 'cold', 'project', 'cold']) {
|
|
||||||
await tester.tap(find.byKey(ValueKey('timeline-tab-$id')));
|
|
||||||
await tester.pump();
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
|
||||||
expect(
|
|
||||||
container.read(projectsProvider).requireValue.visibleTimelineId,
|
|
||||||
id,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await advance(1000);
|
|
||||||
rapidSub.close();
|
|
||||||
expect(
|
|
||||||
container.read(projectsProvider).requireValue.timeline!.id,
|
|
||||||
'cold',
|
|
||||||
);
|
|
||||||
result['rapidSelection'] = rapid;
|
|
||||||
await until(
|
|
||||||
() => activePreview()?.ready == true,
|
|
||||||
'preview after rapid selection',
|
|
||||||
);
|
|
||||||
final preview = activePreview()!;
|
|
||||||
final session = await container.read(
|
|
||||||
editorTimelineProvider(projectId, 'cold').future,
|
|
||||||
);
|
|
||||||
final sequence = session.activeSequenceId!;
|
|
||||||
final view = session.view(sequence);
|
|
||||||
Future<void> seek(int frame) => preview.controlPreview(
|
|
||||||
sequence,
|
|
||||||
PreviewAction.seek,
|
|
||||||
at: CommandTime(frame, 30),
|
|
||||||
);
|
|
||||||
final seeks = result['seeks']! as List<Map<String, Object?>>;
|
|
||||||
for (final frame in [1800, 60000, 60001, 60002, 60001]) {
|
|
||||||
final before = await diagnostic(preview);
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
await seek(frame);
|
|
||||||
final after = await diagnostic(preview);
|
|
||||||
seeks.add({
|
|
||||||
'frame': frame,
|
|
||||||
'acknowledgmentMs': clock.elapsedMicroseconds / 1000,
|
|
||||||
'frames': frames(after) - frames(before),
|
|
||||||
'native': after,
|
|
||||||
});
|
|
||||||
expect(preview.error, isNull);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
final drags = result['drags']! as List<Map<String, Object?>>;
|
|
||||||
for (var round = 0; round < 2; round++) {
|
|
||||||
for (final local in [false, true]) {
|
|
||||||
view.fitTimeline();
|
|
||||||
await advance(200);
|
|
||||||
final rulerFinder = find.byType(TimelineRuler);
|
|
||||||
final ruler = tester.renderObject<RenderBox>(rulerFinder);
|
|
||||||
final viewport = TimelineViewportRect(
|
|
||||||
width: ruler.size.width,
|
|
||||||
height: ruler.size.height,
|
|
||||||
);
|
|
||||||
final durationFrames = (info.duration.seconds * 30).floor();
|
|
||||||
if (local) {
|
|
||||||
view.setCamera(
|
|
||||||
TimelineCamera(
|
|
||||||
baseTick: TimelineClock.standard.toTicks(
|
|
||||||
RationalTime(59980, 30),
|
|
||||||
),
|
|
||||||
pixelsPerTick:
|
|
||||||
4 / TimelineClock.standard.toTicks(RationalTime(1, 30)),
|
|
||||||
verticalOffset: view.camera.verticalOffset,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await advance(100);
|
|
||||||
}
|
|
||||||
Offset position(int frame) => ruler.localToGlobal(
|
|
||||||
Offset(
|
|
||||||
view.camera.screenXForTick(
|
|
||||||
TimelineClock.standard.toTicks(RationalTime(frame, 30)),
|
|
||||||
viewport,
|
|
||||||
),
|
|
||||||
ruler.size.height / 2,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final startFrame = local ? 60000 : (durationFrames * .05).round();
|
|
||||||
await seek(startFrame);
|
|
||||||
await advance(150);
|
|
||||||
var initial = await diagnostic(preview);
|
|
||||||
final observations = <Map<String, Object?>>[];
|
|
||||||
final inputs = <Map<String, Object?>>[];
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
Future<void>? pending;
|
|
||||||
Object? sampleError;
|
|
||||||
void sample() {
|
|
||||||
if (pending != null) return;
|
|
||||||
pending = diagnostic(preview)
|
|
||||||
.then((d) {
|
|
||||||
observations.add({
|
|
||||||
'ms': clock.elapsedMicroseconds / 1000,
|
|
||||||
...d,
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catchError((Object e) {
|
|
||||||
sampleError = e;
|
|
||||||
})
|
|
||||||
.whenComplete(() => pending = null);
|
|
||||||
}
|
|
||||||
|
|
||||||
final gesture = await tester.startGesture(
|
|
||||||
position(startFrame),
|
|
||||||
kind: PointerDeviceKind.touch,
|
|
||||||
);
|
|
||||||
// Acquire the real ruler's drag recognizer before measuring movement.
|
|
||||||
await gesture.moveBy(const Offset(30, 0));
|
|
||||||
await tester.pump();
|
|
||||||
expect(view.isScrubbing, isTrue);
|
|
||||||
await gesture.moveTo(position(startFrame));
|
|
||||||
await advance(350);
|
|
||||||
initial = await diagnostic(preview);
|
|
||||||
clock.reset();
|
|
||||||
final timer = Timer.periodic(
|
|
||||||
const Duration(milliseconds: 20),
|
|
||||||
(_) => sample(),
|
|
||||||
);
|
|
||||||
for (var i = 0; i < 120; i++) {
|
|
||||||
final dueUs = (i * 1000000 / 60).round();
|
|
||||||
final remaining = dueUs - clock.elapsedMicroseconds;
|
|
||||||
if (remaining > 0) {
|
|
||||||
await Future<void>.delayed(Duration(microseconds: remaining));
|
|
||||||
}
|
|
||||||
final phase = i < 60 ? i : 119 - i;
|
|
||||||
final target = local
|
|
||||||
? 60000 + (i % 40 < 20 ? i % 40 : 39 - i % 40)
|
|
||||||
: (durationFrames * (.05 + .9 * phase / 59)).round();
|
|
||||||
await gesture.moveTo(position(target));
|
|
||||||
inputs.add({
|
|
||||||
'ms': clock.elapsedMicroseconds / 1000,
|
|
||||||
'dueMs': dueUs / 1000,
|
|
||||||
'idealFrame': target,
|
|
||||||
'actualTick': view.playheadTick,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
final releaseAt = clock.elapsedMicroseconds / 1000;
|
|
||||||
final finalTick = view.playheadTick;
|
|
||||||
await gesture.up();
|
|
||||||
await tester.pump();
|
|
||||||
await preview.waitForPendingPreview().timeout(
|
|
||||||
const Duration(seconds: 60),
|
|
||||||
);
|
|
||||||
final settled = await diagnostic(preview);
|
|
||||||
final settledMs = clock.elapsedMicroseconds / 1000;
|
|
||||||
await advance(500);
|
|
||||||
final frozen = await diagnostic(preview);
|
|
||||||
timer.cancel();
|
|
||||||
await pending;
|
|
||||||
expect(sampleError, isNull);
|
|
||||||
expect(preview.error, isNull);
|
|
||||||
final snapshot = await preview.session!.refresh();
|
|
||||||
final clockTick =
|
|
||||||
(BigInt.from(snapshot.position.numerator) *
|
|
||||||
BigInt.from(TimelineClock.ticksPerSecond) ~/
|
|
||||||
BigInt.from(snapshot.position.denominator))
|
|
||||||
.toInt();
|
|
||||||
expectExactSource(settled, finalTick);
|
|
||||||
expect(
|
|
||||||
(clockTick - finalTick).abs(),
|
|
||||||
lessThanOrEqualTo(TimelineClock.ticksPerSecond ~/ 1000000),
|
|
||||||
);
|
|
||||||
drags.add({
|
|
||||||
'round': round,
|
|
||||||
'scenario': local ? 'local-20-frame' : 'fit-entire-source',
|
|
||||||
'viewportWidth': ruler.size.width,
|
|
||||||
'inputs': inputs,
|
|
||||||
'observations': observations,
|
|
||||||
'before': initial,
|
|
||||||
'settled': settled,
|
|
||||||
'frozen': frozen,
|
|
||||||
'releaseAtMs': releaseAt,
|
|
||||||
'settledAtMs': settledMs,
|
|
||||||
'releaseWaitMs': settledMs - releaseAt,
|
|
||||||
'finalTick': finalTick,
|
|
||||||
'clockTick': clockTick,
|
|
||||||
'postSettleFrames': frames(frozen) - frames(settled),
|
|
||||||
});
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final ruler = tester.renderObject<RenderBox>(
|
|
||||||
find.byType(TimelineRuler),
|
|
||||||
);
|
|
||||||
final viewport = TimelineViewportRect(
|
|
||||||
width: ruler.size.width,
|
|
||||||
height: ruler.size.height,
|
|
||||||
);
|
|
||||||
Offset heldPosition(int frame) => ruler.localToGlobal(
|
|
||||||
Offset(
|
|
||||||
view.camera.screenXForTick(
|
|
||||||
TimelineClock.standard.toTicks(RationalTime(frame, 30)),
|
|
||||||
viewport,
|
|
||||||
),
|
|
||||||
ruler.size.height / 2,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await seek(60000);
|
|
||||||
final hold = await tester.startGesture(
|
|
||||||
heldPosition(60000),
|
|
||||||
kind: PointerDeviceKind.touch,
|
|
||||||
);
|
|
||||||
await hold.moveBy(const Offset(30, 0));
|
|
||||||
await tester.pump();
|
|
||||||
await hold.moveTo(heldPosition(60010));
|
|
||||||
await advance(1000);
|
|
||||||
final heldTick = view.playheadTick;
|
|
||||||
final heldBefore = await diagnostic(preview);
|
|
||||||
final releaseClock = Stopwatch()..start();
|
|
||||||
await hold.up();
|
|
||||||
await tester.pump();
|
|
||||||
await preview.waitForPendingPreview().timeout(
|
|
||||||
const Duration(seconds: 60),
|
|
||||||
);
|
|
||||||
final heldAfter = await diagnostic(preview);
|
|
||||||
final heldReleaseMs = releaseClock.elapsedMicroseconds / 1000;
|
|
||||||
await advance(500);
|
|
||||||
final heldFrozen = await diagnostic(preview);
|
|
||||||
(result['heldRelease']! as List<Map<String, Object?>>).add({
|
|
||||||
'holdMilliseconds': 1000,
|
|
||||||
'targetTick': heldTick,
|
|
||||||
'before': heldBefore,
|
|
||||||
'after': heldAfter,
|
|
||||||
'frozen': heldFrozen,
|
|
||||||
'releaseWaitMs': heldReleaseMs,
|
|
||||||
});
|
|
||||||
save();
|
|
||||||
expectExactSource(heldBefore, heldTick);
|
|
||||||
expectExactSource(heldAfter, heldTick);
|
|
||||||
expect(sourcePts(heldAfter), sourcePts(heldBefore));
|
|
||||||
expect(frames(heldAfter), frames(heldBefore));
|
|
||||||
expect(heldAfter['seekRequestCount'], heldBefore['seekRequestCount']);
|
|
||||||
expect(frames(heldFrozen), frames(heldAfter));
|
|
||||||
expect(tester.takeException(), isNull);
|
|
||||||
final after = await file.stat();
|
|
||||||
expect(after.size, before.size);
|
|
||||||
expect(after.modified, before.modified);
|
|
||||||
result['status'] = 'passed';
|
|
||||||
result['sourceUnchanged'] = true;
|
|
||||||
save();
|
|
||||||
} catch (error, stack) {
|
|
||||||
result['status'] = 'failed';
|
|
||||||
result['error'] = '$error';
|
|
||||||
result['stack'] = '$stack';
|
|
||||||
save();
|
|
||||||
rethrow;
|
|
||||||
} finally {
|
|
||||||
await tester.pumpWidget(const SizedBox.shrink());
|
|
||||||
container.dispose();
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 300));
|
|
||||||
await database.close();
|
|
||||||
await SystemChrome.setPreferredOrientations([]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
skip: source.isEmpty || output.isEmpty,
|
|
||||||
timeout: const Timeout(Duration(minutes: 15)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
class _Workspace extends ConsumerWidget {
|
|
||||||
const _Workspace();
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final state = ref.watch(projectsProvider).requireValue;
|
|
||||||
return EditorWorkspace(
|
|
||||||
projectId: state.activeProject!.id,
|
|
||||||
projectName: state.activeProject!.name,
|
|
||||||
timelineId: state.visibleTimelineId!,
|
|
||||||
projectLoading: state.projectBusy,
|
|
||||||
timelineLoading: state.openingTimelineId != null,
|
|
||||||
integratedTitlebar: false,
|
|
||||||
headerLeading: const SizedBox.shrink(),
|
|
||||||
experience: DeviceExperience.tablet,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,14 +16,12 @@ import 'package:cutdex/workspace/projects.dart';
|
|||||||
import 'package:cutdex/workspace/preview_controller_registry.dart';
|
import 'package:cutdex/workspace/preview_controller_registry.dart';
|
||||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
import 'package:cutdex/workspace/timeline_provider.dart';
|
||||||
import 'package:cutdex_native/cutdex_native.dart';
|
import 'package:cutdex_native/cutdex_native.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex_core/execution.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/timeline/engine.dart';
|
||||||
import 'package:cutdex_core/timeline/engine.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
|
||||||
import 'package:drift/native.dart';
|
import 'package:drift/native.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
@@ -217,12 +215,7 @@ void main() {
|
|||||||
try {
|
try {
|
||||||
info = await runtime.probe(media);
|
info = await runtime.probe(media);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// This diagnostic test deliberately inspects the native wire response.
|
final raw = await runtime.invoke('probe', {'media': media.toMap()});
|
||||||
final raw = await const MethodChannel('cutdex_runtime')
|
|
||||||
.invokeMethod<Object?>('probe', {
|
|
||||||
'contractVersion': 1,
|
|
||||||
'media': media.toMap(),
|
|
||||||
});
|
|
||||||
result['rawProbeMetadata'] = raw;
|
result['rawProbeMetadata'] = raw;
|
||||||
// Preserve the actual wire-contract failure in the device report.
|
// Preserve the actual wire-contract failure in the device report.
|
||||||
MediaInfo.fromMap(raw! as Map);
|
MediaInfo.fromMap(raw! as Map);
|
||||||
|
|||||||
@@ -8,11 +8,10 @@ import 'package:cutdex/workspace/timeline_provider.dart';
|
|||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import 'package:cutdex/features/preview/preview_panel.dart';
|
import 'package:cutdex/features/preview/preview_panel.dart';
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
import 'package:cutdex_sdk/preview.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex_core/execution.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import 'package:cutdex/persistence/app_database.dart';
|
|||||||
import 'package:cutdex/workspace/media_file_extensions.dart';
|
import 'package:cutdex/workspace/media_file_extensions.dart';
|
||||||
import 'package:cutdex/workspace/preview_target.dart';
|
import 'package:cutdex/workspace/preview_target.dart';
|
||||||
import 'package:cutdex/workspace/projects.dart';
|
import 'package:cutdex/workspace/projects.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:drift/native.dart';
|
import 'package:drift/native.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ import 'package:cutdex/workspace/media_file_extensions.dart';
|
|||||||
import 'package:cutdex/workspace/preview_target.dart';
|
import 'package:cutdex/workspace/preview_target.dart';
|
||||||
import 'package:cutdex/workspace/projects.dart';
|
import 'package:cutdex/workspace/projects.dart';
|
||||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
import 'package:cutdex/workspace/timeline_provider.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_core/timeline/layout.dart';
|
import 'package:cutdex_sdk/timeline/layout.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:drift/native.dart';
|
import 'package:drift/native.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ import 'package:cutdex/l10n/app_localizations.dart';
|
|||||||
import 'package:cutdex/persistence/app_database.dart';
|
import 'package:cutdex/persistence/app_database.dart';
|
||||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
import 'package:cutdex/workspace/timeline_provider.dart';
|
||||||
import 'package:cutdex/workspace/timeline_session.dart';
|
import 'package:cutdex/workspace/timeline_session.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
import 'package:cutdex_sdk/preview.dart';
|
||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:drift/native.dart';
|
import 'package:drift/native.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|||||||
@@ -6,12 +6,11 @@ import 'package:cutdex/workspace/persistence/project_workspace.dart';
|
|||||||
import 'package:cutdex/workspace/project_state.dart';
|
import 'package:cutdex/workspace/project_state.dart';
|
||||||
import 'package:cutdex/workspace/projects.dart';
|
import 'package:cutdex/workspace/projects.dart';
|
||||||
import 'package:cutdex/workspace/timeline_session.dart';
|
import 'package:cutdex/workspace/timeline_session.dart';
|
||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
import 'package:cutdex_sdk/preview.dart';
|
||||||
import 'package:cutdex_core/execution.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|||||||
@@ -4,13 +4,12 @@ import 'package:cutdex/l10n/app_localizations.dart';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex/features/preview/preview_panel.dart';
|
import 'package:cutdex/features/preview/preview_panel.dart';
|
||||||
import 'package:cutdex/features/properties/picture_properties.dart';
|
import 'package:cutdex/features/properties/picture_properties.dart';
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
import 'package:cutdex_sdk/preview.dart';
|
||||||
import 'package:cutdex_core/execution.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|||||||
@@ -7,12 +7,11 @@ import 'package:cutdex/features/preview/preview_panel.dart';
|
|||||||
import 'package:cutdex/persistence/app_database.dart';
|
import 'package:cutdex/persistence/app_database.dart';
|
||||||
import 'package:cutdex/workspace/projects.dart';
|
import 'package:cutdex/workspace/projects.dart';
|
||||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
import 'package:cutdex/workspace/timeline_provider.dart';
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
import 'package:cutdex_sdk/preview.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
|
import 'package:cutdex_sdk/timeline_ui.dart';
|
||||||
import 'package:drift/native.dart';
|
import 'package:drift/native.dart';
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
@@ -162,7 +161,9 @@ void main() {
|
|||||||
|
|
||||||
final panel = find.byType(EditorPreviewPanel);
|
final panel = find.byType(EditorPreviewPanel);
|
||||||
await tester.tap(
|
await tester.tap(
|
||||||
find.descendant(of: panel, matching: find.byIcon(AppIcons.play)).first,
|
find
|
||||||
|
.descendant(of: panel, matching: find.byIcon(Icons.play_arrow))
|
||||||
|
.first,
|
||||||
);
|
);
|
||||||
await until(() => preview.playing, label: 'UI play');
|
await until(() => preview.playing, label: 'UI play');
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 700));
|
await Future<void>.delayed(const Duration(milliseconds: 700));
|
||||||
@@ -172,7 +173,7 @@ void main() {
|
|||||||
greaterThan(0),
|
greaterThan(0),
|
||||||
);
|
);
|
||||||
await tester.tap(
|
await tester.tap(
|
||||||
find.descendant(of: panel, matching: find.byIcon(AppIcons.pause)).first,
|
find.descendant(of: panel, matching: find.byIcon(Icons.pause)).first,
|
||||||
);
|
);
|
||||||
await until(() => !preview.playing, label: 'UI pause');
|
await until(() => !preview.playing, label: 'UI pause');
|
||||||
mark('real play and pause buttons advanced native media clock');
|
mark('real play and pause buttons advanced native media clock');
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import 'package:cutdex/workspace/timeline_provider.dart';
|
|||||||
|
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
import 'package:cutdex_sdk/preview.dart';
|
||||||
import 'package:cutdex/features/preview/preview_panel.dart';
|
import 'package:cutdex/features/preview/preview_panel.dart';
|
||||||
import 'package:cutdex/features/properties/properties_panel.dart';
|
import 'package:cutdex/features/properties/properties_panel.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import '../test/support/creation_names.dart';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:cutdex/workspace/persistence/project_workspace.dart';
|
import 'package:cutdex/workspace/persistence/project_workspace.dart';
|
||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
|
|
||||||
import '../test/support/processing_fixture.dart';
|
import '../test/support/processing_fixture.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ import 'dart:ui' as ui;
|
|||||||
|
|
||||||
import 'package:cutdex/features/preview/preview_panel.dart';
|
import 'package:cutdex/features/preview/preview_panel.dart';
|
||||||
import 'package:cutdex/features/timeline/timeline_panel.dart';
|
import 'package:cutdex/features/timeline/timeline_panel.dart';
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
import 'package:cutdex_sdk/preview.dart';
|
||||||
import 'package:cutdex/integrations/runtime/timeline_thumbnails.dart';
|
import 'package:cutdex/integrations/runtime/timeline_thumbnails.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
|
import 'package:cutdex_sdk/timeline_ui.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import 'dart:convert';
|
|||||||
import 'package:cutdex/integrations/runtime/processing_configuration.dart';
|
import 'package:cutdex/integrations/runtime/processing_configuration.dart';
|
||||||
import 'package:cutdex/workspace/persistence/project_workspace.dart';
|
import 'package:cutdex/workspace/persistence/project_workspace.dart';
|
||||||
import 'package:cutdex/workspace/timeline_session.dart';
|
import 'package:cutdex/workspace/timeline_session.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
import 'package:cutdex_sdk/preview.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:integration_test/integration_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:flutter/painting.dart';
|
import 'package:flutter/painting.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
class SavedEditValidation {
|
class SavedEditValidation {
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import 'dart:convert';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:cutdex/integrations/runtime/timeline_thumbnails.dart';
|
import 'package:cutdex/integrations/runtime/timeline_thumbnails.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_core/timeline/engine.dart';
|
import 'package:cutdex_sdk/timeline/engine.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|||||||
@@ -17,12 +17,11 @@ import 'package:cutdex/workspace/media_import.dart';
|
|||||||
import 'package:cutdex/workspace/preview_controller_registry.dart';
|
import 'package:cutdex/workspace/preview_controller_registry.dart';
|
||||||
import 'package:cutdex/workspace/projects.dart';
|
import 'package:cutdex/workspace/projects.dart';
|
||||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
import 'package:cutdex/workspace/timeline_provider.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
import 'package:cutdex_sdk/preview.dart';
|
||||||
import 'package:cutdex_core/execution.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/timeline/engine.dart';
|
||||||
import 'package:cutdex_core/timeline/engine.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
|
||||||
import 'package:drift/native.dart';
|
import 'package:drift/native.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|||||||
@@ -17,11 +17,10 @@ import 'package:cutdex/workspace/media_import.dart';
|
|||||||
import 'package:cutdex/workspace/projects.dart';
|
import 'package:cutdex/workspace/projects.dart';
|
||||||
import 'package:cutdex/workspace/preview_controller_registry.dart';
|
import 'package:cutdex/workspace/preview_controller_registry.dart';
|
||||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
import 'package:cutdex/workspace/timeline_provider.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex_core/execution.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/timeline/engine.dart';
|
||||||
import 'package:cutdex_core/timeline/engine.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
|
||||||
import 'package:drift/native.dart';
|
import 'package:drift/native.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ import 'dart:math' as math;
|
|||||||
import 'package:cutdex/features/preview/preview_panel.dart';
|
import 'package:cutdex/features/preview/preview_panel.dart';
|
||||||
import 'package:cutdex/l10n/app_localizations.dart';
|
import 'package:cutdex/l10n/app_localizations.dart';
|
||||||
import 'package:cutdex/workspace/timeline_provider.dart';
|
import 'package:cutdex/workspace/timeline_provider.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:cutdex_preview/cutdex_preview.dart';
|
import 'package:cutdex_sdk/preview.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|||||||
@@ -1,264 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
import 'dart:math' as math;
|
|
||||||
|
|
||||||
import 'package:cutdex/app/app.dart';
|
|
||||||
import 'package:cutdex/integrations/agent/conversation_repository.dart';
|
|
||||||
import 'package:cutdex/integrations/platform/device_experience.dart';
|
|
||||||
import 'package:cutdex/persistence/app_database.dart';
|
|
||||||
import 'package:cutdex/persistence/settings/view_settings_repositories.dart';
|
|
||||||
import 'package:cutdex/workspace/projects.dart';
|
|
||||||
import 'package:cutdex/workspace/view_settings.dart';
|
|
||||||
import 'package:cutdex/workspace/workspace_mode.dart';
|
|
||||||
import 'package:cutdex_core/project.dart';
|
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
|
||||||
import 'package:drift/native.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:integration_test/integration_test.dart';
|
|
||||||
|
|
||||||
import '../test/support/empty_conversation_repository.dart';
|
|
||||||
import '../test/support/preview_fixture.dart';
|
|
||||||
|
|
||||||
/// Run with flutter drive --profile on macOS and test_driver/integration_test.dart.
|
|
||||||
/// Define CUTDEX_RESIZE_SOURCE (an image) and CUTDEX_RESIZE_REPORT (JSON output).
|
|
||||||
/// Widget-test timings are not comparable to these real-engine measurements.
|
|
||||||
void main() {
|
|
||||||
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
||||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
|
|
||||||
const source = String.fromEnvironment('CUTDEX_RESIZE_SOURCE');
|
|
||||||
const output = String.fromEnvironment('CUTDEX_RESIZE_REPORT');
|
|
||||||
const rounds = int.fromEnvironment('CUTDEX_RESIZE_ROUNDS', defaultValue: 3);
|
|
||||||
const inputHz = 120;
|
|
||||||
const inputCount = 240;
|
|
||||||
const clipCount = 64;
|
|
||||||
const assetCount = 100;
|
|
||||||
|
|
||||||
testWidgets('profile full desktop workspace split and junction dragging', (
|
|
||||||
tester,
|
|
||||||
) async {
|
|
||||||
expect(kProfileMode, isTrue, reason: 'Use flutter drive --profile');
|
|
||||||
expect(Platform.isMacOS, isTrue);
|
|
||||||
expect(await File(source).exists(), isTrue);
|
|
||||||
final ids = List.generate(clipCount, (i) => ElementId('clip-$i'));
|
|
||||||
final fixture = await createPreviewFixture(
|
|
||||||
File(source).uri,
|
|
||||||
mediaType: 'image',
|
|
||||||
renderSize: {'width': 1280, 'height': 720},
|
|
||||||
timelineOverride: TimelineDto(
|
|
||||||
id: SequenceId('one'),
|
|
||||||
name: 'Resize profiling',
|
|
||||||
format: TimelineFormat.fps30,
|
|
||||||
primaryStorylineId: StorylineId('primary'),
|
|
||||||
storylines: [StorylineDto(id: StorylineId('primary'), elementIds: ids)],
|
|
||||||
elements: [
|
|
||||||
for (final (i, id) in ids.indexed)
|
|
||||||
ElementDto(
|
|
||||||
id: id,
|
|
||||||
name: 'Clip $i',
|
|
||||||
structure: ElementStructure.content,
|
|
||||||
payloadRef: PayloadRef('source'),
|
|
||||||
duration: RationalTime.seconds(2),
|
|
||||||
sourceRange: TimeRange(
|
|
||||||
start: RationalTime.zero,
|
|
||||||
duration: RationalTime.seconds(2),
|
|
||||||
),
|
|
||||||
mediaRange: TimeRange(
|
|
||||||
start: RationalTime.zero,
|
|
||||||
duration: RationalTime.seconds(2),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
for (var i = 0; i < assetCount; i++) {
|
|
||||||
await fixture.workspace.project!.saveAsset(
|
|
||||||
AssetDocument(
|
|
||||||
id: i == 0 ? 'media' : 'media-$i',
|
|
||||||
name: 'Image $i',
|
|
||||||
storage: AssetStorage.external,
|
|
||||||
location: File(source).uri.toString(),
|
|
||||||
metadata: {'kind': 'image'},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final projectPath = '${fixture.directory.path}/Preview.cutdex';
|
|
||||||
await fixture.workspace.close();
|
|
||||||
final database = AppDatabase(
|
|
||||||
NativeDatabase(File('${fixture.directory.path}/settings.sqlite')),
|
|
||||||
);
|
|
||||||
final workspaceWrites = _CountWorkspaceWrites(
|
|
||||||
DriftWorkspaceViewSettingsRepository(database),
|
|
||||||
);
|
|
||||||
final projectWrites = _CountProjectWrites(
|
|
||||||
DriftProjectViewSettingsRepository(database),
|
|
||||||
);
|
|
||||||
final container = ProviderContainer(
|
|
||||||
overrides: [
|
|
||||||
appDatabaseProvider.overrideWithValue(database),
|
|
||||||
deviceExperienceProvider.overrideWithValue(DeviceExperience.desktop),
|
|
||||||
workspaceViewSettingsRepositoryProvider.overrideWithValue(
|
|
||||||
workspaceWrites,
|
|
||||||
),
|
|
||||||
projectViewSettingsRepositoryProvider.overrideWithValue(projectWrites),
|
|
||||||
conversationRepositoryProvider.overrideWith(
|
|
||||||
(ref) async => EmptyConversationRepository(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
addTearDown(() async {
|
|
||||||
await tester.pumpWidget(const SizedBox.shrink());
|
|
||||||
await container.read(projectsProvider.notifier).prepareToQuit();
|
|
||||||
container.dispose();
|
|
||||||
await database.close();
|
|
||||||
await fixture.directory.delete(recursive: true);
|
|
||||||
});
|
|
||||||
await container.read(workspaceViewSettingsProvider.future);
|
|
||||||
container
|
|
||||||
.read(workspaceViewSettingsProvider.notifier)
|
|
||||||
.setMode(WorkspaceMode.cut);
|
|
||||||
expect(
|
|
||||||
await container.read(projectsProvider.notifier).open(projectPath),
|
|
||||||
isTrue,
|
|
||||||
);
|
|
||||||
// This is the normal app/router/editor, with only isolated storage and chat.
|
|
||||||
// ignore: riverpod_lint/provider_scope_placement
|
|
||||||
await tester.pumpWidget(
|
|
||||||
UncontrolledProviderScope(container: container, child: const CutdexApp()),
|
|
||||||
);
|
|
||||||
await const MethodChannel('cutdex_native/window')
|
|
||||||
.invokeMethod<void>('toggleMaximize');
|
|
||||||
final readyClock = Stopwatch()..start();
|
|
||||||
final junction = find.byKey(const Key('desktop-chat-timeline-junction'));
|
|
||||||
while (junction.evaluate().isEmpty) {
|
|
||||||
if (readyClock.elapsed.inSeconds > 60) {
|
|
||||||
throw TimeoutException('Desktop editor did not open');
|
|
||||||
}
|
|
||||||
await tester.pump();
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
|
||||||
}
|
|
||||||
await Future<void>.delayed(const Duration(seconds: 3));
|
|
||||||
final size = tester.view.physicalSize / tester.view.devicePixelRatio;
|
|
||||||
expect(size.width, greaterThan(1100));
|
|
||||||
final results = <String, dynamic>{
|
|
||||||
'mode': 'profile',
|
|
||||||
'platform': Platform.operatingSystemVersion,
|
|
||||||
'logicalSize': [size.width, size.height],
|
|
||||||
'pixelRatio': tester.view.devicePixelRatio,
|
|
||||||
'displayRefreshHz': tester.view.display.refreshRate,
|
|
||||||
'inputHz': inputHz,
|
|
||||||
'inputsPerDrag': inputCount,
|
|
||||||
'clips': clipCount,
|
|
||||||
'assets': assetCount,
|
|
||||||
'scope': 'Full app, native still-image preview, file-backed SQLite; synthetic mouse input',
|
|
||||||
'runs': <Map<String, dynamic>>[],
|
|
||||||
};
|
|
||||||
final report = File(output);
|
|
||||||
await report.parent.create(recursive: true);
|
|
||||||
Future<void> save() => report.writeAsString(
|
|
||||||
const JsonEncoder.withIndent(' ').convert(results),
|
|
||||||
);
|
|
||||||
await save();
|
|
||||||
const scenarios = {
|
|
||||||
'sidebar': ('project-sidebar-resize', Offset(55, 0)),
|
|
||||||
'media': ('editor-media-resize', Offset(65, 0)),
|
|
||||||
'timeline': ('editor-timeline-resize', Offset(0, 80)),
|
|
||||||
'mediaJunction': ('editor-media-timeline-junction', Offset(65, 80)),
|
|
||||||
'chatJunction': ('desktop-chat-timeline-junction', Offset(55, 80)),
|
|
||||||
};
|
|
||||||
for (var round = 0; round < rounds; round++) {
|
|
||||||
for (final entry in scenarios.entries) {
|
|
||||||
final (key, amplitude) = entry.value;
|
|
||||||
final reportKey = '${entry.key}-$round';
|
|
||||||
final start = tester.getCenter(find.byKey(Key(key)));
|
|
||||||
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
|
|
||||||
await mouse.addPointer(location: start);
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 250));
|
|
||||||
final writesBefore = workspaceWrites.count;
|
|
||||||
final projectWritesBefore = projectWrites.count;
|
|
||||||
final dispatchTimes = <int>[];
|
|
||||||
await binding.watchPerformance(() async {
|
|
||||||
await mouse.down(start);
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
for (var i = 1; i <= inputCount; i++) {
|
|
||||||
final dueUs = (i * 1000000 / inputHz).round();
|
|
||||||
final waitUs = dueUs - clock.elapsedMicroseconds;
|
|
||||||
if (waitUs > 0) {
|
|
||||||
await Future<void>.delayed(Duration(microseconds: waitUs));
|
|
||||||
}
|
|
||||||
final dispatch = Stopwatch()..start();
|
|
||||||
await mouse.moveTo(
|
|
||||||
start + amplitude * math.sin(2 * math.pi * i / inputCount),
|
|
||||||
);
|
|
||||||
dispatchTimes.add(dispatch.elapsedMicroseconds);
|
|
||||||
}
|
|
||||||
await mouse.up();
|
|
||||||
await mouse.removePointer();
|
|
||||||
}, reportKey: reportKey);
|
|
||||||
// Allow queued persistence writes and batched engine timings to arrive.
|
|
||||||
await Future<void>.delayed(const Duration(seconds: 1));
|
|
||||||
final timings = Map<String, dynamic>.from(
|
|
||||||
binding.reportData![reportKey] as Map,
|
|
||||||
);
|
|
||||||
final build = List<int>.from(timings['frame_build_times'] as List);
|
|
||||||
final raster = List<int>.from(
|
|
||||||
timings['frame_rasterizer_times'] as List,
|
|
||||||
);
|
|
||||||
int overBudget(int budgetUs) => List.generate(
|
|
||||||
build.length,
|
|
||||||
(i) => i,
|
|
||||||
).where((i) => build[i] > budgetUs || raster[i] > budgetUs).length;
|
|
||||||
final row = <String, dynamic>{
|
|
||||||
'scenario': entry.key,
|
|
||||||
'round': round,
|
|
||||||
'workspaceWrites': workspaceWrites.count - writesBefore,
|
|
||||||
'projectWrites': projectWrites.count - projectWritesBefore,
|
|
||||||
'over16ms': overBudget(16667),
|
|
||||||
'over8ms': overBudget(8333),
|
|
||||||
'dispatchUs': dispatchTimes,
|
|
||||||
'timings': timings,
|
|
||||||
};
|
|
||||||
(results['runs'] as List).add(row);
|
|
||||||
await save();
|
|
||||||
debugPrint(
|
|
||||||
'RESIZE_PROFILE ${entry.key} $round frames=${build.length} '
|
|
||||||
'over16ms=${row['over16ms']} writes=${row['workspaceWrites']}',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
results['status'] = 'passed';
|
|
||||||
await save();
|
|
||||||
expect(tester.takeException(), isNull);
|
|
||||||
}, skip: !Platform.isMacOS || source.isEmpty || output.isEmpty);
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CountWorkspaceWrites implements WorkspaceViewSettingsRepository {
|
|
||||||
_CountWorkspaceWrites(this.delegate);
|
|
||||||
final WorkspaceViewSettingsRepository delegate;
|
|
||||||
int count = 0;
|
|
||||||
@override
|
|
||||||
Future<WorkspaceViewSettingsData> load() => delegate.load();
|
|
||||||
@override
|
|
||||||
Future<void> save(WorkspaceViewSettingsData settings) {
|
|
||||||
count++;
|
|
||||||
return delegate.save(settings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _CountProjectWrites implements ProjectViewSettingsRepository {
|
|
||||||
_CountProjectWrites(this.delegate);
|
|
||||||
final ProjectViewSettingsRepository delegate;
|
|
||||||
int count = 0;
|
|
||||||
@override
|
|
||||||
Future<ProjectViewSettingsData> load(String id) => delegate.load(id);
|
|
||||||
@override
|
|
||||||
Future<void> save(String id, ProjectViewSettingsData settings) {
|
|
||||||
count++;
|
|
||||||
return delegate.save(id, settings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
enum DesktopContent { workspace, library, resourceLibrary, workflow, settings }
|
enum DesktopContent { workspace, library, settings }
|
||||||
|
|
||||||
typedef DesktopContentSelection = ({
|
typedef DesktopContentSelection = ({
|
||||||
DesktopContent surface,
|
DesktopContent surface,
|
||||||
@@ -9,7 +9,6 @@ typedef DesktopContentSelection = ({
|
|||||||
(String, String)? workspace,
|
(String, String)? workspace,
|
||||||
bool settingsVisited,
|
bool settingsVisited,
|
||||||
bool resourcesSelected,
|
bool resourcesSelected,
|
||||||
bool librarySelected,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final desktopContentProvider =
|
final desktopContentProvider =
|
||||||
@@ -19,8 +18,6 @@ final desktopContentProvider =
|
|||||||
|
|
||||||
/// Navigation changes visibility without disposing any visited content.
|
/// Navigation changes visibility without disposing any visited content.
|
||||||
class DesktopContentController extends Notifier<DesktopContentSelection> {
|
class DesktopContentController extends Notifier<DesktopContentSelection> {
|
||||||
DesktopContent _settingsReturnSurface = DesktopContent.workspace;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
DesktopContentSelection build() => (
|
DesktopContentSelection build() => (
|
||||||
surface: DesktopContent.workspace,
|
surface: DesktopContent.workspace,
|
||||||
@@ -29,7 +26,6 @@ class DesktopContentController extends Notifier<DesktopContentSelection> {
|
|||||||
workspace: null,
|
workspace: null,
|
||||||
settingsVisited: false,
|
settingsVisited: false,
|
||||||
resourcesSelected: false,
|
resourcesSelected: false,
|
||||||
librarySelected: false,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
void select(DesktopContent surface) {
|
void select(DesktopContent surface) {
|
||||||
@@ -41,14 +37,10 @@ class DesktopContentController extends Notifier<DesktopContentSelection> {
|
|||||||
settingsVisited:
|
settingsVisited:
|
||||||
state.settingsVisited || surface == DesktopContent.settings,
|
state.settingsVisited || surface == DesktopContent.settings,
|
||||||
resourcesSelected: surface == DesktopContent.library,
|
resourcesSelected: surface == DesktopContent.library,
|
||||||
librarySelected: surface == DesktopContent.resourceLibrary,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showSettings({int? tab, (String, String)? workspace}) {
|
void showSettings({int? tab, (String, String)? workspace}) {
|
||||||
if (state.surface != DesktopContent.settings) {
|
|
||||||
_settingsReturnSurface = state.surface;
|
|
||||||
}
|
|
||||||
state = (
|
state = (
|
||||||
surface: DesktopContent.settings,
|
surface: DesktopContent.settings,
|
||||||
settingsTab: tab ?? state.settingsTab,
|
settingsTab: tab ?? state.settingsTab,
|
||||||
@@ -56,13 +48,6 @@ class DesktopContentController extends Notifier<DesktopContentSelection> {
|
|||||||
workspace: workspace ?? state.workspace,
|
workspace: workspace ?? state.workspace,
|
||||||
settingsVisited: true,
|
settingsVisited: true,
|
||||||
resourcesSelected: state.resourcesSelected,
|
resourcesSelected: state.resourcesSelected,
|
||||||
librarySelected: state.librarySelected,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void closeSettings() {
|
|
||||||
if (state.surface == DesktopContent.settings) {
|
|
||||||
select(_settingsReturnSurface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -4,49 +4,17 @@ import 'package:flutter/foundation.dart';
|
|||||||
class DesktopWorkspaceController extends ChangeNotifier {
|
class DesktopWorkspaceController extends ChangeNotifier {
|
||||||
double? _agentWidth;
|
double? _agentWidth;
|
||||||
bool _agentFullscreen = false;
|
bool _agentFullscreen = false;
|
||||||
bool _agentFloating = false;
|
|
||||||
bool _agentFloatingExpanded = false;
|
|
||||||
bool _agentVisible = false;
|
|
||||||
|
|
||||||
double? get agentWidth => _agentWidth;
|
double? get agentWidth => _agentWidth;
|
||||||
bool get agentFullscreen => _agentFullscreen;
|
bool get agentFullscreen => _agentFullscreen;
|
||||||
bool get agentFloating => _agentFloating;
|
|
||||||
bool get agentFloatingExpanded => _agentFloatingExpanded;
|
|
||||||
bool get agentVisible => _agentVisible;
|
|
||||||
|
|
||||||
void setAgentVisible(bool value) {
|
|
||||||
if (_agentVisible == value) return;
|
|
||||||
_agentVisible = value;
|
|
||||||
if (!value) {
|
|
||||||
_agentFloating = false;
|
|
||||||
_agentFullscreen = false;
|
|
||||||
_agentFloatingExpanded = false;
|
|
||||||
}
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void toggleFloatingConversation() {
|
|
||||||
_agentFloatingExpanded = !_agentFloatingExpanded;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setAgentWidth(double width) {
|
void setAgentWidth(double width) {
|
||||||
_agentWidth = width;
|
_agentWidth = width;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAgentFloating(bool value) {
|
|
||||||
if (_agentFloating == value) return;
|
|
||||||
_agentFloating = value;
|
|
||||||
_agentVisible = true;
|
|
||||||
if (!value) _agentFloatingExpanded = false;
|
|
||||||
if (value) _agentFullscreen = false;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setAgentFullscreen(bool value) {
|
void setAgentFullscreen(bool value) {
|
||||||
if (_agentFullscreen == value && !(value && _agentFloating)) return;
|
if (_agentFullscreen == value) return;
|
||||||
if (value) _agentFloating = false;
|
|
||||||
_agentFullscreen = value;
|
_agentFullscreen = value;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ abstract final class WorkspaceLayoutPolicy {
|
|||||||
width >=
|
width >=
|
||||||
WorkspaceLayoutMetrics.sidebarMinimumWidth +
|
WorkspaceLayoutMetrics.sidebarMinimumWidth +
|
||||||
WorkspaceLayoutMetrics.contentMinimumWidth +
|
WorkspaceLayoutMetrics.contentMinimumWidth +
|
||||||
WorkspaceLayoutMetrics.desktopSpacing;
|
1;
|
||||||
|
|
||||||
static bool showAgentBesideEditor(double width) =>
|
static bool showAgentBesideEditor(double width) =>
|
||||||
width >= WorkspaceLayoutMetrics.dualPaneMinimumWidth;
|
width >= WorkspaceLayoutMetrics.dualPaneMinimumWidth;
|
||||||
|
|||||||
+4
-14
@@ -11,27 +11,17 @@ import '../integrations/app_updates.dart';
|
|||||||
import '../integrations/editor_tools.dart';
|
import '../integrations/editor_tools.dart';
|
||||||
import '../features/settings/appearance_settings.dart';
|
import '../features/settings/appearance_settings.dart';
|
||||||
import '../shared/widgets/error_notification_host.dart';
|
import '../shared/widgets/error_notification_host.dart';
|
||||||
import '../integrations/platform/device_experience.dart';
|
|
||||||
|
|
||||||
class CutdexApp extends ConsumerWidget {
|
class CutdexApp extends ConsumerWidget {
|
||||||
const CutdexApp({super.key});
|
const CutdexApp({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
ref.watch(applicationMcpConnectionProvider.select((_) => null));
|
ref.watch(applicationMcpConnectionProvider);
|
||||||
ref.watch(appUpdateLifecycleProvider.select((_) => null));
|
ref.watch(appUpdateLifecycleProvider);
|
||||||
final appearance =
|
final appearance =
|
||||||
ref.watch(appearanceSettingsProvider).asData?.value ??
|
ref.watch(appearanceSettingsProvider).asData?.value ??
|
||||||
AppAppearance.system;
|
AppAppearance.system;
|
||||||
final palette =
|
|
||||||
ref.watch(paletteSettingsProvider).asData?.value ?? AppPalette.graphite;
|
|
||||||
final desktop =
|
|
||||||
ref.watch(deviceExperienceProvider) == DeviceExperience.desktop;
|
|
||||||
ThemeData theme(Brightness brightness) {
|
|
||||||
final base = EditorTheme.forPalette(palette, brightness);
|
|
||||||
return desktop ? EditorTheme.desktop(base) : base;
|
|
||||||
}
|
|
||||||
|
|
||||||
return MaterialApp.router(
|
return MaterialApp.router(
|
||||||
builder: (context, child) =>
|
builder: (context, child) =>
|
||||||
ErrorNotificationHost(child: child ?? const SizedBox.shrink()),
|
ErrorNotificationHost(child: child ?? const SizedBox.shrink()),
|
||||||
@@ -41,8 +31,8 @@ class CutdexApp extends ConsumerWidget {
|
|||||||
supportedLocales: AppLocalizations.supportedLocales,
|
supportedLocales: AppLocalizations.supportedLocales,
|
||||||
localeListResolutionCallback: resolveAppLocale,
|
localeListResolutionCallback: resolveAppLocale,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: theme(Brightness.light),
|
theme: EditorTheme.penLight,
|
||||||
darkTheme: theme(Brightness.dark),
|
darkTheme: EditorTheme.penDark,
|
||||||
themeMode: appearance.themeMode,
|
themeMode: appearance.themeMode,
|
||||||
routerConfig: ref.watch(appRouterProvider),
|
routerConfig: ref.watch(appRouterProvider),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:cutdex_ui/theme.dart';
|
import 'package:cutdex_ui/theme.dart';
|
||||||
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
|
import 'package:cutdex_sdk/timeline_ui.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// Connects the application palette to the SDK timeline presentation.
|
/// Connects the application palette to the SDK timeline presentation.
|
||||||
@@ -7,39 +7,10 @@ abstract final class EditorTheme {
|
|||||||
static ThemeData get penLight => adapt(AppTheme.penLight);
|
static ThemeData get penLight => adapt(AppTheme.penLight);
|
||||||
static ThemeData get penDark => adapt(AppTheme.penDark);
|
static ThemeData get penDark => adapt(AppTheme.penDark);
|
||||||
|
|
||||||
static ThemeData forPalette(AppPalette palette, Brightness brightness) =>
|
|
||||||
adapt(AppTheme.forPalette(palette, brightness));
|
|
||||||
|
|
||||||
static ThemeData desktop(ThemeData theme) {
|
|
||||||
final desktop = AppTheme.desktopWorkspaceTheme(theme);
|
|
||||||
final timeline = desktop.extension<TimelineThemeData>();
|
|
||||||
if (timeline == null) return desktop;
|
|
||||||
return desktop.copyWith(
|
|
||||||
extensions: [
|
|
||||||
...desktop.extensions.values.where(
|
|
||||||
(value) => value is! TimelineThemeData,
|
|
||||||
),
|
|
||||||
timeline.copyWith(
|
|
||||||
rulerHeight: AppDesktopMetrics.timelineRuler,
|
|
||||||
rulerTextStyle: timeline.rulerTextStyle.copyWith(
|
|
||||||
fontSize: 12,
|
|
||||||
height: 16 / 12,
|
|
||||||
fontFeatures: const [FontFeature.tabularFigures()],
|
|
||||||
),
|
|
||||||
playheadColor: desktop.colorScheme.primary,
|
|
||||||
clipHeaderHeight: 20,
|
|
||||||
clipHeaderPadding: 4,
|
|
||||||
clipNameTextStyle: timeline.clipNameTextStyle.copyWith(
|
|
||||||
fontSize: 11,
|
|
||||||
height: 16 / 11,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ThemeData adapt(ThemeData theme) {
|
static ThemeData adapt(ThemeData theme) {
|
||||||
final palette = AppColors.of(theme);
|
final palette = theme.brightness == Brightness.dark
|
||||||
|
? AppColors.penDark
|
||||||
|
: AppColors.penLight;
|
||||||
final dark = theme.brightness == Brightness.dark;
|
final dark = theme.brightness == Brightness.dark;
|
||||||
final text = theme.textTheme;
|
final text = theme.textTheme;
|
||||||
final timelineBorder = palette.divider;
|
final timelineBorder = palette.divider;
|
||||||
@@ -56,8 +27,8 @@ abstract final class EditorTheme {
|
|||||||
backgroundColor: palette.background,
|
backgroundColor: palette.background,
|
||||||
primaryLaneBackgroundColor: palette.sidebar,
|
primaryLaneBackgroundColor: palette.sidebar,
|
||||||
visualClipColor: palette.visualClip,
|
visualClipColor: palette.visualClip,
|
||||||
audioClipColor: palette.audioClip,
|
audioClipColor: palette.popover,
|
||||||
audioAccentColor: palette.audioWaveform,
|
audioAccentColor: timelineSecondary,
|
||||||
gapColor: timelineBorder,
|
gapColor: timelineBorder,
|
||||||
gapBorderColor: timelineBorder,
|
gapBorderColor: timelineBorder,
|
||||||
containerAccentColor: timelineSecondary,
|
containerAccentColor: timelineSecondary,
|
||||||
@@ -66,7 +37,7 @@ abstract final class EditorTheme {
|
|||||||
connectionLineWidth: 3,
|
connectionLineWidth: 3,
|
||||||
clipBorderColor: timelineBorder,
|
clipBorderColor: timelineBorder,
|
||||||
clipBorderWidth: 1,
|
clipBorderWidth: 1,
|
||||||
selectionOutlineColor: palette.selection,
|
selectionOutlineColor: palette.foreground,
|
||||||
selectionOutlineWidth: 2,
|
selectionOutlineWidth: 2,
|
||||||
keyframeColor: timelineSecondary,
|
keyframeColor: timelineSecondary,
|
||||||
keyframeBorderColor: palette.background,
|
keyframeBorderColor: palette.background,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ GoRouter appRouter(Ref ref) {
|
|||||||
builder: (context, state) => SettingsPage(
|
builder: (context, state) => SettingsPage(
|
||||||
initialTab:
|
initialTab:
|
||||||
(int.tryParse(state.uri.queryParameters['tab'] ?? '') ?? 0)
|
(int.tryParse(state.uri.queryParameters['tab'] ?? '') ?? 0)
|
||||||
.clamp(0, 3),
|
.clamp(0, 2),
|
||||||
workspace: state.extra is (String, String)
|
workspace: state.extra is (String, String)
|
||||||
? state.extra as (String, String)
|
? state.extra as (String, String)
|
||||||
: null,
|
: null,
|
||||||
|
|||||||
@@ -48,4 +48,4 @@ final class AppRouterProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _$appRouterHash() => r'ea1ed83ca5ca1f7079b268b1a94940d575b6ddf9';
|
String _$appRouterHash() => r'00e948f9d82c1f07ecdfc62b3c1ec833cb03edfe';
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
import 'package:cutdex_native/cutdex_native.dart';
|
import 'package:cutdex_native/cutdex_native.dart';
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../integrations/platform/editor_window_chrome.dart';
|
import '../../integrations/platform/editor_window_chrome.dart';
|
||||||
import '../../l10n/l10n.dart';
|
import '../../l10n/l10n.dart';
|
||||||
import '../../shared/layout/workspace_layout_metrics.dart';
|
import '../../shared/layout/workspace_layout_metrics.dart';
|
||||||
import '../editor_theme.dart';
|
import '../../workspace/workspace_mode.dart';
|
||||||
|
|
||||||
/// Keeps window chrome outside the shared workspace surface.
|
/// Keeps window chrome outside the shared workspace surface.
|
||||||
class DesktopWindowFrame extends StatelessWidget {
|
class DesktopWindowFrame extends StatelessWidget {
|
||||||
@@ -14,40 +12,30 @@ class DesktopWindowFrame extends StatelessWidget {
|
|||||||
super.key,
|
super.key,
|
||||||
required this.integratedTitlebar,
|
required this.integratedTitlebar,
|
||||||
required this.headerControls,
|
required this.headerControls,
|
||||||
this.projectTabs,
|
required this.librarySelected,
|
||||||
this.headerTrailing = const SizedBox.shrink(),
|
|
||||||
this.settingsSelected = false,
|
this.settingsSelected = false,
|
||||||
this.workflowSelected = false,
|
required this.onModeChanged,
|
||||||
required this.onHomePressed,
|
required this.onLibraryPressed,
|
||||||
required this.onWorkflowPressed,
|
|
||||||
required this.onSettingsPressed,
|
required this.onSettingsPressed,
|
||||||
required this.child,
|
required this.child,
|
||||||
});
|
});
|
||||||
|
|
||||||
static const railWidth = 44.0;
|
static const railWidth = 44.0;
|
||||||
static const railButtonSize = 32.0;
|
static const railButtonSize = 32.0;
|
||||||
static const railIconSize = 20.0;
|
static const railIconSize = 22.0;
|
||||||
static const headerHeight = AppDesktopMetrics.windowHeader;
|
static const headerHeight = 40.0;
|
||||||
static const headerInset = (railWidth - AppControlSize.headerButton) / 2;
|
static const contentInset = WorkspaceLayoutMetrics.desktopSpacing;
|
||||||
static const contentInset = WorkspaceLayoutMetrics.desktopOuterSpacing;
|
|
||||||
final bool integratedTitlebar;
|
final bool integratedTitlebar;
|
||||||
final Widget headerControls;
|
final Widget headerControls;
|
||||||
final Widget? projectTabs;
|
final bool librarySelected;
|
||||||
final Widget headerTrailing;
|
|
||||||
final bool settingsSelected;
|
final bool settingsSelected;
|
||||||
final bool workflowSelected;
|
final ValueChanged<WorkspaceMode> onModeChanged;
|
||||||
final VoidCallback onHomePressed;
|
final VoidCallback? onLibraryPressed;
|
||||||
final VoidCallback onWorkflowPressed;
|
|
||||||
final VoidCallback onSettingsPressed;
|
final VoidCallback onSettingsPressed;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => Theme(
|
Widget build(BuildContext context) => ColoredBox(
|
||||||
data: EditorTheme.desktop(Theme.of(context)),
|
|
||||||
child: Builder(builder: _buildFrame),
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget _buildFrame(BuildContext context) => ColoredBox(
|
|
||||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
@@ -56,63 +44,19 @@ class DesktopWindowFrame extends StatelessWidget {
|
|||||||
key: const Key('desktop-window-header'),
|
key: const Key('desktop-window-header'),
|
||||||
height: headerHeight,
|
height: headerHeight,
|
||||||
child: WindowHeaderPadding(
|
child: WindowHeaderPadding(
|
||||||
child: Row(
|
child: SingleChildScrollView(
|
||||||
children: [
|
scrollDirection: Axis.horizontal,
|
||||||
Expanded(
|
child: Row(
|
||||||
child: projectTabs != null
|
children: [
|
||||||
? LayoutBuilder(
|
if (integratedTitlebar)
|
||||||
builder: (context, constraints) =>
|
SizedBox(
|
||||||
SingleChildScrollView(
|
key: const Key('native-window-controls-space'),
|
||||||
scrollDirection: Axis.horizontal,
|
width: EditorWindowChrome.leadingWidth,
|
||||||
child: SizedBox(
|
height: headerHeight,
|
||||||
width: constraints.maxWidth.clamp(
|
),
|
||||||
240.0,
|
headerControls,
|
||||||
double.infinity,
|
],
|
||||||
),
|
),
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
if (integratedTitlebar)
|
|
||||||
SizedBox(
|
|
||||||
key: const Key(
|
|
||||||
'native-window-controls-space',
|
|
||||||
),
|
|
||||||
width:
|
|
||||||
EditorWindowChrome.leadingWidth,
|
|
||||||
height: headerHeight,
|
|
||||||
),
|
|
||||||
headerControls,
|
|
||||||
Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: headerInset,
|
|
||||||
),
|
|
||||||
child: projectTabs!,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
if (integratedTitlebar)
|
|
||||||
SizedBox(
|
|
||||||
key: const Key(
|
|
||||||
'native-window-controls-space',
|
|
||||||
),
|
|
||||||
width: EditorWindowChrome.leadingWidth,
|
|
||||||
height: headerHeight,
|
|
||||||
),
|
|
||||||
headerControls,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
headerTrailing,
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -122,109 +66,77 @@ class DesktopWindowFrame extends StatelessWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
key: const Key('desktop-navigation-rail'),
|
key: const Key('desktop-navigation-rail'),
|
||||||
width: railWidth,
|
width: railWidth,
|
||||||
child: LayoutBuilder(
|
child: Padding(
|
||||||
builder: (context, constraints) => SingleChildScrollView(
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
child: ConstrainedBox(
|
child: Column(
|
||||||
constraints: BoxConstraints(
|
children: [
|
||||||
minHeight: constraints.maxHeight,
|
for (final library in [false, true])
|
||||||
),
|
Padding(
|
||||||
child: IntrinsicHeight(
|
padding: const EdgeInsets.only(bottom: 8),
|
||||||
child: Padding(
|
child: IconButton.filledTonal(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
key: ValueKey(
|
||||||
child: Column(
|
library
|
||||||
children: [
|
? 'desktop-rail-library'
|
||||||
IconButton.filledTonal(
|
: 'desktop-rail-cut',
|
||||||
key: const ValueKey('desktop-rail-home'),
|
),
|
||||||
tooltip: context.l10n.navigationHome,
|
tooltip: library
|
||||||
isSelected:
|
? context.l10n.navigationLibrary
|
||||||
!settingsSelected && !workflowSelected,
|
: context.l10n.navigationChat,
|
||||||
style: IconButton.styleFrom(
|
isSelected:
|
||||||
fixedSize: const Size.square(railButtonSize),
|
!settingsSelected && library == librarySelected,
|
||||||
minimumSize: const Size.square(
|
style: IconButton.styleFrom(
|
||||||
railButtonSize,
|
fixedSize: const Size.square(railButtonSize),
|
||||||
),
|
minimumSize: const Size.square(railButtonSize),
|
||||||
maximumSize: const Size.square(
|
maximumSize: const Size.square(railButtonSize),
|
||||||
railButtonSize,
|
padding: EdgeInsets.zero,
|
||||||
),
|
iconSize: railIconSize,
|
||||||
padding: EdgeInsets.zero,
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
iconSize: railIconSize,
|
backgroundColor:
|
||||||
tapTargetSize:
|
!settingsSelected &&
|
||||||
MaterialTapTargetSize.shrinkWrap,
|
library == librarySelected
|
||||||
backgroundColor:
|
? null
|
||||||
settingsSelected || workflowSelected
|
: Colors.transparent,
|
||||||
? Colors.transparent
|
),
|
||||||
: null,
|
onPressed: library
|
||||||
),
|
? onLibraryPressed
|
||||||
onPressed: onHomePressed,
|
: () => onModeChanged(WorkspaceMode.cut),
|
||||||
icon: const Icon(AppIcons.home),
|
icon: Icon(
|
||||||
),
|
library
|
||||||
const SizedBox(height: 8),
|
? Icons.video_library_outlined
|
||||||
IconButton.filledTonal(
|
: Icons.chat_bubble_outline,
|
||||||
key: const ValueKey('desktop-rail-workflow'),
|
),
|
||||||
tooltip: context.l10n.workflow,
|
|
||||||
isSelected: workflowSelected,
|
|
||||||
style: IconButton.styleFrom(
|
|
||||||
fixedSize: const Size.square(railButtonSize),
|
|
||||||
minimumSize: const Size.square(
|
|
||||||
railButtonSize,
|
|
||||||
),
|
|
||||||
maximumSize: const Size.square(
|
|
||||||
railButtonSize,
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
iconSize: railIconSize,
|
|
||||||
tapTargetSize:
|
|
||||||
MaterialTapTargetSize.shrinkWrap,
|
|
||||||
backgroundColor: workflowSelected
|
|
||||||
? null
|
|
||||||
: Colors.transparent,
|
|
||||||
),
|
|
||||||
onPressed: onWorkflowPressed,
|
|
||||||
icon: const Icon(AppIcons.timeline),
|
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
IconButton(
|
|
||||||
key: const Key('desktop-rail-settings'),
|
|
||||||
tooltip: context.l10n.settings,
|
|
||||||
isSelected: settingsSelected,
|
|
||||||
onPressed: onSettingsPressed,
|
|
||||||
style: IconButton.styleFrom(
|
|
||||||
fixedSize: const Size.square(railButtonSize),
|
|
||||||
minimumSize: const Size.square(
|
|
||||||
railButtonSize,
|
|
||||||
),
|
|
||||||
maximumSize: const Size.square(
|
|
||||||
railButtonSize,
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
iconSize: railIconSize,
|
|
||||||
tapTargetSize:
|
|
||||||
MaterialTapTargetSize.shrinkWrap,
|
|
||||||
),
|
|
||||||
icon: const Icon(AppIcons.settings),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const Spacer(),
|
||||||
|
IconButton(
|
||||||
|
key: const Key('project-settings-button'),
|
||||||
|
tooltip: context.l10n.settings,
|
||||||
|
isSelected: settingsSelected,
|
||||||
|
onPressed: onSettingsPressed,
|
||||||
|
style: IconButton.styleFrom(
|
||||||
|
fixedSize: const Size.square(railButtonSize),
|
||||||
|
minimumSize: const Size.square(railButtonSize),
|
||||||
|
maximumSize: const Size.square(railButtonSize),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
iconSize: railIconSize,
|
||||||
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
),
|
||||||
|
icon: const Icon(Icons.settings_outlined),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
left: contentInset,
|
|
||||||
right: contentInset,
|
right: contentInset,
|
||||||
bottom: contentInset,
|
bottom: contentInset,
|
||||||
),
|
),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
key: const Key('desktop-content-container'),
|
key: const Key('desktop-content-container'),
|
||||||
child: WindowHeaderPane(
|
child: WindowHeaderPane(
|
||||||
offset: const Offset(
|
offset: const Offset(railWidth, headerHeight),
|
||||||
railWidth + contentInset,
|
|
||||||
headerHeight,
|
|
||||||
),
|
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) =>
|
builder: (context, constraints) =>
|
||||||
constraints.maxWidth < 200
|
constraints.maxWidth < 200
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import 'dart:math' as math;
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cutdex_ui/theme.dart';
|
|
||||||
import 'package:cutdex_ui/widgets.dart';
|
|
||||||
|
|
||||||
import '../adaptive/desktop_workspace_controller.dart';
|
import '../adaptive/desktop_workspace_controller.dart';
|
||||||
import '../adaptive/workspace_layout_policy.dart';
|
import '../adaptive/workspace_layout_policy.dart';
|
||||||
@@ -31,12 +27,6 @@ class DesktopWorkspaceShell extends StatefulWidget {
|
|||||||
required this.editor,
|
required this.editor,
|
||||||
required this.scaffoldKey,
|
required this.scaffoldKey,
|
||||||
required this.navigationDrawer,
|
required this.navigationDrawer,
|
||||||
this.projectTabsLayout = false,
|
|
||||||
this.timelineHeight,
|
|
||||||
this.onTimelineHeightChanged,
|
|
||||||
this.onJunctionResizeEnd,
|
|
||||||
this.onSidebarResizeEnd,
|
|
||||||
this.sidebarCanExpand = true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
static const gutterWidth = WorkspaceLayoutMetrics.desktopSpacing;
|
static const gutterWidth = WorkspaceLayoutMetrics.desktopSpacing;
|
||||||
@@ -51,54 +41,12 @@ class DesktopWorkspaceShell extends StatefulWidget {
|
|||||||
final Widget editor;
|
final Widget editor;
|
||||||
final GlobalKey<ScaffoldState> scaffoldKey;
|
final GlobalKey<ScaffoldState> scaffoldKey;
|
||||||
final Widget navigationDrawer;
|
final Widget navigationDrawer;
|
||||||
final bool projectTabsLayout;
|
|
||||||
final double? timelineHeight;
|
|
||||||
final ValueChanged<double>? onTimelineHeightChanged;
|
|
||||||
final VoidCallback? onJunctionResizeEnd;
|
|
||||||
final VoidCallback? onSidebarResizeEnd;
|
|
||||||
final bool sidebarCanExpand;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DesktopWorkspaceShell> createState() => _DesktopWorkspaceShellState();
|
State<DesktopWorkspaceShell> createState() => _DesktopWorkspaceShellState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
||||||
double? _sidebarRestoreWidth;
|
|
||||||
bool _sidebarJunctionDragging = false;
|
|
||||||
|
|
||||||
void _startSidebarResize(double width, {bool junction = false}) {
|
|
||||||
_sidebarRestoreWidth = width;
|
|
||||||
if (junction) setState(() => _sidebarJunctionDragging = true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _resizeSidebar(double requestedWidth, double maximum) {
|
|
||||||
if (!widget.sidebarCanExpand || widget.controller.agentFloating) return;
|
|
||||||
if (requestedWidth < WorkspaceLayoutMetrics.sidebarSnapThreshold) {
|
|
||||||
if (!widget.sidebarCollapsed) {
|
|
||||||
final restoreWidth = _sidebarRestoreWidth;
|
|
||||||
if (restoreWidth != null && widget.sidebarWidth != restoreWidth) {
|
|
||||||
widget.onSidebarWidthChanged(restoreWidth);
|
|
||||||
}
|
|
||||||
widget.onSidebarCollapsedChanged(true);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (widget.sidebarCollapsed) widget.onSidebarCollapsedChanged(false);
|
|
||||||
widget.onSidebarWidthChanged(
|
|
||||||
requestedWidth.clamp(WorkspaceLayoutMetrics.sidebarMinimumWidth, maximum),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _finishSidebarResize() {
|
|
||||||
_sidebarRestoreWidth = null;
|
|
||||||
if (_sidebarJunctionDragging) {
|
|
||||||
setState(() => _sidebarJunctionDragging = false);
|
|
||||||
widget.onJunctionResizeEnd?.call();
|
|
||||||
} else {
|
|
||||||
widget.onSidebarResizeEnd?.call();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -110,11 +58,6 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
|||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant DesktopWorkspaceShell oldWidget) {
|
void didUpdateWidget(covariant DesktopWorkspaceShell oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
if (widget.controller.agentFloating ||
|
|
||||||
!widget.sidebarCanExpand ||
|
|
||||||
widget.onTimelineHeightChanged == null) {
|
|
||||||
_sidebarJunctionDragging = false;
|
|
||||||
}
|
|
||||||
if (oldWidget.controller != widget.controller) {
|
if (oldWidget.controller != widget.controller) {
|
||||||
oldWidget.controller.removeListener(_changed);
|
oldWidget.controller.removeListener(_changed);
|
||||||
widget.controller.addListener(_changed);
|
widget.controller.addListener(_changed);
|
||||||
@@ -136,9 +79,6 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
|||||||
required ValueChanged<double> onResize,
|
required ValueChanged<double> onResize,
|
||||||
double direction = 1,
|
double direction = 1,
|
||||||
VoidCallback? onEnd,
|
VoidCallback? onEnd,
|
||||||
VoidCallback? onStart,
|
|
||||||
Set<WorkspaceResizeBoundary> highlightTargets = const {},
|
|
||||||
Offset highlightOffset = Offset.zero,
|
|
||||||
}) => SizedBox(
|
}) => SizedBox(
|
||||||
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
|
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
|
||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
@@ -149,256 +89,62 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
|||||||
direction: direction,
|
direction: direction,
|
||||||
onResize: onResize,
|
onResize: onResize,
|
||||||
onEnd: onEnd,
|
onEnd: onEnd,
|
||||||
onStart: onStart,
|
|
||||||
highlightTargets: highlightTargets,
|
|
||||||
highlightOffset: highlightOffset,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) =>
|
Widget build(BuildContext context) => LayoutBuilder(
|
||||||
WorkspaceResizeHighlightScope(child: _workspace(context));
|
|
||||||
|
|
||||||
Widget _workspace(BuildContext context) => widget.projectTabsLayout
|
|
||||||
? _projectWorkspace(context)
|
|
||||||
: LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
|
||||||
const gap = DesktopWorkspaceShell.gutterWidth;
|
|
||||||
final width = constraints.maxWidth;
|
|
||||||
final requestedFloating = widget.controller.agentFloating;
|
|
||||||
final showAgent =
|
|
||||||
widget.mode == WorkspaceMode.agent ||
|
|
||||||
widget.controller.agentVisible;
|
|
||||||
final navigationGap = widget.sidebarCollapsed ? 0.0 : gap;
|
|
||||||
final resolved = DesktopWorkspaceGeometry.resolve(
|
|
||||||
// The geometry policy accounts for a one-pixel divider; reserve gutters.
|
|
||||||
width: width - navigationGap - gap + 1,
|
|
||||||
mode: requestedFloating || !showAgent
|
|
||||||
? WorkspaceMode.cut
|
|
||||||
: WorkspaceMode.agent,
|
|
||||||
sidebarCollapsed: widget.sidebarCollapsed,
|
|
||||||
sidebarWidth: widget.sidebarWidth,
|
|
||||||
agentWidth: widget.controller.agentWidth,
|
|
||||||
agentFullscreen: widget.controller.agentFullscreen,
|
|
||||||
);
|
|
||||||
final navigationSpace = widget.sidebarCollapsed
|
|
||||||
? 0.0
|
|
||||||
: resolved.sidebarWidth;
|
|
||||||
final floating =
|
|
||||||
requestedFloating ||
|
|
||||||
(showAgent &&
|
|
||||||
widget.mode == WorkspaceMode.cut &&
|
|
||||||
resolved.editorHidden &&
|
|
||||||
!widget.controller.agentFullscreen);
|
|
||||||
final agentHidden =
|
|
||||||
floating ||
|
|
||||||
!showAgent ||
|
|
||||||
resolved.editorHidden &&
|
|
||||||
widget.mode == WorkspaceMode.cut &&
|
|
||||||
!widget.controller.agentFullscreen;
|
|
||||||
final geometry = DesktopWorkspaceGeometry(
|
|
||||||
sidebarWidth: resolved.sidebarWidth,
|
|
||||||
agentWidth: agentHidden
|
|
||||||
? 0
|
|
||||||
: resolved.editorHidden
|
|
||||||
? width - navigationSpace - navigationGap
|
|
||||||
: resolved.agentWidth,
|
|
||||||
editorHidden: resolved.editorHidden && !agentHidden,
|
|
||||||
);
|
|
||||||
final available = width - navigationSpace - navigationGap;
|
|
||||||
void expandEditor() {
|
|
||||||
final collapseNavigation =
|
|
||||||
available <
|
|
||||||
220 + gap + DesktopWorkspaceGeometry.editorMinimumWidth;
|
|
||||||
if (collapseNavigation) widget.onSidebarCollapsedChanged(true);
|
|
||||||
widget.controller.setAgentFullscreen(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void resizeAgent(double requested) {
|
|
||||||
final maximum =
|
|
||||||
available - gap - DesktopWorkspaceGeometry.editorMinimumWidth;
|
|
||||||
if (maximum < 220) return;
|
|
||||||
final agentWidth = requested.clamp(220.0, maximum);
|
|
||||||
widget.controller.setAgentWidth(agentWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
key: widget.scaffoldKey,
|
|
||||||
drawerEnableOpenDragGesture: false,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
drawer: Drawer(
|
|
||||||
width: 320,
|
|
||||||
child: SafeArea(child: widget.navigationDrawer),
|
|
||||||
),
|
|
||||||
body: Stack(
|
|
||||||
key: const Key('desktop-workspace-shell'),
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
|
||||||
if (!widget.sidebarCollapsed) ...[
|
|
||||||
SizedBox(
|
|
||||||
width: navigationSpace,
|
|
||||||
child: _card(
|
|
||||||
'project',
|
|
||||||
widget.sidebarBuilder(geometry, expandEditor),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
key: Key('project-sidebar-divider'),
|
|
||||||
width: gap,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
Expanded(
|
|
||||||
child: Offstage(
|
|
||||||
key: const Key('editor-auto-collapse'),
|
|
||||||
offstage: geometry.editorHidden,
|
|
||||||
child: TickerMode(
|
|
||||||
enabled: !geometry.editorHidden,
|
|
||||||
child: OverflowBox(
|
|
||||||
alignment: Alignment.topLeft,
|
|
||||||
minWidth: geometry.editorHidden
|
|
||||||
? DesktopWorkspaceGeometry.editorRestoreWidth
|
|
||||||
: null,
|
|
||||||
maxWidth: geometry.editorHidden
|
|
||||||
? DesktopWorkspaceGeometry.editorRestoreWidth
|
|
||||||
: null,
|
|
||||||
child: SizedBox(
|
|
||||||
key: const Key('desktop-editor-card'),
|
|
||||||
child: widget.editor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!agentHidden && !geometry.editorHidden)
|
|
||||||
const SizedBox(width: gap),
|
|
||||||
if (!floating)
|
|
||||||
Offstage(
|
|
||||||
offstage: agentHidden,
|
|
||||||
child: ExcludeFocus(
|
|
||||||
excluding: agentHidden,
|
|
||||||
child: TickerMode(
|
|
||||||
enabled: !agentHidden,
|
|
||||||
child: SizedBox(
|
|
||||||
key: const Key('desktop-agent-slot'),
|
|
||||||
width: agentHidden
|
|
||||||
? widget.controller.agentWidth ?? 320
|
|
||||||
: geometry.agentWidth,
|
|
||||||
child: _card(
|
|
||||||
'agent',
|
|
||||||
widget.agentBuilder(geometry, expandEditor),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
if (floating)
|
|
||||||
Positioned(
|
|
||||||
key: const Key('agent-floating-window'),
|
|
||||||
right: 12,
|
|
||||||
bottom: 12,
|
|
||||||
width: math.min(560, math.max(0, available - 24)),
|
|
||||||
child: AppFloatingDialog(
|
|
||||||
key: const Key('floating-agent-dialog'),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(22),
|
|
||||||
),
|
|
||||||
backgroundColor: AppSurfaces.of(context)
|
|
||||||
.composerBackground,
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxHeight: math.min(
|
|
||||||
640,
|
|
||||||
math.max(0, constraints.maxHeight - 24),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: widget.agentBuilder(geometry, expandEditor),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!widget.sidebarCollapsed)
|
|
||||||
Positioned(
|
|
||||||
left:
|
|
||||||
navigationSpace -
|
|
||||||
WorkspaceLayoutMetrics.desktopResizeSlop,
|
|
||||||
top: 0,
|
|
||||||
bottom: 0,
|
|
||||||
child: _gutter(
|
|
||||||
name: 'project-sidebar',
|
|
||||||
initialWidth: navigationSpace,
|
|
||||||
onResize: (value) => widget.onSidebarWidthChanged(
|
|
||||||
value.clamp(
|
|
||||||
WorkspaceLayoutMetrics.sidebarMinimumWidth,
|
|
||||||
DesktopWorkspaceGeometry.sidebarMaximum(
|
|
||||||
width - 2 * gap + 1,
|
|
||||||
WorkspaceMode.agent,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!agentHidden && !geometry.editorHidden)
|
|
||||||
Positioned(
|
|
||||||
left: geometry.editorHidden
|
|
||||||
? navigationSpace +
|
|
||||||
navigationGap +
|
|
||||||
(widget.sidebarCollapsed
|
|
||||||
? 0
|
|
||||||
: WorkspaceLayoutMetrics.desktopResizeSlop)
|
|
||||||
: width -
|
|
||||||
geometry.agentWidth -
|
|
||||||
gap -
|
|
||||||
WorkspaceLayoutMetrics.desktopResizeSlop,
|
|
||||||
top: 0,
|
|
||||||
bottom: 0,
|
|
||||||
child: _gutter(
|
|
||||||
name: 'agent-panel',
|
|
||||||
initialWidth: geometry.agentWidth,
|
|
||||||
direction: -1,
|
|
||||||
onResize: resizeAgent,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget _projectWorkspace(BuildContext context) => LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
const gap = DesktopWorkspaceShell.gutterWidth;
|
const gap = DesktopWorkspaceShell.gutterWidth;
|
||||||
final width = constraints.maxWidth;
|
final width = constraints.maxWidth;
|
||||||
final maximum = WorkspaceLayoutMetrics.sidebarMaximumWidth(width - gap);
|
final navigationGap = widget.sidebarCollapsed ? 0.0 : gap;
|
||||||
final sidebarWidth =
|
final resolved = DesktopWorkspaceGeometry.resolve(
|
||||||
(widget.sidebarWidth ?? WorkspaceLayoutMetrics.sidebarDefaultWidth)
|
// The geometry policy accounts for a one-pixel divider; reserve gutters.
|
||||||
.clamp(WorkspaceLayoutMetrics.sidebarMinimumWidth, maximum)
|
width: width - navigationGap - gap + 1,
|
||||||
.toDouble();
|
mode: WorkspaceMode.agent,
|
||||||
final floating = widget.controller.agentFloating;
|
sidebarCollapsed: widget.sidebarCollapsed,
|
||||||
final collapsed = widget.sidebarCollapsed || floating;
|
sidebarWidth: widget.sidebarWidth,
|
||||||
double resolveTimelineHeight(double? height) =>
|
agentWidth: widget.controller.agentWidth,
|
||||||
WorkspaceLayoutMetrics.resolveTimelineHeight(
|
agentFullscreen: widget.controller.agentFullscreen,
|
||||||
constraints.maxHeight,
|
|
||||||
height,
|
|
||||||
);
|
|
||||||
final timelineHeight = resolveTimelineHeight(widget.timelineHeight);
|
|
||||||
final geometry = DesktopWorkspaceGeometry(
|
|
||||||
sidebarWidth: sidebarWidth,
|
|
||||||
agentWidth: 0,
|
|
||||||
editorHidden: false,
|
|
||||||
);
|
);
|
||||||
|
final navigationSpace = widget.sidebarCollapsed
|
||||||
|
? 0.0
|
||||||
|
: resolved.sidebarWidth;
|
||||||
|
final agentHidden =
|
||||||
|
resolved.editorHidden &&
|
||||||
|
widget.mode == WorkspaceMode.cut &&
|
||||||
|
!widget.controller.agentFullscreen;
|
||||||
|
final geometry = DesktopWorkspaceGeometry(
|
||||||
|
sidebarWidth: resolved.sidebarWidth,
|
||||||
|
agentWidth: agentHidden
|
||||||
|
? 0
|
||||||
|
: resolved.editorHidden
|
||||||
|
? width - navigationSpace - navigationGap
|
||||||
|
: resolved.agentWidth,
|
||||||
|
editorHidden: resolved.editorHidden && !agentHidden,
|
||||||
|
);
|
||||||
|
final available = width - navigationSpace - navigationGap;
|
||||||
|
void expandEditor() {
|
||||||
|
final collapseNavigation =
|
||||||
|
available < 220 + gap + DesktopWorkspaceGeometry.editorMinimumWidth;
|
||||||
|
if (collapseNavigation) widget.onSidebarCollapsedChanged(true);
|
||||||
|
widget.controller.setAgentFullscreen(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resizeAgent(double requested) {
|
||||||
|
final maximum =
|
||||||
|
available - gap - DesktopWorkspaceGeometry.editorMinimumWidth;
|
||||||
|
if (maximum < 220) return;
|
||||||
|
final agentWidth = requested.clamp(220.0, maximum);
|
||||||
|
widget.controller.setAgentWidth(agentWidth);
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: widget.scaffoldKey,
|
key: widget.scaffoldKey,
|
||||||
drawerEnableOpenDragGesture: false,
|
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
drawer: Drawer(
|
drawer: Drawer(
|
||||||
width: 320,
|
width: 320,
|
||||||
child: SafeArea(
|
child: SafeArea(child: widget.navigationDrawer),
|
||||||
// The drawer and floating panel share the conversation widget.
|
|
||||||
child: floating ? const SizedBox.shrink() : widget.navigationDrawer,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
body: Stack(
|
body: Stack(
|
||||||
key: const Key('desktop-workspace-shell'),
|
key: const Key('desktop-workspace-shell'),
|
||||||
@@ -406,107 +152,95 @@ class _DesktopWorkspaceShellState extends State<DesktopWorkspaceShell> {
|
|||||||
Row(
|
Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
if (!collapsed) ...[
|
if (!widget.sidebarCollapsed) ...[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: sidebarWidth,
|
width: navigationSpace,
|
||||||
child: _card(
|
child: _card(
|
||||||
'chat',
|
'project',
|
||||||
widget.sidebarBuilder(geometry, () {}),
|
widget.sidebarBuilder(geometry, expandEditor),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: gap),
|
const SizedBox(
|
||||||
|
key: Key('project-sidebar-divider'),
|
||||||
|
width: gap,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SizedBox(
|
child: Offstage(
|
||||||
key: const Key('desktop-editor-card'),
|
key: const Key('editor-auto-collapse'),
|
||||||
child: widget.editor,
|
offstage: geometry.editorHidden,
|
||||||
|
child: TickerMode(
|
||||||
|
enabled: !geometry.editorHidden,
|
||||||
|
child: OverflowBox(
|
||||||
|
alignment: Alignment.topLeft,
|
||||||
|
minWidth: geometry.editorHidden
|
||||||
|
? DesktopWorkspaceGeometry.editorRestoreWidth
|
||||||
|
: null,
|
||||||
|
maxWidth: geometry.editorHidden
|
||||||
|
? DesktopWorkspaceGeometry.editorRestoreWidth
|
||||||
|
: null,
|
||||||
|
child: SizedBox(
|
||||||
|
key: const Key('desktop-editor-card'),
|
||||||
|
child: widget.editor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (!agentHidden && !geometry.editorHidden)
|
||||||
|
const SizedBox(width: gap),
|
||||||
|
if (!agentHidden)
|
||||||
|
SizedBox(
|
||||||
|
key: const Key('desktop-agent-slot'),
|
||||||
|
width: geometry.agentWidth,
|
||||||
|
child: _card(
|
||||||
|
'agent',
|
||||||
|
widget.agentBuilder(geometry, expandEditor),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (!floating &&
|
if (!widget.sidebarCollapsed)
|
||||||
widget.sidebarCanExpand &&
|
|
||||||
WorkspaceLayoutPolicy.desktopNavigationFits(width))
|
|
||||||
Positioned(
|
Positioned(
|
||||||
left: collapsed
|
left:
|
||||||
? 0
|
navigationSpace - WorkspaceLayoutMetrics.desktopResizeSlop,
|
||||||
: sidebarWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
|
|
||||||
top: 0,
|
top: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
child: _gutter(
|
child: _gutter(
|
||||||
name: 'project-sidebar',
|
name: 'project-sidebar',
|
||||||
highlightTargets: const {WorkspaceResizeBoundary.sidebar},
|
initialWidth: navigationSpace,
|
||||||
highlightOffset: collapsed
|
onResize: (value) => widget.onSidebarWidthChanged(
|
||||||
? const Offset(
|
value.clamp(
|
||||||
-WorkspaceLayoutMetrics.desktopResizeHitExtent / 2,
|
WorkspaceLayoutMetrics.sidebarMinimumWidth,
|
||||||
0,
|
DesktopWorkspaceGeometry.sidebarMaximum(
|
||||||
)
|
width - 2 * gap + 1,
|
||||||
: Offset.zero,
|
WorkspaceMode.agent,
|
||||||
initialWidth: collapsed ? 0 : sidebarWidth,
|
|
||||||
onStart: () => _startSidebarResize(sidebarWidth),
|
|
||||||
onResize: (value) => _resizeSidebar(value, maximum),
|
|
||||||
onEnd: _finishSidebarResize,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!floating &&
|
|
||||||
widget.sidebarCanExpand &&
|
|
||||||
WorkspaceLayoutPolicy.desktopNavigationFits(width) &&
|
|
||||||
widget.onTimelineHeightChanged != null)
|
|
||||||
Positioned(
|
|
||||||
left: collapsed
|
|
||||||
? 0
|
|
||||||
: sidebarWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
|
|
||||||
bottom:
|
|
||||||
timelineHeight - WorkspaceLayoutMetrics.desktopResizeSlop,
|
|
||||||
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
|
|
||||||
height: WorkspaceLayoutMetrics.desktopResizeHitExtent,
|
|
||||||
child: WorkspaceResizeHandle.junction(
|
|
||||||
key: const Key('desktop-chat-timeline-junction'),
|
|
||||||
highlightOffset: collapsed
|
|
||||||
? const Offset(
|
|
||||||
-WorkspaceLayoutMetrics.desktopResizeHitExtent / 2,
|
|
||||||
0,
|
|
||||||
)
|
|
||||||
: Offset.zero,
|
|
||||||
highlightTargets: const {
|
|
||||||
WorkspaceResizeBoundary.sidebar,
|
|
||||||
WorkspaceResizeBoundary.timeline,
|
|
||||||
},
|
|
||||||
initialWidth: collapsed ? 0 : sidebarWidth,
|
|
||||||
initialHeight: timelineHeight,
|
|
||||||
verticalDirection: -1,
|
|
||||||
onStart: () =>
|
|
||||||
_startSidebarResize(sidebarWidth, junction: true),
|
|
||||||
onWidthChanged: (value) => _resizeSidebar(value, maximum),
|
|
||||||
onHeightChanged: (value) => widget.onTimelineHeightChanged!(
|
|
||||||
resolveTimelineHeight(value),
|
|
||||||
),
|
|
||||||
onEnd: _finishSidebarResize,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (floating)
|
|
||||||
Positioned(
|
|
||||||
key: const Key('agent-floating-window'),
|
|
||||||
right: 12,
|
|
||||||
bottom: 12,
|
|
||||||
width: math.min(560, math.max(0, width - 24)),
|
|
||||||
child: AppFloatingDialog(
|
|
||||||
key: const Key('floating-agent-dialog'),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(22),
|
|
||||||
),
|
|
||||||
backgroundColor: AppSurfaces.of(context).composerBackground,
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxHeight: math.min(
|
|
||||||
640,
|
|
||||||
math.max(0, constraints.maxHeight - 24),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: widget.agentBuilder(geometry, () {}),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (!agentHidden && !geometry.editorHidden)
|
||||||
|
Positioned(
|
||||||
|
left: geometry.editorHidden
|
||||||
|
? navigationSpace +
|
||||||
|
navigationGap +
|
||||||
|
(widget.sidebarCollapsed
|
||||||
|
? 0
|
||||||
|
: WorkspaceLayoutMetrics.desktopResizeSlop)
|
||||||
|
: width -
|
||||||
|
geometry.agentWidth -
|
||||||
|
gap -
|
||||||
|
WorkspaceLayoutMetrics.desktopResizeSlop,
|
||||||
|
top: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: _gutter(
|
||||||
|
name: 'agent-panel',
|
||||||
|
initialWidth: geometry.agentWidth,
|
||||||
|
direction: -1,
|
||||||
|
onResize: resizeAgent,
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../l10n/l10n.dart';
|
import '../../l10n/l10n.dart';
|
||||||
@@ -44,12 +43,12 @@ class PhoneWorkspaceShell extends StatelessWidget {
|
|||||||
destinations: [
|
destinations: [
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
key: const Key('workspace-agent-destination'),
|
key: const Key('workspace-agent-destination'),
|
||||||
icon: const Icon(AppIcons.chat),
|
icon: const Icon(Icons.chat_bubble_outline),
|
||||||
label: context.l10n.workspaceAgent,
|
label: context.l10n.workspaceAgent,
|
||||||
),
|
),
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
key: const Key('workspace-cut-destination'),
|
key: const Key('workspace-cut-destination'),
|
||||||
icon: const Icon(AppIcons.video),
|
icon: const Icon(Icons.movie_outlined),
|
||||||
label: context.l10n.workspaceCut,
|
label: context.l10n.workspaceCut,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../l10n/l10n.dart';
|
import '../../l10n/l10n.dart';
|
||||||
@@ -56,14 +55,14 @@ class TabletWorkspaceShell extends StatelessWidget {
|
|||||||
destinations: [
|
destinations: [
|
||||||
NavigationRailDestination(
|
NavigationRailDestination(
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
AppIcons.chat,
|
Icons.chat_bubble_outline,
|
||||||
key: Key('workspace-agent-destination'),
|
key: Key('workspace-agent-destination'),
|
||||||
),
|
),
|
||||||
label: Text(context.l10n.workspaceAgent),
|
label: Text(context.l10n.workspaceAgent),
|
||||||
),
|
),
|
||||||
NavigationRailDestination(
|
NavigationRailDestination(
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
AppIcons.video,
|
Icons.movie_outlined,
|
||||||
key: Key('workspace-cut-destination'),
|
key: Key('workspace-cut-destination'),
|
||||||
),
|
),
|
||||||
label: Text(context.l10n.workspaceCut),
|
label: Text(context.l10n.workspaceCut),
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../integrations/platform/editor_window_chrome.dart';
|
import '../../integrations/platform/editor_window_chrome.dart';
|
||||||
@@ -46,7 +45,7 @@ class WorkspaceFrame extends StatelessWidget {
|
|||||||
key: const Key('workspace-navigation-button'),
|
key: const Key('workspace-navigation-button'),
|
||||||
tooltip: context.l10n.expandSidebar,
|
tooltip: context.l10n.expandSidebar,
|
||||||
onPressed: () => Scaffold.of(context).openDrawer(),
|
onPressed: () => Scaffold.of(context).openDrawer(),
|
||||||
icon: const Icon(AppIcons.menu),
|
icon: const Icon(Icons.menu),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:cutdex_native/cutdex_native.dart';
|
import 'package:cutdex_native/cutdex_native.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
// Opt-in profiler of the existing full app; normal launches do no benchmark work.
|
|
||||||
import 'dart:async';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'full_app_viewport_bench/config.dart';
|
|
||||||
import 'full_app_viewport_bench/runner.dart';
|
|
||||||
|
|
||||||
void startFullAppViewportBenchFromEnvironment() {
|
|
||||||
final output = Platform.environment['CUTDEX_FULL_APP_VIEWPORT_BENCH'];
|
|
||||||
if (output == null || output.isEmpty) return;
|
|
||||||
unawaited(_start(output));
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _start(String output) async {
|
|
||||||
try {
|
|
||||||
await runFullAppViewportBench(
|
|
||||||
ViewportBenchConfig.fromEnvironment(Platform.environment),
|
|
||||||
);
|
|
||||||
} catch (error, stack) {
|
|
||||||
final directory = Directory(output);
|
|
||||||
await directory.create(recursive: true);
|
|
||||||
await File('${directory.path}/error.txt').writeAsString('$error\n$stack');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
# 完整编辑器拖拽实测
|
|
||||||
|
|
||||||
没有 `CUTDEX_FULL_APP_VIEWPORT_BENCH` 时入口立即返回。启用后使用正常持久化项目和时间线,通过真实播放头手势进入生产预览链路;不会加载素材夹具或替换页面。请先在正常编辑器打开待测素材所在的时间线并暂停播放。
|
|
||||||
|
|
||||||
代码职责:`config.dart` 校验配置,`workload.dart` 生成目标轨迹,`drag.dart` 投递实际手势并验证播放头,`diagnostics.dart` 校准 QPC/采样,`records.dart` 写出证据,`capture.dart` 管理可选捕获进程,`runner.dart` 编排和验证停止。
|
|
||||||
|
|
||||||
以下变量统一加 `CUTDEX_FULL_APP_VIEWPORT_` 前缀:
|
|
||||||
|
|
||||||
| 后缀 | 默认/含义 |
|
|
||||||
|---|---|
|
|
||||||
| `BENCH` | 必填输出目录;每次使用新目录 |
|
|
||||||
| `START_GATE` | 可选门文件路径;正常项目加载后创建文件,最多等待120秒 |
|
|
||||||
| `EXPECTED_FRAMES` | 可选预期时间线长度,容差2帧;未指定时从实际时间线读取 |
|
|
||||||
| `TIMELINE_FPS` | 30;目标坐标的时间基准,不是源视频帧率 |
|
|
||||||
| `ROUNDS` | 5 |
|
|
||||||
| `PAIRED` | 0;设为1比较全片5%–95%往返和局部往返 |
|
|
||||||
| `INPUT_HZ` / `INPUT_COUNT` | 60 / 360;配对模式每场景6秒,输入数量必须是至少6的偶数 |
|
|
||||||
| `LOCAL_START_FRAME` | 实际时间线长度的28%;可指定复现旧测试位置 |
|
|
||||||
| `LOCAL_SPAN_FRAMES` / `LOCAL_PIXELS_PER_FRAME` | 20 / 4 |
|
|
||||||
| `EDGE_MARGIN_FRAMES` | 900;旧五场景模式首尾边距,也用于检查时间线足够长;短素材需缩小 |
|
|
||||||
| `SAMPLE_INTERVAL_MS` | 16 |
|
|
||||||
| `NATIVE_ONLY` | 1;采样原生提交,不捕获桌面 |
|
|
||||||
| `CAPTURE_HELPER` | `NATIVE_ONLY=0` 时必填捕获工具绝对路径 |
|
|
||||||
| `SILENT` | 0;保持生产 audible policy,设为1仅用于明确要求的静音对照 |
|
|
||||||
|
|
||||||
MIDE旧测试配置:`PAIRED=1`、`ROUNDS=3`、`EXPECTED_FRAMES=214073.82`、`LOCAL_START_FRAME=60137`、`NATIVE_ONLY=1`,其余保持默认。
|
|
||||||
|
|
||||||
输出保留 `inputs.csv`、`phases.csv`、`native-samples.jsonl`、`meta.json` 和 `progress.json` 的既有字段,`meta.json.configuration` 增加实际配置。停止仅等待已有请求完成,不发出额外定位;最终时钟必须命中最后目标,之后观察冻结窗口。通过状态在采样与文件流完成后写出,异常写入 `error.txt`。
|
|
||||||
|
|
||||||
输入/阶段CSV里的帧数使用配置的时间基准。兼容元数据中名字含 `At30Hz` 的字段仍换算为30Hz。原生提交数不能当作DWM屏幕扫描帧数;正式分析还须校验GPU、输出尺寸、冻结期间源帧计数和最终提交相对松手的时刻。
|
|
||||||
|
|
||||||
## 时间线切换实测
|
|
||||||
|
|
||||||
`main.dart` 提供独立、默认关闭的完整应用切换测试,实现在
|
|
||||||
`../timeline_switch_bench.dart`。启动正常 Profile 程序前,将
|
|
||||||
`CUTDEX_TIMELINE_SWITCH_BENCH` 设置为新的输出目录。测试保持生产 provider
|
|
||||||
和编辑页面,通过 `GestureBinding` 点击真实时间线标签,输出
|
|
||||||
`results.json` 和 `done.json`。
|
|
||||||
|
|
||||||
初始时间线必须不同于 `CUTDEX_TIMELINE_SWITCH_TARGET`;不设置时选择项目中
|
|
||||||
第一个非当前时间线,因此项目至少需要两条时间线。测试等待初始预览控制器
|
|
||||||
完成初始化。可选的 `CUTDEX_TIMELINE_SWITCH_GATE` 文件允许先检查正常工作区,
|
|
||||||
创建该文件后才开始测量。`CUTDEX_TIMELINE_SWITCH_RAPID=1` 改为连续点击五次,
|
|
||||||
每次计划间隔 16 ms,并在最后一次点击后观察五秒,验证最新选择不被旧请求覆盖;
|
|
||||||
输出为 `rapid.json`。
|
|
||||||
|
|
||||||
UI 耗时记录到目标工作区的 post-frame 回调,数据耗时记录到 `Projects` 发布
|
|
||||||
准备好的文档。原生首帧采用异步 20 ms 诊断轮询,因此记录的是首次观察耗时;
|
|
||||||
缓存时间线的原生计数表示复用已有帧。首次打开对照必须使用新进程和未缓存的
|
|
||||||
目标会话。启动出错或正常切换测试缺少原生帧均判失败;`startup.json` 记录
|
|
||||||
初始状态。快速切换模式验证状态一致性,未单独计时原生首帧。普通启动应清除
|
|
||||||
上述测试环境变量。
|
|
||||||
|
|
||||||
## 触摸板缩放回放与驱动事件
|
|
||||||
|
|
||||||
`../timeline_gesture_bench.dart` 提供默认关闭的完整应用手势回放。启动正常
|
|
||||||
Profile 程序前设置 `CUTDEX_TIMELINE_GESTURE_BENCH` 为新输出目录,测试等待
|
|
||||||
六秒后向当前时间线发送原生 pan/zoom 协议及 Ctrl+滚轮输入。播放头应在
|
|
||||||
viewport 内,键盘修饰键应松开。输入走正常命中测试和手势识别路径,输出
|
|
||||||
`results.json`、`done.json`;异常输出 `error.txt`。回放结束恢复原相机,
|
|
||||||
不定位播放头、不修改时间线文档。回放不等同于物理触摸板操作。
|
|
||||||
|
|
||||||
可独立设置 `CUTDEX_TIMELINE_GESTURE_TRACE` 为 JSONL 文件路径,记录实际
|
|
||||||
`PointerPanZoom` 与 `PointerScroll` 事件以及 Ctrl/Meta 状态。`source` 区分
|
|
||||||
`protocol-replay` 与 `driver`,回放使用 device 7200。记录默认关闭,启用时
|
|
||||||
每秒刷新文件,可用于确认驱动是发送合并的 pan/scale,还是兼容滚轮输入。
|
|
||||||
普通启动应清除这两个环境变量。
|
|
||||||
|
|
||||||
独立测试入口 `tool/windows/native_preview_bench.dart` 要求显式设置
|
|
||||||
`CUTDEX_BENCH_SOURCE`、`CUTDEX_BENCH_DURATION_FRAMES`(30 Hz 时基下的正整数
|
|
||||||
时长)和 `CUTDEX_BENCH_CAPTURE_HELPER`;素材及桌面捕获工具保留在仓库外。
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'config.dart';
|
|
||||||
|
|
||||||
/// Optional desktop capture process; its path is supplied explicitly.
|
|
||||||
class BenchCapture {
|
|
||||||
BenchCapture._(this.output, this.process);
|
|
||||||
final Directory output;
|
|
||||||
final Process process;
|
|
||||||
|
|
||||||
static Future<BenchCapture?> start(
|
|
||||||
ViewportBenchConfig config,
|
|
||||||
Directory output,
|
|
||||||
) async {
|
|
||||||
if (config.nativeOnly) return null;
|
|
||||||
final helper = config.captureHelper!;
|
|
||||||
final probe = await Process.run(helper, ['$pid']);
|
|
||||||
if (probe.exitCode != 0) {
|
|
||||||
throw StateError('Capture probe failed: ${probe.stderr}');
|
|
||||||
}
|
|
||||||
final line = probe.stdout
|
|
||||||
.toString()
|
|
||||||
.split('\n')
|
|
||||||
.singleWhere((s) => s.startsWith('CutdexD3D11Preview 1 '));
|
|
||||||
final rect = line.trim().split(' ').skip(2).map(int.parse).toList();
|
|
||||||
final process = await Process.start(helper, [
|
|
||||||
output.path,
|
|
||||||
'$pid',
|
|
||||||
'${rect[0] + 8}',
|
|
||||||
'${rect[1] + 8}',
|
|
||||||
'${rect[2] - 8}',
|
|
||||||
'${rect[3] - 8}',
|
|
||||||
]);
|
|
||||||
unawaited(process.stdout.drain<void>());
|
|
||||||
unawaited(process.stderr.drain<void>());
|
|
||||||
final capture = BenchCapture._(output, process);
|
|
||||||
for (
|
|
||||||
var i = 0;
|
|
||||||
!await File('${output.path}/capture-ready').exists() && i < 500;
|
|
||||||
i++
|
|
||||||
) {
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 10));
|
|
||||||
}
|
|
||||||
if (!await File('${output.path}/capture-ready').exists()) {
|
|
||||||
await capture.stop();
|
|
||||||
throw StateError('Capture not ready');
|
|
||||||
}
|
|
||||||
return capture;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> stop() async {
|
|
||||||
await File('${output.path}/capture-stop').writeAsString('stop');
|
|
||||||
try {
|
|
||||||
final code = await process.exitCode.timeout(const Duration(seconds: 10));
|
|
||||||
if (code != 0) throw StateError('Capture exit $code');
|
|
||||||
} on TimeoutException {
|
|
||||||
process.kill();
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
/// Explicit inputs for the opt-in full-editor benchmark.
|
|
||||||
class ViewportBenchConfig {
|
|
||||||
ViewportBenchConfig.fromEnvironment(Map<String, String> environment)
|
|
||||||
: outputPath = environment['CUTDEX_FULL_APP_VIEWPORT_BENCH']!,
|
|
||||||
startGate = environment['CUTDEX_FULL_APP_VIEWPORT_START_GATE'],
|
|
||||||
expectedFrames = _number(environment, 'EXPECTED_FRAMES'),
|
|
||||||
rounds = _integer(environment, 'ROUNDS', 5),
|
|
||||||
paired = _flag(environment, 'PAIRED', false),
|
|
||||||
silent = _flag(environment, 'SILENT', false),
|
|
||||||
nativeOnly = _flag(environment, 'NATIVE_ONLY', true),
|
|
||||||
captureHelper = environment['CUTDEX_FULL_APP_VIEWPORT_CAPTURE_HELPER'],
|
|
||||||
timelineFps = _integer(environment, 'TIMELINE_FPS', 30),
|
|
||||||
inputHz = _integer(environment, 'INPUT_HZ', 60),
|
|
||||||
inputCount = _integer(environment, 'INPUT_COUNT', 360),
|
|
||||||
localStartFrame = _optionalInteger(environment, 'LOCAL_START_FRAME'),
|
|
||||||
localSpanFrames = _integer(environment, 'LOCAL_SPAN_FRAMES', 20),
|
|
||||||
localPixelsPerFrame = _number(environment, 'LOCAL_PIXELS_PER_FRAME') ?? 4,
|
|
||||||
edgeMarginFrames = _integer(environment, 'EDGE_MARGIN_FRAMES', 900),
|
|
||||||
sampleIntervalMs = _integer(environment, 'SAMPLE_INTERVAL_MS', 16) {
|
|
||||||
if (outputPath.isEmpty ||
|
|
||||||
rounds < 1 ||
|
|
||||||
timelineFps < 1 ||
|
|
||||||
inputHz < 1 ||
|
|
||||||
inputCount < 6 ||
|
|
||||||
inputCount.isOdd ||
|
|
||||||
localSpanFrames < 1 ||
|
|
||||||
localPixelsPerFrame <= 0 ||
|
|
||||||
edgeMarginFrames < 1 ||
|
|
||||||
sampleIntervalMs < 1 ||
|
|
||||||
(expectedFrames != null && expectedFrames! <= 0)) {
|
|
||||||
throw ArgumentError('Invalid viewport benchmark configuration');
|
|
||||||
}
|
|
||||||
if (!nativeOnly && (captureHelper == null || captureHelper!.isEmpty)) {
|
|
||||||
throw ArgumentError('CAPTURE_HELPER is required when NATIVE_ONLY=0');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final String outputPath;
|
|
||||||
final String? startGate;
|
|
||||||
final double? expectedFrames;
|
|
||||||
final int rounds, timelineFps, inputHz, inputCount, localSpanFrames;
|
|
||||||
final int edgeMarginFrames, sampleIntervalMs;
|
|
||||||
final int? localStartFrame;
|
|
||||||
final double localPixelsPerFrame;
|
|
||||||
final bool paired, silent, nativeOnly;
|
|
||||||
final String? captureHelper;
|
|
||||||
|
|
||||||
Map<String, Object?> toJson() => {
|
|
||||||
'expectedFrames': expectedFrames,
|
|
||||||
'rounds': rounds,
|
|
||||||
'paired': paired,
|
|
||||||
'timelineFps': timelineFps,
|
|
||||||
'inputHz': inputHz,
|
|
||||||
'inputCount': inputCount,
|
|
||||||
'localStartFrame': localStartFrame,
|
|
||||||
'localSpanFrames': localSpanFrames,
|
|
||||||
'localPixelsPerFrame': localPixelsPerFrame,
|
|
||||||
'edgeMarginFrames': edgeMarginFrames,
|
|
||||||
'sampleIntervalMs': sampleIntervalMs,
|
|
||||||
'nativeOnly': nativeOnly,
|
|
||||||
'captureHelper': captureHelper,
|
|
||||||
'silent': silent,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int _integer(Map<String, String> env, String key, int fallback) =>
|
|
||||||
_optionalInteger(env, key) ?? fallback;
|
|
||||||
static int? _optionalInteger(Map<String, String> env, String key) {
|
|
||||||
final value = env['CUTDEX_FULL_APP_VIEWPORT_$key'];
|
|
||||||
return value == null ? null : int.parse(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static double? _number(Map<String, String> env, String key) {
|
|
||||||
final value = env['CUTDEX_FULL_APP_VIEWPORT_$key'];
|
|
||||||
if (value == null) return null;
|
|
||||||
final number = double.parse(value);
|
|
||||||
if (!number.isFinite) throw ArgumentError('Non-finite $key');
|
|
||||||
return number;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool _flag(Map<String, String> env, String key, bool fallback) {
|
|
||||||
final value = env['CUTDEX_FULL_APP_VIEWPORT_$key'];
|
|
||||||
return switch (value) {
|
|
||||||
null => fallback,
|
|
||||||
'1' => true,
|
|
||||||
'0' => false,
|
|
||||||
_ => throw ArgumentError('$key must be 0 or 1'),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
|
||||||
|
|
||||||
/// Native QPC clock calibration and bounded asynchronous diagnostics sampling.
|
|
||||||
class BenchDiagnostics {
|
|
||||||
BenchDiagnostics(this.session, this.clock);
|
|
||||||
final RuntimeSession session;
|
|
||||||
final Stopwatch clock;
|
|
||||||
double uncertaintyMs = double.infinity, _offset = 0;
|
|
||||||
Timer? _timer;
|
|
||||||
Future<void>? _pending;
|
|
||||||
Object? _sampleError;
|
|
||||||
|
|
||||||
double now() => _offset + clock.elapsedMicroseconds / 1000;
|
|
||||||
Future<Map<String, Object?>> read() => session.previewDiagnostics();
|
|
||||||
|
|
||||||
Future<void> calibrate() async {
|
|
||||||
for (var i = 0; i < 20; i++) {
|
|
||||||
final begin = clock.elapsedMicroseconds / 1000;
|
|
||||||
final diagnostic = await read();
|
|
||||||
final end = clock.elapsedMicroseconds / 1000;
|
|
||||||
if (end - begin < uncertaintyMs) {
|
|
||||||
uncertaintyMs = end - begin;
|
|
||||||
_offset = (diagnostic['qpcMs'] as num).toDouble() - (begin + end) / 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> until(double due) async {
|
|
||||||
while (now() < due) {
|
|
||||||
await Future<void>.delayed(
|
|
||||||
Duration(microseconds: ((due - now()) * 1000).ceil().clamp(1, 1000000)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void startSamples(IOSink sink, int intervalMs) {
|
|
||||||
_timer = Timer.periodic(Duration(milliseconds: intervalMs), (_) {
|
|
||||||
if (_pending != null || _sampleError != null) return;
|
|
||||||
_pending = _sample(sink).whenComplete(() => _pending = null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _sample(IOSink sink) async {
|
|
||||||
try {
|
|
||||||
sink.writeln(jsonEncode(await read()));
|
|
||||||
} catch (error) {
|
|
||||||
_sampleError = error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void check() {
|
|
||||||
if (_sampleError != null) {
|
|
||||||
throw StateError('Native sampler failed: $_sampleError');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> stopSamples() async {
|
|
||||||
_timer?.cancel();
|
|
||||||
await _pending;
|
|
||||||
check();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
import 'package:cutdex_core/timeline/model.dart';
|
|
||||||
import 'package:cutdex_core/timeline/layout.dart';
|
|
||||||
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
|
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
|
|
||||||
/// Real playhead gesture input, quantized to physical pixels like desktop input.
|
|
||||||
class BenchPlayheadDrag {
|
|
||||||
BenchPlayheadDrag({
|
|
||||||
required this.view,
|
|
||||||
required this.ruler,
|
|
||||||
required this.viewport,
|
|
||||||
required this.scale,
|
|
||||||
required this.clock,
|
|
||||||
required this.pointer,
|
|
||||||
required this.warmFrame,
|
|
||||||
required this.fps,
|
|
||||||
}) : camera = view.camera;
|
|
||||||
final TimelineViewController view;
|
|
||||||
final RenderBox ruler;
|
|
||||||
final TimelineViewportRect viewport;
|
|
||||||
final TimelineCamera camera;
|
|
||||||
final double scale;
|
|
||||||
final Stopwatch clock;
|
|
||||||
final int pointer, warmFrame, fps;
|
|
||||||
Offset _position = Offset.zero, _origin = Offset.zero;
|
|
||||||
bool _active = false;
|
|
||||||
|
|
||||||
int tick(int frame) =>
|
|
||||||
TimelineClock.standard.toTicks(RationalTime(frame, fps));
|
|
||||||
double get _pixelsPerFrame => camera.pixelsPerTick * tick(1);
|
|
||||||
int _delta(int frame) =>
|
|
||||||
((frame - warmFrame) * _pixelsPerFrame * scale).round();
|
|
||||||
int target(int frame) =>
|
|
||||||
(warmFrame + _delta(frame) / (_pixelsPerFrame * scale)).round();
|
|
||||||
|
|
||||||
Future<void> begin() async {
|
|
||||||
final point = ruler.localToGlobal(
|
|
||||||
Offset(
|
|
||||||
camera.screenXForTick(tick(warmFrame), viewport),
|
|
||||||
ruler.size.height / 2,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
_position = Offset(
|
|
||||||
(point.dx * scale).round() / scale,
|
|
||||||
(point.dy * scale).round() / scale,
|
|
||||||
);
|
|
||||||
GestureBinding.instance.handlePointerEvent(
|
|
||||||
PointerAddedEvent(
|
|
||||||
pointer: pointer,
|
|
||||||
device: 42,
|
|
||||||
kind: PointerDeviceKind.mouse,
|
|
||||||
position: _position,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
GestureBinding.instance.handlePointerEvent(
|
|
||||||
PointerDownEvent(
|
|
||||||
pointer: pointer,
|
|
||||||
device: 42,
|
|
||||||
kind: PointerDeviceKind.mouse,
|
|
||||||
buttons: kPrimaryButton,
|
|
||||||
position: _position,
|
|
||||||
timeStamp: clock.elapsed,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
_active = true;
|
|
||||||
_move(_position + const Offset(40, 0));
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 20));
|
|
||||||
if (!view.isScrubbing || view.playheadTick != tick(warmFrame)) {
|
|
||||||
throw StateError('Playhead drag warmup failed');
|
|
||||||
}
|
|
||||||
_origin = _position;
|
|
||||||
}
|
|
||||||
|
|
||||||
void moveTo(int frame) {
|
|
||||||
_move(_origin + Offset(_delta(frame) / scale, 0));
|
|
||||||
if (!view.isScrubbing || view.playheadTick != tick(target(frame))) {
|
|
||||||
throw StateError('Real playhead mismatch at input frame $frame');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _move(Offset next) {
|
|
||||||
GestureBinding.instance.handlePointerEvent(
|
|
||||||
PointerMoveEvent(
|
|
||||||
pointer: pointer,
|
|
||||||
device: 42,
|
|
||||||
kind: PointerDeviceKind.mouse,
|
|
||||||
buttons: kPrimaryButton,
|
|
||||||
position: next,
|
|
||||||
delta: next - _position,
|
|
||||||
timeStamp: clock.elapsed,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
_position = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
void end() {
|
|
||||||
GestureBinding.instance.handlePointerEvent(
|
|
||||||
PointerUpEvent(
|
|
||||||
pointer: pointer,
|
|
||||||
device: 42,
|
|
||||||
kind: PointerDeviceKind.mouse,
|
|
||||||
position: _position,
|
|
||||||
timeStamp: clock.elapsed,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
_remove();
|
|
||||||
if (view.isScrubbing || !identical(camera, view.camera)) {
|
|
||||||
throw StateError('Release/camera failure');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cancel() {
|
|
||||||
if (!_active) return;
|
|
||||||
GestureBinding.instance.handlePointerEvent(
|
|
||||||
PointerCancelEvent(
|
|
||||||
pointer: pointer,
|
|
||||||
device: 42,
|
|
||||||
kind: PointerDeviceKind.mouse,
|
|
||||||
position: _position,
|
|
||||||
timeStamp: clock.elapsed,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
_remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _remove() {
|
|
||||||
GestureBinding.instance.handlePointerEvent(
|
|
||||||
PointerRemovedEvent(
|
|
||||||
pointer: pointer,
|
|
||||||
device: 42,
|
|
||||||
kind: PointerDeviceKind.mouse,
|
|
||||||
position: _position,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
_active = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
/// Owns benchmark output streams and metadata, preserving the existing CSV schema.
|
|
||||||
class BenchRecords {
|
|
||||||
BenchRecords(this.output)
|
|
||||||
: inputs = File('${output.path}/inputs.csv').openWrite(),
|
|
||||||
phases = File('${output.path}/phases.csv').openWrite(),
|
|
||||||
samples = File('${output.path}/native-samples.jsonl').openWrite() {
|
|
||||||
inputs.writeln(
|
|
||||||
'round,scenario,index,target,qpc_ms,scheduled_ms,request_ms',
|
|
||||||
);
|
|
||||||
phases.writeln(
|
|
||||||
'round,scenario,start_ms,end_ms,release_begin_ms,final_frame,final_clock_frame,freeze_begin_ms,freeze_end_ms',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final Directory output;
|
|
||||||
final IOSink inputs, phases, samples;
|
|
||||||
Future<void>? _closing;
|
|
||||||
final stages = <Map<String, Object?>>[], checks = <Map<String, Object?>>[];
|
|
||||||
|
|
||||||
void input(
|
|
||||||
int round,
|
|
||||||
int scenario,
|
|
||||||
int index,
|
|
||||||
int target,
|
|
||||||
double begin,
|
|
||||||
double due,
|
|
||||||
double returned,
|
|
||||||
) => inputs.writeln(
|
|
||||||
'$round,$scenario,$index,$target,$begin,$due,${returned - begin}',
|
|
||||||
);
|
|
||||||
void phase(
|
|
||||||
int round,
|
|
||||||
int scenario,
|
|
||||||
double start,
|
|
||||||
double end,
|
|
||||||
double release,
|
|
||||||
int finalFrame,
|
|
||||||
double actual,
|
|
||||||
double frozenBegin,
|
|
||||||
double frozenEnd,
|
|
||||||
) => phases.writeln(
|
|
||||||
'$round,$scenario,$start,$end,$release,$finalFrame,$actual,$frozenBegin,$frozenEnd',
|
|
||||||
);
|
|
||||||
Future<void> progress(int round) =>
|
|
||||||
File('${output.path}/progress.json')
|
|
||||||
.writeAsString(jsonEncode({'completedRounds': round}));
|
|
||||||
Future<void> complete(Map<String, Object?> metadata) =>
|
|
||||||
File('${output.path}/meta.json').writeAsString(
|
|
||||||
jsonEncode({
|
|
||||||
...metadata,
|
|
||||||
'nativeDiagnostics': stages,
|
|
||||||
'checks': checks,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
Future<void> close() => _closing ??= _close();
|
|
||||||
|
|
||||||
Future<void> _close() async {
|
|
||||||
await samples.close();
|
|
||||||
await inputs.close();
|
|
||||||
await phases.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,259 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:cutdex/features/preview/preview_panel.dart';
|
|
||||||
import 'package:cutdex_core/editor.dart';
|
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
|
||||||
import 'package:cutdex_core/timeline/layout.dart';
|
|
||||||
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import 'capture.dart';
|
|
||||||
import 'config.dart';
|
|
||||||
import 'diagnostics.dart';
|
|
||||||
import 'drag.dart';
|
|
||||||
import 'records.dart';
|
|
||||||
import 'workload.dart';
|
|
||||||
|
|
||||||
Future<void> _sleep(int ms) => Future<void>.delayed(Duration(milliseconds: ms));
|
|
||||||
|
|
||||||
/// Orchestrates existing editor state, real input, exact-stop validation and output.
|
|
||||||
Future<void> runFullAppViewportBench(ViewportBenchConfig config) async {
|
|
||||||
final output = Directory(config.outputPath);
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
BenchCapture? capture;
|
|
||||||
BenchDiagnostics? diagnostics;
|
|
||||||
BenchRecords? records;
|
|
||||||
BenchPlayheadDrag? activeDrag;
|
|
||||||
await output.create(recursive: true);
|
|
||||||
try {
|
|
||||||
await _sleep(6000);
|
|
||||||
if (config.startGate case final gatePath?) {
|
|
||||||
final gate = File(gatePath);
|
|
||||||
for (var i = 0; !await gate.exists() && i < 240; i++) {
|
|
||||||
await _sleep(500);
|
|
||||||
}
|
|
||||||
if (!await gate.exists()) {
|
|
||||||
throw StateError('Benchmark start gate timed out');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Element? previewElement;
|
|
||||||
TimelineViewport? timeline;
|
|
||||||
RenderBox? ruler;
|
|
||||||
void visit(Element element) {
|
|
||||||
if (element.widget is EditorPreviewPanel) previewElement = element;
|
|
||||||
if (element.widget is TimelineViewport) {
|
|
||||||
timeline = element.widget as TimelineViewport;
|
|
||||||
}
|
|
||||||
if (element.widget is TimelineRuler) {
|
|
||||||
ruler = element.findRenderObject() as RenderBox?;
|
|
||||||
}
|
|
||||||
element.visitChildElements(visit);
|
|
||||||
}
|
|
||||||
|
|
||||||
WidgetsBinding.instance.rootElement!.visitChildElements(visit);
|
|
||||||
if (previewElement == null || timeline == null || ruler == null) {
|
|
||||||
throw StateError('Full normal editor is not open');
|
|
||||||
}
|
|
||||||
final panel = previewElement!.widget as EditorPreviewPanel;
|
|
||||||
final container = ProviderScope.containerOf(previewElement!);
|
|
||||||
final preview = container
|
|
||||||
.read(editorPreviewProvider(panel.projectId, panel.timelineId))
|
|
||||||
.asData
|
|
||||||
?.value;
|
|
||||||
if (preview?.session == null || preview!.error != null) {
|
|
||||||
throw StateError('Normal preview unavailable');
|
|
||||||
}
|
|
||||||
final sequence = preview.activeSequence()!;
|
|
||||||
final view = timeline!.controller;
|
|
||||||
final endTime = TimelineClock.standard.fromTicks(view.contentEndTick);
|
|
||||||
final endFrame =
|
|
||||||
endTime.numerator * config.timelineFps / endTime.denominator;
|
|
||||||
final workloads = ViewportBenchWorkload.forTimeline(config, endFrame);
|
|
||||||
view.fitTimeline();
|
|
||||||
await _sleep(500);
|
|
||||||
final viewport = TimelineViewportRect(
|
|
||||||
width: ruler!.size.width,
|
|
||||||
height: ruler!.size.height,
|
|
||||||
);
|
|
||||||
final scale = View.of(previewElement!).devicePixelRatio;
|
|
||||||
final clipStart = view.camera.screenXForTick(0, viewport);
|
|
||||||
final clipEnd = view.camera.screenXForTick(view.contentEndTick, viewport);
|
|
||||||
if (clipStart < 0 || clipEnd > viewport.width) {
|
|
||||||
throw StateError('Clip outside viewport');
|
|
||||||
}
|
|
||||||
final native = diagnostics = BenchDiagnostics(preview.session!, clock);
|
|
||||||
await native.calibrate();
|
|
||||||
capture = await BenchCapture.start(config, output);
|
|
||||||
final record = records = BenchRecords(output);
|
|
||||||
native.startSamples(record.samples, config.sampleIntervalMs);
|
|
||||||
int tick(int frame) =>
|
|
||||||
TimelineClock.standard.toTicks(RationalTime(frame, config.timelineFps));
|
|
||||||
|
|
||||||
for (var round = 1; round <= config.rounds; round++) {
|
|
||||||
for (final workload in workloads) {
|
|
||||||
final scenario = workload.scenario;
|
|
||||||
if (config.paired) {
|
|
||||||
if (workload.local) {
|
|
||||||
view.setCamera(
|
|
||||||
TimelineCamera(
|
|
||||||
baseTick: tick(workload.cameraBaseFrame),
|
|
||||||
pixelsPerTick: config.localPixelsPerFrame / tick(1),
|
|
||||||
verticalOffset: view.camera.verticalOffset,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
view.fitTimeline();
|
|
||||||
}
|
|
||||||
await _sleep(100);
|
|
||||||
}
|
|
||||||
final warm = workload.warmFrame;
|
|
||||||
final drag = activeDrag = BenchPlayheadDrag(
|
|
||||||
view: view,
|
|
||||||
ruler: ruler!,
|
|
||||||
viewport: viewport,
|
|
||||||
scale: scale,
|
|
||||||
clock: clock,
|
|
||||||
pointer: 100 + round * 10 + scenario,
|
|
||||||
warmFrame: warm,
|
|
||||||
fps: config.timelineFps,
|
|
||||||
);
|
|
||||||
await preview.controlPreview(
|
|
||||||
sequence,
|
|
||||||
PreviewAction.seek,
|
|
||||||
at: CommandTime(warm, config.timelineFps),
|
|
||||||
);
|
|
||||||
await _sleep(80);
|
|
||||||
if (config.silent) {
|
|
||||||
await preview.session!.beginSkimming(mode: SkimmingMode.silent);
|
|
||||||
}
|
|
||||||
await drag.begin();
|
|
||||||
drag.moveTo(workload.idealFrame(0));
|
|
||||||
await _sleep(350);
|
|
||||||
final before = await native.read();
|
|
||||||
final start = native.now();
|
|
||||||
for (var i = 0; i < workload.count; i++) {
|
|
||||||
final due = start + 1000 * i / workload.hz;
|
|
||||||
await native.until(due);
|
|
||||||
final begin = native.now();
|
|
||||||
final ideal = workload.idealFrame(i);
|
|
||||||
drag.moveTo(ideal);
|
|
||||||
record.input(
|
|
||||||
round,
|
|
||||||
scenario,
|
|
||||||
i,
|
|
||||||
drag.target(ideal),
|
|
||||||
begin,
|
|
||||||
due,
|
|
||||||
native.now(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await native.until(start + workload.durationMs);
|
|
||||||
final end = native.now();
|
|
||||||
final release = native.now();
|
|
||||||
drag.end();
|
|
||||||
activeDrag = null;
|
|
||||||
await preview.waitForPendingPreview();
|
|
||||||
final settled = await preview.session!.refresh();
|
|
||||||
final settledAt = native.now();
|
|
||||||
await _sleep(350);
|
|
||||||
final frozenBegin = native.now();
|
|
||||||
await _sleep(350);
|
|
||||||
final snapshot = await preview.session!.refresh();
|
|
||||||
final after = await native.read();
|
|
||||||
record.stages.add({
|
|
||||||
'round': round,
|
|
||||||
'scenario': scenario,
|
|
||||||
'before': before,
|
|
||||||
'after': after,
|
|
||||||
'settledAtMs': settledAt,
|
|
||||||
'settledClock':
|
|
||||||
'${settled.position.numerator}/${settled.position.denominator}',
|
|
||||||
});
|
|
||||||
final actual =
|
|
||||||
snapshot.position.numerator *
|
|
||||||
config.timelineFps /
|
|
||||||
snapshot.position.denominator;
|
|
||||||
final finalTarget = drag.target(
|
|
||||||
workload.idealFrame(workload.count - 1),
|
|
||||||
);
|
|
||||||
if ((actual - finalTarget).abs() > .01 || preview.error != null) {
|
|
||||||
throw StateError('Final precision failure $actual');
|
|
||||||
}
|
|
||||||
native.check();
|
|
||||||
record.checks.add({
|
|
||||||
'round': round,
|
|
||||||
'scenario': scenario,
|
|
||||||
'finalClockFrame': actual,
|
|
||||||
'target': finalTarget,
|
|
||||||
'state': snapshot.state.name,
|
|
||||||
});
|
|
||||||
record.phase(
|
|
||||||
round,
|
|
||||||
scenario,
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
release,
|
|
||||||
finalTarget,
|
|
||||||
actual,
|
|
||||||
frozenBegin,
|
|
||||||
native.now(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await record.progress(round);
|
|
||||||
}
|
|
||||||
await capture?.stop();
|
|
||||||
capture = null;
|
|
||||||
await native.stopSamples();
|
|
||||||
await record.close();
|
|
||||||
await record.complete({
|
|
||||||
'status': 'passed',
|
|
||||||
'entrypoint': 'lib/main.dart',
|
|
||||||
'fullApp': true,
|
|
||||||
'startGateUsed': config.startGate != null,
|
|
||||||
'configuration': config.toJson(),
|
|
||||||
'projectId': panel.projectId,
|
|
||||||
'timelineId': panel.timelineId,
|
|
||||||
'sequenceId': sequence.value,
|
|
||||||
'timelineEndFramesAt30Hz': endFrame * 30 / config.timelineFps,
|
|
||||||
'firstSampleFrameAt30Hz':
|
|
||||||
config.edgeMarginFrames * 30 / config.timelineFps,
|
|
||||||
'lastSampleFrameAt30Hz':
|
|
||||||
(endFrame.round() - config.edgeMarginFrames - 1) *
|
|
||||||
30 /
|
|
||||||
config.timelineFps,
|
|
||||||
'clipStartX': clipStart,
|
|
||||||
'clipEndX': clipEnd,
|
|
||||||
'viewportWidth': viewport.width,
|
|
||||||
'devicePixelRatio': scale,
|
|
||||||
'qpcCalibrationRoundTripMs': native.uncertaintyMs,
|
|
||||||
'inputRoute': 'GestureBinding -> real normal TimelineViewport playhead handle -> production preview/runtime/native presenter',
|
|
||||||
'physicalPixelInput': true,
|
|
||||||
'rounds': config.rounds,
|
|
||||||
'pairedWideLocal': config.paired,
|
|
||||||
'nativeOnly': config.nativeOnly,
|
|
||||||
'silentOverride': config.silent,
|
|
||||||
'skimmingPolicy': preview.policy.skimmingMode.name,
|
|
||||||
'canvas': {
|
|
||||||
'width': preview.canvas.width,
|
|
||||||
'height': preview.canvas.height,
|
|
||||||
},
|
|
||||||
'timelineSettings': preview.timeline.settings,
|
|
||||||
});
|
|
||||||
// Leave the normal editor paused with the complete clip visible.
|
|
||||||
view.fitTimeline();
|
|
||||||
} finally {
|
|
||||||
activeDrag?.cancel();
|
|
||||||
try {
|
|
||||||
await capture?.stop();
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
await diagnostics?.stopSamples();
|
|
||||||
} finally {
|
|
||||||
await records?.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
import 'config.dart';
|
|
||||||
|
|
||||||
/// A deterministic input sequence; independent of Flutter, decoding and sampling.
|
|
||||||
class ViewportBenchWorkload {
|
|
||||||
const ViewportBenchWorkload({
|
|
||||||
required this.scenario,
|
|
||||||
required this.hz,
|
|
||||||
required this.count,
|
|
||||||
required this.firstFrame,
|
|
||||||
required this.lastFrame,
|
|
||||||
required this.steps,
|
|
||||||
required this.paired,
|
|
||||||
required this.localSpanFrames,
|
|
||||||
required this.timelineEndFrame,
|
|
||||||
});
|
|
||||||
|
|
||||||
final int scenario, hz, count, firstFrame, lastFrame, steps, localSpanFrames;
|
|
||||||
final bool paired;
|
|
||||||
final double timelineEndFrame;
|
|
||||||
bool get local => paired && scenario == 1;
|
|
||||||
double get durationMs => 1000 * count / hz;
|
|
||||||
int get warmFrame => idealFrame(0) - 1;
|
|
||||||
int get cameraBaseFrame => firstFrame - 17;
|
|
||||||
|
|
||||||
int idealFrame(int i) {
|
|
||||||
if (local) {
|
|
||||||
final phase = i % (2 * localSpanFrames);
|
|
||||||
return firstFrame +
|
|
||||||
(phase <= localSpanFrames ? phase : 2 * localSpanFrames - phase);
|
|
||||||
}
|
|
||||||
if (paired) {
|
|
||||||
final half = count ~/ 2;
|
|
||||||
final phase = i % count;
|
|
||||||
final index = phase < half ? phase : count - 1 - phase;
|
|
||||||
return (timelineEndFrame * (.05 + .9 * index / (half - 1))).round();
|
|
||||||
}
|
|
||||||
final period = 2 * (steps - 1);
|
|
||||||
final phase = i % period;
|
|
||||||
final index = switch (scenario) {
|
|
||||||
0 => i,
|
|
||||||
1 => steps - 1 - i,
|
|
||||||
_ => phase < steps ? phase : period - phase,
|
|
||||||
};
|
|
||||||
return (firstFrame * (steps - 1) +
|
|
||||||
(lastFrame - firstFrame) * index +
|
|
||||||
(steps - 1) ~/ 2) ~/
|
|
||||||
(steps - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static List<ViewportBenchWorkload> forTimeline(
|
|
||||||
ViewportBenchConfig config,
|
|
||||||
double endFrame,
|
|
||||||
) {
|
|
||||||
if (!endFrame.isFinite ||
|
|
||||||
endFrame < 2 * config.edgeMarginFrames + 2 ||
|
|
||||||
(config.expectedFrames != null &&
|
|
||||||
(endFrame - config.expectedFrames!).abs() > 2)) {
|
|
||||||
throw StateError('Unexpected normal timeline length: $endFrame');
|
|
||||||
}
|
|
||||||
final localStart = config.localStartFrame ?? (endFrame * .28).round();
|
|
||||||
if (config.paired &&
|
|
||||||
(localStart < 18 || localStart + config.localSpanFrames >= endFrame)) {
|
|
||||||
throw StateError('Local benchmark range falls outside the timeline');
|
|
||||||
}
|
|
||||||
final steps = config.inputCount ~/ 3;
|
|
||||||
return List.generate(config.paired ? 2 : 5, (scenario) {
|
|
||||||
final hz = config.paired
|
|
||||||
? config.inputHz
|
|
||||||
: config.inputHz * [1, 2, 1, 2, 4][scenario];
|
|
||||||
final count = config.paired
|
|
||||||
? config.inputCount
|
|
||||||
: [
|
|
||||||
steps,
|
|
||||||
steps,
|
|
||||||
config.inputCount,
|
|
||||||
config.inputCount * 2,
|
|
||||||
config.inputCount * 4,
|
|
||||||
][scenario];
|
|
||||||
return ViewportBenchWorkload(
|
|
||||||
scenario: scenario,
|
|
||||||
hz: hz,
|
|
||||||
count: count,
|
|
||||||
firstFrame: config.paired
|
|
||||||
? (scenario == 0 ? (endFrame * .05).round() : localStart)
|
|
||||||
: config.edgeMarginFrames,
|
|
||||||
lastFrame: config.paired
|
|
||||||
? (endFrame * .95).round()
|
|
||||||
: endFrame.round() - config.edgeMarginFrames - 1,
|
|
||||||
steps: steps,
|
|
||||||
paired: config.paired,
|
|
||||||
localSpanFrames: config.localSpanFrames,
|
|
||||||
timelineEndFrame: endFrame,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,220 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:cutdex_core/timeline/layout.dart';
|
|
||||||
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
|
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter/widgets.dart';
|
|
||||||
|
|
||||||
bool _replayActive = false;
|
|
||||||
|
|
||||||
/// Replays trackpad input through the normal full-app timeline hit-test path.
|
|
||||||
/// An independent opt-in trace can also record physical driver events.
|
|
||||||
void startTimelineGestureBenchFromEnvironment() {
|
|
||||||
final trace = Platform.environment['CUTDEX_TIMELINE_GESTURE_TRACE'];
|
|
||||||
if (trace != null && trace.isNotEmpty) {
|
|
||||||
final file = File(trace)..parent.createSync(recursive: true);
|
|
||||||
final sink = file.openWrite(mode: FileMode.append);
|
|
||||||
Timer.periodic(const Duration(seconds: 1), (_) => unawaited(sink.flush()));
|
|
||||||
GestureBinding.instance.pointerRouter.addGlobalRoute((event) {
|
|
||||||
if (event is! PointerPanZoomStartEvent &&
|
|
||||||
event is! PointerPanZoomUpdateEvent &&
|
|
||||||
event is! PointerPanZoomEndEvent &&
|
|
||||||
event is! PointerScrollEvent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sink.writeln(
|
|
||||||
jsonEncode({
|
|
||||||
'at': DateTime.now().toUtc().toIso8601String(),
|
|
||||||
'type': event.runtimeType.toString(),
|
|
||||||
'source': _replayActive ? 'protocol-replay' : 'driver',
|
|
||||||
'device': event.device,
|
|
||||||
'kind': event.kind.name,
|
|
||||||
'control': HardwareKeyboard.instance.isControlPressed,
|
|
||||||
'meta': HardwareKeyboard.instance.isMetaPressed,
|
|
||||||
if (event is PointerPanZoomUpdateEvent) ...{
|
|
||||||
'pan': [event.pan.dx, event.pan.dy],
|
|
||||||
'scale': event.scale,
|
|
||||||
},
|
|
||||||
if (event is PointerScrollEvent)
|
|
||||||
'scroll': [event.scrollDelta.dx, event.scrollDelta.dy],
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
final output = Platform.environment['CUTDEX_TIMELINE_GESTURE_BENCH'];
|
|
||||||
if (output == null || output.isEmpty) return;
|
|
||||||
unawaited(
|
|
||||||
_run(output).catchError((Object error, StackTrace stack) async {
|
|
||||||
await Directory(output).create(recursive: true);
|
|
||||||
await File('$output/error.txt').writeAsString('$error\n$stack');
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Element? _surface() {
|
|
||||||
Element? result;
|
|
||||||
void visit(Element element) {
|
|
||||||
if (element.widget case TimelineInteractionRegion(ruler: false)) {
|
|
||||||
result = element;
|
|
||||||
}
|
|
||||||
element.visitChildElements(visit);
|
|
||||||
}
|
|
||||||
|
|
||||||
WidgetsBinding.instance.rootElement?.visitChildElements(visit);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _run(String output) async {
|
|
||||||
await Directory(output).create(recursive: true);
|
|
||||||
await Future<void>.delayed(const Duration(seconds: 6));
|
|
||||||
final element = _surface();
|
|
||||||
if (element == null) throw StateError('Normal timeline surface is not open');
|
|
||||||
if (HardwareKeyboard.instance.logicalKeysPressed.isNotEmpty) {
|
|
||||||
throw StateError('Release keyboard modifiers before replay');
|
|
||||||
}
|
|
||||||
final region = element.widget as TimelineInteractionRegion;
|
|
||||||
final c = region.controller;
|
|
||||||
final box = element.findRenderObject()! as RenderBox;
|
|
||||||
final viewport = TimelineViewportRect(
|
|
||||||
width: box.size.width,
|
|
||||||
height: box.size.height,
|
|
||||||
);
|
|
||||||
final position = box.localToGlobal(
|
|
||||||
Offset(box.size.width * .8, box.size.height * .5),
|
|
||||||
);
|
|
||||||
final saved = c.camera;
|
|
||||||
final playhead = c.playheadTick;
|
|
||||||
final version = c.version;
|
|
||||||
final x = saved.screenXForTick(playhead, viewport);
|
|
||||||
if (x < 0 || x > viewport.width) throw StateError('Playhead must be visible');
|
|
||||||
final rows = <Map<String, Object?>>[];
|
|
||||||
const device = 7200;
|
|
||||||
void send(PointerEvent event) =>
|
|
||||||
GestureBinding.instance.handlePointerEvent(event);
|
|
||||||
void start(int pointer) => send(
|
|
||||||
PointerPanZoomStartEvent(
|
|
||||||
pointer: pointer,
|
|
||||||
device: device,
|
|
||||||
position: position,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
void update(int pointer, Offset pan, double scale) => send(
|
|
||||||
PointerPanZoomUpdateEvent(
|
|
||||||
pointer: pointer,
|
|
||||||
device: device,
|
|
||||||
position: position,
|
|
||||||
pan: pan,
|
|
||||||
scale: scale,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
void end(int pointer) => send(
|
|
||||||
PointerPanZoomEndEvent(
|
|
||||||
pointer: pointer,
|
|
||||||
device: device,
|
|
||||||
position: position,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
void record(String name, {bool anchor = true}) {
|
|
||||||
final drift = c.camera.screenXForTick(playhead, viewport) - x;
|
|
||||||
final unchanged =
|
|
||||||
c.playheadTick == playhead && identical(c.version, version);
|
|
||||||
rows.add({
|
|
||||||
'scenario': name,
|
|
||||||
'playheadPixelDrift': drift,
|
|
||||||
'scaleRatio': c.camera.pixelsPerTick / saved.pixelsPerTick,
|
|
||||||
'verticalDrift': c.camera.verticalOffset - saved.verticalOffset,
|
|
||||||
'timelineUnchanged': unchanged,
|
|
||||||
'cameraBaseTick': c.camera.baseTick,
|
|
||||||
'savedCameraBaseTick': saved.baseTick,
|
|
||||||
});
|
|
||||||
File('$output/progress.json').writeAsStringSync(jsonEncode(rows));
|
|
||||||
if (!unchanged || (anchor && drift.abs() > .001)) {
|
|
||||||
throw StateError('$name changed the timeline or moved the zoom anchor');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
_replayActive = true;
|
|
||||||
send(
|
|
||||||
PointerAddedEvent(
|
|
||||||
device: device,
|
|
||||||
kind: PointerDeviceKind.trackpad,
|
|
||||||
position: position,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
start(7201);
|
|
||||||
update(7201, const Offset(50, 30), 1.2);
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
|
||||||
update(7201, const Offset(100, 60), 1.5);
|
|
||||||
await WidgetsBinding.instance.endOfFrame;
|
|
||||||
record('native-pinch-with-translation');
|
|
||||||
final pinchCamera = c.camera;
|
|
||||||
update(7201, const Offset(140, 90), 1.5);
|
|
||||||
await WidgetsBinding.instance.endOfFrame;
|
|
||||||
record('pinch-scale-pauses');
|
|
||||||
if (c.camera != pinchCamera) throw StateError('Pinch tail became a pan');
|
|
||||||
end(7201);
|
|
||||||
c.setCamera(saved);
|
|
||||||
HardwareKeyboard.instance.handleKeyEvent(
|
|
||||||
const KeyDownEvent(
|
|
||||||
physicalKey: PhysicalKeyboardKey.controlLeft,
|
|
||||||
logicalKey: LogicalKeyboardKey.controlLeft,
|
|
||||||
timeStamp: Duration.zero,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
try {
|
|
||||||
send(
|
|
||||||
PointerScrollEvent(
|
|
||||||
position: position,
|
|
||||||
scrollDelta: const Offset(0, -120),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
HardwareKeyboard.instance.handleKeyEvent(
|
|
||||||
const KeyUpEvent(
|
|
||||||
physicalKey: PhysicalKeyboardKey.controlLeft,
|
|
||||||
logicalKey: LogicalKeyboardKey.controlLeft,
|
|
||||||
timeStamp: Duration(milliseconds: 1),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await WidgetsBinding.instance.endOfFrame;
|
|
||||||
record('control-scroll-zoom');
|
|
||||||
c.setCamera(saved);
|
|
||||||
start(7202);
|
|
||||||
update(7202, const Offset(-30, 0), 1);
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
|
||||||
update(7202, const Offset(-70, 0), 1);
|
|
||||||
await WidgetsBinding.instance.endOfFrame;
|
|
||||||
record('plain-two-finger-pan', anchor: false);
|
|
||||||
end(7202);
|
|
||||||
if ((c.camera.screenXForTick(playhead, viewport) - x).abs() < 1 ||
|
|
||||||
c.camera.pixelsPerTick != saved.pixelsPerTick) {
|
|
||||||
throw StateError('Ordinary pan stopped working');
|
|
||||||
}
|
|
||||||
await File('$output/results.json').writeAsString(
|
|
||||||
jsonEncode({
|
|
||||||
'inputRoute':
|
|
||||||
'GestureBinding -> normal full-app TimelineInteractionRegion',
|
|
||||||
'inputKind': 'synthetic driver-protocol replay; not physical fingers',
|
|
||||||
'playheadTick': playhead,
|
|
||||||
'playheadScreenX': x,
|
|
||||||
'rows': rows,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
send(
|
|
||||||
PointerRemovedEvent(
|
|
||||||
device: device,
|
|
||||||
kind: PointerDeviceKind.trackpad,
|
|
||||||
position: position,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
c.setCamera(saved);
|
|
||||||
_replayActive = false;
|
|
||||||
}
|
|
||||||
await File('$output/done.json').writeAsString(jsonEncode({'complete': true}));
|
|
||||||
}
|
|
||||||
@@ -1,311 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/scheduler.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../features/editor/editor_page.dart';
|
|
||||||
import '../features/preview/preview_panel.dart';
|
|
||||||
import '../workspace/timeline_provider.dart';
|
|
||||||
import '../workspace/projects.dart';
|
|
||||||
import '../workspace/project_state.dart';
|
|
||||||
import '../workspace/preview_controller_registry.dart';
|
|
||||||
import 'full_app_viewport_bench/diagnostics.dart';
|
|
||||||
import 'app_diagnostics.dart';
|
|
||||||
|
|
||||||
/// Opt-in measurements through normal timeline tabs in the complete application.
|
|
||||||
void startTimelineSwitchBenchFromEnvironment() {
|
|
||||||
final output = Platform.environment['CUTDEX_TIMELINE_SWITCH_BENCH'];
|
|
||||||
if (output == null || output.isEmpty) return;
|
|
||||||
unawaited(
|
|
||||||
_run(output).catchError((Object error, StackTrace stack) async {
|
|
||||||
await Directory(output).create(recursive: true);
|
|
||||||
await File('$output/error.txt').writeAsString('$error\n$stack');
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Element? _find(bool Function(Widget) matches) {
|
|
||||||
Element? result;
|
|
||||||
void visit(Element element) {
|
|
||||||
if (matches(element.widget)) result = element;
|
|
||||||
element.visitChildElements(visit);
|
|
||||||
}
|
|
||||||
|
|
||||||
WidgetsBinding.instance.rootElement?.visitChildElements(visit);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _run(String output) async {
|
|
||||||
await Directory(output).create(recursive: true);
|
|
||||||
final gate = Platform.environment['CUTDEX_TIMELINE_SWITCH_GATE'];
|
|
||||||
await Future<void>.delayed(const Duration(seconds: 6));
|
|
||||||
if (gate != null) {
|
|
||||||
for (var i = 0; !await File(gate).exists() && i < 600; i++) {
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 200));
|
|
||||||
}
|
|
||||||
if (!await File(gate).exists()) throw StateError('Start gate timed out');
|
|
||||||
}
|
|
||||||
final element = _find((widget) => widget is EditorWorkspace);
|
|
||||||
if (element == null) throw StateError('Normal editor is not open');
|
|
||||||
final container = ProviderScope.containerOf(element);
|
|
||||||
final initial = container.read(projectsProvider).requireValue;
|
|
||||||
final projectId = initial.activeProject!.id;
|
|
||||||
final target =
|
|
||||||
Platform.environment['CUTDEX_TIMELINE_SWITCH_TARGET'] ??
|
|
||||||
initial.timelines.firstWhere((t) => t.id != initial.timeline!.id).id;
|
|
||||||
if (initial.timeline!.id == target) throw StateError('Target already active');
|
|
||||||
final initialSession = container
|
|
||||||
.read(projectsProvider.notifier)
|
|
||||||
.cachedTimelineSession(projectId, initial.timeline!.id)!;
|
|
||||||
final initialSequence = initialSession.activeSequenceId;
|
|
||||||
File('$output/startup.json').writeAsStringSync(
|
|
||||||
jsonEncode({
|
|
||||||
'initialTimelineId': initial.timeline!.id,
|
|
||||||
'editorError': container
|
|
||||||
.read(editorTimelineProvider(projectId, initial.timeline!.id))
|
|
||||||
.error
|
|
||||||
?.toString(),
|
|
||||||
'previewError': container
|
|
||||||
.read(editorPreviewProvider(projectId, initial.timeline!.id))
|
|
||||||
.error
|
|
||||||
?.toString(),
|
|
||||||
'diagnosticsDirectory': AppDiagnostics.instance?.store.directory.path,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
if (initialSequence != null &&
|
|
||||||
initialSession.sequenceDurationTicks(initialSequence) > 0) {
|
|
||||||
var ready = false;
|
|
||||||
for (var i = 0; i < 3000; i++) {
|
|
||||||
final editing = container.read(
|
|
||||||
editorTimelineProvider(projectId, initial.timeline!.id),
|
|
||||||
);
|
|
||||||
if (editing.hasError) {
|
|
||||||
throw StateError(
|
|
||||||
'Initial editor failed: ${editing.error}\n${editing.stackTrace}',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final previewState = container.read(
|
|
||||||
editorPreviewProvider(projectId, initial.timeline!.id),
|
|
||||||
);
|
|
||||||
if (previewState.hasError) {
|
|
||||||
throw StateError(
|
|
||||||
'Initial preview failed: ${previewState.error}\n${previewState.stackTrace}',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final preview = container.read(previewControllerRegistryProvider).cached((
|
|
||||||
projectId,
|
|
||||||
initial.timeline!.id,
|
|
||||||
));
|
|
||||||
if (preview?.session != null) {
|
|
||||||
ready = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 20));
|
|
||||||
}
|
|
||||||
if (!ready) throw StateError('Initial preview is not ready');
|
|
||||||
}
|
|
||||||
final rows = <Map<String, Object?>>[];
|
|
||||||
var pointer = 500;
|
|
||||||
|
|
||||||
void tap(String id, Stopwatch clock) {
|
|
||||||
final button = _find(
|
|
||||||
(widget) => widget.key == ValueKey('timeline-tab-$id'),
|
|
||||||
);
|
|
||||||
final box = button?.findRenderObject() as RenderBox?;
|
|
||||||
if (box == null || !box.hasSize) throw StateError('Tab not laid out: $id');
|
|
||||||
final position = box.localToGlobal(box.size.center(Offset.zero));
|
|
||||||
final input = ++pointer;
|
|
||||||
GestureBinding.instance.handlePointerEvent(
|
|
||||||
PointerAddedEvent(
|
|
||||||
pointer: input,
|
|
||||||
device: 51,
|
|
||||||
kind: PointerDeviceKind.mouse,
|
|
||||||
position: position,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
GestureBinding.instance.handlePointerEvent(
|
|
||||||
PointerDownEvent(
|
|
||||||
pointer: input,
|
|
||||||
device: 51,
|
|
||||||
kind: PointerDeviceKind.mouse,
|
|
||||||
buttons: kPrimaryButton,
|
|
||||||
position: position,
|
|
||||||
timeStamp: clock.elapsed,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
GestureBinding.instance.handlePointerEvent(
|
|
||||||
PointerUpEvent(
|
|
||||||
pointer: input,
|
|
||||||
device: 51,
|
|
||||||
kind: PointerDeviceKind.mouse,
|
|
||||||
position: position,
|
|
||||||
timeStamp: clock.elapsed,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
GestureBinding.instance.handlePointerEvent(
|
|
||||||
PointerRemovedEvent(
|
|
||||||
pointer: input,
|
|
||||||
device: 51,
|
|
||||||
kind: PointerDeviceKind.mouse,
|
|
||||||
position: position,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> measure(String id, String scenario) async {
|
|
||||||
final cached =
|
|
||||||
container
|
|
||||||
.read(projectsProvider.notifier)
|
|
||||||
.cachedTimelineSession(projectId, id) !=
|
|
||||||
null;
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
double? dataMs, uiMs, firstFrameObservedMs;
|
|
||||||
final subscription = container.listen(projectsProvider, (_, next) {
|
|
||||||
if (next.value?.timeline?.id == id &&
|
|
||||||
next.value?.openingTimelineId == null) {
|
|
||||||
dataMs ??= clock.elapsedMicroseconds / 1000;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
void observeFrame(Duration _) {
|
|
||||||
final workspace =
|
|
||||||
_find((w) => w is EditorWorkspace)?.widget as EditorWorkspace?;
|
|
||||||
if (workspace?.timelineId == id) {
|
|
||||||
uiMs ??= clock.elapsedMicroseconds / 1000;
|
|
||||||
}
|
|
||||||
if (uiMs == null && clock.elapsedMilliseconds < 60000) {
|
|
||||||
SchedulerBinding.instance.addPostFrameCallback(observeFrame);
|
|
||||||
SchedulerBinding.instance.scheduleFrame();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SchedulerBinding.instance.addPostFrameCallback(observeFrame);
|
|
||||||
tap(id, clock);
|
|
||||||
try {
|
|
||||||
for (var i = 0; i < 3000; i++) {
|
|
||||||
final preview = container
|
|
||||||
.read(previewControllerRegistryProvider)
|
|
||||||
.cached((projectId, id));
|
|
||||||
if (preview?.session != null && uiMs != null && dataMs != null) {
|
|
||||||
final diagnostic = await BenchDiagnostics(
|
|
||||||
preview!.session!,
|
|
||||||
clock,
|
|
||||||
).read().timeout(const Duration(seconds: 2));
|
|
||||||
if ((diagnostic['sourceSubmitted'] as num?) != null &&
|
|
||||||
(diagnostic['sourceSubmitted'] as num) > 0 &&
|
|
||||||
(diagnostic['presented'] as num?) != null &&
|
|
||||||
(diagnostic['presented'] as num) > 0) {
|
|
||||||
firstFrameObservedMs = clock.elapsedMicroseconds / 1000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 20));
|
|
||||||
}
|
|
||||||
if (uiMs == null || dataMs == null) {
|
|
||||||
throw StateError('Switch timed out: $scenario');
|
|
||||||
}
|
|
||||||
if (firstFrameObservedMs == null) {
|
|
||||||
final previewState = container.read(
|
|
||||||
editorPreviewProvider(projectId, id),
|
|
||||||
);
|
|
||||||
throw StateError(
|
|
||||||
'Native frame timed out: $scenario; ${previewState.error}\n${previewState.stackTrace}',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
rows.add({
|
|
||||||
'scenario': scenario,
|
|
||||||
'timelineId': id,
|
|
||||||
'sessionCachedBeforeClick': cached,
|
|
||||||
'clickToUiPostFrameMs': uiMs,
|
|
||||||
'clickToDataMs': dataMs,
|
|
||||||
'clickToNativeFrameObservedMs': firstFrameObservedMs,
|
|
||||||
});
|
|
||||||
await File('$output/results.json').writeAsString(
|
|
||||||
jsonEncode({
|
|
||||||
'projectId': projectId,
|
|
||||||
'initialTimelineId': initial.timeline!.id,
|
|
||||||
'inputRoute':
|
|
||||||
'GestureBinding -> real timeline TextButton -> Projects',
|
|
||||||
'uiClock': 'Stopwatch until target EditorWorkspace post-frame',
|
|
||||||
'nativeClock':
|
|
||||||
'20 ms polling; cached frames are reuse, not new decode',
|
|
||||||
'rows': rows,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
subscription.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Platform.environment['CUTDEX_TIMELINE_SWITCH_RAPID'] == '1') {
|
|
||||||
final third = initial.timelines
|
|
||||||
.firstWhere((t) => t.id != target && t.id != initial.timeline!.id)
|
|
||||||
.id;
|
|
||||||
final clock = Stopwatch()..start();
|
|
||||||
final inputs = <Map<String, Object?>>[];
|
|
||||||
final states = <Map<String, Object?>>[];
|
|
||||||
var latest = initial.timeline!.id;
|
|
||||||
final subscription = container.listen(projectsProvider, (_, next) {
|
|
||||||
final value = next.value!;
|
|
||||||
states.add({
|
|
||||||
'ms': clock.elapsedMicroseconds / 1000,
|
|
||||||
'latestInput': latest,
|
|
||||||
'visible': value.visibleTimelineId,
|
|
||||||
'loaded': value.timeline?.id,
|
|
||||||
'pending': value.openingTimelineId,
|
|
||||||
'error': value.error?.toString(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
for (final id in [
|
|
||||||
target,
|
|
||||||
initial.timeline!.id,
|
|
||||||
third,
|
|
||||||
initial.timeline!.id,
|
|
||||||
target,
|
|
||||||
]) {
|
|
||||||
latest = id;
|
|
||||||
inputs.add({'ms': clock.elapsedMicroseconds / 1000, 'timelineId': id});
|
|
||||||
tap(id, clock);
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 16));
|
|
||||||
}
|
|
||||||
await Future<void>.delayed(const Duration(seconds: 5));
|
|
||||||
final finalState = container.read(projectsProvider).requireValue;
|
|
||||||
if (finalState.timeline?.id != target ||
|
|
||||||
finalState.openingTimelineId != null ||
|
|
||||||
finalState.error != null ||
|
|
||||||
states.any((s) => s['visible'] != s['latestInput'])) {
|
|
||||||
throw StateError(
|
|
||||||
'Rapid navigation did not preserve the latest request',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await File('$output/rapid.json').writeAsString(
|
|
||||||
jsonEncode({
|
|
||||||
'inputRoute': 'GestureBinding -> real timeline tabs',
|
|
||||||
'inputs': inputs,
|
|
||||||
'states': states,
|
|
||||||
'finalTimelineId': finalState.timeline!.id,
|
|
||||||
'latestWins': true,
|
|
||||||
'stabilityWindowMs': 5000,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
await File('$output/done.json')
|
|
||||||
.writeAsString(jsonEncode({'complete': true}));
|
|
||||||
return;
|
|
||||||
} finally {
|
|
||||||
subscription.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await measure(target, 'cold-target');
|
|
||||||
for (var round = 1; round <= 3; round++) {
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 200));
|
|
||||||
await measure(initial.timeline!.id, 'warm-return-$round');
|
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 200));
|
|
||||||
await measure(target, 'warm-target-$round');
|
|
||||||
}
|
|
||||||
await File('$output/done.json').writeAsString(jsonEncode({'complete': true}));
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,6 @@ enum AppErrorCode {
|
|||||||
openMatchingProject,
|
openMatchingProject,
|
||||||
openTimelineFailed,
|
openTimelineFailed,
|
||||||
projectMismatch,
|
projectMismatch,
|
||||||
projectAlreadyExists,
|
|
||||||
openProjectFirst,
|
openProjectFirst,
|
||||||
localFilesOnly,
|
localFilesOnly,
|
||||||
foldersUnsupported,
|
foldersUnsupported,
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../media/media_asset_cover.dart';
|
import '../media/media_asset_cover.dart';
|
||||||
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
import 'package:cutdex_ui/theme.dart';
|
||||||
|
|
||||||
import '../media/audio_asset_tile.dart';
|
import '../media/audio_asset_tile.dart';
|
||||||
@@ -26,13 +25,13 @@ class AgentAttachmentCard extends StatelessWidget {
|
|||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
fallback: Center(
|
fallback: Center(
|
||||||
child: Icon(
|
child: Icon(
|
||||||
kind == 'image' ? AppIcons.image : AppIcons.video,
|
kind == 'image' ? Icons.image_outlined : Icons.movie_outlined,
|
||||||
color: colors.onSurfaceVariant,
|
color: colors.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
errorFallback: Center(
|
errorFallback: Center(
|
||||||
child: Icon(
|
child: Icon(
|
||||||
AppIcons.imageUnavailable,
|
Icons.broken_image_outlined,
|
||||||
color: colors.onSurfaceVariant,
|
color: colors.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -43,7 +42,12 @@ class AgentAttachmentCard extends StatelessWidget {
|
|||||||
showName: false,
|
showName: false,
|
||||||
aspectRatio: 132 / 96,
|
aspectRatio: 132 / 96,
|
||||||
),
|
),
|
||||||
_ => Center(child: Icon(AppIcons.file, color: colors.onSurfaceVariant)),
|
_ => Center(
|
||||||
|
child: Icon(
|
||||||
|
Icons.insert_drive_file_outlined,
|
||||||
|
color: colors.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 132,
|
width: 132,
|
||||||
@@ -89,7 +93,7 @@ class AgentAttachmentCard extends StatelessWidget {
|
|||||||
backgroundColor: colors.surface,
|
backgroundColor: colors.surface,
|
||||||
foregroundColor: colors.onSurface,
|
foregroundColor: colors.onSurface,
|
||||||
),
|
),
|
||||||
icon: const Icon(AppIcons.close, size: 13),
|
icon: const Icon(Icons.close, size: 13),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,127 +0,0 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../../integrations/platform/platform_capabilities.dart';
|
|
||||||
import '../../integrations/platform/native_project_drop_region.dart';
|
|
||||||
import '../../integrations/platform/native_file_drop_policy.dart';
|
|
||||||
import '../../workspace/projects.dart';
|
|
||||||
import '../../workspace/media_import.dart';
|
|
||||||
import '../../workspace/external_media_import.dart';
|
|
||||||
import '../../shared/widgets/drop_to_add_overlay.dart';
|
|
||||||
import '../media/media_asset_drag.dart';
|
|
||||||
import 'agent_composer_controller.dart';
|
|
||||||
|
|
||||||
/// Shared attachment drop handling for docked and floating chat presentations.
|
|
||||||
class AgentAttachmentDropRegion extends ConsumerStatefulWidget {
|
|
||||||
const AgentAttachmentDropRegion({
|
|
||||||
super.key,
|
|
||||||
required this.projectId,
|
|
||||||
required this.composer,
|
|
||||||
required this.child,
|
|
||||||
this.shrinkWrap = false,
|
|
||||||
});
|
|
||||||
final String? projectId;
|
|
||||||
final AgentComposerController composer;
|
|
||||||
final Widget child;
|
|
||||||
final bool shrinkWrap;
|
|
||||||
@override
|
|
||||||
ConsumerState<AgentAttachmentDropRegion> createState() =>
|
|
||||||
_AgentAttachmentDropRegionState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AgentAttachmentDropRegionState
|
|
||||||
extends ConsumerState<AgentAttachmentDropRegion> {
|
|
||||||
bool _hovering = false;
|
|
||||||
bool _canAttach(MediaAssetDrag drag) {
|
|
||||||
final workspace = ref.read(projectsProvider).value;
|
|
||||||
return widget.projectId == drag.projectId &&
|
|
||||||
workspace?.activeProject?.id == drag.projectId &&
|
|
||||||
!widget.composer.attachments.any((item) => item.id == drag.assetId) &&
|
|
||||||
workspace!.assets.any((asset) => asset.id == drag.assetId);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _canAttachFiles(List<ExternalMediaFile> files) {
|
|
||||||
if (files.isEmpty) return true;
|
|
||||||
final assets = ref.read(projectsProvider).value?.assets;
|
|
||||||
if (assets == null) return false;
|
|
||||||
final ids = {for (final item in widget.composer.attachments) item.id};
|
|
||||||
final locations = {
|
|
||||||
for (final asset in assets)
|
|
||||||
if (ids.contains(asset.id)) ?mediaSourceLocation(asset),
|
|
||||||
};
|
|
||||||
return files.any((file) => !locations.contains(file.sourceUri.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final workspace = ref.watch(
|
|
||||||
projectsProvider.select(
|
|
||||||
(value) => value.value?.copyWith(
|
|
||||||
recent: const [],
|
|
||||||
timelines: const [],
|
|
||||||
error: null,
|
|
||||||
creatingTimeline: false,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final native = ref.watch(platformCapabilitiesProvider).nativeFileDrop;
|
|
||||||
final importing =
|
|
||||||
widget.composer.busy ||
|
|
||||||
widget.projectId != null &&
|
|
||||||
ref.watch(
|
|
||||||
externalMediaImportProvider(widget.projectId!)
|
|
||||||
.select((value) => value.isLoading),
|
|
||||||
);
|
|
||||||
final internal = DragTarget<MediaAssetDrag>(
|
|
||||||
key: const Key('agent-panel-drop-target'),
|
|
||||||
onWillAcceptWithDetails: (details) => _canAttach(details.data),
|
|
||||||
onAcceptWithDetails: (details) {
|
|
||||||
if (_canAttach(details.data)) {
|
|
||||||
widget.composer.attach(
|
|
||||||
ref
|
|
||||||
.read(projectsProvider)
|
|
||||||
.value!
|
|
||||||
.assets
|
|
||||||
.firstWhere((asset) => asset.id == details.data.assetId),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
builder: (context, candidates, _) => Stack(
|
|
||||||
fit: widget.shrinkWrap ? StackFit.loose : StackFit.expand,
|
|
||||||
children: [
|
|
||||||
widget.child,
|
|
||||||
if (candidates.isNotEmpty || _hovering)
|
|
||||||
const Positioned.fill(
|
|
||||||
child: DropToAddOverlay(key: Key('agent-drop-overlay')),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (!native) return internal;
|
|
||||||
return NativeProjectDropRegion(
|
|
||||||
regionId: 'attachments',
|
|
||||||
policy: NativeFileDropPolicy.attachments,
|
|
||||||
enabled:
|
|
||||||
widget.projectId != null &&
|
|
||||||
workspace?.activeProject?.id == widget.projectId &&
|
|
||||||
(workspace?.projectBusy == false || importing),
|
|
||||||
onEnter: (files) {
|
|
||||||
if (!importing && _canAttachFiles(files)) {
|
|
||||||
setState(() => _hovering = true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onExit: () {
|
|
||||||
if (mounted && _hovering) setState(() => _hovering = false);
|
|
||||||
},
|
|
||||||
onDrop: (files) async {
|
|
||||||
setState(() => _hovering = false);
|
|
||||||
try {
|
|
||||||
await widget.composer.importAttachments(files);
|
|
||||||
} catch (_) {
|
|
||||||
/* Shared composer publishes import feedback. */
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: internal,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
|
||||||
|
|
||||||
import '../../l10n/l10n.dart';
|
|
||||||
import 'chat_state.dart';
|
|
||||||
import 'agent_composer_controller.dart';
|
|
||||||
import 'composer_document.dart';
|
|
||||||
import 'agent_message_codec.dart';
|
|
||||||
|
|
||||||
/// Consume one draft after the shared chat controller's send preconditions pass.
|
|
||||||
String takeAgentDraft(
|
|
||||||
ComposerDocumentController input,
|
|
||||||
AgentComposerController composer,
|
|
||||||
) {
|
|
||||||
final text = AgentComposerMessage.encodeDocument(
|
|
||||||
input.segments,
|
|
||||||
composer.attachments,
|
|
||||||
);
|
|
||||||
input.clearDocument();
|
|
||||||
composer.clear();
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
String agentChatErrorMessage(BuildContext context, AgentChatError error) =>
|
|
||||||
switch (error) {
|
|
||||||
AgentChatError.configurationReadFailed =>
|
|
||||||
context.l10n.agentConfigurationReadFailed,
|
|
||||||
AgentChatError.configurationRequired =>
|
|
||||||
context.l10n.agentConfigurationRequired,
|
|
||||||
AgentChatError.sessionRestoreFailed =>
|
|
||||||
context.l10n.agentSessionRestoreFailed,
|
|
||||||
AgentChatError.contextBudget => context.l10n.agentContextBudgetExceeded,
|
|
||||||
AgentChatError.authentication => context.l10n.agentAuthenticationFailed,
|
|
||||||
AgentChatError.exportReplyFailed => context.l10n.agentExportReplyFailed,
|
|
||||||
AgentChatError.connection => context.l10n.agentConnectionFailed,
|
|
||||||
AgentChatError.protocol => context.l10n.agentProtocolFailed,
|
|
||||||
AgentChatError.turnLimit => context.l10n.agentTurnLimitReached,
|
|
||||||
AgentChatError.interrupted => context.l10n.agentTaskInterrupted,
|
|
||||||
AgentChatError.recoveryRequired => context.l10n.agentRecoveryRequired,
|
|
||||||
AgentChatError.replyFailed => context.l10n.replyFailed,
|
|
||||||
AgentChatError.requestFailed => context.l10n.chatFailed,
|
|
||||||
};
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
import 'agent_reply_region.dart';
|
|
||||||
|
|
||||||
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
||||||
|
|
||||||
import '../../shared/layout/composer_layout.dart';
|
import '../../shared/layout/composer_layout.dart';
|
||||||
@@ -7,12 +5,10 @@ import '../../shared/theme/composer_style.dart';
|
|||||||
|
|
||||||
import 'package:cutdex/l10n/l10n.dart';
|
import 'package:cutdex/l10n/l10n.dart';
|
||||||
|
|
||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
|
|
||||||
import '../../integrations/platform/platform_capabilities.dart';
|
import '../../integrations/platform/platform_capabilities.dart';
|
||||||
import 'agent_composer_controller.dart';
|
import 'agent_composer_controller.dart';
|
||||||
import 'agent_attachment_drop_region.dart';
|
|
||||||
import 'agent_chat_actions.dart';
|
|
||||||
import 'agent_composer_store.dart';
|
import 'agent_composer_store.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -20,17 +16,21 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||||||
|
|
||||||
import '../../integrations/agent/agent_provider.dart';
|
import '../../integrations/agent/agent_provider.dart';
|
||||||
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
import 'package:cutdex_ui/theme.dart';
|
||||||
import 'package:cutdex_ui/widgets.dart';
|
import 'package:cutdex_ui/widgets.dart';
|
||||||
|
|
||||||
|
import '../../shared/widgets/drop_to_add_overlay.dart';
|
||||||
import '../settings/settings_page.dart';
|
import '../settings/settings_page.dart';
|
||||||
import 'chat_controller.dart';
|
import 'chat_controller.dart';
|
||||||
import 'chat_state.dart';
|
import 'chat_state.dart';
|
||||||
import '../../integrations/agent/conversation_repository.dart';
|
import '../../integrations/agent/conversation_repository.dart';
|
||||||
|
import '../../integrations/platform/native_project_drop_region.dart';
|
||||||
|
import '../../integrations/platform/native_file_drop_policy.dart';
|
||||||
|
import '../../workspace/media_import.dart';
|
||||||
import '../../workspace/external_media_import.dart';
|
import '../../workspace/external_media_import.dart';
|
||||||
import '../../settings/settings_operation.dart';
|
import '../../settings/settings_operation.dart';
|
||||||
import '../../workspace/projects.dart';
|
import '../../workspace/projects.dart';
|
||||||
|
import '../media/media_asset_drag.dart';
|
||||||
import '../media/media_browser_feedback.dart';
|
import '../media/media_browser_feedback.dart';
|
||||||
import 'agent_attachment_card.dart';
|
import 'agent_attachment_card.dart';
|
||||||
import 'agent_media_attachments.dart';
|
import 'agent_media_attachments.dart';
|
||||||
@@ -97,7 +97,8 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
'agent-model-${widget.projectId}-${widget.conversationId ?? widget.draftKey ?? 'new'}';
|
'agent-model-${widget.projectId}-${widget.conversationId ?? widget.draftKey ?? 'new'}';
|
||||||
bool get _choosingModel =>
|
bool get _choosingModel =>
|
||||||
ref.read(settingsOperationProvider(_modelOperation)).isLoading;
|
ref.read(settingsOperationProvider(_modelOperation)).isLoading;
|
||||||
bool get _usingDraftModel => _composer.usingDraftModel;
|
bool _usingDraftModel = false;
|
||||||
|
bool _dropHovering = false;
|
||||||
bool get _importingAttachments =>
|
bool get _importingAttachments =>
|
||||||
_composer.busy ||
|
_composer.busy ||
|
||||||
widget.projectId != null &&
|
widget.projectId != null &&
|
||||||
@@ -142,12 +143,33 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
if (oldWidget.conversationId != widget.conversationId ||
|
if (oldWidget.conversationId != widget.conversationId ||
|
||||||
oldWidget.projectId != widget.projectId ||
|
oldWidget.projectId != widget.projectId ||
|
||||||
oldWidget.draftKey != widget.draftKey) {
|
oldWidget.draftKey != widget.draftKey) {
|
||||||
|
_usingDraftModel = false;
|
||||||
_composer.removeListener(_composerChanged);
|
_composer.removeListener(_composerChanged);
|
||||||
_composer = _resolveComposer();
|
_composer = _resolveComposer();
|
||||||
_composer.addListener(_composerChanged);
|
_composer.addListener(_composerChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _errorMessage(BuildContext context, AgentChatError error) =>
|
||||||
|
switch (error) {
|
||||||
|
AgentChatError.configurationReadFailed =>
|
||||||
|
context.l10n.agentConfigurationReadFailed,
|
||||||
|
AgentChatError.configurationRequired =>
|
||||||
|
context.l10n.agentConfigurationRequired,
|
||||||
|
AgentChatError.sessionRestoreFailed =>
|
||||||
|
context.l10n.agentSessionRestoreFailed,
|
||||||
|
AgentChatError.contextBudget => context.l10n.agentContextBudgetExceeded,
|
||||||
|
AgentChatError.authentication => context.l10n.agentAuthenticationFailed,
|
||||||
|
AgentChatError.exportReplyFailed => context.l10n.agentExportReplyFailed,
|
||||||
|
AgentChatError.connection => context.l10n.agentConnectionFailed,
|
||||||
|
AgentChatError.protocol => context.l10n.agentProtocolFailed,
|
||||||
|
AgentChatError.turnLimit => context.l10n.agentTurnLimitReached,
|
||||||
|
AgentChatError.interrupted => context.l10n.agentTaskInterrupted,
|
||||||
|
AgentChatError.recoveryRequired => context.l10n.agentRecoveryRequired,
|
||||||
|
AgentChatError.replyFailed => context.l10n.replyFailed,
|
||||||
|
AgentChatError.requestFailed => context.l10n.chatFailed,
|
||||||
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -167,6 +189,41 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _canAttach(MediaAssetDrag drag) {
|
||||||
|
final workspace = ref.read(projectsProvider).asData?.value;
|
||||||
|
return widget.projectId == drag.projectId &&
|
||||||
|
workspace?.activeProject?.id == drag.projectId &&
|
||||||
|
!_attachments.any((item) => item.id == drag.assetId) &&
|
||||||
|
workspace!.assets.any((asset) => asset.id == drag.assetId);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _canAttachExternalFiles(List<ExternalMediaFile> files) {
|
||||||
|
if (files.isEmpty) return true;
|
||||||
|
final assets = ref.read(projectsProvider).asData?.value.assets;
|
||||||
|
if (assets == null) return false;
|
||||||
|
final attachedIds = {for (final item in _attachments) item.id};
|
||||||
|
final attachedLocations = {
|
||||||
|
for (final asset in assets)
|
||||||
|
if (attachedIds.contains(asset.id)) ?mediaSourceLocation(asset),
|
||||||
|
};
|
||||||
|
return files.any(
|
||||||
|
(file) => !attachedLocations.contains(file.sourceUri.toString()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _attachAsset(AssetDocument asset) => _composer.attach(asset);
|
||||||
|
|
||||||
|
bool get _desktop => ref.read(platformCapabilitiesProvider).nativeFileDrop;
|
||||||
|
|
||||||
|
Future<void> _dropExternalFiles(List<ExternalMediaFile> files) async {
|
||||||
|
setState(() => _dropHovering = false);
|
||||||
|
try {
|
||||||
|
await _composer.importAttachments(files);
|
||||||
|
} catch (_) {
|
||||||
|
// Feedback belongs to the composer even if this panel is hidden.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _pickAttachments() async {
|
Future<void> _pickAttachments() async {
|
||||||
try {
|
try {
|
||||||
await _composer.pickAttachments();
|
await _composer.pickAttachments();
|
||||||
@@ -175,27 +232,64 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
Widget _agentDropRegion(Widget child) {
|
||||||
Widget build(BuildContext context) {
|
final workspace = ref.watch(projectsProvider).asData?.value;
|
||||||
ref.watch(
|
final enabled =
|
||||||
settingsOperationProvider(_modelOperation)
|
_desktop &&
|
||||||
.select((value) => value.isLoading),
|
widget.projectId != null &&
|
||||||
);
|
workspace?.activeProject?.id == widget.projectId &&
|
||||||
if (widget.projectId != null) {
|
(workspace?.projectBusy == false || _importingAttachments);
|
||||||
ref.watch(
|
final internal = DragTarget<MediaAssetDrag>(
|
||||||
externalMediaImportProvider(widget.projectId!)
|
key: const Key('agent-panel-drop-target'),
|
||||||
.select((value) => value.isLoading),
|
hitTestBehavior: HitTestBehavior.opaque,
|
||||||
);
|
onWillAcceptWithDetails: (details) => _canAttach(details.data),
|
||||||
}
|
onAcceptWithDetails: (details) {
|
||||||
final workspace = ref.watch(
|
final drag = details.data;
|
||||||
projectsProvider.select(
|
if (!_canAttach(drag)) return;
|
||||||
(value) => value.asData?.value.copyWith(
|
final asset = ref
|
||||||
recent: const [],
|
.read(projectsProvider)
|
||||||
error: null,
|
.asData!
|
||||||
creatingTimeline: false,
|
.value
|
||||||
),
|
.assets
|
||||||
|
.firstWhere((item) => item.id == drag.assetId);
|
||||||
|
_attachAsset(asset);
|
||||||
|
},
|
||||||
|
builder: (context, candidates, rejected) => Stack(
|
||||||
|
fit: StackFit.expand,
|
||||||
|
children: [
|
||||||
|
child,
|
||||||
|
if (candidates.isNotEmpty || _dropHovering)
|
||||||
|
const Positioned.fill(
|
||||||
|
child: DropToAddOverlay(key: Key('agent-drop-overlay')),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
if (!_desktop) return internal;
|
||||||
|
return NativeProjectDropRegion(
|
||||||
|
regionId: 'attachments',
|
||||||
|
policy: NativeFileDropPolicy.attachments,
|
||||||
|
enabled: enabled,
|
||||||
|
onEnter: (files) {
|
||||||
|
if (!_importingAttachments && _canAttachExternalFiles(files)) {
|
||||||
|
setState(() => _dropHovering = true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onExit: () {
|
||||||
|
if (mounted && _dropHovering) setState(() => _dropHovering = false);
|
||||||
|
},
|
||||||
|
onDrop: _dropExternalFiles,
|
||||||
|
child: internal,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
ref.watch(settingsOperationProvider(_modelOperation));
|
||||||
|
if (widget.projectId != null) {
|
||||||
|
ref.watch(externalMediaImportProvider(widget.projectId!));
|
||||||
|
}
|
||||||
|
final workspace = ref.watch(projectsProvider).asData?.value;
|
||||||
final referenceValidator = ComposerReferenceValidator(
|
final referenceValidator = ComposerReferenceValidator(
|
||||||
workspace: workspace,
|
workspace: workspace,
|
||||||
projectId: widget.projectId,
|
projectId: widget.projectId,
|
||||||
@@ -211,9 +305,7 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
draftKey: widget.draftKey,
|
draftKey: widget.draftKey,
|
||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
final state = provider == null
|
final state = provider == null ? const ChatState() : ref.watch(provider);
|
||||||
? const ChatState()
|
|
||||||
: ref.watch(provider.select(chatChrome));
|
|
||||||
final settings = ref.watch(agentSettingsProvider).asData?.value;
|
final settings = ref.watch(agentSettingsProvider).asData?.value;
|
||||||
final available =
|
final available =
|
||||||
settings?.providers
|
settings?.providers
|
||||||
@@ -268,7 +360,7 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
});
|
});
|
||||||
if (!mounted || !context.mounted) return;
|
if (!mounted || !context.mounted) return;
|
||||||
if (saved) {
|
if (saved) {
|
||||||
_composer.useDraftModel();
|
setState(() => _usingDraftModel = true);
|
||||||
} else {
|
} else {
|
||||||
ErrorNotificationHost.of(context).show(
|
ErrorNotificationHost.of(context).show(
|
||||||
ErrorNotification(
|
ErrorNotification(
|
||||||
@@ -287,7 +379,7 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
key: const Key('agent-configure-model'),
|
key: const Key('agent-configure-model'),
|
||||||
style: compactButtonStyle,
|
style: compactButtonStyle,
|
||||||
onPressed: () => showSettingsPage(context, initialTab: 1),
|
onPressed: () => showSettingsPage(context, initialTab: 1),
|
||||||
icon: const Icon(AppIcons.tune, size: 16),
|
icon: const Icon(Icons.tune, size: 16),
|
||||||
label: Text(context.l10n.agentConfigureModel),
|
label: Text(context.l10n.agentConfigureModel),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -331,14 +423,14 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
const Icon(AppIcons.expandMore, size: 14),
|
const Icon(Icons.expand_more, size: 14),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (provider != null && TickerMode.valuesOf(context).enabled) {
|
if (provider != null) {
|
||||||
ref.listen(provider, (previous, next) {
|
ref.listen(provider, (previous, next) {
|
||||||
if (_follow) {
|
if (_follow) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
@@ -361,7 +453,12 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
(_input.text.trim().isEmpty && _attachments.isEmpty)) {
|
(_input.text.trim().isEmpty && _attachments.isEmpty)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final text = takeAgentDraft(_input, _composer);
|
final text = AgentComposerMessage.encodeDocument(
|
||||||
|
_input.segments,
|
||||||
|
_attachments,
|
||||||
|
);
|
||||||
|
_input.clearDocument();
|
||||||
|
_composer.clear();
|
||||||
_follow = true;
|
_follow = true;
|
||||||
ref
|
ref
|
||||||
.read(provider.notifier)
|
.read(provider.notifier)
|
||||||
@@ -374,10 +471,8 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final content = AgentAttachmentDropRegion(
|
final content = _agentDropRegion(
|
||||||
projectId: widget.projectId,
|
LayoutBuilder(
|
||||||
composer: _composer,
|
|
||||||
child: LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final panelWidth =
|
final panelWidth =
|
||||||
(constraints.maxWidth - ComposerLayout.horizontalInset * 2)
|
(constraints.maxWidth - ComposerLayout.horizontalInset * 2)
|
||||||
@@ -467,8 +562,8 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Icon(
|
Icon(
|
||||||
AppIcons
|
Icons
|
||||||
.chevronRight,
|
.chevron_right,
|
||||||
size: 14,
|
size: 14,
|
||||||
color:
|
color:
|
||||||
AppTheme.chatMetaTextStyle(
|
AppTheme.chatMetaTextStyle(
|
||||||
@@ -480,6 +575,7 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
),
|
),
|
||||||
Divider(
|
Divider(
|
||||||
height: 1,
|
height: 1,
|
||||||
|
thickness: 1,
|
||||||
color:
|
color:
|
||||||
theme.dividerColor,
|
theme.dividerColor,
|
||||||
),
|
),
|
||||||
@@ -544,39 +640,32 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
in AgentComposerMessage.decode(
|
in AgentComposerMessage.decode(
|
||||||
message.text,
|
message.text,
|
||||||
).attachments)
|
).attachments)
|
||||||
Consumer(
|
if (ref
|
||||||
builder: (context, ref, _) {
|
.watch(
|
||||||
final asset = ref.watch(
|
projectsProvider,
|
||||||
projectsProvider.select(
|
)
|
||||||
(
|
.asData
|
||||||
value,
|
?.value
|
||||||
) => value
|
.assets
|
||||||
.asData
|
.where(
|
||||||
?.value
|
(
|
||||||
.assets
|
asset,
|
||||||
.where(
|
) =>
|
||||||
(
|
asset.id ==
|
||||||
asset,
|
attachment.id,
|
||||||
) =>
|
)
|
||||||
asset.id ==
|
.firstOrNull
|
||||||
attachment.id,
|
case final asset?)
|
||||||
)
|
AgentAttachmentCard(
|
||||||
.firstOrNull,
|
asset: asset,
|
||||||
),
|
)
|
||||||
);
|
else
|
||||||
return asset ==
|
Chip(
|
||||||
null
|
label: Text(
|
||||||
? Chip(
|
attachment
|
||||||
label: Text(
|
.name,
|
||||||
attachment.name,
|
),
|
||||||
),
|
),
|
||||||
)
|
|
||||||
: AgentAttachmentCard(
|
|
||||||
asset:
|
|
||||||
asset,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -592,12 +681,44 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
AgentReplyRegion(
|
if (state.busy) ...[
|
||||||
projectId: widget.projectId,
|
if (state
|
||||||
conversationId:
|
.partialResponse
|
||||||
widget.conversationId,
|
.isNotEmpty)
|
||||||
draftKey: widget.draftKey,
|
SelectableText(
|
||||||
),
|
state.partialResponse,
|
||||||
|
style:
|
||||||
|
AppTheme.chatMessageTextStyle(
|
||||||
|
context,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
state.stopping
|
||||||
|
? context.l10n.stopping
|
||||||
|
: switch (state.activity) {
|
||||||
|
AgentChatActivity
|
||||||
|
.compacting =>
|
||||||
|
context
|
||||||
|
.l10n
|
||||||
|
.agentCompacting,
|
||||||
|
AgentChatActivity
|
||||||
|
.editing =>
|
||||||
|
context
|
||||||
|
.l10n
|
||||||
|
.agentEditing,
|
||||||
|
AgentChatActivity
|
||||||
|
.verifying =>
|
||||||
|
context
|
||||||
|
.l10n
|
||||||
|
.agentVerifying,
|
||||||
|
AgentChatActivity
|
||||||
|
.replying =>
|
||||||
|
context.l10n.replying,
|
||||||
|
},
|
||||||
|
style:
|
||||||
|
theme.textTheme.bodySmall,
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -630,7 +751,7 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
horizontal: AppSpacing.compact,
|
horizontal: AppSpacing.compact,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
agentChatErrorMessage(context, error),
|
_errorMessage(context, error),
|
||||||
style: theme.textTheme.bodySmall,
|
style: theme.textTheme.bodySmall,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -924,7 +1045,7 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
? _pickAttachments
|
? _pickAttachments
|
||||||
: null,
|
: null,
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
AppIcons.add,
|
Icons.add,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@@ -964,7 +1085,7 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
)
|
)
|
||||||
.stop,
|
.stop,
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
AppIcons.stop,
|
Icons.stop,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
@@ -999,7 +1120,7 @@ class _AgentChatPanelState extends ConsumerState<AgentChatPanel> {
|
|||||||
? send
|
? send
|
||||||
: null,
|
: null,
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
AppIcons.arrowUp,
|
Icons.arrow_upward,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import '../../workspace/external_media_import.dart';
|
import '../../workspace/external_media_import.dart';
|
||||||
@@ -22,14 +22,6 @@ class AgentComposerController extends ChangeNotifier {
|
|||||||
final List<AgentMediaAttachment> attachments;
|
final List<AgentMediaAttachment> attachments;
|
||||||
final feedback = MediaImportFeedbackController();
|
final feedback = MediaImportFeedbackController();
|
||||||
bool _busy = false;
|
bool _busy = false;
|
||||||
bool _usingDraftModel = false;
|
|
||||||
bool get usingDraftModel => _usingDraftModel;
|
|
||||||
void useDraftModel() {
|
|
||||||
if (_disposed) return;
|
|
||||||
_usingDraftModel = true;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
bool get busy => _busy;
|
bool get busy => _busy;
|
||||||
|
|
||||||
|
|||||||
@@ -37,24 +37,12 @@ final class AgentComposerStore {
|
|||||||
final AgentComposerController Function(String?) createComposer;
|
final AgentComposerController Function(String?) createComposer;
|
||||||
ComposerDocumentController _draft = ComposerDocumentController();
|
ComposerDocumentController _draft = ComposerDocumentController();
|
||||||
ComposerDocumentController get draft => _draft;
|
ComposerDocumentController get draft => _draft;
|
||||||
final _projectDrafts = <String?, ComposerDocumentController>{};
|
|
||||||
final _inputs = <(String?, String), ComposerDocumentController>{};
|
final _inputs = <(String?, String), ComposerDocumentController>{};
|
||||||
final _composers = <(String?, String), AgentComposerController>{};
|
final _composers = <(String?, String), AgentComposerController>{};
|
||||||
|
|
||||||
ComposerDocumentController input(
|
ComposerDocumentController input(String? projectId, String? conversationId) =>
|
||||||
String? projectId,
|
conversationId == null
|
||||||
String? conversationId, {
|
? draft
|
||||||
bool projectScoped = false,
|
|
||||||
}) => conversationId == null
|
|
||||||
? projectScoped
|
|
||||||
? _projectDrafts.putIfAbsent(
|
|
||||||
projectId,
|
|
||||||
() => projectId == null
|
|
||||||
? ComposerDocumentController()
|
|
||||||
: _projectDrafts.remove(null) ??
|
|
||||||
ComposerDocumentController(),
|
|
||||||
)
|
|
||||||
: draft
|
|
||||||
: _inputs.putIfAbsent((
|
: _inputs.putIfAbsent((
|
||||||
projectId,
|
projectId,
|
||||||
conversationId,
|
conversationId,
|
||||||
@@ -69,9 +57,8 @@ final class AgentComposerStore {
|
|||||||
void promoteDraft(String projectId, String draftKey, String conversationId) {
|
void promoteDraft(String projectId, String draftKey, String conversationId) {
|
||||||
final destination = (projectId, conversationId);
|
final destination = (projectId, conversationId);
|
||||||
_inputs.remove(destination)?.dispose();
|
_inputs.remove(destination)?.dispose();
|
||||||
final scoped = _projectDrafts.remove(projectId);
|
_inputs[destination] = _draft;
|
||||||
_inputs[destination] = scoped ?? _draft;
|
_draft = ComposerDocumentController();
|
||||||
if (scoped == null) _draft = ComposerDocumentController();
|
|
||||||
final composer = _composers.remove((projectId, draftKey));
|
final composer = _composers.remove((projectId, draftKey));
|
||||||
if (composer != null) {
|
if (composer != null) {
|
||||||
_composers.remove(destination)?.dispose();
|
_composers.remove(destination)?.dispose();
|
||||||
@@ -90,10 +77,6 @@ final class AgentComposerStore {
|
|||||||
|
|
||||||
void dispose() {
|
void dispose() {
|
||||||
draft.dispose();
|
draft.dispose();
|
||||||
for (final input in _projectDrafts.values) {
|
|
||||||
input.dispose();
|
|
||||||
}
|
|
||||||
_projectDrafts.clear();
|
|
||||||
for (final input in _inputs.values) {
|
for (final input in _inputs.values) {
|
||||||
input.dispose();
|
input.dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import 'dart:convert';
|
|||||||
import 'package:cutdex_agent/cutdex_agent.dart';
|
import 'package:cutdex_agent/cutdex_agent.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
import 'package:cutdex_native_flutter/cutdex_native_flutter.dart';
|
import 'package:cutdex_sdk/runtime.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
import '../../diagnostics/agent_request_diagnostics.dart';
|
import '../../diagnostics/agent_request_diagnostics.dart';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
part 'agent_media_attachments.freezed.dart';
|
part 'agent_media_attachments.freezed.dart';
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
|
||||||
|
|
||||||
class AgentPanelPresentation extends InheritedWidget {
|
|
||||||
const AgentPanelPresentation({
|
|
||||||
super.key,
|
|
||||||
required this.compact,
|
|
||||||
this.expanded = false,
|
|
||||||
this.onToggleExpanded,
|
|
||||||
this.onDock,
|
|
||||||
required super.child,
|
|
||||||
});
|
|
||||||
final bool compact;
|
|
||||||
final bool expanded;
|
|
||||||
final VoidCallback? onToggleExpanded;
|
|
||||||
final VoidCallback? onDock;
|
|
||||||
static AgentPanelPresentation? of(BuildContext context) =>
|
|
||||||
context.dependOnInheritedWidgetOfExactType<AgentPanelPresentation>();
|
|
||||||
static bool compactOf(BuildContext context) =>
|
|
||||||
context
|
|
||||||
.dependOnInheritedWidgetOfExactType<AgentPanelPresentation>()
|
|
||||||
?.compact ??
|
|
||||||
false;
|
|
||||||
@override
|
|
||||||
bool updateShouldNotify(AgentPanelPresentation oldWidget) =>
|
|
||||||
compact != oldWidget.compact || expanded != oldWidget.expanded;
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
|
||||||
|
|
||||||
import '../../l10n/l10n.dart';
|
|
||||||
import 'chat_controller.dart';
|
|
||||||
import 'chat_state.dart';
|
|
||||||
|
|
||||||
/// Streaming output observes its conversation independently of history/composer.
|
|
||||||
class AgentReplyRegion extends ConsumerWidget {
|
|
||||||
const AgentReplyRegion({
|
|
||||||
super.key,
|
|
||||||
required this.projectId,
|
|
||||||
this.conversationId,
|
|
||||||
this.draftKey,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String? projectId;
|
|
||||||
final String? conversationId;
|
|
||||||
final String? draftKey;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
if (projectId == null) return const SizedBox.shrink();
|
|
||||||
final provider =
|
|
||||||
chatControllerProvider(
|
|
||||||
projectId!,
|
|
||||||
conversationId: conversationId,
|
|
||||||
draftKey: draftKey,
|
|
||||||
).select(
|
|
||||||
(state) => (
|
|
||||||
state.busy,
|
|
||||||
state.partialResponse,
|
|
||||||
state.stopping,
|
|
||||||
state.activity,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final state = TickerMode.valuesOf(context).enabled
|
|
||||||
? ref.watch(provider)
|
|
||||||
: ref.read(provider);
|
|
||||||
if (!state.$1) return const SizedBox.shrink();
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
|
||||||
if (state.$2.isNotEmpty)
|
|
||||||
SelectionArea(
|
|
||||||
child: Text(
|
|
||||||
state.$2,
|
|
||||||
style: AppTheme.chatMessageTextStyle(context),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
state.$3
|
|
||||||
? context.l10n.stopping
|
|
||||||
: switch (state.$4) {
|
|
||||||
AgentChatActivity.compacting => context.l10n.agentCompacting,
|
|
||||||
AgentChatActivity.editing => context.l10n.agentEditing,
|
|
||||||
AgentChatActivity.verifying => context.l10n.agentVerifying,
|
|
||||||
AgentChatActivity.replying => context.l10n.replying,
|
|
||||||
},
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Stable chrome/history snapshot; each streamed token belongs to reply region.
|
|
||||||
ChatState chatChrome(ChatState state) =>
|
|
||||||
state.copyWith(partialResponse: '', activity: AgentChatActivity.replying);
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
import 'package:cutdex_ui/theme.dart';
|
||||||
|
|
||||||
part 'composer_document.freezed.dart';
|
part 'composer_document.freezed.dart';
|
||||||
@@ -323,8 +322,8 @@ class ComposerDocumentController extends TextEditingController {
|
|||||||
padding: const EdgeInsets.only(right: 4),
|
padding: const EdgeInsets.only(right: 4),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
mark.reference.kind == ComposerReferenceKind.timeline
|
mark.reference.kind == ComposerReferenceKind.timeline
|
||||||
? AppIcons.timeline
|
? Icons.view_timeline_outlined
|
||||||
: AppIcons.attachment,
|
: Icons.attach_file,
|
||||||
size: 14,
|
size: 14,
|
||||||
color: color,
|
color: color,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import '../../l10n/l10n.dart';
|
|||||||
import '../../shared/layout/composer_layout.dart';
|
import '../../shared/layout/composer_layout.dart';
|
||||||
import '../../shared/theme/composer_style.dart';
|
import '../../shared/theme/composer_style.dart';
|
||||||
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
import 'package:cutdex_ui/theme.dart';
|
||||||
|
|
||||||
import '../../workspace/project_state.dart';
|
import '../../workspace/project_state.dart';
|
||||||
@@ -73,7 +72,7 @@ class _ComposerProjectSelectorState extends State<ComposerProjectSelector> {
|
|||||||
if (selected == true) ...[
|
if (selected == true) ...[
|
||||||
const SizedBox(width: ComposerLayout.menuIconGap),
|
const SizedBox(width: ComposerLayout.menuIconGap),
|
||||||
Icon(
|
Icon(
|
||||||
AppIcons.check,
|
Icons.check,
|
||||||
size: ComposerLayout.menuIconSize,
|
size: ComposerLayout.menuIconSize,
|
||||||
color: colors.onSurfaceVariant,
|
color: colors.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
@@ -86,7 +85,10 @@ class _ComposerProjectSelectorState extends State<ComposerProjectSelector> {
|
|||||||
|
|
||||||
Widget _separator() => const Padding(
|
Widget _separator() => const Padding(
|
||||||
padding: AppComposerStyle.menuSeparatorPadding,
|
padding: AppComposerStyle.menuSeparatorPadding,
|
||||||
child: Divider(height: 1),
|
child: Divider(
|
||||||
|
height: 1,
|
||||||
|
thickness: AppComposerStyle.menuSeparatorThickness,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -139,8 +141,6 @@ class _ComposerProjectSelectorState extends State<ComposerProjectSelector> {
|
|||||||
controller: _search,
|
controller: _search,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
style: AppTheme.composerTextStyle(context),
|
style: AppTheme.composerTextStyle(context),
|
||||||
cursorHeight: AppTheme.composerCursorHeight(context),
|
|
||||||
textAlignVertical: TextAlignVertical.center,
|
|
||||||
onChanged: (_) => setState(() {}),
|
onChanged: (_) => setState(() {}),
|
||||||
decoration: AppComposerStyle.projectSearchDecoration(
|
decoration: AppComposerStyle.projectSearchDecoration(
|
||||||
context,
|
context,
|
||||||
@@ -169,7 +169,7 @@ class _ComposerProjectSelectorState extends State<ComposerProjectSelector> {
|
|||||||
_item(
|
_item(
|
||||||
key: ValueKey('composer-project-${project.id}'),
|
key: ValueKey('composer-project-${project.id}'),
|
||||||
label: project.name,
|
label: project.name,
|
||||||
icon: AppIcons.folder,
|
icon: Icons.folder_outlined,
|
||||||
selected: project.id == widget.selected?.id,
|
selected: project.id == widget.selected?.id,
|
||||||
onPressed:
|
onPressed:
|
||||||
widget.busy || !project.availability.canOpen
|
widget.busy || !project.availability.canOpen
|
||||||
@@ -188,7 +188,7 @@ class _ComposerProjectSelectorState extends State<ComposerProjectSelector> {
|
|||||||
key: const Key('composer-new-project'),
|
key: const Key('composer-new-project'),
|
||||||
secondary: true,
|
secondary: true,
|
||||||
label: context.l10n.newProject,
|
label: context.l10n.newProject,
|
||||||
icon: AppIcons.add,
|
icon: Icons.add,
|
||||||
onPressed: widget.busy || widget.onCreate == null
|
onPressed: widget.busy || widget.onCreate == null
|
||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
@@ -209,7 +209,7 @@ class _ComposerProjectSelectorState extends State<ComposerProjectSelector> {
|
|||||||
: controller.open(),
|
: controller.open(),
|
||||||
style: AppComposerStyle.projectTrigger(context),
|
style: AppComposerStyle.projectTrigger(context),
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
AppIcons.folder,
|
Icons.folder_outlined,
|
||||||
size: ComposerLayout.menuIconSize,
|
size: ComposerLayout.menuIconSize,
|
||||||
),
|
),
|
||||||
label: Text(
|
label: Text(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../l10n/app_localizations.dart';
|
import '../../l10n/app_localizations.dart';
|
||||||
@@ -63,10 +62,10 @@ abstract final class ComposerOptionCatalog {
|
|||||||
title: asset.name,
|
title: asset.name,
|
||||||
subtitle: l10n.materials,
|
subtitle: l10n.materials,
|
||||||
icon: switch (asset.metadata['kind']) {
|
icon: switch (asset.metadata['kind']) {
|
||||||
'video' => AppIcons.video,
|
'video' => Icons.movie_outlined,
|
||||||
'audio' => AppIcons.audio,
|
'audio' => Icons.audiotrack_outlined,
|
||||||
'image' => AppIcons.image,
|
'image' => Icons.image_outlined,
|
||||||
_ => AppIcons.file,
|
_ => Icons.insert_drive_file_outlined,
|
||||||
},
|
},
|
||||||
group: ComposerOptionGroup.media,
|
group: ComposerOptionGroup.media,
|
||||||
reference: ComposerReference(
|
reference: ComposerReference(
|
||||||
@@ -81,7 +80,7 @@ abstract final class ComposerOptionCatalog {
|
|||||||
trigger: '@',
|
trigger: '@',
|
||||||
title: timeline.name,
|
title: timeline.name,
|
||||||
subtitle: l10n.timelines,
|
subtitle: l10n.timelines,
|
||||||
icon: AppIcons.timeline,
|
icon: Icons.view_timeline_outlined,
|
||||||
group: ComposerOptionGroup.timeline,
|
group: ComposerOptionGroup.timeline,
|
||||||
reference: ComposerReference(
|
reference: ComposerReference(
|
||||||
kind: ComposerReferenceKind.timeline,
|
kind: ComposerReferenceKind.timeline,
|
||||||
|
|||||||
@@ -1,792 +0,0 @@
|
|||||||
import 'agent_reply_region.dart';
|
|
||||||
import '../../workspace/projects.dart';
|
|
||||||
|
|
||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
|
||||||
import 'package:cutdex_ui/widgets.dart';
|
|
||||||
|
|
||||||
import '../../shared/layout/composer_layout.dart';
|
|
||||||
import '../../shared/theme/composer_style.dart';
|
|
||||||
import '../../shared/widgets/workspace_resize_handle.dart';
|
|
||||||
|
|
||||||
import '../../l10n/l10n.dart';
|
|
||||||
import '../../workspace/project_state.dart';
|
|
||||||
import '../../workspace/external_media_import.dart';
|
|
||||||
import '../../integrations/agent/agent_provider.dart';
|
|
||||||
import '../../integrations/agent/conversation_repository.dart';
|
|
||||||
import '../projects/conversation_sidebar.dart';
|
|
||||||
import '../media/media_browser_feedback.dart';
|
|
||||||
import '../settings/settings_page.dart';
|
|
||||||
import '../../settings/settings_operation.dart';
|
|
||||||
import '../../shared/widgets/error_notification_host.dart';
|
|
||||||
import 'agent_chat_actions.dart';
|
|
||||||
import 'agent_attachment_card.dart';
|
|
||||||
import 'agent_attachment_drop_region.dart';
|
|
||||||
import 'agent_composer_controller.dart';
|
|
||||||
import 'agent_message_codec.dart';
|
|
||||||
import 'breakable_selectable_text.dart';
|
|
||||||
import 'chat_controller.dart';
|
|
||||||
import 'chat_state.dart';
|
|
||||||
import 'composer_document.dart';
|
|
||||||
import 'composer_reference_validator.dart';
|
|
||||||
import 'composer_suggestion_surface.dart';
|
|
||||||
|
|
||||||
/// Independent floating presentation of the same conversation and draft stores.
|
|
||||||
class FloatingAgentPanel extends ConsumerStatefulWidget {
|
|
||||||
const FloatingAgentPanel({
|
|
||||||
super.key,
|
|
||||||
required this.state,
|
|
||||||
required this.selection,
|
|
||||||
required this.input,
|
|
||||||
required this.composer,
|
|
||||||
required this.expanded,
|
|
||||||
required this.onToggleExpanded,
|
|
||||||
required this.onDock,
|
|
||||||
required this.onConversationCreated,
|
|
||||||
required this.onConversationUpdated,
|
|
||||||
});
|
|
||||||
final ProjectState state;
|
|
||||||
final ConversationSelectionState selection;
|
|
||||||
final ComposerDocumentController input;
|
|
||||||
final AgentComposerController composer;
|
|
||||||
final bool expanded;
|
|
||||||
final VoidCallback onToggleExpanded;
|
|
||||||
final VoidCallback onDock;
|
|
||||||
final ValueChanged<ConversationMetadata> onConversationCreated;
|
|
||||||
final ValueChanged<ConversationMetadata> onConversationUpdated;
|
|
||||||
@override
|
|
||||||
ConsumerState<FloatingAgentPanel> createState() => _FloatingAgentPanelState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FloatingAgentPanelState extends ConsumerState<FloatingAgentPanel>
|
|
||||||
with SingleTickerProviderStateMixin {
|
|
||||||
final _scroll = ScrollController();
|
|
||||||
late final AnimationController _reveal;
|
|
||||||
bool _resizing = false;
|
|
||||||
|
|
||||||
void _animateReveal(bool expanded) {
|
|
||||||
_reveal.animateTo(expanded ? 1 : 0, curve: Curves.easeOutCubic);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _startResize() {
|
|
||||||
_reveal.stop();
|
|
||||||
setState(() => _resizing = true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _finishResize() {
|
|
||||||
if (!_resizing) return;
|
|
||||||
final expanded = _reveal.value >= .35;
|
|
||||||
setState(() => _resizing = false);
|
|
||||||
if (expanded != widget.expanded) {
|
|
||||||
widget.onToggleExpanded();
|
|
||||||
} else {
|
|
||||||
_animateReveal(expanded);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void _changed() {
|
|
||||||
if (mounted) setState(() {});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_reveal = AnimationController(
|
|
||||||
vsync: this,
|
|
||||||
duration: const Duration(milliseconds: 220),
|
|
||||||
value: widget.expanded ? 1 : 0,
|
|
||||||
);
|
|
||||||
widget.composer.addListener(_changed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didUpdateWidget(FloatingAgentPanel oldWidget) {
|
|
||||||
super.didUpdateWidget(oldWidget);
|
|
||||||
if (widget.expanded != oldWidget.expanded) {
|
|
||||||
_animateReveal(widget.expanded);
|
|
||||||
}
|
|
||||||
if (oldWidget.input != widget.input) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
if (mounted && _scroll.hasClients) {
|
|
||||||
_scroll.jumpTo(_scroll.position.maxScrollExtent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (oldWidget.composer != widget.composer) {
|
|
||||||
oldWidget.composer.removeListener(_changed);
|
|
||||||
widget.composer.addListener(_changed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
widget.composer.removeListener(_changed);
|
|
||||||
_reveal.dispose();
|
|
||||||
_scroll.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final assets =
|
|
||||||
ref.watch(
|
|
||||||
projectsProvider.select(
|
|
||||||
(value) =>
|
|
||||||
value.asData?.value.activeProject?.id ==
|
|
||||||
widget.state.activeProject?.id
|
|
||||||
? value.asData?.value.assets
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
) ??
|
|
||||||
widget.state.assets;
|
|
||||||
final workspace = widget.state.copyWith(assets: assets);
|
|
||||||
final projectId = workspace.activeProject?.id;
|
|
||||||
final timelineId = widget.state.timeline?.id;
|
|
||||||
final selection = widget.selection;
|
|
||||||
final provider = projectId == null
|
|
||||||
? null
|
|
||||||
: chatControllerProvider(
|
|
||||||
projectId,
|
|
||||||
conversationId: selection.selectedId,
|
|
||||||
draftKey: selection.selectedId == null ? selection.draftKey : null,
|
|
||||||
);
|
|
||||||
final chat = provider == null
|
|
||||||
? const ChatState()
|
|
||||||
: ref.watch(provider.select(chatChrome));
|
|
||||||
final settings = ref.watch(agentSettingsProvider).value;
|
|
||||||
final available =
|
|
||||||
settings?.providers
|
|
||||||
.where(
|
|
||||||
(p) =>
|
|
||||||
p.enabled &&
|
|
||||||
AgentApiType.values.any((type) => type.name == p.apiType) &&
|
|
||||||
p.models.isNotEmpty,
|
|
||||||
)
|
|
||||||
.toList() ??
|
|
||||||
[];
|
|
||||||
final conversation = chat.conversation;
|
|
||||||
final providerId = conversation?.providerId ?? settings?.selectedProviderId;
|
|
||||||
final modelId = conversation?.modelId ?? settings?.selectedModelId;
|
|
||||||
final selectedProvider = available
|
|
||||||
.where((p) => p.id == providerId)
|
|
||||||
.firstOrNull;
|
|
||||||
final selectedModel = selectedProvider?.models
|
|
||||||
.where((m) => m.id == modelId)
|
|
||||||
.firstOrNull;
|
|
||||||
final configured =
|
|
||||||
conversation != null ||
|
|
||||||
(selection.selectedId != null && !widget.composer.usingDraftModel)
|
|
||||||
? conversation != null &&
|
|
||||||
settings?.enabled == true &&
|
|
||||||
selectedModel != null
|
|
||||||
: ref.watch(agentRuntimeProvider).value != null;
|
|
||||||
final importing =
|
|
||||||
widget.composer.busy ||
|
|
||||||
(projectId != null &&
|
|
||||||
ref.watch(
|
|
||||||
externalMediaImportProvider(projectId)
|
|
||||||
.select((value) => value.isLoading),
|
|
||||||
));
|
|
||||||
final operation =
|
|
||||||
'agent-model-$projectId-${selection.selectedId ?? selection.draftKey}';
|
|
||||||
final choosingModel = ref.watch(
|
|
||||||
settingsOperationProvider(operation).select((value) => value.isLoading),
|
|
||||||
);
|
|
||||||
final validator = ComposerReferenceValidator(
|
|
||||||
workspace: workspace,
|
|
||||||
projectId: projectId,
|
|
||||||
);
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
if (mounted) validator.validate(widget.input);
|
|
||||||
});
|
|
||||||
if (provider != null && TickerMode.valuesOf(context).enabled) {
|
|
||||||
ref.listen(provider, (old, next) {
|
|
||||||
if (_scroll.hasClients && _scroll.position.extentAfter < 80) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
if (mounted && _scroll.hasClients) {
|
|
||||||
_scroll.jumpTo(_scroll.position.maxScrollExtent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
void send() {
|
|
||||||
validator.validate(widget.input);
|
|
||||||
if (provider == null ||
|
|
||||||
timelineId == null ||
|
|
||||||
!configured ||
|
|
||||||
choosingModel ||
|
|
||||||
chat.busy ||
|
|
||||||
importing ||
|
|
||||||
widget.input.hasInvalidReferences ||
|
|
||||||
(widget.input.text.trim().isEmpty &&
|
|
||||||
widget.composer.attachments.isEmpty)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final text = takeAgentDraft(widget.input, widget.composer);
|
|
||||||
if (!widget.expanded) widget.onToggleExpanded();
|
|
||||||
unawaited(
|
|
||||||
ref
|
|
||||||
.read(provider.notifier)
|
|
||||||
.send(
|
|
||||||
text,
|
|
||||||
timelineId: timelineId,
|
|
||||||
onCreated: widget.onConversationCreated,
|
|
||||||
onUpdated: widget.onConversationUpdated,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> chooseModel(String p, String m) async {
|
|
||||||
if (chat.busy || choosingModel) return;
|
|
||||||
final composer = widget.composer;
|
|
||||||
final saved = await ref
|
|
||||||
.read(settingsOperationProvider(operation).notifier)
|
|
||||||
.run(() async {
|
|
||||||
if (provider == null) {
|
|
||||||
await ref.read(agentSettingsProvider.notifier).selectModel(p, m);
|
|
||||||
} else {
|
|
||||||
await ref.read(provider.notifier).selectModel(p, m);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!mounted || !context.mounted) return;
|
|
||||||
if (saved) composer.useDraftModel();
|
|
||||||
if (!saved && context.mounted) {
|
|
||||||
ErrorNotificationHost.of(context).show(
|
|
||||||
ErrorNotification(
|
|
||||||
content: Text(context.l10n.agentSaveSettingsFailed),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final groups = ref.watch(conversationSidebarProvider).value?.groups;
|
|
||||||
final items = groups?[projectId] ?? const <ConversationMetadata>[];
|
|
||||||
final title =
|
|
||||||
conversation?.title ??
|
|
||||||
items.where((c) => c.id == selection.selectedId).firstOrNull?.title ??
|
|
||||||
context.l10n.agentNewConversation;
|
|
||||||
final inputDecoration = AppComposerStyle.inputDecoration(
|
|
||||||
context,
|
|
||||||
hintText: context.l10n.assistantHint,
|
|
||||||
);
|
|
||||||
Widget modelButton() => AppDropdownMenu(
|
|
||||||
enabled: !chat.busy && !choosingModel,
|
|
||||||
minWidth: ComposerLayout.menuWidth,
|
|
||||||
maxHeight: ComposerLayout.menuListMaxHeight,
|
|
||||||
items: [
|
|
||||||
for (final p in available) ...[
|
|
||||||
AppMenuLabel(p.name),
|
|
||||||
for (final m in p.models)
|
|
||||||
AppMenuItem(
|
|
||||||
label: m.id,
|
|
||||||
selectOption: true,
|
|
||||||
selected: p.id == providerId && m.id == modelId,
|
|
||||||
onPressed: () => unawaited(chooseModel(p.id, m.id)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
const Divider(height: 1),
|
|
||||||
AppMenuItem(
|
|
||||||
label: context.l10n.agentConfigureModel,
|
|
||||||
onPressed: () => showSettingsPage(context, initialTab: 1),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
builder: (context, toggle, focus) => Tooltip(
|
|
||||||
message: selectedModel?.id ?? context.l10n.agentConfigureModel,
|
|
||||||
child: AppToolbarDropdownButton(
|
|
||||||
buttonKey: const Key('floating-agent-model-picker'),
|
|
||||||
focusNode: focus,
|
|
||||||
onPressed: toggle,
|
|
||||||
style: AppComposerStyle.controlButton(context),
|
|
||||||
child: const Icon(AppIcons.model, size: ComposerLayout.iconSize),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final conversationView = ExcludeFocus(
|
|
||||||
excluding: !widget.expanded && !_resizing,
|
|
||||||
child: IgnorePointer(
|
|
||||||
ignoring: !widget.expanded && !_resizing,
|
|
||||||
child: LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
|
||||||
final height = constraints.maxHeight.clamp(
|
|
||||||
AppControlSize.panelToolbar + 1,
|
|
||||||
double.infinity,
|
|
||||||
);
|
|
||||||
return ClipRect(
|
|
||||||
child: OverflowBox(
|
|
||||||
alignment: Alignment.topCenter,
|
|
||||||
minHeight: height,
|
|
||||||
maxHeight: height,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
height: AppControlSize.panelToolbar,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: AppSpacing.small,
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
key: const Key('floating-agent-collapse'),
|
|
||||||
style: AppComposerStyle.controlIcon(context),
|
|
||||||
tooltip: context.l10n.agentCollapseConversation,
|
|
||||||
onPressed: widget.onToggleExpanded,
|
|
||||||
icon: const Icon(
|
|
||||||
AppIcons.remove,
|
|
||||||
size: AppIconSize.header,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: AppDropdownMenu(
|
|
||||||
minWidth: ComposerLayout.menuWidth,
|
|
||||||
maxHeight: ComposerLayout.menuListMaxHeight,
|
|
||||||
items: [
|
|
||||||
AppMenuItem(
|
|
||||||
label: context.l10n.agentNewConversation,
|
|
||||||
onPressed: () => ref
|
|
||||||
.read(
|
|
||||||
conversationSidebarProvider.notifier,
|
|
||||||
)
|
|
||||||
.newConversation(),
|
|
||||||
),
|
|
||||||
for (final item in items)
|
|
||||||
AppMenuItem(
|
|
||||||
label: item.title,
|
|
||||||
selectOption: true,
|
|
||||||
selected: item.id == selection.selectedId,
|
|
||||||
onPressed: () {
|
|
||||||
final controller = ref.read(
|
|
||||||
conversationSidebarProvider.notifier,
|
|
||||||
);
|
|
||||||
controller.activate(item);
|
|
||||||
unawaited(
|
|
||||||
controller.rememberSelection(item),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
builder: (context, toggle, focus) =>
|
|
||||||
AppToolbarDropdownButton(
|
|
||||||
focusNode: focus,
|
|
||||||
onPressed: toggle,
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Flexible(
|
|
||||||
child: Text(
|
|
||||||
title,
|
|
||||||
key: const Key(
|
|
||||||
'agent-floating-title',
|
|
||||||
),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: AppSpacing.tiny,
|
|
||||||
),
|
|
||||||
const Icon(
|
|
||||||
AppIcons.expandMore,
|
|
||||||
size: AppIconSize.header,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
key: const Key('floating-agent-dock'),
|
|
||||||
style: AppComposerStyle.controlIcon(context),
|
|
||||||
tooltip: context.l10n.agentDock,
|
|
||||||
onPressed: widget.onDock,
|
|
||||||
icon: const Icon(
|
|
||||||
AppIcons.exitFullscreen,
|
|
||||||
size: AppIconSize.header,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: ListView(
|
|
||||||
controller: _scroll,
|
|
||||||
key: const Key('floating-agent-messages'),
|
|
||||||
padding: const EdgeInsets.all(AppSpacing.medium),
|
|
||||||
children: [
|
|
||||||
for (final message in chat.messages)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(
|
|
||||||
bottom: AppSpacing.large,
|
|
||||||
),
|
|
||||||
child: Align(
|
|
||||||
alignment: message.isUser
|
|
||||||
? Alignment.centerRight
|
|
||||||
: Alignment.centerLeft,
|
|
||||||
child: Container(
|
|
||||||
constraints: const BoxConstraints(
|
|
||||||
maxWidth: ComposerLayout.maxWidth,
|
|
||||||
),
|
|
||||||
padding: message.isUser
|
|
||||||
? const EdgeInsets.symmetric(
|
|
||||||
horizontal: AppSpacing.medium,
|
|
||||||
vertical: AppSpacing.itemVertical,
|
|
||||||
)
|
|
||||||
: EdgeInsets.zero,
|
|
||||||
decoration: message.isUser
|
|
||||||
? AppTheme.userMessageDecoration(context)
|
|
||||||
: null,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment:
|
|
||||||
CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
if (message.elapsedMs case final elapsed?)
|
|
||||||
Text(
|
|
||||||
context.l10n.agentElapsedTime(
|
|
||||||
context.l10n.durationSeconds(
|
|
||||||
(elapsed / 1000).ceil(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
style: AppTheme.chatMetaTextStyle(
|
|
||||||
context,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (message.isUser)
|
|
||||||
BreakableSelectableText(
|
|
||||||
text: AgentComposerMessage.decode(
|
|
||||||
message.text,
|
|
||||||
).text,
|
|
||||||
style: AppTheme.chatMessageTextStyle(
|
|
||||||
context,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
SelectableText(
|
|
||||||
AgentComposerMessage.decode(
|
|
||||||
message.text,
|
|
||||||
).text,
|
|
||||||
style: AppTheme.chatMessageTextStyle(
|
|
||||||
context,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
for (final attachment
|
|
||||||
in AgentComposerMessage.decode(
|
|
||||||
message.text,
|
|
||||||
).attachments)
|
|
||||||
Chip(label: Text(attachment.name)),
|
|
||||||
if (message.interrupted)
|
|
||||||
Text(context.l10n.replyInterrupted),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
AgentReplyRegion(
|
|
||||||
projectId: projectId,
|
|
||||||
conversationId: selection.selectedId,
|
|
||||||
draftKey: selection.selectedId == null
|
|
||||||
? selection.draftKey
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final composerView = Padding(
|
|
||||||
key: const Key('floating-agent-input-area'),
|
|
||||||
padding: const EdgeInsets.all(AppSpacing.small),
|
|
||||||
child: LayoutBuilder(
|
|
||||||
builder: (context, constraints) => ComposerSuggestionSurface(
|
|
||||||
controller: widget.input,
|
|
||||||
width: constraints.maxWidth,
|
|
||||||
projectId: projectId,
|
|
||||||
assets: assets,
|
|
||||||
timelines: widget.state.timelines,
|
|
||||||
onSend: send,
|
|
||||||
builder: (context, focus) {
|
|
||||||
final attachment = IconButton(
|
|
||||||
style: AppComposerStyle.controlIcon(context),
|
|
||||||
tooltip: context.l10n.addAttachment,
|
|
||||||
onPressed:
|
|
||||||
projectId == null || importing || widget.state.projectBusy
|
|
||||||
? null
|
|
||||||
: () async {
|
|
||||||
try {
|
|
||||||
await widget.composer.pickAttachments();
|
|
||||||
} catch (_) {
|
|
||||||
/* Shared composer publishes import feedback. */
|
|
||||||
}
|
|
||||||
},
|
|
||||||
icon: const Icon(AppIcons.add),
|
|
||||||
);
|
|
||||||
final input = TextField(
|
|
||||||
key: const Key('floating-agent-input'),
|
|
||||||
controller: widget.input,
|
|
||||||
focusNode: focus,
|
|
||||||
minLines: 1,
|
|
||||||
maxLines: 5,
|
|
||||||
style: AppTheme.composerTextStyle(context),
|
|
||||||
cursorHeight: AppTheme.composerCursorHeight(context),
|
|
||||||
decoration: inputDecoration.copyWith(
|
|
||||||
constraints: const BoxConstraints(
|
|
||||||
minHeight: ComposerLayout.controlSize,
|
|
||||||
),
|
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: AppSpacing.small,
|
|
||||||
vertical: AppSpacing.tiny,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
if (!widget.expanded) {
|
|
||||||
widget.onToggleExpanded();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
final submit = ValueListenableBuilder<TextEditingValue>(
|
|
||||||
valueListenable: widget.input,
|
|
||||||
builder: (context, value, _) => IconButton.filled(
|
|
||||||
style: AppTheme.accentIconButtonStyle(context)
|
|
||||||
.merge(AppComposerStyle.controlIcon(context)),
|
|
||||||
tooltip: chat.busy
|
|
||||||
? context.l10n.stopReply
|
|
||||||
: context.l10n.sendMessage,
|
|
||||||
onPressed: chat.busy
|
|
||||||
? (chat.stopping ? null : ref.read(provider!.notifier).stop)
|
|
||||||
: provider != null &&
|
|
||||||
timelineId != null &&
|
|
||||||
configured &&
|
|
||||||
!importing &&
|
|
||||||
!choosingModel &&
|
|
||||||
!widget.input.hasInvalidReferences &&
|
|
||||||
(value.text.trim().isNotEmpty ||
|
|
||||||
widget.composer.attachments.isNotEmpty)
|
|
||||||
? send
|
|
||||||
: null,
|
|
||||||
icon: Icon(
|
|
||||||
chat.busy ? AppIcons.squareFilled : AppIcons.arrowUp,
|
|
||||||
size: chat.busy ? 12 : ComposerLayout.iconSize,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
// Keep the editor at the same tree position and bottom
|
|
||||||
// anchor while the conversation opens above it.
|
|
||||||
return Row(
|
|
||||||
key: const Key('floating-agent-composer'),
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
attachment,
|
|
||||||
Expanded(child: input),
|
|
||||||
modelButton(),
|
|
||||||
submit,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final content = LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
|
||||||
final conversationHeight =
|
|
||||||
(constraints.maxHeight -
|
|
||||||
ComposerLayout.controlSize -
|
|
||||||
AppSpacing.small * 2)
|
|
||||||
.clamp(0.0, double.infinity);
|
|
||||||
return AnimatedBuilder(
|
|
||||||
animation: _reveal,
|
|
||||||
builder: (context, _) => MediaImportFeedbackListener(
|
|
||||||
feedback: widget.composer.feedback,
|
|
||||||
child: Material(
|
|
||||||
color: Theme.of(context).colorScheme.surface,
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Flexible(
|
|
||||||
child: SizedBox(
|
|
||||||
key: const Key('floating-agent-conversation-region'),
|
|
||||||
height: conversationHeight * _reveal.value,
|
|
||||||
child: ClipRect(
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Offstage(
|
|
||||||
offstage: _reveal.value == 0,
|
|
||||||
child: conversationView,
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 0,
|
|
||||||
child: Divider(
|
|
||||||
key: const Key(
|
|
||||||
'floating-agent-input-divider',
|
|
||||||
),
|
|
||||||
height: 1,
|
|
||||||
thickness: 1,
|
|
||||||
color: AppTheme.floatingDialogDividerColor(
|
|
||||||
context,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (chat.error case final error?)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(AppSpacing.small),
|
|
||||||
child: Text(
|
|
||||||
agentChatErrorMessage(context, error),
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if ({
|
|
||||||
AgentChatError.recoveryRequired,
|
|
||||||
AgentChatError.interrupted,
|
|
||||||
AgentChatError.turnLimit,
|
|
||||||
AgentChatError.exportReplyFailed,
|
|
||||||
}.contains(chat.error))
|
|
||||||
TextButton(
|
|
||||||
onPressed:
|
|
||||||
provider == null ||
|
|
||||||
timelineId == null ||
|
|
||||||
chat.busy
|
|
||||||
? null
|
|
||||||
: () => ref
|
|
||||||
.read(provider.notifier)
|
|
||||||
.send(
|
|
||||||
chat.error ==
|
|
||||||
AgentChatError.exportReplyFailed
|
|
||||||
? context.l10n.agentRetrySummary
|
|
||||||
: context.l10n.agentResumeTask,
|
|
||||||
timelineId: timelineId,
|
|
||||||
summaryOnly:
|
|
||||||
chat.error ==
|
|
||||||
AgentChatError.exportReplyFailed,
|
|
||||||
resumeOnly:
|
|
||||||
chat.error !=
|
|
||||||
AgentChatError.exportReplyFailed,
|
|
||||||
onUpdated: widget.onConversationUpdated,
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
chat.error == AgentChatError.exportReplyFailed
|
|
||||||
? context.l10n.agentRetrySummary
|
|
||||||
: context.l10n.agentResumeTask,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ValueListenableBuilder<TextEditingValue>(
|
|
||||||
valueListenable: widget.input,
|
|
||||||
builder: (context, _, _) =>
|
|
||||||
widget.input.hasInvalidReferences
|
|
||||||
? Padding(
|
|
||||||
padding: const EdgeInsets.all(AppSpacing.small),
|
|
||||||
child: Text(
|
|
||||||
context.l10n.composerReferenceInvalid,
|
|
||||||
style: AppSurfaces.of(context).errorText,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: const SizedBox.shrink(),
|
|
||||||
),
|
|
||||||
if (widget.composer.attachments.isNotEmpty)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(AppSpacing.small),
|
|
||||||
child: Wrap(
|
|
||||||
spacing: AppSpacing.gap,
|
|
||||||
children: [
|
|
||||||
for (final asset in widget.composer.attachments)
|
|
||||||
if (assets
|
|
||||||
.where((item) => item.id == asset.id)
|
|
||||||
.firstOrNull
|
|
||||||
case final document?)
|
|
||||||
AgentAttachmentCard(
|
|
||||||
asset: document,
|
|
||||||
onRemove: () =>
|
|
||||||
widget.composer.remove(asset.id),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
InputChip(
|
|
||||||
label: Text(asset.name),
|
|
||||||
onDeleted: () =>
|
|
||||||
widget.composer.remove(asset.id),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
composerView,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: 0,
|
|
||||||
left: ComposerLayout.radius,
|
|
||||||
right: ComposerLayout.radius,
|
|
||||||
height: AppSpacing.small,
|
|
||||||
child: Semantics(
|
|
||||||
button: true,
|
|
||||||
label: widget.expanded
|
|
||||||
? context.l10n.agentCollapseConversation
|
|
||||||
: context.l10n.agentExpandConversation,
|
|
||||||
onTap: widget.onToggleExpanded,
|
|
||||||
child: Stack(
|
|
||||||
fit: StackFit.expand,
|
|
||||||
children: [
|
|
||||||
Center(
|
|
||||||
child: Container(
|
|
||||||
width: ComposerLayout.controlSize,
|
|
||||||
height: 2,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onSurfaceVariant
|
|
||||||
.withValues(alpha: .35),
|
|
||||||
borderRadius: BorderRadius.circular(
|
|
||||||
AppRadius.pill,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
WorkspaceResizeHandle(
|
|
||||||
key: const Key('floating-agent-resize-handle'),
|
|
||||||
axis: Axis.vertical,
|
|
||||||
direction: -1,
|
|
||||||
initialValue: _reveal.value * conversationHeight,
|
|
||||||
onStart: _startResize,
|
|
||||||
onResize: (height) {
|
|
||||||
if (conversationHeight > 0) {
|
|
||||||
_reveal.value = (height / conversationHeight)
|
|
||||||
.clamp(0.0, 1.0);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onEnd: _finishResize,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
return AgentAttachmentDropRegion(
|
|
||||||
projectId: projectId,
|
|
||||||
composer: widget.composer,
|
|
||||||
shrinkWrap: true,
|
|
||||||
child: content,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,8 +9,6 @@ import '../../workspace/project_state.dart';
|
|||||||
|
|
||||||
import '../projects/conversation_sidebar.dart';
|
import '../projects/conversation_sidebar.dart';
|
||||||
import 'agent_chat_panel.dart';
|
import 'agent_chat_panel.dart';
|
||||||
import 'agent_panel_presentation.dart';
|
|
||||||
import 'floating_agent_panel.dart';
|
|
||||||
import 'agent_composer_store.dart';
|
import 'agent_composer_store.dart';
|
||||||
import 'composer_project_selector.dart';
|
import 'composer_project_selector.dart';
|
||||||
|
|
||||||
@@ -21,13 +19,11 @@ class WorkspaceAgentSurface extends ConsumerWidget {
|
|||||||
required this.state,
|
required this.state,
|
||||||
required this.onSelectProject,
|
required this.onSelectProject,
|
||||||
required this.onCreateProject,
|
required this.onCreateProject,
|
||||||
this.showProjectSelector = true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final ProjectState state;
|
final ProjectState state;
|
||||||
final ValueChanged<RecentProject>? onSelectProject;
|
final ValueChanged<RecentProject>? onSelectProject;
|
||||||
final VoidCallback? onCreateProject;
|
final VoidCallback? onCreateProject;
|
||||||
final bool showProjectSelector;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
@@ -38,54 +34,21 @@ class WorkspaceAgentSurface extends ConsumerWidget {
|
|||||||
final composers = ref.watch(agentComposerStoreProvider);
|
final composers = ref.watch(agentComposerStoreProvider);
|
||||||
final projectId = state.activeProject?.id;
|
final projectId = state.activeProject?.id;
|
||||||
final conversationId = selection.selectedId;
|
final conversationId = selection.selectedId;
|
||||||
final presentation = AgentPanelPresentation.of(context);
|
|
||||||
if (presentation?.compact == true) {
|
|
||||||
return FloatingAgentPanel(
|
|
||||||
state: state,
|
|
||||||
selection: selection,
|
|
||||||
input: composers.input(
|
|
||||||
projectId,
|
|
||||||
conversationId,
|
|
||||||
projectScoped: !showProjectSelector,
|
|
||||||
),
|
|
||||||
composer: composers.composer(
|
|
||||||
projectId,
|
|
||||||
conversationId ?? selection.draftKey,
|
|
||||||
),
|
|
||||||
expanded: presentation!.expanded,
|
|
||||||
onToggleExpanded: presentation.onToggleExpanded!,
|
|
||||||
onDock: presentation.onDock!,
|
|
||||||
onConversationCreated: (item) => unawaited(
|
|
||||||
conversations.updateListing(
|
|
||||||
item,
|
|
||||||
selectIfDraftKey: selection.draftKey,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onConversationUpdated: (item) =>
|
|
||||||
unawaited(conversations.updateListing(item)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return AgentChatPanel(
|
return AgentChatPanel(
|
||||||
key: ValueKey((projectId, conversationId ?? selection.draftKey)),
|
key: ValueKey((projectId, conversationId ?? selection.draftKey)),
|
||||||
inputController: composers.input(
|
inputController: composers.input(projectId, conversationId),
|
||||||
projectId,
|
|
||||||
conversationId,
|
|
||||||
projectScoped: !showProjectSelector,
|
|
||||||
),
|
|
||||||
composer: composers.composer(
|
composer: composers.composer(
|
||||||
projectId,
|
projectId,
|
||||||
conversationId ?? selection.draftKey,
|
conversationId ?? selection.draftKey,
|
||||||
),
|
),
|
||||||
projectSelector: showProjectSelector
|
projectSelector: ComposerProjectSelector(
|
||||||
? ComposerProjectSelector(
|
backgroundColor: AppTheme.composerUtilityBackground(context),
|
||||||
backgroundColor: AppTheme.composerUtilityBackground(context),
|
projects: state.recent,
|
||||||
projects: state.recent,
|
selected: state.activeProject,
|
||||||
selected: state.activeProject,
|
busy: state.projectBusy,
|
||||||
busy: state.projectBusy,
|
onSelect: (project) => onSelectProject?.call(project),
|
||||||
onSelect: (project) => onSelectProject?.call(project),
|
onCreate: onCreateProject,
|
||||||
onCreate: onCreateProject,
|
),
|
||||||
)
|
|
||||||
: null,
|
|
||||||
composerColor: AppSurfaces.of(context).composerBackground,
|
composerColor: AppSurfaces.of(context).composerBackground,
|
||||||
projectId: projectId,
|
projectId: projectId,
|
||||||
timelineId: state.timeline?.id,
|
timelineId: state.timeline?.id,
|
||||||
|
|||||||
@@ -2,12 +2,11 @@ import 'package:cutdex/l10n/l10n.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
import 'package:cutdex_ui/theme.dart';
|
||||||
|
|
||||||
import '../../integrations/runtime/processing_resource_repository.dart';
|
import '../../integrations/runtime/processing_resource_repository.dart';
|
||||||
import '../../workspace/background_task_registry.dart';
|
import '../../workspace/background_task_registry.dart';
|
||||||
import '../../shared/widgets/listenable_selector.dart';
|
import '../../workspace/background_task_state.dart';
|
||||||
import '../../integrations/runtime/processing_resource_state.dart';
|
import '../../integrations/runtime/processing_resource_state.dart';
|
||||||
|
|
||||||
import 'package:cutdex_ui/widgets.dart';
|
import 'package:cutdex_ui/widgets.dart';
|
||||||
@@ -15,14 +14,9 @@ import 'package:cutdex_ui/widgets.dart';
|
|||||||
import '../media/background_tasks_dialog.dart';
|
import '../media/background_tasks_dialog.dart';
|
||||||
|
|
||||||
class BackgroundTasksButton extends ConsumerWidget {
|
class BackgroundTasksButton extends ConsumerWidget {
|
||||||
const BackgroundTasksButton({
|
const BackgroundTasksButton({super.key, this.iconSize = AppIconSize.header});
|
||||||
super.key,
|
|
||||||
this.iconSize = AppIconSize.header,
|
|
||||||
this.alignment = AlignmentDirectional.bottomStart,
|
|
||||||
});
|
|
||||||
|
|
||||||
final double iconSize;
|
final double iconSize;
|
||||||
final AlignmentGeometry alignment;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
@@ -31,39 +25,30 @@ class BackgroundTasksButton extends ConsumerWidget {
|
|||||||
.watch(processingResourceRepositoryProvider)
|
.watch(processingResourceRepositoryProvider)
|
||||||
.asData
|
.asData
|
||||||
?.value;
|
?.value;
|
||||||
|
final tasks = ref.watch(backgroundTasksProvider(registry: registry));
|
||||||
final downloads = resources == null
|
final downloads = resources == null
|
||||||
? null
|
? null
|
||||||
: ref.watch(
|
: ref.watch(processingResourcesProvider(resources));
|
||||||
processingResourcesProvider(resources).select(
|
bool hasRunningTasks() =>
|
||||||
(downloads) =>
|
tasks.runningCount > 0 ||
|
||||||
downloads.subtitleDownloading ||
|
downloads?.subtitleDownloading == true ||
|
||||||
downloads.installs.any(
|
(downloads?.installs.any(
|
||||||
(install) =>
|
(install) => install.state == ProcessingResourceState.downloading,
|
||||||
install.state == ProcessingResourceState.downloading,
|
) ??
|
||||||
),
|
false);
|
||||||
),
|
Widget button(VoidCallback toggle) => IconButton(
|
||||||
);
|
|
||||||
Widget button(VoidCallback toggle, bool running) => IconButton(
|
|
||||||
key: const ValueKey('background-tasks-button'),
|
key: const ValueKey('background-tasks-button'),
|
||||||
tooltip: context.l10n.backgroundTasks,
|
tooltip: context.l10n.backgroundTasks,
|
||||||
onPressed: toggle,
|
onPressed: toggle,
|
||||||
icon: Badge(
|
icon: Badge(
|
||||||
isLabelVisible: running || downloads == true,
|
isLabelVisible: hasRunningTasks(),
|
||||||
child: Icon(AppIcons.success, size: iconSize),
|
child: Icon(Icons.task_alt_outlined, size: iconSize),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return ListenableSelector<bool>(
|
return AppPopover(
|
||||||
listenable: registry,
|
width: 384,
|
||||||
select: () => registry.runningCount > 0,
|
builder: (_, toggle) => button(toggle),
|
||||||
builder: (context, running) => AppPopover(
|
child: BackgroundTasksContent(registry: registry, repository: resources),
|
||||||
width: 384,
|
|
||||||
alignment: alignment,
|
|
||||||
builder: (_, toggle) => button(toggle, running),
|
|
||||||
child: BackgroundTasksContent(
|
|
||||||
registry: registry,
|
|
||||||
repository: resources,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
import '../../shared/widgets/listenable_selector.dart';
|
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:cutdex/l10n/l10n.dart';
|
import 'package:cutdex/l10n/l10n.dart';
|
||||||
@@ -13,12 +11,9 @@ import 'package:cutdex_native/cutdex_native.dart';
|
|||||||
import '../../persistence/app_settings_repositories.dart';
|
import '../../persistence/app_settings_repositories.dart';
|
||||||
import '../../shared/layout/workspace_layout_metrics.dart';
|
import '../../shared/layout/workspace_layout_metrics.dart';
|
||||||
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
import 'package:cutdex_ui/theme.dart';
|
||||||
|
|
||||||
import '../../workspace/timeline_provider.dart';
|
import '../../workspace/timeline_provider.dart';
|
||||||
import '../../workspace/preview_target.dart';
|
|
||||||
import '../../workspace/projects.dart';
|
|
||||||
import '../../workspace/view_settings.dart';
|
import '../../workspace/view_settings.dart';
|
||||||
import '../media/media_browser_page.dart';
|
import '../media/media_browser_page.dart';
|
||||||
import '../media/media_panel.dart';
|
import '../media/media_panel.dart';
|
||||||
@@ -28,7 +23,6 @@ import '../properties/properties_panel.dart';
|
|||||||
import '../timeline/timeline_panel.dart';
|
import '../timeline/timeline_panel.dart';
|
||||||
import 'editor_presentation_controller.dart';
|
import 'editor_presentation_controller.dart';
|
||||||
import 'editor_panel_defaults.dart';
|
import 'editor_panel_defaults.dart';
|
||||||
import 'timeline_operation_region.dart';
|
|
||||||
import 'layouts/bounded_editor_layout.dart';
|
import 'layouts/bounded_editor_layout.dart';
|
||||||
import 'layouts/expanded_editor_layout.dart';
|
import 'layouts/expanded_editor_layout.dart';
|
||||||
|
|
||||||
@@ -42,15 +36,11 @@ class EditorWorkspace extends ConsumerStatefulWidget {
|
|||||||
required this.integratedTitlebar,
|
required this.integratedTitlebar,
|
||||||
required this.headerLeading,
|
required this.headerLeading,
|
||||||
this.projectLoading = false,
|
this.projectLoading = false,
|
||||||
this.timelineLoading = false,
|
|
||||||
this.showProjectName = true,
|
this.showProjectName = true,
|
||||||
this.experience = DeviceExperience.desktop,
|
this.experience = DeviceExperience.desktop,
|
||||||
});
|
});
|
||||||
|
|
||||||
final bool projectLoading;
|
final bool projectLoading;
|
||||||
|
|
||||||
/// Navigation is preparing another timeline; the current content stays visible.
|
|
||||||
final bool timelineLoading;
|
|
||||||
final String projectId;
|
final String projectId;
|
||||||
final String timelineId;
|
final String timelineId;
|
||||||
final String projectName;
|
final String projectName;
|
||||||
@@ -65,13 +55,6 @@ class EditorWorkspace extends ConsumerStatefulWidget {
|
|||||||
|
|
||||||
class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
||||||
final _previewKey = GlobalKey();
|
final _previewKey = GlobalKey();
|
||||||
bool get _timelinePending => widget.projectLoading;
|
|
||||||
|
|
||||||
Widget _timelineInteraction(Widget child) => TimelineOperationRegion(
|
|
||||||
projectId: widget.projectId,
|
|
||||||
loading: widget.timelineLoading,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
EditorPresentationController get _presentation =>
|
EditorPresentationController get _presentation =>
|
||||||
ref.read(editorPresentationProvider(widget.projectId));
|
ref.read(editorPresentationProvider(widget.projectId));
|
||||||
ProjectViewSettingsData get _viewSettings =>
|
ProjectViewSettingsData get _viewSettings =>
|
||||||
@@ -80,10 +63,10 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
|||||||
ProjectViewSettings get _viewController =>
|
ProjectViewSettings get _viewController =>
|
||||||
ref.read(projectViewSettingsProvider(widget.projectId).notifier);
|
ref.read(projectViewSettingsProvider(widget.projectId).notifier);
|
||||||
bool get _propertiesOpen => _viewSettings.propertiesOpen;
|
bool get _propertiesOpen => _viewSettings.propertiesOpen;
|
||||||
|
double? get _timelineHeight => _viewSettings.timelineHeight;
|
||||||
|
|
||||||
void _saveViewSettings() {
|
void _saveViewSettings() {
|
||||||
if (widget.projectId.isEmpty ||
|
if (!ref.read(projectViewSettingsProvider(widget.projectId)).hasValue) {
|
||||||
!ref.read(projectViewSettingsProvider(widget.projectId)).hasValue) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unawaited(_viewController.save());
|
unawaited(_viewController.save());
|
||||||
@@ -92,100 +75,50 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final viewSettings = ref.watch(
|
final viewSettings = ref.watch(
|
||||||
projectViewSettingsProvider(widget.projectId)
|
projectViewSettingsProvider(widget.projectId),
|
||||||
.select((value) => (value.hasValue, value.value?.propertiesOpen)),
|
|
||||||
);
|
);
|
||||||
final preview = KeyedSubtree(
|
final preview = KeyedSubtree(
|
||||||
key: _previewKey,
|
key: _previewKey,
|
||||||
child: _timelineInteraction(
|
child: EditorPreviewPanel(
|
||||||
EditorPreviewPanel(
|
projectId: widget.projectId,
|
||||||
projectId: widget.projectId,
|
timelineId: widget.timelineId,
|
||||||
timelineId: widget.timelineId,
|
pending: widget.projectLoading,
|
||||||
pending: _timelinePending,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final timeline = EditorTimelinePanel(
|
final timeline = EditorTimelinePanel(
|
||||||
projectId: widget.projectId,
|
projectId: widget.projectId,
|
||||||
timelineId: widget.timelineId,
|
timelineId: widget.timelineId,
|
||||||
pending: widget.projectLoading,
|
pending: widget.projectLoading,
|
||||||
timelineLoading: widget.timelineLoading,
|
|
||||||
);
|
|
||||||
final properties = _timelineInteraction(
|
|
||||||
_timelinePending
|
|
||||||
? const EditorEmptyPanel()
|
|
||||||
: EditorPropertiesPanel(
|
|
||||||
projectId: widget.projectId,
|
|
||||||
timelineId: widget.timelineId,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
final properties = widget.projectLoading
|
||||||
|
? const EditorEmptyPanel()
|
||||||
|
: EditorPropertiesPanel(
|
||||||
|
projectId: widget.projectId,
|
||||||
|
timelineId: widget.timelineId,
|
||||||
|
);
|
||||||
final media = widget.projectLoading
|
final media = widget.projectLoading
|
||||||
? const EditorEmptyPanel()
|
? const EditorEmptyPanel()
|
||||||
: MediaPanel(projectId: widget.projectId, projectScoped: true);
|
: MediaPanel(projectId: widget.projectId);
|
||||||
return ListenableBuilder(
|
return ListenableBuilder(
|
||||||
listenable: ref.watch(editorPresentationProvider(widget.projectId)),
|
listenable: ref.watch(editorPresentationProvider(widget.projectId)),
|
||||||
builder: (context, _) => LayoutBuilder(
|
builder: (context, _) => LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final desktop = widget.experience == DeviceExperience.desktop;
|
final desktop = widget.experience == DeviceExperience.desktop;
|
||||||
final mediaOpen = desktop
|
|
||||||
? _presentation.mediaOpen
|
|
||||||
: _presentation.activeTool == EditorTool.media;
|
|
||||||
final mediaWidth = mediaOpen
|
|
||||||
? WorkspaceLayoutMetrics.mediaPanelWidth +
|
|
||||||
WorkspaceLayoutMetrics.desktopSpacing
|
|
||||||
: 0.0;
|
|
||||||
final sideWidth = (_propertiesOpen
|
final sideWidth = (_propertiesOpen
|
||||||
? WorkspaceLayoutMetrics.propertiesPanelWidth +
|
? WorkspaceLayoutMetrics.propertiesPanelWidth + 1
|
||||||
WorkspaceLayoutMetrics.desktopSpacing
|
|
||||||
: 0);
|
: 0);
|
||||||
final dockMedia =
|
final dockPanels =
|
||||||
desktop &&
|
desktop &&
|
||||||
mediaOpen &&
|
|
||||||
constraints.maxWidth >=
|
constraints.maxWidth >=
|
||||||
WorkspaceLayoutMetrics.previewMinimumWidth + mediaWidth;
|
WorkspaceLayoutMetrics.previewMinimumWidth + sideWidth;
|
||||||
final dockProperties =
|
final desktopTool = _propertiesOpen ? EditorTool.properties : null;
|
||||||
desktop &&
|
final headerHeight = desktop ? AppControlSize.panelToolbar : 48.0;
|
||||||
_propertiesOpen &&
|
final mediaOpen = _presentation.activeTool == EditorTool.media;
|
||||||
constraints.maxWidth >=
|
|
||||||
WorkspaceLayoutMetrics.previewMinimumWidth +
|
|
||||||
sideWidth +
|
|
||||||
(dockMedia ? mediaWidth : 0);
|
|
||||||
final desktopTool =
|
|
||||||
mediaOpen && !dockMedia && _presentation.desktopToolRequested
|
|
||||||
? _presentation.desktopTool(propertiesOpen: _propertiesOpen)
|
|
||||||
: _propertiesOpen && !dockProperties
|
|
||||||
? EditorTool.properties
|
|
||||||
: null;
|
|
||||||
final headerHeight = desktop ? AppDesktopMetrics.panelHeader : 48.0;
|
|
||||||
final propertiesOpen = desktop
|
final propertiesOpen = desktop
|
||||||
? dockProperties
|
? dockPanels
|
||||||
? _propertiesOpen
|
? _propertiesOpen
|
||||||
: desktopTool == EditorTool.properties
|
: desktopTool == EditorTool.properties
|
||||||
: _presentation.activeTool == EditorTool.properties;
|
: _presentation.activeTool == EditorTool.properties;
|
||||||
final mediaButton = HeaderControlRegion(
|
|
||||||
child: SizedBox.square(
|
|
||||||
dimension: desktop ? AppControlSize.headerButton : 48,
|
|
||||||
child: IconButton(
|
|
||||||
key: const Key('editor-media-button'),
|
|
||||||
tooltip: context.l10n.materials,
|
|
||||||
isSelected: mediaOpen,
|
|
||||||
onPressed: () {
|
|
||||||
if (desktop) {
|
|
||||||
if (!dockMedia &&
|
|
||||||
desktopTool != EditorTool.media &&
|
|
||||||
_presentation.mediaOpen) {
|
|
||||||
_presentation.preferDesktopTool(EditorTool.media);
|
|
||||||
} else {
|
|
||||||
_presentation.toggleMedia();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
_presentation.toggleTool(EditorTool.media);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
icon: const Icon(AppIcons.mediaLibrary),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final header = Material(
|
final header = Material(
|
||||||
color: Theme.of(context).colorScheme.surface,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
@@ -195,27 +128,15 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
|||||||
padding: desktop
|
padding: desktop
|
||||||
? const EdgeInsets.symmetric(
|
? const EdgeInsets.symmetric(
|
||||||
horizontal: AppSidebarMetrics.outerPadding,
|
horizontal: AppSidebarMetrics.outerPadding,
|
||||||
vertical: AppSpacing.tiny,
|
vertical: AppSpacing.gap,
|
||||||
)
|
)
|
||||||
: EdgeInsets.zero,
|
: EdgeInsets.zero,
|
||||||
child: WindowHeaderPadding(
|
child: WindowHeaderPadding(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
widget.headerLeading,
|
widget.headerLeading,
|
||||||
if (desktop) mediaButton,
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: desktop
|
child: widget.showProjectName
|
||||||
? Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: AppSpacing.small,
|
|
||||||
),
|
|
||||||
child: _PreviewHeaderTitle(
|
|
||||||
projectId: widget.projectId,
|
|
||||||
timelineId: widget.timelineId,
|
|
||||||
pending: _timelinePending,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: widget.showProjectName
|
|
||||||
? Row(
|
? Row(
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Flexible(
|
||||||
@@ -232,7 +153,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
|||||||
),
|
),
|
||||||
Flexible(
|
Flexible(
|
||||||
fit: FlexFit.loose,
|
fit: FlexFit.loose,
|
||||||
child: _timelinePending
|
child: widget.projectLoading
|
||||||
? const SizedBox.shrink()
|
? const SizedBox.shrink()
|
||||||
: _TimelineSaveStatus(
|
: _TimelineSaveStatus(
|
||||||
projectId: widget.projectId,
|
projectId: widget.projectId,
|
||||||
@@ -243,7 +164,35 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
|||||||
)
|
)
|
||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
if (!desktop) mediaButton,
|
if (!desktop)
|
||||||
|
HeaderControlRegion(
|
||||||
|
child: SizedBox.square(
|
||||||
|
dimension: desktop
|
||||||
|
? AppControlSize.headerButton
|
||||||
|
: 48,
|
||||||
|
child: IconButton(
|
||||||
|
key: const Key('editor-media-button'),
|
||||||
|
tooltip: context.l10n.materials,
|
||||||
|
isSelected: mediaOpen,
|
||||||
|
onPressed: () {
|
||||||
|
if (desktop) {
|
||||||
|
if (!dockPanels &&
|
||||||
|
desktopTool != EditorTool.media &&
|
||||||
|
_presentation.mediaOpen) {
|
||||||
|
_presentation.preferDesktopTool(
|
||||||
|
EditorTool.media,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
_presentation.toggleMedia();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_presentation.toggleTool(EditorTool.media);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.perm_media_outlined),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
if (!desktop) const SizedBox(width: AppSpacing.tiny),
|
if (!desktop) const SizedBox(width: AppSpacing.tiny),
|
||||||
HeaderControlRegion(
|
HeaderControlRegion(
|
||||||
child: SizedBox.square(
|
child: SizedBox.square(
|
||||||
@@ -254,11 +203,11 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
|||||||
? context.l10n.collapseProperties
|
? context.l10n.collapseProperties
|
||||||
: context.l10n.expandProperties,
|
: context.l10n.expandProperties,
|
||||||
isSelected: propertiesOpen,
|
isSelected: propertiesOpen,
|
||||||
onPressed: !viewSettings.$1
|
onPressed: !viewSettings.hasValue
|
||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
if (desktop) {
|
if (desktop) {
|
||||||
if (dockProperties ||
|
if (dockPanels ||
|
||||||
desktopTool ==
|
desktopTool ==
|
||||||
EditorTool.properties ||
|
EditorTool.properties ||
|
||||||
!_propertiesOpen) {
|
!_propertiesOpen) {
|
||||||
@@ -277,7 +226,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
AppIcons.tune,
|
Icons.tune,
|
||||||
size: AppIconSize.header,
|
size: AppIconSize.header,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -290,40 +239,23 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
Widget dockedEditing({required bool showTools}) => Consumer(
|
Widget dockedEditing({required bool showTools}) =>
|
||||||
builder: (context, ref, _) {
|
ExpandedEditorLayout(
|
||||||
final dimensions = ref.watch(
|
|
||||||
projectViewSettingsProvider(widget.projectId).select(
|
|
||||||
(value) =>
|
|
||||||
(value.value?.mediaWidth, value.value?.timelineHeight),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return ExpandedEditorLayout(
|
|
||||||
preview: preview,
|
preview: preview,
|
||||||
header: header,
|
header: header,
|
||||||
properties: properties,
|
properties: properties,
|
||||||
media: media,
|
media: media,
|
||||||
showMedia: dockMedia,
|
showMedia: false,
|
||||||
showProperties: showTools && dockProperties,
|
showProperties: showTools && _propertiesOpen,
|
||||||
mediaWidth: dimensions.$1,
|
timelineHeight: _timelineHeight,
|
||||||
onMediaWidthChanged: (width) {
|
|
||||||
if (viewSettings.$1) {
|
|
||||||
_viewController.setMediaWidth(width);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onMediaWidthChangeEnd: _saveViewSettings,
|
|
||||||
timelineHeight: dimensions.$2,
|
|
||||||
onTimelineHeightChanged: (height) {
|
onTimelineHeightChanged: (height) {
|
||||||
if (viewSettings.$1) {
|
if (viewSettings.hasValue) {
|
||||||
_viewController.setTimelineHeight(height);
|
_viewController.setTimelineHeight(height);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onTimelineHeightChangeEnd: _saveViewSettings,
|
onTimelineHeightChangeEnd: _saveViewSettings,
|
||||||
onJunctionResizeEnd: _saveViewSettings,
|
|
||||||
timeline: timeline,
|
timeline: timeline,
|
||||||
);
|
);
|
||||||
},
|
|
||||||
);
|
|
||||||
return Stack(
|
return Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
@@ -331,7 +263,7 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
|||||||
children: [
|
children: [
|
||||||
if (!desktop) header,
|
if (!desktop) header,
|
||||||
Expanded(
|
Expanded(
|
||||||
child: desktop && desktopTool == null
|
child: dockPanels
|
||||||
? dockedEditing(showTools: true)
|
? dockedEditing(showTools: true)
|
||||||
: BoundedEditorLayout(
|
: BoundedEditorLayout(
|
||||||
experience: widget.experience,
|
experience: widget.experience,
|
||||||
@@ -356,23 +288,19 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
|||||||
projectId: widget.projectId,
|
projectId: widget.projectId,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
properties: _timelinePending
|
properties: widget.projectLoading
|
||||||
? properties
|
? properties
|
||||||
: switch (widget.experience) {
|
: switch (widget.experience) {
|
||||||
DeviceExperience.desktop => properties,
|
DeviceExperience.desktop => properties,
|
||||||
DeviceExperience.tablet =>
|
DeviceExperience.tablet =>
|
||||||
_timelineInteraction(
|
PropertiesToolPanel(
|
||||||
PropertiesToolPanel(
|
projectId: widget.projectId,
|
||||||
projectId: widget.projectId,
|
timelineId: widget.timelineId,
|
||||||
timelineId: widget.timelineId,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
DeviceExperience.phone =>
|
DeviceExperience.phone =>
|
||||||
_timelineInteraction(
|
PropertiesEditorPage(
|
||||||
PropertiesEditorPage(
|
projectId: widget.projectId,
|
||||||
projectId: widget.projectId,
|
timelineId: widget.timelineId,
|
||||||
timelineId: widget.timelineId,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
onCloseTool: () {
|
onCloseTool: () {
|
||||||
@@ -406,73 +334,6 @@ class _EditorWorkspaceState extends ConsumerState<EditorWorkspace> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PreviewHeaderTitle extends ConsumerWidget {
|
|
||||||
const _PreviewHeaderTitle({
|
|
||||||
required this.projectId,
|
|
||||||
required this.timelineId,
|
|
||||||
required this.pending,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String projectId;
|
|
||||||
final String timelineId;
|
|
||||||
final bool pending;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final navigation = pending
|
|
||||||
? const PreviewTargetState.timeline()
|
|
||||||
: ref.watch(previewNavigationProvider(projectId, timelineId));
|
|
||||||
final name = pending
|
|
||||||
? context.l10n.preview
|
|
||||||
: ref.watch(
|
|
||||||
projectsProvider.select((value) {
|
|
||||||
final workspace = value.value;
|
|
||||||
return switch (navigation) {
|
|
||||||
SourcePreviewTarget(:final asset) =>
|
|
||||||
workspace?.assets
|
|
||||||
.where((item) => item.id == asset.id)
|
|
||||||
.firstOrNull
|
|
||||||
?.name ??
|
|
||||||
asset.name,
|
|
||||||
_ =>
|
|
||||||
workspace?.timeline?.id == timelineId
|
|
||||||
? workspace!.timeline!.name
|
|
||||||
: context.l10n.preview,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
final session = pending
|
|
||||||
? null
|
|
||||||
: ref.watch(editorTimelineProvider(projectId, timelineId)).value;
|
|
||||||
Widget title(String? saveStatus) => Tooltip(
|
|
||||||
message: saveStatus == null ? name : '$name\n$saveStatus',
|
|
||||||
child: Text(
|
|
||||||
name,
|
|
||||||
key: const Key('editor-preview-title'),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: Theme.of(context).textTheme.titleSmall,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (session == null) return title(null);
|
|
||||||
return ListenableSelector<(bool, bool, bool)>(
|
|
||||||
listenable: session,
|
|
||||||
select: () => (session.error != null, session.saving, session.dirty),
|
|
||||||
builder: (context, value) => title(_timelineSaveLabel(context, value)),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String _timelineSaveLabel(BuildContext context, (bool, bool, bool) value) =>
|
|
||||||
value.$1
|
|
||||||
? context.l10n.unsaved
|
|
||||||
: value.$2
|
|
||||||
? context.l10n.saving
|
|
||||||
: value.$3
|
|
||||||
? context.l10n.pendingSave
|
|
||||||
: context.l10n.saved;
|
|
||||||
|
|
||||||
class _TimelineSaveStatus extends ConsumerWidget {
|
class _TimelineSaveStatus extends ConsumerWidget {
|
||||||
const _TimelineSaveStatus({
|
const _TimelineSaveStatus({
|
||||||
required this.projectId,
|
required this.projectId,
|
||||||
@@ -489,19 +350,22 @@ class _TimelineSaveStatus extends ConsumerWidget {
|
|||||||
.asData
|
.asData
|
||||||
?.value;
|
?.value;
|
||||||
if (session == null) return const SizedBox.shrink();
|
if (session == null) return const SizedBox.shrink();
|
||||||
return ListenableSelector<(bool, bool, bool)>(
|
return ListenableBuilder(
|
||||||
listenable: session,
|
listenable: session,
|
||||||
select: () => (session.error != null, session.saving, session.dirty),
|
builder: (context, _) => Padding(
|
||||||
builder: (context, value) => Padding(
|
|
||||||
padding: const EdgeInsets.only(left: AppSpacing.small),
|
padding: const EdgeInsets.only(left: AppSpacing.small),
|
||||||
child: Text(
|
child: Text(
|
||||||
_timelineSaveLabel(context, value),
|
session.error != null
|
||||||
|
? context.l10n.unsaved
|
||||||
|
: session.saving
|
||||||
|
? context.l10n.saving
|
||||||
|
: session.dirty
|
||||||
|
? context.l10n.pendingSave
|
||||||
|
: context.l10n.saved,
|
||||||
key: const Key('timeline-save-status'),
|
key: const Key('timeline-save-status'),
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: AppTheme.isDesktop(context)
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(fontSize: 10),
|
||||||
? Theme.of(context).textTheme.bodySmall
|
|
||||||
: Theme.of(context).textTheme.bodySmall?.copyWith(fontSize: 10),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex/l10n/l10n.dart';
|
|
||||||
import 'package:cutdex_ui/widgets.dart';
|
import 'package:cutdex_ui/widgets.dart';
|
||||||
import 'package:cutdex_ui/theme.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// Empty values while a project's content is being bound to its cards.
|
/// Empty values while a project's content is being bound to its cards.
|
||||||
@@ -22,116 +19,40 @@ class EditorTimelineDefaults extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) => Column(
|
Widget build(BuildContext context) => Column(
|
||||||
children: [
|
children: [
|
||||||
if (showTabs) ...[
|
if (showTabs) ...[
|
||||||
ColoredBox(
|
const SizedBox(
|
||||||
key: const Key('timeline-tabs-background'),
|
key: Key('timeline-tabs-bar'),
|
||||||
color: AppTheme.timelineTabsBackground(context),
|
height: 26,
|
||||||
child: SizedBox(
|
child: Row(
|
||||||
key: const Key('timeline-tabs-bar'),
|
children: [
|
||||||
height: AppTheme.isDesktop(context)
|
IconButton(onPressed: null, icon: Icon(Icons.add, size: 16)),
|
||||||
? AppDesktopMetrics.timelineTabs
|
],
|
||||||
: 26,
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.symmetric(
|
|
||||||
horizontal: AppTheme.isDesktop(context) ? AppSpacing.small : 0,
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
if (AppTheme.isDesktop(context))
|
|
||||||
SizedBox.square(
|
|
||||||
dimension: AppDesktopMetrics.timelineTabControl,
|
|
||||||
child: IconButton(
|
|
||||||
key: const Key('timeline-add-button'),
|
|
||||||
onPressed: null,
|
|
||||||
style: AppTheme.timelineTabActionStyle,
|
|
||||||
icon: const Icon(AppIcons.add, size: 16),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
const IconButton(
|
|
||||||
onPressed: null,
|
|
||||||
icon: Icon(AppIcons.add, size: 16),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(height: 1),
|
const Divider(height: 1),
|
||||||
],
|
],
|
||||||
Expanded(
|
Expanded(
|
||||||
child: WorkspacePanel(
|
child: WorkspacePanel(
|
||||||
headerHeight: AppTheme.isDesktop(context)
|
headerHeight: 32,
|
||||||
? AppDesktopMetrics.timelineToolbar
|
|
||||||
: 32,
|
|
||||||
headerPadding: EdgeInsets.zero,
|
headerPadding: EdgeInsets.zero,
|
||||||
controls: SizedBox(
|
controls: SizedBox(
|
||||||
key: const Key('timeline-toolbar'),
|
key: const Key('timeline-toolbar'),
|
||||||
height: AppTheme.isDesktop(context)
|
height: 32,
|
||||||
? AppDesktopMetrics.timelineToolbar
|
child: SingleChildScrollView(
|
||||||
: 32,
|
scrollDirection: Axis.horizontal,
|
||||||
child: !AppTheme.isDesktop(context)
|
child: Row(
|
||||||
? SingleChildScrollView(
|
children: [
|
||||||
scrollDirection: Axis.horizontal,
|
for (final icon in [
|
||||||
child: Row(
|
Icons.undo,
|
||||||
children: [
|
Icons.redo,
|
||||||
for (final icon in [
|
Icons.content_cut,
|
||||||
AppIcons.undo,
|
Icons.align_horizontal_left,
|
||||||
AppIcons.redo,
|
Icons.align_horizontal_right,
|
||||||
AppIcons.cut,
|
Icons.delete_outline,
|
||||||
AppIcons.alignLeft,
|
])
|
||||||
AppIcons.alignRight,
|
IconButton(onPressed: null, icon: Icon(icon, size: 16)),
|
||||||
AppIcons.delete,
|
],
|
||||||
])
|
),
|
||||||
IconButton(
|
),
|
||||||
onPressed: null,
|
|
||||||
icon: Icon(icon, size: 16),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: AppSpacing.medium,
|
|
||||||
),
|
|
||||||
child: AppCommandToolbar(
|
|
||||||
groups: [
|
|
||||||
[
|
|
||||||
AppToolbarCommand(
|
|
||||||
label: context.l10n.undo,
|
|
||||||
icon: AppIcons.undo,
|
|
||||||
onPressed: null,
|
|
||||||
),
|
|
||||||
AppToolbarCommand(
|
|
||||||
label: context.l10n.redo,
|
|
||||||
icon: AppIcons.redo,
|
|
||||||
onPressed: null,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
AppToolbarCommand(
|
|
||||||
label: context.l10n.splitAtPlayhead,
|
|
||||||
icon: AppIcons.cut,
|
|
||||||
onPressed: null,
|
|
||||||
),
|
|
||||||
AppToolbarCommand(
|
|
||||||
label: context.l10n.trimLeftTooltip,
|
|
||||||
icon: AppIcons.alignLeft,
|
|
||||||
onPressed: null,
|
|
||||||
),
|
|
||||||
AppToolbarCommand(
|
|
||||||
label: context.l10n.trimRightTooltip,
|
|
||||||
icon: AppIcons.alignRight,
|
|
||||||
onPressed: null,
|
|
||||||
),
|
|
||||||
AppToolbarCommand(
|
|
||||||
label: context.l10n.deleteSelectedClips,
|
|
||||||
icon: AppIcons.delete,
|
|
||||||
onPressed: null,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: const SizedBox.expand(key: Key('timeline-default-tracks')),
|
child: const SizedBox.expand(key: Key('timeline-default-tracks')),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -12,14 +12,12 @@ final editorPresentationProvider =
|
|||||||
|
|
||||||
/// Presentation choices survive shell changes without changing project data.
|
/// Presentation choices survive shell changes without changing project data.
|
||||||
class EditorPresentationController extends ChangeNotifier {
|
class EditorPresentationController extends ChangeNotifier {
|
||||||
bool _mediaOpen = true;
|
bool _mediaOpen = false;
|
||||||
EditorTool? _activeTool;
|
EditorTool? _activeTool;
|
||||||
EditorTool _preferredDesktopTool = EditorTool.properties;
|
EditorTool _preferredDesktopTool = EditorTool.properties;
|
||||||
bool _desktopToolRequested = false;
|
|
||||||
|
|
||||||
bool get mediaOpen => _mediaOpen;
|
bool get mediaOpen => _mediaOpen;
|
||||||
EditorTool? get activeTool => _activeTool;
|
EditorTool? get activeTool => _activeTool;
|
||||||
bool get desktopToolRequested => _desktopToolRequested;
|
|
||||||
EditorTool desktopTool({required bool propertiesOpen}) =>
|
EditorTool desktopTool({required bool propertiesOpen}) =>
|
||||||
_preferredDesktopTool == EditorTool.media && _mediaOpen
|
_preferredDesktopTool == EditorTool.media && _mediaOpen
|
||||||
? EditorTool.media
|
? EditorTool.media
|
||||||
@@ -28,14 +26,12 @@ class EditorPresentationController extends ChangeNotifier {
|
|||||||
: EditorTool.media;
|
: EditorTool.media;
|
||||||
|
|
||||||
void preferDesktopTool(EditorTool tool) {
|
void preferDesktopTool(EditorTool tool) {
|
||||||
_desktopToolRequested = true;
|
|
||||||
_preferredDesktopTool = tool;
|
_preferredDesktopTool = tool;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggleMedia() {
|
void toggleMedia() {
|
||||||
_mediaOpen = !_mediaOpen;
|
_mediaOpen = !_mediaOpen;
|
||||||
_desktopToolRequested = _mediaOpen;
|
|
||||||
if (_mediaOpen) _preferredDesktopTool = EditorTool.media;
|
if (_mediaOpen) _preferredDesktopTool = EditorTool.media;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../../../integrations/platform/device_experience.dart';
|
import '../../../integrations/platform/device_experience.dart';
|
||||||
import '../../../l10n/l10n.dart';
|
import '../../../l10n/l10n.dart';
|
||||||
import '../../../shared/layout/workspace_layout_metrics.dart';
|
|
||||||
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
import 'package:cutdex_ui/theme.dart';
|
||||||
|
|
||||||
import '../editor_presentation_controller.dart';
|
import '../editor_presentation_controller.dart';
|
||||||
@@ -38,39 +36,29 @@ class BoundedEditorLayout extends StatelessWidget {
|
|||||||
Widget toolSurface() => Column(
|
Widget toolSurface() => Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: desktop ? AppDesktopMetrics.panelHeader : 48,
|
height: desktop ? AppControlSize.panelToolbar : 48,
|
||||||
child: Padding(
|
child: Row(
|
||||||
padding: EdgeInsets.symmetric(
|
children: [
|
||||||
horizontal: desktop ? AppSpacing.small : 0,
|
SizedBox.square(
|
||||||
),
|
dimension: desktop ? AppControlSize.headerButton : 48,
|
||||||
child: Row(
|
child: IconButton(
|
||||||
children: [
|
key: const Key('editor-tool-close'),
|
||||||
SizedBox.square(
|
tooltip: MaterialLocalizations.of(context)
|
||||||
dimension: desktop ? AppControlSize.headerButton : 48,
|
.closeButtonTooltip,
|
||||||
child: IconButton(
|
onPressed: onCloseTool,
|
||||||
key: const Key('editor-tool-close'),
|
icon: Icon(page ? Icons.arrow_back : Icons.close),
|
||||||
tooltip: MaterialLocalizations.of(context)
|
|
||||||
.closeButtonTooltip,
|
|
||||||
onPressed: onCloseTool,
|
|
||||||
icon: Icon(page ? AppIcons.arrowBack : AppIcons.close),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Expanded(
|
),
|
||||||
child: Text(
|
Expanded(
|
||||||
tool == EditorTool.media
|
child: Text(
|
||||||
? context.l10n.materials
|
tool == EditorTool.media
|
||||||
: context.l10n.expandProperties,
|
? context.l10n.materials
|
||||||
maxLines: 1,
|
: context.l10n.expandProperties,
|
||||||
overflow: TextOverflow.ellipsis,
|
maxLines: 1,
|
||||||
style: desktop && tool == EditorTool.properties
|
overflow: TextOverflow.ellipsis,
|
||||||
? AppTheme.propertiesPanelTheme(Theme.of(context))
|
|
||||||
.textTheme
|
|
||||||
.titleSmall
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(height: 1),
|
const Divider(height: 1),
|
||||||
@@ -104,17 +92,12 @@ class BoundedEditorLayout extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
if (tool != null)
|
if (tool != null)
|
||||||
Positioned(
|
Positioned(
|
||||||
top: desktop ? AppDesktopMetrics.panelHeader + 1 : 0,
|
top: desktop ? AppControlSize.panelToolbar + 1 : 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
width: page
|
width: page
|
||||||
? constraints.maxWidth
|
? constraints.maxWidth
|
||||||
: math.min(
|
: math.min(320, constraints.maxWidth),
|
||||||
desktop && tool == EditorTool.properties
|
|
||||||
? WorkspaceLayoutMetrics.propertiesPanelWidth
|
|
||||||
: 320,
|
|
||||||
constraints.maxWidth,
|
|
||||||
),
|
|
||||||
child: Material(
|
child: Material(
|
||||||
key: const Key('editor-tool-surface'),
|
key: const Key('editor-tool-surface'),
|
||||||
elevation: page ? 0 : 8,
|
elevation: page ? 0 : 8,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:cutdex_ui/theme.dart';
|
||||||
|
|
||||||
import '../../../shared/layout/workspace_layout_metrics.dart';
|
import '../../../shared/layout/workspace_layout_metrics.dart';
|
||||||
import '../../../shared/widgets/workspace_card.dart';
|
import '../../../shared/widgets/workspace_card.dart';
|
||||||
@@ -15,13 +16,9 @@ class ExpandedEditorLayout extends StatefulWidget {
|
|||||||
required this.media,
|
required this.media,
|
||||||
required this.showMedia,
|
required this.showMedia,
|
||||||
required this.showProperties,
|
required this.showProperties,
|
||||||
required this.mediaWidth,
|
|
||||||
required this.onMediaWidthChanged,
|
|
||||||
required this.onMediaWidthChangeEnd,
|
|
||||||
required this.timelineHeight,
|
required this.timelineHeight,
|
||||||
required this.onTimelineHeightChanged,
|
required this.onTimelineHeightChanged,
|
||||||
required this.onTimelineHeightChangeEnd,
|
required this.onTimelineHeightChangeEnd,
|
||||||
required this.onJunctionResizeEnd,
|
|
||||||
required this.timeline,
|
required this.timeline,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -31,13 +28,9 @@ class ExpandedEditorLayout extends StatefulWidget {
|
|||||||
final Widget media;
|
final Widget media;
|
||||||
final bool showMedia;
|
final bool showMedia;
|
||||||
final bool showProperties;
|
final bool showProperties;
|
||||||
final double? mediaWidth;
|
|
||||||
final ValueChanged<double> onMediaWidthChanged;
|
|
||||||
final VoidCallback onMediaWidthChangeEnd;
|
|
||||||
final double? timelineHeight;
|
final double? timelineHeight;
|
||||||
final ValueChanged<double> onTimelineHeightChanged;
|
final ValueChanged<double> onTimelineHeightChanged;
|
||||||
final VoidCallback onTimelineHeightChangeEnd;
|
final VoidCallback onTimelineHeightChangeEnd;
|
||||||
final VoidCallback onJunctionResizeEnd;
|
|
||||||
final Widget timeline;
|
final Widget timeline;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -46,96 +39,84 @@ class ExpandedEditorLayout extends StatefulWidget {
|
|||||||
|
|
||||||
class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
|
class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
|
||||||
static const gap = WorkspaceLayoutMetrics.desktopSpacing;
|
static const gap = WorkspaceLayoutMetrics.desktopSpacing;
|
||||||
late bool _mediaVisited = widget.showMedia;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didUpdateWidget(covariant ExpandedEditorLayout oldWidget) {
|
|
||||||
super.didUpdateWidget(oldWidget);
|
|
||||||
_mediaVisited |= widget.showMedia;
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _card(String name, Widget child) =>
|
Widget _card(String name, Widget child) =>
|
||||||
WorkspaceCard(key: Key('editor-$name-card'), child: child);
|
WorkspaceCard(key: Key('editor-$name-card'), child: child);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) =>
|
Widget build(BuildContext context) => LayoutBuilder(
|
||||||
WorkspaceResizeHighlightScope(child: _layout());
|
|
||||||
|
|
||||||
Widget _layout() => LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
double resolveTimelineHeight(double? height) =>
|
final maximum = math.max(
|
||||||
WorkspaceLayoutMetrics.resolveTimelineHeight(
|
0.0,
|
||||||
constraints.maxHeight,
|
constraints.maxHeight -
|
||||||
height,
|
gap -
|
||||||
);
|
AppControlSize.panelToolbar -
|
||||||
final timelineHeight = resolveTimelineHeight(widget.timelineHeight);
|
WorkspaceLayoutMetrics.timelineMinimumHeight,
|
||||||
|
);
|
||||||
|
final minimum = math.min(
|
||||||
|
WorkspaceLayoutMetrics.timelineMinimumHeight,
|
||||||
|
maximum,
|
||||||
|
);
|
||||||
|
final timelineHeight =
|
||||||
|
(widget.timelineHeight ??
|
||||||
|
constraints.maxHeight *
|
||||||
|
WorkspaceLayoutMetrics.timelineDefaultHeightFraction)
|
||||||
|
.clamp(minimum, maximum)
|
||||||
|
.toDouble();
|
||||||
|
final mediaWidth = widget.showMedia
|
||||||
|
? WorkspaceLayoutMetrics.mediaPanelWidth
|
||||||
|
: 0.0;
|
||||||
final propertiesWidth = widget.showProperties
|
final propertiesWidth = widget.showProperties
|
||||||
? WorkspaceLayoutMetrics.propertiesPanelWidth
|
? WorkspaceLayoutMetrics.propertiesPanelWidth
|
||||||
: 0.0;
|
: 0.0;
|
||||||
final mediaMaximumWidth = math.max(
|
|
||||||
0.0,
|
|
||||||
constraints.maxWidth -
|
|
||||||
WorkspaceLayoutMetrics.previewMinimumWidth -
|
|
||||||
gap -
|
|
||||||
(widget.showProperties ? propertiesWidth + gap : 0),
|
|
||||||
);
|
|
||||||
final mediaMinimumWidth = math.min(
|
|
||||||
WorkspaceLayoutMetrics.mediaPanelMinimumWidth,
|
|
||||||
mediaMaximumWidth,
|
|
||||||
);
|
|
||||||
final mediaWidth =
|
|
||||||
(widget.mediaWidth ?? WorkspaceLayoutMetrics.mediaPanelWidth)
|
|
||||||
.clamp(mediaMinimumWidth, mediaMaximumWidth)
|
|
||||||
.toDouble();
|
|
||||||
return Stack(
|
return Stack(
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
children: [
|
children: [
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: _card(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
'preview',
|
||||||
children: [
|
Row(
|
||||||
if (_mediaVisited)
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
Offstage(
|
children: [
|
||||||
offstage: !widget.showMedia,
|
Expanded(
|
||||||
child: ExcludeFocus(
|
child: Column(
|
||||||
excluding: !widget.showMedia,
|
|
||||||
child: TickerMode(
|
|
||||||
enabled: widget.showMedia,
|
|
||||||
child: SizedBox(
|
|
||||||
key: const Key('editor-media-region'),
|
|
||||||
width: mediaWidth,
|
|
||||||
child: _card('media', widget.media),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (widget.showMedia) const SizedBox(width: gap),
|
|
||||||
Expanded(
|
|
||||||
child: _card(
|
|
||||||
'preview',
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
widget.header,
|
widget.header,
|
||||||
Expanded(child: widget.preview),
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
if (widget.showMedia) ...[
|
||||||
|
SizedBox(
|
||||||
|
key: const Key('editor-media-region'),
|
||||||
|
width: mediaWidth,
|
||||||
|
child: widget.media,
|
||||||
|
),
|
||||||
|
const VerticalDivider(width: 1),
|
||||||
|
],
|
||||||
|
Expanded(child: widget.preview),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (widget.showProperties) ...[
|
||||||
if (widget.showProperties) ...[
|
const VerticalDivider(
|
||||||
const SizedBox(
|
key: Key('editor-properties-divider'),
|
||||||
key: Key('editor-properties-divider'),
|
width: 1,
|
||||||
width: gap,
|
),
|
||||||
),
|
SizedBox(
|
||||||
SizedBox(
|
key: const Key('editor-properties-region'),
|
||||||
key: const Key('editor-properties-region'),
|
width: propertiesWidth,
|
||||||
width: propertiesWidth,
|
child: widget.properties,
|
||||||
child: _card('properties', widget.properties),
|
),
|
||||||
),
|
],
|
||||||
],
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: gap),
|
const SizedBox(height: gap),
|
||||||
@@ -145,24 +126,6 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (widget.showMedia)
|
|
||||||
Positioned(
|
|
||||||
key: const Key('editor-media-divider'),
|
|
||||||
left: mediaWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
|
|
||||||
top: 0,
|
|
||||||
bottom: timelineHeight + gap,
|
|
||||||
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
|
|
||||||
child: WorkspaceResizeHandle(
|
|
||||||
key: const Key('editor-media-resize'),
|
|
||||||
highlightTargets: const {WorkspaceResizeBoundary.media},
|
|
||||||
axis: Axis.horizontal,
|
|
||||||
initialValue: mediaWidth,
|
|
||||||
onResize: (width) => widget.onMediaWidthChanged(
|
|
||||||
width.clamp(mediaMinimumWidth, mediaMaximumWidth).toDouble(),
|
|
||||||
),
|
|
||||||
onEnd: widget.onMediaWidthChangeEnd,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
Positioned(
|
||||||
key: const Key('editor-timeline-divider'),
|
key: const Key('editor-timeline-divider'),
|
||||||
left: 0,
|
left: 0,
|
||||||
@@ -171,39 +134,15 @@ class _ExpandedEditorLayoutState extends State<ExpandedEditorLayout> {
|
|||||||
height: WorkspaceLayoutMetrics.desktopResizeHitExtent,
|
height: WorkspaceLayoutMetrics.desktopResizeHitExtent,
|
||||||
child: WorkspaceResizeHandle(
|
child: WorkspaceResizeHandle(
|
||||||
key: const Key('editor-timeline-resize'),
|
key: const Key('editor-timeline-resize'),
|
||||||
highlightTargets: const {WorkspaceResizeBoundary.timeline},
|
|
||||||
axis: Axis.vertical,
|
axis: Axis.vertical,
|
||||||
initialValue: timelineHeight,
|
initialValue: timelineHeight,
|
||||||
direction: -1,
|
direction: -1,
|
||||||
onResize: (height) =>
|
onResize: (height) => widget.onTimelineHeightChanged(
|
||||||
widget.onTimelineHeightChanged(resolveTimelineHeight(height)),
|
height.clamp(minimum, maximum).toDouble(),
|
||||||
|
),
|
||||||
onEnd: widget.onTimelineHeightChangeEnd,
|
onEnd: widget.onTimelineHeightChangeEnd,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.showMedia)
|
|
||||||
Positioned(
|
|
||||||
left: mediaWidth - WorkspaceLayoutMetrics.desktopResizeSlop,
|
|
||||||
bottom: timelineHeight - WorkspaceLayoutMetrics.desktopResizeSlop,
|
|
||||||
width: WorkspaceLayoutMetrics.desktopResizeHitExtent,
|
|
||||||
height: WorkspaceLayoutMetrics.desktopResizeHitExtent,
|
|
||||||
child: WorkspaceResizeHandle.junction(
|
|
||||||
key: const Key('editor-media-timeline-junction'),
|
|
||||||
highlightTargets: const {
|
|
||||||
WorkspaceResizeBoundary.media,
|
|
||||||
WorkspaceResizeBoundary.timeline,
|
|
||||||
},
|
|
||||||
initialWidth: mediaWidth,
|
|
||||||
initialHeight: timelineHeight,
|
|
||||||
verticalDirection: -1,
|
|
||||||
onWidthChanged: (width) => widget.onMediaWidthChanged(
|
|
||||||
width.clamp(mediaMinimumWidth, mediaMaximumWidth).toDouble(),
|
|
||||||
),
|
|
||||||
onHeightChanged: (height) => widget.onTimelineHeightChanged(
|
|
||||||
resolveTimelineHeight(height),
|
|
||||||
),
|
|
||||||
onEnd: widget.onJunctionResizeEnd,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
|
|
||||||
import '../../workspace/projects.dart';
|
|
||||||
|
|
||||||
/// Keeps the surface mounted while a timeline operation temporarily blocks edits.
|
|
||||||
class TimelineOperationRegion extends ConsumerWidget {
|
|
||||||
const TimelineOperationRegion({
|
|
||||||
super.key,
|
|
||||||
required this.projectId,
|
|
||||||
required this.child,
|
|
||||||
this.loading = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String projectId;
|
|
||||||
final bool loading;
|
|
||||||
final Widget child;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final creating = ref.watch(
|
|
||||||
projectsProvider.select(
|
|
||||||
(value) =>
|
|
||||||
value.value?.activeProject?.id == projectId &&
|
|
||||||
value.value?.creatingTimeline == true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final blocked = loading || creating;
|
|
||||||
return IgnorePointer(
|
|
||||||
ignoring: blocked,
|
|
||||||
child: ExcludeFocus(excluding: blocked, child: child),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,13 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:cutdex_core/timeline/model.dart';
|
import 'package:cutdex_sdk/timeline/model.dart';
|
||||||
import 'package:cutdex_timeline_ui/cutdex_timeline_ui.dart';
|
import 'package:cutdex_sdk/timeline_ui.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
import '../../integrations/runtime/media_presentations.dart';
|
import '../../integrations/runtime/media_presentations.dart';
|
||||||
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
import 'package:cutdex_ui/theme.dart';
|
||||||
|
|
||||||
class AudioAssetTile extends StatelessWidget {
|
class AudioAssetTile extends StatelessWidget {
|
||||||
@@ -64,7 +63,7 @@ class _AudioWaveformCover extends ConsumerWidget {
|
|||||||
if (waveform == null) {
|
if (waveform == null) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Icon(
|
child: Icon(
|
||||||
AppIcons.audioFile,
|
Icons.audio_file_outlined,
|
||||||
size: AppIconSize.emptyState,
|
size: AppIconSize.emptyState,
|
||||||
color: theme.colorScheme.onSurfaceVariant,
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:cutdex/diagnostics/app_diagnostics.dart';
|
import 'package:cutdex/diagnostics/app_diagnostics.dart';
|
||||||
import 'package:cutdex/errors/app_failure.dart';
|
import 'package:cutdex/errors/app_failure.dart';
|
||||||
|
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import 'package:cutdex_ui/theme.dart';
|
|||||||
import 'package:cutdex_ui/widgets.dart';
|
import 'package:cutdex_ui/widgets.dart';
|
||||||
|
|
||||||
import '../../shared/widgets/confirm_resource_download_cancel.dart';
|
import '../../shared/widgets/confirm_resource_download_cancel.dart';
|
||||||
import '../../shared/widgets/error_notification_host.dart';
|
|
||||||
import '../../shared/widgets/processing_resource_download_dialog.dart';
|
import '../../shared/widgets/processing_resource_download_dialog.dart';
|
||||||
import '../../workspace/timeline_session.dart';
|
import '../../workspace/timeline_session.dart';
|
||||||
|
|
||||||
@@ -77,10 +76,10 @@ class _BackgroundRemovalDialogState
|
|||||||
_closing = true;
|
_closing = true;
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
final notifications = ErrorNotificationHost.maybeOf(context);
|
final messenger = ScaffoldMessenger.maybeOf(context);
|
||||||
final message = context.l10n.backgroundRemovalTaskStarted;
|
final message = context.l10n.backgroundRemovalTaskStarted;
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
notifications?.showMessage(content: Text(message));
|
messenger?.showSnackBar(SnackBar(content: Text(message)));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return ref
|
return ref
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import '../../shared/widgets/presentation_list.dart';
|
|
||||||
|
|
||||||
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
@@ -7,7 +5,7 @@ import 'subtitle_download.dart';
|
|||||||
import 'subtitle_task_actions.dart';
|
import 'subtitle_task_actions.dart';
|
||||||
|
|
||||||
import 'package:cutdex/l10n/l10n.dart';
|
import 'package:cutdex/l10n/l10n.dart';
|
||||||
import 'package:cutdex_core/editor.dart';
|
import 'package:cutdex_sdk/editor.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../integrations/runtime/processing_resource_repository.dart';
|
import '../../integrations/runtime/processing_resource_repository.dart';
|
||||||
@@ -46,50 +44,12 @@ class BackgroundTasksContent extends ConsumerWidget {
|
|||||||
final ProcessingResourceRepository? repository;
|
final ProcessingResourceRepository? repository;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final tasksProvider = backgroundTasksProvider(
|
final snapshot = ref.watch(
|
||||||
registry: registry,
|
backgroundTasksProvider(registry: registry, session: session),
|
||||||
session: session,
|
|
||||||
);
|
);
|
||||||
ref.watch(
|
|
||||||
tasksProvider.select(
|
|
||||||
(snapshot) => (
|
|
||||||
PresentationList(
|
|
||||||
snapshot.subtitles.map(
|
|
||||||
(entry) => (entry.owner.session, entry.job.id),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PresentationList(
|
|
||||||
snapshot.removals.map(
|
|
||||||
(entry) => (entry.owner.session, entry.task.id),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final snapshot = ref.read(tasksProvider);
|
|
||||||
if (repository != null) {
|
|
||||||
ref.watch(
|
|
||||||
processingResourcesProvider(repository!).select(
|
|
||||||
(snapshot) => (
|
|
||||||
snapshot.subtitleDownloading,
|
|
||||||
PresentationList(
|
|
||||||
snapshot.installs
|
|
||||||
.where(
|
|
||||||
(install) =>
|
|
||||||
install.state == ProcessingResourceState.downloading ||
|
|
||||||
install.state == ProcessingResourceState.failed,
|
|
||||||
)
|
|
||||||
.map(
|
|
||||||
(install) => (install.package.capability, install.state),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final resources = repository == null
|
final resources = repository == null
|
||||||
? null
|
? null
|
||||||
: ref.read(processingResourcesProvider(repository!));
|
: ref.watch(processingResourcesProvider(repository!));
|
||||||
final subtitleEntries = snapshot.subtitles;
|
final subtitleEntries = snapshot.subtitles;
|
||||||
final removalEntries = snapshot.removals;
|
final removalEntries = snapshot.removals;
|
||||||
final subtitleDownloading = resources?.subtitleDownloading == true;
|
final subtitleDownloading = resources?.subtitleDownloading == true;
|
||||||
@@ -158,11 +118,9 @@ class BackgroundTasksContent extends ConsumerWidget {
|
|||||||
resourceDownloads.isNotEmpty ||
|
resourceDownloads.isNotEmpty ||
|
||||||
subtitleDownloading)
|
subtitleDownloading)
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
_ObservedRemovalTask(
|
_BackgroundRemovalTaskCard(
|
||||||
key: ValueKey((entry.owner.session, entry.task.id)),
|
key: ValueKey(entry.task.id),
|
||||||
entry: entry,
|
entry: entry,
|
||||||
registry: registry,
|
|
||||||
session: session,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
for (final (index, entry)
|
for (final (index, entry)
|
||||||
@@ -172,14 +130,9 @@ class BackgroundTasksContent extends ConsumerWidget {
|
|||||||
removalEntries.isNotEmpty ||
|
removalEntries.isNotEmpty ||
|
||||||
subtitleDownloading)
|
subtitleDownloading)
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
_ObservedSubtitleTask(
|
_SubtitleTaskCard(
|
||||||
key: ValueKey((
|
key: ValueKey(entry.job.recognition.id),
|
||||||
entry.owner.session,
|
|
||||||
entry.job.recognition.id,
|
|
||||||
)),
|
|
||||||
entry: entry,
|
entry: entry,
|
||||||
registry: registry,
|
|
||||||
session: session,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@@ -191,70 +144,6 @@ class BackgroundTasksContent extends ConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ObservedSubtitleTask extends ConsumerWidget {
|
|
||||||
const _ObservedSubtitleTask({
|
|
||||||
super.key,
|
|
||||||
required this.entry,
|
|
||||||
this.registry,
|
|
||||||
this.session,
|
|
||||||
});
|
|
||||||
final SubtitleTaskEntry entry;
|
|
||||||
final BackgroundTaskRegistry? registry;
|
|
||||||
final EditorTimelineSession? session;
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final current = ref.watch(
|
|
||||||
backgroundTasksProvider(registry: registry, session: session).select(
|
|
||||||
(snapshot) => snapshot.subtitles
|
|
||||||
.where(
|
|
||||||
(item) =>
|
|
||||||
identical(item.owner.session, entry.owner.session) &&
|
|
||||||
item.job.id == entry.job.id,
|
|
||||||
)
|
|
||||||
.firstOrNull,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return current == null
|
|
||||||
? const SizedBox.shrink()
|
|
||||||
: _SubtitleTaskCard(
|
|
||||||
key: ValueKey((current.owner.session, current.job.id)),
|
|
||||||
entry: current,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ObservedRemovalTask extends ConsumerWidget {
|
|
||||||
const _ObservedRemovalTask({
|
|
||||||
super.key,
|
|
||||||
required this.entry,
|
|
||||||
this.registry,
|
|
||||||
this.session,
|
|
||||||
});
|
|
||||||
final RemovalTaskEntry entry;
|
|
||||||
final BackgroundTaskRegistry? registry;
|
|
||||||
final EditorTimelineSession? session;
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
|
||||||
final current = ref.watch(
|
|
||||||
backgroundTasksProvider(registry: registry, session: session).select(
|
|
||||||
(snapshot) => snapshot.removals
|
|
||||||
.where(
|
|
||||||
(item) =>
|
|
||||||
identical(item.owner.session, entry.owner.session) &&
|
|
||||||
item.task.id == entry.task.id,
|
|
||||||
)
|
|
||||||
.firstOrNull,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return current == null
|
|
||||||
? const SizedBox.shrink()
|
|
||||||
: _BackgroundRemovalTaskCard(
|
|
||||||
key: ValueKey((current.owner.session, current.task.id)),
|
|
||||||
entry: current,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String _ownerName(BackgroundTaskSession owner) => owner.projectName.isEmpty
|
String _ownerName(BackgroundTaskSession owner) => owner.projectName.isEmpty
|
||||||
? owner.timelineName
|
? owner.timelineName
|
||||||
: '${owner.projectName} · ${owner.timelineName}';
|
: '${owner.projectName} · ${owner.timelineName}';
|
||||||
@@ -498,31 +387,7 @@ class _ResourceDownloadCard extends ConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final snapshot = ref.watch(
|
final snapshot = ref.watch(processingResourcesProvider(repository));
|
||||||
processingResourcesProvider(repository).select((snapshot) {
|
|
||||||
final capability = this.install?.package.capability;
|
|
||||||
return snapshot.copyWith(
|
|
||||||
installs: snapshot.installs
|
|
||||||
.where((install) => install.package.capability == capability)
|
|
||||||
.toList(),
|
|
||||||
paused: capability == null
|
|
||||||
? const {}
|
|
||||||
: snapshot.paused.where((item) => item == capability).toSet(),
|
|
||||||
rates: capability == null
|
|
||||||
? const {}
|
|
||||||
: {capability: snapshot.rates[capability] ?? 0},
|
|
||||||
subtitleDownloading: subtitleBundle && snapshot.subtitleDownloading,
|
|
||||||
subtitlePaused: subtitleBundle && snapshot.subtitlePaused,
|
|
||||||
subtitleDownloadedBytes: subtitleBundle
|
|
||||||
? snapshot.subtitleDownloadedBytes
|
|
||||||
: 0,
|
|
||||||
subtitleTotalBytes: subtitleBundle ? snapshot.subtitleTotalBytes : 0,
|
|
||||||
subtitleBytesPerSecond: subtitleBundle
|
|
||||||
? snapshot.subtitleBytesPerSecond
|
|
||||||
: 0,
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
final install = this.install == null
|
final install = this.install == null
|
||||||
? null
|
? null
|
||||||
: snapshot.installs
|
: snapshot.installs
|
||||||
|
|||||||
@@ -1,228 +0,0 @@
|
|||||||
import 'package:cutdex_core/project.dart';
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import '../../l10n/l10n.dart';
|
|
||||||
import '../../workspace/media_availability.dart';
|
|
||||||
import 'audio_asset_tile.dart';
|
|
||||||
import 'media_asset_strip.dart';
|
|
||||||
import 'media_browser_layout.dart';
|
|
||||||
import 'unavailable_media_placeholder.dart';
|
|
||||||
import 'visual_asset_tile.dart';
|
|
||||||
|
|
||||||
/// Desktop cards and rows use the same cover, name and availability labels.
|
|
||||||
class DesktopMediaAssetTile extends StatelessWidget {
|
|
||||||
const DesktopMediaAssetTile({
|
|
||||||
super.key,
|
|
||||||
required this.asset,
|
|
||||||
required this.grid,
|
|
||||||
required this.availability,
|
|
||||||
});
|
|
||||||
final AssetDocument asset;
|
|
||||||
final bool grid;
|
|
||||||
final MediaAvailability? availability;
|
|
||||||
|
|
||||||
static TextStyle? _nameStyle(BuildContext context) =>
|
|
||||||
Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
||||||
fontFamily: 'packages/cutdex_ui/Inter',
|
|
||||||
fontSize: AppInspectorMetrics.fontSize,
|
|
||||||
height: AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontVariations: const [FontVariation('wght', 500)],
|
|
||||||
letterSpacing: AppInspectorMetrics.fontSize * .005,
|
|
||||||
);
|
|
||||||
|
|
||||||
static TextStyle? _metadataStyle(BuildContext context) =>
|
|
||||||
Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
||||||
fontFamily: 'packages/cutdex_ui/Inter',
|
|
||||||
fontSize: AppInspectorMetrics.fontSize,
|
|
||||||
height: AppInspectorMetrics.lineHeight / AppInspectorMetrics.fontSize,
|
|
||||||
fontVariations: const [FontVariation('wght', 450)],
|
|
||||||
letterSpacing: AppInspectorMetrics.fontSize * .005,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Font fallback and fractional scaling can round a line above size × height.
|
|
||||||
static double gridLabelHeight(BuildContext context) {
|
|
||||||
double lineHeight(TextStyle? style) {
|
|
||||||
final painter = TextPainter(
|
|
||||||
text: TextSpan(text: '国Ag', style: style),
|
|
||||||
maxLines: 1,
|
|
||||||
textDirection: Directionality.of(context),
|
|
||||||
textScaler: MediaQuery.textScalerOf(context),
|
|
||||||
locale: Localizations.maybeLocaleOf(context),
|
|
||||||
textHeightBehavior: DefaultTextStyle.of(context).textHeightBehavior,
|
|
||||||
)..layout();
|
|
||||||
final height = painter.height.ceilToDouble();
|
|
||||||
painter.dispose();
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
return lineHeight(_nameStyle(context)) +
|
|
||||||
lineHeight(_metadataStyle(context));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final theme = Theme.of(context);
|
|
||||||
final unavailable =
|
|
||||||
availability != null && availability != MediaAvailability.available;
|
|
||||||
final kind = switch (asset.metadata['kind']) {
|
|
||||||
'video' => context.l10n.video,
|
|
||||||
'image' => context.l10n.picture,
|
|
||||||
'audio' => context.l10n.audio,
|
|
||||||
_ => context.l10n.materials,
|
|
||||||
};
|
|
||||||
final width = asset.metadata['width'];
|
|
||||||
final height = asset.metadata['height'];
|
|
||||||
final dimensions = width is num && height is num && width > 0 && height > 0
|
|
||||||
? '${width.toInt()} × ${height.toInt()}'
|
|
||||||
: null;
|
|
||||||
final info = unavailable
|
|
||||||
? availability == MediaAvailability.missing
|
|
||||||
? context.l10n.mediaMissing
|
|
||||||
: context.l10n.mediaUnavailable
|
|
||||||
: dimensions == null
|
|
||||||
? kind
|
|
||||||
: '$kind · $dimensions';
|
|
||||||
final name = Tooltip(
|
|
||||||
message: asset.name,
|
|
||||||
child: Text(
|
|
||||||
asset.name,
|
|
||||||
key: ValueKey('media-name-${asset.id}'),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: _nameStyle(context),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
Widget metadata({bool showDuration = false}) => Row(
|
|
||||||
children: [
|
|
||||||
Flexible(
|
|
||||||
child: Text(
|
|
||||||
info,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: _metadataStyle(context)?.copyWith(
|
|
||||||
color: unavailable
|
|
||||||
? theme.colorScheme.error
|
|
||||||
: theme.colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (showDuration && !unavailable) ...[
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Flexible(child: MediaAssetDuration(asset: asset, badge: false)),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
);
|
|
||||||
final cover = ClipRRect(
|
|
||||||
key: ValueKey('desktop-media-cover-${asset.id}'),
|
|
||||||
borderRadius: BorderRadius.circular(AppInspectorMetrics.radius),
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
if (unavailable)
|
|
||||||
AspectRatio(
|
|
||||||
aspectRatio: 16 / 9,
|
|
||||||
child: UnavailableMediaPlaceholder(
|
|
||||||
availability: availability!,
|
|
||||||
showLabel: false,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
else
|
|
||||||
switch (asset.metadata['kind']) {
|
|
||||||
'video' ||
|
|
||||||
'image' => VisualAssetTile(asset: asset, showName: false),
|
|
||||||
'audio' => AudioAssetTile(asset: asset, showName: false),
|
|
||||||
_ => AspectRatio(
|
|
||||||
aspectRatio: 16 / 9,
|
|
||||||
child: ColoredBox(
|
|
||||||
color: AppSurfaces.of(context).previewBackground,
|
|
||||||
child: const Center(child: Icon(AppIcons.file, size: 20)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
if (grid && !unavailable)
|
|
||||||
Positioned(
|
|
||||||
bottom: 4,
|
|
||||||
left: 4,
|
|
||||||
right: 4,
|
|
||||||
child: Align(
|
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
|
||||||
child: MediaAssetDuration(asset: asset),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (!grid) {
|
|
||||||
return LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
|
||||||
final columns = DesktopMediaListColumns(constraints.maxWidth);
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: DesktopMediaMetrics.listCover,
|
|
||||||
height: DesktopMediaMetrics.listCover * 9 / 16,
|
|
||||||
child: cover,
|
|
||||||
),
|
|
||||||
const SizedBox(width: DesktopMediaMetrics.gap),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
name,
|
|
||||||
if (!columns.specification)
|
|
||||||
metadata(showDuration: !columns.duration),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (columns.duration)
|
|
||||||
SizedBox(
|
|
||||||
width: DesktopMediaListColumns.durationWidth,
|
|
||||||
child: Align(
|
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
|
||||||
child: unavailable
|
|
||||||
? const SizedBox.shrink()
|
|
||||||
: MediaAssetDuration(asset: asset, badge: false),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (columns.specification) ...[
|
|
||||||
const SizedBox(width: DesktopMediaMetrics.gap),
|
|
||||||
SizedBox(
|
|
||||||
width: DesktopMediaListColumns.specificationWidth,
|
|
||||||
child: Text(
|
|
||||||
unavailable ? info : dimensions ?? '—',
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: _metadataStyle(context)?.copyWith(
|
|
||||||
color: unavailable
|
|
||||||
? theme.colorScheme.error
|
|
||||||
: theme.colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
if (columns.kind) ...[
|
|
||||||
const SizedBox(width: DesktopMediaMetrics.gap),
|
|
||||||
SizedBox(
|
|
||||||
width: DesktopMediaListColumns.kindWidth,
|
|
||||||
child: Text(
|
|
||||||
kind,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: _metadataStyle(context),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [cover, const SizedBox(height: 4), name, metadata()],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
import '../../integrations/runtime/media_presentations.dart';
|
import '../../integrations/runtime/media_presentations.dart';
|
||||||
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
import 'package:cutdex_ui/theme.dart';
|
||||||
|
|
||||||
import 'audio_asset_tile.dart';
|
import 'audio_asset_tile.dart';
|
||||||
@@ -65,9 +64,9 @@ class _VisualAssetStrip extends ConsumerWidget {
|
|||||||
timeMilliseconds: video && duration != null
|
timeMilliseconds: video && duration != null
|
||||||
? (duration * 1000 * index / count).floor()
|
? (duration * 1000 * index / count).floor()
|
||||||
: 0,
|
: 0,
|
||||||
fallback: const Center(child: Icon(AppIcons.video)),
|
fallback: const Center(child: Icon(Icons.movie_outlined)),
|
||||||
errorFallback: const Center(
|
errorFallback: const Center(
|
||||||
child: Icon(AppIcons.imageUnavailable),
|
child: Icon(Icons.broken_image_outlined),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -78,9 +77,8 @@ class _VisualAssetStrip extends ConsumerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MediaAssetDuration extends ConsumerWidget {
|
class MediaAssetDuration extends ConsumerWidget {
|
||||||
const MediaAssetDuration({super.key, required this.asset, this.badge = true});
|
const MediaAssetDuration({super.key, required this.asset});
|
||||||
final AssetDocument asset;
|
final AssetDocument asset;
|
||||||
final bool badge;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
@@ -96,20 +94,6 @@ class MediaAssetDuration extends ConsumerWidget {
|
|||||||
'${hours > 0 ? '$hours:' : ''}'
|
'${hours > 0 ? '$hours:' : ''}'
|
||||||
'${minutes.toString().padLeft(2, '0')}:'
|
'${minutes.toString().padLeft(2, '0')}:'
|
||||||
'${(seconds % 60).toString().padLeft(2, '0')}';
|
'${(seconds % 60).toString().padLeft(2, '0')}';
|
||||||
if (!badge) {
|
|
||||||
return Text(
|
|
||||||
text,
|
|
||||||
key: ValueKey('media-duration-${asset.id}'),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
||||||
fontSize: 12,
|
|
||||||
height: 16 / 12,
|
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
fontFeatures: const [FontFeature.tabularFigures()],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return DecoratedBox(
|
return DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.black.withValues(alpha: .55),
|
color: Colors.black.withValues(alpha: .55),
|
||||||
@@ -120,8 +104,6 @@ class MediaAssetDuration extends ConsumerWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
text,
|
text,
|
||||||
key: ValueKey('media-duration-${asset.id}'),
|
key: ValueKey('media-duration-${asset.id}'),
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontFeatures: const [FontFeature.tabularFigures()],
|
fontFeatures: const [FontFeature.tabularFigures()],
|
||||||
|
|||||||
@@ -1,36 +1,29 @@
|
|||||||
import '../../shared/widgets/listenable_selector.dart';
|
|
||||||
|
|
||||||
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
||||||
import 'package:cutdex/errors/app_failure.dart';
|
import 'package:cutdex/errors/app_failure.dart';
|
||||||
|
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:cutdex/l10n/l10n.dart';
|
import 'package:cutdex/l10n/l10n.dart';
|
||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
import '../../integrations/platform/platform_capabilities.dart';
|
import '../../integrations/platform/platform_capabilities.dart';
|
||||||
|
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:cutdex_ui/theme.dart';
|
import 'package:cutdex_ui/theme.dart';
|
||||||
import 'package:cutdex_ui/widgets.dart';
|
import 'package:cutdex_ui/widgets.dart';
|
||||||
|
|
||||||
import '../../workspace/external_media_import.dart';
|
import '../../workspace/external_media_import.dart';
|
||||||
import '../../workspace/media_availability.dart';
|
import '../../workspace/media_availability.dart';
|
||||||
import '../../workspace/project_state.dart';
|
|
||||||
import '../../workspace/projects.dart';
|
import '../../workspace/projects.dart';
|
||||||
import '../../workspace/timeline_provider.dart';
|
import '../../workspace/timeline_provider.dart';
|
||||||
import '../../workspace/timeline_session.dart';
|
|
||||||
import 'audio_asset_tile.dart';
|
import 'audio_asset_tile.dart';
|
||||||
import 'media_asset_drag.dart';
|
import 'media_asset_drag.dart';
|
||||||
import 'media_asset_strip.dart';
|
import 'media_asset_strip.dart';
|
||||||
import 'media_browser_controller.dart';
|
import 'media_browser_controller.dart';
|
||||||
import 'unavailable_media_placeholder.dart';
|
import 'unavailable_media_placeholder.dart';
|
||||||
import 'visual_asset_tile.dart';
|
import 'visual_asset_tile.dart';
|
||||||
import 'desktop_media_asset_tile.dart';
|
|
||||||
import 'media_browser_layout.dart';
|
|
||||||
|
|
||||||
extension MediaFilterLabel on MediaFilter {
|
extension MediaFilterLabel on MediaFilter {
|
||||||
String label(BuildContext context) => switch (this) {
|
String label(BuildContext context) => switch (this) {
|
||||||
@@ -51,37 +44,26 @@ class MediaBrowserBody extends ConsumerStatefulWidget {
|
|||||||
required this.grid,
|
required this.grid,
|
||||||
this.draggable = false,
|
this.draggable = false,
|
||||||
this.compact = false,
|
this.compact = false,
|
||||||
this.desktop = false,
|
|
||||||
});
|
});
|
||||||
final String projectId;
|
final String projectId;
|
||||||
final bool grid;
|
final bool grid;
|
||||||
final bool draggable;
|
final bool draggable;
|
||||||
final bool compact;
|
final bool compact;
|
||||||
final bool desktop;
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<MediaBrowserBody> createState() => _MediaBrowserBodyState();
|
ConsumerState<MediaBrowserBody> createState() => _MediaBrowserBodyState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
||||||
with WidgetsBindingObserver {
|
with WidgetsBindingObserver {
|
||||||
final _desktopScroll = _MediaScrollController();
|
|
||||||
MediaBrowserController? _anchorOwner;
|
|
||||||
List<AssetDocument> _anchorAssets = const [];
|
|
||||||
int _anchorColumns = 1;
|
|
||||||
double _anchorStride = 1;
|
|
||||||
Object? _viewportConfiguration;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
_desktopScroll.addListener(_storeBrowseAnchor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
WidgetsBinding.instance.removeObserver(this);
|
WidgetsBinding.instance.removeObserver(this);
|
||||||
_desktopScroll.dispose();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,67 +83,6 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
|||||||
bool get _isGrid => widget.grid;
|
bool get _isGrid => widget.grid;
|
||||||
bool get _desktop => ref.read(platformCapabilitiesProvider).nativeFileDrop;
|
bool get _desktop => ref.read(platformCapabilitiesProvider).nativeFileDrop;
|
||||||
|
|
||||||
void _storeBrowseAnchor() {
|
|
||||||
if (_anchorOwner == null ||
|
|
||||||
_anchorAssets.isEmpty ||
|
|
||||||
!_desktopScroll.hasClients) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final rowPosition = math.max(
|
|
||||||
0.0,
|
|
||||||
(_desktopScroll.position.pixels - DesktopMediaMetrics.padding) /
|
|
||||||
_anchorStride,
|
|
||||||
);
|
|
||||||
final row = rowPosition.floor();
|
|
||||||
final index = math.min(_anchorAssets.length - 1, row * _anchorColumns);
|
|
||||||
_anchorOwner!.viewportAnchor = (
|
|
||||||
assetId: _anchorAssets[index].id,
|
|
||||||
fraction: rowPosition - row,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _prepareDesktopScroll({
|
|
||||||
required List<AssetDocument> assets,
|
|
||||||
required Object configuration,
|
|
||||||
required int columns,
|
|
||||||
required double extent,
|
|
||||||
required double height,
|
|
||||||
}) {
|
|
||||||
if (_viewportConfiguration == configuration) return;
|
|
||||||
_viewportConfiguration = configuration;
|
|
||||||
final owner = _browser;
|
|
||||||
final anchor = owner.viewportAnchor;
|
|
||||||
final index = anchor == null
|
|
||||||
? -1
|
|
||||||
: assets.indexWhere((asset) => asset.id == anchor.assetId);
|
|
||||||
final stride = extent + DesktopMediaMetrics.gap;
|
|
||||||
final row = index < 0 ? 0 : index ~/ columns;
|
|
||||||
final fraction = index < 0 ? 0.0 : anchor!.fraction;
|
|
||||||
final rows = (assets.length / columns).ceil();
|
|
||||||
final maximum = math.max(
|
|
||||||
0.0,
|
|
||||||
DesktopMediaMetrics.padding * 2 +
|
|
||||||
rows * stride -
|
|
||||||
(_isGrid && rows > 0 ? DesktopMediaMetrics.gap : 0) -
|
|
||||||
height,
|
|
||||||
);
|
|
||||||
final offset =
|
|
||||||
(row == 0 && fraction == 0
|
|
||||||
? 0.0
|
|
||||||
: DesktopMediaMetrics.padding + (row + fraction) * stride)
|
|
||||||
.clamp(0.0, maximum);
|
|
||||||
_anchorOwner = owner;
|
|
||||||
_anchorAssets = assets;
|
|
||||||
_anchorColumns = columns;
|
|
||||||
_anchorStride = stride;
|
|
||||||
_desktopScroll.initialOffset = offset;
|
|
||||||
// Layout consumes the corrected pixels before painting. No change
|
|
||||||
// notification or post-frame jump is needed to preserve the browse anchor.
|
|
||||||
for (final position in _desktopScroll.positions) {
|
|
||||||
if (position.pixels != offset) position.correctPixels(offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _action(Future<bool> Function() action) async {
|
Future<void> _action(Future<bool> Function() action) async {
|
||||||
final ok = await action();
|
final ok = await action();
|
||||||
if (!mounted || ok) return;
|
if (!mounted || ok) return;
|
||||||
@@ -195,19 +116,12 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
|||||||
],
|
],
|
||||||
child: AppField(
|
child: AppField(
|
||||||
label: context.l10n.name,
|
label: context.l10n.name,
|
||||||
child: Builder(
|
child: TextField(
|
||||||
builder: (fieldContext) => TextField(
|
controller: controller,
|
||||||
controller: controller,
|
autofocus: true,
|
||||||
autofocus: true,
|
onSubmitted: (value) {
|
||||||
style: AppTheme.inputTextStyle(fieldContext),
|
if (value.trim().isNotEmpty) Navigator.pop(context, value.trim());
|
||||||
cursorHeight: AppTheme.inputCursorHeight(fieldContext),
|
},
|
||||||
textAlignVertical: TextAlignVertical.center,
|
|
||||||
onSubmitted: (value) {
|
|
||||||
if (value.trim().isNotEmpty) {
|
|
||||||
Navigator.pop(context, value.trim());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -245,14 +159,12 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => ListenableBuilder(
|
||||||
final browser = ref.watch(mediaBrowserProvider(widget.projectId));
|
listenable: ref.watch(mediaBrowserProvider(widget.projectId)),
|
||||||
// Provider subscriptions belong to this Consumer's build lifecycle. Local
|
builder: (context, _) => _buildBrowser(context),
|
||||||
// selector rebuilds must not register watches on this outer ref.
|
);
|
||||||
ref.watch(
|
Widget _buildBrowser(BuildContext context) {
|
||||||
externalMediaImportProvider(widget.projectId)
|
ref.watch(externalMediaImportProvider(widget.projectId));
|
||||||
.select((value) => value.isLoading),
|
|
||||||
);
|
|
||||||
ref.watch(
|
ref.watch(
|
||||||
projectsProvider.select(
|
projectsProvider.select(
|
||||||
(value) => (
|
(value) => (
|
||||||
@@ -265,6 +177,12 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
|||||||
);
|
);
|
||||||
final workspace = ref.read(projectsProvider).value;
|
final workspace = ref.read(projectsProvider).value;
|
||||||
final active = workspace?.activeProject?.id == widget.projectId;
|
final active = workspace?.activeProject?.id == widget.projectId;
|
||||||
|
final allAssets = active ? workspace!.assets : <AssetDocument>[];
|
||||||
|
final assets = _filter == MediaFilter.all
|
||||||
|
? allAssets
|
||||||
|
: allAssets
|
||||||
|
.where((asset) => asset.metadata['kind'] == _filter.kind)
|
||||||
|
.toList();
|
||||||
final timelineId = active ? workspace?.timeline?.id : null;
|
final timelineId = active ? workspace?.timeline?.id : null;
|
||||||
final timeline = timelineId == null
|
final timeline = timelineId == null
|
||||||
? null
|
? null
|
||||||
@@ -272,129 +190,12 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
|||||||
.watch(editorTimelineProvider(widget.projectId, timelineId))
|
.watch(editorTimelineProvider(widget.projectId, timelineId))
|
||||||
.asData
|
.asData
|
||||||
?.value;
|
?.value;
|
||||||
return ListenableSelector(
|
return assets.isEmpty
|
||||||
listenable: browser,
|
|
||||||
select: () => (
|
|
||||||
browser.filter,
|
|
||||||
widget.desktop ? browser.query : '',
|
|
||||||
widget.desktop ? browser.sort : MediaSort.importOrder,
|
|
||||||
widget.desktop ? browser.gridSize : MediaGridSize.medium,
|
|
||||||
),
|
|
||||||
builder: (context, _) => _buildBrowser(context, workspace, timeline),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildBrowser(
|
|
||||||
BuildContext context,
|
|
||||||
ProjectState? workspace,
|
|
||||||
EditorTimelineSession? timeline,
|
|
||||||
) {
|
|
||||||
final active = workspace?.activeProject?.id == widget.projectId;
|
|
||||||
final timelineId = active ? workspace?.timeline?.id : null;
|
|
||||||
final allAssets = active ? workspace!.assets : <AssetDocument>[];
|
|
||||||
final assets = _browser.visibleAssets(allAssets, desktop: widget.desktop);
|
|
||||||
if (widget.desktop && assets.isEmpty) {
|
|
||||||
_viewportConfiguration = null;
|
|
||||||
_anchorOwner = null;
|
|
||||||
_anchorAssets = const [];
|
|
||||||
}
|
|
||||||
Widget item(BuildContext context, int index) {
|
|
||||||
final asset = assets[index];
|
|
||||||
return Consumer(
|
|
||||||
builder: (context, ref, _) {
|
|
||||||
final availability = ref
|
|
||||||
.watch(mediaAvailabilityProvider(widget.projectId, asset))
|
|
||||||
.asData
|
|
||||||
?.value;
|
|
||||||
final unavailable =
|
|
||||||
availability != null &&
|
|
||||||
availability != MediaAvailability.available;
|
|
||||||
return ListenableSelector<(bool, bool)>(
|
|
||||||
listenable: _browser,
|
|
||||||
select: () => (_selectedAssetId == asset.id, _checkingDrop),
|
|
||||||
builder: (context, presentation) => AppContextMenu(
|
|
||||||
key: ValueKey(('media-menu', asset.id)),
|
|
||||||
itemsBuilder: (_) {
|
|
||||||
final available = ref.read(projectsProvider).asData?.value;
|
|
||||||
final canEdit =
|
|
||||||
available?.activeProject?.id == widget.projectId &&
|
|
||||||
available?.projectBusy == false &&
|
|
||||||
!_checkingDrop;
|
|
||||||
final sequence = timeline?.activeSequenceId;
|
|
||||||
return [
|
|
||||||
AppMenuItem(
|
|
||||||
label: context.l10n.addToTimeline,
|
|
||||||
icon: AppIcons.add,
|
|
||||||
onPressed:
|
|
||||||
canEdit &&
|
|
||||||
!unavailable &&
|
|
||||||
sequence != null &&
|
|
||||||
available?.timeline?.id == timelineId
|
|
||||||
? () => _action(() => _browser.insertAsset(asset))
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
AppMenuItem(
|
|
||||||
label: context.l10n.rename,
|
|
||||||
icon: AppIcons.rename,
|
|
||||||
onPressed: canEdit ? () => _rename(asset) : null,
|
|
||||||
),
|
|
||||||
AppMenuItem(
|
|
||||||
label: defaultTargetPlatform == TargetPlatform.macOS
|
|
||||||
? context.l10n.revealFinder
|
|
||||||
: context.l10n.revealFileManager,
|
|
||||||
icon: AppIcons.folderOpen,
|
|
||||||
onPressed: canEdit && _desktop
|
|
||||||
? () => _action(() => _browser.reveal(asset))
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
const AppMenuSeparator(),
|
|
||||||
AppMenuItem(
|
|
||||||
label: context.l10n.removeMedia,
|
|
||||||
icon: AppIcons.delete,
|
|
||||||
destructive: true,
|
|
||||||
onPressed: canEdit ? () => _remove(asset) : null,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
},
|
|
||||||
child: Listener(
|
|
||||||
onPointerDown: (event) {
|
|
||||||
if (event.buttons == 2) {
|
|
||||||
_selectedAssetId = asset.id;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: _SelectableAsset(
|
|
||||||
key: ValueKey(asset.id),
|
|
||||||
grid: _isGrid,
|
|
||||||
desktop: widget.desktop,
|
|
||||||
drag: MediaAssetDrag(
|
|
||||||
projectId: widget.projectId,
|
|
||||||
assetId: asset.id,
|
|
||||||
),
|
|
||||||
name: asset.name,
|
|
||||||
draggable:
|
|
||||||
widget.draggable &&
|
|
||||||
!workspace!.projectBusy &&
|
|
||||||
!presentation.$2 &&
|
|
||||||
!unavailable,
|
|
||||||
selected: presentation.$1,
|
|
||||||
onTap: () => _browser.selectAsset(asset),
|
|
||||||
child: _assetTile(asset, availability),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final content = assets.isEmpty
|
|
||||||
? Center(
|
? Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(AppSpacing.medium),
|
padding: const EdgeInsets.all(AppSpacing.medium),
|
||||||
child: Text(
|
child: Text(
|
||||||
widget.desktop && _browser.query.trim().isNotEmpty
|
_filter != MediaFilter.all
|
||||||
? context.l10n.noMatchingMedia
|
|
||||||
: _filter != MediaFilter.all
|
|
||||||
? context.l10n.noMediaOfType(_filter.label(context))
|
? context.l10n.noMediaOfType(_filter.label(context))
|
||||||
: _desktop
|
: _desktop
|
||||||
? context.l10n.dragMediaHint
|
? context.l10n.dragMediaHint
|
||||||
@@ -405,25 +206,16 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
|||||||
)
|
)
|
||||||
: LayoutBuilder(
|
: LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final spacing = widget.desktop
|
final spacing = widget.compact
|
||||||
? DesktopMediaMetrics.gap
|
|
||||||
: widget.compact
|
|
||||||
? AppSpacing.gap
|
? AppSpacing.gap
|
||||||
: AppSpacing.small;
|
: AppSpacing.small;
|
||||||
final padding = widget.desktop
|
final padding = widget.compact
|
||||||
? DesktopMediaMetrics.padding
|
|
||||||
: widget.compact
|
|
||||||
? AppSidebarMetrics.outerPadding
|
? AppSidebarMetrics.outerPadding
|
||||||
: AppSpacing.compact;
|
: AppSpacing.compact;
|
||||||
final width = math.max(1.0, constraints.maxWidth - padding * 2);
|
final width = math.max(1.0, constraints.maxWidth - padding * 2);
|
||||||
final columns = math.max(
|
final columns = math.max(
|
||||||
1,
|
1,
|
||||||
widget.desktop
|
widget.compact
|
||||||
? DesktopMediaMetrics.columns(
|
|
||||||
width,
|
|
||||||
_browser.gridSize.targetWidth,
|
|
||||||
)
|
|
||||||
: widget.compact
|
|
||||||
? ((width + spacing) /
|
? ((width + spacing) /
|
||||||
(maximumCompactMediaGridTileWidth + spacing))
|
(maximumCompactMediaGridTileWidth + spacing))
|
||||||
.ceil()
|
.ceil()
|
||||||
@@ -436,158 +228,134 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
|||||||
final labelHeight =
|
final labelHeight =
|
||||||
MediaQuery.textScalerOf(context).scale(textStyle.fontSize!) *
|
MediaQuery.textScalerOf(context).scale(textStyle.fontSize!) *
|
||||||
(textStyle.height ?? 1.2);
|
(textStyle.height ?? 1.2);
|
||||||
final desktopLabelHeight = widget.desktop && _isGrid
|
Widget item(BuildContext context, int index) {
|
||||||
? DesktopMediaAssetTile.gridLabelHeight(context)
|
final asset = assets[index];
|
||||||
: 0.0;
|
return Consumer(
|
||||||
final desktopExtent = !widget.desktop
|
builder: (context, ref, _) {
|
||||||
? 0.0
|
final availability = ref
|
||||||
: _isGrid
|
.watch(
|
||||||
? DesktopMediaMetrics.gridExtent(
|
mediaAvailabilityProvider(widget.projectId, asset),
|
||||||
tileWidth,
|
)
|
||||||
desktopLabelHeight,
|
.asData
|
||||||
)
|
?.value;
|
||||||
: math.max(
|
final unavailable =
|
||||||
DesktopMediaMetrics.listRow,
|
availability != null &&
|
||||||
DesktopMediaAssetTile.gridLabelHeight(context) +
|
availability != MediaAvailability.available;
|
||||||
DesktopMediaMetrics.tilePadding * 2,
|
return AppContextMenu(
|
||||||
);
|
key: ValueKey(('media-menu', asset.id)),
|
||||||
if (widget.desktop) {
|
itemsBuilder: (_) {
|
||||||
_prepareDesktopScroll(
|
final available = ref
|
||||||
assets: assets,
|
.read(projectsProvider)
|
||||||
configuration: (
|
.asData
|
||||||
widget.projectId,
|
?.value;
|
||||||
_browser,
|
final canEdit =
|
||||||
_isGrid,
|
available?.activeProject?.id == widget.projectId &&
|
||||||
columns,
|
available?.projectBusy == false &&
|
||||||
desktopExtent,
|
!_checkingDrop;
|
||||||
constraints.maxHeight,
|
final sequence = timeline?.activeSequenceId;
|
||||||
_filter,
|
return [
|
||||||
_browser.query,
|
AppMenuItem(
|
||||||
_browser.sort,
|
label: context.l10n.addToTimeline,
|
||||||
allAssets,
|
icon: Icons.add,
|
||||||
),
|
onPressed:
|
||||||
columns: _isGrid ? columns : 1,
|
canEdit &&
|
||||||
extent: desktopExtent,
|
!unavailable &&
|
||||||
height: constraints.maxHeight,
|
sequence != null &&
|
||||||
);
|
available?.timeline?.id == timelineId
|
||||||
}
|
? () =>
|
||||||
Widget scrollView(ScrollController controller) => !_isGrid
|
_action(() => _browser.insertAsset(asset))
|
||||||
? widget.desktop
|
: null,
|
||||||
? ListView.builder(
|
),
|
||||||
key: PageStorageKey((
|
AppMenuItem(
|
||||||
'media-list',
|
label: context.l10n.rename,
|
||||||
widget.projectId,
|
icon: Icons.drive_file_rename_outline,
|
||||||
)),
|
onPressed: canEdit ? () => _rename(asset) : null,
|
||||||
controller: controller,
|
),
|
||||||
padding: EdgeInsets.all(padding),
|
AppMenuItem(
|
||||||
itemCount: assets.length,
|
label: defaultTargetPlatform == TargetPlatform.macOS
|
||||||
itemExtent: desktopExtent + spacing,
|
? context.l10n.revealFinder
|
||||||
itemBuilder: (context, index) => Padding(
|
: context.l10n.revealFileManager,
|
||||||
padding: EdgeInsets.only(bottom: spacing),
|
icon: Icons.folder_open,
|
||||||
child: item(context, index),
|
onPressed: canEdit && _desktop
|
||||||
),
|
? () => _action(() => _browser.reveal(asset))
|
||||||
)
|
: null,
|
||||||
: ListView.separated(
|
),
|
||||||
key: PageStorageKey((
|
const AppMenuSeparator(),
|
||||||
'media-list',
|
AppMenuItem(
|
||||||
widget.projectId,
|
label: context.l10n.removeMedia,
|
||||||
)),
|
icon: Icons.delete_outline,
|
||||||
controller: controller,
|
destructive: true,
|
||||||
padding: EdgeInsets.all(padding),
|
onPressed: canEdit ? () => _remove(asset) : null,
|
||||||
itemCount: assets.length,
|
),
|
||||||
itemBuilder: item,
|
];
|
||||||
separatorBuilder: (_, _) =>
|
},
|
||||||
SizedBox(height: spacing),
|
child: Listener(
|
||||||
)
|
onPointerDown: (event) {
|
||||||
: GridView.custom(
|
if (event.buttons == 2) {
|
||||||
key: PageStorageKey(('media-grid', widget.projectId)),
|
setState(() => _selectedAssetId = asset.id);
|
||||||
controller: controller,
|
}
|
||||||
semanticChildCount: assets.length,
|
},
|
||||||
padding: EdgeInsets.all(padding),
|
child: _SelectableAsset(
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
key: ValueKey(asset.id),
|
||||||
crossAxisCount: columns,
|
grid: _isGrid,
|
||||||
crossAxisSpacing: spacing,
|
drag: MediaAssetDrag(
|
||||||
mainAxisSpacing: widget.desktop || widget.compact
|
projectId: widget.projectId,
|
||||||
? spacing
|
assetId: asset.id,
|
||||||
: AppSpacing.compact,
|
),
|
||||||
mainAxisExtent: widget.desktop
|
name: asset.name,
|
||||||
? desktopExtent
|
draggable:
|
||||||
: tileWidth * 9 / 16 +
|
widget.draggable &&
|
||||||
(widget.compact
|
!workspace!.projectBusy &&
|
||||||
? AppSpacing.gap
|
!_checkingDrop &&
|
||||||
: AppSpacing.small) +
|
!unavailable,
|
||||||
labelHeight +
|
selected: _selectedAssetId == asset.id,
|
||||||
2,
|
onTap: () => _browser.selectAsset(asset),
|
||||||
),
|
child: _assetTile(asset, availability),
|
||||||
childrenDelegate: _MediaChildrenDelegate(
|
),
|
||||||
item,
|
|
||||||
childCount: assets.length,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (widget.desktop) {
|
},
|
||||||
return ScrollEdgeFade(
|
|
||||||
controller: _desktopScroll,
|
|
||||||
child: scrollView(_desktopScroll),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ScrollEdgeFadeBuilder(
|
return ScrollEdgeFadeBuilder(
|
||||||
key: ValueKey(('media-scroll-fade', widget.projectId, _isGrid)),
|
key: ValueKey(('media-scroll-fade', widget.projectId, _isGrid)),
|
||||||
builder: scrollView,
|
builder: (controller) => !_isGrid
|
||||||
|
? ListView.separated(
|
||||||
|
key: PageStorageKey(('media-list', widget.projectId)),
|
||||||
|
controller: controller,
|
||||||
|
padding: EdgeInsets.all(padding),
|
||||||
|
itemCount: assets.length,
|
||||||
|
itemBuilder: item,
|
||||||
|
separatorBuilder: (_, _) => SizedBox(height: spacing),
|
||||||
|
)
|
||||||
|
: GridView.builder(
|
||||||
|
key: PageStorageKey(('media-grid', widget.projectId)),
|
||||||
|
controller: controller,
|
||||||
|
padding: EdgeInsets.all(padding),
|
||||||
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
|
crossAxisCount: columns,
|
||||||
|
crossAxisSpacing: spacing,
|
||||||
|
mainAxisSpacing: widget.compact
|
||||||
|
? spacing
|
||||||
|
: AppSpacing.compact,
|
||||||
|
mainAxisExtent:
|
||||||
|
tileWidth * 9 / 16 +
|
||||||
|
(widget.compact
|
||||||
|
? AppSpacing.gap
|
||||||
|
: AppSpacing.small) +
|
||||||
|
labelHeight +
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
itemCount: assets.length,
|
||||||
|
itemBuilder: item,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (!widget.desktop) return content;
|
|
||||||
return Column(
|
|
||||||
children: [
|
|
||||||
Expanded(child: content),
|
|
||||||
const Divider(height: 1),
|
|
||||||
SizedBox(
|
|
||||||
key: const Key('media-browser-footer'),
|
|
||||||
height: 28,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
||||||
child: ListenableSelector(
|
|
||||||
listenable: _browser,
|
|
||||||
select: () => assets.any((asset) => asset.id == _selectedAssetId),
|
|
||||||
builder: (context, selected) => Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
context.l10n.mediaCount(assets.length),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (selected)
|
|
||||||
Flexible(
|
|
||||||
child: Align(
|
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
|
||||||
child: Text(
|
|
||||||
context.l10n.mediaSelectedCount(1),
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: Theme.of(context).textTheme.bodySmall,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _assetTile(AssetDocument asset, MediaAvailability? availability) {
|
Widget _assetTile(AssetDocument asset, MediaAvailability? availability) {
|
||||||
if (widget.desktop) {
|
|
||||||
return DesktopMediaAssetTile(
|
|
||||||
asset: asset,
|
|
||||||
grid: _isGrid,
|
|
||||||
availability: availability,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final unavailable =
|
final unavailable =
|
||||||
availability != null && availability != MediaAvailability.available;
|
availability != null && availability != MediaAvailability.available;
|
||||||
final cover = unavailable
|
final cover = unavailable
|
||||||
@@ -620,7 +388,7 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
|||||||
aspectRatio: 16 / 9,
|
aspectRatio: 16 / 9,
|
||||||
child: ColoredBox(
|
child: ColoredBox(
|
||||||
color: AppSurfaces.of(context).previewBackground,
|
color: AppSurfaces.of(context).previewBackground,
|
||||||
child: const Icon(AppIcons.file),
|
child: const Icon(Icons.insert_drive_file_outlined),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@@ -661,28 +429,10 @@ class _MediaBrowserBodyState extends ConsumerState<MediaBrowserBody>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MediaScrollController extends ScrollController {
|
|
||||||
_MediaScrollController() : super(keepScrollOffset: false);
|
|
||||||
double initialOffset = 0;
|
|
||||||
|
|
||||||
@override
|
|
||||||
ScrollPosition createScrollPosition(
|
|
||||||
ScrollPhysics physics,
|
|
||||||
ScrollContext context,
|
|
||||||
ScrollPosition? oldPosition,
|
|
||||||
) => ScrollPositionWithSingleContext(
|
|
||||||
physics: physics,
|
|
||||||
context: context,
|
|
||||||
initialPixels: initialOffset,
|
|
||||||
keepScrollOffset: false,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
class _SelectableAsset extends StatelessWidget {
|
class _SelectableAsset extends StatelessWidget {
|
||||||
const _SelectableAsset({
|
const _SelectableAsset({
|
||||||
super.key,
|
super.key,
|
||||||
required this.grid,
|
required this.grid,
|
||||||
this.desktop = false,
|
|
||||||
required this.selected,
|
required this.selected,
|
||||||
required this.drag,
|
required this.drag,
|
||||||
required this.name,
|
required this.name,
|
||||||
@@ -693,7 +443,6 @@ class _SelectableAsset extends StatelessWidget {
|
|||||||
|
|
||||||
final bool selected;
|
final bool selected;
|
||||||
final bool grid;
|
final bool grid;
|
||||||
final bool desktop;
|
|
||||||
final MediaAssetDrag drag;
|
final MediaAssetDrag drag;
|
||||||
final String name;
|
final String name;
|
||||||
final bool draggable;
|
final bool draggable;
|
||||||
@@ -708,68 +457,39 @@ class _SelectableAsset extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
final tile = Semantics(
|
final tile = Semantics(
|
||||||
selected: selected,
|
selected: selected,
|
||||||
child: desktop
|
child: InkWell(
|
||||||
? Material(
|
onTap: onTap,
|
||||||
color: selected
|
hoverColor: Colors.transparent,
|
||||||
? Theme.of(context).colorScheme.primary.withValues(alpha: .08)
|
highlightColor: Colors.transparent,
|
||||||
: Colors.transparent,
|
splashFactory: NoSplash.splashFactory,
|
||||||
shape: RoundedRectangleBorder(
|
child: Stack(
|
||||||
borderRadius: BorderRadius.circular(6),
|
children: [
|
||||||
side: BorderSide(
|
child,
|
||||||
color: selected
|
if (selected && !grid)
|
||||||
? Theme.of(context).colorScheme.primary
|
Positioned(
|
||||||
: Colors.transparent,
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
height: MediaAssetStrip.height,
|
||||||
|
child: IgnorePointer(
|
||||||
|
child: DecoratedBox(decoration: selectionDecoration),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
clipBehavior: Clip.antiAlias,
|
if (selected && grid)
|
||||||
child: InkWell(
|
Positioned(
|
||||||
onTap: onTap,
|
top: 0,
|
||||||
hoverColor: Theme.of(context).colorScheme.onSurface
|
left: 0,
|
||||||
.withValues(alpha: .05),
|
right: 0,
|
||||||
child: Padding(
|
child: IgnorePointer(
|
||||||
padding: const EdgeInsets.all(5),
|
child: AspectRatio(
|
||||||
child: grid
|
aspectRatio: 16 / 9,
|
||||||
? child
|
child: DecoratedBox(decoration: selectionDecoration),
|
||||||
: ConstrainedBox(
|
),
|
||||||
constraints: const BoxConstraints(minHeight: 38),
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
],
|
||||||
: InkWell(
|
),
|
||||||
onTap: onTap,
|
),
|
||||||
hoverColor: Colors.transparent,
|
|
||||||
highlightColor: Colors.transparent,
|
|
||||||
splashFactory: NoSplash.splashFactory,
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
child,
|
|
||||||
if (selected && !grid)
|
|
||||||
Positioned(
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
height: MediaAssetStrip.height,
|
|
||||||
child: IgnorePointer(
|
|
||||||
child: DecoratedBox(decoration: selectionDecoration),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (selected && grid)
|
|
||||||
Positioned(
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
child: IgnorePointer(
|
|
||||||
child: AspectRatio(
|
|
||||||
aspectRatio: 16 / 9,
|
|
||||||
child: DecoratedBox(decoration: selectionDecoration),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
return Draggable<MediaAssetDrag>(
|
return Draggable<MediaAssetDrag>(
|
||||||
data: drag,
|
data: drag,
|
||||||
@@ -802,13 +522,3 @@ class _SelectableAsset extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constraint changes reflow existing cells without rebuilding menus and tiles.
|
|
||||||
// A new builder is created when assets, filters or the project change.
|
|
||||||
class _MediaChildrenDelegate extends SliverChildBuilderDelegate {
|
|
||||||
const _MediaChildrenDelegate(super.builder, {super.childCount});
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool shouldRebuild(covariant _MediaChildrenDelegate oldDelegate) =>
|
|
||||||
builder != oldDelegate.builder || childCount != oldDelegate.childCount;
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:cutdex_core/project.dart';
|
import 'package:cutdex_sdk/project.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
import '../../integrations/platform/file_picker.dart';
|
import '../../integrations/platform/file_picker.dart';
|
||||||
@@ -14,8 +14,6 @@ import '../../workspace/timeline_provider.dart';
|
|||||||
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
import 'resource_section.dart';
|
|
||||||
|
|
||||||
enum MediaFilter {
|
enum MediaFilter {
|
||||||
all(null),
|
all(null),
|
||||||
image('image'),
|
image('image'),
|
||||||
@@ -26,18 +24,6 @@ enum MediaFilter {
|
|||||||
final String? kind;
|
final String? kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum MediaSort { importOrder, nameAscending, nameDescending }
|
|
||||||
|
|
||||||
/// Desktop thumbnail density, independent of touch-page presentation.
|
|
||||||
enum MediaGridSize {
|
|
||||||
small(96),
|
|
||||||
medium(120),
|
|
||||||
large(160);
|
|
||||||
|
|
||||||
const MediaGridSize(this.targetWidth);
|
|
||||||
final double targetWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
final mediaBrowserProvider = Provider.family<MediaBrowserController, String>((
|
final mediaBrowserProvider = Provider.family<MediaBrowserController, String>((
|
||||||
ref,
|
ref,
|
||||||
projectId,
|
projectId,
|
||||||
@@ -55,9 +41,8 @@ class MediaBrowserController extends ChangeNotifier {
|
|||||||
final feedback = MediaImportFeedbackController();
|
final feedback = MediaImportFeedbackController();
|
||||||
bool _working = false;
|
bool _working = false;
|
||||||
bool _disposed = false;
|
bool _disposed = false;
|
||||||
bool get importing =>
|
bool get busy =>
|
||||||
_ref.read(externalMediaImportProvider(projectId)).isLoading;
|
_working || _ref.read(externalMediaImportProvider(projectId)).isLoading;
|
||||||
bool get busy => _working || importing;
|
|
||||||
bool get active =>
|
bool get active =>
|
||||||
!_disposed &&
|
!_disposed &&
|
||||||
_ref.mounted &&
|
_ref.mounted &&
|
||||||
@@ -96,11 +81,7 @@ class MediaBrowserController extends ChangeNotifier {
|
|||||||
.importFiles(files);
|
.importFiles(files);
|
||||||
final asset = result?.selected.firstOrNull;
|
final asset = result?.selected.firstOrNull;
|
||||||
if (!_disposed && asset != null) {
|
if (!_disposed && asset != null) {
|
||||||
_resourceSection = ResourceSection.imported;
|
|
||||||
_selectedAssetId = asset.id;
|
_selectedAssetId = asset.id;
|
||||||
if (!asset.name.toLowerCase().contains(_query.trim().toLowerCase())) {
|
|
||||||
_query = '';
|
|
||||||
}
|
|
||||||
if (_filter != MediaFilter.all &&
|
if (_filter != MediaFilter.all &&
|
||||||
asset.metadata['kind'] != _filter.kind) {
|
asset.metadata['kind'] != _filter.kind) {
|
||||||
_filter = MediaFilter.all;
|
_filter = MediaFilter.all;
|
||||||
@@ -191,87 +172,23 @@ class MediaBrowserController extends ChangeNotifier {
|
|||||||
String? _selectedAssetId;
|
String? _selectedAssetId;
|
||||||
MediaFilter _filter = MediaFilter.all;
|
MediaFilter _filter = MediaFilter.all;
|
||||||
bool _grid = true;
|
bool _grid = true;
|
||||||
String _query = '';
|
|
||||||
MediaSort _sort = MediaSort.importOrder;
|
|
||||||
MediaGridSize _gridSize = MediaGridSize.medium;
|
|
||||||
ResourceSection _resourceSection = ResourceSection.imported;
|
|
||||||
|
|
||||||
/// The first visible desktop asset and its fraction through the current row.
|
|
||||||
/// Scroll updates are silent; browsing does not rebuild controls or metadata.
|
|
||||||
({String assetId, double fraction})? viewportAnchor;
|
|
||||||
|
|
||||||
String? get selectedAssetId => _selectedAssetId;
|
String? get selectedAssetId => _selectedAssetId;
|
||||||
MediaFilter get filter => _filter;
|
MediaFilter get filter => _filter;
|
||||||
bool get grid => _grid;
|
bool get grid => _grid;
|
||||||
String get query => _query;
|
|
||||||
MediaSort get sort => _sort;
|
|
||||||
MediaGridSize get gridSize => _gridSize;
|
|
||||||
ResourceSection get resourceSection => _resourceSection;
|
|
||||||
|
|
||||||
/// Resource libraries are desktop navigation, separate from media filters.
|
|
||||||
set resourceSection(ResourceSection value) {
|
|
||||||
if (_resourceSection == value) return;
|
|
||||||
_resourceSection = value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Touch pages keep their own presentation while sharing category selection.
|
|
||||||
List<AssetDocument> visibleAssets(
|
|
||||||
Iterable<AssetDocument> assets, {
|
|
||||||
bool desktop = false,
|
|
||||||
}) {
|
|
||||||
final query = desktop ? _query.trim().toLowerCase() : '';
|
|
||||||
final result = assets
|
|
||||||
.where(
|
|
||||||
(asset) =>
|
|
||||||
(_filter == MediaFilter.all ||
|
|
||||||
asset.metadata['kind'] == _filter.kind) &&
|
|
||||||
asset.name.toLowerCase().contains(query),
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
if (desktop && _sort != MediaSort.importOrder) {
|
|
||||||
result.sort((a, b) {
|
|
||||||
var order = a.name.toLowerCase().compareTo(b.name.toLowerCase());
|
|
||||||
if (order == 0) order = a.id.compareTo(b.id);
|
|
||||||
return _sort == MediaSort.nameDescending ? -order : order;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
set query(String value) {
|
|
||||||
if (_query == value) return;
|
|
||||||
_query = value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
set sort(MediaSort value) {
|
|
||||||
if (_sort == value) return;
|
|
||||||
_sort = value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
set selectedAssetId(String? value) {
|
set selectedAssetId(String? value) {
|
||||||
if (_selectedAssetId == value) return;
|
|
||||||
_selectedAssetId = value;
|
_selectedAssetId = value;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
set filter(MediaFilter value) {
|
set filter(MediaFilter value) {
|
||||||
if (_filter == value) return;
|
|
||||||
_filter = value;
|
_filter = value;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
set grid(bool value) {
|
set grid(bool value) {
|
||||||
if (_grid == value) return;
|
|
||||||
_grid = value;
|
_grid = value;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
set gridSize(MediaGridSize value) {
|
|
||||||
if (_gridSize == value) return;
|
|
||||||
_gridSize = value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import 'dart:math' as math;
|
|
||||||
|
|
||||||
/// Shared desktop geometry for cards, rows, headers and browse anchoring.
|
|
||||||
abstract final class DesktopMediaMetrics {
|
|
||||||
static const padding = 16.0;
|
|
||||||
static const gap = 8.0;
|
|
||||||
static const tilePadding = 8.0;
|
|
||||||
static const listCover = 56.0;
|
|
||||||
static const listRow = 48.0;
|
|
||||||
|
|
||||||
static int columns(double width, double targetWidth) =>
|
|
||||||
math.max(1, ((width + gap) / (targetWidth + gap)).ceil());
|
|
||||||
|
|
||||||
static double gridExtent(double tileWidth, double labelHeight) =>
|
|
||||||
(tileWidth - tilePadding * 2) * 9 / 16 +
|
|
||||||
4 +
|
|
||||||
labelHeight +
|
|
||||||
tilePadding * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// List-column visibility within asset rows.
|
|
||||||
final class DesktopMediaListColumns {
|
|
||||||
const DesktopMediaListColumns(double width)
|
|
||||||
: duration = width >= 240,
|
|
||||||
specification = width >= 480,
|
|
||||||
kind = width >= 620;
|
|
||||||
|
|
||||||
final bool duration, specification, kind;
|
|
||||||
static const durationWidth = 64.0;
|
|
||||||
static const specificationWidth = 136.0;
|
|
||||||
static const kindWidth = 56.0;
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
import 'package:cutdex/shared/widgets/error_notification_host.dart';
|
||||||
import 'package:cutdex_ui/icons.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
@@ -40,19 +39,8 @@ class TouchMediaBrowser extends ConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final browser = ref.watch(mediaBrowserProvider(projectId));
|
final browser = ref.watch(mediaBrowserProvider(projectId));
|
||||||
ref.watch(
|
ref.watch(externalMediaImportProvider(projectId));
|
||||||
externalMediaImportProvider(projectId).select((value) => value.isLoading),
|
final workspace = ref.watch(projectsProvider).value;
|
||||||
);
|
|
||||||
final workspace = ref.watch(
|
|
||||||
projectsProvider.select(
|
|
||||||
(value) => value.value?.copyWith(
|
|
||||||
recent: const [],
|
|
||||||
timelines: const [],
|
|
||||||
error: null,
|
|
||||||
creatingTimeline: false,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
final timelineId = workspace?.activeProject?.id == projectId
|
final timelineId = workspace?.activeProject?.id == projectId
|
||||||
? workspace?.timeline?.id
|
? workspace?.timeline?.id
|
||||||
: null;
|
: null;
|
||||||
@@ -84,20 +72,20 @@ class TouchMediaBrowser extends ConsumerWidget {
|
|||||||
height: 56,
|
height: 56,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox.square(
|
||||||
height: 48,
|
dimension: 48,
|
||||||
child: TextButton(
|
child: IconButton(
|
||||||
key: const Key('media-import-button'),
|
key: const Key('media-import-button'),
|
||||||
|
tooltip: context.l10n.importMedia,
|
||||||
onPressed: browser.canImport
|
onPressed: browser.canImport
|
||||||
? () => pickMediaFiles(browser)
|
? () => pickMediaFiles(browser)
|
||||||
: null,
|
: null,
|
||||||
child: Text(context.l10n.importMedia),
|
icon: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: DropdownButton<MediaFilter>(
|
child: DropdownButton<MediaFilter>(
|
||||||
key: const Key('media-category-picker'),
|
key: const Key('media-category-picker'),
|
||||||
icon: const Icon(AppIcons.expandMore),
|
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
underline: const SizedBox.shrink(),
|
underline: const SizedBox.shrink(),
|
||||||
value: browser.filter,
|
value: browser.filter,
|
||||||
@@ -122,8 +110,8 @@ class TouchMediaBrowser extends ConsumerWidget {
|
|||||||
: context.l10n.gridLayout,
|
: context.l10n.gridLayout,
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
browser.grid
|
browser.grid
|
||||||
? AppIcons.listView
|
? Icons.view_list_outlined
|
||||||
: AppIcons.gridView,
|
: Icons.grid_view_outlined,
|
||||||
),
|
),
|
||||||
onPressed: () => browser.grid = !browser.grid,
|
onPressed: () => browser.grid = !browser.grid,
|
||||||
),
|
),
|
||||||
@@ -131,7 +119,7 @@ class TouchMediaBrowser extends ConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (browser.importing) const LinearProgressIndicator(),
|
if (browser.busy) const LinearProgressIndicator(),
|
||||||
Expanded(
|
Expanded(
|
||||||
key: const Key('media-panel-body'),
|
key: const Key('media-panel-body'),
|
||||||
child: MediaBrowserBody(
|
child: MediaBrowserBody(
|
||||||
@@ -162,7 +150,7 @@ class TouchMediaBrowser extends ConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon: const Icon(AppIcons.add),
|
icon: const Icon(Icons.add),
|
||||||
label: Text(
|
label: Text(
|
||||||
context.l10n.addToTimeline,
|
context.l10n.addToTimeline,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
|||||||
Loaded 100 of 593 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user