diff --git a/.github/workflows/flatpak.yml b/.github/workflows/flatpak.yml index 8179eb22..8465a80c 100644 --- a/.github/workflows/flatpak.yml +++ b/.github/workflows/flatpak.yml @@ -5,16 +5,22 @@ on: branches: [ "main" ] types: [ "review_requested", "ready_for_review" ] workflow_dispatch: + workflow_call: + inputs: + tag: + description: "Git ref to check out" + type: string + required: true name: Flatpak permissions: id-token: write contents: read jobs: - gnome-flatpak: - name: "GNOME on Flatpak" + flatpak: + name: "Tauri on Flatpak" if: ${{ github.event.pull_request.user.login != 'weblate' }} container: - image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-49 + image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-51 options: --privileged strategy: matrix: @@ -25,12 +31,15 @@ jobs: runner: ubuntu-24.04-arm runs-on: ${{ matrix.variant.runner }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 + with: + ref: ${{ inputs.tag || github.ref_name }} - uses: flatpak/flatpak-github-actions/flatpak-builder@v6 with: - bundle: org.nickvision.application.flatpak - manifest-path: flatpak/org.nickvision.application.json - cache-key: flatpak-builder-${{ github.sha }} + bundle: org.nickvision.application.${{ matrix.variant.arch }}.flatpak + manifest-path: build-aux/flatpak/org.nickvision.application.json + cache-key: flatpak-builder-${{ inputs.tag || github.sha }} arch: ${{ matrix.variant.arch }} restore-cache: true - verbose: true \ No newline at end of file + verbose: true + artifact-name: org.nickvision.application.${{ matrix.variant.arch }}.flatpak diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 00000000..f3f18383 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,47 @@ +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + types: [ "review_requested", "ready_for_review" ] + workflow_dispatch: +name: Format +permissions: + contents: read +jobs: + rust: + name: "Rust" + if: ${{ github.event.pull_request.user.login != 'weblate' }} + runs-on: macos-latest + steps: + - uses: actions/checkout@v7 + - name: "Setup Environment" + run: | + brew install gettext + echo "$(brew --prefix gettext)/bin" >> "$GITHUB_PATH" + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + with: + workspaces: src-tauri -> target + - name: "cargo fmt" + working-directory: src-tauri + run: cargo fmt --all -- --check + - name: "cargo clippy" + working-directory: src-tauri + run: cargo clippy --all-targets -- -D warnings + frontend: + name: "Frontend" + if: ${{ github.event.pull_request.user.login != 'weblate' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: lts/* + cache: npm + - name: "Install frontend dependencies" + run: npm ci + - name: "Format check" + run: npm run format:check diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 00000000..80f3f64e --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,88 @@ +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + types: [ "review_requested", "ready_for_review" ] + workflow_dispatch: + workflow_call: + inputs: + tag: + description: "Git ref to check out" + type: string + required: true + release_tag: + description: "GitHub release tag to publish to; leave empty to only build" + type: string + required: false + default: "" + prerelease: + type: boolean + required: false + default: false + release_body: + type: string + required: false + default: "" +name: Linux +permissions: + id-token: write + contents: write +jobs: + tauri-linux: + name: "Tauri on Linux" + if: ${{ github.event.pull_request.user.login != 'weblate' }} + strategy: + fail-fast: false + matrix: + variant: + - arch: x86_64 + runner: ubuntu-latest + - arch: aarch64 + runner: ubuntu-24.04-arm + runs-on: ${{ matrix.variant.runner }} + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ inputs.tag || github.ref_name }} + - name: "Setup environment" + run: | + sudo apt-get update + sudo apt-get install -y \ + libwebkit2gtk-4.1-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev \ + patchelf \ + build-essential \ + curl \ + wget \ + file \ + libssl-dev \ + libxdo-dev \ + libfuse2 \ + gettext + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: src-tauri -> target + key: ${{ (inputs.release_tag != '' && 'release-') || '' }}${{ matrix.variant.arch }} + - uses: actions/setup-node@v7 + with: + node-version: lts/* + cache: npm + - name: "Install frontend dependencies" + run: npm ci + - name: "Build" + uses: tauri-apps/tauri-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} + with: + tagName: ${{ inputs.release_tag }} + releaseName: "Application ${{ inputs.tag }}" + releaseBody: ${{ inputs.release_body }} + prerelease: ${{ inputs.prerelease == true }} + retryAttempts: 3 + uploadWorkflowArtifacts: ${{ inputs.release_tag == '' }} + workflowArtifactNamePattern: Application-${{ matrix.variant.arch }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index b17f8ba2..533b3184 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -5,44 +5,72 @@ on: branches: [ "main" ] types: [ "review_requested", "ready_for_review" ] workflow_dispatch: + workflow_call: + inputs: + tag: + description: "Git ref to check out" + type: string + required: true + release_tag: + description: "GitHub release tag to publish to; leave empty to only build" + type: string + required: false + default: "" + prerelease: + type: boolean + required: false + default: false + release_body: + type: string + required: false + default: "" name: macOS permissions: id-token: write - contents: read -env: - PROJECT_NAME: Nickvision.Application.GNOME - APP_NAME: Application + contents: write jobs: - gnome-macos: - name: "GNOME on macOS" + tauri-macos: + name: "Tauri on macOS" if: ${{ github.event.pull_request.user.login != 'weblate' }} strategy: + fail-fast: false matrix: variant: - arch: arm64 runner: macos-latest - runtime: osx-arm64 - arch: x64 - runner: macos-15-intel - runtime: osx-x64 + runner: macos-26-intel runs-on: ${{ matrix.variant.runner }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 with: - submodules: recursive - - name: "Setup Environment" - run: brew install gtk4 libadwaita blueprint-compiler gettext glib - - uses: actions/setup-dotnet@v5 - with: - dotnet-version: '10.0.x' - - name: "Restore" - run: dotnet restore ${{ env.PROJECT_NAME }} --runtime ${{ matrix.variant.runtime }} /p:PublishReadyToRun=true - - name: "Package" - working-directory: ${{ github.workspace }} + ref: ${{ inputs.tag || github.ref_name }} + - name: "Setup environment" run: | - chmod +x resources/macos/publish-and-package.sh - ./resources/macos/publish-and-package.sh ${{ matrix.variant.runtime }} - - uses: actions/upload-artifact@v4 + brew install gettext + echo "$(brew --prefix gettext)/bin" >> "$GITHUB_PATH" + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: src-tauri -> target + key: ${{ (inputs.release_tag != '' && 'release-') || '' }}${{ matrix.variant.arch }} + - uses: actions/setup-node@v7 + with: + node-version: lts/* + cache: npm + - name: "Install frontend dependencies" + run: npm ci + - name: "Build" + uses: tauri-apps/tauri-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} with: - path: ${{ github.workspace }}/resources/macos/${{ env.APP_NAME }}.app - name: ${{ env.APP_NAME }}-${{ matrix.variant.arch }} + tagName: ${{ inputs.release_tag }} + releaseName: "Application ${{ inputs.tag }}" + releaseBody: ${{ inputs.release_body }} + prerelease: ${{ inputs.prerelease == true }} + retryAttempts: 3 + uploadWorkflowArtifacts: ${{ inputs.release_tag == '' }} + workflowArtifactNamePattern: Application-${{ matrix.variant.arch }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..df0f9c32 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,99 @@ +on: + push: + tags: + - "v*" + workflow_dispatch: + inputs: + tag: + description: "Tag to release (e.g. v2026.9.1 or v2026.9.1-beta.1)" + required: true +name: Release +permissions: + contents: write +jobs: + channel: + name: "Determine release channel" + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.vars.outputs.tag }} + release_tag: ${{ steps.vars.outputs.release_tag }} + prerelease: ${{ steps.vars.outputs.prerelease }} + steps: + - id: vars + run: | + TAG="${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}" + echo "tag=$TAG" >> "$GITHUB_OUTPUT" + if [[ "$TAG" == *-* ]]; then + echo "prerelease=true" >> "$GITHUB_OUTPUT" + echo "release_tag=preview" >> "$GITHUB_OUTPUT" + else + echo "prerelease=false" >> "$GITHUB_OUTPUT" + echo "release_tag=$TAG" >> "$GITHUB_OUTPUT" + fi + changelog: + name: "Read changelog" + needs: channel + runs-on: ubuntu-latest + outputs: + body: ${{ steps.read.outputs.body }} + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ needs.channel.outputs.tag }} + - id: read + run: | + { + echo 'body<> "$GITHUB_OUTPUT" + windows: + name: "Tauri on Windows" + needs: [ channel, changelog ] + uses: ./.github/workflows/windows.yml + secrets: inherit + with: + tag: ${{ needs.channel.outputs.tag }} + release_tag: ${{ needs.channel.outputs.release_tag }} + prerelease: ${{ needs.channel.outputs.prerelease == 'true' }} + release_body: ${{ needs.changelog.outputs.body }} + macos: + name: "Tauri on macOS" + needs: [ channel, changelog ] + uses: ./.github/workflows/macos.yml + secrets: inherit + with: + tag: ${{ needs.channel.outputs.tag }} + release_tag: ${{ needs.channel.outputs.release_tag }} + prerelease: ${{ needs.channel.outputs.prerelease == 'true' }} + release_body: ${{ needs.changelog.outputs.body }} + linux: + name: "Tauri on Linux" + needs: [ channel, changelog ] + uses: ./.github/workflows/linux.yml + secrets: inherit + with: + tag: ${{ needs.channel.outputs.tag }} + release_tag: ${{ needs.channel.outputs.release_tag }} + prerelease: ${{ needs.channel.outputs.prerelease == 'true' }} + release_body: ${{ needs.changelog.outputs.body }} + flatpak: + name: "Tauri on Flatpak" + needs: channel + uses: ./.github/workflows/flatpak.yml + secrets: inherit + with: + tag: ${{ needs.channel.outputs.tag }} + flatpak-release: + name: "Publish Flatpak" + needs: [ channel, windows, macos, linux, flatpak ] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v7 + with: + path: bundles + - uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ needs.channel.outputs.release_tag }} + prerelease: ${{ needs.channel.outputs.prerelease }} + files: bundles/**/*.flatpak diff --git a/.github/workflows/sources.yml b/.github/workflows/sources.yml new file mode 100644 index 00000000..4d93caa1 --- /dev/null +++ b/.github/workflows/sources.yml @@ -0,0 +1,63 @@ +on: + workflow_dispatch: + pull_request: + branches: [ "main" ] + paths: + - "src-tauri/Cargo.lock" + - "package-lock.json" + push: + branches: [ "main" ] + paths: + - "src-tauri/Cargo.lock" + - "package-lock.json" +name: Sources +permissions: + contents: write + pull-requests: write +jobs: + update-sources: + name: "Update Sources" + if: ${{ github.event.pull_request.user.login != 'weblate' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} + - uses: actions/setup-python@v6 + with: + python-version: "3.x" + - name: "Install generators" + run: | + pip install tomlkit aiohttp + git clone --depth 1 https://github.com/flatpak/flatpak-builder-tools.git /tmp/flatpak-builder-tools + pip install /tmp/flatpak-builder-tools/node + - name: "Update project dependencies" + run: npm update && cd src-tauri && cargo update && cd .. + - name: "Generate cargo-sources.json" + run: python3 /tmp/flatpak-builder-tools/cargo/flatpak-cargo-generator.py src-tauri/Cargo.lock -o build-aux/flatpak/cargo-sources.json + - name: "Generate node-sources.json" + run: flatpak-node-generator npm package-lock.json -o build-aux/flatpak/node-sources.json + - name: "Check for changes" + id: diff + run: echo "changed=$(git diff --quiet -- package-lock.json src-tauri/Cargo.lock build-aux/flatpak/cargo-sources.json build-aux/flatpak/node-sources.json && echo false || echo true)" >> "$GITHUB_OUTPUT" + - name: "Commit to existing PR" + if: steps.diff.outputs.changed == 'true' && github.event_name == 'pull_request' + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add package-lock.json src-tauri/Cargo.lock build-aux/flatpak/cargo-sources.json build-aux/flatpak/node-sources.json + git commit -m "chore: Sync sources" + git push + - name: "Open PR with sync" + if: steps.diff.outputs.changed == 'true' && github.event_name != 'pull_request' + uses: peter-evans/create-pull-request@v7 + with: + commit-message: "chore: Sync sources" + title: "chore: Sync sources" + body: "Automated update of project dependencies (package-lock.json, src-tauri/Cargo.lock) and build-aux/flatpak/cargo-sources.json, build-aux/flatpak/node-sources.json to match." + branch: sync-sources + add-paths: | + package-lock.json + src-tauri/Cargo.lock + build-aux/flatpak/cargo-sources.json + build-aux/flatpak/node-sources.json diff --git a/.github/workflows/spelling.yml b/.github/workflows/spelling.yml index fede7477..20b8d0dc 100644 --- a/.github/workflows/spelling.yml +++ b/.github/workflows/spelling.yml @@ -12,9 +12,9 @@ jobs: codespell: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - uses: codespell-project/actions-codespell@v2 with: check_filenames: true - skip: cargo-sources.json,.git,*.svg,*.html,*.js,*.po,*.pot,*.page,*.map,*.rtf,pch.h,CONTRIBUTING.md + skip: cargo-sources.json,node-sources.json,package-lock.json,.git,*.svg,*.po,*.pot,CONTRIBUTING.md ignore_words_list: gir diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 38bc47bd..e3ea7249 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -5,23 +5,39 @@ on: branches: [ "main" ] types: [ "review_requested", "ready_for_review" ] workflow_dispatch: + workflow_call: + inputs: + tag: + description: "Git ref to check out" + type: string + required: true + release_tag: + description: "GitHub release tag to publish to; leave empty to only build" + type: string + required: false + default: "" + prerelease: + type: boolean + required: false + default: false + release_body: + type: string + required: false + default: "" name: Windows permissions: id-token: write - contents: read -env: - PROJECT_NAME: Nickvision.Application.WinUI - INSTALLER_NAME: NickvisionApplicationSetup - SHORT_NAME: Application + contents: write jobs: - winui-windows: - name: "WinUI on Windows" + tauri-windows: + name: "Tauri on Windows" if: ${{ github.event.pull_request.user.login != 'weblate' }} strategy: + fail-fast: false matrix: variant: - arch: x64 - runner: windows-2025-vs2026 + runner: windows-latest subsys: mingw64 type: x86_64 - arch: arm64 @@ -30,54 +46,50 @@ jobs: type: clang-aarch64 runs-on: ${{ matrix.variant.runner }} steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 with: - submodules: recursive + ref: ${{ inputs.tag || github.ref_name }} - uses: msys2/setup-msys2@v2 id: msys2 with: msystem: ${{ matrix.variant.subsys }} install: mingw-w64-${{ matrix.variant.type }}-gettext-tools - - uses: actions/setup-dotnet@v5 - with: - dotnet-version: '10.0.x' - - name: "Setup Environment" + - name: "Setup environment" shell: pwsh run: echo "${{ steps.msys2.outputs.msys2-location }}\${{ matrix.variant.subsys }}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - - name: "Restore" - run: | - $vsInstallPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath - Import-Module "$vsInstallPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" - Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation - dotnet restore ${{ env.PROJECT_NAME }} --runtime win-${{ matrix.variant.arch }} /p:PublishReadyToRun=true - - name: "Publish" - run: | - $vsInstallPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath - Import-Module "$vsInstallPath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" - Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation - dotnet publish ${{ env.PROJECT_NAME }} -c Release --no-restore --runtime win-${{ matrix.variant.arch }} /p:Platform=${{ matrix.variant.arch }} - - name: "Installer" - working-directory: ${{github.workspace}}/inno - env: - APP_FILES_PATH: ${{ env.PROJECT_NAME }}/bin/${{ matrix.variant.arch }}/Release/net10.0-windows10.0.19041.0/win-${{ matrix.variant.arch }}/publish - shell: pwsh - run: | - $ProgressPreference = 'SilentlyContinue' - iscc setup.iss - - name: "Portable" + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: src-tauri -> target + key: ${{ (inputs.release_tag != '' && 'release-') || '' }}${{ matrix.variant.arch }} + - uses: actions/setup-node@v7 + with: + node-version: lts/* + cache: npm + - name: "Install frontend dependencies" + run: npm ci + - name: "Compute MSI version" shell: pwsh run: | - $publishDir = "${{ env.PROJECT_NAME }}\bin\${{ matrix.variant.arch }}\Release\net10.0-windows10.0.19041.0\win-${{ matrix.variant.arch }}\publish" - $portableDir = "${{ github.workspace }}\portable" - New-Item -ItemType Directory -Force -Path "$portableDir\Release" | Out-Null - Copy-Item -Path "$publishDir\*" -Destination "$portableDir\Release" -Recurse - $batContent = "@echo off`r`n`"%~dp0Release\${{ env.PROJECT_NAME }}.exe`" --portable" - Set-Content -Path "$portableDir\${{ env.SHORT_NAME }}.bat" -Value $batContent -NoNewline - - uses: actions/upload-artifact@v4 - with: - path: ${{ github.workspace }}/inno/${{ env.INSTALLER_NAME }}.exe - name: ${{ env.INSTALLER_NAME }}-${{ matrix.variant.arch }} - - uses: actions/upload-artifact@v4 + $version = (Get-Content src-tauri/tauri.conf.json | ConvertFrom-Json).version + $parts = $version -split '\.' + $wixVersion = "$([int]$parts[0] - 2000).$($parts[1]).$($parts[2])" + $conf = Get-Content src-tauri/tauri.windows.conf.json -Raw | ConvertFrom-Json -AsHashtable + if (-not $conf.bundle.Contains('windows')) { $conf.bundle.windows = @{} } + if (-not $conf.bundle.windows.Contains('wix')) { $conf.bundle.windows.wix = @{} } + $conf.bundle.windows.wix.version = $wixVersion + $conf | ConvertTo-Json -Depth 10 | Set-Content -Path src-tauri/tauri.windows.conf.json + - name: "Build" + uses: tauri-apps/tauri-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} with: - path: ${{ github.workspace }}/portable - name: ${{ env.PROJECT_NAME }}-portable-${{ matrix.variant.arch }} + tagName: ${{ inputs.release_tag }} + releaseName: "Application ${{ inputs.tag }}" + releaseBody: ${{ inputs.release_body }} + prerelease: ${{ inputs.prerelease == true }} + retryAttempts: 3 + uploadWorkflowArtifacts: ${{ inputs.release_tag == '' }} + workflowArtifactNamePattern: Application-${{ matrix.variant.arch }} diff --git a/.gitignore b/.gitignore index f754cbaa..8416a981 100644 --- a/.gitignore +++ b/.gitignore @@ -1,408 +1,24 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -.idea/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -# but not Directory.Build.rsp, as it configures directory-level build defaults -!Directory.Build.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj +# Logs +logs *.log -*.tlog -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx -*.appxbundle -*.appxupload - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio 6 auto-generated project file (contains which files were open etc.) -*.vbp - -# Visual Studio 6 workspace and project file (working project files containing files to include in project) -*.dsw -*.dsp - -# Visual Studio 6 technical files -*.ncb -*.aps - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# Visual Studio History (VSHistory) files -.vshistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd - -# VS Code files for those working on multiple tools -.vscode/ -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -# Local History for Visual Studio Code -.history/ - -# Windows Installer files from build outputs -*.cab -*.msi -*.msix -*.msm -*.msp - -# JetBrains Rider -*.sln.iml - -# Translations -*.mo - -# macOS -.DS_Store \ No newline at end of file +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +.claude +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..b448734b --- /dev/null +++ b/.prettierignore @@ -0,0 +1,11 @@ +node_modules +dist +dist-ssr +src-tauri +src/components/ui +package-lock.json +.github +.idea +resources +README.md +build-aux diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..81b81d20 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,3 @@ +{ + "bracketSpacing": false +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index feb64de7..a64e7061 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,9 +2,14 @@ First off, thanks for taking the time to contribute! ❤️ -All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉 - -> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: +All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways +to help and details about how this project handles them. Please make sure to read the relevant section before making +your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The +community looks forward to your contributions. 🎉 + +> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support +> the project and show your appreciation, which we would also be very happy about: +> > - Star the project > - Post about it > - Reference this project in your project's readme @@ -25,9 +30,12 @@ All types of contributions are encouraged and valued. See the [Table of Contents ## I Have a Question -Before you ask a question, it is best to search for existing [Discussions](https://github.com/NickvisionApps/Application/discussions) and [Issues](https://github.com/NickvisionApps/Application/issues) that might help you. +Before you ask a question, it is best to search for +existing [Discussions](https://github.com/NickvisionApps/Application/discussions) +and [Issues](https://github.com/NickvisionApps/Application/issues) that might help you. -In case you have found a suitable existing issue/discussion and still need clarification, you can write your question in said post. It is also advisable to search the internet for answers first to common error messages. +In case you have found a suitable existing issue/discussion and still need clarification, you can write your question in +said post. It is also advisable to search the internet for answers first to common error messages. If you then still feel the need to ask a question and need clarification, we recommend the following: @@ -40,54 +48,77 @@ We will then take care of the question as soon as possible and convert it to a p ## I Want To Contribute ### Legal Notice -When contributing to this project, you must agree that you have authored 100% of the content and/or that you have the necessary rights to the content and that the content you contribute may be provided under the project [license](LICENSE). + +When contributing to this project, you must agree that you have authored 100% of the content and/or that you have the +necessary rights to the content and that the content you contribute may be provided under the +project [license](LICENSE). ### Reporting Bugs #### Before Submitting a Bug Report -A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask that you investigate carefully, collect necessary information and describe the issue in detail in your report. Please complete the following steps in advanced to help us fix any potential bug as fast as possible: +A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask that you +investigate carefully, collect necessary information and describe the issue in detail in your report. Please complete +the following steps in advanced to help us fix any potential bug as fast as possible: - Make sure that you are using the latest released stable version. -- Determine if your bug is really a bug and not an error on your side. If you are looking for support, you might want to check [this section](#i-have-a-question). -- See if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in both the [Discussions](https://github.com/NickvisionApps/Application/discussions) and [Issues](https://github.com/NickvisionApps/Application/issues) sections. +- Determine if your bug is really a bug and not an error on your side. If you are looking for support, you might want to + check [this section](#i-have-a-question). +- See if other users have experienced (and potentially already solved) the same issue you are having, check if there is + not already a bug report existing for your bug or error in both + the [Discussions](https://github.com/NickvisionApps/Application/discussions) + and [Issues](https://github.com/NickvisionApps/Application/issues) sections. - Collect information about the bug: - Debug information provided by the application - - GNOME: From the main hamburger menu, open About Application → Troubleshooting → Debugging Information and copy the information to the clipboard to paste in your issue. - - WinUI: From the main Help menu, open About Application --> Debugging and copy the information to the clipboard to paste in your issue. + - From the user menu at the bottom of the sidebar, open Help → Debugging Information and copy the information to + the clipboard to paste in your issue. - Stack trace (Traceback) - Including any error messages thrown by the application - You may need to start the application via the terminal/console to receive an error message for a crash. - OS, Platform and Version (Distro, Kernel Version, x64/ARM64, etc...) - Your input and the output to the application - - i.e. Steps you took to produce the crash and/or attach any files you may have opened within the app that caused a crash + - i.e. Steps you took to produce the crash and/or attach any files you may have opened within the app that + caused a crash - Can you reliably reproduce the issue? And can you also reproduce it with older versions? #### How Do I Submit a Good Bug Report? -You must never report security related issues, vulnerabilities and bugs (including sensitive information) to the issue tracker nor elsewhere in public. Instead, sensitive issues must be reported and handled via email to . +You must never report security related issues, vulnerabilities and bugs (including sensitive information) to the issue +tracker nor elsewhere in public. Instead, sensitive issues must be reported and handled via email +to . We use GitHub issues to track bugs and errors. If you run into an issue with the project: -- Open a [new Issue](https://github.com/NickvisionApps/Application/issues/new) and explain the behavior you are experiencing and what you expect to happen. -- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own system. For good bug reports you should isolate the problem and create a reduced test case. +- Open a [new Issue](https://github.com/NickvisionApps/Application/issues/new) and explain the behavior you are + experiencing and what you expect to happen. +- Please provide as much context as possible and describe the _reproduction steps_ that someone else can follow to + recreate the issue on their own system. For good bug reports you should isolate the problem and create a reduced test + case. - Provide the information you collected in the previous section. Once it has been opened: - The project team will label the issue accordingly. -- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps. - - Bugs that are not able to be reproduced will not be addressed until they are reproduced. Therefore, it is important to include steps to speed up the fixing process. +- A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no + obvious way to reproduce the issue, the team will ask you for those steps. + - Bugs that are not able to be reproduced will not be addressed until they are reproduced. Therefore, it is + important to include steps to speed up the fixing process. ### Suggesting Enhancements -This section guides you through submitting an enhancement suggestion for Nickvision Application, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community in understanding your suggestion and finding related suggestions. +This section guides you through submitting an enhancement suggestion for Nickvision Application, **including completely +new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and +the community in understanding your suggestion and finding related suggestions. #### Before Submitting an Enhancement - Make sure that you are using the latest released version. -- Perform a search through [Discussions](https://github.com/NickvisionApps/Application/discussions) and [Issues](https://github.com/NickvisionApps/Application/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. -- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. +- Perform a search through [Discussions](https://github.com/NickvisionApps/Application/discussions) + and [Issues](https://github.com/NickvisionApps/Application/issues) to see if the enhancement has already been + suggested. If it has, add a comment to the existing issue instead of opening a new one. +- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to + convince the project's developers of the merits of this feature. Keep in mind that we want features that will be + useful to the majority of our users and not just a small subset. #### How Do I Submit a Good Enhancement Suggestion? @@ -95,13 +126,18 @@ Enhancement suggestions are tracked as [GitHub issues](https://github.com/Nickvi - Use a **clear and descriptive title** for the issue to identify the suggestion. - Provide a **step-by-step description of the suggested enhancement** in as many details as possible. - - For enhancements to existing functionality, **describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you. - - For completely new features, **describe what you would like to see from this new feature** in terms of **both functionality and design**. Providing mockups, even if in sketch format, greatly help the team envision what you would like to see. -- **Explain why this enhancement would be useful** to most Application users. You may also want to point out similar projects of other platforms and their solutions to serve as inspiration. + - For enhancements to existing functionality, **describe the current behavior** and **explain which behavior you + expected to see instead** and why. At this point you can also tell which alternatives do not work for you. + - For completely new features, **describe what you would like to see from this new feature** in terms of **both + functionality and design**. Providing mockups, even if in sketch format, greatly help the team envision what you + would like to see. +- **Explain why this enhancement would be useful** to most Application users. You may also want to point out similar + projects of other platforms and their solutions to serve as inspiration. ### Providing Translations -Everyone is welcome to translate this app into their native or known languages, so that the application is accessible to everyone. +Everyone is welcome to translate this app into their native or known languages, so that the application is accessible to +everyone. ##### Via Weblate @@ -111,15 +147,21 @@ Application is available to translate on [Weblate](https://hosted.weblate.org/en To start translating the app, fork the repository and clone it locally. -Application uses [gettext](https://www.gnu.org/software/gettext/manual/gettext.html#PO-Files) for translations. In the `resources/po` folder you will find files that can be edited in your favourite `*.po` files editor (or with any plain text editor). +Application uses [gettext](https://www.gnu.org/software/gettext/manual/gettext.html#PO-Files) for translations. In the +`resources/po` folder you will find files that can be edited in your favourite `*.po` files editor (or with any plain +text editor). -If you want to create a new translation, copy the `application.pot` file and rename said copy as `.po`, where `` is the language code for your translation. Usually the code is two letters, but it can also be a specific locale code to differentiate between versions of the same language (for example, `pt` and `pt_BR`). +If you want to create a new translation, copy the `application.pot` file and rename said copy as `.po`, where +`` is the language code for your translation. Usually the code is two letters, but it can also be a specific +locale code to differentiate between versions of the same language (for example, `pt` and `pt_BR`). **Also, add the language code to `LINGUAS` file** (keeping this file in alphabetical order). Edit your new translation file with correct translations for the English messages. -To check your translation file, make sure your system is in the locale of the language you are translating and [locally build and run the app](README#building-manually). If all steps were carried out successfully, you should see your translation in action! +To check your translation file, make sure your system is in the locale of the language you are translating +and [locally build and run the app](README.md#building) using `npm run tauri dev`. If all steps were carried out +successfully, you should see your translation in action! Once all changes to your translated file are made, commit these changes and create a pull request to the project. @@ -127,53 +169,50 @@ Once all changes to your translated file are made, commit these changes and crea #### Structure -Application is built using .NET 10 and platform-native user interface libraries. With these technologies, Application is built for the Windows and Linux operating systems. +Application is built using [Tauri](https://tauri.app), pairing a Rust backend with a React/TypeScript frontend. With +this stack, Application is built for the Windows, macOS, and Linux operating systems from a single shared codebase. -The project is split up into the following sub-projects: - - [Nickvision.Application.Shared](#Nickvision.Application.Shared) - - [Nickvision.Application.GNOME](#Nickvision.Application.GNOME) - - [Nickvision.Application.WinUI](#Nickvision.Application.WinUI) +The project is split up into the following top-level folders: -The whole project utilizes the [MVC](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) pattern for separating data models, business logic, and UI views. +- [src-tauri](#src-tauri) +- [src](#src) -##### Nickvision.Application.Shared +##### src-tauri -This project contains all of the code used by all platforms of the app: -- `Controllers` => The objects used by UI views to receive and manipulate data in the application. -- `Events` => Arguments that are used by events throughout the application. -- `Models` => The data driven objects of the application (i.e. Configuration, Database, etc...). -- `Services` => The business logic for modifying models and data throughout the application. +This folder contains the Rust backend of the app: -##### Nickvision.Application.GNOME +- `src/commands` => Thin [Tauri command](https://tauri.app/develop/calling-rust/) handlers exposed to the frontend over + IPC. +- `src/controller.rs`, `config.rs`, `folder.rs`, `product`, `translation.rs` => The business logic and data models of + the application. +- `capabilities` => Tauri permission manifests scoping what the frontend is allowed to call. -This project contains all of the code used for the GNOME platform version of the app: -- `Blueprint` => UI design files written in [Blueprint markup language](https://jwestman.pages.gitlab.gnome.org/blueprint-compiler/). -- `Controls` => Generic controls for the app. - - These UI objects are separate from views in that they should not be backed by a controller and should be easily ported to any other app. -- `Resources` => Extra icons and other files specific for the GNOME platform version of the app. -- `Views` => The views (pages, windows, dialogs, etc...) of the app. +##### src -##### Nickvision.Application.WinUI +This folder contains the React/TypeScript frontend of the app: -This project contains all of the code used for the WinUI platform version of the app: -- `Assets` => Extra icons and other files specific for the WinUI platform version of the app. -- `Controls` => Generic controls for the app. - - These UI objects are separate from views in that they should not be backed by a controller and should be easily ported to any other app. -- `Views` => The views (pages, windows, dialogs, etc...) of the app. +- `components` => The UI of the app, including `dialogs` (modal dialogs), `layout` (layout primitives), `pages` + (top-level views), and `ui` (generated [shadcn/ui](https://ui.shadcn.com/) primitives, which should not be + hand-edited). +- `hooks` => Reusable React hooks. +- `lib` => React context providers that expose app state and Tauri commands to components (configuration, translation, + dialogs, navigation, etc...). ## Styleguides -Application uses the following naming conventions: -- `CamelCase` for namespaces, classes, file names, functions, properties -- `pascalCase` for local variables -- `_` prefix appended to class member variables -- `s_` prefix appended to global static variables +Application uses: -Application uses the standard Microsoft C# style code conventions. +- [rustfmt](https://github.com/rust-lang/rustfmt) conventions for Rust code (`src-tauri`) +- [ESLint](https://eslint.org/) (`npm run lint`) and [Prettier](https://prettier.io/) (`npm run format`) for + TypeScript/React code (`src`) + +Please run `npm run lint` and `npm run format` before submitting a pull request. Generated code (`src/components/ui`) is +excluded from linting/formatting and should not be manually restyled. ## Join The Project Team Join our room ## Attribution + This guide was based on a template by [contributing-gen](https://github.com/bttger/contributing-gen). diff --git a/Nickvision.Application.GNOME/Blueprints/MainWindow.blp b/Nickvision.Application.GNOME/Blueprints/MainWindow.blp deleted file mode 100644 index 6b385fa9..00000000 --- a/Nickvision.Application.GNOME/Blueprints/MainWindow.blp +++ /dev/null @@ -1,82 +0,0 @@ -using Gtk 4.0; -using Adw 1; - -menu mainMenu { - item(_("Preferences"), "win.preferences") - item(_("Keyboard Shortcuts"), "win.keyboardShortcuts") - item(_("About Application"), "win.about") -} - -Adw.ApplicationWindow root { - width-request: 360; - height-request: 200; - default-width: 800; - default-height: 600; - - Adw.ToolbarView toolbarView { - [top] - Adw.HeaderBar headerBar { - title-widget: Adw.WindowTitle windowTitle {}; - - [start] - Gtk.Button btnOpenFolder { - tooltip-text: _("Open Folder (Ctrl+O)"); - visible: false; - action-name: "win.openFolder"; - - Adw.ButtonContent { - label: _("Open"); - icon-name: "folder-open-symbolic"; - } - } - - [start] - Gtk.Button btnCloseFolder { - icon-name: "window-close-symbolic"; - tooltip-text: _("Close Folder (Ctrl+W)"); - action-name: "win.closeFolder"; - visible: false; - } - - [end] - Gtk.MenuButton { - direction: none; - menu-model: mainMenu; - tooltip-text: _("Main Menu"); - primary: true; - } - } - - content: Adw.ToastOverlay toastOverlay { - hexpand: true; - vexpand: true; - - Adw.ViewStack viewStack { - Adw.ViewStackPage { - name: "NoFolder"; - child: Adw.StatusPage pageGreeting { - icon-name: "org.nickvision.application"; - description: _("Open a folder (or drag one into the app) to get started"); - child: Gtk.Button { - label: _("Open"); - halign: center; - action-name: "win.openFolder"; - styles ["pill", "suggested-action"] - }; - - styles ["icon-dropshadow"] - }; - } - - Adw.ViewStackPage { - name: "Folder"; - child: Adw.StatusPage pageFiles { - icon-name: "folder-documents-symbolic"; - - styles ["compact"] - }; - } - } - }; - } -} \ No newline at end of file diff --git a/Nickvision.Application.GNOME/Blueprints/PreferencesDialog.blp b/Nickvision.Application.GNOME/Blueprints/PreferencesDialog.blp deleted file mode 100644 index 1bf3730c..00000000 --- a/Nickvision.Application.GNOME/Blueprints/PreferencesDialog.blp +++ /dev/null @@ -1,34 +0,0 @@ -using Gtk 4.0; -using Adw 1; - -Adw.PreferencesDialog root { - content-width: 600; - content-height: 600; - search-enabled: true; - title: _("Preferences"); - - Adw.PreferencesPage { - Adw.PreferencesGroup { - title: _("User Interface"); - - Adw.ComboRow themeRow { - title: _("Theme"); - - [prefix] - Gtk.Image { - icon-name: "dark-mode-symbolic"; - } - } - - Adw.ComboRow languageRow { - title: _("Translation Language"); - subtitle: _("An application restart is required for a change to take effect"); - - [prefix] - Gtk.Image { - icon-name: "translate-symbolic"; - } - } - } - } -} \ No newline at end of file diff --git a/Nickvision.Application.GNOME/Blueprints/ShortcutsDialog.blp b/Nickvision.Application.GNOME/Blueprints/ShortcutsDialog.blp deleted file mode 100644 index e454176c..00000000 --- a/Nickvision.Application.GNOME/Blueprints/ShortcutsDialog.blp +++ /dev/null @@ -1,42 +0,0 @@ -using Gtk 4.0; -using Adw 1; - -Adw.ShortcutsDialog root { - Adw.ShortcutsSection { - title: C_("Shortcut", "Application"); - - Adw.ShortcutsItem { - title: _("Preferences"); - accelerator: "comma"; - } - - Adw.ShortcutsItem { - title: _("Keyboard Shortcuts"); - accelerator: "question"; - } - - Adw.ShortcutsItem { - title: _("About Application"); - accelerator: "F1"; - } - - Adw.ShortcutsItem { - title: _("Quit"); - accelerator: "Q"; - } - } - - Adw.ShortcutsSection { - title: _("Folder"); - - Adw.ShortcutsItem { - title: _("Open Folder"); - accelerator: "O"; - } - - Adw.ShortcutsItem { - title: _("Close Folder"); - accelerator: "W"; - } - } -} diff --git a/Nickvision.Application.GNOME/Helpers/IServiceCollectionExtensions.cs b/Nickvision.Application.GNOME/Helpers/IServiceCollectionExtensions.cs deleted file mode 100644 index 78907b32..00000000 --- a/Nickvision.Application.GNOME/Helpers/IServiceCollectionExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Nickvision.Application.GNOME.Views; - -namespace Nickvision.Application.GNOME.Helpers; - -public static class IServiceCollectionExtensions -{ - extension(IServiceCollection collection) - { - public IServiceCollection AddControls() - { - collection.AddTransient(); - return collection; - } - } -} \ No newline at end of file diff --git a/Nickvision.Application.GNOME/Nickvision.Application.GNOME.csproj b/Nickvision.Application.GNOME/Nickvision.Application.GNOME.csproj deleted file mode 100644 index 3a3f86f8..00000000 --- a/Nickvision.Application.GNOME/Nickvision.Application.GNOME.csproj +++ /dev/null @@ -1,64 +0,0 @@ - - - - net10.0-windows10.0.19041.0 - net10.0 - latest - disable - enable - Exe - AnyCPU;ARM64;x64 - 2026.4.0 - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @(AllBlueprintFiles->'"%(FullPath)"', ' ') - - - - - - - - - - - - - @(AllBlueprintFiles->'"%(FullPath)"', ' ') - - - - - - - - \ No newline at end of file diff --git a/Nickvision.Application.GNOME/Program.cs b/Nickvision.Application.GNOME/Program.cs deleted file mode 100644 index ec135166..00000000 --- a/Nickvision.Application.GNOME/Program.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.Extensions.Hosting; -using Nickvision.Application.GNOME.Helpers; -using Nickvision.Application.GNOME.Views; -using Nickvision.Application.Shared.Helpers; -using Nickvision.Desktop.GNOME.Helpers; -using System.Threading.Tasks; - -namespace Nickvision.Application.GNOME; - -public class Program -{ - public static async Task Main(string[] args) - { - var newArgs = new string[args.Length + 1]; - newArgs[0] = "org.nickvision.application"; - args.CopyTo(newArgs, 1); - var builder = Host.CreateApplicationBuilder(args); - builder.ConfigureApplication(newArgs); - builder.ConfigureAdw(); - builder.Services.AddControls(); - var app = builder.Build(); - await app.RunAsync(); - } -} \ No newline at end of file diff --git a/Nickvision.Application.GNOME/Resources/dark-mode-symbolic.svg b/Nickvision.Application.GNOME/Resources/dark-mode-symbolic.svg deleted file mode 100644 index 94eee23e..00000000 --- a/Nickvision.Application.GNOME/Resources/dark-mode-symbolic.svg +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/Nickvision.Application.GNOME/Resources/org.nickvision.application.gresource.xml b/Nickvision.Application.GNOME/Resources/org.nickvision.application.gresource.xml deleted file mode 100644 index efa03419..00000000 --- a/Nickvision.Application.GNOME/Resources/org.nickvision.application.gresource.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - ../../resources/org.nickvision.application.svg - ../../resources/org.nickvision.application-devel.svg - - - ../../resources/org.nickvision.application-symbolic.svg - - - dark-mode-symbolic.svg - translate-symbolic.svg - - diff --git a/Nickvision.Application.GNOME/Resources/translate-symbolic.svg b/Nickvision.Application.GNOME/Resources/translate-symbolic.svg deleted file mode 100644 index 33554eda..00000000 --- a/Nickvision.Application.GNOME/Resources/translate-symbolic.svg +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/Nickvision.Application.GNOME/Views/MainWindow.cs b/Nickvision.Application.GNOME/Views/MainWindow.cs deleted file mode 100644 index b22810b3..00000000 --- a/Nickvision.Application.GNOME/Views/MainWindow.cs +++ /dev/null @@ -1,269 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Nickvision.Application.Shared.Controllers; -using Nickvision.Application.Shared.Events; -using Nickvision.Application.Shared.Models; -using Nickvision.Application.Shared.Services; -using Nickvision.Desktop.Application; -using Nickvision.Desktop.Globalization; -using Nickvision.Desktop.GNOME.Controls; -using Nickvision.Desktop.GNOME.Helpers; -using Nickvision.Desktop.Notifications; -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Linq; - -namespace Nickvision.Application.GNOME.Views; - -public class MainWindow : Adw.ApplicationWindow -{ - private readonly IServiceProvider _serviceProvider; - private readonly Adw.Application _application; - private readonly MainWindowController _controller; - private readonly AppInfo _appInfo; - private readonly ITranslationService _translationService; - private readonly Gtk.Builder _builder; - private bool _shown; - - [Gtk.Connect("windowTitle")] - private Adw.WindowTitle? _windowTitle; - [Gtk.Connect("btnOpenFolder")] - private Gtk.Button? _btnOpenFolder; - [Gtk.Connect("btnCloseFolder")] - private Gtk.Button? _btnCloseFolder; - [Gtk.Connect("toastOverlay")] - private Adw.ToastOverlay? _toastOverlay; - [Gtk.Connect("viewStack")] - private Adw.ViewStack? _viewStack; - [Gtk.Connect("pageGreeting")] - private Adw.StatusPage? _pageGreeting; - [Gtk.Connect("pageFiles")] - private Adw.StatusPage? _pageFiles; - - public MainWindow(IServiceProvider serviceProvider, Adw.Application application, MainWindowController controller, AppInfo appInfo, IEventsService eventsService, ITranslationService translationService, IGtkBuilderFactory builderFactory) : this(serviceProvider, application, controller, appInfo, eventsService, translationService, builderFactory.Create("MainWindow")) - { - - } - - [DynamicDependency(DynamicallyAccessedMemberTypes.NonPublicFields, typeof(MainWindow))] - private MainWindow(IServiceProvider serviceProvider, Adw.Application application, MainWindowController controller, AppInfo appInfo, IEventsService eventsService, ITranslationService translationService, Gtk.Builder builder) : base(new Adw.Internal.ApplicationWindowHandle(builder.GetPointer("root"), false)) - { - _serviceProvider = serviceProvider; - _application = application; - _controller = controller; - _appInfo = appInfo; - _translationService = translationService; - _builder = builder; - _shown = false; - _builder.Connect(this); - // Window - Adw.StyleManager.GetDefault().ColorScheme = _controller.Theme switch - { - Theme.Light => Adw.ColorScheme.ForceLight, - Theme.Dark => Adw.ColorScheme.ForceDark, - _ => Adw.ColorScheme.Default - }; - Title = _appInfo.ShortName; - IconName = _appInfo.Id; - if (_appInfo.Version!.IsPreview) - { - AddCssClass("devel"); - } - _windowTitle!.Title = _appInfo.ShortName; - _pageGreeting!.Title = _controller.Greeting; - // Events - OnShow += Window_OnShow; - OnCloseRequest += Window_OnCloseRequest; - eventsService.AppNotificationSent += (sender, e) => GLib.Functions.IdleAdd(0, () => - { - App_AppNotificationSent(sender, e); - return false; - }); - eventsService.FolderChanged += App_FolderChanged; - // Drop target - var dropTarget = Gtk.DropTarget.New(Gio.FileHelper.GetGType(), Gdk.DragAction.Copy); - dropTarget.OnDrop += Window_OnDrop; - AddController(dropTarget); - // Quit action - var actQuit = Gio.SimpleAction.New("quit", null); - actQuit.OnActivate += Quit; - AddAction(actQuit); - _application.SetAccelsForAction("win.quit", ["q"]); - // Open in files action - var actOpenInFiles = Gio.SimpleAction.New("openInFiles", null); - actOpenInFiles.OnActivate += OpenInFiles; - AddAction(actOpenInFiles); - // Open folder action - var actOpenFolder = Gio.SimpleAction.New("openFolder", null); - actOpenFolder.OnActivate += OpenFolder; - AddAction(actOpenFolder); - _application.SetAccelsForAction("win.openFolder", ["o"]); - // Close folder action - var actCloseFolder = Gio.SimpleAction.New("closeFolder", null); - actCloseFolder.OnActivate += CloseFolder; - AddAction(actCloseFolder); - _application.SetAccelsForAction("win.closeFolder", ["w"]); - // Preferences action - var actPreferences = Gio.SimpleAction.New("preferences", null); - actPreferences.OnActivate += Preferences; - AddAction(actPreferences); - _application.SetAccelsForAction("win.preferences", ["period"]); - // Keyboard shortcuts action - var actKeyboardShortcuts = Gio.SimpleAction.New("keyboardShortcuts", null); - actKeyboardShortcuts.OnActivate += KeyboardShortcuts; - AddAction(actKeyboardShortcuts); - _application.SetAccelsForAction("win.keyboardShortcuts", ["question"]); - // About action - var actAbout = Gio.SimpleAction.New("about", null); - actAbout.OnActivate += About; - AddAction(actAbout); - _application.SetAccelsForAction("win.about", ["F1"]); - } - - public new void Present() - { - base.Present(); - this.WindowGeometry = _controller.WindowGeometry; - } - - public async void Window_OnShow(Gtk.Widget sender, EventArgs e) - { - if (_shown) - { - return; - } - await _controller.CheckForUpdatesAsync(false); - _shown = true; - } - - private bool Window_OnCloseRequest(Gtk.Window sender, EventArgs e) - { - if (!_controller.CanShutdown) - { - return true; - } - GetDefaultSize(out int width, out int height); - _controller.WindowGeometry = this.WindowGeometry; - Destroy(); - _serviceProvider.GetRequiredService().StopApplication(); - return false; - } - - private bool Window_OnDrop(Gtk.DropTarget sender, Gtk.DropTarget.DropSignalArgs e) - { - var file = new Gio.FileHelper(e.Value.GetObject()!.Handle); - var path = file.GetPath(); - if (string.IsNullOrEmpty(path)) - { - return false; - } - _controller.OpenFolder(path); - return true; - } - - private void App_AppNotificationSent(object? sender, AppNotificationSentEventArgs e) - { - if (e.Notification is ShellNotification shellNotification) - { - var notification = Gio.Notification.New(shellNotification.Title); - notification.SetBody(shellNotification.Message); - if (shellNotification.Action == "open" && !Directory.Exists(shellNotification.ActionParam)) - { - notification.AddButton(_translationService._("Open in Files"), "win.openInFiles"); - } - _application.SendNotification(null, notification); - } - var toast = Adw.Toast.New(e.Notification.Message); - if (e.Notification.Action == "close") - { - toast.ButtonLabel = _translationService._("Close"); - toast.OnButtonClicked += (_, _) => _controller.CloseFolder(); - } - else if (e.Notification.Action == "update") - { - toast.ButtonLabel = _translationService._("View"); - toast.OnButtonClicked += async (_, _) => - { - var launcher = Gtk.UriLauncher.New($"{_appInfo.SourceRepository}/releases/latest"); - await launcher.LaunchAsync(this); - }; - } - _toastOverlay!.AddToast(toast); - } - - private void App_FolderChanged(object? sender, FolderChangedEventArgs e) - { - _windowTitle!.Subtitle = e.IsOpen ? e.Path : string.Empty; - _btnOpenFolder!.Visible = e.IsOpen; - _btnCloseFolder!.Visible = e.IsOpen; - _viewStack!.VisibleChildName = e.IsOpen ? "Folder" : "NoFolder"; - _pageFiles!.Description = _translationService._n("There is {0} file in the folder.", "There are {0} files in the folder", e.Files.Count, e.Files.Count); - } - - private void Quit(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs e) => Window_OnCloseRequest(this, new EventArgs()); - - private async void OpenInFiles(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs e) - { - if (!Directory.Exists(_controller.CurrentFolder)) - { - return; - } - var launcher = Gtk.FileLauncher.New(Gio.FileHelper.NewForPath(_controller.CurrentFolder)); - await launcher.LaunchAsync(this); - } - - private async void OpenFolder(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs e) - { - var folderDialog = Gtk.FileDialog.New(); - folderDialog.Title = _translationService._("Open Folder"); - try - { - var file = await folderDialog.SelectFolderAsync(this); - if (file is not null) - { - _controller.OpenFolder(file.GetPath()!); - } - } - catch { } - } - - private void CloseFolder(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs e) => _controller.CloseFolder(); - - private void Preferences(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs e) => _serviceProvider.GetRequiredService().Present(this); - - private void KeyboardShortcuts(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs e) => _serviceProvider.GetRequiredService().Present(this); - - private void About(Gio.SimpleAction sender, Gio.SimpleAction.ActivateSignalArgs e) - { - var extraInfo = string.Empty; - extraInfo += $"GTK {Gtk.Functions.GetMajorVersion()}.{Gtk.Functions.GetMinorVersion()}.{Gtk.Functions.GetMicroVersion()}\n"; - extraInfo += $"libadwaita {Adw.Functions.GetMajorVersion()}.{Adw.Functions.GetMinorVersion()}.{Adw.Functions.GetMicroVersion()}"; - var dialog = Adw.AboutDialog.New(); - dialog.ApplicationName = _appInfo.ShortName; - dialog.ApplicationIcon = _appInfo.Version!.IsPreview ? $"{_appInfo.Id}-devel" : _appInfo.Id; - dialog.DeveloperName = "Nickvision"; - dialog.Version = _appInfo.Version.ToString(); - dialog.ReleaseNotes = _appInfo.HtmlChangelog; - dialog.DebugInfo = _controller.GetDebugInformation(extraInfo); - dialog.Comments = _appInfo.Description; - dialog.LicenseType = Gtk.License.MitX11; - dialog.Copyright = "© Nickvision 2021-2026"; - dialog.Website = "https://nickvision.org"; - dialog.IssueUrl = _appInfo.IssueTracker!.ToString(); - dialog.SupportUrl = _appInfo.DiscussionsForum!.ToString(); - dialog.AddLink(_translationService._("GitHub Repo"), _appInfo.SourceRepository!.ToString()); - foreach (var pair in _appInfo.ExtraLinks) - { - dialog.AddLink(pair.Key, pair.Value.ToString()); - } - dialog.Developers = _appInfo.Developers.Select(x => $"{x.Key} {x.Value}").ToArray(); - dialog.Designers = _appInfo.Designers.Select(x => $"{x.Key} {x.Value}").ToArray(); - dialog.Artists = _appInfo.Artists.Select(x => $"{x.Key} {x.Value}").ToArray(); - if (!string.IsNullOrEmpty(_appInfo.TranslationCredits) && _appInfo.TranslationCredits != "translation-credits") - { - dialog.TranslatorCredits = _appInfo.TranslationCredits; - } - dialog.Present(this); - } -} diff --git a/Nickvision.Application.GNOME/Views/PreferencesDialog.cs b/Nickvision.Application.GNOME/Views/PreferencesDialog.cs deleted file mode 100644 index 24d912b6..00000000 --- a/Nickvision.Application.GNOME/Views/PreferencesDialog.cs +++ /dev/null @@ -1,57 +0,0 @@ -using Nickvision.Application.Shared.Controllers; -using Nickvision.Application.Shared.Models; -using Nickvision.Desktop.GNOME.Helpers; -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Nickvision.Application.GNOME.Views; - -public class PreferencesDialog : Adw.PreferencesDialog -{ - private readonly PreferencesViewController _controller; - private readonly Gtk.Builder _builder; - - [Gtk.Connect("themeRow")] - private Adw.ComboRow? _themeRow; - [Gtk.Connect("languageRow")] - private Adw.ComboRow? _languageRow; - - public PreferencesDialog(PreferencesViewController controller, IGtkBuilderFactory builderFactory) : this(controller, builderFactory.Create("PreferencesDialog")) - { - - } - - [DynamicDependency(DynamicallyAccessedMemberTypes.NonPublicFields, typeof(PreferencesDialog))] - private PreferencesDialog(PreferencesViewController controller, Gtk.Builder builder) : base(new Adw.Internal.PreferencesDialogHandle(builder.GetPointer("root"), false)) - { - _controller = controller; - _builder = builder; - _builder.Connect(this); - // Load - _themeRow!.SetModel(_controller.Themes); - _languageRow!.SetModel(_controller.AvailableTranslationLanguages); - // Events - OnClosed += Dialog_OnClosed; - _themeRow!.OnNotify += ThemeRow_OnNotify; - } - - private async void Dialog_OnClosed(Adw.Dialog sender, EventArgs args) - { - _controller.TranslationLanguage = _controller.AvailableTranslationLanguages[(int)_languageRow!.Selected]; - await _controller.SaveConfigurationAsync(); - } - - private void ThemeRow_OnNotify(GObject.Object sender, NotifySignalArgs args) - { - if (args.Pspec.GetName() == "selected-item") - { - _controller.Theme = _controller.Themes[(int)_themeRow!.Selected]; - Adw.StyleManager.GetDefault().ColorScheme = _controller.Themes[(int)_themeRow!.Selected].Value switch - { - Theme.Light => Adw.ColorScheme.ForceLight, - Theme.Dark => Adw.ColorScheme.ForceDark, - _ => Adw.ColorScheme.Default - }; - } - } -} diff --git a/Nickvision.Application.Shared/Controllers/MainWindowController.cs b/Nickvision.Application.Shared/Controllers/MainWindowController.cs deleted file mode 100644 index a73e2393..00000000 --- a/Nickvision.Application.Shared/Controllers/MainWindowController.cs +++ /dev/null @@ -1,127 +0,0 @@ -using Microsoft.Extensions.Logging; -using Nickvision.Application.Shared.Helpers; -using Nickvision.Application.Shared.Models; -using Nickvision.Application.Shared.Services; -using Nickvision.Desktop.Application; -using Nickvision.Desktop.Globalization; -using Nickvision.Desktop.Network; -using Nickvision.Desktop.Notifications; -using System; -using System.Threading.Tasks; - -namespace Nickvision.Application.Shared.Controllers; - -public class MainWindowController -{ - ILogger _logger; - private readonly AppInfo _appInfo; - private readonly IConfigurationService _configurationService; - private readonly IFolderService _folderService; - private readonly INotificationService _notificationService; - private readonly ITranslationService _translationService; - private readonly IUpdaterService _updaterService; - private AppVersion _latestVersion; - - public MainWindowController(ILogger logger, AppInfo appInfo, IArgumentsService argumentsService, IConfigurationService configurationService, IFolderService folderService, INotificationService notificationService, ITranslationService translationService, IUpdaterService updaterService) - { - _logger = logger; - _appInfo = appInfo; - _configurationService = configurationService; - _folderService = folderService; - _notificationService = notificationService; - _translationService = translationService; - _updaterService = updaterService; - _latestVersion = appInfo.Version!; - _translationService.Language = _configurationService.TranslationLanguage; - _logger.LogInformation($"Received command-line arguments: [{string.Join(", ", argumentsService.Data)}]"); - // Translate strings - _appInfo.ShortName = _translationService._("Application"); - _appInfo.Description = _translationService._("Create new Nickvision applications."); - _appInfo.ExtraLinks.Add(_translationService._("Matrix Chat"), new Uri("https://matrix.to/#/#nickvision:matrix.org")); - _appInfo.Developers.Add(_translationService._("Nicholas Logozzo"), "https://github.com/nlogozzo"); - _appInfo.Developers.Add(_translationService._("Contributors on GitHub ❤️"), "https://github.com/NickvisionApps/Application/graphs/contributors"); - _appInfo.Designers.Add(_translationService._("Nicholas Logozzo"), "https://github.com/nlogozzo"); - _appInfo.Designers.Add(_translationService._("Fyodor Sobolev"), "https://github.com/fsobolev"); - _appInfo.Designers.Add(_translationService._("DaPigGuy"), "https://github.com/DaPigGuy"); - _appInfo.Artists.Add(_translationService._("David Lapshin"), "https://github.com/daudix"); - _appInfo.TranslationCredits = _translationService._("translation-credits"); - } - - public bool CanShutdown => true; - - public string? CurrentFolder => _folderService.Path; - - public string Greeting => DateTime.Now.Hour switch - { - >= 0 and < 6 => _translationService._p("Night", "Good Morning!"), - < 12 => _translationService._p("Morning", "Good Morning!"), - < 18 => _translationService._("Good Afternoon!"), - < 24 => _translationService._("Good Evening!"), - var _ => _translationService._("Good Day!") - }; - - public Theme Theme => _configurationService.Theme; - - public WindowGeometry WindowGeometry - { - get => _configurationService.WindowGeometry; - - set => _configurationService.WindowGeometry = value; - } - - public async Task CheckForUpdatesAsync(bool showNotificationForNoUpdates) - { - _logger.LogInformation("Checking for updates..."); - var stableVersion = await _updaterService.GetLatestStableVersionAsync(); - if (stableVersion is not null) - { - _latestVersion = stableVersion; - } - if (_configurationService.AllowPreviewUpdates) - { - var previewVersion = await _updaterService.GetLatestPreviewVersionAsync(); - if (previewVersion is not null && previewVersion > stableVersion) - { - _latestVersion = previewVersion; - } - } - if (_latestVersion > _appInfo.Version!) - { - if (!OperatingSystem.IsLinux()) - { - _logger.LogInformation($"New application update available: {_latestVersion}"); - _notificationService.Send(new AppNotification(_translationService._("New {0} update available: {1}", _appInfo.ShortName!, _latestVersion.ToString()), NotificationSeverity.Success) - { - Action = "update" - }); - } - } - else - { - _logger.LogInformation("No application update available."); - if (showNotificationForNoUpdates) - { - _notificationService.Send(new AppNotification(_translationService._("No update available"), NotificationSeverity.Warning)); - } - } - } - - public string GetDebugInformation(string extraInformation = "") => Desktop.System.Environment.GetDebugInformation(_appInfo, extraInformation); - - public void OpenFolder(string path) => _folderService.Open(path); - - public void CloseFolder() => _folderService.Close(); - - public async Task WindowsUpdateAsync(IProgress progress) - { - var res = await _updaterService.WindowsApplicationUpdateAsync(_latestVersion, progress); - if (res) - { - _notificationService.Send(new AppNotification(_translationService._("Starting {0} installer...", _appInfo.ShortName!), NotificationSeverity.Success)); - } - else - { - _notificationService.Send(new AppNotification(_translationService._("Unable to download and install the update"), NotificationSeverity.Error)); - } - } -} diff --git a/Nickvision.Application.Shared/Controllers/PreferencesViewController.cs b/Nickvision.Application.Shared/Controllers/PreferencesViewController.cs deleted file mode 100644 index 0ce0b842..00000000 --- a/Nickvision.Application.Shared/Controllers/PreferencesViewController.cs +++ /dev/null @@ -1,92 +0,0 @@ -using Microsoft.Data.Sqlite; -using Nickvision.Application.Shared.Helpers; -using Nickvision.Application.Shared.Models; -using Nickvision.Desktop.Application; -using Nickvision.Desktop.Globalization; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Nickvision.Application.Shared.Controllers; - -public class PreferencesViewController : IDisposable -{ - private readonly IConfigurationService _configurationService; - private readonly ITranslationService _translationService; - private SqliteTransaction? _transaction; - - public IReadOnlyList> AvailableTranslationLanguages { get; } - public IReadOnlyList> Themes { get; } - - public PreferencesViewController(IConfigurationService configurationService, ITranslationService translationService) - { - _configurationService = configurationService; - _translationService = translationService; - _transaction = _configurationService.CreateTransaction(); - AvailableTranslationLanguages = new List>() - { - new SelectionItem(string.Empty, _translationService._("System"), string.IsNullOrEmpty(_configurationService.TranslationLanguage)), - new SelectionItem("C", "en_US", _configurationService.TranslationLanguage == "C") - }; - var languages = _translationService.AvailableLanguages.ToList(); - languages.Sort(); - foreach (var language in languages) - { - (AvailableTranslationLanguages as IList)!.Add(new SelectionItem(language, language, _configurationService.TranslationLanguage == language)); - } - Themes = new List>() - { - new SelectionItem(Models.Theme.Light, _translationService._p("Theme", "Light"), _configurationService.Theme == Models.Theme.Light), - new SelectionItem(Models.Theme.Dark, _translationService._p("Theme", "Dark"), _configurationService.Theme == Models.Theme.Dark), - new SelectionItem(Models.Theme.System, _translationService._p("Theme", "System"), _configurationService.Theme == Models.Theme.System), - }; - } - - ~PreferencesViewController() - { - Dispose(false); - } - - public SelectionItem Theme - { - set => _configurationService.Theme = value.Value; - } - - public SelectionItem TranslationLanguage - { - set => _configurationService.TranslationLanguage = value.Value; - } - - public bool AllowPreviewUpdates - { - get => _configurationService.AllowPreviewUpdates; - - set => _configurationService.AllowPreviewUpdates = value; - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - public async Task SaveConfigurationAsync() - { - if (_transaction is not null) - { - await _transaction.CommitAsync(); - await _transaction.DisposeAsync(); - _transaction = null; - } - } - private void Dispose(bool disposing) - { - if (!disposing) - { - return; - } - _transaction?.Dispose(); - } -} diff --git a/Nickvision.Application.Shared/Events/FolderChangedEventArgs.cs b/Nickvision.Application.Shared/Events/FolderChangedEventArgs.cs deleted file mode 100644 index 4a8f5299..00000000 --- a/Nickvision.Application.Shared/Events/FolderChangedEventArgs.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Nickvision.Application.Shared.Events; - -public class FolderChangedEventArgs : EventArgs -{ - public string? Path { get; init; } - public List Files { get; init; } - - public bool IsOpen => !string.IsNullOrEmpty(Path); - - public FolderChangedEventArgs(string? path, List? files = default) - { - Path = path; - Files = files ?? []; - } -} diff --git a/Nickvision.Application.Shared/Helpers/ApplicationJsonContext.cs b/Nickvision.Application.Shared/Helpers/ApplicationJsonContext.cs deleted file mode 100644 index a191f3c4..00000000 --- a/Nickvision.Application.Shared/Helpers/ApplicationJsonContext.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Nickvision.Desktop.Application; -using System.Text.Json.Serialization; - -namespace Nickvision.Application.Shared.Helpers; - -[JsonSourceGenerationOptions(DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, WriteIndented = true)] -[JsonSerializable(typeof(WindowGeometry))] -public partial class ApplicationJsonContext : JsonSerializerContext -{ - -} diff --git a/Nickvision.Application.Shared/Helpers/HostApplicationBuilderExtensions.cs b/Nickvision.Application.Shared/Helpers/HostApplicationBuilderExtensions.cs deleted file mode 100644 index 975b4fa8..00000000 --- a/Nickvision.Application.Shared/Helpers/HostApplicationBuilderExtensions.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Nickvision.Application.Shared.Controllers; -using Nickvision.Application.Shared.Services; -using Nickvision.Desktop.Application; -using Nickvision.Desktop.Filesystem; -using Nickvision.Desktop.Helpers; -using System; -using System.IO; - -namespace Nickvision.Application.Shared.Helpers; - -public static class HostApplicationBuilderExtensions -{ - extension(IHostApplicationBuilder builder) - { - public IHostApplicationBuilder ConfigureApplication(string[] args) - { - var appInfo = new AppInfo("org.nickvision.application", "Nickvision Application", "Application") - { - Version = new AppVersion("2026.4.0-next"), - Changelog = "- Initial release", - SourceRepository = new Uri("https://github.com/NickvisionApps/Application"), - IssueTracker = new Uri("https://github.com/NickvisionApps/Application/issues/new"), - DiscussionsForum = new Uri("https://github.com/NickvisionApps/Application/discussions"), - IsPortable = OperatingSystem.IsWindows() && args.Contains("--portable") - }; - builder.Properties.Add("AppInfo", appInfo); - builder.Services.AddSingleton(appInfo); - builder.ConfigureNickvision(args, appInfo.IsPortable ? "app.log" : Path.Combine(UserDirectories.LocalData, appInfo.Name, "app.log")); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddSingleton(); - builder.Services.AddTransient(); - builder.Services.AddHostedService(); - return builder; - } - } -} diff --git a/Nickvision.Application.Shared/Helpers/IConfigurationServiceExtensions.cs b/Nickvision.Application.Shared/Helpers/IConfigurationServiceExtensions.cs deleted file mode 100644 index 408c1f67..00000000 --- a/Nickvision.Application.Shared/Helpers/IConfigurationServiceExtensions.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Nickvision.Application.Shared.Models; -using Nickvision.Desktop.Application; - -namespace Nickvision.Application.Shared.Helpers; - -public static class IConfigurationServiceExtensions -{ - extension(IConfigurationService configurationService) - { - public bool AllowPreviewUpdates - { - get => configurationService.Get("AllowPreviewUpdates", false); - - set => configurationService.Set("AllowPreviewUpdates", value); - } - - public Theme Theme - { - get => configurationService.Get("Theme", Theme.System); - - set => configurationService.Set("Theme", value); - } - - public string TranslationLanguage - { - get => configurationService.Get("TranslationLanguage", string.Empty); - - set => configurationService.Set("TranslationLanguage", value); - } - - public WindowGeometry WindowGeometry - { - get => configurationService.Get("WindowGeometry", new WindowGeometry(), ApplicationJsonContext.Default.WindowGeometry); - - set => configurationService.Set("WindowGeometry", value, ApplicationJsonContext.Default.WindowGeometry); - } - } -} diff --git a/Nickvision.Application.Shared/Models/Theme.cs b/Nickvision.Application.Shared/Models/Theme.cs deleted file mode 100644 index a61b33d6..00000000 --- a/Nickvision.Application.Shared/Models/Theme.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Nickvision.Application.Shared.Models; - -public enum Theme -{ - Light, - Dark, - System -} diff --git a/Nickvision.Application.Shared/Nickvision.Application.Shared.csproj b/Nickvision.Application.Shared/Nickvision.Application.Shared.csproj deleted file mode 100644 index f51156f0..00000000 --- a/Nickvision.Application.Shared/Nickvision.Application.Shared.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - net10.0-windows10.0.19041.0 - net10.0 - latest - disable - enable - AnyCPU;ARM64;x64 - 2026.4.0 - true - - - - - - - - \ No newline at end of file diff --git a/Nickvision.Application.Shared/Services/ConfigurationMigrationService.cs b/Nickvision.Application.Shared/Services/ConfigurationMigrationService.cs deleted file mode 100644 index 198e2258..00000000 --- a/Nickvision.Application.Shared/Services/ConfigurationMigrationService.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using Nickvision.Desktop.Application; -using Nickvision.Desktop.Filesystem; -using Nickvision.Desktop.System; -using System.IO; -using System.Threading; -using System.Threading.Tasks; - -namespace Nickvision.Application.Shared.Services; - -public class ConfigurationMigrationService : IHostedService -{ - private readonly ILogger _logger; - private readonly IConfigurationService _configurationService; - private readonly string _directory; - - public ConfigurationMigrationService(ILogger logger, AppInfo appInfo, IConfigurationService configurationService) - { - _logger = logger; - _configurationService = configurationService; - _directory = appInfo.IsPortable ? Environment.ExecutingDirectory : Path.Combine(UserDirectories.Config, appInfo.Name); - } - - public async Task StartAsync(CancellationToken cancellationToken) - { - _logger.LogInformation("Starting configuration migration..."); - var configPath = Path.Combine(_directory, "config.json"); - if (File.Exists(configPath)) - { - _logger.LogInformation($"Migrating configuration file ({configPath})..."); - var res = await _configurationService.ImportFromJsonFileAsync(configPath); - _logger.LogInformation($"Migrated {res} properties from configuration file ({configPath})."); - File.Delete(configPath); - } - _logger.LogInformation("Finished configuration migration."); - } - - public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; -} diff --git a/Nickvision.Application.Shared/Services/EventsService.cs b/Nickvision.Application.Shared/Services/EventsService.cs deleted file mode 100644 index 7bc2ad60..00000000 --- a/Nickvision.Application.Shared/Services/EventsService.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Nickvision.Application.Shared.Events; -using Nickvision.Desktop.Application; -using Nickvision.Desktop.Notifications; -using System; - -namespace Nickvision.Application.Shared.Services; - -public class EventsService : IEventsService -{ - private readonly IConfigurationService _configurationService; - private readonly IFolderService _folderService; - private readonly INotificationService _notificationService; - - public EventsService(IConfigurationService configurationService, IFolderService folderService, INotificationService notificationService) - { - _configurationService = configurationService; - _folderService = folderService; - _notificationService = notificationService; - } - - public event EventHandler? AppNotificationSent - { - add => _notificationService.AppNotificationSent += value; - - remove => _notificationService.AppNotificationSent -= value; - } - - public event EventHandler? ConfigurationSaved - { - add => _configurationService.Saved += value; - - remove => _configurationService.Saved -= value; - } - - public event EventHandler FolderChanged - { - add => _folderService.Changed += value; - - remove => _folderService.Changed -= value; - } -} diff --git a/Nickvision.Application.Shared/Services/FolderService.cs b/Nickvision.Application.Shared/Services/FolderService.cs deleted file mode 100644 index d294bb3f..00000000 --- a/Nickvision.Application.Shared/Services/FolderService.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Microsoft.Extensions.Logging; -using Nickvision.Application.Shared.Events; -using Nickvision.Desktop.Globalization; -using Nickvision.Desktop.Notifications; -using System; -using System.Collections.Generic; -using System.IO; - -namespace Nickvision.Application.Shared.Services; - -public class FolderService : IFolderService -{ - private readonly ILogger _logger; - private readonly INotificationService _notificationService; - private readonly ITranslationService _translationService; - - public List Files { get; init; } - public string? Path { get; private set; } - - public event EventHandler? Changed; - - public FolderService(ILogger logger, INotificationService notificationService, ITranslationService translationService) - { - _logger = logger; - _notificationService = notificationService; - _translationService = translationService; - Files = new List(); - Path = null; - } - - public void Open(string path) - { - _logger.LogDebug($"Opening folder: {path}"); - if (!Directory.Exists(path)) - { - _logger.LogError("Folder does not exist."); - Path = null; - return; - } - Path = path; - Files.Clear(); - foreach (var file in Directory.EnumerateFiles(Path)) - { - Files.Add(file); - } - _logger.LogInformation($"Folder opened with {Files.Count} file(s)."); - _notificationService.Send(new AppNotification(_translationService._("Folder opened: {0}", Path), NotificationSeverity.Success) - { - Action = "close" - }); - _notificationService.Send(new ShellNotification(_translationService._("Folder"), _translationService._("Loaded {0} file(s)", Files.Count), NotificationSeverity.Information) - { - Action = "open", - ActionParam = Path - }); - Changed?.Invoke(this, new FolderChangedEventArgs(Path, Files)); - } - - public void Close() - { - _logger.LogDebug($"Closing folder: {Path}"); - Path = null; - Files.Clear(); - _logger.LogInformation("Folder closed."); - _notificationService.Send(new AppNotification(_translationService._("Folder closed"), NotificationSeverity.Warning)); - Changed?.Invoke(this, new FolderChangedEventArgs(null)); - } -} diff --git a/Nickvision.Application.Shared/Services/IEventsService.cs b/Nickvision.Application.Shared/Services/IEventsService.cs deleted file mode 100644 index 21edb29c..00000000 --- a/Nickvision.Application.Shared/Services/IEventsService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Nickvision.Application.Shared.Events; -using Nickvision.Desktop.Application; -using Nickvision.Desktop.Notifications; -using System; - -namespace Nickvision.Application.Shared.Services; - -public interface IEventsService -{ - event EventHandler? AppNotificationSent; - event EventHandler? ConfigurationSaved; - event EventHandler FolderChanged; -} diff --git a/Nickvision.Application.Shared/Services/IFolderService.cs b/Nickvision.Application.Shared/Services/IFolderService.cs deleted file mode 100644 index c9792d42..00000000 --- a/Nickvision.Application.Shared/Services/IFolderService.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Nickvision.Application.Shared.Events; -using System; -using System.Collections.Generic; - -namespace Nickvision.Application.Shared.Services; - -public interface IFolderService -{ - public List Files { get; } - public string? Path { get; } - - public event EventHandler? Changed; - - public void Open(string path); - - public void Close(); -} diff --git a/Nickvision.Application.WinUI/App.xaml b/Nickvision.Application.WinUI/App.xaml deleted file mode 100644 index 68d378f1..00000000 --- a/Nickvision.Application.WinUI/App.xaml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - diff --git a/Nickvision.Application.WinUI/App.xaml.cs b/Nickvision.Application.WinUI/App.xaml.cs deleted file mode 100644 index ed3dbeec..00000000 --- a/Nickvision.Application.WinUI/App.xaml.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.UI.Xaml; -using Nickvision.Application.WinUI.Views; -using System; - -namespace Nickvision.Application.WinUI; - -public partial class App : Microsoft.UI.Xaml.Application -{ - private readonly IServiceProvider _serviceProvider; - private Window? _window; - - public App(IServiceProvider serviceProvider) - { - InitializeComponent(); - _serviceProvider = serviceProvider; - UnhandledException += (_, e) => - { - _serviceProvider.GetRequiredService>().LogError(e.Exception, $"An unhandled exception occurred: {e.Message}"); - }; - } - - protected override void OnLaunched(LaunchActivatedEventArgs args) - { - if (_window is null) - { - _window = _serviceProvider.GetRequiredService(); - } - _window.Activate(); - } -} diff --git a/Nickvision.Application.WinUI/Assets/org.nickvision.application.ico b/Nickvision.Application.WinUI/Assets/org.nickvision.application.ico deleted file mode 100644 index 79fd698a..00000000 Binary files a/Nickvision.Application.WinUI/Assets/org.nickvision.application.ico and /dev/null differ diff --git a/Nickvision.Application.WinUI/Controls/AboutDialog.xaml b/Nickvision.Application.WinUI/Controls/AboutDialog.xaml deleted file mode 100644 index be320d72..00000000 --- a/Nickvision.Application.WinUI/Controls/AboutDialog.xaml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Nickvision.Application.WinUI/Controls/AboutDialog.xaml.cs b/Nickvision.Application.WinUI/Controls/AboutDialog.xaml.cs deleted file mode 100644 index 25925813..00000000 --- a/Nickvision.Application.WinUI/Controls/AboutDialog.xaml.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using Nickvision.Desktop.Application; -using Nickvision.Desktop.Globalization; -using System.Linq; -using System.Threading.Tasks; -using Windows.ApplicationModel.DataTransfer; - -namespace Nickvision.Application.WinUI.Controls; - -public sealed partial class AboutDialog : ContentDialog -{ - private readonly AppInfo _appInfo; - private readonly ITranslationService _translator; - - public AboutDialog(AppInfo appInfo, ITranslationService translator) - { - InitializeComponent(); - _appInfo = appInfo; - _translator = translator; - DebugInformation = string.Empty; - Title = _translator._("About {0}", appInfo.ShortName!); - CloseButtonText = _translator._("Close"); - DefaultButton = ContentDialogButton.Close; - SelectorGeneral.Text = _translator._("General"); - SelectorChangelog.Text = _translator._("Changelog"); - SelectorDebugging.Text = _translator._("Debugging"); - SelectorCredits.Text = _translator._("Credits"); - LblAppName.Text = appInfo.ShortName; - LblAppDescription.Text = appInfo.Description; - LblAppVersion.Text = appInfo.Version!.ToString(); - LblAppCopyright.Text = "© Nickvision 2021-2026"; - LblChangelog.Text = appInfo.Changelog!; - LblCopyDebugInformation.Text = _translator._("Copy Debug Information"); - if (string.IsNullOrEmpty(_appInfo.TranslationCredits) || _appInfo.TranslationCredits == "translation-credits") - { - LblCredits.Text = _translator._("Developers:\n{0}\n\nDesigners:\n{1}\n\nArtists:\n{2}", _appInfo.Developers.Keys.Aggregate((current, next) => $"{current}\n{next}"), _appInfo.Designers.Keys.Aggregate((current, next) => $"{current}\n{next}"), _appInfo.Artists.Keys.Aggregate((current, next) => $"{current}\n{next}")); - } - else - { - LblCredits.Text = _translator._("Developers:\n{0}\n\nDesigners:\n{1}\n\nArtists:\n{2}\n\nTranslators:\n{3}", _appInfo.Developers.Keys.Aggregate((current, next) => $"{current}\n{next}"), _appInfo.Designers.Keys.Aggregate((current, next) => $"{current}\n{next}"), _appInfo.Artists.Keys.Aggregate((current, next) => $"{current}\n{next}"), _appInfo.TranslationCredits!); - } - } - - public string DebugInformation - { - get => field; - - set - { - field = value; - LblDebugInformation.Text = value; - } - } - - private void Dialog_Loaded(object sender, RoutedEventArgs e) => SelectorGeneral.IsSelected = true; - - private void SelectorBar_SelectionChanged(SelectorBar sender, SelectorBarSelectionChangedEventArgs args) - { - var index = sender.Items.IndexOf(sender.SelectedItem); - ViewStack.SelectedIndex = index == -1 ? 0 : index; - } - - private async void CopyDebugInformation(object sender, RoutedEventArgs args) - { - var package = new DataPackage(); - package.SetText(LblDebugInformation.Text); - Clipboard.SetContent(package); - IconCopyDebugInformation.Glyph = "\uE73E"; - await Task.Delay(2000).ContinueWith(_ => - { - DispatcherQueue.TryEnqueue(() => - { - IconCopyDebugInformation.Glyph = "\uE8C8"; - }); - }); - } -} diff --git a/Nickvision.Application.WinUI/Helpers/IServiceCollectionExtensions.cs b/Nickvision.Application.WinUI/Helpers/IServiceCollectionExtensions.cs deleted file mode 100644 index 3268ae2c..00000000 --- a/Nickvision.Application.WinUI/Helpers/IServiceCollectionExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Nickvision.Application.WinUI.Controls; -using Nickvision.Application.WinUI.Views; - -namespace Nickvision.Application.WinUI.Helpers; - -public static class IServiceCollectionExtensions -{ - extension(IServiceCollection collection) - { - public IServiceCollection AddControls() - { - collection.AddSingleton(); - collection.AddTransient(); - collection.AddSingleton(); - return collection; - } - } -} \ No newline at end of file diff --git a/Nickvision.Application.WinUI/Nickvision.Application.WinUI.csproj b/Nickvision.Application.WinUI/Nickvision.Application.WinUI.csproj deleted file mode 100644 index 7baf5523..00000000 --- a/Nickvision.Application.WinUI/Nickvision.Application.WinUI.csproj +++ /dev/null @@ -1,71 +0,0 @@ - - - - net10.0-windows10.0.19041.0 - 10.0.17763.0 - latest - disable - enable - true - WinExe - Nickvision.Application.WinUI - app.manifest - x86;x64;ARM64 - win-x86;win-x64;win-arm64 - win-$(Platform).pubxml - true - false - true - None - true - DISABLE_XAML_GENERATED_MAIN - Nickvision.Application.WinUI.Program - 2026.4.0 - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - False - True - False - True - - - Assets\org.nickvision.application.ico - - - - - \ No newline at end of file diff --git a/Nickvision.Application.WinUI/Program.cs b/Nickvision.Application.WinUI/Program.cs deleted file mode 100644 index 341e48a9..00000000 --- a/Nickvision.Application.WinUI/Program.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.Extensions.Hosting; -using Nickvision.Application.Shared.Helpers; -using Nickvision.Application.WinUI.Helpers; -using Nickvision.Desktop.WinUI.Helpers; -using System; -using System.Runtime.InteropServices; - -namespace Nickvision.Application.WinUI; - -public static partial class Program -{ - [LibraryImport("Microsoft.ui.xaml.dll", EntryPoint = "XamlCheckProcessRequirements")] - private static partial void XamlCheckProcessRequirements(); - - [STAThread] - private static void Main(string[] args) - { - XamlCheckProcessRequirements(); - var builder = Host.CreateApplicationBuilder(args); - builder.ConfigureApplication(args); - builder.ConfigureWinUI(); - builder.Services.AddControls(); - var app = builder.Build(); - app.Run(); - } -} diff --git a/Nickvision.Application.WinUI/Views/MainWindow.xaml b/Nickvision.Application.WinUI/Views/MainWindow.xaml deleted file mode 100644 index d4c3c86b..00000000 --- a/Nickvision.Application.WinUI/Views/MainWindow.xaml +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + )} + + + ); +} diff --git a/src/components/dialogs/settings-dialog.tsx b/src/components/dialogs/settings-dialog.tsx new file mode 100644 index 00000000..6ebd84b6 --- /dev/null +++ b/src/components/dialogs/settings-dialog.tsx @@ -0,0 +1,301 @@ +import { + Dialog, + DialogContent, + DialogDescription, + DialogTitle, +} from "@/components/ui/dialog.tsx"; +import { + Field, + FieldContent, + FieldGroup, + FieldSet, + FieldTitle, +} from "@/components/ui/field.tsx"; +import {Input} from "@/components/ui/input.tsx"; +import {ScrollArea} from "@/components/ui/scroll-area.tsx"; +import { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select.tsx"; +import { + Sidebar, + SidebarContent, + SidebarGroup, + SidebarGroupContent, + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, + SidebarProvider, +} from "@/components/ui/sidebar.tsx"; +import {Switch} from "@/components/ui/switch.tsx"; +import {useConfiguration} from "@/lib/contexts/configuration-context.ts"; +import {useDialog} from "@/lib/contexts/dialog-context.ts"; +import {useTranslation} from "@/lib/contexts/translation-context.ts"; +import {invoke} from "@tauri-apps/api/core"; +import {CloudDownload, Settings2} from "lucide-react"; +import {useEffect, useState} from "react"; + +const SETTINGS_PAGES = ["general", "updates"] as const; + +type SettingsDialogPage = (typeof SETTINGS_PAGES)[number]; + +export function SettingsDialog() { + const {closeDialog} = useDialog(); + const {configuration, setConfiguration} = useConfiguration(); + const {_g, _p, _f} = useTranslation(); + const [availableLanguages, setAvailableLanguages] = useState([]); + const [page, setPage] = useState("general"); + const [search, setSearch] = useState(""); + + const themeOptions = [ + {value: 0, label: _p("Theme", "Light")}, + {value: 1, label: _p("Theme", "Dark")}, + {value: 2, label: _p("Theme", "System")}, + ]; + const query = search.trim().toLowerCase(); + const isSearching = query.length > 0; + const matchingPages = new Set( + ( + [ + {page: "general", label: _g("Theme")}, + {page: "general", label: _g("Language")}, + {page: "updates", label: _g("Automatically check for updates")}, + {page: "updates", label: _g("Allow preview (beta) updates")}, + ] satisfies {page: SettingsDialogPage; label: string}[] + ) + .filter((field) => field.label.toLowerCase().includes(query)) + .map((field) => field.page), + ); + + useEffect(() => { + async function startup() { + setAvailableLanguages( + await invoke("get_available_translation_languages"), + ); + } + + void startup(); + }, []); + + useEffect(() => { + if (isSearching && !matchingPages.has(page)) { + const nextPage = SETTINGS_PAGES.find((candidate) => + matchingPages.has(candidate), + ); + if (nextPage) { + setPage(nextPage); + } + } + }, [page, isSearching, matchingPages]); + + return ( + { + if (!open) { + closeDialog(); + } + }} + > + + + {_g("Settings")} + + + + + + + + {(!isSearching || matchingPages.has("general")) && ( + + setPage("general")} + > + + {_g("General")} + + + )} + {(!isSearching || matchingPages.has("updates")) && ( + + setPage("updates")} + > + + {_g("Updates")} + + + )} + + + + + +
+
+ {_g("Settings")} + setSearch(event.target.value)} + /> +
+ {page === "general" && + (!isSearching || matchingPages.has("general")) && ( + + +
+ + {(!isSearching || + _g("Theme").toLowerCase().includes(query)) && ( + + + {_g("Theme")} + + + + )} + {(!isSearching || + _g("Language").toLowerCase().includes(query)) && ( + + + {_g("Language")} + + + + )} + +
+
+
+ )} + {page === "updates" && + (!isSearching || matchingPages.has("updates")) && ( + + +
+ + {(!isSearching || + _g("Automatically check for updates") + .toLowerCase() + .includes(query)) && ( + + + + {_g("Automatically check for updates")} + + + { + setConfiguration({ + ...configuration, + automaticallyCheckForUpdates: checked, + }); + }} + /> + + )} + {(!isSearching || + _g("Allow preview (beta) updates") + .toLowerCase() + .includes(query)) && ( + + + + {_g("Allow preview (beta) updates")} + + + { + setConfiguration({ + ...configuration, + allowPreviewUpdates: checked, + }); + }} + /> + + )} + +
+
+
+ )} + {isSearching && !matchingPages.has(page) && ( + +

+ {_f("No results found for “{0}”", [search])} +

+
+ )} +
+
+
+
+ ); +} diff --git a/src/components/dialogs/update-dialog.tsx b/src/components/dialogs/update-dialog.tsx new file mode 100644 index 00000000..d7464345 --- /dev/null +++ b/src/components/dialogs/update-dialog.tsx @@ -0,0 +1,110 @@ +import {VStack} from "@/components/layout/stack.tsx"; +import {Alert, AlertDescription} from "@/components/ui/alert.tsx"; +import {Button} from "@/components/ui/button.tsx"; +import { + Dialog, + DialogClose, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog.tsx"; +import {ScrollArea} from "@/components/ui/scroll-area.tsx"; +import {useDialog} from "@/lib/contexts/dialog-context.ts"; +import {useTranslation} from "@/lib/contexts/translation-context.ts"; +import {useUpdate} from "@/lib/contexts/update-context.ts"; +import {platform} from "@tauri-apps/plugin-os"; +import {TriangleAlert} from "lucide-react"; +import {Streamdown} from "streamdown"; + +export function UpdateDialog() { + const {closeDialog} = useDialog(); + const {updateInformation, installUpdate} = useUpdate(); + const {_g, _p} = useTranslation(); + + return updateInformation ? ( + { + if (!open) { + closeDialog(); + } + }} + > + + + {_g("New Update")} + + + + {updateInformation.version} + {updateInformation.date && + ` · ${new Date(updateInformation.date * 1000).toLocaleDateString( + undefined, + {year: "numeric", month: "long", day: "numeric"}, + )}`} + + {updateInformation.changelog && ( + + + {_g("Changelog")} + + + {updateInformation.changelog} + + + )} + + + + + {_p( + "AppName", + "Application will restart to finish installing the update", + )} + + + + {platform() === "windows" && ( + <> + { + void installUpdate(); + }} + > + {_g("Install")} + + } + /> + {_g("Cancel")}} + /> + + )} + {platform() !== "windows" && ( + <> + {_g("Cancel")}} + /> + { + void installUpdate(); + }} + > + {_g("Install")} + + } + /> + + )} + + + + ) : ( + <> + ); +} diff --git a/src/components/layout/grid.tsx b/src/components/layout/grid.tsx new file mode 100644 index 00000000..82459fe9 --- /dev/null +++ b/src/components/layout/grid.tsx @@ -0,0 +1,113 @@ +import {cva, type VariantProps} from "class-variance-authority"; +import {cn} from "cn"; +import * as React from "react"; + +const gridVariants = cva("grid", { + variants: { + columns: { + 1: "grid-cols-1", + 2: "grid-cols-2", + 3: "grid-cols-3", + 4: "grid-cols-4", + 5: "grid-cols-5", + 6: "grid-cols-6", + 12: "grid-cols-12", + }, + rows: { + 1: "grid-rows-1", + 2: "grid-rows-2", + 3: "grid-rows-3", + 4: "grid-rows-4", + 5: "grid-rows-5", + 6: "grid-rows-6", + }, + gap: { + 0: "gap-0", + 0.5: "gap-0.5", + 1: "gap-1", + 1.5: "gap-1.5", + 2: "gap-2", + 2.5: "gap-2.5", + 3: "gap-3", + 4: "gap-4", + 5: "gap-5", + 6: "gap-6", + 8: "gap-8", + 10: "gap-10", + 12: "gap-12", + }, + }, +}); + +type GridProps = React.ComponentProps<"div"> & + VariantProps; + +export function Grid({className, columns, rows, gap, ...props}: GridProps) { + return ( +
+ ); +} + +const gridColumnVariants = cva("", { + variants: { + span: { + 1: "col-span-1", + 2: "col-span-2", + 3: "col-span-3", + 4: "col-span-4", + 5: "col-span-5", + 6: "col-span-6", + 7: "col-span-7", + 8: "col-span-8", + 9: "col-span-9", + 10: "col-span-10", + 11: "col-span-11", + 12: "col-span-12", + full: "col-span-full", + }, + }, +}); + +type GridColumnProps = React.ComponentProps<"div"> & + VariantProps; + +export function GridColumn({className, span, ...props}: GridColumnProps) { + return ( +
+ ); +} + +const gridRowVariants = cva("", { + variants: { + span: { + 1: "row-span-1", + 2: "row-span-2", + 3: "row-span-3", + 4: "row-span-4", + 5: "row-span-5", + 6: "row-span-6", + full: "row-span-full", + }, + }, +}); + +type GridRowProps = React.ComponentProps<"div"> & + VariantProps; + +export function GridRow({className, span, ...props}: GridRowProps) { + return ( +
+ ); +} diff --git a/src/components/layout/stack.tsx b/src/components/layout/stack.tsx new file mode 100644 index 00000000..565fae70 --- /dev/null +++ b/src/components/layout/stack.tsx @@ -0,0 +1,84 @@ +import {mergeProps} from "@base-ui/react/merge-props"; +import {useRender} from "@base-ui/react/use-render"; +import {cva, type VariantProps} from "class-variance-authority"; +import {cn} from "cn"; +import * as React from "react"; + +const stackVariants = cva("flex", { + variants: { + direction: { + row: "flex-row", + column: "flex-col", + }, + align: { + start: "items-start", + center: "items-center", + end: "items-end", + stretch: "items-stretch", + baseline: "items-baseline", + }, + justify: { + start: "justify-start", + center: "justify-center", + end: "justify-end", + between: "justify-between", + around: "justify-around", + evenly: "justify-evenly", + }, + gap: { + 0: "gap-0", + 0.5: "gap-0.5", + 1: "gap-1", + 1.5: "gap-1.5", + 2: "gap-2", + 2.5: "gap-2.5", + 3: "gap-3", + 4: "gap-4", + 5: "gap-5", + 6: "gap-6", + 8: "gap-8", + 10: "gap-10", + 12: "gap-12", + }, + }, + defaultVariants: { + direction: "row", + }, +}); + +type StackProps = useRender.ComponentProps<"div"> & + React.ComponentProps<"div"> & + VariantProps; + +function Stack({ + className, + direction, + align, + justify, + gap, + render, + ...props +}: StackProps) { + return useRender({ + defaultTagName: "div", + render, + props: mergeProps<"div">( + { + className: cn( + stackVariants({direction, align, justify, gap}), + className, + ), + "data-slot": "stack", + } as React.ComponentProps<"div">, + props, + ), + }); +} + +export function HStack(props: Omit) { + return ; +} + +export function VStack(props: Omit) { + return ; +} diff --git a/src/components/navigation-view.tsx b/src/components/navigation-view.tsx new file mode 100644 index 00000000..e4186107 --- /dev/null +++ b/src/components/navigation-view.tsx @@ -0,0 +1,413 @@ +import {Avatar, AvatarFallback} from "@/components/ui/avatar.tsx"; +import {Badge} from "@/components/ui/badge.tsx"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuItem, + DropdownMenuPortal, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuSub, + DropdownMenuSubContent, + DropdownMenuSubTrigger, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu.tsx"; +import {Item, ItemContent, ItemMedia} from "@/components/ui/item.tsx"; +import {Progress} from "@/components/ui/progress.tsx"; +import { + Sidebar, + SidebarContent, + SidebarFooter, + SidebarGroup, + SidebarGroupContent, + SidebarGroupLabel, + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, + useSidebar, +} from "@/components/ui/sidebar.tsx"; +import {Spinner} from "@/components/ui/spinner.tsx"; +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@/components/ui/tooltip.tsx"; +import {Theme, useConfiguration} from "@/lib/contexts/configuration-context.ts"; +import {useDialog} from "@/lib/contexts/dialog-context.ts"; +import {useFolderView} from "@/lib/contexts/folder-view-context.ts"; +import {Page, useNavigation} from "@/lib/contexts/navigation-context.ts"; +import {useTranslation} from "@/lib/contexts/translation-context.ts"; +import {useUpdate} from "@/lib/contexts/update-context.ts"; +import {invoke} from "@tauri-apps/api/core"; +import {platform} from "@tauri-apps/plugin-os"; +import { + BadgeInfo, + BadgePlus, + Bug, + ChevronsUpDown, + Folder, + Home, + LifeBuoy, + LucideIcon, + MessageSquareShare, + RefreshCw, + Settings, + Sparkles, + SquareLibrary, + SunMoon, + UserGroup, +} from "lucide-react"; +import {useEffect, useState} from "react"; + +interface NavigationViewItem { + title: string; + page: Page; + icon: LucideIcon; +} + +interface NavigationViewSection { + title: string; + items: (NavigationViewItem | null)[]; +} + +interface User { + username: string; + fullName: string; +} + +export function NavigationView() { + const {configuration, setConfiguration} = useConfiguration(); + const {_f, _g, _p} = useTranslation(); + const { + checkingForUpdates, + checkForUpdates, + installingUpdate, + updateDownloadProgress, + updateInformation, + } = useUpdate(); + const {openDialog} = useDialog(); + const {page, setPage} = useNavigation(); + const {isMobile} = useSidebar(); + const {folderView} = useFolderView(); + const [user, setUser] = useState({ + username: "", + fullName: "", + }); + + const items: NavigationViewSection[] = [ + { + title: "", + items: [ + { + title: _g("Home"), + page: "home", + icon: Home, + }, + folderView.path + ? { + title: _g("Folder"), + page: "folder", + icon: Folder, + } + : null, + ], + }, + ]; + + useEffect(() => { + async function startup() { + setUser(await invoke("get_user")); + } + + void startup(); + }, []); + + return ( + + + {items.map((section) => ( + + {section.title && ( + {section.title} + )} + + + {section.items + .filter((item) => item !== null) + .map((item) => ( + + { + setPage(item.page); + }} + > + + {item.title} + + + ))} + + + + ))} + + + + {checkingForUpdates && ( + + + + + + + {_g("Checking for updates...")} + + + + )} + {installingUpdate && ( + + }> + {(!updateDownloadProgress || + updateDownloadProgress.total === 0) && ( + + + + )} + +
+ + {_g("Downloading update...")} + + {updateDownloadProgress && + updateDownloadProgress.total > 0 && ( + + {Math.round( + (updateDownloadProgress.downloaded / + updateDownloadProgress.total) * + 100, + )} + % + + )} +
+ {updateDownloadProgress && + updateDownloadProgress.total > 0 && ( + + )} +
+
+ + {updateDownloadProgress && updateDownloadProgress.total > 0 + ? _f("Downloading update... {0}% ({1} MB of {2} MB)", [ + Math.round( + (updateDownloadProgress.downloaded / + updateDownloadProgress.total) * + 100, + ).toString(), + (updateDownloadProgress.downloaded / 1048576).toFixed(1), + (updateDownloadProgress.total / 1048576).toFixed(1), + ]) + : _g("Downloading update...")} + +
+ )} + {updateInformation && !installingUpdate && ( + + openDialog("update")} + > + + {_g("Update Available")} + {updateInformation.version} + + + )} + + + }> + {user.fullName && ( + <> + + + {user.fullName + .split(" ") + .map((word) => word.charAt(0)) + .join("")} + + +
+ + {user.fullName} + + {user.username !== user.fullName && ( + + {user.username} + + )} +
+ + + )} + {!user.fullName && } +
+ + + { + void checkForUpdates(); + }} + > + + {_g("Check for Updates")} + {platform() === "macos" && ( + ⌘R + )} + {platform() !== "macos" && ( + Ctrl+R + )} + + + + + {_g("Help")} + + + + + { + openDialog("changelog"); + }} + > + + {_g("What's New?")} + F1 + + + + + { + void invoke("open_github_repository"); + }} + > + + {_g("GitHub Repository")} + + { + void invoke("open_report_a_bug"); + }} + > + + {_g("Report a Bug")} + + { + void invoke("open_discussions"); + }} + > + + {_g("Discussions")} + + + + + { + openDialog("credits"); + }} + > + + {_g("Credits")} + + { + openDialog("debugging"); + }} + > + + {_g("Debugging Information")} + {platform() === "macos" && ( + ⌘⇧D + )} + {platform() !== "macos" && ( + + Ctrl+Shift+D + + )} + + + + + + + + + + + + {_g("Theme")} + + + + { + setConfiguration({ + ...configuration, + theme: value as Theme, + }); + }} + > + + {_p("Theme", "Light")} + + + {_p("Theme", "Dark")} + + + {_p("Theme", "System")} + + + + + + { + openDialog("settings"); + }} + > + + {_g("Settings")} + {platform() === "macos" && ( + ⌘, + )} + {platform() !== "macos" && ( + Ctrl+, + )} + + + +
+
+
+
+
+ ); +} diff --git a/src/components/pages/folder-page.tsx b/src/components/pages/folder-page.tsx new file mode 100644 index 00000000..d805edd1 --- /dev/null +++ b/src/components/pages/folder-page.tsx @@ -0,0 +1,288 @@ +import {Grid} from "@/components/layout/grid.tsx"; +import {HStack, VStack} from "@/components/layout/stack.tsx"; +import {Button} from "@/components/ui/button.tsx"; +import { + Empty, + EmptyDescription, + EmptyHeader, + EmptyMedia, + EmptyTitle, +} from "@/components/ui/empty.tsx"; +import {Kbd, KbdGroup} from "@/components/ui/kbd.tsx"; +import { + ResizableHandle, + ResizablePanel, + ResizablePanelGroup, +} from "@/components/ui/resizable.tsx"; +import {ScrollArea} from "@/components/ui/scroll-area.tsx"; +import {ToggleGroup, ToggleGroupItem} from "@/components/ui/toggle-group.tsx"; +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@/components/ui/tooltip.tsx"; +import {useTitlebarControls} from "@/hooks/titlebar.tsx"; +import {useFolderView} from "@/lib/contexts/folder-view-context.ts"; +import {useTranslation} from "@/lib/contexts/translation-context.ts"; +import {convertFileSrc} from "@tauri-apps/api/core"; +import {platform} from "@tauri-apps/plugin-os"; +import { + FileIcon, + FolderOpenIcon, + LayoutGridIcon, + ListIcon, + XIcon, +} from "lucide-react"; +import {useEffect, useMemo, useState} from "react"; + +const IMAGE_EXTENSIONS = new Set([ + "png", + "jpg", + "jpeg", + "gif", + "webp", + "bmp", + "avif", + "ico", +]); + +interface FolderFile { + path: string; + name: string; +} + +export function FolderPage() { + const {_g} = useTranslation(); + const {folderView, closeFolder, openFolder} = useFolderView(); + const [selectedFile, setSelectedFile] = useState(null); + const [imageLoadFailed, setImageLoadFailed] = useState(false); + const [viewMode, setViewMode] = useState<"list" | "grid">("list"); + + useEffect(() => { + setSelectedFile(null); + }, [folderView.path]); + + useEffect(() => { + setImageLoadFailed(false); + }, [selectedFile]); + + const files = useMemo(() => { + return folderView.files.map((filePath): FolderFile => ({ + path: filePath, + name: filePath.split(/[/\\]/).filter(Boolean).pop() ?? filePath, + })); + }, [folderView.files]); + + const selectedExtension = selectedFile + ? selectedFile.path + .slice(selectedFile.path.lastIndexOf(".") + 1) + .toLowerCase() + : ""; + const canPreviewImage = + selectedFile !== null && + IMAGE_EXTENSIONS.has(selectedExtension) && + !imageLoadFailed; + + const titlebarControls = useMemo( + () => ( + <> + { + if (value.length > 0) { + setViewMode(value[0] as "list" | "grid"); + } + }} + > + + + + + } + /> + {_g("List View")} + + + + + + } + /> + {_g("Grid View")} + + + + { + void openFolder(); + }} + > + + + } + /> + + {_g("Open Folder")} + + {platform() === "macos" && ⌘} + {platform() !== "macos" && Ctrl} + O + + + + + { + void closeFolder(); + }} + > + + + } + /> + + {_g("Close Folder")} + + {platform() === "macos" && ⌘} + {platform() !== "macos" && Ctrl} + Shift + + + W + + + + + ), + [viewMode, _g, openFolder, closeFolder], + ); + + useTitlebarControls(titlebarControls); + + return ( + + + + + {viewMode === "list" ? ( + + {files.length > 0 ? ( + files.map((file) => ( + + } + align="center" + justify="start" + gap={1.5} + onClick={() => { + setSelectedFile(file); + }} + className="w-full px-2 py-1 text-left text-sm" + > + + {file.name} + + )) + ) : ( +

+ {_g("This folder is empty.")} +

+ )} +
+ ) : ( + + {files.length > 0 ? ( + files.map((file) => ( + + } + align="center" + justify="center" + gap={1} + onClick={() => { + setSelectedFile(file); + }} + className="h-auto w-full p-3 text-center text-sm" + > + + + {file.name} + + + )) + ) : ( +

+ {_g("This folder is empty.")} +

+ )} +
+ )} +
+
+ + + + {selectedFile === null ? ( + + + {_g("No File Selected")} + + {_g("Select a file to preview it here.")} + + + + ) : canPreviewImage ? ( + {selectedFile.path} { + setImageLoadFailed(true); + }} + className="max-h-full max-w-full rounded-lg object-contain" + /> + ) : ( + + + + + + {_g("No Preview Available")} + {selectedFile.name} + + + )} + + +
+
+ ); +} diff --git a/src/components/pages/home-page.tsx b/src/components/pages/home-page.tsx new file mode 100644 index 00000000..c8db740a --- /dev/null +++ b/src/components/pages/home-page.tsx @@ -0,0 +1,199 @@ +import {HStack, VStack} from "@/components/layout/stack.tsx"; +import {Button} from "@/components/ui/button.tsx"; +import {Kbd, KbdGroup} from "@/components/ui/kbd.tsx"; +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@/components/ui/tooltip.tsx"; +import {useDialog} from "@/lib/contexts/dialog-context.ts"; +import {useFolderView} from "@/lib/contexts/folder-view-context.ts"; +import {useTranslation} from "@/lib/contexts/translation-context.ts"; +import {platform} from "@tauri-apps/plugin-os"; +import { + FolderOpen, + LucideIcon, + Moon, + MoonStar, + Settings, + Sparkles, + Sun, +} from "lucide-react"; +import {useEffect, useState} from "react"; + +interface Greeting { + label: string; + icon: LucideIcon; +} + +export function HomePage() { + const {_g, _p} = useTranslation(); + const {openDialog} = useDialog(); + const {openFolder} = useFolderView(); + const [greeting, setGreeting] = useState({ + label: _g("Good Day!"), + icon: Sun, + }); + + useEffect(() => { + const hours = new Date().getHours(); + let label: string; + let icon = Sun; + if (hours < 6) { + label = _p("Night", "Good Morning!"); + icon = MoonStar; + } else if (hours < 12) { + label = _p("Morning", "Good Morning!"); + } else if (hours < 18) { + label = _g("Good Afternoon!"); + } else { + label = _g("Good Evening!"); + icon = Moon; + } + setGreeting({ + label, + icon, + }); + }, []); + + return ( +
+ + + +
+ +
+

+ {greeting.label} +

+

+ {_g("Open a folder (or drag one in) to get started!")} +

+
+ + { + void openFolder(); + }} + > + + {_g("Open Folder")} + + } + /> + + {_g("Open Folder")} + + {platform() === "macos" && ⌘} + {platform() !== "macos" && Ctrl} + O + + + + + + { + openDialog("changelog"); + }} + > + + {_g("What's New?")} + + } + /> + + {_g("What's New?")} + F1 + + + + { + openDialog("settings"); + }} + > + + {_g("Settings")} + + } + /> + + {_g("Settings")} + + {platform() === "macos" && ⌘} + {platform() !== "macos" && Ctrl} + , + + + + +
+
+ ); +} diff --git a/src/components/ui/accordion.tsx b/src/components/ui/accordion.tsx new file mode 100644 index 00000000..89033a29 --- /dev/null +++ b/src/components/ui/accordion.tsx @@ -0,0 +1,71 @@ +import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion" +import { cn } from "cn" +import { ChevronDownIcon, ChevronUpIcon } from "lucide-react" + +function Accordion({ className, ...props }: AccordionPrimitive.Root.Props) { + return ( + + ) +} + +function AccordionItem({ className, ...props }: AccordionPrimitive.Item.Props) { + return ( + + ) +} + +function AccordionTrigger({ + className, + children, + ...props +}: AccordionPrimitive.Trigger.Props) { + return ( + + + {children} + + + + + ) +} + +function AccordionContent({ + className, + children, + ...props +}: AccordionPrimitive.Panel.Props) { + return ( + +
+ {children} +
+
+ ) +} + +export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } diff --git a/src/components/ui/alert-dialog.tsx b/src/components/ui/alert-dialog.tsx new file mode 100644 index 00000000..30fd5cc0 --- /dev/null +++ b/src/components/ui/alert-dialog.tsx @@ -0,0 +1,185 @@ +import * as React from "react" +import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog" +import { cn } from "cn" + +import { Button } from "@/components/ui/button" + +function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) { + return +} + +function AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) { + return ( + + ) +} + +function AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props) { + return ( + + ) +} + +function AlertDialogOverlay({ + className, + ...props +}: AlertDialogPrimitive.Backdrop.Props) { + return ( + + ) +} + +function AlertDialogContent({ + className, + size = "default", + ...props +}: AlertDialogPrimitive.Popup.Props & { + size?: "default" | "sm" +}) { + return ( + + + + + ) +} + +function AlertDialogHeader({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertDialogFooter({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertDialogMedia({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertDialogTitle({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogDescription({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AlertDialogAction({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function CarouselNext({ + className, + variant = "outline", + size = "icon-sm", + ...props +}: React.ComponentProps) { + const { orientation, scrollNext, canScrollNext } = useCarousel() + + return ( + + ) +} + +export { + type CarouselApi, + Carousel, + CarouselContent, + CarouselItem, + CarouselPrevious, + CarouselNext, + useCarousel, +} diff --git a/src/components/ui/chart.tsx b/src/components/ui/chart.tsx new file mode 100644 index 00000000..c5f6eb3c --- /dev/null +++ b/src/components/ui/chart.tsx @@ -0,0 +1,370 @@ +import * as React from "react" +import { cn } from "cn" +import * as RechartsPrimitive from "recharts" +import type { TooltipValueType } from "recharts" + +// Format: { THEME_NAME: CSS_SELECTOR } +const THEMES = { light: "", dark: ".dark" } as const + +const INITIAL_DIMENSION = { width: 320, height: 200 } as const +type TooltipNameType = number | string + +export type ChartConfig = Record< + string, + { + label?: React.ReactNode + icon?: React.ComponentType + } & ( + | { color?: string; theme?: never } + | { color?: never; theme: Record } + ) +> + +type ChartContextProps = { + config: ChartConfig +} + +const ChartContext = React.createContext(null) + +function useChart() { + const context = React.useContext(ChartContext) + + if (!context) { + throw new Error("useChart must be used within a ") + } + + return context +} + +function ChartContainer({ + id, + className, + children, + config, + initialDimension = INITIAL_DIMENSION, + ...props +}: React.ComponentProps<"div"> & { + config: ChartConfig + children: React.ComponentProps< + typeof RechartsPrimitive.ResponsiveContainer + >["children"] + initialDimension?: { + width: number + height: number + } +}) { + const uniqueId = React.useId() + const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}` + + return ( + +
+ + + {children} + +
+
+ ) +} + +const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { + const colorConfig = Object.entries(config).filter( + ([, config]) => config.theme ?? config.color + ) + + if (!colorConfig.length) { + return null + } + + return ( +