diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a55310ce4..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,177 +0,0 @@ -version: 2.1 - -orbs: - gh: circleci/github-cli@2.2.0 - -jobs: - flutter_linux_arm: - machine: - image: ubuntu-2204:current - resource_class: arm.medium - parameters: - version: - type: string - default: 3.1.1 - channel: - type: enum - enum: - - release - - nightly - default: release - github_run_number: - type: string - default: "0" - dry_run: - type: boolean - default: true - steps: - - checkout - - gh/setup - - - run: - name: Get current date - command: | - echo "export CURRENT_DATE=$(date +%Y-%m-%d)" >> $BASH_ENV - - - run: - name: Install dependencies - command: | - sudo apt-get update -y - sudo apt-get install -y tar clang cmake ninja-build pkg-config libgtk-3-dev make python3-pip python3-setuptools desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse libunwind-dev locate patchelf gir1.2-appindicator3-0.1 libappindicator3-1 libappindicator3-dev libsecret-1-0 libjsoncpp25 libsecret-1-dev libjsoncpp-dev libnotify-bin libnotify-dev mpv libmpv-dev zip rpm - - - run: - name: Install Flutter - command: | - git clone https://github.com/flutter/flutter.git - cd flutter && git checkout stable && cd .. - export PATH="$PATH:`pwd`/flutter/bin" - flutter precache - flutter doctor -v - - - run: - name: Install AppImageTool - command: | - wget -O appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-aarch64.AppImage" - chmod +x appimagetool - mv appimagetool flutter/bin - - - persist_to_workspace: - root: flutter - paths: - - . - - - when: - condition: - equal: [<< parameters.channel >>, nightly] - steps: - - run: - name: Replace pubspec version and BUILD_VERSION Env (nightly) - command: | - curl -sS https://webi.sh/yq | sh - yq -i '.version |= sub("\+\d+", "+<< parameters.channel >>.")' pubspec.yaml - yq -i '.version += strenv(GITHUB_RUN_NUMBER)' pubspec.yaml - echo 'export BUILD_VERSION="<< parameters.version >>+<< parameters.channel >>.<< parameters.github_run_number >>"' >> $BASH_ENV - - - when: - condition: - equal: [<< parameters.channel >>, release] - steps: - - run: echo 'export BUILD_VERSION="<< parameters.version >>"' >> $BASH_ENV - - - run: - name: Generate .env file - command: | - echo "SPOTIFY_SECRETS=${SPOTIFY_SECRETS}" >> .env - - - run: - name: Replace Version in files - command: | - sed -i 's|%{{APPDATA_RELEASE}}%||' linux/com.github.KRTirtho.Spotube.appdata.xml - echo "build_arch: aarch64" >> linux/packaging/rpm/make_config.yaml - - - run: - name: Build secrets - command: | - export PATH="$PATH:`pwd`/flutter/bin" - flutter config --enable-linux-desktop - flutter pub get - dart run build_runner build --delete-conflicting-outputs --enable-experiment=records,patterns - - - run: - name: Build Flutter app - command: | - export PATH="$PATH:`pwd`/flutter/bin" - export PATH="$PATH":"$HOME/.pub-cache/bin" - dart pub global activate flutter_distributor - alias dpkg-deb="dpkg-deb --Zxz" - flutter_distributor package --platform=linux --targets=deb - flutter_distributor package --platform=linux --targets=appimage - flutter_distributor package --platform=linux --targets=rpm - - - when: - condition: - equal: [<< parameters.channel >>, nightly] - steps: - - run: make tar VERSION=nightly ARCH=arm64 PKG_ARCH=aarch64 - - - when: - condition: - equal: [<< parameters.channel >>, release] - steps: - - run: make tar VERSION=${BUILD_VERSION} ARCH=arm64 PKG_ARCH=aarch64 - - - run: - name: Move artifacts - command: | - mkdir bundle - mv build/spotube-linux-*-aarch64.tar.xz bundle/ - mv dist/**/spotube-*-linux.deb bundle/Spotube-linux-aarch64.deb - mv dist/**/spotube-*-linux.rpm bundle/Spotube-linux-aarch64.rpm - mv dist/**/spotube-*-linux.AppImage bundle/Spotube-linux-aarch64.AppImage - zip -r Spotube-linux-aarch64.zip bundle - - - store_artifacts: - path: Spotube-linux-aarch64.zip - - - when: - condition: - and: - - equal: [<< parameters.dry_run >>, false] - - equal: [<< parameters.channel >>, release] - steps: - - run: - name: Upload to release (release) - command: gh release upload v<< parameters.version >> bundle/* --clobber - - - when: - condition: - and: - - equal: [<< parameters.dry_run >>, false] - - equal: [<< parameters.channel >>, nightly] - steps: - - run: - name: Upload to release (nightly) - command: gh release upload nightly bundle/* --clobber - -parameters: - GHA_Actor: - type: string - default: "" - GHA_Action: - type: string - default: "" - GHA_Event: - type: string - default: "" - GHA_Meta: - type: string - default: "" - -workflows: - build_flutter_for_arm_workflow: - when: << pipeline.parameters.GHA_Action >> - jobs: - - flutter_linux_arm: - context: - - org-global - - GITHUB_CREDS diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..ddfd15179 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +build +dist +.dart_tool +.idea +.github +.git \ No newline at end of file diff --git a/.env.example b/.env.example index 22abd24bd..566656632 100644 --- a/.env.example +++ b/.env.example @@ -9,3 +9,6 @@ ENABLE_UPDATE_CHECK= LASTFM_API_KEY= LASTFM_API_SECRET= + +# Release channel. Can be: nightly, stable +RELEASE_CHANNEL= diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 7ca74200a..160b5b293 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,4 +1,4 @@ { - "flutterSdkVersion": "3.19.1", + "flutterSdkVersion": "3.22.3", "flavors": {} } \ No newline at end of file diff --git a/.github/Dockerfile b/.github/Dockerfile new file mode 100644 index 000000000..f6a9f538a --- /dev/null +++ b/.github/Dockerfile @@ -0,0 +1,25 @@ +ARG FLUTTER_VERSION + +FROM --platform=linux/arm64 krtirtho/flutter_distributor:${FLUTTER_VERSION} + +ARG BUILD_VERSION + +WORKDIR /app + +COPY . . + +RUN chown -R $(whoami) /app + +RUN rustup target add aarch64-unknown-linux-gnu + +RUN flutter pub get + +RUN alias dpkg-deb="dpkg-deb --Zxz" &&\ + flutter_distributor package --platform=linux --targets=deb --skip-clean + +RUN make tar VERSION=${BUILD_VERSION} ARCH=arm64 PKG_ARCH=aarch64 + +RUN mv build/spotube-linux-*-aarch64.tar.xz dist/ &&\ + mv dist/**/spotube-*-linux.deb dist/Spotube-linux-aarch64.deb + +CMD [ "sleep", "5000000" ] \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 64ee89d2c..fed668501 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -53,7 +53,7 @@ body: description: Where did you install Spotube from? multiple: true options: - - "Website (spotube.netlify.app) or (spotube.krtirtho.dev)" + - "Website (spotube.krtirtho.dev)" - "GitHub Releases (Binary)" - "GitHub Actions (Nightly Binary)" - "Play Store (Android)" @@ -77,4 +77,4 @@ body: description: If you are a developer and want to work on this issue yourself, you can check this box and wait for maintainer response. We welcome contributions! options: - label: I'm ready to work on this issue! - required: false \ No newline at end of file + required: false diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/pr-lint.yml index 156d1a076..db158029a 100644 --- a/.github/workflows/pr-lint.yml +++ b/.github/workflows/pr-lint.yml @@ -4,7 +4,7 @@ on: pull_request: env: - FLUTTER_VERSION: '3.19.5' + FLUTTER_VERSION: 3.22.2 jobs: lint: diff --git a/.github/workflows/spotube-publish-binary.yml b/.github/workflows/spotube-publish-binary.yml index 805a89ac3..812849acc 100644 --- a/.github/workflows/spotube-publish-binary.yml +++ b/.github/workflows/spotube-publish-binary.yml @@ -4,7 +4,7 @@ on: inputs: version: description: Version to publish (x.x.x) - default: 3.1.0 + default: 3.8.0 required: true dry_run: description: Dry run @@ -12,10 +12,10 @@ on: type: boolean default: true jobs: - description: Jobs to run (flathub,aur,winget,chocolatey) + description: Jobs to run (flathub,aur,winget,chocolatey,playstore) required: true type: string - default: "flathub,aur,winget,chocolatey" + default: "flathub,aur,winget,chocolatey,playstore" jobs: flathub: @@ -66,7 +66,7 @@ jobs: - name: Release to AUR if: ${{ !inputs.dry_run }} - uses: KSXGitHub/github-actions-deploy-aur@v2.7.1 + uses: KSXGitHub/github-actions-deploy-aur@v2.7.2 with: pkgname: spotube-bin pkgbuild: aur-struct/PKGBUILD @@ -104,3 +104,34 @@ jobs: - name: Publish to Chocolatey Repository if: ${{ !inputs.dry_run }} run: choco push Spotube-windows-x86_64.nupkg --source https://push.chocolatey.org/ + + playstore: + runs-on: ubuntu-latest + if: contains(inputs.jobs, 'playstore') + steps: + - name: Tagname (workflow dispatch) + run: echo 'TAG_NAME=${{inputs.version}}' >> $GITHUB_ENV + + - uses: robinraju/release-downloader@main + with: + repository: KRTirtho/spotube + tag: v${{ env.TAG_NAME }} + tarBall: false + zipBall: false + out-file-path: dist + fileName: "Spotube-playstore-all-arch.aab" + + - name: Create service-account.json + run: | + echo "${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_BASE64 }}" | base64 -d > service-account.json + + - name: Upload Android Release to Play Store + if: ${{!inputs.dry_run}} + uses: r0adkll/upload-google-play@v1 + with: + serviceAccountJson: ./service-account.json + releaseFiles: ./dist/Spotube-playstore-all-arch.aab + packageName: oss.krtirtho.spotube + track: production + status: draft + releaseName: ${{ env.TAG_NAME }} \ No newline at end of file diff --git a/.github/workflows/spotube-release-binary.yml b/.github/workflows/spotube-release-binary.yml index d9fbd0c7d..b103ea2e0 100644 --- a/.github/workflows/spotube-release-binary.yml +++ b/.github/workflows/spotube-release-binary.yml @@ -2,345 +2,119 @@ name: Spotube Release Binary on: workflow_dispatch: inputs: - version: - description: Version to release (x.x.x) - default: 3.6.0 - required: true channel: type: choice - description: Release Channel - required: true options: - stable - nightly default: nightly + description: The release channel debug: - description: Debug on failed when channel is nightly - required: true type: boolean default: false + description: Debug with SSH toggle + required: false dry_run: - description: Dry run - required: true type: boolean - default: true + default: false + description: Dry run without uploading to release env: - FLUTTER_VERSION: '3.19.1' - -jobs: - windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - uses: subosito/flutter-action@v2.12.0 - with: - cache: true - flutter-version: ${{ env.FLUTTER_VERSION }} - - - name: Replace pubspec version and BUILD_VERSION Env (nightly) - if: ${{ inputs.channel == 'nightly' }} - run: | - choco install sed make yq -y - yq -i '.version |= sub("\+\d+", "+${{ inputs.channel }}.")' pubspec.yaml - yq -i '.version += strenv(GITHUB_RUN_NUMBER)' pubspec.yaml - "BUILD_VERSION=${{ inputs.version }}+${{ inputs.channel }}.${{ github.run_number }}" >> $env:GITHUB_ENV - - - name: BUILD_VERSION Env (stable) - if: ${{ inputs.channel == 'stable' }} - run: | - "BUILD_VERSION=${{ inputs.version }}" >> $env:GITHUB_ENV - - - name: Replace version in files - run: | - choco install sed make -y - sed -i "s/%{{SPOTUBE_VERSION}}%/${{ env.BUILD_VERSION }}/" windows/runner/Runner.rc - sed -i "s/%{{SPOTUBE_VERSION}}%/${{ env.BUILD_VERSION }}/" choco-struct/tools/VERIFICATION.txt - sed -i "s/%{{SPOTUBE_VERSION}}%/${{ env.BUILD_VERSION }}/" choco-struct/spotube.nuspec - - - name: Create Stable .env - if: ${{ inputs.channel == 'stable' }} - run: echo '${{ secrets.DOTENV_RELEASE }}' > .env - - - name: Create Nightly .env - if: ${{ inputs.channel == 'nightly' }} - run: echo '${{ secrets.DOTENV_NIGHTLY }}' > .env - - - name: Generating Secrets - run: | - flutter config --enable-windows-desktop - flutter pub get - dart run build_runner build --delete-conflicting-outputs --enable-experiment=records,patterns - - - name: Build Windows Executable - run: | - dart pub global activate flutter_distributor - make innoinstall - flutter_distributor package --platform=windows --targets=exe --skip-clean - mv dist/**/spotube-*-windows-setup.exe dist/Spotube-windows-x86_64-setup.exe - - - name: Create Chocolatey Package and set hash - if: ${{ inputs.channel == 'stable' }} - run: | - Set-Variable -Name HASH -Value (Get-FileHash dist\Spotube-windows-x86_64-setup.exe).Hash - sed -i "s/%{{WIN_SHA256}}%/$HASH/" choco-struct/tools/VERIFICATION.txt - make choco - mv dist/spotube.*.nupkg dist/Spotube-windows-x86_64.nupkg - - - - name: Upload Artifact - uses: actions/upload-artifact@v3 - with: - if-no-files-found: error - name: Spotube-Release-Binaries - path: | - dist/Spotube-windows-x86_64.nupkg - dist/Spotube-windows-x86_64-setup.exe - - - name: Debug With SSH When fails - if: ${{ failure() && inputs.debug && inputs.channel == 'nightly' }} - uses: mxschmitt/action-tmate@v3 - with: - limit-access-to-actor: true - - linux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: subosito/flutter-action@v2.12.0 - with: - cache: true - flutter-version: ${{ env.FLUTTER_VERSION }} - - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - - - name: Install Dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y tar clang cmake ninja-build pkg-config libgtk-3-dev make python3-pip python3-setuptools desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse libunwind-dev locate patchelf gir1.2-appindicator3-0.1 libappindicator3-1 libappindicator3-dev libsecret-1-0 libjsoncpp25 libsecret-1-dev libjsoncpp-dev libnotify-bin libnotify-dev mpv libmpv-dev - - - name: Install AppImage Tool - run: | - wget -O appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" - chmod +x appimagetool - mv appimagetool /usr/local/bin/ - - - name: Replace pubspec version and BUILD_VERSION Env (nightly) - if: ${{ inputs.channel == 'nightly' }} - run: | - curl -sS https://webi.sh/yq | sh - yq -i '.version |= sub("\+\d+", "+${{ inputs.channel }}.")' pubspec.yaml - yq -i '.version += strenv(GITHUB_RUN_NUMBER)' pubspec.yaml - echo "BUILD_VERSION=${{ inputs.version }}+${{ inputs.channel }}.${{ github.run_number }}" >> $GITHUB_ENV - - - name: BUILD_VERSION Env (stable) - if: ${{ inputs.channel == 'stable' }} - run: | - echo "BUILD_VERSION=${{ inputs.version }}" >> $GITHUB_ENV - - - name: Create Stable .env - if: ${{ inputs.channel == 'stable' }} - run: echo '${{ secrets.DOTENV_RELEASE }}' > .env + FLUTTER_VERSION: 3.22.3 - - name: Create Nightly .env - if: ${{ inputs.channel == 'nightly' }} - run: echo '${{ secrets.DOTENV_NIGHTLY }}' > .env - - - name: Replace Version in files - run: | - sed -i 's|%{{APPDATA_RELEASE}}%||' linux/com.github.KRTirtho.Spotube.appdata.xml - - - name: Generate Secrets - run: | - flutter config --enable-linux-desktop - flutter pub get - dart run build_runner build --delete-conflicting-outputs --enable-experiment=records,patterns - - - name: Build Linux Packages - run: | - dart pub global activate flutter_distributor - alias dpkg-deb="dpkg-deb --Zxz" - flutter_distributor package --platform=linux --targets=deb - flutter_distributor package --platform=linux --targets=rpm - - - name: Create tar.xz (stable) - if: ${{ inputs.channel == 'stable' }} - run: make tar VERSION=${{ env.BUILD_VERSION }} ARCH=x64 PKG_ARCH=x86_64 - - - name: Create tar.xz (nightly) - if: ${{ inputs.channel == 'nightly' }} - run: make tar VERSION=nightly ARCH=x64 PKG_ARCH=x86_64 - - - name: Move Files to dist - run: | - mv build/spotube-linux-*-x86_64.tar.xz dist/ - mv dist/**/spotube-*-linux.deb dist/Spotube-linux-x86_64.deb - mv dist/**/spotube-*-linux.rpm dist/Spotube-linux-x86_64.rpm +permissions: + contents: write - - - uses: actions/upload-artifact@v3 - if: ${{ inputs.channel == 'stable' }} - with: - if-no-files-found: error - name: Spotube-Release-Binaries - path: | - dist/Spotube-linux-x86_64.deb - dist/Spotube-linux-x86_64.rpm - dist/spotube-linux-${{ env.BUILD_VERSION }}-x86_64.tar.xz - - - uses: actions/upload-artifact@v3 - if: ${{ inputs.channel == 'nightly' }} - with: - if-no-files-found: error - name: Spotube-Release-Binaries - path: | - dist/Spotube-linux-x86_64.deb - dist/Spotube-linux-x86_64.rpm - dist/spotube-linux-nightly-x86_64.tar.xz - - - name: Debug With SSH When fails - if: ${{ failure() && inputs.debug && inputs.channel == 'nightly' }} - uses: mxschmitt/action-tmate@v3 - with: - limit-access-to-actor: true - - - android: - runs-on: ubuntu-latest +jobs: + build_platform: + strategy: + matrix: + include: + - os: ubuntu-latest + platform: linux + files: | + dist/Spotube-linux-x86_64.deb + dist/Spotube-linux-x86_64.rpm + dist/spotube-linux-*-x86_64.tar.xz + - os: ubuntu-latest + platform: linux_arm + files: | + dist/Spotube-linux-aarch64.deb + dist/spotube-linux-*-aarch64.tar.xz + - os: ubuntu-latest + platform: android + files: | + build/Spotube-android-all-arch.apk + build/Spotube-playstore-all-arch.aab + - os: windows-latest + platform: windows + files: | + dist/Spotube-windows-x86_64.nupkg + dist/Spotube-windows-x86_64-setup.exe + - os: macos-latest + platform: ios + files: | + Spotube-iOS.ipa + - os: macos-14 + platform: macos + files: | + build/Spotube-macos-universal.dmg + build/Spotube-macos-universal.pkg + runs-on: ${{matrix.os}} steps: - uses: actions/checkout@v4 - uses: subosito/flutter-action@v2.12.0 with: cache: true + cache-key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.yaml') }} flutter-version: ${{ env.FLUTTER_VERSION }} - - - name: Install Dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev make python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse xmlstarlet - - - name: Replace pubspec version and BUILD_VERSION Env (nightly) - if: ${{ inputs.channel == 'nightly' }} - run: | - curl -sS https://webi.sh/yq | sh - yq -i '.version |= sub("\+\d+", "+${{ inputs.channel }}.")' pubspec.yaml - yq -i '.version += strenv(GITHUB_RUN_NUMBER)' pubspec.yaml - echo "BUILD_VERSION=${{ inputs.version }}+${{ inputs.channel }}.${{ github.run_number }}" >> $GITHUB_ENV - - - name: BUILD_VERSION Env (stable) - if: ${{ inputs.channel == 'stable' }} - run: | - echo "BUILD_VERSION=${{ inputs.version }}" >> $GITHUB_ENV - - - name: Create Stable .env - if: ${{ inputs.channel == 'stable' }} - run: echo '${{ secrets.DOTENV_RELEASE }}' > .env - - - name: Create Nightly .env - if: ${{ inputs.channel == 'nightly' }} - run: echo '${{ secrets.DOTENV_NIGHTLY }}' > .env - - - name: Generate Secrets + - name: Setup Java + if: ${{matrix.platform == 'android'}} + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '17' + cache: 'gradle' + check-latest: true + - name: Set up QEMU + if: ${{matrix.platform == 'linux_arm'}} + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + if: ${{matrix.platform == 'linux_arm'}} + uses: docker/setup-buildx-action@v3 + - name: Setup Rust toolchain + if: ${{matrix.platform != 'linux_arm'}} + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + + - name: Install ${{matrix.platform}} dependencies run: | flutter pub get - dart run build_runner build --delete-conflicting-outputs --enable-experiment=records,patterns + dart cli/cli.dart install-dependencies --platform=${{matrix.platform}} - name: Sign Apk + if: ${{matrix.platform == 'android'}} run: | echo '${{ secrets.KEYSTORE }}' | base64 --decode > android/app/upload-keystore.jks echo '${{ secrets.KEY_PROPERTIES }}' > android/key.properties - - - name: Build Apk - run: | - flutter build apk --flavor ${{ inputs.channel }} - mv build/app/outputs/flutter-apk/app-${{ inputs.channel }}-release.apk build/Spotube-android-all-arch.apk - - - name: Build Playstore AppBundle - run: | - echo 'ENABLE_UPDATE_CHECK=0' >> .env - dart run build_runner build --delete-conflicting-outputs --enable-experiment=records,patterns - export MANIFEST=android/app/src/main/AndroidManifest.xml - xmlstarlet ed -d '//meta-data[@android:name="com.google.android.gms.car.application"]' $MANIFEST > $MANIFEST.tmp - mv $MANIFEST.tmp $MANIFEST - flutter build appbundle --flavor ${{ inputs.channel }} - mv build/app/outputs/bundle/${{ inputs.channel }}Release/app-${{ inputs.channel }}-release.aab build/Spotube-playstore-all-arch.aab - - - - uses: actions/upload-artifact@v3 - with: - if-no-files-found: error - name: Spotube-Release-Binaries - path: | - build/Spotube-android-all-arch.apk - build/Spotube-playstore-all-arch.aab - - - name: Debug With SSH When fails - if: ${{ failure() && inputs.debug && inputs.channel == 'nightly' }} - uses: mxschmitt/action-tmate@v3 - with: - limit-access-to-actor: true - - macos: - - runs-on: macos-14 - steps: - - uses: actions/checkout@v4 - - uses: subosito/flutter-action@v2.12.0 - with: - cache: true - flutter-version: ${{ env.FLUTTER_VERSION }} - - - name: Replace pubspec version and BUILD_VERSION Env (nightly) - if: ${{ inputs.channel == 'nightly' }} - run: | - brew install yq - yq -i '.version |= sub("\+\d+", "+${{ inputs.channel }}.")' pubspec.yaml - yq -i '.version += strenv(GITHUB_RUN_NUMBER)' pubspec.yaml - echo "BUILD_VERSION=${{ inputs.version }}+${{ inputs.channel }}.${{ github.run_number }}" >> $GITHUB_ENV - - - name: BUILD_VERSION Env (stable) - if: ${{ inputs.channel == 'stable' }} - run: | - echo "BUILD_VERSION=${{ inputs.version }}" >> $GITHUB_ENV - - - name: Create Stable .env - if: ${{ inputs.channel == 'stable' }} - run: echo '${{ secrets.DOTENV_RELEASE }}' > .env - - - name: Create Nightly .env - if: ${{ inputs.channel == 'nightly' }} - run: echo '${{ secrets.DOTENV_NIGHTLY }}' > .env - - - name: Generate Secrets - run: | - dart pub global activate flutter_distributor - flutter pub get - dart run build_runner build --delete-conflicting-outputs --enable-experiment=records,patterns - - - name: Build Macos App - run: | - flutter config --enable-macos-desktop - flutter build macos - du -sh build/macos/Build/Products/Release/spotube.app - - - name: Package Macos App + + - name: Unessary hosted tools + if: ${{matrix.platform == 'linux_arm'}} run: | - brew install python-setuptools - npm install -g appdmg - mkdir -p build/${{ env.BUILD_VERSION }} - appdmg appdmg.json build/Spotube-macos-universal.dmg - flutter_distributor package --platform=macos --targets pkg --skip-clean - mv dist/**/spotube-*-macos.pkg build/Spotube-macos-universal.pkg - + sudo rm -rf /usr/share/dotnet + + - name: Build ${{matrix.platform}} binaries + run: dart cli/cli.dart build ${{matrix.platform}} + env: + CHANNEL: ${{inputs.channel}} + DOTENV: ${{secrets.DOTENV_RELEASE}} + - uses: actions/upload-artifact@v3 with: if-no-files-found: error name: Spotube-Release-Binaries - path: | - build/Spotube-macos-universal.dmg - build/Spotube-macos-universal.pkg + path: ${{matrix.files}} - name: Debug With SSH When fails if: ${{ failure() && inputs.debug && inputs.channel == 'nightly' }} @@ -348,70 +122,12 @@ jobs: with: limit-access-to-actor: true - iOS: - runs-on: macos-14 - steps: - - uses: actions/checkout@v4 - - uses: subosito/flutter-action@v2.10.0 - with: - cache: true - flutter-version: ${{ env.FLUTTER_VERSION }} - - - name: Replace pubspec version and BUILD_VERSION Env (nightly) - if: ${{ inputs.channel == 'nightly' }} - run: | - brew install yq - yq -i '.version |= sub("\+\d+", "+${{ inputs.channel }}.")' pubspec.yaml - yq -i '.version += strenv(GITHUB_RUN_NUMBER)' pubspec.yaml - echo "BUILD_VERSION=${{ inputs.version }}+${{ inputs.channel }}.${{ github.run_number }}" >> $GITHUB_ENV - - - name: BUILD_VERSION Env (stable) - if: ${{ inputs.channel == 'stable' }} - run: | - echo "BUILD_VERSION=${{ inputs.version }}" >> $GITHUB_ENV - - - name: Create Stable .env - if: ${{ inputs.channel == 'stable' }} - run: echo '${{ secrets.DOTENV_RELEASE }}' > .env - - - name: Create Nightly .env - if: ${{ inputs.channel == 'nightly' }} - run: echo '${{ secrets.DOTENV_NIGHTLY }}' > .env - - - name: Generate Secrets - run: | - flutter pub get - dart run build_runner build --delete-conflicting-outputs --enable-experiment=records,patterns - - - name: Build iOS iPA - run: | - flutter build ios --release --no-codesign --flavor ${{ inputs.channel }} - ln -sf ./build/ios/iphoneos Payload - zip -r9 Spotube-iOS.ipa Payload/${{ inputs.channel }}.app - - - uses: actions/upload-artifact@v3 - with: - if-no-files-found: error - name: Spotube-Release-Binaries - path: | - Spotube-iOS.ipa - - - name: Debug With SSH When fails - if: ${{ failure() && inputs.debug && inputs.channel == 'nightly' }} - uses: mxschmitt/action-tmate@v3 - with: - limit-access-to-actor: true - upload: runs-on: ubuntu-latest - needs: - - windows - - linux - - android - - macos - - iOS + - build_platform steps: + - uses: actions/checkout@v4 - uses: actions/download-artifact@v3 with: name: Spotube-Release-Binaries @@ -426,6 +142,10 @@ jobs: md5sum Spotube-Release-Binaries/* >> RELEASE.md5sum sha256sum Spotube-Release-Binaries/* >> RELEASE.sha256sum sed -i 's|Spotube-Release-Binaries/||' RELEASE.sha256sum RELEASE.md5sum + + - name: Extract pubspec version + run: | + echo "PUBSPEC_VERSION=$(grep -oP 'version:\s*\K[^+]+(?=\+)' pubspec.yaml)" >> $GITHUB_ENV - uses: actions/upload-artifact@v3 with: @@ -440,7 +160,7 @@ jobs: uses: ncipollo/release-action@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - tag: v${{ inputs.version }} # mind the "v" prefix + tag: v${{ env.PUBSPEC_VERSION }} # mind the "v" prefix omitBodyDuringUpdate: true omitNameDuringUpdate: true omitPrereleaseDuringUpdate: true @@ -458,3 +178,8 @@ jobs: omitPrereleaseDuringUpdate: true allowUpdates: true artifacts: Spotube-Release-Binaries/*,RELEASE.sha256sum,RELEASE.md5sum + body: | + Build Number: ${{github.run_number}} + + Nightly release includes newest features but may contain bugs + It is preferred to use the stable version unless you know what you're doing diff --git a/.gitignore b/.gitignore index 96d810871..4f9ebc281 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,5 @@ android/key.properties .fvm/flutter_sdk **/pb_data + +tm.json diff --git a/.metadata b/.metadata index 082985ad4..828f2c0ad 100644 --- a/.metadata +++ b/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: eb6d86ee27deecba4a83536aa20f366a6044895c - channel: stable + revision: "300451adae589accbece3490f4396f10bdf15e6e" + channel: "stable" project_type: app @@ -13,11 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - - platform: macos - create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c - base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c + create_revision: 300451adae589accbece3490f4396f10bdf15e6e + base_revision: 300451adae589accbece3490f4396f10bdf15e6e + - platform: windows + create_revision: 300451adae589accbece3490f4396f10bdf15e6e + base_revision: 300451adae589accbece3490f4396f10bdf15e6e # User provided section diff --git a/.vscode/settings.json b/.vscode/settings.json index 29c5ba4e0..0ec6ca766 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,6 +17,7 @@ "songlink", "speechiness", "Spotube", + "titlebar", "winget" ], "editor.formatOnSave": true, @@ -24,5 +25,6 @@ "explorer.fileNesting.patterns": { "pubspec.yaml": "pubspec.lock,analysis_options.yaml,.packages,.flutter-plugins,.flutter-plugins-dependencies,flutter_launcher_icons*.yaml,flutter_native_splash*.yaml", "README.md": "LICENSE,CODE_OF_CONDUCT.md,CONTRIBUTING.md,SECURITY.md,CONTRIBUTION.md,CHANGELOG.md,PRIVACY_POLICY.md", + "*.dart": "${capture}.g.dart,${capture}.freezed.dart", } } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 21ca4b693..7e4345740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,91 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -## [3.6.0-0](https://github.com/krtirtho/spotube/compare/v3.5.0...v3.6.0-0) (2024-04-15) +## [3.8.0](https://github.com/krtirtho/spotube/compare/v3.7.1...v3.8.0) (2024-06-06) + +### Features + +- translations: make state page's hard coded strings translatable (#1719) +- discord: add listening activity type +- discord: album art, playing time and play pause support (#1765) +- linux: Use XDG_STATE_HOME to storage logs (#1675) +- discord rpc for macOS, windows-arm64 and linux-arm64 (#1713) +- desktop: implement webview based login +- stats: add lazy loading support + +### Bug Fixes + +- translations: fix Russian translations (#1696) +- ios: permission exception +- linux: tray icon wrong name for flatpak +- windows: app crashes when no internet +- windows: local tracks plays but disabled playback controls +- go to track album shows up for local tracks +- local track metadata timeout +- windows: window stretching #1553 +- android: app getting killed from background +- linux: OS Media control not working for Flatpak #1627 +- incorrect datatype used for MPRIS position property #1521 +- Too many artists for a track causing overflows +- playlist share button does not work #1639 +- unescape html escape values #1300 +- lyrics page doesn't scroll to top after song ends #885 +- changed source doesn't get saved and uses the wrong once again +- null exception in album page navigated from /home +- popup menu item opacity +- linux: change app id in flatpak environment + + +## [3.7.1](https://github.com/krtirtho/spotube/compare/v3.7.0...v3.7.1) (2024-06-06) + + +### Bug Fixes + +* alternative sources not showing up for SongLink matched results ([37d002d](https://github.com/krtirtho/spotube/commit/37d002d133cacb3a34884713ac8f6637694af57c)) +* **android:** Media Controls not working above Android 14 [#1561](https://github.com/krtirtho/spotube/issues/1561) ([3394c1b](https://github.com/krtirtho/spotube/commit/3394c1b0574e44dc624b2b2f0bf32f343ae9f049)) +* browse anonymously button takes to wrong route ([73c5b30](https://github.com/krtirtho/spotube/commit/73c5b30b63a4c82bb7ad5b52bc10c5594566a800)) +* **desktop:** titlebar drag to move not working ([5f280a1](https://github.com/krtirtho/spotube/commit/5f280a19f4d5f8882ae2ff60c6cc595ded7a5a1d)) +* **desktop:** window is not centered ([47f98b9](https://github.com/krtirtho/spotube/commit/47f98b98aafab9b426733ed44cab2be8a646a98e)) +* **ios:** download not working [#1575](https://github.com/krtirtho/spotube/issues/1575) ([6591ec0](https://github.com/krtirtho/spotube/commit/6591ec0e1b441dd8fd535eace19a58c7749389ca)) +* **linux:** application window not visible after launch ([8fc44ed](https://github.com/krtirtho/spotube/commit/8fc44ed6550e8b2b804991ff82df08afb1c94ca8)) +* local track not showing up in queue ([d82261c](https://github.com/krtirtho/spotube/commit/d82261cb25ece63f85af0e40216cf32dccdc9dd5)) +* use weak match for Jiosaavn fallback to improve matching ([6cb2986](https://github.com/krtirtho/spotube/commit/6cb29868d2030b5e9312863c17e8f24889942e24)) +* **windows:** media controls not showing up [#1542](https://github.com/krtirtho/spotube/issues/1542) ([d7d864f](https://github.com/krtirtho/spotube/commit/d7d864ff2bc937675a544a7edf645c5148ec836a)) +* **windows:** revert Flutter version to 3.19.6 to avoid distortion [#1553](https://github.com/krtirtho/spotube/issues/1553) ([982cf0b](https://github.com/krtirtho/spotube/commit/982cf0bd435638fa20f17ef527fe21d031b5ffaf)) + +## [3.7.0](https://github.com/krtirtho/spotube/compare/v3.6.0...v3.7.0) (2024-06-03) + + +### Features + +* local library folder cards ([fc5bfa0](https://github.com/krtirtho/spotube/commit/fc5bfa089ce2f46ab786565d6750564d704ee7e0)) +* Local music library ([#1479](https://github.com/krtirtho/spotube/issues/1479)) ([22caa81](https://github.com/krtirtho/spotube/commit/22caa818f4ac31626aaff6952e43512b42237d00)) +* personalized stats based on local music history ([#1522](https://github.com/krtirtho/spotube/issues/1522)) ([82307bc](https://github.com/krtirtho/spotube/commit/82307bc030035b03ab1b8d8ec7b24da19a866b12)) +* play initially available tracks of playlist/album immediately and fetch rest in background [#670](https://github.com/krtirtho/spotube/issues/670) ([02acbd9](https://github.com/krtirtho/spotube/commit/02acbd93271145dde365f6c547e0d9d902be65f1)) +* **player:** add volume slider floating label showing percentage ([#1445](https://github.com/krtirtho/spotube/issues/1445)) ([8fad225](https://github.com/krtirtho/spotube/commit/8fad2251b3536e9468e0fb193939ead98bad3bc6)), closes [#1310](https://github.com/krtirtho/spotube/issues/1310) [#1311](https://github.com/krtirtho/spotube/issues/1311) [#1082](https://github.com/krtirtho/spotube/issues/1082) [#1171](https://github.com/krtirtho/spotube/issues/1171) [#1082](https://github.com/krtirtho/spotube/issues/1082) [#1082](https://github.com/krtirtho/spotube/issues/1082) +* **translations:** add Basque translation ([#1493](https://github.com/krtirtho/spotube/issues/1493)) ([dbc1c45](https://github.com/krtirtho/spotube/commit/dbc1c452dd53153c61589f956ea9836cea7bf2bb)) +* **translations:** add Finnish translations ([#1449](https://github.com/krtirtho/spotube/issues/1449)) ([edc997e](https://github.com/krtirtho/spotube/commit/edc997e7470ce17f60c96b8198dc8851cbf21f18)), closes [#1310](https://github.com/krtirtho/spotube/issues/1310) [#1311](https://github.com/krtirtho/spotube/issues/1311) [#1082](https://github.com/krtirtho/spotube/issues/1082) [#1171](https://github.com/krtirtho/spotube/issues/1171) [#1082](https://github.com/krtirtho/spotube/issues/1082) [#1082](https://github.com/krtirtho/spotube/issues/1082) +* **translations:** add georgian language ([#1450](https://github.com/krtirtho/spotube/issues/1450)) ([1e7f0e1](https://github.com/krtirtho/spotube/commit/1e7f0e1fe71e0a8d86614fc884861f8791469112)) +* **translations:** add Indonesian translation ([#1426](https://github.com/krtirtho/spotube/issues/1426)) ([0280654](https://github.com/krtirtho/spotube/commit/0280654bb6bad373aee521f5a866228d2d38f038)), closes [#1310](https://github.com/krtirtho/spotube/issues/1310) [#1311](https://github.com/krtirtho/spotube/issues/1311) [#1082](https://github.com/krtirtho/spotube/issues/1082) [#1171](https://github.com/krtirtho/spotube/issues/1171) [#1082](https://github.com/krtirtho/spotube/issues/1082) [#1082](https://github.com/krtirtho/spotube/issues/1082) +* **translations:** Improve tr locales ([#1419](https://github.com/krtirtho/spotube/issues/1419)) ([bf45681](https://github.com/krtirtho/spotube/commit/bf45681deb951c772bf6ca05e213c949c04bded1)), closes [#1310](https://github.com/krtirtho/spotube/issues/1310) [#1311](https://github.com/krtirtho/spotube/issues/1311) [#1082](https://github.com/krtirtho/spotube/issues/1082) [#1171](https://github.com/krtirtho/spotube/issues/1171) [#1082](https://github.com/krtirtho/spotube/issues/1082) [#1082](https://github.com/krtirtho/spotube/issues/1082) +* upgrade to Flutter 3.22.0 ([71341ec](https://github.com/krtirtho/spotube/commit/71341ec0bda6ed985b43836712075b97a2cf8bac)) + + +### Bug Fixes + +* fallback to LRCLIB when lyrics line less than 6 lines [#1461](https://github.com/krtirtho/spotube/issues/1461) ([9aea354](https://github.com/krtirtho/spotube/commit/9aea35468fa7cd176ddc8810b37b90c2d8246931)) +* **linux:** tray icon not showing [#541](https://github.com/krtirtho/spotube/issues/541) ([7ac7917](https://github.com/krtirtho/spotube/commit/7ac791757abb30f40374c169c4211916287bb3f3)) +* local track not showing up in queue ([d82261c](https://github.com/krtirtho/spotube/commit/d82261cb25ece63f85af0e40216cf32dccdc9dd5)) +* **macos:** Logs directory not created by default [#1353](https://github.com/krtirtho/spotube/issues/1353) ([4ca8939](https://github.com/krtirtho/spotube/commit/4ca893950b07f678acf7db690112c47d21e54782)) +* **playback:** skipping tracks with unplayable sources instead of falling back [#1492](https://github.com/krtirtho/spotube/issues/1492) ([c607a33](https://github.com/krtirtho/spotube/commit/c607a330ed279dfbebe8d4bd325745ac6301a58f)) +* **search:** load more button not working [#1417](https://github.com/krtirtho/spotube/issues/1417) ([7e07c2e](https://github.com/krtirtho/spotube/commit/7e07c2e1985da7ccb96b1fac2ecd703720068d26)) +* some text are garbled in different parts of the app [#1463](https://github.com/krtirtho/spotube/issues/1463) [#1505](https://github.com/krtirtho/spotube/issues/1505) ([d2683c5](https://github.com/krtirtho/spotube/commit/d2683c52d81d807be6ff72f15b8e9eb18181e211)) +* spotify friends and user profile icon (mobile) showing when not authenticated [#1410](https://github.com/krtirtho/spotube/issues/1410) ([9bccbc9](https://github.com/krtirtho/spotube/commit/9bccbc93c63dd34f6e15ff68c276976ecd1d9a33)) +* **updater:** dead link ([#1408](https://github.com/krtirtho/spotube/issues/1408)) ([6907f9c](https://github.com/krtirtho/spotube/commit/6907f9c756d8f49aadb1b23a2a1dc8bf7d658dc0)), closes [#1310](https://github.com/krtirtho/spotube/issues/1310) [#1311](https://github.com/krtirtho/spotube/issues/1311) [#1082](https://github.com/krtirtho/spotube/issues/1082) [#1171](https://github.com/krtirtho/spotube/issues/1171) [#1082](https://github.com/krtirtho/spotube/issues/1082) [#1082](https://github.com/krtirtho/spotube/issues/1082) +* windows SSL Certificate error breaking login [#905](https://github.com/krtirtho/spotube/issues/905) ([#1474](https://github.com/krtirtho/spotube/issues/1474)) ([937a706](https://github.com/krtirtho/spotube/commit/937a706ac9c0e59943b2609e5cc398dcdbed2344)), closes [#1468](https://github.com/krtirtho/spotube/issues/1468) +* **windows:** installer tries to install in current directory ([c3c9fc5](https://github.com/krtirtho/spotube/commit/c3c9fc544c68b3d897dd7241a61cab7a199b4539)) + +## [3.6.0](https://github.com/krtirtho/spotube/compare/v3.5.0...v3.6.0) (2024-04-15) ### Features diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index e859f9e6f..d4746a1a9 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -32,7 +32,7 @@ All types of contributions are encouraged and valued. See the [Table of Contents This project and everyone participating in it is governed by the [Spotube Code of Conduct](https://github.com/KRTirtho/spotube/blob/master/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior -to <>. +to krtirtho@gmail.com. ## I Have a Question @@ -123,16 +123,16 @@ Do the following: - Install Development dependencies in linux - Debian (>=12/Bookworm)/Ubuntu ```bash - $ apt-get install mpv libmpv-dev libappindicator3-1 gir1.2-appindicator3-0.1 libappindicator3-dev libsecret-1-0 libjsoncpp25 libsecret-1-dev libjsoncpp-dev libnotify-bin libnotify-dev avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan + $ apt-get install mpv libmpv-dev libappindicator3-1 gir1.2-appindicator3-0.1 libappindicator3-dev libsecret-1-0 libjsoncpp25 libsecret-1-dev libjsoncpp-dev libnotify-bin libnotify-dev avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan libwebkit2gtk-4.1-0 libwebkit2gtk-4.1-dev libsoup-3.0-0 libsoup-3.0-dev ``` - Use `libjsoncpp1` instead of `libjsoncpp25` (for Ubuntu < 22.04) - Arch/Manjaro ```bash - yay -S mpv libappindicator-gtk3 libsecret jsoncpp libnotify avahi nss-mdns mdns-scan + yay -S mpv libappindicator-gtk3 libsecret jsoncpp libnotify avahi nss-mdns mdns-scan webkit2gtk-4.1 libsoup3 ``` - Fedora ```bash - dnf install mpv mpv-devel libappindicator-gtk3 libappindicator-gtk3-devel libsecret libsecret-devel jsoncpp jsoncpp-devel libnotify libnotify-devel avahi mdns-scan nss-mdns + dnf install mpv mpv-devel libappindicator-gtk3 libappindicator-gtk3-devel libsecret libsecret-devel jsoncpp jsoncpp-devel libnotify libnotify-devel avahi mdns-scan nss-mdns webkit2gtk4.1 webkit2gtk4.1-devel libsoup3 libsoup3-devel ``` - Clone the Repo - Create a `.env` in root of the project following the `.env.example` template diff --git a/README.md b/README.md index f2666fbc2..71c879bac 100644 --- a/README.md +++ b/README.md @@ -210,116 +210,116 @@ If you are concerned, you can [read the reason of choosing this license](https:/ 1. [LastFM](https://last.fm) - Last.fm is a music streaming and discovery platform that helps users discover and share new music. It tracks users' music listening habits across many devices and platforms. ### Dependencies +1. [app_links](https://github.com/llfbandit/app_links) - Android App Links, Deep Links, iOs Universal Links and Custom URL schemes handler for Flutter (desktop included). 1. [args](https://pub.dev/packages/args) - Library for defining parsers for parsing raw command-line arguments into a set of options and values using GNU and POSIX style options. 1. [async](https://pub.dev/packages/async) - Utility functions and classes related to the 'dart:async' library. +1. [audio_service_mpris](https://github.com/bdrazhzhov/audio-service-mpris) - audio_service platform interface supporting Media Player Remote Interfacing Specification. 1. [audio_service](https://pub.dev/packages/audio_service) - Flutter plugin to play audio in the background while the screen is off. 1. [audio_session](https://github.com/ryanheise/audio_session) - Sets the iOS audio session category and Android audio attributes for your app, and manages your app's audio focus, mixing and ducking behaviour. 1. [auto_size_text](https://github.com/leisim/auto_size_text) - Flutter widget that automatically resizes text to fit perfectly within its bounds. +1. [bonsoir](https://bonsoir.skyost.eu) - A Zeroconf library that allows you to discover network services and to broadcast your own. Based on Apple Bonjour and Android NSD. +1. [build_runner](https://pub.dev/packages/build_runner) - A build system for Dart code generation and modular compilation. 1. [buttons_tabbar](https://afonsoraposo.com) - A Flutter package that implements a TabBar where each label is a toggle button. 1. [cached_network_image](https://github.com/Baseflow/flutter_cached_network_image) - Flutter library to load and cache network images. Can also be used with placeholder and error widgets. 1. [catcher_2](https://github.com/ThexXTURBOXx/catcher_2) - Plugin for error catching which provides multiple handlers for dealing with errors when they are not caught by the developer. 1. [collection](https://pub.dev/packages/collection) - Collections and utilities functions and classes related to collections. -1. [cupertino_icons](https://pub.dev/packages/cupertino_icons) - Default icons asset for Cupertino widgets based on Apple styled icons +1. [crypto](https://pub.dev/packages/crypto) - Implementations of SHA, MD5, and HMAC cryptographic functions. 1. [curved_navigation_bar](https://github.com/rafalbednarczuk/curved_navigation_bar) - Stunning Animating Curved Shape Navigation Bar. Adjustable color, background color, animation curve, animation duration. +1. [custom_lint](https://pub.dev/packages/custom_lint) - Lint rules are a powerful way to improve the maintainability of a project. Custom Lint allows package authors and developers to easily write custom lint rules. +1. [dart_discord_rpc](https://github.com/alexmercerind/dart_discord_rpc) - Discord Rich Presence for Flutter & Dart apps & games. 1. [dbus](https://github.com/canonical/dbus.dart) - A native Dart implementation of the D-Bus message bus client. This package allows Dart applications to directly access services on the Linux desktop. 1. [device_info_plus](https://plus.fluttercommunity.dev/) - Flutter plugin providing detailed information about the device (make, model, etc.), and Android or iOS version the app is running on. -1. [device_preview](https://github.com/aloisdeniel/flutter_device_preview) - Approximate how your Flutter app looks and performs on another device. 1. [dio](https://github.com/cfug/dio) - A powerful HTTP networking package,supports Interceptors,Aborting and canceling a request,Custom adapters, Transformers, etc. 1. [disable_battery_optimization](https://github.com/pvsvamsi/Disable-Battery-Optimizations) - Flutter plugin to check and disable battery optimizations. Also shows custom steps to disable the optimizations in devices like mi, xiaomi, samsung, oppo, huawei, oneplus etc +1. [draggable_scrollbar](https://github.com/fluttercommunity/flutter-draggable-scrollbar) - A scrollbar that can be dragged for quickly navigation through a vertical list. Additional option is showing label next to scrollthumb with information about current item. 1. [duration](https://github.com/desktop-dart/duration) - Utilities to make working with 'Duration's easier. Formats duration in human readable form and also parses duration in human readable form to Dart's Duration. +1. [envied_generator](https://github.com/petercinibulk/envied) - Generator for the Envied package. See https://pub.dev/packages/envied. 1. [envied](https://github.com/petercinibulk/envied) - Explicitly reads environment variables into a dart file from a .env file for more security and faster start up times. +1. [file_picker](https://github.com/miguelpruivo/plugins_flutter_file_picker) - A package that allows you to use a native file explorer to pick single or multiple absolute file paths, with extension filtering support. 1. [file_selector](https://pub.dev/packages/file_selector) - Flutter plugin for opening and saving files, or selecting directories, using native file selection UI. 1. [fluentui_system_icons](https://github.com/microsoft/fluentui-system-icons/tree/main) - Fluent UI System Icons are a collection of familiar, friendly and modern icons from Microsoft. +1. [flutter_broadcasts](https://pub.dev/packages/flutter_broadcasts) - A plugin for sending and receiving broadcasts with Android intents and iOS notifications. 1. [flutter_cache_manager](https://github.com/Baseflow/flutter_cache_manager/tree/develop/flutter_cache_manager) - Generic cache manager for flutter. Saves web files on the storages of the device and saves the cache info using sqflite. 1. [flutter_displaymode](https://github.com/ajinasokan/flutter_displaymode) - A Flutter plugin to set display mode (resolution, refresh rate) on Android platform. Allows to enable high refresh rate on supported devices. 1. [flutter_feather_icons](https://github.com/muj-programmer/flutter_feather_icons) - Feather is a collection of simply beautiful open source icons. Each icon is designed on a 24x24 grid with an emphasis on simplicity, consistency and usability. +1. [flutter_gen_runner](https://github.com/FlutterGen/flutter_gen) - The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs. 1. [flutter_hooks](https://github.com/rrousselGit/flutter_hooks) - A flutter implementation of React hooks. It adds a new kind of widget with enhanced code reuse. 1. [flutter_inappwebview](https://inappwebview.dev/) - A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. +1. [flutter_launcher_icons](https://github.com/fluttercommunity/flutter_launcher_icons) - A package which simplifies the task of updating your Flutter app's launcher icon. +1. [flutter_lints](https://pub.dev/packages/flutter_lints) - Recommended lints for Flutter apps, packages, and plugins to encourage good coding practices. 1. [flutter_native_splash](https://pub.dev/packages/flutter_native_splash) - Customize Flutter's default white native splash screen with background color and splash image. Supports dark mode, full screen, and more. 1. [flutter_riverpod](https://riverpod.dev) - A reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze. 1. [flutter_secure_storage](https://pub.dev/packages/flutter_secure_storage) - Flutter Secure Storage provides API to store data in secure storage. Keychain is used in iOS, KeyStore based solution is used in Android. +1. [flutter_sharing_intent](https://github.com/bhagat-techind/flutter_sharing_intent.git) - A flutter plugin that allow flutter apps to receive photos, videos, text, urls or any other file types from another app. 1. [flutter_svg](https://pub.dev/packages/flutter_svg) - An SVG rendering and widget library for Flutter, which allows painting and displaying Scalable Vector Graphics 1.1 files. 1. [form_validator](https://github.com/TheMisir/form-validator) - Simplest form validation library for flutter's form field widgets +1. [freezed_annotation](https://pub.dev/packages/freezed_annotation) - Annotations for the freezed code-generator. This package does nothing without freezed too. +1. [freezed](https://pub.dev/packages/freezed) - Code generation for immutable classes that has a simple syntax/API without compromising on the features. 1. [fuzzywuzzy](https://github.com/sphericalkat/dart-fuzzywuzzy) - An implementation of the popular fuzzywuzzy package in Dart, to suit all your fuzzy string matching/searching needs! +1. [gap](https://github.com/letsar/gap) - Flutter widgets for easily adding gaps inside Flex widgets such as Columns and Rows or scrolling views. 1. [go_router](https://pub.dev/packages/go_router) - A declarative router for Flutter based on Navigation 2 supporting deep linking, data-driven routes and more 1. [google_fonts](https://pub.dev/packages/google_fonts) - A Flutter package to use fonts from fonts.google.com. Supports HTTP fetching, caching, and asset bundling. -1. [hive](https://github.com/hivedb/hive/tree/master/hive) - Lightweight and blazing fast key-value database written in pure Dart. Strongly encrypted using AES-256. 1. [hive_flutter](https://github.com/hivedb/hive/tree/master/hive_flutter) - Extension for Hive. Makes it easier to use Hive in Flutter apps. +1. [hive_generator](https://github.com/hivedb/hive/tree/master/hive_generator) - Extension for Hive. Automatically generates TypeAdapters to store any class. +1. [hive](https://github.com/hivedb/hive/tree/master/hive) - Lightweight and blazing fast key-value database written in pure Dart. Strongly encrypted using AES-256. 1. [hooks_riverpod](https://riverpod.dev) - A reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze. +1. [html_unescape](https://github.com/filiph/html_unescape) - A small library for un-escaping HTML. Supports all Named Character References, Decimal Character References and Hexadecimal Character References. 1. [html](https://pub.dev/packages/html) - APIs for parsing and manipulating HTML content outside the browser. 1. [http](https://pub.dev/packages/http) - A composable, multi-platform, Future-based API for HTTP requests. 1. [image_picker](https://pub.dev/packages/image_picker) - Flutter plugin for selecting images from the Android and iOS image library, and taking new pictures with the camera. 1. [intl](https://pub.dev/packages/intl) - Contains code to deal with internationalized/localized messages, date and number formatting and parsing, bi-directional text, and other internationalization issues. 1. [introduction_screen](https://pub.dev/packages/introduction_screen) - Introduction/Onboarding package for flutter app with some customizations possibilities +1. [io](https://pub.dev/packages/io) - Utilities for the Dart VM Runtime including support for ANSI colors, file copying, and standard exit code values. +1. [jiosaavn](https://github.com/KRTirtho/jiosaavn) - Unofficial API client for jiosaavn.com 1. [json_annotation](https://pub.dev/packages/json_annotation) - Classes and helper functions that support JSON code generation via the `json_serializable` package. +1. [json_serializable](https://pub.dev/packages/json_serializable) - Automatically generate code for converting to and from JSON by annotating Dart classes. +1. [local_notifier](https://github.com/leanflutter/local_notifier) - This plugin allows Flutter desktop apps to displaying local notifications. 1. [logger](https://pub.dev/packages/logger) - Small, easy to use and extensible logger which prints beautiful logs. -1. [media_kit](https://github.com/media-kit/media-kit) - A cross-platform video player & audio player for Flutter & Dart. Performant, stable, feature-proof & modular. +1. [lrc](https://pub.dev/packages/lrc) - A Dart-only package that creates, parses, and handles LRC, which is a format that stores song lyrics. 1. [media_kit_libs_audio](https://github.com/media-kit/media-kit.git) - package:media_kit audio (only) playback native libraries for all platforms. +1. [media_kit](https://github.com/media-kit/media-kit) - A cross-platform video player & audio player for Flutter & Dart. Performant, stable, feature-proof & modular. 1. [metadata_god](https://github.com/KRTirtho/metadata_god) - Plugin for retrieving and writing audio tags/metadata from audio files 1. [mime](https://pub.dev/packages/mime) - Utilities for handling media (MIME) types, including determining a type from a file extension and file contents. 1. [package_info_plus](https://plus.fluttercommunity.dev/) - Flutter plugin for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android. 1. [palette_generator](https://pub.dev/packages/palette_generator) - Flutter package for generating palette colors from a source image. -1. [path](https://pub.dev/packages/path) - A string-based path manipulation library. All of the path operations you know and love, with solid support for Windows, POSIX (Linux and Mac OS X), and the web. 1. [path_provider](https://pub.dev/packages/path_provider) - Flutter plugin for getting commonly used locations on host platform file systems, such as the temp and app data directories. +1. [path](https://pub.dev/packages/path) - A string-based path manipulation library. All of the path operations you know and love, with solid support for Windows, POSIX (Linux and Mac OS X), and the web. 1. [permission_handler](https://pub.dev/packages/permission_handler) - Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions. +1. [piped_client](https://github.com/KRTirtho/piped_client) - API Client for piped.video 1. [popover](https://github.com/minikin/popover) - A popover is a transient view that appears above other content onscreen when you tap a control or in an area. +1. [process_run](https://github.com/tekartik/process_run.dart/blob/master/packages/process_run) - Process run helpers for Linux/Win/Mac and which like feature for finding executables. +1. [pub_api_client](https://github.com/leoafarias/pub_api_client) - An API Client for Pub to interact with public package information. +1. [pubspec_parse](https://pub.dev/packages/pubspec_parse) - Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. +1. [riverpod_lint](https://riverpod.dev) - Riverpod_lint is a developer tool for users of Riverpod, designed to help stop common issues and simplify repetitive tasks. +1. [scrobblenaut](https://github.com/Nebulino/Scrobblenaut) - A deadly simple LastFM API Wrapper for Dart. So deadly simple that it's gonna hit the mark. 1. [scroll_to_index](https://github.com/quire-io/scroll-to-index) - Scroll to a specific child of any scrollable widget in Flutter -1. [sidebarx](https://github.com/Frezyx/sidebarx) - flutter multiplatform navigation sidebar / side navigationbar / drawer widget 1. [shared_preferences](https://pub.dev/packages/shared_preferences) - Flutter plugin for reading and writing simple key-value pairs. Wraps NSUserDefaults on iOS and SharedPreferences on Android. +1. [shelf_router](https://pub.dev/packages/shelf_router) - A convenient request router for the shelf web-framework, with support for URL-parameters, nested routers and routers generated from source annotations. +1. [shelf_web_socket](https://pub.dev/packages/shelf_web_socket) - A shelf handler that wires up a listener for every connection. +1. [shelf](https://pub.dev/packages/shelf) - A model for web server middleware that encourages composition and easy reuse. +1. [sidebarx](https://github.com/Frezyx/sidebarx) - flutter multiplatform navigation sidebar / side navigationbar / drawer widget +1. [simple_icons](https://teavelopment.com/) - The Simple Icon pack available as Flutter Icons. Provides over 1500 Free SVG icons for popular brands. 1. [skeleton_text](https://github.com/101Loop/Skeleton-Text) - A package that provides an easy way to add skeleton text loading animation in Flutter project. This project is a part of 101Loop community. +1. [skeletonizer](https://github.com/Milad-Akarie/skeletonizer) - Converts already built widgets into skeleton loaders with no extra effort. +1. [sliver_tools](https://github.com/Kavantix) - A set of useful sliver tools that are missing from the flutter framework 1. [smtc_windows](https://github.com/KRTirtho/smtc_windows) - Windows `SystemMediaTransportControls` implementation for Flutter giving access to Windows OS Media Control applet. +1. [spotify](https://github.com/rinukkusu/spotify-dart) - An incomplete dart library for interfacing with the Spotify Web API. 1. [stroke_text](https://github.com/MohamedAbd0/stroke_text) - A Simple Flutter plugin for applying stroke (border) style to a text widget 1. [system_theme](https://pub.dev/packages/system_theme) - A plugin to get the current system theme info. Supports Android, Web, Windows, Linux and macOS +1. [timezone](https://pub.dev/packages/timezone) - Time zone database and time zone aware DateTime. 1. [titlebar_buttons](https://github.com/gtk-flutter/titlebar_buttons) - A package which provides most of the titlebar buttons from windows, linux and macos. +1. [tray_manager](https://github.com/leanflutter/tray_manager) - This plugin allows Flutter desktop apps to defines system tray. 1. [url_launcher](https://pub.dev/packages/url_launcher) - Flutter plugin for launching a URL. Supports web, phone, SMS, and email schemes. 1. [uuid](https://pub.dev/packages/uuid) - RFC4122 (v1, v4, v5, v6, v7, v8) UUID Generator and Parser for Dart 1. [version](https://github.com/dartninja/version) - Provides a simple class for parsing and comparing semantic versions as defined by http://semver.org/ -1. [visibility_detector](https://pub.dev/packages/visibility_detector) - A widget that detects the visibility of its child and notifies a callback. -1. [window_manager](https://github.com/leanflutter/window_manager) - This plugin allows Flutter desktop apps to resizing and repositioning the window. -1. [youtube_explode_dart](https://github.com/Hexer10/youtube_explode_dart) - A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key. -1. [simple_icons](https://teavelopment.com/) - The Simple Icon pack available as Flutter Icons. Provides over 1500 Free SVG icons for popular brands. -1. [audio_service_mpris](https://github.com/bdrazhzhov/audio-service-mpris) - audio_service platform interface supporting Media Player Remote Interfacing Specification. -1. [file_picker](https://github.com/miguelpruivo/plugins_flutter_file_picker) - A package that allows you to use a native file explorer to pick single or multiple absolute file paths, with extension filtering support. -1. [jiosaavn](https://github.com/KRTirtho/jiosaavn) - Unofficial API client for jiosaavn.com 1. [very_good_infinite_list](https://github.com/VeryGoodOpenSource/very_good_infinite_list) - A library for easily displaying paginated data, created by Very Good Ventures. Great for activity feeds, news feeds, and more. -1. [gap](https://github.com/letsar/gap) - Flutter widgets for easily adding gaps inside Flex widgets such as Columns and Rows or scrolling views. -1. [sliver_tools](https://github.com/Kavantix) - A set of useful sliver tools that are missing from the flutter framework -1. [html_unescape](https://github.com/filiph/html_unescape) - A small library for un-escaping HTML. Supports all Named Character References, Decimal Character References and Hexadecimal Character References. +1. [visibility_detector](https://pub.dev/packages/visibility_detector) - A widget that detects the visibility of its child and notifies a callback. +1. [web_socket_channel](https://pub.dev/packages/web_socket_channel) - StreamChannel wrappers for WebSockets. Provides a cross-platform WebSocketChannel API, a cross-platform implementation of that API that communicates over an underlying StreamChannel. 1. [wikipedia_api](https://github.com/KRTirtho/wikipedia_api) - Wikipedia API for dart and flutter -1. [skeletonizer](https://github.com/Milad-Akarie/skeletonizer) - Converts already built widgets into skeleton loaders with no extra effort. -1. [app_links](https://github.com/llfbandit/app_links) - Android App Links, Deep Links, iOs Universal Links and Custom URL schemes handler for Flutter (desktop included). 1. [win32_registry](https://pub.dev/packages/win32_registry) - A package that provides a friendly Dart API for accessing the Windows Registry. -1. [flutter_sharing_intent](https://github.com/bhagat-techind/flutter_sharing_intent.git) - A flutter plugin that allow flutter apps to receive photos, videos, text, urls or any other file types from another app. -1. [flutter_broadcasts](https://pub.dev/packages/flutter_broadcasts) - A plugin for sending and receiving broadcasts with Android intents and iOS notifications. -1. [freezed_annotation](https://pub.dev/packages/freezed_annotation) - Annotations for the freezed code-generator. This package does nothing without freezed too. -1. [spotify](https://github.com/rinukkusu/spotify-dart) - An incomplete dart library for interfacing with the Spotify Web API. -1. [bonsoir](https://bonsoir.skyost.eu) - A Zeroconf library that allows you to discover network services and to broadcast your own. Based on Apple Bonjour and Android NSD. -1. [shelf](https://pub.dev/packages/shelf) - A model for web server middleware that encourages composition and easy reuse. -1. [shelf_router](https://pub.dev/packages/shelf_router) - A convenient request router for the shelf web-framework, with support for URL-parameters, nested routers and routers generated from source annotations. -1. [shelf_web_socket](https://pub.dev/packages/shelf_web_socket) - A shelf handler that wires up a listener for every connection. -1. [web_socket_channel](https://pub.dev/packages/web_socket_channel) - StreamChannel wrappers for WebSockets. Provides a cross-platform WebSocketChannel API, a cross-platform implementation of that API that communicates over an underlying StreamChannel. -1. [lrc](https://pub.dev/packages/lrc) - A Dart-only package that creates, parses, and handles LRC, which is a format that stores song lyrics. -1. [pub_api_client](https://github.com/leoafarias/pub_api_client) - An API Client for Pub to interact with public package information. -1. [pubspec_parse](https://pub.dev/packages/pubspec_parse) - Simple package for parsing pubspec.yaml files with a type-safe API and rich error reporting. -1. [timezone](https://pub.dev/packages/timezone) - Time zone database and time zone aware DateTime. -1. [crypto](https://pub.dev/packages/crypto) - Implementations of SHA, MD5, and HMAC cryptographic functions. -1. [build_runner](https://pub.dev/packages/build_runner) - A build system for Dart code generation and modular compilation. -1. [envied_generator](https://github.com/petercinibulk/envied) - Generator for the Envied package. See https://pub.dev/packages/envied. -1. [flutter_distributor](https://distributor.leanflutter.dev) - A complete tool for packaging and publishing your Flutter apps. -1. [flutter_gen_runner](https://github.com/FlutterGen/flutter_gen) - The Flutter code generator for your assets, fonts, colors, … — Get rid of all String-based APIs. -1. [flutter_launcher_icons](https://github.com/fluttercommunity/flutter_launcher_icons) - A package which simplifies the task of updating your Flutter app's launcher icon. -1. [flutter_lints](https://pub.dev/packages/flutter_lints) - Recommended lints for Flutter apps, packages, and plugins to encourage good coding practices. -1. [hive_generator](https://github.com/hivedb/hive/tree/master/hive_generator) - Extension for Hive. Automatically generates TypeAdapters to store any class. -1. [json_serializable](https://pub.dev/packages/json_serializable) - Automatically generate code for converting to and from JSON by annotating Dart classes. -1. [freezed](https://pub.dev/packages/freezed) - Code generation for immutable classes that has a simple syntax/API without compromising on the features. -1. [custom_lint](https://pub.dev/packages/custom_lint) - Lint rules are a powerful way to improve the maintainability of a project. Custom Lint allows package authors and developers to easily write custom lint rules. -1. [riverpod_lint](https://riverpod.dev) - Riverpod_lint is a developer tool for users of Riverpod, designed to help stop common issues and simplify repetitive tasks. -1. [flutter_desktop_tools](https://github.com/KRTirtho/flutter_desktop_tools) - Essential collection of tools for flutter desktop app development -1. [piped_client](https://github.com/KRTirtho/piped_client) - API Client for piped.video -1. [scrobblenaut](https://github.com/Nebulino/Scrobblenaut) - A deadly simple LastFM API Wrapper for Dart. So deadly simple that it's gonna hit the mark. -1. [window_size](https://github.com/google/flutter-desktop-embedding.git) - Allows resizing and repositioning the window containing Flutter. -1. [draggable_scrollbar](https://github.com/fluttercommunity/flutter-draggable-scrollbar) - A scrollbar that can be dragged for quickly navigation through a vertical list. Additional option is showing label next to scrollthumb with information about current item. -1. [dart_discord_rpc](https://github.com/alexmercerind/dart_discord_rpc) - Discord Rich Presence for Flutter & Dart apps & games. +1. [window_manager](https://github.com/leanflutter/window_manager) - This plugin allows Flutter desktop apps to resizing and repositioning the window. +1. [xml](https://github.com/renggli/dart-xml) - A lightweight library for parsing, traversing, querying, transforming and building XML documents. +1. [youtube_explode_dart](https://github.com/Hexer10/youtube_explode_dart) - A port in dart of the youtube explode library. Supports several API functions without the need of Youtube API Key.

© Copyright Spotube 2024

diff --git a/android/app/build.gradle b/android/app/build.gradle index 2f85cdebc..8ec1872e0 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,3 +1,9 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) { } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' @@ -21,10 +22,6 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { @@ -34,7 +31,7 @@ if (keystorePropertiesFile.exists()) { android { compileSdkVersion 34 - ndkVersion "21.4.7075529" + ndkVersion "25.1.8937393" compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -50,10 +47,9 @@ android { } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "oss.krtirtho.spotube" minSdkVersion 24 - targetSdkVersion flutter.targetSdkVersion + targetSdkVersion 34 versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true @@ -71,6 +67,9 @@ android { release { signingConfig signingConfigs.release } + debug { + signingConfig signingConfigs.release + } } flavorDimensions "default" @@ -81,16 +80,19 @@ android { resValue "string", "app_name_en", "Spotube Nightly" applicationIdSuffix ".nightly" versionNameSuffix "-nightly" + signingConfig signingConfigs.release } dev { dimension "default" resValue "string", "app_name_en", "Spotube Dev" applicationIdSuffix ".dev" versionNameSuffix "-dev" + signingConfig signingConfigs.release } stable { dimension "default" resValue "string", "app_name_en", "Spotube" + signingConfig signingConfigs.release } } @@ -101,15 +103,6 @@ flutter { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - constraints { - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version") { - because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib") - } - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version") { - because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib") - } - } implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' // other deps so just ignore diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 5ab7a0b51..64c32e28d 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ + @@ -24,6 +25,11 @@ android:usesCleartextTraffic="true" android:requestLegacyExternalStorage="true" > + + + properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "7.2.1" apply false + id "org.jetbrains.kotlin.android" version "1.8.22" apply false +} + +include ":app" \ No newline at end of file diff --git a/aur-struct/.SRCINFO b/aur-struct/.SRCINFO index ae0b6d10c..29eedf742 100644 --- a/aur-struct/.SRCINFO +++ b/aur-struct/.SRCINFO @@ -1,17 +1,17 @@ pkgbase = spotube-bin - pkgdesc = Open source Spotify client that doesn't require Premium nor uses Electron! Available for both desktop & mobile! - pkgver = 2.3.0 - pkgrel = 1 - url = https://github.com/KRTirtho/spotube/ - arch = x86_64 - license = BSD-4-Clause - depends = mpv - depends = libappindicator-gtk3 - depends = libsecret - depends = jsoncpp - depends = libnotify - depends = xdg-user-dirs - source = https://github.com/KRTirtho/spotube/releases/download/v2.3.0/Spotube-linux-x86_64.tar.xz - md5sums = 8cd6a7385c5c75d203dccd762f1d63ec +pkgdesc = Open source Spotify client that doesn't require Premium nor uses Electron! Available for both desktop & mobile! +pkgver = 3.7.1 +pkgrel = 2 +url = https://github.com/KRTirtho/spotube/ +arch = x86_64 +license = BSD-4-Clause +depends = mpv +depends = libappindicator-gtk3 +depends = libsecret +depends = jsoncpp +depends = libnotify +depends = xdg-user-dirs +source = https://github.com/KRTirtho/spotube/releases/download/v3.7.1/spotube-linux-3.7.1-x86_64.tar.xz +md5sums = 475b1ae9b08f27743a4d4749391ae3db pkgname = spotube-bin diff --git a/bin/gen-credits.dart b/bin/gen-credits.dart deleted file mode 100644 index f8975335f..000000000 --- a/bin/gen-credits.dart +++ /dev/null @@ -1,103 +0,0 @@ -import 'dart:developer'; -import 'dart:io'; - -import 'package:collection/collection.dart'; -import 'package:http/http.dart'; -import 'package:html/parser.dart'; -import 'package:pub_api_client/pub_api_client.dart'; -import 'package:pubspec_parse/pubspec_parse.dart'; - -void main() async { - final client = PubClient(); - - final pubspec = Pubspec.parse(File('pubspec.yaml').readAsStringSync()); - - final allDeps = [ - ...pubspec.dependencies.entries, - ...pubspec.devDependencies.entries, - ]; - - final dependencies = allDeps - .where((d) => d.value is HostedDependency) - .map((d) => d.key) - .toSet(); - final packageInfo = await Future.wait(dependencies.map(client.packageInfo)); - - final gitDepsList = List.castFrom, - MapEntry>( - allDeps - .where((d) => d.value is GitDependency) - .map((d) => MapEntry(d.key, d.value as GitDependency)) - .toList(), - ); - - final gitDeps = gitDepsList.map( - (d) { - final uri = Uri.parse( - d.value.url.toString().replaceAll('.git', ''), - ); - return MapEntry( - d.key, - uri.replace( - pathSegments: [ - ...uri.pathSegments, - 'raw', - d.value.ref ?? 'main', - d.value.path ?? '', - 'pubspec.yaml', - ], - ).toString(), - ); - }, - ).toList(); - - final gitPubspecs = await Future.wait( - gitDeps.map( - (d) { - Pubspec parser(res) { - try { - return Pubspec.parse(res.body); - } catch (e) { - final document = parse(res.body); - final pre = document.querySelector('pre'); - if (pre == null) { - log(d.toString()); - rethrow; - } - return Pubspec.parse(pre.text); - } - } - - return get(Uri.parse(d.value)).then(parser).catchError( - (_) => get(Uri.parse(d.value.replaceFirst('/main', '/master'))) - .then(parser), - ); - }, - ), - ); - - // ignore: avoid_print - print( - packageInfo - .map( - (package) => - '1. [${package.name}](${package.latestPubspec.homepage ?? package.url}) - ${package.description.replaceAll('\n', '')}', - ) - .join('\n'), - ); - // ignore: avoid_print - print( - gitPubspecs.map( - (package) { - final packageUrl = package.homepage ?? - gitDepsList - .firstWhereOrNull((dep) => dep.key == package.name) - ?.value - .url - .toString(); - return '1. [${package.name}]($packageUrl) - ${package.description?.replaceAll('\n', '')}'; - }, - ).join('\n'), - ); - exit(0); -} diff --git a/bin/translated_messages.dart b/bin/translated_messages.dart deleted file mode 100644 index 1ac8f148f..000000000 --- a/bin/translated_messages.dart +++ /dev/null @@ -1,28 +0,0 @@ -// ignore_for_file: avoid_print - -import 'dart:convert'; -import 'dart:io'; - -void main(List args) async { - final translatedFile = - jsonDecode(await File('tm.json').readAsString()) as Map; - - for (final MapEntry(:key, :value) in translatedFile.entries) { - print('Updating locale: $key'); - final file = File('lib/l10n/app_$key.arb'); - - final fileContent = - jsonDecode(await file.readAsString()) as Map; - - final newContent = { - ...fileContent, - ...value, - }; - - await file.writeAsString( - const JsonEncoder.withIndent(' ').convert(newContent), - ); - - print('✅ Updated locale: $key'); - } -} diff --git a/bin/untranslated_messages.dart b/bin/untranslated_messages.dart deleted file mode 100644 index 0b3485a7b..000000000 --- a/bin/untranslated_messages.dart +++ /dev/null @@ -1,50 +0,0 @@ -// ignore_for_file: avoid_print - -import 'dart:convert'; -import 'dart:io'; - -/// Generate JSON output for untranslated messages with English values -/// for quick translation in ChatGPT -/// -/// Usage: dart bin/untranslated_messages.dart [locale?] -/// -/// Example: dart bin/untranslated_messages.dart -/// -/// or with specific locale (e.g. bn (Bengali)) -/// -/// Example: dart bin/untranslated_messages.dart bn - -void main(List args) { - final file = jsonDecode( - File('untranslated_messages.json').readAsStringSync(), - ) as Map; - - final englishMessages = - jsonDecode(File('lib/l10n/app_en.arb').readAsStringSync()) - as Map; - - final messagesWithValues = {}; - - for (final MapEntry(key: locale, value: messages) in file.entries) { - messagesWithValues[locale] = Map.fromEntries( - messages - .map( - (message) => - MapEntry(message, englishMessages[message]), - ) - .toList() - .cast>(), - ); - } - - print( - "Prompt:\n" - "Translate following to their appropriate locale for flutter arb translations files." - " Put the respective new translations in a map of their corresponding locale.", - ); - print( - const JsonEncoder.withIndent(' ').convert( - args.isNotEmpty ? messagesWithValues[args.first] : messagesWithValues, - ), - ); -} diff --git a/bin/verify-pkgbuild.dart b/bin/verify-pkgbuild.dart deleted file mode 100644 index 587e63d07..000000000 --- a/bin/verify-pkgbuild.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; - -void main() { - Process.run("sh", ["-c", '"./scripts/pkgbuild2json.sh aur-struct/PKGBUILD"']) - .then((result) { - try { - final pkgbuild = jsonDecode(result.stdout); - if (pkgbuild["version"] != - Platform.environment["RELEASE_VERSION"]?.substring(1)) { - throw Exception( - "PKGBUILD version doesn't match current RELEASE_VERSION"); - } - if (pkgbuild["release"] != "1") { - throw Exception("In new releases pkgrel should be 1"); - } - } catch (e) { - // ignore: avoid_print - print("[Failed to parse PKGBUILD] $e"); - } - }); -} diff --git a/build.yaml b/build.yaml index f074d6e15..8dbfe45d6 100644 --- a/build.yaml +++ b/build.yaml @@ -2,4 +2,16 @@ targets: $default: sources: exclude: - - bin/*.dart \ No newline at end of file + - bin/*.dart + builders: + json_serializable: + options: + any_map: true + explicit_to_json: true + drift_dev: + options: + sql: + dialect: sqlite + options: + modules: + - json1 diff --git a/cli/README.md b/cli/README.md new file mode 100644 index 000000000..b2ba8ebda --- /dev/null +++ b/cli/README.md @@ -0,0 +1,4 @@ +## Spotube Configuration CLI + +This is used for building the project for multiple platforms and having utilities specific for the project. +Written in Dart diff --git a/cli/cli.dart b/cli/cli.dart new file mode 100644 index 000000000..26190d4c4 --- /dev/null +++ b/cli/cli.dart @@ -0,0 +1,22 @@ +import 'package:args/command_runner.dart'; + +import 'commands/build.dart'; +import 'commands/credits.dart'; +import 'commands/install-dependencies.dart'; +import 'commands/translated.dart'; +import 'commands/untranslated.dart'; + +void main(List args) { + final commandRunner = CommandRunner( + "cli", + "Configuration CLI for Spotube", + ); + + commandRunner.addCommand(InstallDependenciesCommand()); + commandRunner.addCommand(BuildCommand()); + commandRunner.addCommand(CreditsCommand()); + commandRunner.addCommand(TranslatedCommand()); + commandRunner.addCommand(UntranslatedCommand()); + + commandRunner.run(args); +} diff --git a/cli/commands/build.dart b/cli/commands/build.dart new file mode 100644 index 000000000..fdf35a952 --- /dev/null +++ b/cli/commands/build.dart @@ -0,0 +1,25 @@ +import 'package:args/command_runner.dart'; + +import 'build/android.dart'; +import 'build/ios.dart'; +import 'build/linux.dart'; +import 'build/linux_arm.dart'; +import 'build/macos.dart'; +import 'build/windows.dart'; + +class BuildCommand extends Command { + @override + String get description => "Build for different platforms"; + + @override + String get name => "build"; + + BuildCommand() { + addSubcommand(AndroidBuildCommand()); + addSubcommand(IosBuildCommand()); + addSubcommand(LinuxBuildCommand()); + addSubcommand(LinuxArmBuildCommand()); + addSubcommand(MacosBuildCommand()); + addSubcommand(WindowsBuildCommand()); + } +} diff --git a/cli/commands/build/android.dart b/cli/commands/build/android.dart new file mode 100644 index 000000000..800522b8a --- /dev/null +++ b/cli/commands/build/android.dart @@ -0,0 +1,90 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:args/command_runner.dart'; +import 'package:collection/collection.dart'; +import 'package:path/path.dart'; +import 'package:xml/xml.dart'; + +import '../../core/env.dart'; +import 'common.dart'; + +class AndroidBuildCommand extends Command with BuildCommandCommonSteps { + @override + String get description => "Build for android"; + + @override + String get name => "android"; + + @override + FutureOr? run() async { + await bootstrap(); + + await shell.run( + "flutter build apk --flavor ${CliEnv.channel.name}", + ); + + await dotEnvFile.writeAsString( + "\nENABLE_UPDATE_CHECK=0", + mode: FileMode.append, + ); + + final androidManifestFile = File( + join(cwd.path, "android", "app", "src", "main", "AndroidManifest.xml")); + + final androidManifestXml = + XmlDocument.parse(await androidManifestFile.readAsString()); + + final deletingElement = + androidManifestXml.findAllElements("meta-data").firstWhereOrNull( + (el) => + el.getAttribute("android:name") == + "com.google.android.gms.car.application", + ); + + deletingElement?.parent?.children.remove(deletingElement); + + await androidManifestFile.writeAsString( + androidManifestXml.toXmlString(pretty: true), + ); + + await shell.run( + """ + dart run build_runner build --delete-conflicting-outputs + flutter build appbundle --flavor ${CliEnv.channel.name} + """, + ); + + final ogApkFile = File( + join( + "build", + "app", + "outputs", + "flutter-apk", + "app-${CliEnv.channel.name}-release.apk", + ), + ); + + await ogApkFile.copy( + join(cwd.path, "build", "Spotube-android-all-arch.apk"), + ); + + final ogAppbundleFile = File( + join( + cwd.path, + "build", + "app", + "outputs", + "bundle", + "${CliEnv.channel.name}Release", + "app-${CliEnv.channel.name}-release.aab", + ), + ); + + await ogAppbundleFile.copy( + join(cwd.path, "build", "Spotube-playstore-all-arch.aab"), + ); + + stdout.writeln("✅ Built Android Apk and Appbundle"); + } +} diff --git a/cli/commands/build/common.dart b/cli/commands/build/common.dart new file mode 100644 index 000000000..4c7e3e510 --- /dev/null +++ b/cli/commands/build/common.dart @@ -0,0 +1,66 @@ +import 'dart:io'; + +import 'package:args/command_runner.dart'; +import 'package:path/path.dart'; +import 'package:process_run/shell_run.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; + +import '../../core/env.dart'; + +mixin BuildCommandCommonSteps on Command { + final shell = Shell(); + Directory get cwd => Directory.current; + + Pubspec? _pubspec; + + Pubspec get pubspec { + if (_pubspec != null) { + return _pubspec!; + } + + final pubspecFile = File(join(cwd.path, "pubspec.yaml")); + _pubspec = Pubspec.parse(pubspecFile.readAsStringSync()); + + return _pubspec!; + } + + String get versionWithoutBuildNumber { + return "${pubspec.version!.major}.${pubspec.version!.minor}.${pubspec.version!.patch}"; + } + + RegExp get versionVarRegExp => + RegExp(r"\%\{\{SPOTUBE_VERSION\}\}\%", multiLine: true); + + File get dotEnvFile => File(join(cwd.path, ".env")); + + Future bootstrap() async { + await dotEnvFile.create(recursive: true); + + await dotEnvFile.writeAsString( + "${CliEnv.dotenv}\n" + "RELEASE_CHANNEL=${CliEnv.channel.name}\n", + ); + + if (CliEnv.channel == BuildChannel.nightly) { + final pubspecFile = File(join(cwd.path, "pubspec.yaml")); + + pubspecFile.writeAsStringSync( + pubspecFile.readAsStringSync().replaceAll( + "version: ${pubspec.version!.canonicalizedVersion}", + "version: $versionWithoutBuildNumber+${CliEnv.ghRunNumber}", + ), + ); + + _pubspec = null; + pubspec; + } + + await shell.run( + """ + flutter pub get + dart run build_runner build --delete-conflicting-outputs + dart pub global activate flutter_distributor + """, + ); + } +} diff --git a/cli/commands/build/ios.dart b/cli/commands/build/ios.dart new file mode 100644 index 000000000..6460f9edb --- /dev/null +++ b/cli/commands/build/ios.dart @@ -0,0 +1,29 @@ +import 'dart:async'; + +import 'package:args/command_runner.dart'; +import 'package:path/path.dart'; + +import '../../core/env.dart'; +import 'common.dart'; + +class IosBuildCommand extends Command with BuildCommandCommonSteps { + @override + String get description => "iOS build command"; + + @override + String get name => "ios"; + + @override + FutureOr? run() async { + await bootstrap(); + + final buildDirPath = join(cwd.path, "build", "ios", "iphoneos"); + await shell.run( + """ + flutter build ios --release --no-codesign --flavor ${CliEnv.channel.name} + ln -sf $buildDirPath Payload + zip -r9 Spotube-iOS.ipa ${join("Payload", "${CliEnv.channel.name}.app")} + """, + ); + } +} diff --git a/cli/commands/build/linux.dart b/cli/commands/build/linux.dart new file mode 100644 index 000000000..a218720ce --- /dev/null +++ b/cli/commands/build/linux.dart @@ -0,0 +1,106 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:io/io.dart'; +import 'package:args/command_runner.dart'; +import 'package:intl/intl.dart'; +import 'package:path/path.dart'; + +import '../../core/env.dart'; +import 'common.dart'; + +class LinuxBuildCommand extends Command with BuildCommandCommonSteps { + @override + String get description => "Linux build command"; + + @override + String get name => "linux"; + + @override + FutureOr? run() async { + stdout.writeln("Replacing versions"); + + final appDataFile = File( + join(cwd.path, "linux", "com.github.KRTirtho.Spotube.appdata.xml"), + ); + + appDataFile.writeAsStringSync( + appDataFile.readAsStringSync().replaceAll( + versionVarRegExp, + '', + ), + ); + + await bootstrap(); + + await shell.run( + """ + flutter_distributor package --platform=linux --targets=deb + flutter_distributor package --platform=linux --targets=rpm + """, + ); + + final tempDir = join(Directory.systemTemp.path, "spotube-tar"); + + final bundleDirPath = + join(cwd.path, "build", "linux", "x64", "release", "bundle"); + + final tarFile = File(join( + cwd.path, + "dist", + "spotube-linux-" + "${CliEnv.channel == BuildChannel.nightly ? "nightly" : versionWithoutBuildNumber}" + "-x86_64.tar.xz", + )); + + await copyPath(bundleDirPath, tempDir); + await File(join(cwd.path, "linux", "spotube.desktop")).copy( + join(tempDir, "spotube.desktop"), + ); + await File( + join(cwd.path, "linux", "com.github.KRTirtho.Spotube.appdata.xml"), + ).copy( + join(tempDir, "com.github.KRTirtho.Spotube.appdata.xml"), + ); + await File(join(cwd.path, "assets", "spotube-logo.png")).copy( + join(tempDir, "spotube-logo.png"), + ); + + await shell.run( + "tar -cJf ${tarFile.path} -C $tempDir .", + ); + + final ogDeb = File( + join( + cwd.path, + "dist", + pubspec.version.toString(), + "spotube-${pubspec.version}-linux.deb", + ), + ); + + final ogRpm = File( + join( + cwd.path, + "dist", + pubspec.version.toString(), + "spotube-${pubspec.version}-linux.rpm", + ), + ); + + await ogDeb.copy( + join(cwd.path, "dist", "Spotube-linux-x86_64.deb"), + ); + await ogRpm.copy( + join(cwd.path, "dist", "Spotube-linux-x86_64.rpm"), + ); + + await ogDeb.delete(); + await ogRpm.delete(); + + stdout.writeln("✅ Linux building done"); + } +} diff --git a/cli/commands/build/linux_arm.dart b/cli/commands/build/linux_arm.dart new file mode 100644 index 000000000..a09f09808 --- /dev/null +++ b/cli/commands/build/linux_arm.dart @@ -0,0 +1,37 @@ +import 'dart:async'; + +import 'package:args/command_runner.dart'; +import 'package:path/path.dart'; + +import '../../core/env.dart'; +import 'common.dart'; + +class LinuxArmBuildCommand extends Command with BuildCommandCommonSteps { + @override + String get description => "Build Linux Arm"; + + @override + String get name => "linux_arm"; + + @override + FutureOr? run() async { + await bootstrap(); + + await shell.run( + "docker buildx build --platform=linux/arm64 " + "-f ${join(cwd.path, ".github", "Dockerfile")} ${cwd.path} " + "--build-arg FLUTTER_VERSION=${CliEnv.flutterVersion} " + "--build-arg BUILD_VERSION=${CliEnv.channel == BuildChannel.nightly ? "nightly" : versionWithoutBuildNumber} " + "-t krtirtho/spotube_linux_arm:latest " + "--load", + ); + + await shell.run( + """ + docker images ls + docker create --name spotube_linux_arm krtirtho/spotube_linux_arm:latest + docker cp spotube_linux_arm:/app/dist/ dist/ + """, + ); + } +} diff --git a/cli/commands/build/macos.dart b/cli/commands/build/macos.dart new file mode 100644 index 000000000..e8f34b775 --- /dev/null +++ b/cli/commands/build/macos.dart @@ -0,0 +1,42 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:args/command_runner.dart'; +import 'package:path/path.dart'; + +import 'common.dart'; + +class MacosBuildCommand extends Command with BuildCommandCommonSteps { + @override + String get description => "Macos Build command"; + + @override + String get name => "macos"; + + @override + FutureOr? run() async { + await bootstrap(); + + await shell.run( + """ + flutter build macos + appdmg appdmg.json ${join(cwd.path, "build", "Spotube-macos-universal.dmg")} + flutter_distributor package --platform=macos --targets pkg --skip-clean + """, + ); + + final ogPkg = File( + join( + cwd.path, + "dist", + pubspec.version.toString(), + "spotube-${pubspec.version}-macos.pkg", + ), + ); + + await ogPkg.copy( + join(cwd.path, "build", "Spotube-macos-universal.pkg"), + ); + await ogPkg.delete(); + } +} diff --git a/cli/commands/build/windows.dart b/cli/commands/build/windows.dart new file mode 100644 index 000000000..c44ed52f5 --- /dev/null +++ b/cli/commands/build/windows.dart @@ -0,0 +1,119 @@ +import 'dart:io'; + +import 'package:args/command_runner.dart'; +import 'package:path/path.dart'; +import 'package:crypto/crypto.dart'; +import 'common.dart'; + +class WindowsBuildCommand extends Command with BuildCommandCommonSteps { + @override + String get description => "Build Windows exe"; + + @override + String get name => "windows"; + + Future innoDependInstall() async { + final innoDependencyPath = join(cwd.path, "build", "inno-depend"); + + await shell.run( + "git clone https://github.com/DomGries/InnoDependencyInstaller.git $innoDependencyPath", + ); + } + + @override + void run() async { + stdout.writeln("Replace versions"); + + final chocoFiles = [ + join(cwd.path, "choco-struct", "tools", "VERIFICATION.txt"), + join(cwd.path, "choco-struct", "spotube.nuspec"), + ]; + + for (final filePath in chocoFiles) { + final file = File(filePath); + final content = file.readAsStringSync(); + final newContent = + content.replaceAll(versionVarRegExp, versionWithoutBuildNumber); + + file.writeAsStringSync(newContent); + } + + await bootstrap(); + await innoDependInstall(); + + final runnerRCFile = File( + join(cwd.path, "windows", "runner", "Runner.rc"), + ); + + runnerRCFile.writeAsStringSync( + runnerRCFile + .readAsStringSync() + .replaceAll("%{{SPOTUBE_VERSION}}%", versionWithoutBuildNumber) + .replaceAll( + "%{{SPOTUBE_VERSION_AS_NUMBER}}%", + [ + pubspec.version!.major, + pubspec.version!.minor, + pubspec.version!.patch, + 0 + ].join(","), + ), + ); + + await shell.run( + "flutter_distributor package --platform=windows --targets=exe --skip-clean", + ); + + final ogExe = File( + join( + cwd.path, + "dist", + pubspec.version.toString(), + "spotube-${pubspec.version}-windows-setup.exe", + ), + ); + + final exePath = join(cwd.path, "dist", "Spotube-windows-x86_64-setup.exe"); + + await ogExe.copy(exePath); + await ogExe.delete(); + + stdout.writeln("✅ Windows exe built at $exePath"); + + final exeFile = File(exePath); + + final hash = sha256.convert(await exeFile.readAsBytes()).toString(); + + final chocoVerificationFile = File(chocoFiles.first); + + chocoVerificationFile.writeAsStringSync( + chocoVerificationFile.readAsStringSync().replaceAll( + RegExp(r"\%\{\{WIN_SHA256\}\}\%"), + hash, + ), + ); + + await exeFile.copy( + join(cwd.path, "choco-struct", "tools", basename(exeFile.path)), + ); + + await shell.run( + "choco pack ${chocoFiles[1]} --outputdirectory ${join(cwd.path, "dist")}", + ); + + final chocoNupkg = File( + join(cwd.path, "dist", "spotube.$versionWithoutBuildNumber.nupkg"), + ); + + final distNupkgPath = join( + cwd.path, + "dist", + "Spotube-windows-x86_64.nupkg", + ); + + await chocoNupkg.copy(distNupkgPath); + await chocoNupkg.delete(); + + stdout.writeln("✅ Windows nupkg built at $distNupkgPath"); + } +} diff --git a/cli/commands/credits.dart b/cli/commands/credits.dart new file mode 100644 index 000000000..6bad7a444 --- /dev/null +++ b/cli/commands/credits.dart @@ -0,0 +1,121 @@ +import 'dart:io'; + +import 'package:args/command_runner.dart'; +import 'package:collection/collection.dart'; +import 'package:dio/dio.dart'; +import 'package:html/parser.dart'; +import 'package:path/path.dart'; +import 'package:pub_api_client/pub_api_client.dart'; +import 'package:pubspec_parse/pubspec_parse.dart'; + +class CreditsCommand extends Command { + final dio = Dio( + BaseOptions( + responseType: ResponseType.plain, + ), + ); + + @override + String get description => "Generate credits for used Library's authors"; + + @override + String get name => "credits"; + + @override + run() async { + final client = PubClient(); + final cwd = Directory.current; + + final pubspec = Pubspec.parse( + File(join(cwd.path, 'pubspec.yaml')).readAsStringSync(), + ); + + final allDeps = [ + ...pubspec.dependencies.entries, + ...pubspec.devDependencies.entries, + ]; + + final dependencies = allDeps + .where((d) => d.value is HostedDependency) + .map((d) => d.key) + .toSet(); + final packageInfo = await Future.wait(dependencies.map(client.packageInfo)); + + final gitDepsList = List.castFrom, + MapEntry>( + allDeps + .where((d) => d.value is GitDependency) + .map((d) => MapEntry(d.key, d.value as GitDependency)) + .toList(), + ); + + final gitDeps = gitDepsList.map( + (d) { + final uri = Uri.parse( + d.value.url.toString().replaceAll('.git', ''), + ); + return MapEntry( + d.key, + uri.replace( + pathSegments: [ + ...uri.pathSegments, + 'raw', + d.value.ref ?? 'main', + d.value.path ?? '', + 'pubspec.yaml', + ], + ).toString(), + ); + }, + ).toList(); + + final gitPubspecs = await Future.wait( + gitDeps.map( + (d) { + Pubspec parser(Response res) { + try { + return Pubspec.parse(res.data); + } catch (e) { + final document = parse(res.data); + final pre = document.querySelector('pre'); + if (pre == null) { + stdout.writeln(d.toString()); + rethrow; + } + return Pubspec.parse(pre.text); + } + } + + return dio.get(d.value).then(parser).catchError( + (_) => dio + .get(d.value.replaceFirst('/main', '/master')) + .then(parser), + ); + }, + ), + ); + + stdout.writeln( + packageInfo + .map( + (package) => + '1. [${package.name}](${package.latestPubspec.homepage ?? package.url}) - ${package.description.replaceAll('\n', '')}', + ) + .join('\n'), + ); + + stdout.writeln( + gitPubspecs.map( + (package) { + final packageUrl = package.homepage ?? + gitDepsList + .firstWhereOrNull((dep) => dep.key == package.name) + ?.value + .url + .toString(); + return '1. [${package.name}]($packageUrl) - ${package.description?.replaceAll('\n', '')}'; + }, + ).join('\n'), + ); + } +} diff --git a/cli/commands/install-dependencies.dart b/cli/commands/install-dependencies.dart new file mode 100644 index 000000000..dc519cc61 --- /dev/null +++ b/cli/commands/install-dependencies.dart @@ -0,0 +1,79 @@ +import 'dart:async'; + +import 'package:args/command_runner.dart'; +import 'package:process_run/shell_run.dart'; + +class InstallDependenciesCommand extends Command { + @override + String get description => "Install platform dependencies"; + + @override + String get name => "install-dependencies"; + + InstallDependenciesCommand() { + argParser.addOption( + "platform", + abbr: "p", + allowed: [ + "windows", + "linux", + "linux_arm", + "macos", + "ios", + "android", + ], + mandatory: true, + ); + } + + @override + FutureOr? run() async { + final shell = Shell(); + + switch (argResults!.option("platform")) { + case "windows": + break; + case "linux": + await shell.run( + """ + sudo apt-get update -y + sudo apt-get install -y tar clang cmake ninja-build pkg-config libgtk-3-dev make python3-pip python3-setuptools desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse libunwind-dev locate patchelf gir1.2-appindicator3-0.1 libappindicator3-1 libappindicator3-dev libsecret-1-0 libjsoncpp25 libsecret-1-dev libjsoncpp-dev libnotify-bin libnotify-dev mpv libmpv-dev libwebkit2gtk-4.1-0 libwebkit2gtk-4.1-dev libsoup-3.0-0 libsoup-3.0-dev + """, + ); + break; + case "linux_arm": + await shell.run( + """ + sudo apt-get update -y + sudo apt-get install -y pkg-config make python3-pip python3-setuptools + """, + ); + break; + case "macos": + await shell.run( + """ + brew install python-setuptools + npm install -g appdmg + """, + ); + break; + case "ios": + await shell.run( + """ + rustup target add aarch64-apple-ios + """, + ); + break; + case "android": + await shell.run( + """ + sudo apt-get update -y + sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev make python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse + """, + ); + break; + default: + break; + } + } +} diff --git a/cli/commands/translated.dart b/cli/commands/translated.dart new file mode 100644 index 000000000..43c4ea49d --- /dev/null +++ b/cli/commands/translated.dart @@ -0,0 +1,39 @@ +import 'dart:async'; + +import 'dart:convert'; +import 'dart:io'; +import 'package:args/command_runner.dart'; +import 'package:path/path.dart'; + +class TranslatedCommand extends Command { + @override + String get description => + "Update translation based on generated translated messages"; + + @override + String get name => "translated"; + + @override + FutureOr? run() async { + final cwd = Directory.current; + final translatedFile = jsonDecode( + await File(join(cwd.path, 'tm.json')).readAsString(), + ) as Map; + + for (final MapEntry(:key, :value) in translatedFile.entries) { + stdout.writeln('Updating locale: $key'); + final file = File(join(cwd.path, 'lib', 'l10n', 'app_$key.arb')); + + final fileContent = + jsonDecode(await file.readAsString()) as Map; + + final newContent = {...fileContent, ...value}; + + await file.writeAsString( + const JsonEncoder.withIndent(' ').convert(newContent), + ); + + stdout.writeln('✅ Updated locale: $key'); + } + } +} diff --git a/cli/commands/untranslated.dart b/cli/commands/untranslated.dart new file mode 100644 index 000000000..dadcd8b5b --- /dev/null +++ b/cli/commands/untranslated.dart @@ -0,0 +1,48 @@ +import 'package:args/command_runner.dart'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:path/path.dart'; + +class UntranslatedCommand extends Command { + @override + get name => "untranslated"; + @override + get description => + "Generate Untranslated Messages for ChatGPT based Translation"; + + @override + run() async { + final cwd = Directory.current; + final file = jsonDecode( + File(join(cwd.path, 'untranslated_messages.json')).readAsStringSync(), + ) as Map; + + final englishMessages = jsonDecode( + File(join(cwd.path, 'lib', 'l10n', 'app_en.arb')).readAsStringSync(), + ) as Map; + + final messagesWithValues = {}; + + for (final MapEntry(key: locale, value: messages) in file.entries) { + messagesWithValues[locale] = Map.fromEntries( + messages + .map( + (message) => + MapEntry(message, englishMessages[message]), + ) + .toList() + .cast>(), + ); + } + + stdout.writeln( + "Prompt:\n" + "Translate following to their appropriate locale for flutter arb translations files." + " Put the respective new translations in a map of their corresponding locale.", + ); + stdout.writeln( + const JsonEncoder.withIndent(' ').convert(messagesWithValues), + ); + } +} diff --git a/cli/core/env.dart b/cli/core/env.dart new file mode 100644 index 000000000..33cc5df13 --- /dev/null +++ b/cli/core/env.dart @@ -0,0 +1,24 @@ +import 'dart:io'; + +enum BuildChannel { + stable, + nightly; + + factory BuildChannel.fromEnvironment(String name) { + final channel = Platform.environment[name]!; + if (channel == "stable") { + return BuildChannel.stable; + } else if (channel == "nightly") { + return BuildChannel.nightly; + } else { + throw Exception("Invalid channel: $channel"); + } + } +} + +class CliEnv { + static final channel = BuildChannel.fromEnvironment("CHANNEL"); + static final dotenv = Platform.environment["DOTENV"]!; + static final ghRunNumber = Platform.environment["GITHUB_RUN_NUMBER"]; + static final flutterVersion = Platform.environment["FLUTTER_VERSION"]!; +} diff --git a/devtools_options.yaml b/devtools_options.yaml new file mode 100644 index 000000000..7e7e7f67d --- /dev/null +++ b/devtools_options.yaml @@ -0,0 +1 @@ +extensions: diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 1d048cc9b..7e5f24b53 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -49,6 +49,8 @@ PODS: - Flutter (1.0.0) - flutter_broadcasts (0.0.1): - Flutter + - flutter_discord_rpc (0.0.1): + - Flutter - flutter_inappwebview_ios (0.0.1): - Flutter - flutter_inappwebview_ios/Core (= 0.0.1) @@ -58,20 +60,12 @@ PODS: - OrderedSet (~> 5.0) - flutter_keyboard_visibility (0.0.1): - Flutter - - flutter_mailer (0.0.1): - - Flutter - flutter_native_splash (0.0.1): - Flutter - flutter_secure_storage (6.0.0): - Flutter - flutter_sharing_intent (0.0.1): - Flutter - - fluttertoast (0.0.2): - - Flutter - - Toast - - FMDB (2.7.5): - - FMDB/standard (= 2.7.5) - - FMDB/standard (2.7.5) - image_picker_ios (0.0.1): - Flutter - integration_test (0.0.1): @@ -80,14 +74,15 @@ PODS: - Flutter - media_kit_native_event_loop (1.0.0): - Flutter - - metadata_god (0.0.1) + - metadata_god (0.0.1): + - Flutter - OrderedSet (5.0.0) - package_info_plus (0.4.5): - Flutter - path_provider_foundation (0.0.1): - Flutter - FlutterMacOS - - permission_handler_apple (9.1.1): + - permission_handler_apple (9.3.0): - Flutter - SDWebImage (5.18.8): - SDWebImage/Core (= 5.18.8) @@ -97,9 +92,23 @@ PODS: - FlutterMacOS - sqflite (0.0.3): - Flutter - - FMDB (>= 2.7.5) + - FlutterMacOS + - "sqlite3 (3.46.0+1)": + - "sqlite3/common (= 3.46.0+1)" + - "sqlite3/common (3.46.0+1)" + - "sqlite3/fts5 (3.46.0+1)": + - sqlite3/common + - "sqlite3/perf-threadsafe (3.46.0+1)": + - sqlite3/common + - "sqlite3/rtree (3.46.0+1)": + - sqlite3/common + - sqlite3_flutter_libs (0.0.1): + - Flutter + - sqlite3 (~> 3.46.0) + - sqlite3/fts5 + - sqlite3/perf-threadsafe + - sqlite3/rtree - SwiftyGif (5.4.4) - - Toast (4.0.0) - url_launcher_ios (0.0.1): - Flutter @@ -113,13 +122,12 @@ DEPENDENCIES: - file_selector_ios (from `.symlinks/plugins/file_selector_ios/ios`) - Flutter (from `Flutter`) - flutter_broadcasts (from `.symlinks/plugins/flutter_broadcasts/ios`) + - flutter_discord_rpc (from `.symlinks/plugins/flutter_discord_rpc/ios`) - flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`) - flutter_keyboard_visibility (from `.symlinks/plugins/flutter_keyboard_visibility/ios`) - - flutter_mailer (from `.symlinks/plugins/flutter_mailer/ios`) - flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`) - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - flutter_sharing_intent (from `.symlinks/plugins/flutter_sharing_intent/ios`) - - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - integration_test (from `.symlinks/plugins/integration_test/ios`) - media_kit_libs_ios_audio (from `.symlinks/plugins/media_kit_libs_ios_audio/ios`) @@ -129,18 +137,18 @@ DEPENDENCIES: - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - - sqflite (from `.symlinks/plugins/sqflite/ios`) + - sqflite (from `.symlinks/plugins/sqflite/darwin`) + - sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) SPEC REPOS: trunk: - DKImagePickerController - DKPhotoGallery - - FMDB - OrderedSet - SDWebImage + - sqlite3 - SwiftyGif - - Toast EXTERNAL SOURCES: app_links: @@ -161,20 +169,18 @@ EXTERNAL SOURCES: :path: Flutter flutter_broadcasts: :path: ".symlinks/plugins/flutter_broadcasts/ios" + flutter_discord_rpc: + :path: ".symlinks/plugins/flutter_discord_rpc/ios" flutter_inappwebview_ios: :path: ".symlinks/plugins/flutter_inappwebview_ios/ios" flutter_keyboard_visibility: :path: ".symlinks/plugins/flutter_keyboard_visibility/ios" - flutter_mailer: - :path: ".symlinks/plugins/flutter_mailer/ios" flutter_native_splash: :path: ".symlinks/plugins/flutter_native_splash/ios" flutter_secure_storage: :path: ".symlinks/plugins/flutter_secure_storage/ios" flutter_sharing_intent: :path: ".symlinks/plugins/flutter_sharing_intent/ios" - fluttertoast: - :path: ".symlinks/plugins/fluttertoast/ios" image_picker_ios: :path: ".symlinks/plugins/image_picker_ios/ios" integration_test: @@ -194,45 +200,46 @@ EXTERNAL SOURCES: shared_preferences_foundation: :path: ".symlinks/plugins/shared_preferences_foundation/darwin" sqflite: - :path: ".symlinks/plugins/sqflite/ios" + :path: ".symlinks/plugins/sqflite/darwin" + sqlite3_flutter_libs: + :path: ".symlinks/plugins/sqlite3_flutter_libs/ios" url_launcher_ios: :path: ".symlinks/plugins/url_launcher_ios/ios" SPEC CHECKSUMS: - app_links: 5ef33d0d295a89d9d16bb81b0e3b0d5f70d6c875 + app_links: e70ca16b4b0f88253b3b3660200d4a10b4ea9795 audio_service: f509d65da41b9521a61f1c404dd58651f265a567 - audio_session: 4f3e461722055d21515cf3261b64c973c062f345 + audio_session: 088d2483ebd1dc43f51d253d4a1c517d9a2e7207 bonsoir_darwin: e3b8526c42ca46a885142df84229131dfabea842 - device_info_plus: c6fb39579d0f423935b0c9ce7ee2f44b71b9fce6 + device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 - file_picker: 15fd9539e4eb735dc54bae8c0534a7a9511a03de - file_selector_ios: 8c25d700d625e1dcdd6599f2d927072f2254647b + file_picker: 09aa5ec1ab24135ccd7a1621c46c84134bfd6655 + file_selector_ios: 78baf21d03f1e37a7df97bb2494f9cd86de8fa5d Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_broadcasts: 3ece15b27d8ccbe2132c3df303e7c3401feab882 + flutter_discord_rpc: e1c342f29ceb9dd76cdc01db59a70c93bb4d9ec5 flutter_inappwebview_ios: 97215cf7d4677db55df76782dbd2930c5e1c1ea0 flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069 - flutter_mailer: 2ef5a67087bc8c6c4cefd04a178bf1ae2c94cd83 - flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef + flutter_native_splash: edf599c81f74d093a4daf8e17bd7a018854bc778 flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be flutter_sharing_intent: e35380d0e1501d7111dbb7e46d5ac6339da6da98 - fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265 - FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a - image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5 - integration_test: 13825b8a9334a850581300559b8839134b124670 + image_picker_ios: b545a5f16c0fa88e3ecbbce3ed4de45567a8ec18 + integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4 media_kit_libs_ios_audio: 8f39d96a9c630685dfb844c289bd1d114c486fb3 media_kit_native_event_loop: 99111eded5acbdc9c2738021ea6550dd36ca8837 - metadata_god: eceae399d0020475069a5cebc35943ce8562b5d7 + metadata_god: 4bbd8523cdb5d42c5e59d2fabad01ff8f4bc53f9 OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c - package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7 - path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 - permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6 + package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c + path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c + permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 SDWebImage: a81bbb3ba4ea5f810f4069c68727cb118467a04a - shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 - sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a + shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 + sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec + sqlite3: 292c3e1bfe89f64e51ea7fc7dab9182a017c8630 + sqlite3_flutter_libs: 0d611efdf6d1c9297d5ab03dab21b75aeebdae31 SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f - Toast: 91b396c56ee72a5790816f40d3a94dd357abc196 - url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 + url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586 PODFILE CHECKSUM: 0659b64ac6e9e96b61d8550decffa8bff51a957e diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 13f624a46..34793f682 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -324,6 +324,7 @@ 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 6E9FEF583EA597C8B76255B2 /* [CP] Embed Pods Frameworks */, + 46F6EB27C31C41D86428A28B /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -346,6 +347,7 @@ B536BD992B405DB1009B3CE4 /* Embed Frameworks */, B536BD9A2B405DB1009B3CE4 /* Thin Binary */, A6D446F111DE4C4A202BE7F7 /* [CP] Embed Pods Frameworks */, + 2DEF3CF18D30E819C0FF4BCE /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -368,6 +370,7 @@ B536BDB62B405FDE009B3CE4 /* Embed Frameworks */, B536BDB72B405FDE009B3CE4 /* Thin Binary */, 244D41CE80E4BC0FFD63F8C6 /* [CP] Embed Pods Frameworks */, + 4DD66E9E53D92195290872BE /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -390,6 +393,7 @@ B536BDD82B4060B3009B3CE4 /* Embed Frameworks */, B536BDD92B4060B3009B3CE4 /* Thin Binary */, D566C841A84D807A607F6DE5 /* [CP] Embed Pods Frameworks */, + 5C9D945D6569D9C3AC420285 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -523,6 +527,23 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + 2DEF3CF18D30E819C0FF4BCE /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-stable/Pods-stable-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-stable/Pods-stable-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-stable/Pods-stable-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -539,6 +560,57 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 46F6EB27C31C41D86428A28B /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 4DD66E9E53D92195290872BE /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-dev/Pods-dev-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-dev/Pods-dev-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-dev/Pods-dev-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 5C9D945D6569D9C3AC420285 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-nightly/Pods-nightly-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-nightly/Pods-nightly-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-nightly/Pods-nightly-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 5CD4405E93760FBD048E36E2 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/lib/collections/cache_keys.dart b/lib/collections/cache_keys.dart deleted file mode 100644 index bca133229..000000000 --- a/lib/collections/cache_keys.dart +++ /dev/null @@ -1,21 +0,0 @@ -abstract class LocalStorageKeys { - static String saveTrackLyrics = 'save_track_lyrics'; - static String recommendationMarket = 'recommendation_market'; - static String ytSearchFormate = 'youtube_search_format'; - - static String clientId = 'clientId'; - static String clientSecret = 'clientSecret'; - static String accessToken = 'accessToken'; - static String refreshToken = 'refreshToken'; - static String expiration = "expiration"; - static String geniusAccessToken = "genius_access_token"; - - static String themeMode = "theme_mode"; - static String nextTrackHotKey = "next_track_hot_key"; - static String prevTrackHotKey = "prev_track_hot_key"; - static String playPauseHotKey = "play_pause_hot_key"; - - static String volume = "volume"; - - static String windowSizeInfo = "window_size_info"; -} diff --git a/lib/collections/env.dart b/lib/collections/env.dart index 50fe1e6a7..df45cee91 100644 --- a/lib/collections/env.dart +++ b/lib/collections/env.dart @@ -1,8 +1,13 @@ import 'package:envied/envied.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; +import 'package:spotube/utils/platform.dart'; part 'env.g.dart'; +enum ReleaseChannel { + nightly, + stable, +} + @Envied(obfuscate: true, requireEnvFile: true, path: ".env") abstract class Env { @EnviedField(varName: 'SPOTIFY_SECRETS') @@ -25,8 +30,15 @@ abstract class Env { @EnviedField(varName: 'ENABLE_UPDATE_CHECK', defaultValue: "1") static final String _enableUpdateChecker = _Env._enableUpdateChecker; + @EnviedField(varName: "RELEASE_CHANNEL", defaultValue: "nightly") + static final String _releaseChannel = _Env._releaseChannel; + + static ReleaseChannel get releaseChannel => _releaseChannel == "stable" + ? ReleaseChannel.stable + : ReleaseChannel.nightly; + static bool get enableUpdateChecker => - DesktopTools.platform.isFlatpak || _enableUpdateChecker == "1"; + kIsFlatpak || _enableUpdateChecker == "1"; static String discordAppId = "1176718791388975124"; -} +} \ No newline at end of file diff --git a/lib/collections/fake.dart b/lib/collections/fake.dart index 4df19dfc9..31f97e0c9 100644 --- a/lib/collections/fake.dart +++ b/lib/collections/fake.dart @@ -1,7 +1,8 @@ import 'package:spotify/spotify.dart'; -import 'package:spotube/extensions/track.dart'; +import 'package:spotube/models/database/database.dart'; import 'package:spotube/models/spotify/home_feed.dart'; import 'package:spotube/models/spotify_friends.dart'; +import 'package:spotube/provider/history/summary.dart'; abstract class FakeData { static final Image image = Image() @@ -223,4 +224,36 @@ abstract class FakeData { ) ], ); + + static const historySummary = PlaybackHistorySummary( + albums: 1, + artists: 1, + duration: Duration(seconds: 1), + playlists: 1, + tracks: 1, + fees: 1, + ); + + static final historyRecentlyPlayedPlaylist = HistoryTableData( + id: 0, + type: HistoryEntryType.track, + createdAt: DateTime.now(), + itemId: "1", + data: playlist.toJson(), + ); + + static final historyRecentlyPlayedAlbum = HistoryTableData( + id: 0, + type: HistoryEntryType.track, + createdAt: DateTime.now(), + itemId: "1", + data: album.toJson(), + ); + + static final historyRecentlyPlayedItems = List.generate( + 10, + (index) => index % 2 == 0 + ? historyRecentlyPlayedPlaylist + : historyRecentlyPlayedAlbum, + ); } diff --git a/lib/collections/formatters.dart b/lib/collections/formatters.dart new file mode 100644 index 000000000..0aed9e9f8 --- /dev/null +++ b/lib/collections/formatters.dart @@ -0,0 +1,8 @@ +import 'package:intl/intl.dart'; + +final compactNumberFormatter = NumberFormat.compact(); +final usdFormatter = NumberFormat.compactCurrency( + locale: 'en-US', + symbol: r"$", + decimalDigits: 2, +); diff --git a/lib/collections/initializers.dart b/lib/collections/initializers.dart index 9627de1c3..976661fc2 100644 --- a/lib/collections/initializers.dart +++ b/lib/collections/initializers.dart @@ -1,9 +1,10 @@ import 'dart:io'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; + +import 'package:spotube/utils/platform.dart'; import 'package:win32_registry/win32_registry.dart'; Future registerWindowsScheme(String scheme) async { - if (!DesktopTools.platform.isWindows) return; + if (!kIsWindows) return; String appPath = Platform.resolvedExecutable; String protocolRegKey = 'Software\\Classes\\$scheme'; diff --git a/lib/collections/intents.dart b/lib/collections/intents.dart index 5f60959ed..4f446831a 100644 --- a/lib/collections/intents.dart +++ b/lib/collections/intents.dart @@ -5,9 +5,12 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:spotube/collections/routes.dart'; -import 'package:spotube/components/player/player_controls.dart'; -import 'package:spotube/models/logger.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/modules/player/player_controls.dart'; +import 'package:spotube/pages/home/home.dart'; +import 'package:spotube/pages/library/library.dart'; +import 'package:spotube/pages/lyrics/lyrics.dart'; +import 'package:spotube/pages/search/search.dart'; +import 'package:spotube/provider/audio_player/querying_track_info.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; import 'package:spotube/utils/platform.dart'; @@ -17,8 +20,6 @@ class PlayPauseIntent extends Intent { } class PlayPauseAction extends Action { - final logger = getLogger(PlayPauseAction); - @override invoke(intent) async { if (PlayerControls.focusNode.canRequestFocus) { @@ -67,16 +68,16 @@ class HomeTabAction extends Action { final router = intent.ref.read(routerProvider); switch (intent.tab) { case HomeTabs.browse: - router.go("/"); + router.goNamed(HomePage.name); break; case HomeTabs.search: - router.go("/search"); + router.goNamed(SearchPage.name); break; case HomeTabs.library: - router.go("/library"); + router.goNamed(LibraryPage.name); break; case HomeTabs.lyrics: - router.go("/lyrics"); + router.goNamed(LyricsPage.name); break; } return null; @@ -92,8 +93,8 @@ class SeekIntent extends Intent { class SeekAction extends Action { @override invoke(intent) async { - final playlist = intent.ref.read(proxyPlaylistProvider); - if (playlist.isFetching) { + final isFetchingActiveTrack = intent.ref.read(queryingTrackInfoProvider); + if (isFetchingActiveTrack) { DirectionalFocusAction().invoke( DirectionalFocusIntent( intent.forward ? TraversalDirection.right : TraversalDirection.left, @@ -101,7 +102,7 @@ class SeekAction extends Action { ); return null; } - final position = (await audioPlayer.position ?? Duration.zero).inSeconds; + final position = audioPlayer.position.inSeconds; await audioPlayer.seek( Duration( seconds: intent.forward ? position + 5 : position - 5, diff --git a/lib/collections/language_codes.dart b/lib/collections/language_codes.dart index 45456d697..44da6ee61 100644 --- a/lib/collections/language_codes.dart +++ b/lib/collections/language_codes.dart @@ -81,10 +81,10 @@ abstract class LanguageLocals { // name: "Bashkir", // nativeName: "башҡорт теле", // ), - // "eu": const ISOLanguageName( - // name: "Basque", - // nativeName: "euskara,", - // ), + "eu": const ISOLanguageName( + name: "Basque", + nativeName: "Euskara", + ), // "be": const ISOLanguageName( // name: "Belarusian", // nativeName: "Беларуская", @@ -197,10 +197,10 @@ abstract class LanguageLocals { // name: "Fijian", // nativeName: "vosa Vakaviti", // ), - // "fi": const ISOLanguageName( - // name: "Finnish", - // nativeName: "suomi", - // ), + "fi": const ISOLanguageName( + name: "Finnish", + nativeName: "suomi", + ), "fr": const ISOLanguageName( name: "French", nativeName: "français", @@ -213,10 +213,10 @@ abstract class LanguageLocals { // name: "Galician", // nativeName: "Galego", // ), - // "ka": const ISOLanguageName( - // name: "Georgian", - // nativeName: "ქართული", - // ), + "ka": const ISOLanguageName( + name: "Georgian", + nativeName: "ქართული", + ), "de": const ISOLanguageName( name: "German", nativeName: "Deutsch", @@ -265,10 +265,10 @@ abstract class LanguageLocals { // name: "Interlingua", // nativeName: "Interlingua", // ), - // "id": const ISOLanguageName( - // name: "Indonesian", - // nativeName: "Bahasa Indonesia", - // ), + "id": const ISOLanguageName( + name: "Indonesian", + nativeName: "Bahasa Indonesia", + ), // "ie": const ISOLanguageName( // name: "Interlingue", // nativeName: "Occidental", @@ -354,8 +354,8 @@ abstract class LanguageLocals { // nativeName: "KiKongo", // ), "ko": const ISOLanguageName( - name: "Korean", - nativeName: "한국어 (韓國語), 조선말 (朝鮮語)", + name: "Korean", + nativeName: "한국어 (韓國語), 조선말 (朝鮮語)", ), // "ku": const ISOLanguageName( // name: "Kurdish", diff --git a/lib/collections/routes.dart b/lib/collections/routes.dart index 080cbd8a2..3bf1d883d 100644 --- a/lib/collections/routes.dart +++ b/lib/collections/routes.dart @@ -1,4 +1,3 @@ -import 'package:catcher_2/catcher_2.dart'; import 'package:flutter/foundation.dart' hide Category; import 'package:flutter/widgets.dart'; import 'package:go_router/go_router.dart'; @@ -14,6 +13,7 @@ import 'package:spotube/pages/home/genres/genre_playlists.dart'; import 'package:spotube/pages/home/genres/genres.dart'; import 'package:spotube/pages/home/home.dart'; import 'package:spotube/pages/lastfm_login/lastfm_login.dart'; +import 'package:spotube/pages/library/local_folder.dart'; import 'package:spotube/pages/library/playlist_generate/playlist_generate.dart'; import 'package:spotube/pages/library/playlist_generate/playlist_generate_result.dart'; import 'package:spotube/pages/lyrics/mini_lyrics.dart'; @@ -24,21 +24,25 @@ import 'package:spotube/pages/search/search.dart'; import 'package:spotube/pages/settings/blacklist.dart'; import 'package:spotube/pages/settings/about.dart'; import 'package:spotube/pages/settings/logs.dart'; +import 'package:spotube/pages/stats/albums/albums.dart'; +import 'package:spotube/pages/stats/artists/artists.dart'; +import 'package:spotube/pages/stats/fees/fees.dart'; +import 'package:spotube/pages/stats/minutes/minutes.dart'; +import 'package:spotube/pages/stats/playlists/playlists.dart'; +import 'package:spotube/pages/stats/stats.dart'; +import 'package:spotube/pages/stats/streams/streams.dart'; import 'package:spotube/pages/track/track.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/services/kv_store/kv_store.dart'; -import 'package:spotube/utils/platform.dart'; -import 'package:spotube/components/shared/spotube_page_route.dart'; +import 'package:spotube/components/spotube_page_route.dart'; import 'package:spotube/pages/artist/artist.dart'; import 'package:spotube/pages/library/library.dart'; -import 'package:spotube/pages/desktop_login/login_tutorial.dart'; -import 'package:spotube/pages/desktop_login/desktop_login.dart'; import 'package:spotube/pages/lyrics/lyrics.dart'; import 'package:spotube/pages/root/root_app.dart'; import 'package:spotube/pages/settings/settings.dart'; import 'package:spotube/pages/mobile_login/mobile_login.dart'; -final rootNavigatorKey = Catcher2.navigatorKey; +final rootNavigatorKey = GlobalKey(); final shellRouteNavigatorKey = GlobalKey(); final routerProvider = Provider((ref) { return GoRouter( @@ -50,12 +54,11 @@ final routerProvider = Provider((ref) { routes: [ GoRoute( path: "/", + name: HomePage.name, redirect: (context, state) async { - final authNotifier = ref.read(authenticationProvider.notifier); - final json = await authNotifier.box.get(authNotifier.cacheKey); + final auth = await ref.read(authenticationProvider.future); - if (json?["cookie"] == null && - !KVStoreService.doneGettingStarted) { + if (auth == null && !KVStoreService.doneGettingStarted) { return "/getting-started"; } @@ -66,11 +69,13 @@ final routerProvider = Provider((ref) { routes: [ GoRoute( path: "genres", + name: GenrePage.name, pageBuilder: (context, state) => const SpotubePage(child: GenrePage()), ), GoRoute( path: "genre/:categoryId", + name: GenrePlaylistsPage.name, pageBuilder: (context, state) => SpotubePage( child: GenrePlaylistsPage( category: state.extra as Category, @@ -79,6 +84,7 @@ final routerProvider = Provider((ref) { ), GoRoute( path: "feeds/:feedId", + name: HomeFeedSectionPage.name, pageBuilder: (context, state) => SpotubePage( child: HomeFeedSectionPage( sectionUri: state.pathParameters["feedId"] as String, @@ -89,45 +95,62 @@ final routerProvider = Provider((ref) { ), GoRoute( path: "/search", - name: "Search", + name: SearchPage.name, pageBuilder: (context, state) => const SpotubePage(child: SearchPage()), ), GoRoute( path: "/library", - name: "Library", + name: LibraryPage.name, pageBuilder: (context, state) => const SpotubePage(child: LibraryPage()), routes: [ GoRoute( - path: "generate", - pageBuilder: (context, state) => - const SpotubePage(child: PlaylistGeneratorPage()), - routes: [ - GoRoute( - path: "result", - pageBuilder: (context, state) => SpotubePage( - child: PlaylistGenerateResultPage( - state: state.extra as GeneratePlaylistProviderInput, - ), + path: "generate", + name: PlaylistGeneratorPage.name, + pageBuilder: (context, state) => + const SpotubePage(child: PlaylistGeneratorPage()), + routes: [ + GoRoute( + path: "result", + name: PlaylistGenerateResultPage.name, + pageBuilder: (context, state) => SpotubePage( + child: PlaylistGenerateResultPage( + state: state.extra as GeneratePlaylistProviderInput, ), ), - ]), + ) + ], + ), + GoRoute( + path: "local", + name: LocalLibraryPage.name, + pageBuilder: (context, state) { + assert(state.extra is String); + return SpotubePage( + child: LocalLibraryPage(state.extra as String, + isDownloads: + state.uri.queryParameters["downloads"] != null), + ); + }, + ), ]), GoRoute( path: "/lyrics", - name: "Lyrics", + name: LyricsPage.name, pageBuilder: (context, state) => const SpotubePage(child: LyricsPage()), ), GoRoute( path: "/settings", + name: SettingsPage.name, pageBuilder: (context, state) => const SpotubePage( child: SettingsPage(), ), routes: [ GoRoute( path: "blacklist", + name: BlackListPage.name, pageBuilder: (context, state) => SpotubeSlidePage( child: const BlackListPage(), ), @@ -135,12 +158,14 @@ final routerProvider = Provider((ref) { if (!kIsWeb) GoRoute( path: "logs", + name: LogsPage.name, pageBuilder: (context, state) => SpotubeSlidePage( child: const LogsPage(), ), ), GoRoute( path: "about", + name: AboutSpotube.name, pageBuilder: (context, state) => SpotubeSlidePage( child: const AboutSpotube(), ), @@ -149,6 +174,7 @@ final routerProvider = Provider((ref) { ), GoRoute( path: "/album/:id", + name: AlbumPage.name, pageBuilder: (context, state) { assert(state.extra is AlbumSimple); return SpotubePage( @@ -158,6 +184,7 @@ final routerProvider = Provider((ref) { ), GoRoute( path: "/artist/:id", + name: ArtistPage.name, pageBuilder: (context, state) { assert(state.pathParameters["id"] != null); return SpotubePage( @@ -166,6 +193,7 @@ final routerProvider = Provider((ref) { ), GoRoute( path: "/playlist/:id", + name: PlaylistPage.name, pageBuilder: (context, state) { assert(state.extra is PlaylistSimple); return SpotubePage( @@ -177,6 +205,7 @@ final routerProvider = Provider((ref) { ), GoRoute( path: "/track/:id", + name: TrackPage.name, pageBuilder: (context, state) { final id = state.pathParameters["id"]!; return SpotubePage( @@ -186,12 +215,14 @@ final routerProvider = Provider((ref) { ), GoRoute( path: "/connect", + name: ConnectPage.name, pageBuilder: (context, state) => const SpotubePage( child: ConnectPage(), ), routes: [ GoRoute( path: "control", + name: ConnectControlPage.name, pageBuilder: (context, state) { return const SpotubePage( child: ConnectControlPage(), @@ -202,13 +233,66 @@ final routerProvider = Provider((ref) { ), GoRoute( path: "/profile", + name: ProfilePage.name, pageBuilder: (context, state) => const SpotubePage(child: ProfilePage()), + ), + GoRoute( + path: "/stats", + name: StatsPage.name, + pageBuilder: (context, state) => const SpotubePage( + child: StatsPage(), + ), + routes: [ + GoRoute( + path: "minutes", + name: StatsMinutesPage.name, + pageBuilder: (context, state) => const SpotubePage( + child: StatsMinutesPage(), + ), + ), + GoRoute( + path: "streams", + name: StatsStreamsPage.name, + pageBuilder: (context, state) => const SpotubePage( + child: StatsStreamsPage(), + ), + ), + GoRoute( + path: "fees", + name: StatsStreamFeesPage.name, + pageBuilder: (context, state) => const SpotubePage( + child: StatsStreamFeesPage(), + ), + ), + GoRoute( + path: "artists", + name: StatsArtistsPage.name, + pageBuilder: (context, state) => const SpotubePage( + child: StatsArtistsPage(), + ), + ), + GoRoute( + path: "albums", + name: StatsAlbumsPage.name, + pageBuilder: (context, state) => const SpotubePage( + child: StatsAlbumsPage(), + ), + ), + GoRoute( + path: "playlists", + name: StatsPlaylistsPage.name, + pageBuilder: (context, state) => const SpotubePage( + child: StatsPlaylistsPage(), + ), + ), + ], ) ], ), GoRoute( path: "/mini-player", + name: MiniLyricsPage.name, parentNavigatorKey: rootNavigatorKey, pageBuilder: (context, state) => SpotubePage( child: MiniLyricsPage(prevSize: state.extra as Size), @@ -216,6 +300,7 @@ final routerProvider = Provider((ref) { ), GoRoute( path: "/getting-started", + name: GettingStarting.name, parentNavigatorKey: rootNavigatorKey, pageBuilder: (context, state) => const SpotubePage( child: GettingStarting(), @@ -223,20 +308,15 @@ final routerProvider = Provider((ref) { ), GoRoute( path: "/login", - parentNavigatorKey: rootNavigatorKey, - pageBuilder: (context, state) => SpotubePage( - child: kIsMobile ? const WebViewLogin() : const DesktopLoginPage(), - ), - ), - GoRoute( - path: "/login-tutorial", + name: WebViewLogin.name, parentNavigatorKey: rootNavigatorKey, pageBuilder: (context, state) => const SpotubePage( - child: LoginTutorial(), + child: WebViewLogin(), ), ), GoRoute( path: "/lastfm-login", + name: LastFMLoginPage.name, parentNavigatorKey: rootNavigatorKey, pageBuilder: (context, state) => const SpotubePage(child: LastFMLoginPage()), diff --git a/lib/collections/side_bar_tiles.dart b/lib/collections/side_bar_tiles.dart index 551d70d72..4f23c049a 100644 --- a/lib/collections/side_bar_tiles.dart +++ b/lib/collections/side_bar_tiles.dart @@ -1,33 +1,82 @@ import 'package:flutter/material.dart'; import 'package:spotube/collections/spotube_icons.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:spotube/pages/home/home.dart'; +import 'package:spotube/pages/library/library.dart'; +import 'package:spotube/pages/lyrics/lyrics.dart'; +import 'package:spotube/pages/search/search.dart'; +import 'package:spotube/pages/stats/stats.dart'; class SideBarTiles { final IconData icon; final String title; final String id; - SideBarTiles({required this.icon, required this.title, required this.id}); + final String name; + + SideBarTiles({ + required this.icon, + required this.title, + required this.id, + required this.name, + }); } List getSidebarTileList(AppLocalizations l10n) => [ - SideBarTiles(id: "browse", icon: SpotubeIcons.home, title: l10n.browse), - SideBarTiles(id: "search", icon: SpotubeIcons.search, title: l10n.search), SideBarTiles( - id: "library", icon: SpotubeIcons.library, title: l10n.library), - SideBarTiles(id: "lyrics", icon: SpotubeIcons.music, title: l10n.lyrics), + id: "browse", + name: HomePage.name, + icon: SpotubeIcons.home, + title: l10n.browse, + ), + SideBarTiles( + id: "search", + name: SearchPage.name, + icon: SpotubeIcons.search, + title: l10n.search, + ), + SideBarTiles( + id: "library", + name: LibraryPage.name, + icon: SpotubeIcons.library, + title: l10n.library, + ), + SideBarTiles( + id: "lyrics", + name: LyricsPage.name, + icon: SpotubeIcons.music, + title: l10n.lyrics, + ), + SideBarTiles( + id: "stats", + name: StatsPage.name, + icon: SpotubeIcons.chart, + title: l10n.stats, + ), ]; List getNavbarTileList(AppLocalizations l10n) => [ - SideBarTiles(id: "browse", icon: SpotubeIcons.home, title: l10n.browse), - SideBarTiles(id: "search", icon: SpotubeIcons.search, title: l10n.search), + SideBarTiles( + id: "browse", + name: HomePage.name, + icon: SpotubeIcons.home, + title: l10n.browse, + ), + SideBarTiles( + id: "search", + name: SearchPage.name, + icon: SpotubeIcons.search, + title: l10n.search, + ), SideBarTiles( id: "library", + name: LibraryPage.name, icon: SpotubeIcons.library, title: l10n.library, ), SideBarTiles( - id: "settings", - icon: SpotubeIcons.settings, - title: l10n.settings, - ) + id: "stats", + name: StatsPage.name, + icon: SpotubeIcons.chart, + title: l10n.stats, + ), ]; diff --git a/lib/collections/spotube_icons.dart b/lib/collections/spotube_icons.dart index 6de212840..a45e581ed 100644 --- a/lib/collections/spotube_icons.dart +++ b/lib/collections/spotube_icons.dart @@ -121,4 +121,7 @@ abstract class SpotubeIcons { static const monitor = FeatherIcons.monitor; static const power = FeatherIcons.power; static const bluetooth = FeatherIcons.bluetooth; + static const chart = FeatherIcons.barChart2; + static const folderAdd = FeatherIcons.folderPlus; + static const folderRemove = FeatherIcons.folderMinus; } diff --git a/lib/components/shared/adaptive/adaptive_list_tile.dart b/lib/components/adaptive/adaptive_list_tile.dart similarity index 100% rename from lib/components/shared/adaptive/adaptive_list_tile.dart rename to lib/components/adaptive/adaptive_list_tile.dart diff --git a/lib/components/shared/adaptive/adaptive_pop_sheet_list.dart b/lib/components/adaptive/adaptive_pop_sheet_list.dart similarity index 97% rename from lib/components/shared/adaptive/adaptive_pop_sheet_list.dart rename to lib/components/adaptive/adaptive_pop_sheet_list.dart index 21f56a220..97dc61321 100644 --- a/lib/components/shared/adaptive/adaptive_pop_sheet_list.dart +++ b/lib/components/adaptive/adaptive_pop_sheet_list.dart @@ -187,7 +187,7 @@ class AdaptivePopSheetList extends StatelessWidget { icon: icon ?? const Icon(SpotubeIcons.moreVertical), tooltip: tooltip, style: theme.iconButtonTheme.style?.copyWith( - shape: MaterialStatePropertyAll( + shape: WidgetStatePropertyAll( RoundedRectangleBorder( borderRadius: borderRadius, ), @@ -226,7 +226,10 @@ class _AdaptivePopSheetListItem extends StatelessWidget { }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 8), - child: IgnorePointer(child: item), + child: IconTheme.merge( + data: const IconThemeData(opacity: 1), + child: IgnorePointer(child: item), + ), ), ); } diff --git a/lib/components/shared/adaptive/adaptive_popup_menu_button.dart b/lib/components/adaptive/adaptive_popup_menu_button.dart similarity index 100% rename from lib/components/shared/adaptive/adaptive_popup_menu_button.dart rename to lib/components/adaptive/adaptive_popup_menu_button.dart diff --git a/lib/components/shared/adaptive/adaptive_select_tile.dart b/lib/components/adaptive/adaptive_select_tile.dart similarity index 100% rename from lib/components/shared/adaptive/adaptive_select_tile.dart rename to lib/components/adaptive/adaptive_select_tile.dart diff --git a/lib/components/shared/animated_gradient.dart b/lib/components/animated_gradient.dart similarity index 100% rename from lib/components/shared/animated_gradient.dart rename to lib/components/animated_gradient.dart diff --git a/lib/components/shared/bordered_text.dart b/lib/components/bordered_text.dart similarity index 100% rename from lib/components/shared/bordered_text.dart rename to lib/components/bordered_text.dart diff --git a/lib/components/shared/compact_search.dart b/lib/components/compact_search.dart similarity index 100% rename from lib/components/shared/compact_search.dart rename to lib/components/compact_search.dart diff --git a/lib/components/desktop_login/login_form.dart b/lib/components/desktop_login/login_form.dart deleted file mode 100644 index 2949fbae7..000000000 --- a/lib/components/desktop_login/login_form.dart +++ /dev/null @@ -1,73 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/extensions/context.dart'; - -import 'package:spotube/provider/authentication_provider.dart'; - -class TokenLoginForm extends HookConsumerWidget { - final void Function()? onDone; - const TokenLoginForm({ - super.key, - this.onDone, - }); - - @override - Widget build(BuildContext context, ref) { - final authenticationNotifier = ref.watch(authenticationProvider.notifier); - final directCodeController = useTextEditingController(); - final mounted = useIsMounted(); - - final isLoading = useState(false); - - return ConstrainedBox( - constraints: const BoxConstraints( - maxWidth: 400, - ), - child: Column( - children: [ - TextField( - controller: directCodeController, - decoration: InputDecoration( - hintText: context.l10n.spotify_cookie("\"sp_dc\""), - labelText: context.l10n.cookie_name_cookie("sp_dc"), - ), - keyboardType: TextInputType.visiblePassword, - ), - const SizedBox(height: 10), - FilledButton( - onPressed: isLoading.value - ? null - : () async { - try { - isLoading.value = true; - if (directCodeController.text.isEmpty) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(context.l10n.fill_in_all_fields), - behavior: SnackBarBehavior.floating, - ), - ); - return; - } - final cookieHeader = - "sp_dc=${directCodeController.text.trim()}"; - - authenticationNotifier.setCredentials( - await AuthenticationCredentials.fromCookie( - cookieHeader), - ); - if (mounted()) { - onDone?.call(); - } - } finally { - isLoading.value = false; - } - }, - child: Text(context.l10n.submit), - ) - ], - ), - ); - } -} diff --git a/lib/components/shared/dialogs/confirm_download_dialog.dart b/lib/components/dialogs/confirm_download_dialog.dart similarity index 97% rename from lib/components/shared/dialogs/confirm_download_dialog.dart rename to lib/components/dialogs/confirm_download_dialog.dart index 486310a7a..897c64cb2 100644 --- a/lib/components/shared/dialogs/confirm_download_dialog.dart +++ b/lib/components/dialogs/confirm_download_dialog.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; diff --git a/lib/components/shared/dialogs/piped_down_dialog.dart b/lib/components/dialogs/piped_down_dialog.dart similarity index 100% rename from lib/components/shared/dialogs/piped_down_dialog.dart rename to lib/components/dialogs/piped_down_dialog.dart diff --git a/lib/components/shared/dialogs/playlist_add_track_dialog.dart b/lib/components/dialogs/playlist_add_track_dialog.dart similarity index 96% rename from lib/components/shared/dialogs/playlist_add_track_dialog.dart rename to lib/components/dialogs/playlist_add_track_dialog.dart index 5d493a68d..5af9c9e4d 100644 --- a/lib/components/shared/dialogs/playlist_add_track_dialog.dart +++ b/lib/components/dialogs/playlist_add_track_dialog.dart @@ -4,8 +4,8 @@ import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/playlist/playlist_create_dialog.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/modules/playlist/playlist_create_dialog.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/provider/spotify/spotify.dart'; diff --git a/lib/components/shared/dialogs/prompt_dialog.dart b/lib/components/dialogs/prompt_dialog.dart similarity index 100% rename from lib/components/shared/dialogs/prompt_dialog.dart rename to lib/components/dialogs/prompt_dialog.dart diff --git a/lib/components/shared/dialogs/replace_downloaded_dialog.dart b/lib/components/dialogs/replace_downloaded_dialog.dart similarity index 100% rename from lib/components/shared/dialogs/replace_downloaded_dialog.dart rename to lib/components/dialogs/replace_downloaded_dialog.dart diff --git a/lib/components/shared/dialogs/select_device_dialog.dart b/lib/components/dialogs/select_device_dialog.dart similarity index 88% rename from lib/components/shared/dialogs/select_device_dialog.dart rename to lib/components/dialogs/select_device_dialog.dart index cd8dedb7c..3a3bde60a 100644 --- a/lib/components/shared/dialogs/select_device_dialog.dart +++ b/lib/components/dialogs/select_device_dialog.dart @@ -15,15 +15,12 @@ class SelectDeviceDialog extends HookConsumerWidget { final remoteService = connectClients.asData!.value.resolvedService!; return AlertDialog( - title: const Text("Choose the device:"), + title: Text(context.l10n.choose_the_device), insetPadding: const EdgeInsets.all(16), content: Column( mainAxisSize: MainAxisSize.min, children: [ - const Text( - "There are multiple device connected.\n" - "Choose the device you want this action to take place", - ), + Text(context.l10n.multiple_device_connected), RadioListTile.adaptive( title: Text(remoteService.name), value: true, @@ -33,7 +30,7 @@ class SelectDeviceDialog extends HookConsumerWidget { }, ), RadioListTile.adaptive( - title: const Text("This Device"), + title: Text(context.l10n.this_device), value: false, groupValue: isRemoteService.value, onChanged: (value) { diff --git a/lib/components/shared/dialogs/track_details_dialog.dart b/lib/components/dialogs/track_details_dialog.dart similarity index 96% rename from lib/components/shared/dialogs/track_details_dialog.dart rename to lib/components/dialogs/track_details_dialog.dart index da2a140b9..61bca7b1f 100644 --- a/lib/components/shared/dialogs/track_details_dialog.dart +++ b/lib/components/dialogs/track_details_dialog.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/links/artist_link.dart'; -import 'package:spotube/components/shared/links/hyper_link.dart'; -import 'package:spotube/components/shared/links/link_text.dart'; +import 'package:spotube/components/links/artist_link.dart'; +import 'package:spotube/components/links/hyper_link.dart'; +import 'package:spotube/components/links/link_text.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/services/sourced_track/sourced_track.dart'; @@ -28,6 +28,7 @@ class TrackDetailsDialog extends HookWidget { artists: track.artists ?? [], mainAxisAlignment: WrapAlignment.start, textStyle: const TextStyle(color: Colors.blue), + hideOverflowArtist: false, ), context.l10n.album: LinkText( track.album!.name!, diff --git a/lib/components/shared/expandable_search/expandable_search.dart b/lib/components/expandable_search/expandable_search.dart similarity index 100% rename from lib/components/shared/expandable_search/expandable_search.dart rename to lib/components/expandable_search/expandable_search.dart diff --git a/lib/components/shared/fallbacks/anonymous_fallback.dart b/lib/components/fallbacks/anonymous_fallback.dart similarity index 61% rename from lib/components/shared/fallbacks/anonymous_fallback.dart rename to lib/components/fallbacks/anonymous_fallback.dart index 2f06b0b6f..62ed8ddd6 100644 --- a/lib/components/shared/fallbacks/anonymous_fallback.dart +++ b/lib/components/fallbacks/anonymous_fallback.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:spotube/extensions/context.dart'; +import 'package:spotube/pages/settings/settings.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/utils/service_utils.dart'; class AnonymousFallback extends ConsumerWidget { @@ -14,9 +15,13 @@ class AnonymousFallback extends ConsumerWidget { @override Widget build(BuildContext context, ref) { - final isLoggedIn = ref.watch(authenticationProvider) != null; + final isLoggedIn = ref.watch(authenticationProvider); - if (isLoggedIn && child != null) return child!; + if (isLoggedIn.isLoading) { + return const Center(child: CircularProgressIndicator()); + } + + if (isLoggedIn.asData?.value != null && child != null) return child!; return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -25,7 +30,7 @@ class AnonymousFallback extends ConsumerWidget { const SizedBox(height: 10), FilledButton( child: Text(context.l10n.login_with_spotify), - onPressed: () => ServiceUtils.push(context, "/settings"), + onPressed: () => ServiceUtils.pushNamed(context, SettingsPage.name), ) ], ), diff --git a/lib/components/shared/fallbacks/not_found.dart b/lib/components/fallbacks/not_found.dart similarity index 81% rename from lib/components/shared/fallbacks/not_found.dart rename to lib/components/fallbacks/not_found.dart index 5a74f6720..ce168f178 100644 --- a/lib/components/shared/fallbacks/not_found.dart +++ b/lib/components/fallbacks/not_found.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:spotube/collections/assets.gen.dart'; +import 'package:spotube/extensions/context.dart'; class NotFound extends StatelessWidget { final bool vertical; @@ -18,9 +19,9 @@ class NotFound extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ - Text("Nothing found", style: theme.textTheme.titleLarge), + Text(context.l10n.nothing_found, style: theme.textTheme.titleLarge), Text( - "The box is empty", + context.l10n.the_box_is_empty, style: theme.textTheme.titleMedium, ), ], diff --git a/lib/components/shared/heart_button.dart b/lib/components/heart_button/heart_button.dart similarity index 66% rename from lib/components/shared/heart_button.dart rename to lib/components/heart_button/heart_button.dart index c296d7a9c..fa4318cc0 100644 --- a/lib/components/shared/heart_button.dart +++ b/lib/components/heart_button/heart_button.dart @@ -1,11 +1,10 @@ import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; +import 'package:spotube/components/heart_button/use_track_toggle_like.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/provider/authentication_provider.dart'; -import 'package:spotube/provider/scrobbler_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class HeartButton extends HookConsumerWidget { @@ -27,7 +26,7 @@ class HeartButton extends HookConsumerWidget { Widget build(BuildContext context, ref) { final auth = ref.watch(authenticationProvider); - if (auth == null) return const SizedBox.shrink(); + if (auth.asData?.value == null) return const SizedBox.shrink(); return IconButton( tooltip: tooltip, @@ -55,38 +54,6 @@ class HeartButton extends HookConsumerWidget { } } -typedef UseTrackToggleLike = ({ - bool isLiked, - Future Function(Track track) toggleTrackLike, -}); - -UseTrackToggleLike useTrackToggleLike(Track track, WidgetRef ref) { - final savedTracks = ref.watch(likedTracksProvider); - final savedTracksNotifier = ref.watch(likedTracksProvider.notifier); - - final isLiked = useMemoized( - () => - savedTracks.asData?.value.any((element) => element.id == track.id) ?? - false, - [savedTracks.asData?.value, track.id], - ); - - final scrobblerNotifier = ref.read(scrobblerProvider.notifier); - - return ( - isLiked: isLiked, - toggleTrackLike: (track) async { - await savedTracksNotifier.toggleFavorite(track); - - if (!isLiked) { - await scrobblerNotifier.love(track); - } else { - await scrobblerNotifier.unlove(track); - } - }, - ); -} - class TrackHeartButton extends HookConsumerWidget { final Track track; const TrackHeartButton({ diff --git a/lib/components/heart_button/use_track_toggle_like.dart b/lib/components/heart_button/use_track_toggle_like.dart new file mode 100644 index 000000000..ba5cbee11 --- /dev/null +++ b/lib/components/heart_button/use_track_toggle_like.dart @@ -0,0 +1,37 @@ +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/provider/scrobbler/scrobbler.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; + +typedef UseTrackToggleLike = ({ + bool isLiked, + Future Function(Track track) toggleTrackLike, +}); + +UseTrackToggleLike useTrackToggleLike(Track track, WidgetRef ref) { + final savedTracks = ref.watch(likedTracksProvider); + final savedTracksNotifier = ref.watch(likedTracksProvider.notifier); + + final isLiked = useMemoized( + () => + savedTracks.asData?.value.any((element) => element.id == track.id) ?? + false, + [savedTracks.asData?.value, track.id], + ); + + final scrobblerNotifier = ref.read(scrobblerProvider.notifier); + + return ( + isLiked: isLiked, + toggleTrackLike: (track) async { + await savedTracksNotifier.toggleFavorite(track); + + if (!isLiked) { + await scrobblerNotifier.love(track); + } else { + await scrobblerNotifier.unlove(track); + } + }, + ); +} diff --git a/lib/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart b/lib/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart similarity index 95% rename from lib/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart rename to lib/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart index e142cb35c..16204952d 100644 --- a/lib/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart +++ b/lib/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart @@ -5,9 +5,9 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/fake.dart'; -import 'package:spotube/components/album/album_card.dart'; -import 'package:spotube/components/artist/artist_card.dart'; -import 'package:spotube/components/playlist/playlist_card.dart'; +import 'package:spotube/modules/album/album_card.dart'; +import 'package:spotube/modules/artist/artist_card.dart'; +import 'package:spotube/modules/playlist/playlist_card.dart'; import 'package:spotube/hooks/utils/use_breakpoint_value.dart'; import 'package:very_good_infinite_list/very_good_infinite_list.dart'; @@ -96,7 +96,7 @@ class HorizontalPlaybuttonCardView extends HookWidget { return switch (item) { PlaylistSimple() => PlaylistCard(item as PlaylistSimple), - AlbumSimple() => AlbumCard(item as Album), + AlbumSimple() => AlbumCard(item as AlbumSimple), Artist() => Padding( padding: const EdgeInsets.symmetric( horizontal: 12.0), diff --git a/lib/components/shared/hover_builder.dart b/lib/components/hover_builder.dart similarity index 100% rename from lib/components/shared/hover_builder.dart rename to lib/components/hover_builder.dart diff --git a/lib/components/shared/image/universal_image.dart b/lib/components/image/universal_image.dart similarity index 100% rename from lib/components/shared/image/universal_image.dart rename to lib/components/image/universal_image.dart diff --git a/lib/components/shared/inter_scrollbar/inter_scrollbar.dart b/lib/components/inter_scrollbar/inter_scrollbar.dart similarity index 80% rename from lib/components/shared/inter_scrollbar/inter_scrollbar.dart rename to lib/components/inter_scrollbar/inter_scrollbar.dart index 2b3ce3192..8a86b6439 100644 --- a/lib/components/shared/inter_scrollbar/inter_scrollbar.dart +++ b/lib/components/inter_scrollbar/inter_scrollbar.dart @@ -1,7 +1,7 @@ import 'package:draggable_scrollbar/draggable_scrollbar.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:spotube/utils/platform.dart'; class InterScrollbar extends HookWidget { final Widget child; @@ -15,7 +15,7 @@ class InterScrollbar extends HookWidget { @override Widget build(BuildContext context) { - if (DesktopTools.platform.isDesktop) return child; + if (kIsDesktop) return child; return DraggableScrollbar.semicircle( controller: controller, diff --git a/lib/components/library/user_local_tracks.dart b/lib/components/library/user_local_tracks.dart deleted file mode 100644 index a7b2102b8..000000000 --- a/lib/components/library/user_local_tracks.dart +++ /dev/null @@ -1,331 +0,0 @@ -import 'dart:io'; - -import 'package:catcher_2/catcher_2.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:collection/collection.dart'; -import 'package:fuzzywuzzy/fuzzywuzzy.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:metadata_god/metadata_god.dart'; -import 'package:mime/mime.dart'; -import 'package:path/path.dart'; -import 'package:path_provider/path_provider.dart'; -import 'package:skeletonizer/skeletonizer.dart'; - -import 'package:spotify/spotify.dart'; -import 'package:spotube/collections/fake.dart'; -import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/expandable_search/expandable_search.dart'; -import 'package:spotube/components/shared/fallbacks/not_found.dart'; -import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart'; -import 'package:spotube/components/shared/sort_tracks_dropdown.dart'; -import 'package:spotube/components/shared/track_tile/track_tile.dart'; -import 'package:spotube/extensions/artist_simple.dart'; -import 'package:spotube/extensions/context.dart'; -import 'package:spotube/extensions/track.dart'; -import 'package:spotube/models/local_track.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/utils/service_utils.dart'; -// ignore: depend_on_referenced_packages -import 'package:flutter_rust_bridge/flutter_rust_bridge.dart' show FfiException; - -const supportedAudioTypes = [ - "audio/webm", - "audio/ogg", - "audio/mpeg", - "audio/mp4", - "audio/opus", - "audio/wav", - "audio/aac", -]; - -const imgMimeToExt = { - "image/png": ".png", - "image/jpeg": ".jpg", - "image/webp": ".webp", - "image/gif": ".gif", -}; - -enum SortBy { - none, - ascending, - descending, - newest, - oldest, - duration, - artist, - album, -} - -final localTracksProvider = FutureProvider>((ref) async { - try { - if (kIsWeb) return []; - final downloadLocation = ref.watch( - userPreferencesProvider.select((s) => s.downloadLocation), - ); - if (downloadLocation.isEmpty) return []; - final downloadDir = Directory(downloadLocation); - if (!await downloadDir.exists()) { - await downloadDir.create(recursive: true); - return []; - } - final entities = downloadDir.listSync(recursive: true); - - final filesWithMetadata = (await Future.wait( - entities.map((e) => File(e.path)).where((file) { - final mimetype = lookupMimeType(file.path); - return mimetype != null && supportedAudioTypes.contains(mimetype); - }).map( - (file) async { - try { - final metadata = await MetadataGod.readMetadata(file: file.path); - - final imageFile = File(join( - (await getTemporaryDirectory()).path, - "spotube", - basenameWithoutExtension(file.path) + - imgMimeToExt[metadata.picture?.mimeType ?? "image/jpeg"]!, - )); - if (!await imageFile.exists() && metadata.picture != null) { - await imageFile.create(recursive: true); - await imageFile.writeAsBytes( - metadata.picture?.data ?? [], - mode: FileMode.writeOnly, - ); - } - - return {"metadata": metadata, "file": file, "art": imageFile.path}; - } catch (e, stack) { - if (e is FfiException) { - return {"file": file}; - } - Catcher2.reportCheckedError(e, stack); - return {}; - } - }, - ), - )) - .where((e) => e.isNotEmpty) - .toList(); - - final tracks = filesWithMetadata - .map( - (fileWithMetadata) => LocalTrack.fromTrack( - track: Track().fromFile( - fileWithMetadata["file"], - metadata: fileWithMetadata["metadata"], - art: fileWithMetadata["art"], - ), - path: fileWithMetadata["file"].path, - ), - ) - .toList(); - - return tracks; - } catch (e, stack) { - Catcher2.reportCheckedError(e, stack); - return []; - } -}); - -class UserLocalTracks extends HookConsumerWidget { - const UserLocalTracks({super.key}); - - Future playLocalTracks( - WidgetRef ref, - List tracks, { - LocalTrack? currentTrack, - }) async { - final playlist = ref.read(proxyPlaylistProvider); - final playback = ref.read(proxyPlaylistProvider.notifier); - currentTrack ??= tracks.first; - final isPlaylistPlaying = playlist.containsTracks(tracks); - if (!isPlaylistPlaying) { - await playback.load( - tracks, - initialIndex: tracks.indexWhere((s) => s.id == currentTrack?.id), - autoPlay: true, - ); - } else if (isPlaylistPlaying && - currentTrack.id != null && - currentTrack.id != playlist.activeTrack?.id) { - await playback.jumpToTrack(currentTrack); - } - } - - @override - Widget build(BuildContext context, ref) { - final sortBy = useState(SortBy.none); - final playlist = ref.watch(proxyPlaylistProvider); - final trackSnapshot = ref.watch(localTracksProvider); - final isPlaylistPlaying = - playlist.containsTracks(trackSnapshot.asData?.value ?? []); - - final searchController = useTextEditingController(); - useValueListenable(searchController); - final searchFocus = useFocusNode(); - final isFiltering = useState(false); - - final controller = useScrollController(); - - return Column( - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: Row( - children: [ - const SizedBox(width: 5), - FilledButton( - onPressed: trackSnapshot.asData?.value != null - ? () async { - if (trackSnapshot.asData?.value.isNotEmpty == true) { - if (!isPlaylistPlaying) { - await playLocalTracks( - ref, - trackSnapshot.asData!.value, - ); - } - } - } - : null, - child: Row( - children: [ - Text(context.l10n.play), - Icon( - isPlaylistPlaying ? SpotubeIcons.stop : SpotubeIcons.play, - ) - ], - ), - ), - const Spacer(), - ExpandableSearchButton( - isFiltering: isFiltering.value, - onPressed: (value) => isFiltering.value = value, - searchFocus: searchFocus, - ), - const SizedBox(width: 10), - SortTracksDropdown( - value: sortBy.value, - onChanged: (value) { - sortBy.value = value; - }, - ), - const SizedBox(width: 5), - FilledButton( - child: const Icon(SpotubeIcons.refresh), - onPressed: () { - ref.invalidate(localTracksProvider); - }, - ) - ], - ), - ), - ExpandableSearchField( - searchController: searchController, - searchFocus: searchFocus, - isFiltering: isFiltering.value, - onChangeFiltering: (value) => isFiltering.value = value, - ), - trackSnapshot.when( - data: (tracks) { - final sortedTracks = useMemoized(() { - return ServiceUtils.sortTracks(tracks, sortBy.value); - }, [sortBy.value, tracks]); - - final filteredTracks = useMemoized(() { - if (searchController.text.isEmpty) { - return sortedTracks; - } - return sortedTracks - .map((e) => ( - weightedRatio( - "${e.name} - ${e.artists?.asString() ?? ""}", - searchController.text, - ), - e, - )) - .toList() - .sorted( - (a, b) => b.$1.compareTo(a.$1), - ) - .where((e) => e.$1 > 50) - .map((e) => e.$2) - .toList() - .toList(); - }, [searchController.text, sortedTracks]); - - if (!trackSnapshot.isLoading && filteredTracks.isEmpty) { - return const Expanded( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [NotFound()], - ), - ); - } - - return Expanded( - child: RefreshIndicator( - onRefresh: () async { - ref.invalidate(localTracksProvider); - }, - child: InterScrollbar( - controller: controller, - child: Skeletonizer( - enabled: trackSnapshot.isLoading, - child: ListView.builder( - controller: controller, - physics: const AlwaysScrollableScrollPhysics(), - itemCount: - trackSnapshot.isLoading ? 5 : filteredTracks.length, - itemBuilder: (context, index) { - if (trackSnapshot.isLoading) { - return TrackTile( - playlist: playlist, - track: FakeData.track, - index: index, - ); - } - - final track = filteredTracks[index]; - return TrackTile( - index: index, - playlist: playlist, - track: track, - userPlaylist: false, - onTap: () async { - await playLocalTracks( - ref, - sortedTracks, - currentTrack: track, - ); - }, - ); - }, - ), - ), - ), - ), - ); - }, - loading: () => Expanded( - child: Skeletonizer( - enabled: true, - child: ListView.builder( - itemCount: 5, - itemBuilder: (context, index) => TrackTile( - track: FakeData.track, - index: index, - playlist: playlist, - ), - ), - ), - ), - error: (error, stackTrace) => - Text(error.toString() + stackTrace.toString()), - ) - ], - ); - } -} diff --git a/lib/components/shared/links/anchor_button.dart b/lib/components/links/anchor_button.dart similarity index 95% rename from lib/components/shared/links/anchor_button.dart rename to lib/components/links/anchor_button.dart index d78bbf962..c6f0b889b 100644 --- a/lib/components/shared/links/anchor_button.dart +++ b/lib/components/links/anchor_button.dart @@ -29,7 +29,7 @@ class AnchorButton extends HookWidget { onTapUp: (event) => tap.value = false, onTap: onTap, child: MouseRegion( - cursor: MaterialStateMouseCursor.clickable, + cursor: WidgetStateMouseCursor.clickable, child: Text( text, style: style.copyWith( diff --git a/lib/components/links/artist_link.dart b/lib/components/links/artist_link.dart new file mode 100644 index 000000000..9f06f1b37 --- /dev/null +++ b/lib/components/links/artist_link.dart @@ -0,0 +1,81 @@ +import 'package:flutter/material.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/components/links/anchor_button.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/pages/artist/artist.dart'; +import 'package:spotube/utils/service_utils.dart'; + +class ArtistLink extends StatelessWidget { + final List artists; + final WrapCrossAlignment crossAxisAlignment; + final WrapAlignment mainAxisAlignment; + final TextStyle textStyle; + final bool hideOverflowArtist; + final void Function(String route)? onRouteChange; + final VoidCallback? onOverflowArtistClick; + + const ArtistLink({ + super.key, + required this.artists, + this.crossAxisAlignment = WrapCrossAlignment.center, + this.mainAxisAlignment = WrapAlignment.center, + this.textStyle = const TextStyle(), + this.onRouteChange, + this.hideOverflowArtist = true, + this.onOverflowArtistClick, + }) : assert(hideOverflowArtist ? onOverflowArtistClick != null : true); + + @override + Widget build(BuildContext context) { + final ThemeData(:colorScheme) = Theme.of(context); + + return Wrap( + crossAxisAlignment: crossAxisAlignment, + alignment: mainAxisAlignment, + children: [ + ...(hideOverflowArtist ? artists.take(3).toList() : artists) + .asMap() + .entries + .map( + (artist) => Builder(builder: (context) { + if (artist.value.name == null) { + return Text("Spotify", style: textStyle); + } + return AnchorButton( + (artist.key != artists.length - 1) + ? "${artist.value.name}, " + : artist.value.name!, + onTap: () { + if (onRouteChange != null) { + onRouteChange?.call("/artist/${artist.value.id}"); + } else { + ServiceUtils.pushNamed( + context, + ArtistPage.name, + pathParameters: { + "id": artist.value.id!, + }, + ); + } + }, + overflow: TextOverflow.ellipsis, + style: textStyle, + ); + }), + ), + if (hideOverflowArtist && artists.length > 3) + AnchorButton( + context.l10n.and_n_more(artists.length - 3), + onTap: () { + onOverflowArtistClick?.call(); + }, + overflow: TextOverflow.ellipsis, + style: textStyle.copyWith( + color: colorScheme.secondary, + decoration: TextDecoration.underline, + ), + ), + ], + ); + } +} diff --git a/lib/components/shared/links/hyper_link.dart b/lib/components/links/hyper_link.dart similarity index 92% rename from lib/components/shared/links/hyper_link.dart rename to lib/components/links/hyper_link.dart index f84517b45..32d715e01 100644 --- a/lib/components/shared/links/hyper_link.dart +++ b/lib/components/links/hyper_link.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:spotube/components/shared/links/anchor_button.dart'; +import 'package:spotube/components/links/anchor_button.dart'; import 'package:url_launcher/url_launcher_string.dart'; class Hyperlink extends StatelessWidget { diff --git a/lib/components/shared/links/link_text.dart b/lib/components/links/link_text.dart similarity index 93% rename from lib/components/shared/links/link_text.dart rename to lib/components/links/link_text.dart index db7b6358c..0cab71d0d 100644 --- a/lib/components/shared/links/link_text.dart +++ b/lib/components/links/link_text.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:spotube/components/shared/links/anchor_button.dart'; +import 'package:spotube/components/links/anchor_button.dart'; import 'package:spotube/utils/service_utils.dart'; class LinkText extends StatelessWidget { diff --git a/lib/components/shared/panels/controller.dart b/lib/components/panels/controller.dart similarity index 99% rename from lib/components/shared/panels/controller.dart rename to lib/components/panels/controller.dart index 65c2444e7..834e9ce6d 100644 --- a/lib/components/shared/panels/controller.dart +++ b/lib/components/panels/controller.dart @@ -1,4 +1,4 @@ -part of './sliding_up_panel.dart'; +part of 'sliding_up_panel.dart'; class PanelController extends ChangeNotifier { SlidingUpPanelState? _panelState; diff --git a/lib/components/shared/panels/helpers.dart b/lib/components/panels/helpers.dart similarity index 98% rename from lib/components/shared/panels/helpers.dart rename to lib/components/panels/helpers.dart index 6d0dde310..d79fa97c7 100644 --- a/lib/components/shared/panels/helpers.dart +++ b/lib/components/panels/helpers.dart @@ -1,4 +1,4 @@ -part of "./sliding_up_panel.dart"; +part of "sliding_up_panel.dart"; /// if you want to prevent the panel from being dragged using the widget, /// wrap the widget with this diff --git a/lib/components/shared/panels/sliding_up_panel.dart b/lib/components/panels/sliding_up_panel.dart similarity index 100% rename from lib/components/shared/panels/sliding_up_panel.dart rename to lib/components/panels/sliding_up_panel.dart diff --git a/lib/components/shared/playbutton_card.dart b/lib/components/playbutton_card.dart similarity index 91% rename from lib/components/shared/playbutton_card.dart rename to lib/components/playbutton_card.dart index 80a27eb01..d540d31e2 100644 --- a/lib/components/shared/playbutton_card.dart +++ b/lib/components/playbutton_card.dart @@ -3,23 +3,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:gap/gap.dart'; import 'package:skeletonizer/skeletonizer.dart'; - import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/hover_builder.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/components/hover_builder.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/extensions/constrains.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/extensions/string.dart'; import 'package:spotube/hooks/utils/use_breakpoint_value.dart'; import 'package:spotube/hooks/utils/use_brightness_value.dart'; -final htmlTagRegexp = RegExp(r"<[^>]*>", caseSensitive: true); - -String? useDescription(String? description) { - return useMemoized(() { - if (description == null) return null; - return description.replaceAll(htmlTagRegexp, ''); - }, [description]); -} - class PlaybuttonCard extends HookWidget { final void Function()? onTap; final void Function()? onPlaybuttonPressed; @@ -66,19 +58,18 @@ class PlaybuttonCard extends HookWidget { others: 15, ); - final cleanDescription = useDescription(description); - + var unescapeHtml = description?.unescapeHtml(); return Container( constraints: BoxConstraints(maxWidth: size), margin: margin, child: Material( color: Color.lerp( - theme.colorScheme.surfaceVariant, + theme.colorScheme.surfaceContainerHighest, theme.colorScheme.surface, useBrightnessValue(.9, .7), ), borderRadius: radius, - shadowColor: theme.colorScheme.background, + shadowColor: theme.colorScheme.surface, elevation: 3, child: InkWell( mouseCursor: SystemMouseCursors.click, @@ -137,7 +128,7 @@ class PlaybuttonCard extends HookWidget { ), if (isHovered) Text( - "Owned by you", + context.l10n.owned_by_you, style: theme.textTheme.bodySmall?.copyWith( color: Colors.white, ), @@ -158,7 +149,7 @@ class PlaybuttonCard extends HookWidget { Skeleton.keep( child: IconButton( style: IconButton.styleFrom( - backgroundColor: theme.colorScheme.background, + backgroundColor: theme.colorScheme.surface, foregroundColor: theme.colorScheme.primary, minimumSize: const Size.square(10), ), @@ -205,11 +196,11 @@ class PlaybuttonCard extends HookWidget { overflow: TextOverflow.ellipsis, ), ), - if (cleanDescription != null) + if (description != null) Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0), child: AutoSizeText( - cleanDescription, + unescapeHtml!, maxLines: 2, style: theme.textTheme.bodySmall?.copyWith( color: theme.colorScheme.onSurface.withOpacity(.5), diff --git a/lib/components/shared/links/artist_link.dart b/lib/components/shared/links/artist_link.dart deleted file mode 100644 index af8b186af..000000000 --- a/lib/components/shared/links/artist_link.dart +++ /dev/null @@ -1,57 +0,0 @@ -import 'package:flutter/widgets.dart'; -import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/links/anchor_button.dart'; -import 'package:spotube/utils/service_utils.dart'; - -class ArtistLink extends StatelessWidget { - final List artists; - final WrapCrossAlignment crossAxisAlignment; - final WrapAlignment mainAxisAlignment; - final TextStyle textStyle; - final void Function(String route)? onRouteChange; - - const ArtistLink({ - super.key, - required this.artists, - this.crossAxisAlignment = WrapCrossAlignment.center, - this.mainAxisAlignment = WrapAlignment.center, - this.textStyle = const TextStyle(), - this.onRouteChange, - }); - - @override - Widget build(BuildContext context) { - return Wrap( - crossAxisAlignment: crossAxisAlignment, - alignment: mainAxisAlignment, - children: artists - .asMap() - .entries - .map( - (artist) => Builder(builder: (context) { - if (artist.value.name == null) { - return Text("Spotify", style: textStyle); - } - return AnchorButton( - (artist.key != artists.length - 1) - ? "${artist.value.name}, " - : artist.value.name!, - onTap: () { - if (onRouteChange != null) { - onRouteChange?.call("/artist/${artist.value.id}"); - } else { - ServiceUtils.push( - context, - "/artist/${artist.value.id}", - ); - } - }, - overflow: TextOverflow.ellipsis, - style: textStyle, - ); - }), - ) - .toList(), - ); - } -} diff --git a/lib/components/shared/page_window_title_bar.dart b/lib/components/shared/page_window_title_bar.dart deleted file mode 100644 index 37daefa95..000000000 --- a/lib/components/shared/page_window_title_bar.dart +++ /dev/null @@ -1,650 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/utils/platform.dart'; -import 'package:titlebar_buttons/titlebar_buttons.dart'; -import 'dart:math'; -import 'package:flutter/foundation.dart' show kIsWeb; -import 'dart:io' show Platform; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; - -class PageWindowTitleBar extends StatefulHookConsumerWidget - implements PreferredSizeWidget { - final Widget? leading; - final bool automaticallyImplyLeading; - final List? actions; - final Color? backgroundColor; - final Color? foregroundColor; - final IconThemeData? actionsIconTheme; - final bool? centerTitle; - final double? titleSpacing; - final double toolbarOpacity; - final double? leadingWidth; - final TextStyle? toolbarTextStyle; - final TextStyle? titleTextStyle; - final double? titleWidth; - final Widget? title; - - final bool _sliver; - - const PageWindowTitleBar({ - super.key, - this.actions, - this.title, - this.toolbarOpacity = 1, - this.backgroundColor, - this.actionsIconTheme, - this.automaticallyImplyLeading = false, - this.centerTitle, - this.foregroundColor, - this.leading, - this.leadingWidth, - this.titleSpacing, - this.titleTextStyle, - this.titleWidth, - this.toolbarTextStyle, - }) : _sliver = false, - pinned = false, - floating = false, - snap = false, - stretch = false; - - final bool pinned; - final bool floating; - final bool snap; - final bool stretch; - - const PageWindowTitleBar.sliver({ - super.key, - this.actions, - this.title, - this.backgroundColor, - this.actionsIconTheme, - this.automaticallyImplyLeading = false, - this.centerTitle, - this.foregroundColor, - this.leading, - this.leadingWidth, - this.titleSpacing, - this.titleTextStyle, - this.titleWidth, - this.toolbarTextStyle, - this.pinned = false, - this.floating = false, - this.snap = false, - this.stretch = false, - }) : _sliver = true, - toolbarOpacity = 1; - - @override - Size get preferredSize => const Size.fromHeight(kToolbarHeight); - - @override - ConsumerState createState() => _PageWindowTitleBarState(); -} - -class _PageWindowTitleBarState extends ConsumerState { - void onDrag(details) { - final systemTitleBar = - ref.read(userPreferencesProvider.select((s) => s.systemTitleBar)); - if (kIsDesktop && !systemTitleBar) { - DesktopTools.window.startDragging(); - } - } - - @override - Widget build(BuildContext context) { - final mediaQuery = MediaQuery.of(context); - - if (widget._sliver) { - return SliverLayoutBuilder( - builder: (context, constraints) { - final hasFullscreen = - mediaQuery.size.width == constraints.crossAxisExtent; - final hasLeadingOrCanPop = - widget.leading != null || Navigator.canPop(context); - - return SliverPadding( - padding: EdgeInsets.only( - left: DesktopTools.platform.isMacOS && - hasFullscreen && - hasLeadingOrCanPop - ? 65 - : 0, - ), - sliver: SliverAppBar( - leading: widget.leading, - automaticallyImplyLeading: widget.automaticallyImplyLeading, - actions: [ - ...?widget.actions, - WindowTitleBarButtons(foregroundColor: widget.foregroundColor), - ], - backgroundColor: widget.backgroundColor, - foregroundColor: widget.foregroundColor, - actionsIconTheme: widget.actionsIconTheme, - centerTitle: widget.centerTitle, - titleSpacing: widget.titleSpacing, - leadingWidth: widget.leadingWidth, - toolbarTextStyle: widget.toolbarTextStyle, - titleTextStyle: widget.titleTextStyle, - title: widget.title, - pinned: widget.pinned, - floating: widget.floating, - snap: widget.snap, - stretch: widget.stretch, - ), - ); - }, - ); - } - - return LayoutBuilder(builder: (context, constrains) { - final hasFullscreen = mediaQuery.size.width == constrains.maxWidth; - final hasLeadingOrCanPop = - widget.leading != null || Navigator.canPop(context); - - return GestureDetector( - onHorizontalDragStart: onDrag, - onVerticalDragStart: onDrag, - child: Padding( - padding: EdgeInsets.only( - left: DesktopTools.platform.isMacOS && - hasFullscreen && - hasLeadingOrCanPop - ? 65 - : 0, - ), - child: AppBar( - leading: widget.leading, - automaticallyImplyLeading: widget.automaticallyImplyLeading, - actions: [ - ...?widget.actions, - WindowTitleBarButtons(foregroundColor: widget.foregroundColor), - ], - backgroundColor: widget.backgroundColor, - foregroundColor: widget.foregroundColor, - actionsIconTheme: widget.actionsIconTheme, - centerTitle: widget.centerTitle, - titleSpacing: widget.titleSpacing, - toolbarOpacity: widget.toolbarOpacity, - leadingWidth: widget.leadingWidth, - toolbarTextStyle: widget.toolbarTextStyle, - titleTextStyle: widget.titleTextStyle, - title: widget.title, - ), - ), - ); - }); - } -} - -class WindowTitleBarButtons extends HookConsumerWidget { - final Color? foregroundColor; - const WindowTitleBarButtons({ - super.key, - this.foregroundColor, - }); - - @override - Widget build(BuildContext context, ref) { - final preferences = ref.watch(userPreferencesProvider); - final isMaximized = useState(null); - const type = ThemeType.auto; - - Future onClose() async { - await DesktopTools.window.close(); - } - - useEffect(() { - if (kIsDesktop) { - DesktopTools.window.isMaximized().then((value) { - isMaximized.value = value; - }); - } - return null; - }, []); - - if (!kIsDesktop || kIsMacOS || preferences.systemTitleBar) { - return const SizedBox.shrink(); - } - - if (kIsWindows) { - final theme = Theme.of(context); - final colors = WindowButtonColors( - normal: Colors.transparent, - iconNormal: foregroundColor ?? theme.colorScheme.onBackground, - mouseOver: theme.colorScheme.onBackground.withOpacity(0.1), - mouseDown: theme.colorScheme.onBackground.withOpacity(0.2), - iconMouseOver: theme.colorScheme.onBackground, - iconMouseDown: theme.colorScheme.onBackground, - ); - - final closeColors = WindowButtonColors( - normal: Colors.transparent, - iconNormal: foregroundColor ?? theme.colorScheme.onBackground, - mouseOver: Colors.red, - mouseDown: Colors.red[800]!, - iconMouseOver: Colors.white, - iconMouseDown: Colors.black, - ); - - return Padding( - padding: const EdgeInsets.only(bottom: 25), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - MinimizeWindowButton( - onPressed: DesktopTools.window.minimize, - colors: colors, - ), - if (isMaximized.value != true) - MaximizeWindowButton( - colors: colors, - onPressed: () { - DesktopTools.window.maximize(); - isMaximized.value = true; - }, - ) - else - RestoreWindowButton( - colors: colors, - onPressed: () { - DesktopTools.window.unmaximize(); - isMaximized.value = false; - }, - ), - CloseWindowButton( - colors: closeColors, - onPressed: onClose, - ), - ], - ), - ); - } - - return Padding( - padding: const EdgeInsets.only(bottom: 20, left: 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - DecoratedMinimizeButton( - type: type, - onPressed: DesktopTools.window.minimize, - ), - DecoratedMaximizeButton( - type: type, - onPressed: () async { - if (await DesktopTools.window.isMaximized()) { - await DesktopTools.window.unmaximize(); - isMaximized.value = false; - } else { - await DesktopTools.window.maximize(); - isMaximized.value = true; - } - }, - ), - DecoratedCloseButton( - type: type, - onPressed: onClose, - ), - ], - ), - ); - } -} - -typedef WindowButtonIconBuilder = Widget Function( - WindowButtonContext buttonContext); -typedef WindowButtonBuilder = Widget Function( - WindowButtonContext buttonContext, Widget icon); - -class WindowButtonContext { - BuildContext context; - MouseState mouseState; - Color? backgroundColor; - Color iconColor; - WindowButtonContext( - {required this.context, - required this.mouseState, - this.backgroundColor, - required this.iconColor}); -} - -class WindowButtonColors { - late Color normal; - late Color mouseOver; - late Color mouseDown; - late Color iconNormal; - late Color iconMouseOver; - late Color iconMouseDown; - WindowButtonColors( - {Color? normal, - Color? mouseOver, - Color? mouseDown, - Color? iconNormal, - Color? iconMouseOver, - Color? iconMouseDown}) { - this.normal = normal ?? _defaultButtonColors.normal; - this.mouseOver = mouseOver ?? _defaultButtonColors.mouseOver; - this.mouseDown = mouseDown ?? _defaultButtonColors.mouseDown; - this.iconNormal = iconNormal ?? _defaultButtonColors.iconNormal; - this.iconMouseOver = iconMouseOver ?? _defaultButtonColors.iconMouseOver; - this.iconMouseDown = iconMouseDown ?? _defaultButtonColors.iconMouseDown; - } -} - -final _defaultButtonColors = WindowButtonColors( - normal: Colors.transparent, - iconNormal: const Color(0xFF805306), - mouseOver: const Color(0xFF404040), - mouseDown: const Color(0xFF202020), - iconMouseOver: const Color(0xFFFFFFFF), - iconMouseDown: const Color(0xFFF0F0F0), -); - -class WindowButton extends StatelessWidget { - final WindowButtonBuilder? builder; - final WindowButtonIconBuilder? iconBuilder; - late final WindowButtonColors colors; - final bool animate; - final EdgeInsets? padding; - final VoidCallback? onPressed; - - WindowButton( - {super.key, - WindowButtonColors? colors, - this.builder, - @required this.iconBuilder, - this.padding, - this.onPressed, - this.animate = false}) { - this.colors = colors ?? _defaultButtonColors; - } - - Color getBackgroundColor(MouseState mouseState) { - if (mouseState.isMouseDown) return colors.mouseDown; - if (mouseState.isMouseOver) return colors.mouseOver; - return colors.normal; - } - - Color getIconColor(MouseState mouseState) { - if (mouseState.isMouseDown) return colors.iconMouseDown; - if (mouseState.isMouseOver) return colors.iconMouseOver; - return colors.iconNormal; - } - - @override - Widget build(BuildContext context) { - if (kIsWeb) { - return Container(); - } else { - // Don't show button on macOS - if (Platform.isMacOS) { - return Container(); - } - } - - return MouseStateBuilder( - builder: (context, mouseState) { - WindowButtonContext buttonContext = WindowButtonContext( - mouseState: mouseState, - context: context, - backgroundColor: getBackgroundColor(mouseState), - iconColor: getIconColor(mouseState)); - - var icon = - (iconBuilder != null) ? iconBuilder!(buttonContext) : Container(); - - var fadeOutColor = - getBackgroundColor(MouseState()..isMouseOver = true).withOpacity(0); - var padding = this.padding ?? const EdgeInsets.all(10); - var animationMs = - mouseState.isMouseOver ? (animate ? 100 : 0) : (animate ? 200 : 0); - Widget iconWithPadding = Padding(padding: padding, child: icon); - iconWithPadding = AnimatedContainer( - curve: Curves.easeOut, - duration: Duration(milliseconds: animationMs), - color: buttonContext.backgroundColor ?? fadeOutColor, - child: iconWithPadding); - var button = - (builder != null) ? builder!(buttonContext, icon) : iconWithPadding; - return SizedBox( - width: 45, - height: 32, - child: button, - ); - }, - onPressed: () { - if (onPressed != null) onPressed!(); - }, - ); - } -} - -class MinimizeWindowButton extends WindowButton { - MinimizeWindowButton( - {super.key, super.colors, super.onPressed, bool? animate}) - : super( - animate: animate ?? false, - iconBuilder: (buttonContext) => - MinimizeIcon(color: buttonContext.iconColor), - ); -} - -class MaximizeWindowButton extends WindowButton { - MaximizeWindowButton( - {super.key, super.colors, super.onPressed, bool? animate}) - : super( - animate: animate ?? false, - iconBuilder: (buttonContext) => - MaximizeIcon(color: buttonContext.iconColor), - ); -} - -class RestoreWindowButton extends WindowButton { - RestoreWindowButton({super.key, super.colors, super.onPressed, bool? animate}) - : super( - animate: animate ?? false, - iconBuilder: (buttonContext) => - RestoreIcon(color: buttonContext.iconColor), - ); -} - -final _defaultCloseButtonColors = WindowButtonColors( - mouseOver: const Color(0xFFD32F2F), - mouseDown: const Color(0xFFB71C1C), - iconNormal: const Color(0xFF805306), - iconMouseOver: const Color(0xFFFFFFFF)); - -class CloseWindowButton extends WindowButton { - CloseWindowButton( - {super.key, WindowButtonColors? colors, super.onPressed, bool? animate}) - : super( - colors: colors ?? _defaultCloseButtonColors, - animate: animate ?? false, - iconBuilder: (buttonContext) => - CloseIcon(color: buttonContext.iconColor), - ); -} - -// Switched to CustomPaint icons by https://github.com/esDotDev - -/// Close -class CloseIcon extends StatelessWidget { - final Color color; - const CloseIcon({super.key, required this.color}); - @override - Widget build(BuildContext context) => Align( - alignment: Alignment.topLeft, - child: Stack(children: [ - // Use rotated containers instead of a painter because it renders slightly crisper than a painter for some reason. - Transform.rotate( - angle: pi * .25, - child: - Center(child: Container(width: 14, height: 1, color: color))), - Transform.rotate( - angle: pi * -.25, - child: - Center(child: Container(width: 14, height: 1, color: color))), - ]), - ); -} - -/// Maximize -class MaximizeIcon extends StatelessWidget { - final Color color; - const MaximizeIcon({super.key, required this.color}); - @override - Widget build(BuildContext context) => _AlignedPaint(_MaximizePainter(color)); -} - -class _MaximizePainter extends _IconPainter { - _MaximizePainter(super.color); - @override - void paint(Canvas canvas, Size size) { - Paint p = getPaint(color); - canvas.drawRect(Rect.fromLTRB(0, 0, size.width - 1, size.height - 1), p); - } -} - -/// Restore -class RestoreIcon extends StatelessWidget { - final Color color; - const RestoreIcon({ - super.key, - required this.color, - }); - @override - Widget build(BuildContext context) => _AlignedPaint(_RestorePainter(color)); -} - -class _RestorePainter extends _IconPainter { - _RestorePainter(super.color); - @override - void paint(Canvas canvas, Size size) { - Paint p = getPaint(color); - canvas.drawRect(Rect.fromLTRB(0, 2, size.width - 2, size.height), p); - canvas.drawLine(const Offset(2, 2), const Offset(2, 0), p); - canvas.drawLine(const Offset(2, 0), Offset(size.width, 0), p); - canvas.drawLine( - Offset(size.width, 0), Offset(size.width, size.height - 2), p); - canvas.drawLine(Offset(size.width, size.height - 2), - Offset(size.width - 2, size.height - 2), p); - } -} - -/// Minimize -class MinimizeIcon extends StatelessWidget { - final Color color; - const MinimizeIcon({super.key, required this.color}); - @override - Widget build(BuildContext context) => _AlignedPaint(_MinimizePainter(color)); -} - -class _MinimizePainter extends _IconPainter { - _MinimizePainter(super.color); - @override - void paint(Canvas canvas, Size size) { - Paint p = getPaint(color); - canvas.drawLine( - Offset(0, size.height / 2), Offset(size.width, size.height / 2), p); - } -} - -/// Helpers -abstract class _IconPainter extends CustomPainter { - _IconPainter(this.color); - final Color color; - - @override - bool shouldRepaint(covariant CustomPainter oldDelegate) => false; -} - -class _AlignedPaint extends StatelessWidget { - const _AlignedPaint(this.painter); - final CustomPainter painter; - - @override - Widget build(BuildContext context) { - return Align( - alignment: Alignment.center, - child: CustomPaint(size: const Size(10, 10), painter: painter)); - } -} - -Paint getPaint(Color color, [bool isAntiAlias = false]) => Paint() - ..color = color - ..style = PaintingStyle.stroke - ..isAntiAlias = isAntiAlias - ..strokeWidth = 1; - -typedef MouseStateBuilderCB = Widget Function( - BuildContext context, MouseState mouseState); - -class MouseState { - bool isMouseOver = false; - bool isMouseDown = false; - MouseState(); - @override - String toString() { - return "isMouseDown: $isMouseDown - isMouseOver: $isMouseOver"; - } -} - -T? _ambiguate(T? value) => value; - -class MouseStateBuilder extends StatefulWidget { - final MouseStateBuilderCB builder; - final VoidCallback? onPressed; - const MouseStateBuilder({super.key, required this.builder, this.onPressed}); - @override - // ignore: library_private_types_in_public_api - _MouseStateBuilderState createState() => _MouseStateBuilderState(); -} - -class _MouseStateBuilderState extends State { - late MouseState _mouseState; - _MouseStateBuilderState() { - _mouseState = MouseState(); - } - - @override - Widget build(BuildContext context) { - return MouseRegion( - onEnter: (event) { - setState(() { - _mouseState.isMouseOver = true; - }); - }, - onExit: (event) { - setState(() { - _mouseState.isMouseOver = false; - }); - }, - child: GestureDetector( - onTapDown: (_) { - setState(() { - _mouseState.isMouseDown = true; - }); - }, - onTapCancel: () { - setState(() { - _mouseState.isMouseDown = false; - }); - }, - onTap: () { - setState(() { - _mouseState.isMouseDown = false; - _mouseState.isMouseOver = false; - }); - _ambiguate(WidgetsBinding.instance)!.addPostFrameCallback((_) { - if (widget.onPressed != null) { - widget.onPressed!(); - } - }); - }, - onTapUp: (_) {}, - child: widget.builder(context, _mouseState))); - } -} diff --git a/lib/components/shared/track_tile/track_tile.dart b/lib/components/shared/track_tile/track_tile.dart deleted file mode 100644 index 30912da22..000000000 --- a/lib/components/shared/track_tile/track_tile.dart +++ /dev/null @@ -1,268 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:skeletonizer/skeletonizer.dart'; -import 'package:spotify/spotify.dart'; -import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/hover_builder.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/links/artist_link.dart'; -import 'package:spotube/components/shared/links/link_text.dart'; -import 'package:spotube/components/shared/track_tile/track_options.dart'; -import 'package:spotube/extensions/artist_simple.dart'; -import 'package:spotube/extensions/constrains.dart'; -import 'package:spotube/extensions/duration.dart'; -import 'package:spotube/extensions/image.dart'; -import 'package:spotube/models/local_track.dart'; -import 'package:spotube/provider/blacklist_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist.dart'; - -class TrackTile extends HookConsumerWidget { - /// [index] will not be shown if null - final int? index; - final Track track; - final bool selected; - final ValueChanged? onChanged; - final Future Function()? onTap; - final VoidCallback? onLongPress; - final bool userPlaylist; - final String? playlistId; - final ProxyPlaylist playlist; - - final List? leadingActions; - - const TrackTile({ - super.key, - this.index, - required this.track, - this.selected = false, - required this.playlist, - this.onTap, - this.onLongPress, - this.onChanged, - this.userPlaylist = false, - this.playlistId, - this.leadingActions, - }); - - @override - Widget build(BuildContext context, ref) { - final theme = Theme.of(context); - - final blacklist = ref.watch(blacklistProvider); - - final isBlackListed = useMemoized( - () => blacklist.contains( - BlacklistedElement.track( - track.id!, - track.name!, - ), - ), - [blacklist, track], - ); - - final showOptionCbRef = useRef?>(null); - - final isLoading = useState(false); - - final isPlaying = playlist.activeTrack?.id == track.id; - - final isSelected = isPlaying || isLoading.value; - - return LayoutBuilder(builder: (context, constrains) { - return Listener( - onPointerDown: (event) { - if (event.buttons != kSecondaryMouseButton) return; - showOptionCbRef.value?.call( - RelativeRect.fromLTRB( - event.position.dx, - event.position.dy, - constrains.maxWidth - event.position.dx, - constrains.maxHeight - event.position.dy, - ), - ); - }, - child: HoverBuilder( - permanentState: isSelected || constrains.smAndDown ? true : null, - builder: (context, isHovering) { - return ListTile( - selected: isSelected, - onTap: () async { - try { - isLoading.value = true; - await onTap?.call(); - } finally { - if (context.mounted) { - isLoading.value = false; - } - } - }, - onLongPress: onLongPress, - enabled: !isBlackListed, - contentPadding: EdgeInsets.zero, - tileColor: - isBlackListed ? theme.colorScheme.errorContainer : null, - horizontalTitleGap: 12, - leadingAndTrailingTextStyle: theme.textTheme.bodyMedium, - leading: Row( - mainAxisSize: MainAxisSize.min, - children: [ - ...?leadingActions, - if (index != null && onChanged == null && constrains.mdAndUp) - SizedBox( - width: 50, - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 6), - child: Text( - '${(index ?? 0) + 1}', - maxLines: 1, - style: theme.textTheme.bodySmall, - textAlign: TextAlign.center, - ), - ), - ) - else if (constrains.smAndDown) - const SizedBox(width: 16), - if (onChanged != null) - Checkbox( - value: selected, - onChanged: onChanged, - ), - Stack( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(4), - child: AspectRatio( - aspectRatio: 1, - child: UniversalImage( - path: (track.album?.images).asUrlString( - placeholder: ImagePlaceholder.albumArt, - ), - fit: BoxFit.cover, - ), - ), - ), - Positioned.fill( - child: AnimatedContainer( - duration: const Duration(milliseconds: 300), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: isHovering - ? Colors.black.withOpacity(0.4) - : Colors.transparent, - ), - ), - ), - Positioned.fill( - child: Center( - child: IconTheme( - data: theme.iconTheme - .copyWith(size: 26, color: Colors.white), - child: Skeleton.ignore( - child: AnimatedSwitcher( - duration: const Duration(milliseconds: 300), - child: (isPlaying && playlist.isFetching) || - isLoading.value - ? const SizedBox( - width: 26, - height: 26, - child: CircularProgressIndicator( - strokeWidth: 1.5, - color: Colors.white, - ), - ) - : isPlaying - ? Icon( - SpotubeIcons.pause, - color: theme.colorScheme.primary, - ) - : !isHovering - ? const SizedBox.shrink() - : const Icon(SpotubeIcons.play), - ), - ), - ), - ), - ), - ], - ), - ], - ), - title: Row( - children: [ - Expanded( - flex: 6, - child: LinkText( - track.name!, - "/track/${track.id}", - push: true, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ), - if (constrains.mdAndUp) ...[ - const SizedBox(width: 8), - Expanded( - flex: 4, - child: switch (track.runtimeType) { - LocalTrack() => Text( - track.album!.name!, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - _ => Align( - alignment: Alignment.centerLeft, - child: LinkText( - track.album!.name!, - "/album/${track.album?.id}", - extra: track.album, - push: true, - overflow: TextOverflow.ellipsis, - ), - ) - }, - ), - ], - ], - ), - subtitle: Align( - alignment: Alignment.centerLeft, - child: track is LocalTrack - ? Text( - track.artists?.asString() ?? '', - ) - : ClipRect( - child: ConstrainedBox( - constraints: const BoxConstraints(maxHeight: 40), - child: ArtistLink(artists: track.artists ?? []), - ), - ), - ), - trailing: Row( - mainAxisSize: MainAxisSize.min, - children: [ - const SizedBox(width: 8), - Text( - Duration(milliseconds: track.durationMs ?? 0) - .toHumanReadableString(padZero: false), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - TrackOptions( - track: track, - playlistId: playlistId, - userPlaylist: userPlaylist, - showMenuCbRef: showOptionCbRef, - ), - ], - ), - ); - }, - ), - ); - }); - } -} diff --git a/lib/components/shared/shimmers/shimmer_lyrics.dart b/lib/components/shimmers/shimmer_lyrics.dart similarity index 100% rename from lib/components/shared/shimmers/shimmer_lyrics.dart rename to lib/components/shimmers/shimmer_lyrics.dart diff --git a/lib/components/shared/sort_tracks_dropdown.dart b/lib/components/sort_tracks_dropdown.dart similarity index 94% rename from lib/components/shared/sort_tracks_dropdown.dart rename to lib/components/sort_tracks_dropdown.dart index be72d689b..167270134 100644 --- a/lib/components/shared/sort_tracks_dropdown.dart +++ b/lib/components/sort_tracks_dropdown.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/library/user_local_tracks.dart'; -import 'package:spotube/components/shared/adaptive/adaptive_pop_sheet_list.dart'; +import 'package:spotube/modules/library/user_local_tracks.dart'; +import 'package:spotube/components/adaptive/adaptive_pop_sheet_list.dart'; import 'package:spotube/extensions/context.dart'; class SortTracksDropdown extends StatelessWidget { diff --git a/lib/components/shared/spotube_page_route.dart b/lib/components/spotube_page_route.dart similarity index 100% rename from lib/components/shared/spotube_page_route.dart rename to lib/components/spotube_page_route.dart diff --git a/lib/components/shared/themed_button_tab_bar.dart b/lib/components/themed_button_tab_bar.dart similarity index 87% rename from lib/components/shared/themed_button_tab_bar.dart rename to lib/components/themed_button_tab_bar.dart index 017f04aa8..c245e5f4e 100644 --- a/lib/components/shared/themed_button_tab_bar.dart +++ b/lib/components/themed_button_tab_bar.dart @@ -5,7 +5,8 @@ import 'package:spotube/hooks/utils/use_brightness_value.dart'; class ThemedButtonsTabBar extends HookWidget implements PreferredSizeWidget { final List tabs; - const ThemedButtonsTabBar({super.key, required this.tabs}); + final TabController? controller; + const ThemedButtonsTabBar({super.key, required this.tabs, this.controller}); @override Widget build(BuildContext context) { @@ -21,6 +22,7 @@ class ThemedButtonsTabBar extends HookWidget implements PreferredSizeWidget { bottom: 8, ), child: ButtonsTabBar( + controller: controller, radius: 100, decoration: BoxDecoration( color: bgColor, @@ -32,7 +34,7 @@ class ThemedButtonsTabBar extends HookWidget implements PreferredSizeWidget { ), borderWidth: 0, unselectedDecoration: BoxDecoration( - color: theme.colorScheme.background, + color: theme.colorScheme.surface, borderRadius: BorderRadius.circular(15), ), unselectedLabelStyle: theme.textTheme.labelLarge?.copyWith( diff --git a/lib/components/titlebar/mouse_state.dart b/lib/components/titlebar/mouse_state.dart new file mode 100644 index 000000000..9af2a8b0b --- /dev/null +++ b/lib/components/titlebar/mouse_state.dart @@ -0,0 +1,73 @@ +import 'package:flutter/material.dart'; + +typedef MouseStateBuilderCB = Widget Function( + BuildContext context, MouseState mouseState); + +class MouseState { + bool isMouseOver = false; + bool isMouseDown = false; + MouseState(); + @override + String toString() { + return "isMouseDown: $isMouseDown - isMouseOver: $isMouseOver"; + } +} + +T? _ambiguate(T? value) => value; + +class MouseStateBuilder extends StatefulWidget { + final MouseStateBuilderCB builder; + final VoidCallback? onPressed; + const MouseStateBuilder({super.key, required this.builder, this.onPressed}); + @override + // ignore: library_private_types_in_public_api + _MouseStateBuilderState createState() => _MouseStateBuilderState(); +} + +class _MouseStateBuilderState extends State { + late MouseState _mouseState; + _MouseStateBuilderState() { + _mouseState = MouseState(); + } + + @override + Widget build(BuildContext context) { + return MouseRegion( + onEnter: (event) { + setState(() { + _mouseState.isMouseOver = true; + }); + }, + onExit: (event) { + setState(() { + _mouseState.isMouseOver = false; + }); + }, + child: GestureDetector( + onTapDown: (_) { + setState(() { + _mouseState.isMouseDown = true; + }); + }, + onTapCancel: () { + setState(() { + _mouseState.isMouseDown = false; + }); + }, + onTap: () { + setState(() { + _mouseState.isMouseDown = false; + _mouseState.isMouseOver = false; + }); + _ambiguate(WidgetsBinding.instance)!.addPostFrameCallback((_) { + if (widget.onPressed != null) { + widget.onPressed!(); + } + }); + }, + onTapUp: (_) {}, + child: widget.builder(context, _mouseState), + ), + ); + } +} diff --git a/lib/components/titlebar/titlebar.dart b/lib/components/titlebar/titlebar.dart new file mode 100644 index 000000000..76a5ec8a5 --- /dev/null +++ b/lib/components/titlebar/titlebar.dart @@ -0,0 +1,179 @@ +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/components/titlebar/titlebar_buttons.dart'; +import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +import 'package:spotube/utils/platform.dart'; + +import 'package:window_manager/window_manager.dart'; + +class PageWindowTitleBar extends StatefulHookConsumerWidget + implements PreferredSizeWidget { + final Widget? leading; + final bool automaticallyImplyLeading; + final List? actions; + final Color? backgroundColor; + final Color? foregroundColor; + final IconThemeData? actionsIconTheme; + final bool? centerTitle; + final double? titleSpacing; + final double toolbarOpacity; + final double? leadingWidth; + final TextStyle? toolbarTextStyle; + final TextStyle? titleTextStyle; + final double? titleWidth; + final Widget? title; + + final bool _sliver; + + const PageWindowTitleBar({ + super.key, + this.actions, + this.title, + this.toolbarOpacity = 1, + this.backgroundColor, + this.actionsIconTheme, + this.automaticallyImplyLeading = false, + this.centerTitle, + this.foregroundColor, + this.leading, + this.leadingWidth, + this.titleSpacing, + this.titleTextStyle, + this.titleWidth, + this.toolbarTextStyle, + }) : _sliver = false, + pinned = false, + floating = false, + snap = false, + stretch = false; + + final bool pinned; + final bool floating; + final bool snap; + final bool stretch; + + const PageWindowTitleBar.sliver({ + super.key, + this.actions, + this.title, + this.backgroundColor, + this.actionsIconTheme, + this.automaticallyImplyLeading = false, + this.centerTitle, + this.foregroundColor, + this.leading, + this.leadingWidth, + this.titleSpacing, + this.titleTextStyle, + this.titleWidth, + this.toolbarTextStyle, + this.pinned = false, + this.floating = false, + this.snap = false, + this.stretch = false, + }) : _sliver = true, + toolbarOpacity = 1; + + @override + Size get preferredSize => const Size.fromHeight(kToolbarHeight); + + @override + ConsumerState createState() => _PageWindowTitleBarState(); +} + +class _PageWindowTitleBarState extends ConsumerState { + void onDrag(details) { + final systemTitleBar = + ref.read(userPreferencesProvider.select((s) => s.systemTitleBar)); + if (kIsDesktop && !systemTitleBar) { + windowManager.startDragging(); + } + } + + @override + Widget build(BuildContext context) { + final mediaQuery = MediaQuery.of(context); + + if (widget._sliver) { + return SliverLayoutBuilder( + builder: (context, constraints) { + final hasFullscreen = + mediaQuery.size.width == constraints.crossAxisExtent; + final hasLeadingOrCanPop = + widget.leading != null || Navigator.canPop(context); + + return SliverPadding( + padding: EdgeInsets.only( + left: kIsMacOS && hasFullscreen && hasLeadingOrCanPop ? 65 : 0, + ), + sliver: SliverAppBar( + leading: widget.leading, + automaticallyImplyLeading: widget.automaticallyImplyLeading, + actions: [ + ...?widget.actions, + WindowTitleBarButtons(foregroundColor: widget.foregroundColor), + ], + backgroundColor: widget.backgroundColor, + foregroundColor: widget.foregroundColor, + actionsIconTheme: widget.actionsIconTheme, + centerTitle: widget.centerTitle, + titleSpacing: widget.titleSpacing, + leadingWidth: widget.leadingWidth, + toolbarTextStyle: widget.toolbarTextStyle, + titleTextStyle: widget.titleTextStyle, + title: SizedBox( + width: double.infinity, // workaround to force dragging + child: widget.title ?? const Text(""), + ), + pinned: widget.pinned, + floating: widget.floating, + snap: widget.snap, + stretch: widget.stretch, + ), + ); + }, + ); + } + + return LayoutBuilder(builder: (context, constrains) { + final hasFullscreen = mediaQuery.size.width == constrains.maxWidth; + final hasLeadingOrCanPop = + widget.leading != null || Navigator.canPop(context); + + return GestureDetector( + onHorizontalDragStart: onDrag, + onVerticalDragStart: onDrag, + child: Padding( + padding: EdgeInsets.only( + left: kIsMacOS && hasFullscreen && hasLeadingOrCanPop ? 65 : 0, + ), + child: AppBar( + leading: widget.leading, + automaticallyImplyLeading: widget.automaticallyImplyLeading, + actions: [ + ...?widget.actions, + WindowTitleBarButtons(foregroundColor: widget.foregroundColor), + ], + backgroundColor: widget.backgroundColor, + foregroundColor: widget.foregroundColor, + actionsIconTheme: widget.actionsIconTheme, + centerTitle: widget.centerTitle, + titleSpacing: widget.titleSpacing, + toolbarOpacity: widget.toolbarOpacity, + leadingWidth: widget.leadingWidth, + toolbarTextStyle: widget.toolbarTextStyle, + titleTextStyle: widget.titleTextStyle, + title: SizedBox( + width: double.infinity, // workaround to force dragging + child: widget.title ?? const Text(""), + ), + scrolledUnderElevation: 0, + shadowColor: Colors.transparent, + forceMaterialTransparency: true, + elevation: 0, + ), + ), + ); + }); + } +} diff --git a/lib/components/titlebar/titlebar_buttons.dart b/lib/components/titlebar/titlebar_buttons.dart new file mode 100644 index 000000000..35cdf08e1 --- /dev/null +++ b/lib/components/titlebar/titlebar_buttons.dart @@ -0,0 +1,124 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/components/titlebar/titlebar_icon_buttons.dart'; +import 'package:spotube/components/titlebar/window_button.dart'; +import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +import 'package:spotube/utils/platform.dart'; +import 'package:titlebar_buttons/titlebar_buttons.dart'; +import 'package:window_manager/window_manager.dart'; + +class WindowTitleBarButtons extends HookConsumerWidget { + final Color? foregroundColor; + const WindowTitleBarButtons({ + super.key, + this.foregroundColor, + }); + + @override + Widget build(BuildContext context, ref) { + final preferences = ref.watch(userPreferencesProvider); + final isMaximized = useState(null); + const type = ThemeType.auto; + + Future onClose() async { + await windowManager.close(); + } + + useEffect(() { + if (kIsDesktop) { + windowManager.isMaximized().then((value) { + isMaximized.value = value; + }); + } + return null; + }, []); + + if (!kIsDesktop || kIsMacOS || preferences.systemTitleBar) { + return const SizedBox.shrink(); + } + + if (kIsWindows) { + final theme = Theme.of(context); + final colors = WindowButtonColors( + normal: Colors.transparent, + iconNormal: foregroundColor ?? theme.colorScheme.onSurface, + mouseOver: theme.colorScheme.onSurface.withOpacity(0.1), + mouseDown: theme.colorScheme.onSurface.withOpacity(0.2), + iconMouseOver: theme.colorScheme.onSurface, + iconMouseDown: theme.colorScheme.onSurface, + ); + + final closeColors = WindowButtonColors( + normal: Colors.transparent, + iconNormal: foregroundColor ?? theme.colorScheme.onSurface, + mouseOver: Colors.red, + mouseDown: Colors.red[800]!, + iconMouseOver: Colors.white, + iconMouseDown: Colors.black, + ); + + return Padding( + padding: const EdgeInsets.only(bottom: 25), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + MinimizeWindowButton( + onPressed: windowManager.minimize, + colors: colors, + ), + if (isMaximized.value != true) + MaximizeWindowButton( + colors: colors, + onPressed: () { + windowManager.maximize(); + isMaximized.value = true; + }, + ) + else + RestoreWindowButton( + colors: colors, + onPressed: () { + windowManager.unmaximize(); + isMaximized.value = false; + }, + ), + CloseWindowButton( + colors: closeColors, + onPressed: onClose, + ), + ], + ), + ); + } + + return Padding( + padding: const EdgeInsets.only(bottom: 20, left: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + DecoratedMinimizeButton( + type: type, + onPressed: windowManager.minimize, + ), + DecoratedMaximizeButton( + type: type, + onPressed: () async { + if (await windowManager.isMaximized()) { + await windowManager.unmaximize(); + isMaximized.value = false; + } else { + await windowManager.maximize(); + isMaximized.value = true; + } + }, + ), + DecoratedCloseButton( + type: type, + onPressed: onClose, + ), + ], + ), + ); + } +} diff --git a/lib/components/titlebar/titlebar_icon_buttons.dart b/lib/components/titlebar/titlebar_icon_buttons.dart new file mode 100644 index 000000000..701702623 --- /dev/null +++ b/lib/components/titlebar/titlebar_icon_buttons.dart @@ -0,0 +1,161 @@ +import 'dart:math'; + +import 'package:flutter/material.dart'; +import 'package:spotube/components/titlebar/window_button.dart'; + +class MinimizeWindowButton extends WindowButton { + MinimizeWindowButton( + {super.key, super.colors, super.onPressed, bool? animate}) + : super( + animate: animate ?? false, + iconBuilder: (buttonContext) => + MinimizeIcon(color: buttonContext.iconColor), + ); +} + +class MaximizeWindowButton extends WindowButton { + MaximizeWindowButton( + {super.key, super.colors, super.onPressed, bool? animate}) + : super( + animate: animate ?? false, + iconBuilder: (buttonContext) => + MaximizeIcon(color: buttonContext.iconColor), + ); +} + +class RestoreWindowButton extends WindowButton { + RestoreWindowButton({super.key, super.colors, super.onPressed, bool? animate}) + : super( + animate: animate ?? false, + iconBuilder: (buttonContext) => + RestoreIcon(color: buttonContext.iconColor), + ); +} + +final _defaultCloseButtonColors = WindowButtonColors( + mouseOver: const Color(0xFFD32F2F), + mouseDown: const Color(0xFFB71C1C), + iconNormal: const Color(0xFF805306), + iconMouseOver: const Color(0xFFFFFFFF)); + +class CloseWindowButton extends WindowButton { + CloseWindowButton( + {super.key, WindowButtonColors? colors, super.onPressed, bool? animate}) + : super( + colors: colors ?? _defaultCloseButtonColors, + animate: animate ?? false, + iconBuilder: (buttonContext) => + CloseIcon(color: buttonContext.iconColor), + ); +} + +// Switched to CustomPaint icons by https://github.com/esDotDev + +/// Close +class CloseIcon extends StatelessWidget { + final Color color; + const CloseIcon({super.key, required this.color}); + @override + Widget build(BuildContext context) => Align( + alignment: Alignment.topLeft, + child: Stack(children: [ + // Use rotated containers instead of a painter because it renders slightly crisper than a painter for some reason. + Transform.rotate( + angle: pi * .25, + child: + Center(child: Container(width: 14, height: 1, color: color))), + Transform.rotate( + angle: pi * -.25, + child: + Center(child: Container(width: 14, height: 1, color: color))), + ]), + ); +} + +/// Maximize +class MaximizeIcon extends StatelessWidget { + final Color color; + const MaximizeIcon({super.key, required this.color}); + @override + Widget build(BuildContext context) => _AlignedPaint(_MaximizePainter(color)); +} + +class _MaximizePainter extends _IconPainter { + _MaximizePainter(super.color); + @override + void paint(Canvas canvas, Size size) { + Paint p = getPaint(color); + canvas.drawRect(Rect.fromLTRB(0, 0, size.width - 1, size.height - 1), p); + } +} + +/// Restore +class RestoreIcon extends StatelessWidget { + final Color color; + const RestoreIcon({ + super.key, + required this.color, + }); + @override + Widget build(BuildContext context) => _AlignedPaint(_RestorePainter(color)); +} + +class _RestorePainter extends _IconPainter { + _RestorePainter(super.color); + @override + void paint(Canvas canvas, Size size) { + Paint p = getPaint(color); + canvas.drawRect(Rect.fromLTRB(0, 2, size.width - 2, size.height), p); + canvas.drawLine(const Offset(2, 2), const Offset(2, 0), p); + canvas.drawLine(const Offset(2, 0), Offset(size.width, 0), p); + canvas.drawLine( + Offset(size.width, 0), Offset(size.width, size.height - 2), p); + canvas.drawLine(Offset(size.width, size.height - 2), + Offset(size.width - 2, size.height - 2), p); + } +} + +/// Minimize +class MinimizeIcon extends StatelessWidget { + final Color color; + const MinimizeIcon({super.key, required this.color}); + @override + Widget build(BuildContext context) => _AlignedPaint(_MinimizePainter(color)); +} + +class _MinimizePainter extends _IconPainter { + _MinimizePainter(super.color); + @override + void paint(Canvas canvas, Size size) { + Paint p = getPaint(color); + canvas.drawLine( + Offset(0, size.height / 2), Offset(size.width, size.height / 2), p); + } +} + +/// Helpers +abstract class _IconPainter extends CustomPainter { + _IconPainter(this.color); + final Color color; + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) => false; +} + +class _AlignedPaint extends StatelessWidget { + const _AlignedPaint(this.painter); + final CustomPainter painter; + + @override + Widget build(BuildContext context) { + return Align( + alignment: Alignment.center, + child: CustomPaint(size: const Size(10, 10), painter: painter)); + } +} + +Paint getPaint(Color color, [bool isAntiAlias = false]) => Paint() + ..color = color + ..style = PaintingStyle.stroke + ..isAntiAlias = isAntiAlias + ..strokeWidth = 1; diff --git a/lib/components/titlebar/window_button.dart b/lib/components/titlebar/window_button.dart new file mode 100644 index 000000000..3201d191a --- /dev/null +++ b/lib/components/titlebar/window_button.dart @@ -0,0 +1,133 @@ +import 'dart:io'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:spotube/components/titlebar/mouse_state.dart'; + +typedef WindowButtonIconBuilder = Widget Function( + WindowButtonContext buttonContext); +typedef WindowButtonBuilder = Widget Function( + WindowButtonContext buttonContext, Widget icon); + +class WindowButtonContext { + BuildContext context; + MouseState mouseState; + Color? backgroundColor; + Color iconColor; + WindowButtonContext( + {required this.context, + required this.mouseState, + this.backgroundColor, + required this.iconColor}); +} + +class WindowButtonColors { + late Color normal; + late Color mouseOver; + late Color mouseDown; + late Color iconNormal; + late Color iconMouseOver; + late Color iconMouseDown; + WindowButtonColors( + {Color? normal, + Color? mouseOver, + Color? mouseDown, + Color? iconNormal, + Color? iconMouseOver, + Color? iconMouseDown}) { + this.normal = normal ?? _defaultButtonColors.normal; + this.mouseOver = mouseOver ?? _defaultButtonColors.mouseOver; + this.mouseDown = mouseDown ?? _defaultButtonColors.mouseDown; + this.iconNormal = iconNormal ?? _defaultButtonColors.iconNormal; + this.iconMouseOver = iconMouseOver ?? _defaultButtonColors.iconMouseOver; + this.iconMouseDown = iconMouseDown ?? _defaultButtonColors.iconMouseDown; + } +} + +final _defaultButtonColors = WindowButtonColors( + normal: Colors.transparent, + iconNormal: const Color(0xFF805306), + mouseOver: const Color(0xFF404040), + mouseDown: const Color(0xFF202020), + iconMouseOver: const Color(0xFFFFFFFF), + iconMouseDown: const Color(0xFFF0F0F0), +); + +class WindowButton extends StatelessWidget { + final WindowButtonBuilder? builder; + final WindowButtonIconBuilder? iconBuilder; + late final WindowButtonColors colors; + final bool animate; + final EdgeInsets? padding; + final VoidCallback? onPressed; + + WindowButton( + {super.key, + WindowButtonColors? colors, + this.builder, + @required this.iconBuilder, + this.padding, + this.onPressed, + this.animate = false}) { + this.colors = colors ?? _defaultButtonColors; + } + + Color getBackgroundColor(MouseState mouseState) { + if (mouseState.isMouseDown) return colors.mouseDown; + if (mouseState.isMouseOver) return colors.mouseOver; + return colors.normal; + } + + Color getIconColor(MouseState mouseState) { + if (mouseState.isMouseDown) return colors.iconMouseDown; + if (mouseState.isMouseOver) return colors.iconMouseOver; + return colors.iconNormal; + } + + @override + Widget build(BuildContext context) { + if (kIsWeb) { + return Container(); + } else { + // Don't show button on macOS + if (Platform.isMacOS) { + return Container(); + } + } + + return MouseStateBuilder( + builder: (context, mouseState) { + WindowButtonContext buttonContext = WindowButtonContext( + mouseState: mouseState, + context: context, + backgroundColor: getBackgroundColor(mouseState), + iconColor: getIconColor(mouseState)); + + var icon = + (iconBuilder != null) ? iconBuilder!(buttonContext) : Container(); + + var fadeOutColor = + getBackgroundColor(MouseState()..isMouseOver = true).withOpacity(0); + var padding = this.padding ?? const EdgeInsets.all(10); + var animationMs = + mouseState.isMouseOver ? (animate ? 100 : 0) : (animate ? 200 : 0); + Widget iconWithPadding = Padding(padding: padding, child: icon); + iconWithPadding = AnimatedContainer( + curve: Curves.easeOut, + duration: Duration(milliseconds: animationMs), + color: buttonContext.backgroundColor ?? fadeOutColor, + child: iconWithPadding); + var button = + (builder != null) ? builder!(buttonContext, icon) : iconWithPadding; + return SizedBox( + width: 45, + height: 32, + child: button, + ); + }, + onPressed: () { + if (onPressed != null) onPressed!(); + }, + ); + } +} diff --git a/lib/components/shared/track_tile/track_options.dart b/lib/components/track_tile/track_options.dart similarity index 60% rename from lib/components/shared/track_tile/track_options.dart rename to lib/components/track_tile/track_options.dart index a9ec36b94..84b0f41f6 100644 --- a/lib/components/shared/track_tile/track_options.dart +++ b/lib/components/track_tile/track_options.dart @@ -8,24 +8,27 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/library/user_local_tracks.dart'; -import 'package:spotube/components/shared/adaptive/adaptive_pop_sheet_list.dart'; -import 'package:spotube/components/shared/dialogs/playlist_add_track_dialog.dart'; -import 'package:spotube/components/shared/dialogs/prompt_dialog.dart'; -import 'package:spotube/components/shared/dialogs/track_details_dialog.dart'; -import 'package:spotube/components/shared/heart_button.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/links/artist_link.dart'; +import 'package:spotube/components/adaptive/adaptive_pop_sheet_list.dart'; +import 'package:spotube/components/dialogs/playlist_add_track_dialog.dart'; +import 'package:spotube/components/dialogs/prompt_dialog.dart'; +import 'package:spotube/components/dialogs/track_details_dialog.dart'; +import 'package:spotube/components/heart_button/use_track_toggle_like.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/links/artist_link.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; +import 'package:spotube/models/database/database.dart'; import 'package:spotube/models/local_track.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/pages/track/track.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/blacklist_provider.dart'; import 'package:spotube/provider/download_manager_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/local_tracks/local_tracks_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:spotube/provider/spotify_provider.dart'; +import 'package:spotube/utils/service_utils.dart'; import 'package:url_launcher/url_launcher_string.dart'; @@ -95,8 +98,8 @@ class TrackOptions extends HookConsumerWidget { WidgetRef ref, Track track, ) async { - final playback = ref.read(proxyPlaylistProvider.notifier); - final playlist = ref.read(proxyPlaylistProvider); + final playback = ref.read(audioPlayerProvider.notifier); + final playlist = ref.read(audioPlayerProvider); final spotify = ref.read(spotifyProvider); final query = "${track.name} Radio"; final pages = @@ -159,8 +162,8 @@ class TrackOptions extends HookConsumerWidget { final router = GoRouter.of(context); final ThemeData(:colorScheme) = Theme.of(context); - final playlist = ref.watch(proxyPlaylistProvider); - final playback = ref.watch(proxyPlaylistProvider.notifier); + final playlist = ref.watch(audioPlayerProvider); + final playback = ref.watch(audioPlayerProvider.notifier); final auth = ref.watch(authenticationProvider); ref.watch(downloadManagerProvider); final downloadManager = ref.watch(downloadManagerProvider.notifier); @@ -170,11 +173,8 @@ class TrackOptions extends HookConsumerWidget { final favorites = useTrackToggleLike(track, ref); final isBlackListed = useMemoized( - () => blacklist.contains( - BlacklistedElement.track( - track.id!, - track.name!, - ), + () => blacklist.asData?.value.any( + (element) => element.elementId == track.id, ), [blacklist, track], ); @@ -197,6 +197,8 @@ class TrackOptions extends HookConsumerWidget { return downloadManager.getProgressNotifier(spotubeTrack); }); + final isLocalTrack = track is LocalTrack; + final adaptivePopSheetList = AdaptivePopSheetList( onSelected: (value) async { switch (value) { @@ -256,13 +258,16 @@ class TrackOptions extends HookConsumerWidget { .removeTracks(playlistId ?? "", [track.id!]); break; case TrackOptionValue.blacklist: - if (isBlackListed) { - ref.read(blacklistProvider.notifier).remove( - BlacklistedElement.track(track.id!, track.name!), - ); + if (isBlackListed == null) break; + if (isBlackListed == true) { + await ref.read(blacklistProvider.notifier).remove(track.id!); } else { - ref.read(blacklistProvider.notifier).add( - BlacklistedElement.track(track.id!, track.name!), + await ref.read(blacklistProvider.notifier).add( + BlacklistTableCompanion.insert( + name: track.name!, + elementId: track.id!, + elementType: BlacklistedType.track, + ), ); } break; @@ -310,122 +315,133 @@ class TrackOptions extends HookConsumerWidget { ), subtitle: Align( alignment: Alignment.centerLeft, - child: ArtistLink(artists: track.artists!), + child: ArtistLink( + artists: track.artists!, + onOverflowArtistClick: () => ServiceUtils.pushNamed( + context, + TrackPage.name, + pathParameters: { + "id": track.id!, + }, + ), + ), ), ), ], - children: switch (track.runtimeType) { - LocalTrack() => [ - PopSheetEntry( - value: TrackOptionValue.delete, - leading: const Icon(SpotubeIcons.trash), - title: Text(context.l10n.delete), - ) - ], - _ => [ - if (mediaQuery.smAndDown) - PopSheetEntry( - value: TrackOptionValue.album, - leading: const Icon(SpotubeIcons.album), - title: Text(context.l10n.go_to_album), - subtitle: Text(track.album!.name!), - ), - if (!playlist.containsTrack(track)) ...[ - PopSheetEntry( - value: TrackOptionValue.addToQueue, - leading: const Icon(SpotubeIcons.queueAdd), - title: Text(context.l10n.add_to_queue), - ), - PopSheetEntry( - value: TrackOptionValue.playNext, - leading: const Icon(SpotubeIcons.lightning), - title: Text(context.l10n.play_next), - ), - ] else - PopSheetEntry( - value: TrackOptionValue.removeFromQueue, - enabled: playlist.activeTrack?.id != track.id, - leading: const Icon(SpotubeIcons.queueRemove), - title: Text(context.l10n.remove_from_queue), - ), - if (me.asData?.value != null) - PopSheetEntry( - value: TrackOptionValue.favorite, - leading: favorites.isLiked - ? const Icon( - SpotubeIcons.heartFilled, - color: Colors.pink, - ) - : const Icon(SpotubeIcons.heart), - title: Text( - favorites.isLiked - ? context.l10n.remove_from_favorites - : context.l10n.save_as_favorite, - ), - ), - if (auth != null) ...[ - PopSheetEntry( - value: TrackOptionValue.startRadio, - leading: const Icon(SpotubeIcons.radio), - title: Text(context.l10n.start_a_radio), - ), - PopSheetEntry( - value: TrackOptionValue.addToPlaylist, - leading: const Icon(SpotubeIcons.playlistAdd), - title: Text(context.l10n.add_to_playlist), - ), - ], - if (userPlaylist && auth != null) - PopSheetEntry( - value: TrackOptionValue.removeFromPlaylist, - leading: const Icon(SpotubeIcons.removeFilled), - title: Text(context.l10n.remove_from_playlist), - ), - PopSheetEntry( - value: TrackOptionValue.download, - enabled: !isInQueue, - leading: isInQueue - ? HookBuilder(builder: (context) { - final progress = useListenable(progressNotifier!); - return CircularProgressIndicator( - value: progress.value, - ); - }) - : const Icon(SpotubeIcons.download), - title: Text(context.l10n.download_track), - ), - PopSheetEntry( - value: TrackOptionValue.blacklist, - leading: const Icon(SpotubeIcons.playlistRemove), - iconColor: !isBlackListed ? Colors.red[400] : null, - textColor: !isBlackListed ? Colors.red[400] : null, - title: Text( - isBlackListed - ? context.l10n.remove_from_blacklist - : context.l10n.add_to_blacklist, - ), - ), - PopSheetEntry( - value: TrackOptionValue.share, - leading: const Icon(SpotubeIcons.share), - title: Text(context.l10n.share), + children: [ + if (isLocalTrack) + PopSheetEntry( + value: TrackOptionValue.delete, + leading: const Icon(SpotubeIcons.trash), + title: Text(context.l10n.delete), + ), + if (mediaQuery.smAndDown && !isLocalTrack) + PopSheetEntry( + value: TrackOptionValue.album, + leading: const Icon(SpotubeIcons.album), + title: Text(context.l10n.go_to_album), + subtitle: Text(track.album!.name!), + ), + if (!playlist.containsTrack(track)) ...[ + PopSheetEntry( + value: TrackOptionValue.addToQueue, + leading: const Icon(SpotubeIcons.queueAdd), + title: Text(context.l10n.add_to_queue), + ), + PopSheetEntry( + value: TrackOptionValue.playNext, + leading: const Icon(SpotubeIcons.lightning), + title: Text(context.l10n.play_next), + ), + ] else + PopSheetEntry( + value: TrackOptionValue.removeFromQueue, + enabled: playlist.activeTrack?.id != track.id, + leading: const Icon(SpotubeIcons.queueRemove), + title: Text(context.l10n.remove_from_queue), + ), + if (me.asData?.value != null && !isLocalTrack) + PopSheetEntry( + value: TrackOptionValue.favorite, + leading: favorites.isLiked + ? const Icon( + SpotubeIcons.heartFilled, + color: Colors.pink, + ) + : const Icon(SpotubeIcons.heart), + title: Text( + favorites.isLiked + ? context.l10n.remove_from_favorites + : context.l10n.save_as_favorite, ), - PopSheetEntry( - value: TrackOptionValue.songlink, - leading: Assets.logos.songlinkTransparent.image( - width: 22, - height: 22, - color: colorScheme.onSurface.withOpacity(0.5), - ), - title: Text(context.l10n.song_link), + ), + if (auth.asData?.value != null && !isLocalTrack) ...[ + PopSheetEntry( + value: TrackOptionValue.startRadio, + leading: const Icon(SpotubeIcons.radio), + title: Text(context.l10n.start_a_radio), + ), + PopSheetEntry( + value: TrackOptionValue.addToPlaylist, + leading: const Icon(SpotubeIcons.playlistAdd), + title: Text(context.l10n.add_to_playlist), + ), + ], + if (userPlaylist && auth.asData?.value != null && !isLocalTrack) + PopSheetEntry( + value: TrackOptionValue.removeFromPlaylist, + leading: const Icon(SpotubeIcons.removeFilled), + title: Text(context.l10n.remove_from_playlist), + ), + if (!isLocalTrack) + PopSheetEntry( + value: TrackOptionValue.download, + enabled: !isInQueue, + leading: isInQueue + ? HookBuilder(builder: (context) { + final progress = useListenable(progressNotifier!); + return CircularProgressIndicator( + value: progress.value, + ); + }) + : const Icon(SpotubeIcons.download), + title: Text(context.l10n.download_track), + ), + if (!isLocalTrack) + PopSheetEntry( + value: TrackOptionValue.blacklist, + leading: const Icon(SpotubeIcons.playlistRemove), + iconColor: isBlackListed != true ? Colors.red[400] : null, + textColor: isBlackListed != true ? Colors.red[400] : null, + title: Text( + isBlackListed == true + ? context.l10n.remove_from_blacklist + : context.l10n.add_to_blacklist, ), - PopSheetEntry( - value: TrackOptionValue.details, - leading: const Icon(SpotubeIcons.info), - title: Text(context.l10n.details), + ), + if (!isLocalTrack) + PopSheetEntry( + value: TrackOptionValue.share, + leading: const Icon(SpotubeIcons.share), + title: Text(context.l10n.share), + ), + if (!isLocalTrack) + PopSheetEntry( + value: TrackOptionValue.songlink, + leading: Assets.logos.songlinkTransparent.image( + width: 22, + height: 22, + color: colorScheme.onSurface.withOpacity(0.5), ), - ] - }, + title: Text(context.l10n.song_link), + ), + if (!isLocalTrack) + PopSheetEntry( + value: TrackOptionValue.details, + leading: const Icon(SpotubeIcons.info), + title: Text(context.l10n.details), + ), + ], ); //! This is the most ANTI pattern I've ever done, but it works diff --git a/lib/components/track_tile/track_tile.dart b/lib/components/track_tile/track_tile.dart new file mode 100644 index 000000000..12ce063f2 --- /dev/null +++ b/lib/components/track_tile/track_tile.dart @@ -0,0 +1,286 @@ +import 'dart:async'; + +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/collections/spotube_icons.dart'; +import 'package:spotube/components/hover_builder.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/links/artist_link.dart'; +import 'package:spotube/components/links/link_text.dart'; +import 'package:spotube/components/track_tile/track_options.dart'; +import 'package:spotube/extensions/artist_simple.dart'; +import 'package:spotube/extensions/constrains.dart'; +import 'package:spotube/extensions/duration.dart'; +import 'package:spotube/extensions/image.dart'; +import 'package:spotube/models/local_track.dart'; +import 'package:spotube/pages/track/track.dart'; +import 'package:spotube/provider/audio_player/querying_track_info.dart'; +import 'package:spotube/provider/audio_player/state.dart'; +import 'package:spotube/provider/blacklist_provider.dart'; +import 'package:spotube/utils/service_utils.dart'; + +class TrackTile extends HookConsumerWidget { + /// [index] will not be shown if null + final int? index; + final Track track; + final bool selected; + final ValueChanged? onChanged; + final Future Function()? onTap; + final VoidCallback? onLongPress; + final bool userPlaylist; + final String? playlistId; + final AudioPlayerState playlist; + + final List? leadingActions; + + const TrackTile({ + super.key, + this.index, + required this.track, + this.selected = false, + required this.playlist, + this.onTap, + this.onLongPress, + this.onChanged, + this.userPlaylist = false, + this.playlistId, + this.leadingActions, + }); + + @override + Widget build(BuildContext context, ref) { + final theme = Theme.of(context); + + final blacklist = ref.watch(blacklistProvider); + final blacklistNotifier = ref.watch(blacklistProvider.notifier); + + final isBlackListed = useMemoized( + () => blacklistNotifier.contains(track), + [blacklist, track], + ); + + final showOptionCbRef = useRef?>(null); + + final isLoading = useState(false); + + final isPlaying = playlist.activeTrack?.id == track.id; + + final isSelected = isPlaying || isLoading.value; + + return LayoutBuilder(builder: (context, constrains) { + return Listener( + onPointerDown: (event) { + if (event.buttons != kSecondaryMouseButton) return; + showOptionCbRef.value?.call( + RelativeRect.fromLTRB( + event.position.dx, + event.position.dy, + constrains.maxWidth - event.position.dx, + constrains.maxHeight - event.position.dy, + ), + ); + }, + child: HoverBuilder( + permanentState: isSelected || constrains.smAndDown ? true : null, + builder: (context, isHovering) => ListTile( + selected: isSelected, + onTap: () async { + try { + isLoading.value = true; + await onTap?.call(); + } finally { + if (context.mounted) { + isLoading.value = false; + } + } + }, + onLongPress: onLongPress, + enabled: !isBlackListed, + contentPadding: EdgeInsets.zero, + tileColor: isBlackListed ? theme.colorScheme.errorContainer : null, + horizontalTitleGap: 12, + leadingAndTrailingTextStyle: theme.textTheme.bodyMedium, + leading: Row( + mainAxisSize: MainAxisSize.min, + children: [ + ...?leadingActions, + if (index != null && onChanged == null && constrains.mdAndUp) + SizedBox( + width: 50, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 6), + child: Text( + '${(index ?? 0) + 1}', + maxLines: 1, + style: theme.textTheme.bodySmall, + textAlign: TextAlign.center, + ), + ), + ) + else if (constrains.smAndDown) + const SizedBox(width: 16), + if (onChanged != null) + Checkbox( + value: selected, + onChanged: onChanged, + ), + Stack( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(4), + child: AspectRatio( + aspectRatio: 1, + child: UniversalImage( + path: (track.album?.images).asUrlString( + placeholder: ImagePlaceholder.albumArt, + ), + fit: BoxFit.cover, + ), + ), + ), + Positioned.fill( + child: AnimatedContainer( + duration: const Duration(milliseconds: 300), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: isHovering + ? Colors.black.withOpacity(0.4) + : Colors.transparent, + ), + ), + ), + Positioned.fill( + child: Center( + child: IconTheme( + data: theme.iconTheme + .copyWith(size: 26, color: Colors.white), + child: Skeleton.ignore( + child: Consumer( + builder: (context, ref, _) { + final isFetchingActiveTrack = + ref.watch(queryingTrackInfoProvider); + return AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + child: (isPlaying && isFetchingActiveTrack) || + isLoading.value + ? const SizedBox( + width: 26, + height: 26, + child: CircularProgressIndicator( + strokeWidth: 1.5, + color: Colors.white, + ), + ) + : isPlaying + ? Icon( + SpotubeIcons.pause, + color: theme.colorScheme.primary, + ) + : !isHovering + ? const SizedBox.shrink() + : const Icon(SpotubeIcons.play), + ); + }, + ), + ), + ), + ), + ), + ], + ), + ], + ), + title: Row( + children: [ + Expanded( + flex: 6, + child: switch (track) { + LocalTrack() => Text( + track.name!, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + _ => LinkText( + track.name!, + "/track/${track.id}", + push: true, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + }, + ), + if (constrains.mdAndUp) ...[ + const SizedBox(width: 8), + Expanded( + flex: 4, + child: switch (track) { + LocalTrack() => Text( + track.album!.name!, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + _ => Align( + alignment: Alignment.centerLeft, + child: LinkText( + track.album!.name!, + "/album/${track.album?.id}", + extra: track.album, + push: true, + overflow: TextOverflow.ellipsis, + ), + ) + }, + ), + ], + ], + ), + subtitle: Align( + alignment: Alignment.centerLeft, + child: track is LocalTrack + ? Text( + track.artists?.asString() ?? '', + ) + : ClipRect( + child: ConstrainedBox( + constraints: const BoxConstraints(maxHeight: 40), + child: ArtistLink( + artists: track.artists ?? [], + onOverflowArtistClick: () => ServiceUtils.pushNamed( + context, + TrackPage.name, + pathParameters: { + "id": track.id!, + }, + ), + ), + ), + ), + ), + trailing: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const SizedBox(width: 8), + Text( + Duration(milliseconds: track.durationMs ?? 0) + .toHumanReadableString(padZero: false), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + TrackOptions( + track: track, + playlistId: playlistId, + userPlaylist: userPlaylist, + showMenuCbRef: showOptionCbRef, + ), + ], + ), + ), + ), + ); + }); + } +} diff --git a/lib/components/shared/tracks_view/sections/body/track_view_body.dart b/lib/components/tracks_view/sections/body/track_view_body.dart similarity index 76% rename from lib/components/shared/tracks_view/sections/body/track_view_body.dart rename to lib/components/tracks_view/sections/body/track_view_body.dart index f576ba0a1..df841b8d4 100644 --- a/lib/components/shared/tracks_view/sections/body/track_view_body.dart +++ b/lib/components/tracks_view/sections/body/track_view_body.dart @@ -8,16 +8,17 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/fake.dart'; -import 'package:spotube/components/shared/dialogs/select_device_dialog.dart'; -import 'package:spotube/components/shared/expandable_search/expandable_search.dart'; -import 'package:spotube/components/shared/track_tile/track_tile.dart'; -import 'package:spotube/components/shared/tracks_view/sections/body/track_view_body_headers.dart'; -import 'package:spotube/components/shared/tracks_view/sections/body/use_is_user_playlist.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_props.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_provider.dart'; +import 'package:spotube/components/dialogs/select_device_dialog.dart'; +import 'package:spotube/components/expandable_search/expandable_search.dart'; +import 'package:spotube/components/track_tile/track_tile.dart'; +import 'package:spotube/components/tracks_view/sections/body/track_view_body_headers.dart'; +import 'package:spotube/components/tracks_view/sections/body/use_is_user_playlist.dart'; +import 'package:spotube/components/tracks_view/track_view_props.dart'; +import 'package:spotube/components/tracks_view/track_view_provider.dart'; import 'package:spotube/models/connect/connect.dart'; import 'package:spotube/provider/connect/connect.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/history/history.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/utils/service_utils.dart'; import 'package:very_good_infinite_list/very_good_infinite_list.dart'; @@ -26,8 +27,9 @@ class TrackViewBodySection extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { - final playlist = ref.watch(proxyPlaylistProvider); - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); + final playlist = ref.watch(audioPlayerProvider); + final playlistNotifier = ref.watch(audioPlayerProvider.notifier); + final historyNotifier = ref.watch(playbackHistoryActionsProvider); final props = InheritedTrackView.of(context); final trackViewState = ref.watch(trackViewProvider(props.tracks)); @@ -146,11 +148,17 @@ class TrackViewBodySection extends HookConsumerWidget { } else { final tracks = await props.pagination.onFetchAll(); await remotePlayback.load( - WebSocketLoadEventData( - tracks: tracks, - collectionId: props.collectionId, - initialIndex: index, - ), + props.collection is AlbumSimple + ? WebSocketLoadEventData.album( + tracks: tracks, + collection: props.collection as AlbumSimple, + initialIndex: index, + ) + : WebSocketLoadEventData.playlist( + tracks: tracks, + collection: props.collection as PlaylistSimple, + initialIndex: index, + ), ); } } else { @@ -164,6 +172,13 @@ class TrackViewBodySection extends HookConsumerWidget { autoPlay: true, ); playlistNotifier.addCollection(props.collectionId); + if (props.collection is AlbumSimple) { + historyNotifier + .addAlbums([props.collection as AlbumSimple]); + } else { + historyNotifier + .addPlaylists([props.collection as PlaylistSimple]); + } } } }, diff --git a/lib/components/shared/tracks_view/sections/body/track_view_body_headers.dart b/lib/components/tracks_view/sections/body/track_view_body_headers.dart similarity index 87% rename from lib/components/shared/tracks_view/sections/body/track_view_body_headers.dart rename to lib/components/tracks_view/sections/body/track_view_body_headers.dart index 3a1538a39..564c85d0e 100644 --- a/lib/components/shared/tracks_view/sections/body/track_view_body_headers.dart +++ b/lib/components/tracks_view/sections/body/track_view_body_headers.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/components/shared/expandable_search/expandable_search.dart'; -import 'package:spotube/components/shared/sort_tracks_dropdown.dart'; -import 'package:spotube/components/shared/tracks_view/sections/body/track_view_options.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_props.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_provider.dart'; +import 'package:spotube/components/expandable_search/expandable_search.dart'; +import 'package:spotube/components/sort_tracks_dropdown.dart'; +import 'package:spotube/components/tracks_view/sections/body/track_view_options.dart'; +import 'package:spotube/components/tracks_view/track_view_props.dart'; +import 'package:spotube/components/tracks_view/track_view_provider.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; diff --git a/lib/components/shared/tracks_view/sections/body/track_view_options.dart b/lib/components/tracks_view/sections/body/track_view_options.dart similarity index 75% rename from lib/components/shared/tracks_view/sections/body/track_view_options.dart rename to lib/components/tracks_view/sections/body/track_view_options.dart index ff92b6638..23198aec6 100644 --- a/lib/components/shared/tracks_view/sections/body/track_view_options.dart +++ b/lib/components/tracks_view/sections/body/track_view_options.dart @@ -1,16 +1,18 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/adaptive/adaptive_pop_sheet_list.dart'; -import 'package:spotube/components/shared/dialogs/confirm_download_dialog.dart'; -import 'package:spotube/components/shared/dialogs/playlist_add_track_dialog.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_props.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_provider.dart'; +import 'package:spotube/components/adaptive/adaptive_pop_sheet_list.dart'; +import 'package:spotube/components/dialogs/confirm_download_dialog.dart'; +import 'package:spotube/components/dialogs/playlist_add_track_dialog.dart'; +import 'package:spotube/components/tracks_view/track_view_props.dart'; +import 'package:spotube/components/tracks_view/track_view_provider.dart'; import 'package:spotube/extensions/context.dart'; +import 'package:spotube/models/database/database.dart'; import 'package:spotube/provider/download_manager_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/history/history.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; class TrackViewBodyOptions extends HookConsumerWidget { const TrackViewBodyOptions({super.key}); @@ -22,7 +24,8 @@ class TrackViewBodyOptions extends HookConsumerWidget { ref.watch(downloadManagerProvider); final downloader = ref.watch(downloadManagerProvider.notifier); - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); + final playlistNotifier = ref.watch(audioPlayerProvider.notifier); + final historyNotifier = ref.watch(playbackHistoryActionsProvider); final audioSource = ref.watch(userPreferencesProvider.select((s) => s.audioSource)); @@ -72,6 +75,12 @@ class TrackViewBodyOptions extends HookConsumerWidget { { playlistNotifier.addTracksAtFirst(selectedTracks); playlistNotifier.addCollection(props.collectionId); + if (props.collection is AlbumSimple) { + historyNotifier.addAlbums([props.collection as AlbumSimple]); + } else { + historyNotifier + .addPlaylists([props.collection as PlaylistSimple]); + } trackViewState.deselectAll(); break; } @@ -79,6 +88,12 @@ class TrackViewBodyOptions extends HookConsumerWidget { { playlistNotifier.addTracks(selectedTracks); playlistNotifier.addCollection(props.collectionId); + if (props.collection is AlbumSimple) { + historyNotifier.addAlbums([props.collection as AlbumSimple]); + } else { + historyNotifier + .addPlaylists([props.collection as PlaylistSimple]); + } trackViewState.deselectAll(); break; } diff --git a/lib/components/shared/tracks_view/sections/body/use_is_user_playlist.dart b/lib/components/tracks_view/sections/body/use_is_user_playlist.dart similarity index 100% rename from lib/components/shared/tracks_view/sections/body/use_is_user_playlist.dart rename to lib/components/tracks_view/sections/body/use_is_user_playlist.dart diff --git a/lib/components/shared/tracks_view/sections/header/flexible_header.dart b/lib/components/tracks_view/sections/header/flexible_header.dart similarity index 89% rename from lib/components/shared/tracks_view/sections/header/flexible_header.dart rename to lib/components/tracks_view/sections/header/flexible_header.dart index 4a7043023..6845cc3e8 100644 --- a/lib/components/shared/tracks_view/sections/header/flexible_header.dart +++ b/lib/components/tracks_view/sections/header/flexible_header.dart @@ -1,17 +1,18 @@ import 'dart:ui'; import 'package:flutter/material.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; + import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/assets.gen.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/playbutton_card.dart'; -import 'package:spotube/components/shared/tracks_view/sections/header/header_actions.dart'; -import 'package:spotube/components/shared/tracks_view/sections/header/header_buttons.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_props.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/tracks_view/sections/header/header_actions.dart'; +import 'package:spotube/components/tracks_view/sections/header/header_buttons.dart'; +import 'package:spotube/components/tracks_view/track_view_props.dart'; import 'package:gap/gap.dart'; import 'package:spotube/extensions/constrains.dart'; +import 'package:spotube/extensions/string.dart'; import 'package:spotube/hooks/utils/use_palette_color.dart'; +import 'package:spotube/utils/platform.dart'; class TrackViewFlexHeader extends HookConsumerWidget { const TrackViewFlexHeader({super.key}); @@ -23,8 +24,6 @@ class TrackViewFlexHeader extends HookConsumerWidget { final defaultTextStyle = DefaultTextStyle.of(context); final mediaQuery = MediaQuery.of(context); - final description = useDescription(props.description); - final palette = usePaletteColor(props.image, ref); return IconTheme( @@ -53,7 +52,7 @@ class TrackViewFlexHeader extends HookConsumerWidget { floating: false, pinned: true, expandedHeight: 450, - automaticallyImplyLeading: DesktopTools.platform.isMobile, + automaticallyImplyLeading: kIsMobile, backgroundColor: palette.color, title: isExpanded ? null : Text(props.title, style: headingStyle), flexibleSpace: FlexibleSpaceBar( @@ -126,10 +125,10 @@ class TrackViewFlexHeader extends HookConsumerWidget { overflow: TextOverflow.ellipsis, ), const SizedBox(height: 10), - if (description != null && - description.isNotEmpty) + if (props.description != null && + props.description!.isNotEmpty) Text( - description, + props.description!.unescapeHtml(), style: defaultTextStyle.style.copyWith( color: palette.bodyTextColor, diff --git a/lib/components/shared/tracks_view/sections/header/header_actions.dart b/lib/components/tracks_view/sections/header/header_actions.dart similarity index 69% rename from lib/components/shared/tracks_view/sections/header/header_actions.dart rename to lib/components/tracks_view/sections/header/header_actions.dart index f6880485d..8e378f97c 100644 --- a/lib/components/shared/tracks_view/sections/header/header_actions.dart +++ b/lib/components/tracks_view/sections/header/header_actions.dart @@ -2,14 +2,16 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/playlist/playlist_create_dialog.dart'; -import 'package:spotube/components/shared/heart_button.dart'; -import 'package:spotube/components/shared/tracks_view/sections/body/use_is_user_playlist.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_props.dart'; +import 'package:spotube/modules/playlist/playlist_create_dialog.dart'; +import 'package:spotube/components/heart_button/heart_button.dart'; +import 'package:spotube/components/tracks_view/sections/body/use_is_user_playlist.dart'; +import 'package:spotube/components/tracks_view/track_view_props.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/provider/authentication_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; +import 'package:spotube/provider/history/history.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; class TrackViewHeaderActions extends HookConsumerWidget { const TrackViewHeaderActions({super.key}); @@ -18,8 +20,9 @@ class TrackViewHeaderActions extends HookConsumerWidget { Widget build(BuildContext context, ref) { final props = InheritedTrackView.of(context); - final playlist = ref.watch(proxyPlaylistProvider); - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); + final playlist = ref.watch(audioPlayerProvider); + final playlistNotifier = ref.watch(audioPlayerProvider.notifier); + final historyNotifier = ref.watch(playbackHistoryActionsProvider); final isActive = playlist.collections.contains(props.collectionId); @@ -29,6 +32,9 @@ class TrackViewHeaderActions extends HookConsumerWidget { final auth = ref.watch(authenticationProvider); + final copiedText = + context.l10n.copied_shareurl_to_clipboard(props.shareUrl); + return Row( mainAxisSize: MainAxisSize.min, children: [ @@ -45,7 +51,7 @@ class TrackViewHeaderActions extends HookConsumerWidget { width: 300, behavior: SnackBarBehavior.floating, content: Text( - "Copied ${props.shareUrl} to clipboard", + copiedText, textAlign: TextAlign.center, ), ), @@ -61,9 +67,16 @@ class TrackViewHeaderActions extends HookConsumerWidget { final tracks = await props.pagination.onFetchAll(); await playlistNotifier.addTracks(tracks); playlistNotifier.addCollection(props.collectionId); + if (props.collection is AlbumSimple) { + historyNotifier + .addAlbums([props.collection as AlbumSimple]); + } else { + historyNotifier + .addPlaylists([props.collection as PlaylistSimple]); + } }, ), - if (props.onHeart != null && auth != null) + if (props.onHeart != null && auth.asData?.value != null) HeartButton( isLiked: props.isLiked, icon: isUserPlaylist ? SpotubeIcons.trash : null, diff --git a/lib/components/shared/tracks_view/sections/header/header_buttons.dart b/lib/components/tracks_view/sections/header/header_buttons.dart similarity index 62% rename from lib/components/shared/tracks_view/sections/header/header_buttons.dart rename to lib/components/tracks_view/sections/header/header_buttons.dart index 50eeb7470..54e0f0cf7 100644 --- a/lib/components/shared/tracks_view/sections/header/header_buttons.dart +++ b/lib/components/tracks_view/sections/header/header_buttons.dart @@ -5,13 +5,15 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:palette_generator/palette_generator.dart'; +import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/dialogs/select_device_dialog.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_props.dart'; +import 'package:spotube/components/dialogs/select_device_dialog.dart'; +import 'package:spotube/components/tracks_view/track_view_props.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/models/connect/connect.dart'; import 'package:spotube/provider/connect/connect.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/history/history.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; class TrackViewHeaderButtons extends HookConsumerWidget { @@ -26,8 +28,9 @@ class TrackViewHeaderButtons extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { final props = InheritedTrackView.of(context); - final playlist = ref.watch(proxyPlaylistProvider); - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); + final playlist = ref.watch(audioPlayerProvider); + final playlistNotifier = ref.watch(audioPlayerProvider.notifier); + final historyNotifier = ref.watch(playbackHistoryActionsProvider); final isActive = playlist.collections.contains(props.collectionId); @@ -44,28 +47,45 @@ class TrackViewHeaderButtons extends HookConsumerWidget { try { isLoading.value = true; - final allTracks = await props.pagination.onFetchAll(); - + final initialTracks = props.tracks; if (!context.mounted) return; final isRemoteDevice = await showSelectDeviceDialog(context, ref); if (isRemoteDevice) { + final allTracks = await props.pagination.onFetchAll(); final remotePlayback = ref.read(connectProvider.notifier); await remotePlayback.load( - WebSocketLoadEventData( - tracks: allTracks, - collectionId: props.collectionId, - initialIndex: Random().nextInt(allTracks.length)), + props.collection is AlbumSimple + ? WebSocketLoadEventData.album( + tracks: allTracks, + collection: props.collection as AlbumSimple, + initialIndex: Random().nextInt(allTracks.length)) + : WebSocketLoadEventData.playlist( + tracks: allTracks, + collection: props.collection as PlaylistSimple, + initialIndex: Random().nextInt(allTracks.length), + ), ); await remotePlayback.setShuffle(true); } else { await playlistNotifier.load( - allTracks, + initialTracks, autoPlay: true, - initialIndex: Random().nextInt(allTracks.length), + initialIndex: Random().nextInt(initialTracks.length), ); await audioPlayer.setShuffle(true); playlistNotifier.addCollection(props.collectionId); + if (props.collection is AlbumSimple) { + historyNotifier.addAlbums([props.collection as AlbumSimple]); + } else { + historyNotifier.addPlaylists([props.collection as PlaylistSimple]); + } + + final allTracks = await props.pagination.onFetchAll(); + + await playlistNotifier.addTracks( + allTracks.sublist(initialTracks.length), + ); } } finally { isLoading.value = false; @@ -76,25 +96,44 @@ class TrackViewHeaderButtons extends HookConsumerWidget { try { isLoading.value = true; - final allTracks = await props.pagination.onFetchAll(); + final initialTracks = props.tracks; if (!context.mounted) return; final isRemoteDevice = await showSelectDeviceDialog(context, ref); if (isRemoteDevice) { + final allTracks = await props.pagination.onFetchAll(); final remotePlayback = ref.read(connectProvider.notifier); await remotePlayback.load( - WebSocketLoadEventData( - tracks: allTracks, - collectionId: props.collectionId, - ), + props.collection is AlbumSimple + ? WebSocketLoadEventData.album( + tracks: allTracks, + collection: props.collection as AlbumSimple, + ) + : WebSocketLoadEventData.playlist( + tracks: allTracks, + collection: props.collection as PlaylistSimple, + ), ); } else { - await playlistNotifier.load(allTracks, autoPlay: true); + await playlistNotifier.load(initialTracks, autoPlay: true); playlistNotifier.addCollection(props.collectionId); + if (props.collection is AlbumSimple) { + historyNotifier.addAlbums([props.collection as AlbumSimple]); + } else { + historyNotifier.addPlaylists([props.collection as PlaylistSimple]); + } + + final allTracks = await props.pagination.onFetchAll(); + + await playlistNotifier.addTracks( + allTracks.sublist(initialTracks.length), + ); } } finally { - isLoading.value = false; + if (context.mounted) { + isLoading.value = false; + } } } diff --git a/lib/components/shared/tracks_view/track_view.dart b/lib/components/tracks_view/track_view.dart similarity index 71% rename from lib/components/shared/tracks_view/track_view.dart rename to lib/components/tracks_view/track_view.dart index eb8f68712..2a3f5237e 100644 --- a/lib/components/shared/tracks_view/track_view.dart +++ b/lib/components/tracks_view/track_view.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; + import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:sliver_tools/sliver_tools.dart'; -import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; -import 'package:spotube/components/shared/tracks_view/sections/header/flexible_header.dart'; -import 'package:spotube/components/shared/tracks_view/sections/body/track_view_body.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_props.dart'; +import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/components/tracks_view/sections/header/flexible_header.dart'; +import 'package:spotube/components/tracks_view/sections/body/track_view_body.dart'; +import 'package:spotube/components/tracks_view/track_view_props.dart'; +import 'package:spotube/utils/platform.dart'; class TrackView extends HookConsumerWidget { const TrackView({super.key}); @@ -18,7 +19,7 @@ class TrackView extends HookConsumerWidget { final controller = useScrollController(); return Scaffold( - appBar: DesktopTools.platform.isDesktop + appBar: kIsDesktop ? const PageWindowTitleBar( backgroundColor: Colors.transparent, foregroundColor: Colors.white, diff --git a/lib/components/shared/tracks_view/track_view_props.dart b/lib/components/tracks_view/track_view_props.dart similarity index 88% rename from lib/components/shared/tracks_view/track_view_props.dart rename to lib/components/tracks_view/track_view_props.dart index a1a07f84d..b0a00ae29 100644 --- a/lib/components/shared/tracks_view/track_view_props.dart +++ b/lib/components/tracks_view/track_view_props.dart @@ -39,7 +39,7 @@ class PaginationProps { } class InheritedTrackView extends InheritedWidget { - final String collectionId; + final Object collection; final String title; final String? description; final String image; @@ -55,7 +55,7 @@ class InheritedTrackView extends InheritedWidget { const InheritedTrackView({ super.key, required super.child, - required this.collectionId, + required this.collection, required this.title, this.description, required this.image, @@ -65,7 +65,11 @@ class InheritedTrackView extends InheritedWidget { required this.shareUrl, this.isLiked = false, this.onHeart, - }); + }) : assert(collection is AlbumSimple || collection is PlaylistSimple); + + String get collectionId => collection is AlbumSimple + ? (collection as AlbumSimple).id! + : (collection as PlaylistSimple).id!; @override bool updateShouldNotify(InheritedTrackView oldWidget) { @@ -78,7 +82,7 @@ class InheritedTrackView extends InheritedWidget { oldWidget.onHeart != onHeart || oldWidget.shareUrl != shareUrl || oldWidget.routePath != routePath || - oldWidget.collectionId != collectionId || + oldWidget.collection != collection || oldWidget.child != child; } diff --git a/lib/components/shared/tracks_view/track_view_provider.dart b/lib/components/tracks_view/track_view_provider.dart similarity index 95% rename from lib/components/shared/tracks_view/track_view_provider.dart rename to lib/components/tracks_view/track_view_provider.dart index 14dc11369..16aa6d9c5 100644 --- a/lib/components/shared/tracks_view/track_view_provider.dart +++ b/lib/components/tracks_view/track_view_provider.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/library/user_local_tracks.dart'; +import 'package:spotube/modules/library/user_local_tracks.dart'; class TrackViewNotifier extends ChangeNotifier { List tracks; diff --git a/lib/components/shared/waypoint.dart b/lib/components/waypoint.dart similarity index 87% rename from lib/components/shared/waypoint.dart rename to lib/components/waypoint.dart index 08e9088a1..cf00e29b6 100644 --- a/lib/components/shared/waypoint.dart +++ b/lib/components/waypoint.dart @@ -20,8 +20,6 @@ class Waypoint extends HookWidget { @override Widget build(BuildContext context) { - final isMounted = useIsMounted(); - useEffect(() { if (isGrid) { return null; @@ -32,19 +30,19 @@ class Waypoint extends HookWidget { // scrollController fetches the next paginated data when the current // position of the user on the screen has surpassed - if (controller.position.pixels >= nextPageTrigger && isMounted()) { + if (controller.position.pixels >= nextPageTrigger && context.mounted) { await onTouchEdge?.call(); } } WidgetsBinding.instance.addPostFrameCallback((_) { - if (controller.hasClients && isMounted()) { + if (controller.hasClients && context.mounted) { listener(); controller.addListener(listener); } }); return () => controller.removeListener(listener); - }, [controller, onTouchEdge, isMounted]); + }, [controller, onTouchEdge]); if (isGrid) { return VisibilityDetector( diff --git a/lib/extensions/album_simple.dart b/lib/extensions/album_simple.dart index 7c8ae09e8..5678390c4 100644 --- a/lib/extensions/album_simple.dart +++ b/lib/extensions/album_simple.dart @@ -1,21 +1,6 @@ import 'package:spotify/spotify.dart'; extension AlbumExtensions on AlbumSimple { - Map toJson() { - return { - "albumType": albumType?.name, - "id": id, - "name": name, - "images": images - ?.map((image) => { - "height": image.height, - "url": image.url, - "width": image.width, - }) - .toList(), - }; - } - Album toAlbum() { Album album = Album(); album.albumType = albumType; diff --git a/lib/extensions/artist_simple.dart b/lib/extensions/artist_simple.dart index 6a80300ea..7997355d6 100644 --- a/lib/extensions/artist_simple.dart +++ b/lib/extensions/artist_simple.dart @@ -1,17 +1,5 @@ import 'package:spotify/spotify.dart'; -extension ArtistJson on ArtistSimple { - Map toJson() { - return { - "href": href, - "id": id, - "name": name, - "type": type, - "uri": uri, - }; - } -} - extension ArtistExtension on List { String asString() { return map((e) => e.name?.replaceAll(",", " ")).join(", "); diff --git a/lib/extensions/constrains.dart b/lib/extensions/constrains.dart index 1177f5ace..dc1027e2a 100644 --- a/lib/extensions/constrains.dart +++ b/lib/extensions/constrains.dart @@ -1,6 +1,20 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; +enum Breakpoint { + xs, + sm, + md, + lg, + xl, + xxl; + + bool operator <=(Breakpoint other) => index <= other.index; + bool operator <(Breakpoint other) => index < other.index; + bool operator >(Breakpoint other) => index > other.index; + bool operator >=(Breakpoint other) => index >= other.index; +} + // ignore: constant_identifier_names const Breakpoints = ( xs: 480.0, @@ -22,6 +36,15 @@ extension SliverBreakpoints on SliverConstraints { crossAxisExtent > Breakpoints.lg && crossAxisExtent <= Breakpoints.xl; bool get is2Xl => crossAxisExtent > Breakpoints.xl; + Breakpoint get breakpoint { + if (isXs) return Breakpoint.xs; + if (isSm) return Breakpoint.sm; + if (isMd) return Breakpoint.md; + if (isLg) return Breakpoint.lg; + if (isXl) return Breakpoint.xl; + return Breakpoint.xxl; + } + bool get smAndUp => isSm || isMd || isLg || isXl || is2Xl; bool get mdAndUp => isMd || isLg || isXl || is2Xl; bool get lgAndUp => isLg || isXl || is2Xl; @@ -45,6 +68,15 @@ extension ContainerBreakpoints on BoxConstraints { biggest.width > Breakpoints.lg && biggest.width <= Breakpoints.xl; bool get is2Xl => biggest.width > Breakpoints.xl; + Breakpoint get breakpoint { + if (isXs) return Breakpoint.xs; + if (isSm) return Breakpoint.sm; + if (isMd) return Breakpoint.md; + if (isLg) return Breakpoint.lg; + if (isXl) return Breakpoint.xl; + return Breakpoint.xxl; + } + bool get smAndUp => isSm || isMd || isLg || isXl || is2Xl; bool get mdAndUp => isMd || isLg || isXl || is2Xl; bool get lgAndUp => isLg || isXl || is2Xl; diff --git a/lib/extensions/list.dart b/lib/extensions/list.dart deleted file mode 100644 index 6ecf6cf69..000000000 --- a/lib/extensions/list.dart +++ /dev/null @@ -1,99 +0,0 @@ -import 'package:collection/collection.dart'; -import 'package:spotube/models/logger.dart'; - -final logger = getLogger("List"); - -extension MultiSortListMap on List { - /// [preference] - List of properties in which you want to sort the list - /// i.e. - /// ``` - /// List preference = ['property1','property2']; - /// ``` - /// This will first sort the list by property1 then by property2 - /// - /// [criteria] - List of booleans that specifies the criteria of sort - /// i.e., For ascending order `true` and for descending order `false`. - /// ``` - /// List criteria = [true. false]; - /// ``` - List sortByProperties(List criteria, List preference) { - if (preference.isEmpty || criteria.isEmpty || isEmpty) { - return this; - } - if (preference.length != criteria.length) { - logger.d('Criteria length is not equal to preference'); - return this; - } - - int compare(int i, Map a, Map b) { - if (a[preference[i]] == b[preference[i]]) { - return 0; - } else if (a[preference[i]] > b[preference[i]]) { - return criteria[i] ? 1 : -1; - } else { - return criteria[i] ? -1 : 1; - } - } - - int sortAll(Map a, Map b) { - int i = 0; - int result = 0; - while (i < preference.length) { - result = compare(i, a, b); - if (result != 0) break; - i++; - } - return result; - } - - return sorted((a, b) => sortAll(a, b)); - } -} - -extension MultiSortListTupleMap on List<(Map, V)> { - /// [preference] - List of properties in which you want to sort the list - /// i.e. - /// ``` - /// List preference = ['property1','property2']; - /// ``` - /// This will first sort the list by property1 then by property2 - /// - /// [criteria] - List of booleans that specifies the criteria of sort - /// i.e., For ascending order `true` and for descending order `false`. - /// ``` - /// List criteria = [true. false]; - /// ``` - List<(Map, V)> sortByProperties( - List criteria, List preference) { - if (preference.isEmpty || criteria.isEmpty || isEmpty) { - return this; - } - if (preference.length != criteria.length) { - logger.d('Criteria length is not equal to preference'); - return this; - } - - int compare(int i, (Map, V) a, (Map, V) b) { - if (a.$1[preference[i]] == b.$1[preference[i]]) { - return 0; - } else if (a.$1[preference[i]] > b.$1[preference[i]]) { - return criteria[i] ? 1 : -1; - } else { - return criteria[i] ? -1 : 1; - } - } - - int sortAll((Map, V) a, (Map, V) b) { - int i = 0; - int result = 0; - while (i < preference.length) { - result = compare(i, a, b); - if (result != 0) break; - i++; - } - return result; - } - - return sorted((a, b) => sortAll(a, b)); - } -} diff --git a/lib/extensions/string.dart b/lib/extensions/string.dart index 0aa41dc67..d3706f3f2 100644 --- a/lib/extensions/string.dart +++ b/lib/extensions/string.dart @@ -7,7 +7,7 @@ extension UnescapeHtml on String { } extension NullableUnescapeHtml on String? { - String? unescapeHtml() => this == null ? null : htmlEscape.convert(this!); + String? unescapeHtml() => this?.unescapeHtml(); } extension StringExtension on String { diff --git a/lib/extensions/track.dart b/lib/extensions/track.dart index 9755179db..02c0c4927 100644 --- a/lib/extensions/track.dart +++ b/lib/extensions/track.dart @@ -3,8 +3,6 @@ import 'dart:io'; import 'package:metadata_god/metadata_god.dart'; import 'package:path/path.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/extensions/album_simple.dart'; -import 'package:spotube/extensions/artist_simple.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; extension TrackExtensions on Track { @@ -39,33 +37,6 @@ extension TrackExtensions on Track { return this; } - - Map toJson() { - return TrackExtensions.trackToJson(this); - } - - static Map trackToJson(Track track) { - return { - "album": track.album?.toJson(), - "artists": track.artists?.map((artist) => artist.toJson()).toList(), - "available_markets": track.availableMarkets?.map((e) => e.name).toList(), - "disc_number": track.discNumber, - "duration_ms": track.durationMs, - "explicit": track.explicit, - // "external_ids"track.: externalIds, - // "external_urls"track.: externalUrls, - "href": track.href, - "id": track.id, - "is_playable": track.isPlayable, - // "linked_from"track.: linkedFrom, - "name": track.name, - "popularity": track.popularity, - "preview_rrl": track.previewUrl, - "track_number": track.trackNumber, - "type": track.type, - "uri": track.uri, - }; - } } extension TrackSimpleExtensions on TrackSimple { diff --git a/lib/hooks/configurators/use_close_behavior.dart b/lib/hooks/configurators/use_close_behavior.dart index 79b14fa96..2bdc65ef6 100644 --- a/lib/hooks/configurators/use_close_behavior.dart +++ b/lib/hooks/configurators/use_close_behavior.dart @@ -1,29 +1,32 @@ import 'dart:io'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/hooks/configurators/use_window_listener.dart'; +import 'package:spotube/models/database/database.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; -// ignore: depend_on_referenced_packages + import 'package:local_notifier/local_notifier.dart'; +import 'package:spotube/utils/platform.dart'; +import 'package:window_manager/window_manager.dart'; -final closeNotification = DesktopTools.createNotification( - title: 'Spotube', - message: 'Running in background. Minimized to System Tray', - actions: [ - LocalNotificationAction(text: 'Close The App'), - ], -)?..onClickAction = (value) { - exit(0); - }; +final closeNotification = !kIsDesktop + ? null + : (LocalNotification( + title: 'Spotube', + body: 'Running in background. Minimized to System Tray', + actions: [ + LocalNotificationAction(text: 'Close The App'), + ], + )..onClickAction = (value) { + exit(0); + }); void useCloseBehavior(WidgetRef ref) { useWindowListener( onWindowClose: () async { final preferences = ref.read(userPreferencesProvider); if (preferences.closeBehavior == CloseBehavior.minimizeToTray) { - await DesktopTools.window.hide(); + await windowManager.hide(); closeNotification?.show(); } else { exit(0); diff --git a/lib/hooks/configurators/use_deep_linking.dart b/lib/hooks/configurators/use_deep_linking.dart index 2650b05ca..90d062dc7 100644 --- a/lib/hooks/configurators/use_deep_linking.dart +++ b/lib/hooks/configurators/use_deep_linking.dart @@ -7,7 +7,7 @@ import 'package:spotube/collections/routes.dart'; import 'package:spotube/provider/spotify_provider.dart'; import 'package:flutter_sharing_intent/flutter_sharing_intent.dart'; import 'package:flutter_sharing_intent/model/sharing_file.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; +import 'package:spotube/utils/platform.dart'; final appLinks = AppLinks(); final linkStream = appLinks.allStringLinkStream.asBroadcastStream(); @@ -53,7 +53,7 @@ void useDeepLinking(WidgetRef ref) { StreamSubscription? mediaStream; - if (DesktopTools.platform.isMobile) { + if (kIsMobile) { FlutterSharingIntent.instance.getInitialSharing().then(uriListener); mediaStream = diff --git a/lib/hooks/configurators/use_disable_battery_optimizations.dart b/lib/hooks/configurators/use_disable_battery_optimizations.dart index a9afef456..4aa51b741 100644 --- a/lib/hooks/configurators/use_disable_battery_optimizations.dart +++ b/lib/hooks/configurators/use_disable_battery_optimizations.dart @@ -1,12 +1,12 @@ import 'package:disable_battery_optimization/disable_battery_optimization.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; + import 'package:spotube/hooks/utils/use_async_effect.dart'; import 'package:spotube/services/kv_store/kv_store.dart'; +import 'package:spotube/utils/platform.dart'; void useDisableBatteryOptimizations() { useAsyncEffect(() async { - if (!DesktopTools.platform.isAndroid || - KVStoreService.askedForBatteryOptimization) return; + if (!kIsAndroid || KVStoreService.askedForBatteryOptimization) return; await DisableBatteryOptimization.showDisableBatteryOptimizationSettings(); diff --git a/lib/hooks/configurators/use_endless_playback.dart b/lib/hooks/configurators/use_endless_playback.dart index 98f38165a..e2fb1e6ee 100644 --- a/lib/hooks/configurators/use_endless_playback.dart +++ b/lib/hooks/configurators/use_endless_playback.dart @@ -1,28 +1,28 @@ -import 'package:catcher_2/catcher_2.dart'; +import 'package:spotube/services/logger/logger.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/provider/authentication_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/spotify_provider.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; void useEndlessPlayback(WidgetRef ref) { final auth = ref.watch(authenticationProvider); - final playback = ref.watch(proxyPlaylistProvider.notifier); - final playlist = ref.watch(proxyPlaylistProvider); + final playback = ref.watch(audioPlayerProvider.notifier); + final playlist = ref.watch(audioPlayerProvider.select((s) => s.playlist)); final spotify = ref.watch(spotifyProvider); final endlessPlayback = ref.watch(userPreferencesProvider.select((s) => s.endlessPlayback)); useEffect( () { - if (!endlessPlayback || auth == null) return null; + if (!endlessPlayback || auth.asData?.value == null) return null; void listener(int index) async { try { - final playlist = ref.read(proxyPlaylistProvider); + final playlist = ref.read(audioPlayerProvider); if (index != playlist.tracks.length - 1) return; final track = playlist.tracks.last; @@ -56,22 +56,22 @@ void useEndlessPlayback(WidgetRef ref) { await playback.addTracks( tracks.toList() ..removeWhere((e) { - final playlist = ref.read(proxyPlaylistProvider); + final playlist = ref.read(audioPlayerProvider); final isDuplicate = playlist.tracks.any((t) => t.id == e.id); return e.id == track.id || isDuplicate; }), ); } catch (e, stack) { - Catcher2.reportCheckedError(e, stack); + AppLogger.reportError(e, stack); } } // Sometimes user can change settings for which the currentIndexChanged // might not be called. So we need to check if the current track is the // last track and if it is then we need to call the listener manually. - if (playlist.active == playlist.tracks.length - 1 && + if (playlist.index == playlist.medias.length - 1 && audioPlayer.isPlaying) { - listener(playlist.active!); + listener(playlist.index); } final subscription = @@ -82,7 +82,7 @@ void useEndlessPlayback(WidgetRef ref) { [ spotify, playback, - playlist.tracks, + playlist.medias, endlessPlayback, auth, ], diff --git a/lib/hooks/configurators/use_fix_window_stretching.dart b/lib/hooks/configurators/use_fix_window_stretching.dart new file mode 100644 index 000000000..a6603d59e --- /dev/null +++ b/lib/hooks/configurators/use_fix_window_stretching.dart @@ -0,0 +1,21 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:spotube/utils/platform.dart'; +import 'package:window_manager/window_manager.dart'; + +void useFixWindowStretching() { + useEffect(() { + if (!kIsWindows) return; + WidgetsBinding.instance.addPostFrameCallback((Duration timeStamp) async { + await Future.delayed(const Duration(milliseconds: 100), () { + windowManager.getSize().then((Size value) { + windowManager.setSize( + Size(value.width + 1, value.height + 1), + ); + }); + }); + }); + + return null; + }, []); +} diff --git a/lib/hooks/configurators/use_get_storage_perms.dart b/lib/hooks/configurators/use_get_storage_perms.dart index 86b495c40..f860aaa71 100644 --- a/lib/hooks/configurators/use_get_storage_perms.dart +++ b/lib/hooks/configurators/use_get_storage_perms.dart @@ -1,35 +1,46 @@ import 'package:device_info_plus/device_info_plus.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; + import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:spotube/components/library/user_local_tracks.dart'; import 'package:spotube/hooks/utils/use_async_effect.dart'; +import 'package:spotube/provider/local_tracks/local_tracks_provider.dart'; +import 'package:spotube/utils/platform.dart'; void useGetStoragePermissions(WidgetRef ref) { - final isMounted = useIsMounted(); + final context = useContext(); useAsyncEffect( () async { - if (!DesktopTools.platform.isMobile) return; - - final androidInfo = await DeviceInfoPlugin().androidInfo; + if (kIsAndroid) { + final androidInfo = await DeviceInfoPlugin().androidInfo; - final hasNoStoragePerm = androidInfo.version.sdkInt < 33 && - !await Permission.storage.isGranted && - !await Permission.storage.isLimited; + final hasNoStoragePerm = androidInfo.version.sdkInt < 33 && + !await Permission.storage.isGranted && + !await Permission.storage.isLimited; - final hasNoAudioPerm = androidInfo.version.sdkInt >= 33 && - !await Permission.audio.isGranted && - !await Permission.audio.isLimited; + final hasNoAudioPerm = androidInfo.version.sdkInt >= 33 && + !await Permission.audio.isGranted && + !await Permission.audio.isLimited; - if (hasNoStoragePerm) { - await Permission.storage.request(); - if (isMounted()) ref.invalidate(localTracksProvider); + if (hasNoStoragePerm) { + await Permission.storage.request(); + if (context.mounted) ref.invalidate(localTracksProvider); + } + if (hasNoAudioPerm) { + await Permission.audio.request(); + if (context.mounted) ref.invalidate(localTracksProvider); + } } - if (hasNoAudioPerm) { - await Permission.audio.request(); - if (isMounted()) ref.invalidate(localTracksProvider); + + if (kIsIOS) { + final hasStoragePerm = await Permission.storage.isGranted || + await Permission.storage.isLimited; + + if (!hasStoragePerm) { + await Permission.storage.request(); + if (context.mounted) ref.invalidate(localTracksProvider); + } } }, null, diff --git a/lib/hooks/configurators/use_init_sys_tray.dart b/lib/hooks/configurators/use_init_sys_tray.dart deleted file mode 100644 index 0bce67270..000000000 --- a/lib/hooks/configurators/use_init_sys_tray.dart +++ /dev/null @@ -1,128 +0,0 @@ -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/collections/intents.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; - -void useInitSysTray(WidgetRef ref) { - final context = useContext(); - final systemTray = useRef(null); - - final initializeMenu = useCallback(() async { - systemTray.value?.destroy(); - final playlist = ref.read(proxyPlaylistProvider); - final playlistQueue = ref.read(proxyPlaylistProvider.notifier); - final preferences = ref.read(userPreferencesProvider); - if (!preferences.showSystemTrayIcon) { - await systemTray.value?.destroy(); - systemTray.value = null; - return; - } - final enabled = !playlist.isFetching; - systemTray.value = await DesktopTools.createSystemTrayMenu( - title: DesktopTools.platform.isWindows ? "Spotube" : "", - iconPath: "assets/spotube-logo.png", - windowsIconPath: "assets/spotube-logo.ico", - items: [ - MenuItemLabel( - label: "Show/Hide", - name: "show-hide", - onClicked: (item) async { - if (await DesktopTools.window.isVisible()) { - await DesktopTools.window.hide(); - } else { - await DesktopTools.window.show(); - } - }, - ), - MenuSeparator(), - MenuItemLabel( - label: "Play/Pause", - name: "play-pause", - enabled: enabled, - onClicked: (_) async { - Actions.maybeInvoke( - context, PlayPauseIntent(ref)) ?? - PlayPauseAction().invoke(PlayPauseIntent(ref)); - }, - ), - MenuItemLabel( - label: "Next", - name: "next", - enabled: enabled && (playlist.tracks.length) > 1, - onClicked: (p0) async { - await playlistQueue.next(); - }, - ), - MenuItemLabel( - label: "Previous", - name: "previous", - enabled: enabled && (playlist.tracks.length) > 1, - onClicked: (p0) async { - await playlistQueue.previous(); - }, - ), - MenuSeparator(), - MenuItemLabel( - label: "Quit", - name: "quit", - onClicked: (item) async { - exit(0); - }, - ), - ], - onEvent: (event, tray) async { - if (DesktopTools.platform.isWindows) { - switch (event) { - case SystemTrayEvent.click: - await DesktopTools.window.show(); - break; - case SystemTrayEvent.rightClick: - await tray.popUpContextMenu(); - break; - default: - } - } else { - switch (event) { - case SystemTrayEvent.rightClick: - await DesktopTools.window.show(); - break; - case SystemTrayEvent.click: - await tray.popUpContextMenu(); - break; - default: - } - } - }, - ); - }, [ref]); - - useReassemble(initializeMenu); - - ref.listen( - proxyPlaylistProvider, - (previous, next) { - initializeMenu(); - }, - ); - ref.listen( - userPreferencesProvider.select((s) => s.showSystemTrayIcon), - (previous, next) { - initializeMenu(); - }, - ); - - useEffect(() { - WidgetsBinding.instance.addPostFrameCallback((_) { - initializeMenu(); - }); - return () async { - await systemTray.value?.destroy(); - }; - }, [initializeMenu]); -} diff --git a/lib/hooks/configurators/use_update_checker.dart b/lib/hooks/configurators/use_update_checker.dart deleted file mode 100644 index 1a6a5be52..000000000 --- a/lib/hooks/configurators/use_update_checker.dart +++ /dev/null @@ -1,100 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; - -import 'package:flutter/material.dart'; -import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:http/http.dart' as http; -import 'package:spotube/collections/env.dart'; - -import 'package:spotube/components/shared/links/anchor_button.dart'; -import 'package:spotube/hooks/controllers/use_package_info.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:url_launcher/url_launcher_string.dart'; -import 'package:version/version.dart'; - -void useUpdateChecker(WidgetRef ref) { - final isCheckUpdateEnabled = - ref.watch(userPreferencesProvider.select((s) => s.checkUpdate)); - final packageInfo = usePackageInfo( - appName: 'Spotube', - packageName: 'spotube', - ); - final Future> Function() checkUpdate = useCallback( - () async { - final value = await http.get( - Uri.parse( - "https://api.github.com/repos/KRTirtho/spotube/releases/latest"), - ); - final tagName = - (jsonDecode(value.body)["tag_name"] as String).replaceAll("v", ""); - final currentVersion = packageInfo.version == "Unknown" - ? null - : Version.parse(packageInfo.version); - final latestVersion = - tagName == "nightly" ? null : Version.parse(tagName); - return [currentVersion, latestVersion]; - }, - [packageInfo.version], - ); - - final context = useContext(); - - download(String url) => launchUrlString( - url, - mode: LaunchMode.externalApplication, - ); - - useEffect(() { - if (!Env.enableUpdateChecker) return; - if (!isCheckUpdateEnabled) return null; - checkUpdate().then((value) { - final currentVersion = value.first; - final latestVersion = value.last; - if (currentVersion == null || - latestVersion == null || - (latestVersion.isPreRelease && !currentVersion.isPreRelease) || - (!latestVersion.isPreRelease && currentVersion.isPreRelease)) return; - if (latestVersion <= currentVersion) return; - showDialog( - context: context, - barrierDismissible: true, - barrierColor: Colors.black26, - builder: (context) { - const url = - "https://spotube.krtirtho.dev/other-downloads/stable-downloads"; - return AlertDialog( - title: const Text("Spotube has an update"), - actions: [ - FilledButton( - child: const Text("Download Now"), - onPressed: () => download(url), - ), - ], - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text("Spotube v${value.last} has been released"), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text("Read the latest "), - AnchorButton( - "release notes", - style: const TextStyle(color: Colors.blue), - onTap: () => launchUrlString( - url, - mode: LaunchMode.externalApplication, - ), - ), - ], - ), - ], - ), - ); - }, - ); - }); - return null; - }, [packageInfo, isCheckUpdateEnabled]); -} diff --git a/lib/hooks/configurators/use_window_listener.dart b/lib/hooks/configurators/use_window_listener.dart index b91ad413f..5977ea8e8 100644 --- a/lib/hooks/configurators/use_window_listener.dart +++ b/lib/hooks/configurators/use_window_listener.dart @@ -1,6 +1,8 @@ import 'package:flutter/widgets.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; + import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:spotube/utils/platform.dart'; +import 'package:window_manager/window_manager.dart'; class CallbackWindowListener implements WindowListener { final VoidCallback? _onWindowClose; @@ -154,6 +156,8 @@ void useWindowListener({ VoidCallback? onWindowEvent, }) { useEffect(() { + if (!kIsDesktop) return null; + final listener = CallbackWindowListener( onWindowClose: onWindowClose, onWindowFocus: onWindowFocus, @@ -172,9 +176,9 @@ void useWindowListener({ onWindowUndocked: onWindowUndocked, onWindowEvent: onWindowEvent, ); - DesktopTools.window.addListener(listener); + windowManager.addListener(listener); return () { - DesktopTools.window.removeListener(listener); + windowManager.removeListener(listener); }; }, [ onWindowClose, diff --git a/lib/hooks/utils/use_palette_color.dart b/lib/hooks/utils/use_palette_color.dart index 9269edd79..64994d2b0 100644 --- a/lib/hooks/utils/use_palette_color.dart +++ b/lib/hooks/utils/use_palette_color.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:palette_generator/palette_generator.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/components/image/universal_image.dart'; final _paletteColorState = StateProvider( (ref) { @@ -14,7 +14,6 @@ PaletteColor usePaletteColor(String imageUrl, WidgetRef ref) { final context = useContext(); final theme = Theme.of(context); final paletteColor = ref.watch(_paletteColorState); - final mounted = useIsMounted(); useEffect(() { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { @@ -25,7 +24,7 @@ PaletteColor usePaletteColor(String imageUrl, WidgetRef ref) { width: 50, ), ); - if (!mounted()) return; + if (!context.mounted) return; final color = theme.brightness == Brightness.light ? palette.lightMutedColor ?? palette.lightVibrantColor : palette.darkMutedColor ?? palette.darkVibrantColor; @@ -41,7 +40,7 @@ PaletteColor usePaletteColor(String imageUrl, WidgetRef ref) { PaletteGenerator usePaletteGenerator(String imageUrl) { final palette = useState(PaletteGenerator.fromColors([])); - final mounted = useIsMounted(); + final context = useContext(); useEffect(() { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { @@ -52,7 +51,7 @@ PaletteGenerator usePaletteGenerator(String imageUrl) { width: 50, ), ); - if (!mounted()) return; + if (!context.mounted) return; palette.value = newPalette; }); diff --git a/lib/l10n/app_ar.arb b/lib/l10n/app_ar.arb index 68308ba1f..a962b41ba 100644 --- a/lib/l10n/app_ar.arb +++ b/lib/l10n/app_ar.arb @@ -320,5 +320,69 @@ "select": "اختر", "connect_client_alert": "أنت تتم التحكم بواسطة {client}", "this_device": "هذا الجهاز", - "remote": "بعيد" + "remote": "بعيد", + "local_library": "المكتبة المحلية", + "add_library_location": "أضف إلى المكتبة", + "remove_library_location": "إزالة من المكتبة", + "local_tab": "محلي", + "stats": "إحصائيات", + "and_n_more": "و {count} أكثر", + "recently_played": "تم تشغيله مؤخرًا", + "browse_more": "تصفح المزيد", + "no_title": "بدون عنوان", + "not_playing": "غير مشغل", + "epic_failure": "فشل كبير!", + "added_num_tracks_to_queue": "تمت إضافة {tracks_length} مسارات إلى قائمة الانتظار", + "spotube_has_an_update": "يوجد تحديث لسبوتيوب", + "download_now": "تحميل الآن", + "nightly_version": "تم إصدار سبوتيوب الليلي {nightlyBuildNum}", + "release_version": "تم إصدار سبوتيوب v{version}", + "read_the_latest": "اقرأ الأحدث", + "release_notes": "ملاحظات الإصدار", + "pick_color_scheme": "اختر نظام الألوان", + "save": "حفظ", + "choose_the_device": "اختر الجهاز:", + "multiple_device_connected": "تم توصيل أجهزة متعددة.\nاختر الجهاز الذي تريد إجراء هذه العملية عليه", + "nothing_found": "لم يتم العثور على شيء", + "the_box_is_empty": "الصندوق فارغ", + "top_artists": "أفضل الفنانين", + "top_albums": "أفضل الألبومات", + "this_week": "هذا الأسبوع", + "this_month": "هذا الشهر", + "last_6_months": "آخر 6 أشهر", + "this_year": "هذا العام", + "last_2_years": "آخر سنتين", + "all_time": "كل الوقت", + "powered_by_provider": "مدعوم من {providerName}", + "email": "البريد الإلكتروني", + "profile_followers": "المتابعين", + "birthday": "عيد الميلاد", + "subscription": "اشتراك", + "not_born": "لم يولد", + "hacker": "هاكر", + "profile": "الملف الشخصي", + "no_name": "بدون اسم", + "edit": "تعديل", + "user_profile": "ملف المستخدم", + "count_plays": "{count} تشغيلات", + "streaming_fees_hypothetical": "رسوم البث (افتراضية)", + "minutes_listened": "الدقائق المستمعة", + "streamed_songs": "الأغاني المذاعة", + "count_streams": "{count} بث", + "owned_by_you": "مملوك لك", + "copied_shareurl_to_clipboard": "تم نسخ {shareUrl} إلى الحافظة", + "spotify_hipotetical_calculation": "*هذا محسوب بناءً على الدفع لكل بث من سبوتيفاي\nبقيمة 0.003 إلى 0.005 دولار. هذا حساب افتراضي\nلإعطاء المستخدم فكرة عن المبلغ الذي\nكان سيدفعه للفنانين إذا كانوا قد استمعوا\nإلى أغنيتهم على سبوتيفاي.", + "count_mins": "{minutes} دقيقة", + "summary_minutes": "الدقائق", + "summary_listened_to_music": "استمعت إلى الموسيقى", + "summary_songs": "أغاني", + "summary_streamed_overall": "بث بشكل عام", + "summary_owed_to_artists": "مدين للفنانين\nهذا الشهر", + "summary_artists": "الفنانين", + "summary_music_reached_you": "وصلت إليك الموسيقى", + "summary_full_albums": "ألبومات كاملة", + "summary_got_your_love": "حصلت على حبك", + "summary_playlists": "قوائم التشغيل", + "summary_were_on_repeat": "كانت على التكرار", + "total_money": "المجموع {money}" } \ No newline at end of file diff --git a/lib/l10n/app_bn.arb b/lib/l10n/app_bn.arb index 506e78bcb..97872c8c9 100644 --- a/lib/l10n/app_bn.arb +++ b/lib/l10n/app_bn.arb @@ -320,5 +320,69 @@ "select": "নির্বাচন করুন", "connect_client_alert": "আপনি {client} দ্বারা নিয়ন্ত্রিত হচ্ছেন", "this_device": "এই ডিভাইস", - "remote": "রিমোট" + "remote": "রিমোট", + "local_library": "স্থানীয় লাইব্রেরি", + "add_library_location": "লাইব্রেরিতে যোগ করুন", + "remove_library_location": "লাইব্রেরি থেকে সরান", + "local_tab": "স্থানীয়", + "stats": "পরিসংখ্যান", + "and_n_more": "এবং {count} আরও", + "recently_played": "সম্প্রতি বাজানো", + "browse_more": "আরও ব্রাউজ করুন", + "no_title": "কোনো শিরোনাম নেই", + "not_playing": "চালানো হচ্ছে না", + "epic_failure": "বিরাট ব্যর্থতা!", + "added_num_tracks_to_queue": "{tracks_length} ট্র্যাক সারিতে যোগ করা হয়েছে", + "spotube_has_an_update": "স্পটিউবে একটি আপডেট আছে", + "download_now": "এখনই ডাউনলোড করুন", + "nightly_version": "স্পটিউব নাইটলি {nightlyBuildNum} প্রকাশিত হয়েছে", + "release_version": "স্পটিউব v{version} প্রকাশিত হয়েছে", + "read_the_latest": "সর্বশেষ পড়ুন", + "release_notes": "রিলিজ নোট", + "pick_color_scheme": "রঙের থিম নির্বাচন করুন", + "save": "সংরক্ষণ করুন", + "choose_the_device": "ডিভাইস নির্বাচন করুন:", + "multiple_device_connected": "একাধিক ডিভাইস সংযুক্ত রয়েছে।\nযে ডিভাইসে আপনি এই ক্রিয়াটি চালাতে চান সেটি নির্বাচন করুন", + "nothing_found": "কিছুই পাওয়া যায়নি", + "the_box_is_empty": "বাক্সটি খালি", + "top_artists": "শীর্ষ শিল্পী", + "top_albums": "শীর্ষ অ্যালবাম", + "this_week": "এই সপ্তাহ", + "this_month": "এই মাস", + "last_6_months": "গত ৬ মাস", + "this_year": "এই বছর", + "last_2_years": "গত ২ বছর", + "all_time": "সব সময়", + "powered_by_provider": "{providerName} দ্বারা চালিত", + "email": "ইমেইল", + "profile_followers": "অনুসারী", + "birthday": "জন্মদিন", + "subscription": "সাবস্ক্রিপশন", + "not_born": "জন্মগ্রহণ করেনি", + "hacker": "হ্যাকার", + "profile": "প্রোফাইল", + "no_name": "কোন নাম নেই", + "edit": "সম্পাদনা করুন", + "user_profile": "ব্যবহারকারীর প্রোফাইল", + "count_plays": "{count} বার প্লে হয়েছে", + "streaming_fees_hypothetical": "স্ট্রিমিং ফি (ধারণাগত)", + "minutes_listened": "শুনেছেন মিনিট", + "streamed_songs": "স্ট্রিম করা গান", + "count_streams": "{count} বার স্ট্রিম", + "owned_by_you": "আপনার মালিকানাধীন", + "copied_shareurl_to_clipboard": "{shareUrl} ক্লিপবোর্ডে কপি করা হয়েছে", + "spotify_hipotetical_calculation": "*এটি স্পোটিফাইয়ের প্রতি স্ট্রিম\n$0.003 থেকে $0.005 পেআউটের ভিত্তিতে গণনা করা হয়েছে। এটি একটি ধারণাগত\nগণনা ব্যবহারকারীদেরকে জানাতে দেয় যে কত টাকা\nতারা শিল্পীদের দিতো যদি তারা স্পোটিফাইতে\nতাদের গান শুনতেন।", + "count_mins": "{minutes} মিনিট", + "summary_minutes": "মিনিট", + "summary_listened_to_music": "সঙ্গীত শুনেছেন", + "summary_songs": "গান", + "summary_streamed_overall": "মোট স্ট্রিম", + "summary_owed_to_artists": "এই মাসে\nশিল্পীদেরকে ঋণী", + "summary_artists": "শিল্পীর", + "summary_music_reached_you": "আপনার কাছে পৌঁছেছে সঙ্গীত", + "summary_full_albums": "সম্পূর্ণ অ্যালবাম", + "summary_got_your_love": "আপনার ভালোবাসা পেয়েছে", + "summary_playlists": "প্লেলিস্ট", + "summary_were_on_repeat": "পুনরাবৃত্তিতে ছিল", + "total_money": "মোট {money}" } \ No newline at end of file diff --git a/lib/l10n/app_ca.arb b/lib/l10n/app_ca.arb index 8faa0d093..2cda6e88c 100644 --- a/lib/l10n/app_ca.arb +++ b/lib/l10n/app_ca.arb @@ -320,5 +320,69 @@ "select": "Selecciona", "connect_client_alert": "Estàs sent controlat per {client}", "this_device": "Aquest dispositiu", - "remote": "Remot" + "remote": "Remot", + "local_library": "Biblioteca local", + "add_library_location": "Afegeix a la biblioteca", + "remove_library_location": "Elimina de la biblioteca", + "local_tab": "Local", + "stats": "Estadístiques", + "and_n_more": "i {count} més", + "recently_played": "Reproduït recentment", + "browse_more": "Navega més", + "no_title": "Sense títol", + "not_playing": "No s'està reproduint", + "epic_failure": "Fracàs èpic!", + "added_num_tracks_to_queue": "Afegit {tracks_length} pistes a la cua", + "spotube_has_an_update": "Spotube té una actualització", + "download_now": "Descarregar ara", + "nightly_version": "Spotube Nightly {nightlyBuildNum} ha estat publicat", + "release_version": "Spotube v{version} ha estat publicat", + "read_the_latest": "Llegeix el més recent", + "release_notes": "notes de la versió", + "pick_color_scheme": "Tria l'esquema de colors", + "save": "Desar", + "choose_the_device": "Tria el dispositiu:", + "multiple_device_connected": "Hi ha diversos dispositius connectats.\nTria el dispositiu on vols realitzar aquesta acció", + "nothing_found": "No s'ha trobat res", + "the_box_is_empty": "La caixa està buida", + "top_artists": "Millors artistes", + "top_albums": "Millors àlbums", + "this_week": "Aquesta setmana", + "this_month": "Aquest mes", + "last_6_months": "Últims 6 mesos", + "this_year": "Aquest any", + "last_2_years": "Últims 2 anys", + "all_time": "Tots els temps", + "powered_by_provider": "Funciona amb {providerName}", + "email": "Correu electrònic", + "profile_followers": "Seguidors", + "birthday": "Aniversari", + "subscription": "Subscripció", + "not_born": "No ha nascut", + "hacker": "Hacker", + "profile": "Perfil", + "no_name": "Sense nom", + "edit": "Editar", + "user_profile": "Perfil d'usuari", + "count_plays": "{count} reproduccions", + "streaming_fees_hypothetical": "Comissions de streaming (hipotètic)", + "minutes_listened": "minuts escoltats", + "streamed_songs": "cançons reproduïdes", + "count_streams": "{count} reproduccions", + "owned_by_you": "De la teva propietat", + "copied_shareurl_to_clipboard": "S'ha copiat {shareUrl} al porta-retalls", + "spotify_hipotetical_calculation": "*Això es calcula basant-se en els\npagaments per reproducció de Spotify de $0.003 a $0.005.\nAquest és un càlcul hipotètic per\ndonar als usuaris una idea de quant\nhaurien pagat als artistes si haguessin escoltat\nla seva cançó a Spotify.", + "count_mins": "{minutes} minuts", + "summary_minutes": "minuts", + "summary_listened_to_music": "has escoltat música", + "summary_songs": "cançons", + "summary_streamed_overall": "reproduït en general", + "summary_owed_to_artists": "degut als artistes\nAquest mes", + "summary_artists": "artistes", + "summary_music_reached_you": "La música t'ha arribat", + "summary_full_albums": "Àlbums complets", + "summary_got_your_love": "ha aconseguit el teu amor", + "summary_playlists": "llistes de reproducció", + "summary_were_on_repeat": "estaven en repetició", + "total_money": "total {money}" } \ No newline at end of file diff --git a/lib/l10n/app_cs.arb b/lib/l10n/app_cs.arb index 52f5bcf88..b1a22ee26 100644 --- a/lib/l10n/app_cs.arb +++ b/lib/l10n/app_cs.arb @@ -320,5 +320,69 @@ "select": "Vybrat", "connect_client_alert": "Zařízení je ovládáno z {client}", "this_device": "Toto zařízení", - "remote": "Ovladač" + "remote": "Ovladač", + "local_library": "Místní knihovna", + "add_library_location": "Přidat do knihovny", + "remove_library_location": "Odebrat z knihovny", + "local_tab": "Místní", + "stats": "Statistiky", + "and_n_more": "a dalších {count}", + "recently_played": "Nedávno přehráno", + "browse_more": "Procházet více", + "no_title": "Bez názvu", + "not_playing": "Nepřehrává se", + "epic_failure": "Epické selhání!", + "added_num_tracks_to_queue": "Přidáno {tracks_length} skladeb do fronty", + "spotube_has_an_update": "Spotube má aktualizaci", + "download_now": "Stáhnout nyní", + "nightly_version": "Byla vydána noční verze Spotube {nightlyBuildNum}", + "release_version": "Byla vydána verze Spotube v{version}", + "read_the_latest": "Přečtěte si nejnovější ", + "release_notes": "poznámky k vydání", + "pick_color_scheme": "Vyberte barevné schéma", + "save": "Uložit", + "choose_the_device": "Vyberte zařízení:", + "multiple_device_connected": "Je připojeno více zařízení.\nVyberte zařízení, na kterém chcete provést tuto akci", + "nothing_found": "Nic nenalezeno", + "the_box_is_empty": "Krabice je prázdná", + "top_artists": "Nejlepší umělci", + "top_albums": "Nejlepší alba", + "this_week": "Tento týden", + "this_month": "Tento měsíc", + "last_6_months": "Posledních 6 měsíců", + "this_year": "Tento rok", + "last_2_years": "Poslední 2 roky", + "all_time": "Všechny časy", + "powered_by_provider": "Pohání {providerName}", + "email": "Email", + "profile_followers": "Sledující", + "birthday": "Narozeniny", + "subscription": "Předplatné", + "not_born": "Nenarozen", + "hacker": "Hacker", + "profile": "Profil", + "no_name": "Bez jména", + "edit": "Upravit", + "user_profile": "Uživatelský profil", + "count_plays": "{count} přehrání", + "streaming_fees_hypothetical": "Poplatky za streamování (hypotetické)", + "minutes_listened": "Poslouchané minuty", + "streamed_songs": "Streamované skladby", + "count_streams": "{count} streamů", + "owned_by_you": "Vlastněno vámi", + "copied_shareurl_to_clipboard": "Zkopírováno {shareUrl} do schránky", + "spotify_hipotetical_calculation": "*Toto je vypočítáno na základě výplaty\nza stream Spotify od $0.003 do $0.005.\nToto je hypotetický výpočet,\nabyste měli představu o tom, kolik\nbyste zaplatili umělcům,\npokud byste poslouchali jejich píseň na Spotify.", + "count_mins": "{minutes} minut", + "summary_minutes": "minuty", + "summary_listened_to_music": "Poslouchal(a) hudbu", + "summary_songs": "písně", + "summary_streamed_overall": "Streamováno celkově", + "summary_owed_to_artists": "Dluženo umělcům\nTento měsíc", + "summary_artists": "umělců", + "summary_music_reached_you": "Hudba vás oslovila", + "summary_full_albums": "plná alba", + "summary_got_your_love": "Získal vaši lásku", + "summary_playlists": "playlisty", + "summary_were_on_repeat": "Byly na opakování", + "total_money": "Celkem {money}" } \ No newline at end of file diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index 77435d674..4b9495aa8 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -320,5 +320,69 @@ "select": "Auswählen", "connect_client_alert": "Du wirst von {client} gesteuert", "this_device": "Dieses Gerät", - "remote": "Fernbedienung" + "remote": "Fernbedienung", + "local_library": "Lokale Bibliothek", + "add_library_location": "Zur Bibliothek hinzufügen", + "remove_library_location": "Aus der Bibliothek entfernen", + "local_tab": "Lokal", + "stats": "Statistiken", + "and_n_more": "und {count} mehr", + "recently_played": "Zuletzt gespielt", + "browse_more": "Mehr durchsuchen", + "no_title": "Kein Titel", + "not_playing": "Wird nicht abgespielt", + "epic_failure": "Episches Versagen!", + "added_num_tracks_to_queue": "{tracks_length} Titel zur Warteschlange hinzugefügt", + "spotube_has_an_update": "Spotube hat ein Update", + "download_now": "Jetzt herunterladen", + "nightly_version": "Spotube Nightly {nightlyBuildNum} wurde veröffentlicht", + "release_version": "Spotube v{version} wurde veröffentlicht", + "read_the_latest": "Lese die neuesten ", + "release_notes": "Versionshinweise", + "pick_color_scheme": "Farbschema wählen", + "save": "Speichern", + "choose_the_device": "Wähle das Gerät:", + "multiple_device_connected": "Es sind mehrere Geräte verbunden.\nWähle das Gerät, auf dem diese Aktion ausgeführt werden soll", + "nothing_found": "Nichts gefunden", + "the_box_is_empty": "Die Box ist leer", + "top_artists": "Top-Künstler", + "top_albums": "Top-Alben", + "this_week": "Diese Woche", + "this_month": "Diesen Monat", + "last_6_months": "Letzte 6 Monate", + "this_year": "Dieses Jahr", + "last_2_years": "Letzte 2 Jahre", + "all_time": "Alle Zeiten", + "powered_by_provider": "Bereitgestellt von {providerName}", + "email": "Email", + "profile_followers": "Follower", + "birthday": "Geburtstag", + "subscription": "Abonnement", + "not_born": "Nicht geboren", + "hacker": "Hacker", + "profile": "Profil", + "no_name": "Kein Name", + "edit": "Bearbeiten", + "user_profile": "Benutzerprofil", + "count_plays": "{count} Wiedergaben", + "streaming_fees_hypothetical": "Streaming-Gebühren (hypothetisch)", + "minutes_listened": "Gehörte Minuten", + "streamed_songs": "Gestreamte Lieder", + "count_streams": "{count} Streams", + "owned_by_you": "In Ihrem Besitz", + "copied_shareurl_to_clipboard": "{shareUrl} in die Zwischenablage kopiert", + "spotify_hipotetical_calculation": "*Dies ist basierend auf Spotifys\npro Stream Auszahlung von $0,003 bis $0,005\nberechnet. Dies ist eine hypothetische Berechnung,\num dem Benutzer Einblick zu geben,\nwieviel sie den Künstlern gezahlt hätten,\nwenn sie ihren Song auf Spotify gehört hätten.", + "count_mins": "{minutes} Minuten", + "summary_minutes": "Minuten", + "summary_listened_to_music": "Hat Musik gehört", + "summary_songs": "Lieder", + "summary_streamed_overall": "Insgesamt gestreamt", + "summary_owed_to_artists": "Den Künstlern geschuldet\nDiesen Monat", + "summary_artists": "Künstler", + "summary_music_reached_you": "Musik hat Sie erreicht", + "summary_full_albums": "volle Alben", + "summary_got_your_love": "Hat Ihre Liebe gewonnen", + "summary_playlists": "Wiedergabelisten", + "summary_were_on_repeat": "Wurden wiederholt", + "total_money": "Gesamt {money}" } \ No newline at end of file diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 832862c01..06a90d793 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -107,6 +107,9 @@ "always_on_top": "Always on top", "exit_mini_player": "Exit Mini player", "download_location": "Download location", + "local_library": "Local library", + "add_library_location": "Add to library", + "remove_library_location": "Remove from library", "account": "Account", "login_with_spotify": "Login with your Spotify account", "connect_with_spotify": "Connect with Spotify", @@ -295,6 +298,7 @@ "delete_playlist": "Delete Playlist", "delete_playlist_confirmation": "Are you sure you want to delete this playlist?", "local_tracks": "Local Tracks", + "local_tab": "Local", "song_link": "Song Link", "skip_this_nonsense": "Skip this nonsense", "freedom_of_music": "“Freedom of Music”", @@ -320,5 +324,65 @@ "select": "Select", "connect_client_alert": "You're being controlled by {client}", "this_device": "This Device", - "remote": "Remote" + "remote": "Remote", + "stats": "Stats", + "and_n_more": "and {count} more", + "recently_played": "Recently Played", + "browse_more": "Browse More", + "no_title": "No Title", + "not_playing": "Not playing", + "epic_failure": "Epic failure!", + "added_num_tracks_to_queue": "Added {tracks_length} tracks to queue", + "spotube_has_an_update": "Spotube has an update", + "download_now": "Download Now", + "nightly_version": "Spotube Nightly {nightlyBuildNum} has been released", + "release_version": "Spotube v{version} has been released", + "read_the_latest": "Read the latest ", + "release_notes": "release notes", + "pick_color_scheme": "Pick color scheme", + "save": "Save", + "choose_the_device": "Choose the device:", + "multiple_device_connected": "There are multiple device connected.\nChoose the device you want this action to take place", + "nothing_found": "Nothing found", + "the_box_is_empty": "The box is empty", + "top_artists": "Top Artists", + "top_albums": "Top Albums", + "this_week": "This week", + "this_month": "This month", + "last_6_months": "Last 6 months", + "this_year": "This year", + "last_2_years": "Last 2 years", + "all_time": "All time", + "powered_by_provider": "Powered by {providerName}", + "email": "Email", + "profile_followers": "Followers", + "birthday": "Birthday", + "subscription": "Subscription", + "not_born": "Not born", + "hacker": "Hacker", + "profile": "Profile", + "no_name": "No Name", + "edit": "Edit", + "user_profile": "User Profile", + "count_plays": "{count} plays", + "streaming_fees_hypothetical": "Streaming fees (hypothetical)", + "minutes_listened": "Minutes listened", + "streamed_songs": "Streamed songs", + "count_streams": "{count} streams", + "owned_by_you": "Owned by you", + "copied_shareurl_to_clipboard": "Copied {shareUrl} to clipboard", + "spotify_hipotetical_calculation": "*This is calculated based on Spotify's per stream\npayout of $0.003 to $0.005. This is a hypothetical\ncalculation to give user insight about how much they\nwould have paid to the artists if they were to listen\ntheir song in Spotify.", + "count_mins": "{minutes} mins", + "summary_minutes": "minutes", + "summary_listened_to_music": "Listened to music", + "summary_songs": "songs", + "summary_streamed_overall": "Streamed overall", + "summary_owed_to_artists": "Owed to artists\nthis month", + "summary_artists": "artist's", + "summary_music_reached_you": "Music reached you", + "summary_full_albums": "full albums", + "summary_got_your_love": "Got your love", + "summary_playlists": "playlists", + "summary_were_on_repeat": "Were on repeat", + "total_money": "Total {money}" } \ No newline at end of file diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 11617b423..6834d845b 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -320,5 +320,69 @@ "select": "Seleccionar", "connect_client_alert": "Estás siendo controlado por {client}", "this_device": "Este dispositivo", - "remote": "Remoto" + "remote": "Remoto", + "local_library": "Biblioteca local", + "add_library_location": "Añadir a la biblioteca", + "remove_library_location": "Eliminar de la biblioteca", + "local_tab": "Local", + "stats": "Estadísticas", + "and_n_more": "y {count} más", + "recently_played": "Recién reproducido", + "browse_more": "Explorar más", + "no_title": "Sin título", + "not_playing": "No reproduciendo", + "epic_failure": "¡Fallo épico!", + "added_num_tracks_to_queue": "Se añadieron {tracks_length} canciones a la cola", + "spotube_has_an_update": "Spotube tiene una actualización", + "download_now": "Descargar ahora", + "nightly_version": "Spotube Nightly {nightlyBuildNum} ha sido lanzado", + "release_version": "Spotube v{version} ha sido lanzado", + "read_the_latest": "Lee las últimas ", + "release_notes": "notas de la versión", + "pick_color_scheme": "Elige esquema de color", + "save": "Guardar", + "choose_the_device": "Elige el dispositivo:", + "multiple_device_connected": "Hay múltiples dispositivos conectados.\nElige el dispositivo en el que deseas realizar esta acción", + "nothing_found": "Nada encontrado", + "the_box_is_empty": "La caja está vacía", + "top_artists": "Artistas principales", + "top_albums": "Álbumes principales", + "this_week": "Esta semana", + "this_month": "Este mes", + "last_6_months": "Últimos 6 meses", + "this_year": "Este año", + "last_2_years": "Últimos 2 años", + "all_time": "Todos los tiempos", + "powered_by_provider": "Impulsado por {providerName}", + "email": "Correo electrónico", + "profile_followers": "Seguidores", + "birthday": "Cumpleaños", + "subscription": "Suscripción", + "not_born": "No nacido", + "hacker": "Hacker", + "profile": "Perfil", + "no_name": "Sin nombre", + "edit": "Editar", + "user_profile": "Perfil de usuario", + "count_plays": "{count} reproducciones", + "streaming_fees_hypothetical": "Tarifas de streaming (hipotéticas)", + "minutes_listened": "Minutos escuchados", + "streamed_songs": "Canciones reproducidas", + "count_streams": "{count} streams", + "owned_by_you": "En tu posesión", + "copied_shareurl_to_clipboard": "Copiado {shareUrl} al portapapeles", + "spotify_hipotetical_calculation": "*Esto se calcula en base al\npago por stream de Spotify de $0.003 a $0.005.\nEs un cálculo hipotético para dar\nuna idea de cuánto habría\npagado a los artistas si hubieras escuchado\nsu canción en Spotify.", + "count_mins": "{minutes} minutos", + "summary_minutes": "minutos", + "summary_listened_to_music": "Escuchó música", + "summary_songs": "canciones", + "summary_streamed_overall": "Transmitido en general", + "summary_owed_to_artists": "Debido a los artistas\nEste mes", + "summary_artists": "artistas", + "summary_music_reached_you": "La música te alcanzó", + "summary_full_albums": "álbumes completos", + "summary_got_your_love": "Obtuvo tu amor", + "summary_playlists": "listas de reproducción", + "summary_were_on_repeat": "Estaban en repetición", + "total_money": "Total {money}" } \ No newline at end of file diff --git a/lib/l10n/app_eu.arb b/lib/l10n/app_eu.arb new file mode 100644 index 000000000..6cc416201 --- /dev/null +++ b/lib/l10n/app_eu.arb @@ -0,0 +1,388 @@ +{ + "guest": "Gonbidatua", + "browse": "Arakatu", + "search": "Bilatu", + "library": "Liburutegia", + "lyrics": "Hitzak", + "settings": "Ezarpenak", + "genre_categories_filter": "Kategoria edo generoak filtratu...", + "genre": "Generoa", + "personalized": "Pertsonalizatua", + "featured": "Nabarmenduak", + "new_releases": "Argitaratze berriak", + "songs": "Abestiak", + "playing_track": "{track} erreproduzitzen", + "queue_clear_alert": "Uneko zerrenda ezabatuko da. {track_length} abesti ezabatuko dira.\nJarraitu nahi duzu?", + "load_more": "Gehiago kargatu", + "playlists": "Zerrendak", + "artists": "Artistak", + "albums": "Albumak", + "tracks": "Kantak", + "downloads": "Deskargak", + "filter_playlists": "Zure zerrendak filtratu...", + "liked_tracks": "Gustuko Kantak", + "liked_tracks_description": "Zure gustuko kanta guztiak", + "create_playlist": "Sortu zerrenda", + "create_a_playlist": "Sortu zerrenda bat", + "update_playlist": "Eguneratu zerrenda", + "create": "Sortu", + "cancel": "Ezeztatu", + "update": "Eguneratu", + "playlist_name": "Zerrenda Izena", + "name_of_playlist": "Zerrendaren izena", + "description": "Deskribapena", + "public": "Publikoa", + "collaborative": "Kolaboratiboa", + "search_local_tracks": "Bilatu kanta lokalak...", + "play": "Erreproduzitu", + "delete": "Ezabatu", + "none": "Batere ez", + "sort_a_z": "Ordenatu A-Z", + "sort_z_a": "Ordenatu Z-A", + "sort_artist": "Ordenatu Artistaren arabera", + "sort_album": "Ordenatu Albumaren arabera", + "sort_duration": "Ordenar Iraupenaren arabera", + "sort_tracks": "Ordenatu Kantak", + "currently_downloading": "Oraintxe ({tracks_length}) deskargatzen", + "cancel_all": "Ezeztatu dena", + "filter_artist": "Filtratu artistak...", + "followers": "{followers} Jarraitzaile", + "add_artist_to_blacklist": "Gehitu artista zerrenda beltzera", + "top_tracks": "Top Kantak", + "fans_also_like": "Fan-ek hau ere gustuko dute", + "loading": "Kargatzen...", + "artist": "Artista", + "blacklisted": "Zerrenda beltzean", + "following": "Jarraitzen", + "follow": "Jarraitu", + "artist_url_copied": "Artistaren URL-a arbelera kopiatua", + "added_to_queue": "{tracks} kanta zerrendara gehituak", + "filter_albums": "Albumak filtratu...", + "synced": "Sinkronizatuta", + "plain": "Arrunta", + "shuffle": "Ausaz", + "search_tracks": "Bilatu kantak...", + "released": "Argitaratua", + "error": "Errorea: {error}", + "title": "Izenburua", + "time": "Iraupena", + "more_actions": "Ekintza gehiago", + "download_count": "({count}) deskarga", + "add_count_to_playlist": "Gehitu ({count}) zerrendara", + "add_count_to_queue": "Gehitu ({count}) ilarara", + "play_count_next": "Erreproduzitu hurrengo ({count})-ak", + "album": "Albuma", + "copied_to_clipboard": "{data} arbelean kopiatua", + "add_to_following_playlists": "Gehitu {track} hurrengo erreprodukzio-zerrendetara", + "add": "Gehitu", + "added_track_to_queue": "{track} zerrendan gehitua", + "add_to_queue": "Gehitu zerrendan", + "track_will_play_next": "{track} erreproduzituko da ondoren", + "play_next": "Hurrengo erreprodukzioa", + "removed_track_from_queue": "{track} zerrendatik ezabatua", + "remove_from_queue": "Ezabatu ilaratik", + "remove_from_favorites": "Ezabatu gogokoetatik", + "save_as_favorite": "Gorde gogokoetan", + "add_to_playlist": "Gehitu zerrendara", + "remove_from_playlist": "Ezabatu zerrendatik", + "add_to_blacklist": "Gehitu zerrenda beltzera", + "remove_from_blacklist": "Ezabatu zerrenda beltzetik", + "share": "Elkarbanatu", + "mini_player": "Mini Erreproduzitzailea", + "slide_to_seek": "Arrastatu aurrerantz edo atzearantz bilatzeko", + "shuffle_playlist": "Erreproduzitu zerrenda ausazko ordenean", + "unshuffle_playlist": "Desgaitu ausazko erreprodukzioa", + "previous_track": "Aurreko pista", + "next_track": "Hurrengo pista", + "pause_playback": "Pausatu erreprodukzioa", + "resume_playback": "Berrabiarazi erreprodukzioa", + "loop_track": "Kanta begiztan", + "repeat_playlist": "Errepikatu lista", + "queue": "Ilara", + "alternative_track_sources": "Kanten iturri alternatiboak", + "download_track": "Deskargatu kanta", + "tracks_in_queue": "{tracks} kanta zerrendan", + "clear_all": "Garbitu dena", + "show_hide_ui_on_hover": "Erakutsi/Ezkutatu interfazea kurtsorea pasatzean", + "always_on_top": "Beti ikusgai", + "exit_mini_player": "Irten mini erreproduzitzailetik", + "download_location": "Deskargen kokapena", + "local_library": "Liburutegi lokala", + "add_library_location": "Gehitu liburutegira", + "remove_library_location": "Kendu liburutegitik", + "account": "Kontua", + "login_with_spotify": "Hasi saioa zure Spotify kontuarekin", + "connect_with_spotify": "Spotify-rekin konektatu", + "logout": "Itxi saioa", + "logout_of_this_account": "Itxi kontu honen saioa", + "language_region": "Hizkuntza eta Herrialdea", + "language": "Hizkuntza", + "system_default": "Sisteman lehenetsia", + "market_place_region": "Dendaren herrialdea", + "recommendation_country": "Gomendio herrialdea", + "appearance": "Itxura", + "layout_mode": "Diseinua", + "override_layout_settings": "Responsive diseinuaren ezarpenak ezeztatu", + "adaptive": "Moldagarria", + "compact": "Trinkoa", + "extended": "Hedatua", + "theme": "Gaia", + "dark": "Iluna", + "light": "Argia", + "system": "Sistema", + "accent_color": "Azentu kolorea", + "sync_album_color": "Sinkronizatu albumaren kolorea", + "sync_album_color_description": "Albumaren artearen kolore nagusia erabili azentu kolore bezala", + "playback": "Erreprodukzioa", + "audio_quality": "Audioaren kalitatea", + "high": "Altua", + "low": "Baxua", + "pre_download_play": "Aurre-deskargatu eta erreproduzitu", + "pre_download_play_description": "Streaming egin beharrean, byte-ak deskargatu eta erreproduzitu (banda-zabalera handia duten erabiltzaileentzat gomendagarria)", + "skip_non_music": "Musika ez diren segmentuak baztertu (SponsorBlock)", + "blacklist_description": "Zerrenda beltzeko abesti eta artistak", + "wait_for_download_to_finish": "Mesedez, itxaron uneko deskarga bukatu arte", + "desktop": "Mahaigaina", + "close_behavior": "Ixterako Portaera", + "close": "Itxi", + "minimize_to_tray": "Sistemako erretilura minimizatu", + "show_tray_icon": "Erakutsi ikonoa sistemaren erretiluan", + "about": "Honi buruz", + "u_love_spotube": "Badakigu Spotube maite duzula", + "check_for_updates": "Bilatu eguneraketak", + "about_spotube": "Spotube-ri buruz", + "blacklist": "Zerrenda beltza", + "please_sponsor": "Mesedez, babestu/diruz lagundu", + "spotube_description": "Spotube, arina, plataforma-anitza eta doakoa den Spotify-ren bezeroa", + "version": "Bertsioa", + "build_number": "Konpilazio zenbakia", + "founder": "Sortzailea", + "repository": "Errepositorioa", + "bug_issues": "Erroreak eta arazoak", + "made_with": "Bangladesh🇧🇩-en ❤️-z egina", + "kingkor_roy_tirtho": "Kingkor Roy Tirtho", + "copyright": "© 2021-{current_year} Kingkor Roy Tirtho", + "license": "Lizentzia", + "add_spotify_credentials": "Gehitu zure Spotify kredentzialak hasi ahal izateko", + "credentials_will_not_be_shared_disclaimer": "Ez arduratu, zure kredentzialak ez ditugu bilduko edo inorekin elkarbanatuko", + "know_how_to_login": "Ez dakizu nola egin?", + "follow_step_by_step_guide": "Jarraitu pausoz-pausoko gida", + "spotify_cookie": "Spotify-ren {name} cookiea", + "cookie_name_cookie": "{name} cookiea", + "fill_in_all_fields": "Mesedez, osatu eremu guztiak", + "submit": "Bidali", + "exit": "Irten", + "previous": "Aurrekoa", + "next": "Hurrengoa", + "done": "Eginda", + "step_1": "1. pausua", + "first_go_to": "Hasteko, joan hona", + "login_if_not_logged_in": "eta hasi saioa/sortu kontua lehendik ez baduzu eginda", + "step_2": "2. pausua", + "step_2_steps": "1. Saioa hasita duzularik, sakatu F12 edo saguaren eskuineko botoia klikatu > Ikuskatu nabigatzaileko garapen tresnak irekitzeko.\n2. Joan \"Aplikazio\" (Chrome, Edge, Brave, etab.) edo \"Biltegiratzea\" (Firefox, Palemoon, etab.)\n3. Joan \"Cookieak\" atalera eta gero \"https://accounts.spotify.com\" azpiatalera", + "step_3": "3. pausua", + "step_3_steps": "Kopiatu \"sp_dc\" cookiearen balioa", + "success_emoji": "Eginda! 🥳", + "success_message": "Ongi hasi duzu zure Spotify kontua. Lan bikaina, lagun!", + "step_4": "4. pausua", + "step_4_steps": "Itsatsi \"sp_dc\"-tik kopiatutako balioa", + "something_went_wrong": "Zerbaitek huts egin du", + "piped_instance": "Piped zerbitzariaren instantzia", + "piped_description": "Kanten koizidentzietan erabiltzeko Piped zerbitzariaren instantzia", + "piped_warning": "Batzuk agian ez dute ongi funtzionatuko, zure ardurapean erabili", + "generate_playlist": "Sortu Zerrenda", + "track_exists": "{track} kanta dagoeneko badago", + "replace_downloaded_tracks": "Ordezkatu deskargatutako kanta guztiak", + "skip_download_tracks": "Deskargatutako kanta guztien deskarga baztertu", + "do_you_want_to_replace": "Dagoen kanta ordezkatu nahi duzu??", + "replace": "Ordezkatu", + "skip": "Baztertu", + "select_up_to_count_type": "Aukertu {count} {type}", + "select_genres": "Aukeratu Generoak", + "add_genres": "Gehitu Generoak", + "country": "Herrialdea", + "number_of_tracks_generate": "Sortzeko kanta kopurua", + "acousticness": "Akustikotasuna", + "danceability": "Dantzagarritasuna", + "energy": "Energia", + "instrumentalness": "Instrumentaltasuna", + "liveness": "Zuzenean", + "loudness": "Ozentasuna", + "speechiness": "Hitzaldia", + "valence": "Balentzia", + "popularity": "Populartasuna", + "key": "Tonua", + "duration": "Iraupena (s)", + "tempo": "Tenpoa (BPM)", + "mode": "Modua", + "time_signature": "Konpasa", + "short": "Motza", + "medium": "Ertaina", + "long": "Luzea", + "min": "Min.", + "max": "Max.", + "target": "Helburua", + "moderate": "Moderatua", + "deselect_all": "Desaukeratu dena", + "select_all": "Aukeratu dena", + "are_you_sure": "Ziur zaude?", + "generating_playlist": "Zure pertsonalizatutako zerrenda sortzen...", + "selected_count_tracks": "{count} kanta aukeratuta", + "download_warning": "Abesti guztiak aldi berean deskargatuz gero, argi dago musika pirateatzen ari zarela eta musikaren gizarte sortzaileari kalte egiten diozula. Honen jakitun izan eta artisten lan gogorra errespetatu eta babestea espero dut", + "download_ip_ban_warning": "Bidenabar, baliteke zure IPa YouTuben blokeatzea deskarga eskera gehiegi egiten badituzu. IPa blokeatzeak esan nahi du ezin izango duzula YouTube erabili (nahiz eta saioa hasia izan) gutxienez 2-3 hilabetez IP helbide horretatik. Eta Spotube ez da erantzule izango hori gertatzen bazaizu", + "by_clicking_accept_terms": "'Onartu' klikatzean, ondorengo baldintzak onartzen dituzu:", + "download_agreement_1": "Badakit musika pirateatzen ari naizela. Gaiztoa naiz", + "download_agreement_2": "Ahal dudanean lagunduko diot artistari baina oraingoz ez dut bere artea erosteko dirurik", + "download_agreement_3": "Erabat jakitun naiz YouTubek nire IPa blokea dezakeela eta ez diot Spotube-ri edo bere jabe/laguntzaileei erantzukizunik eskatuko nire oraingo jokaerak ekar ditzakeen arazoengatik", + "decline": "Baztertu", + "accept": "Onartu", + "details": "Xehetasunak", + "youtube": "YouTube", + "channel": "Kanala", + "likes": "Gustukoak", + "dislikes": "Ez gustukoak", + "views": "Ikuspenak", + "streamUrl": "Streaming-aren URLa", + "stop": "Gelditu", + "sort_newest": "Ordenatu gehitu berrienetik", + "sort_oldest": "Ordenatu gehitu zaharrenetik", + "sleep_timer": "Itzaltzeko tenporizadorea", + "mins": "{minutes} minutu", + "hours": "{hours} ordu", + "hour": "{hours} ordu", + "custom_hours": "Ordu pertsonalizatuak", + "logs": "Log-ak", + "developers": "Garatzaileak", + "not_logged_in": "Ez duzu saioa hasi", + "search_mode": "Bilaketa modua", + "audio_source": "Audio Iturria", + "ok": "OK", + "failed_to_encrypt": "Errorea zifratzean", + "encryption_failed_warning": "Spotube-ek zifratzea darabil datuak modu seguruan biltegiratzeko. Baina huts egin du. Hori dela eta, biltegiratzea ez da segurua izango\nLinux erabiltzen ari bazara, ziurtatu edozein sekretu-zerbitzu (gnome-keyring, kde-wallet, keepassxc etab.) instalatuta duzula", + "querying_info": "Informazioa egiaztatzen...", + "piped_api_down": "Piped-en APIa ez dago eskuragarri", + "piped_down_error_instructions": "Piped-en {pipedInstance} instantzia ez dago martxan une honetan\n\nAldatu instantzia edo aldatu 'API mota' YouTuberen API ofizialera\n\nZiurtatu aplikazioa berrabiarazten duzula aldaketa eta gero", + "you_are_offline": "Une honetan konexiorik gabe zaude", + "connection_restored": "Internet konexioa berrezarri egin da", + "use_system_title_bar": "Erabili sistemako izenburu barra", + "crunching_results": "Emaitzak prozesatzen...", + "search_to_get_results": "Bilatu emaitzak lortzeko", + "use_amoled_mode": "Erabili AMOLED modua", + "pitch_dark_theme": "Dart-en gai iluna", + "normalize_audio": "Normalizatu audioa", + "change_cover": "Aldatu azala", + "add_cover": "Gehitu azala", + "restore_defaults": "Berrezarri berezko balioak", + "download_music_codec": "Deskargatutako musikaren codec-a", + "streaming_music_codec": "Streaming musikaren codec-a", + "login_with_lastfm": "Hasi saioa Last.fm-n", + "connect": "Konektatu", + "disconnect_lastfm": "Deskonektatu Last.fm-tik", + "disconnect": "Deskonektatu", + "username": "Erabiltzaile izena", + "password": "Pasahitza", + "login": "Hasi saioa", + "login_with_your_lastfm": "Hasi saioa Last.fm-ko zure kontuarekin", + "scrobble_to_lastfm": "Scrobble Last.fm-ra", + "go_to_album": "Albumera joan", + "discord_rich_presence": "Discord-en presentzia aberatsa", + "browse_all": "Esploratu dena", + "genres": "Generoak", + "explore_genres": "Esploratu generoak", + "friends": "Lagunak", + "no_lyrics_available": "Sentitzen dugu, ezin dira kanta honen hitzak aurkitu", + "start_a_radio": "Hasi Irrati bat", + "how_to_start_radio": "Nola hasi nahi duzu irratia?", + "replace_queue_question": "Uneko zerrenda ordezkatu nahi duzu edo bertan gehitu?", + "endless_playback": "Amaigabeko erreprodukzioa", + "delete_playlist": "Ezabatu zerrenda", + "delete_playlist_confirmation": "Ziur zaude zerrenda ezabatu nahi duzula?", + "local_tracks": "Kanta lokalak", + "local_tab": "Lokalean", + "song_link": "Kantaren lotura", + "skip_this_nonsense": "Utzi txorakeria hau", + "freedom_of_music": "“Musika Askatasuna”", + "freedom_of_music_palm": "“Musika Askatasuna zure eskuetan”", + "get_started": "Has gaitezen", + "youtube_source_description": "Gomendatua eta hobekien dabilena.", + "piped_source_description": "Aske zara? YouTube bezala, baino askeago.", + "jiosaavn_source_description": "Asia hegoaldeko herrialdeetarako hoberena.", + "highest_quality": "Kalitate Onena: {quality}", + "select_audio_source": "Aukeratu Audio Iturria", + "endless_playback_description": "Gehitu automatikoki kanta berriak\n ilararen bukaeran", + "choose_your_region": "Aukeratu zure herrialdea", + "choose_your_region_description": "Honekin Spotube-k zure kokalerakuari dagokion edukia\neskeiniko dizu.", + "choose_your_language": "Aukeratu zure hizkuntza", + "help_project_grow": "Lagundu proiektu honi hazten", + "help_project_grow_description": "Spotube kode irekiko proiektu bat da. Proiektu hau hazten lagundu dezakezu, erroreak jakinaraziz edo ezaugarri berriak proposatuz.", + "contribute_on_github": "GitHub-en lagundu", + "donate_on_open_collective": "Open Collective-en diruz lagundu", + "browse_anonymously": "Nabigatu Anonimoki", + "enable_connect": "Gaitu konexioa", + "enable_connect_description": "Kontrolatu Spotube beste gailu batzuetatik", + "devices": "Gailuak", + "select": "Aukeratu", + "connect_client_alert": "{client} gailuak kontrolatzen zaitu", + "this_device": "Gailu hau", + "remote": "Urrunekoa", + "stats": "Estatistikak", + "and_n_more": "eta {count} gehiago", + "recently_played": "Berriki entzunak", + "browse_more": "Gehiago Bilatu", + "no_title": "Titulurik ez", + "not_playing": "Erreprodukziorik ez", + "epic_failure": "Sekulako errorea!", + "added_num_tracks_to_queue": "{tracks_length} kanta gehitu dira zerrendara", + "spotube_has_an_update": "Spotube-ren eguneraketa bat dago", + "download_now": "Orain deskargatu", + "nightly_version": "Spotube {nightlyBuildNum} Nightly-a argitaratu da", + "release_version": "Spotube v{version} argitaratu da", + "read_the_latest": "Irakurri azken ", + "release_notes": "argitatratze oharrak", + "pick_color_scheme": "Aukeratu kolore eskema", + "save": "Gorde", + "choose_the_device": "Aukeratu gailua:", + "multiple_device_connected": "Hainbat gailu daude konektatuta.\nAukeratu zein gailutan aplikatu nahi duzun ekintza hau", + "nothing_found": "Ezer ez da aurkitu", + "the_box_is_empty": "Kaxa hutsik dago", + "top_artists": "Top Artistak", + "top_albums": "Top Albumak", + "this_week": "Aste honetan", + "this_month": "Hilabete honetan", + "last_6_months": "Azken 6 hilabeteetan", + "this_year": "Aurten", + "last_2_years": "Azken 2 urtetan", + "all_time": "Betidanik", + "powered_by_provider": "{providerName}-ren eskutik", + "email": "Email", + "profile_followers": "Jarraitzaileak", + "birthday": "Jaiotze-data", + "subscription": "Harpidetzak", + "not_born": "Jaio gabe", + "hacker": "Hacker", + "profile": "Profila", + "no_name": "Izenik Ez", + "edit": "Editatu", + "user_profile": "Erabiltzaile Profila", + "count_plays": "{count} erreprodukzio", + "streaming_fees_hypothetical": "Streaming ordainketa (hipotetikoa)", + "minutes_listened": "Entzundako minutuak", + "streamed_songs": "Stream-eatutako kantak", + "count_streams": "{count} stream", + "owned_by_you": "Zure jabetzakoa", + "copied_shareurl_to_clipboard": "{shareUrl} arbelera kopiatua", + "spotify_hipotetical_calculation": "*Sportify-k stream bakoitzeko duen $0.003 eta $0.005\nordainsarian oinarritua da. Kalkulu hipotetiko bat,\nkanta hauek Spotify-n entzun bazenitu,\nberaiek artistari zenbat ordaiduko lioketen jakin dezazun.", + "count_mins": "{minutes} minutu", + "summary_minutes": "minutu", + "summary_listened_to_music": "Musika entzuten", + "summary_songs": "kanta", + "summary_streamed_overall": "Stream-eatuta oro har", + "summary_owed_to_artists": "Hilabete honetan\nartistei zor zaiena", + "summary_artists": "artisten", + "summary_music_reached_you": "Musika ailegatu zaizu", + "summary_full_albums": "album osok", + "summary_got_your_love": "Izan dute zure maitasuna", + "summary_playlists": "zerrenda", + "summary_were_on_repeat": "Dituzu errepikatze moduan", + "total_money": "Guztira {money}" +} \ No newline at end of file diff --git a/lib/l10n/app_fa.arb b/lib/l10n/app_fa.arb index 8a0bee3ad..5611e0cc4 100644 --- a/lib/l10n/app_fa.arb +++ b/lib/l10n/app_fa.arb @@ -320,5 +320,69 @@ "select": "انتخاب", "connect_client_alert": "شما توسط {client} کنترل می‌شوید", "this_device": "این دستگاه", - "remote": "راه‌دور" + "remote": "راه‌دور", + "local_library": "کتابخانه محلی", + "add_library_location": "اضافه کردن به کتابخانه", + "remove_library_location": "حذف از کتابخانه", + "local_tab": "محلی", + "stats": "آمار", + "and_n_more": "و {count} بیشتر", + "recently_played": "اخیراً پخش شده", + "browse_more": "بیشتر مرور کنید", + "no_title": "بدون عنوان", + "not_playing": "در حال پخش نیست", + "epic_failure": "شکست حماسی!", + "added_num_tracks_to_queue": "{tracks_length} ترک به صف اضافه شد", + "spotube_has_an_update": "Spotube یک بروزرسانی دارد", + "download_now": "اکنون دانلود کنید", + "nightly_version": "نسخه شبانه Spotube {nightlyBuildNum} منتشر شد", + "release_version": "نسخه Spotube v{version} منتشر شد", + "read_the_latest": "آخرین‌ها را بخوانید", + "release_notes": "یادداشت‌های انتشار", + "pick_color_scheme": "طرح رنگ را انتخاب کنید", + "save": "ذخیره", + "choose_the_device": "دستگاه را انتخاب کنید:", + "multiple_device_connected": "چندین دستگاه متصل هستند.\nدستگاهی را انتخاب کنید که می‌خواهید این عملیات بر روی آن انجام شود", + "nothing_found": "چیزی پیدا نشد", + "the_box_is_empty": "جعبه خالی است", + "top_artists": "بهترین هنرمندان", + "top_albums": "بهترین آلبوم‌ها", + "this_week": "این هفته", + "this_month": "این ماه", + "last_6_months": "۶ ماه گذشته", + "this_year": "امسال", + "last_2_years": "۲ سال گذشته", + "all_time": "همیشه", + "powered_by_provider": "توسط {providerName} پشتیبانی شده است", + "email": "ایمیل", + "profile_followers": "دنبال‌کنندگان", + "birthday": "تولد", + "subscription": "اشتراک", + "not_born": "متولد نشده", + "hacker": "هکر", + "profile": "پروفایل", + "no_name": "بدون نام", + "edit": "ویرایش", + "user_profile": "پروفایل کاربر", + "count_plays": "{count} پخش", + "streaming_fees_hypothetical": "هزینه‌های پخش (فرضی)", + "minutes_listened": "دقایق گوش داده شده", + "streamed_songs": "ترانه‌های پخش شده", + "count_streams": "{count} پخش", + "owned_by_you": "توسط شما مالکیت شده", + "copied_shareurl_to_clipboard": "{shareUrl} به کلیپ‌بورد کپی شد", + "spotify_hipotetical_calculation": "*این بر اساس پرداخت هر پخش اسپاتیفای\nبه مبلغ 0.003 تا 0.005 دلار محاسبه شده است.\nاین یک محاسبه فرضی است که به کاربران نشان دهد چقدر ممکن است\nبه هنرمندان پرداخت می‌کردند اگر ترانه آنها را در اسپاتیفای گوش می‌دادند.", + "count_mins": "{minutes} دقیقه", + "summary_minutes": "دقیقه‌ها", + "summary_listened_to_music": "به موسیقی گوش داده شده", + "summary_songs": "ترانه‌ها", + "summary_streamed_overall": "پخش شده به طور کلی", + "summary_owed_to_artists": "به هنرمندان بدهکار است\nاین ماه", + "summary_artists": "هنرمندان", + "summary_music_reached_you": "موسیقی به شما رسیده است", + "summary_full_albums": "آلبوم‌های کامل", + "summary_got_your_love": "عشق شما را به دست آورد", + "summary_playlists": "لیست‌های پخش", + "summary_were_on_repeat": "در تکرار بودند", + "total_money": "مجموع {money}" } \ No newline at end of file diff --git a/lib/l10n/app_fi.arb b/lib/l10n/app_fi.arb new file mode 100644 index 000000000..57f209aba --- /dev/null +++ b/lib/l10n/app_fi.arb @@ -0,0 +1,388 @@ +{ + "guest": "Vieras", + "browse": "Selaa", + "search": "Hae", + "library": "Kirjasto", + "lyrics": "Lyriikat", + "settings": "Asetukset", + "genre_categories_filter": "Suodata kategorioita tai genrejä", + "genre": "Genre", + "personalized": "Personoidut", + "featured": "Esittelyssä", + "new_releases": "Uusi julkaisu", + "songs": "Laulut", + "playing_track": "Soitetaan {track}", + "queue_clear_alert": "Tämä tulee tyhjentämään jonon. {track_length} Kappaleita poistetaan\nHaluatko jatkaa?", + "load_more": "Lataa lisää", + "playlists": "Soittolistat", + "artists": "Artistit", + "albums": "Albumit", + "tracks": "Kappaleet", + "downloads": "Lataukset", + "filter_playlists": "Suodata soittolistasi...", + "liked_tracks": "Tykätyt kappaleet", + "liked_tracks_description": "Kaikki tykättysi kappaleet", + "create_playlist": "Luo soittolista", + "create_a_playlist": "Luo soittolista", + "update_playlist": "Päivitä soittolista", + "create": "Luo", + "cancel": "Peruuta", + "update": "Päivitä", + "playlist_name": "Soittolistan nimi", + "name_of_playlist": "Soittolistan nimi", + "description": "Kuvaus", + "public": "Julkinen", + "collaborative": "Collaborative", + "search_local_tracks": "Hae paikallisia lauluja...", + "play": "Soita", + "delete": "Poista", + "none": "Ei mitään", + "sort_a_z": "Suodata A-Z", + "sort_z_a": "Suodata Z-A", + "sort_artist": "Suodata Artistilta", + "sort_album": "Suodata Albumilta", + "sort_duration": "Suodata Pituudelta", + "sort_tracks": "Suodata Kappaleet", + "currently_downloading": "Ladataan ({tracks_length})", + "cancel_all": "Peru kaikki", + "filter_artist": "Suodata artistit...", + "followers": "{followers} Seuraajaa", + "add_artist_to_blacklist": "Lisää artisti mustalle listalle", + "top_tracks": "Suosituimmat kappaleet", + "fans_also_like": "Fanit myös tykkäsivät", + "loading": "Ladataan...", + "artist": "Artisti", + "blacklisted": "Mustalistattu", + "following": "Seurataan", + "follow": "Seuraa", + "artist_url_copied": "Aristin URL kopioitiin leikepöytään", + "added_to_queue": "Lisättiin {tracks} kappaletta jonoon", + "filter_albums": "Suodata albumit...", + "synced": "Synkronoitu", + "plain": "Tavallinen", + "shuffle": "Sekoita", + "search_tracks": "Hae kappaleita...", + "released": "Julkaistu", + "error": "Virhe {error}", + "title": "Otsikko", + "time": "Aika", + "more_actions": "Lisää toimintoja", + "download_count": "Lataa ({count})", + "add_count_to_playlist": "Lisää ({count}) Soittolistaasi", + "add_count_to_queue": "Lisää ({count}) Jonoon", + "play_count_next": "Soita ({count}) seuraavaksi", + "album": "Albumi", + "copied_to_clipboard": "Kopioitiin {data} leikepöytään", + "add_to_following_playlists": "Lisää {track} seuraaviin soittolistoihin", + "add": "Lisää", + "added_track_to_queue": "Lisättiin {track} jonoon", + "add_to_queue": "Lisää jonoon", + "track_will_play_next": "{track} Soitetaan seuraavaksi", + "play_next": "Soita seuraavaksi", + "removed_track_from_queue": "Poistettiin {track} jonosta", + "remove_from_queue": "Poista jonosta", + "remove_from_favorites": "Poista suosikeista", + "save_as_favorite": "Tallenna soittolistana", + "add_to_playlist": "Lisää soittolistaan", + "remove_from_playlist": "Poista soittolistasta", + "add_to_blacklist": "Lisää mustalle listalle", + "remove_from_blacklist": "Poista mustalistalta", + "share": "Jaa", + "mini_player": "Minisoitin", + "slide_to_seek": "Liu'uta mennäkseen eteenpäin tai taaksepäin", + "shuffle_playlist": "Sekoita soittolista", + "unshuffle_playlist": "Poista sekoitus soittolistasta", + "previous_track": "Äskeinen kappale", + "next_track": "Seuraava kappale", + "pause_playback": "Pysäytä soittolistan toisto", + "resume_playback": "Jatka soittolistan toistoa", + "loop_track": "Uudelleentoista kappale", + "repeat_playlist": "Toista soittolista uudelleen", + "queue": "Jono", + "alternative_track_sources": "Toinen kappale lähde", + "download_track": "Lataa kappale", + "tracks_in_queue": "{tracks} kappaletta jonossa", + "clear_all": "Tyhjennä kaikki", + "show_hide_ui_on_hover": "Näytä/Piilota UI leijumalla", + "always_on_top": "Aina päällimmäisenä", + "exit_mini_player": "Lähde minisoittimesta", + "download_location": "Lataus sijainti", + "account": "Käyttäjä", + "login_with_spotify": "Kirjaudu Spotify-käyttäjällä", + "connect_with_spotify": "Yhdistä Spotify:lla", + "logout": "Kirjaudu ulos", + "logout_of_this_account": "Kirjaudu ulos tältä käyttäjältä", + "language_region": "Kieli ja Maa", + "language": "Kieli", + "system_default": "Järjestelmän oletus", + "market_place_region": "Markkina-alue", + "recommendation_country": "Suositeltu maa", + "appearance": "Ulkomuto", + "layout_mode": "Asettelutila", + "override_layout_settings": "Jätä reagoiva asettelutila huomioimatta", + "adaptive": "Mukautuva", + "compact": "Kompakti", + "extended": "Laajennettu", + "theme": "Teema", + "dark": "Tumma", + "light": "Vaalea", + "system": "Järjestelmä", + "accent_color": "Korostusväri", + "sync_album_color": "Synkronoi albumin väri", + "sync_album_color_description": "Käyttää albumin kansitaiteen vallitsevaa väirä korostuvärinä", + "playback": "Toisto", + "audio_quality": "Äänenlaatu", + "high": "Korkea", + "low": "Matala", + "pre_download_play": "Esilataa ja soita", + "pre_download_play_description": "Audion suoratoiston sijaan, lataa tavut ja soita ne (Suositeltu korkeamman kaistanleveyden käyttäjille)", + "skip_non_music": "Ohita ei-musiikki kohdat (SponsorBlock)", + "blacklist_description": "Mustalistat kappaleet aja artistit", + "wait_for_download_to_finish": "Odota nykyisen latauksen lopetteluun", + "desktop": "Työpöytä", + "close_behavior": "Sulkemisen käyttäytyminen", + "close": "Sulje", + "minimize_to_tray": "Minimisoi tehtäväpalkkiin", + "show_tray_icon": "Näytä järjestelmäkuvake", + "about": "Tietoa", + "u_love_spotube": "Tiedämme että rakastat Spotubea", + "check_for_updates": "Tarkista päivitykset", + "about_spotube": "Tietoa Spotube:sta", + "blacklist": "Mustalista", + "please_sponsor": "Sponsoroi/Lahjoita, kiitos", + "spotube_description": "Spotube, kevyt, cross-platform, vapaa-kaikille spotify clientti", + "version": "Versio", + "build_number": "Rakennusnumero", + "founder": "Perustaja", + "repository": "Arkisto", + "bug_issues": "Bugit+Ongelmat", + "made_with": "Tehty ❤️ Bangladeshista 🇧🇩", + "kingkor_roy_tirtho": "Kingkor Roy Tirtho", + "copyright": "© 2021-{current_year} Kingkor Roy Tirtho", + "license": "Lisenssi", + "add_spotify_credentials": "Lisää Spotify-tunnuksesi aloittaaksesi", + "credentials_will_not_be_shared_disclaimer": "Älä huoli, tunnuksiasi ei talleteta tai jaeta kenenkään kanssa", + "know_how_to_login": "Etkö tiedä miten tehdä tämä?", + "follow_step_by_step_guide": "Seuraa askel askeleelta opasta", + "spotify_cookie": "Spotify {name} Keksi", + "cookie_name_cookie": "{name} Keksi", + "fill_in_all_fields": "Täytä kaikki kentät", + "submit": "Lähetä", + "exit": "Poistu", + "previous": "Edellinen", + "next": "Seuraava", + "done": "Tehty", + "step_1": "Vaihe 1", + "first_go_to": "Ensiksi, mene", + "login_if_not_logged_in": "ja Kirjaudu/Tee tili jos et ole kirjautunut sisään", + "step_2": "Vaihe 2", + "step_2_steps": "1. Kun olet kirjautunut, paina F12 tai oikeaa hiiren näppäintä > Tarkista ja avaa selaimen kehittäjä työkalut.\n2. Mene sitten \"Application\"-välilehteen (Chrome, Edge, Brave jne..) tai \"Storage\"-välilehteen (Firefox, Palemoon jne..)\n3. Mene \"Cookies\"-osastoon, sitten \"https://accounts.spotify.com\" alakohtaan.", + "step_3": "Vaihe 3", + "step_3_steps": "Kopioi Keksin \"sp_dc\" arvo", + "success_emoji": "Onnistuit🥳", + "success_message": "Olet nyt kirjautunut sisään Spotify-käyttäjällesi. Hyvää työtä toveri!", + "step_4": "Vaihe 4", + "step_4_steps": "Liitä kopioitu \"sp_dc\" arvo", + "something_went_wrong": "Jotain meni pieleen", + "piped_instance": "Johdettu palvelinesiintymä", + "piped_description": "Johdettu palvelinesiintymä Kappale täsmäyksiin", + "piped_warning": "Jotkut niistä eivät toimi hyvin, käytä siis omalla vastuullasi", + "generate_playlist": "Tuota soittolista", + "track_exists": "Kappale {track} on jo olemassa!", + "replace_downloaded_tracks": "Korvaa kaikki ladatut kappaleet", + "skip_download_tracks": "Ohita ladattujen laulujen lataaminen", + "do_you_want_to_replace": "Haluatko korvata olemassa olevan kappaleen??", + "replace": "Korvaa", + "skip": "Ohita", + "select_up_to_count_type": "Valitse enintään {count} {type}", + "select_genres": "Valitse Genret", + "add_genres": "Lisää Genrejä", + "country": "Maa", + "number_of_tracks_generate": "Numero tuotettavia kappaleita", + "acousticness": "Akustisuus", + "danceability": "Tanssittavuus", + "energy": "Energia", + "instrumentalness": "Instrumentaalisuus", + "liveness": "Elävyyttä", + "loudness": "Äänekkyys", + "speechiness": "Puheisuus", + "valence": "Valenssi", + "popularity": "Suosio", + "key": "Sävellaji", + "duration": "Pituus (s)", + "tempo": "Tempo (BPM)", + "mode": "Tila", + "time_signature": "Aikamerkki", + "short": "Lyhyt", + "medium": "Keskikokoinen", + "long": "Pitkä", + "min": "Minimi", + "max": "Maximi", + "target": "Kohde", + "moderate": "Kohtalainen", + "deselect_all": "Poista kaikki valinnat", + "select_all": "Valitse kaikki", + "are_you_sure": "Oletko varma?", + "generating_playlist": "Luodaan mukautettua soittolistoa...", + "selected_count_tracks": "Valittu {count} kappaletta", + "download_warning": "Jos lataat kaikki laulut kerrällä olet selkeästi Piratoimassa ja aiheuttamassa vahinkoa musiikin luovaan yhteiskuntaan. Toivottavasti olet tietoinen tästä. Yritä aina kunnioittaa ja tukea Artistin kovaa työtä.", + "download_ip_ban_warning": "BTW, YouTube voi estää IP-Osoitteesi tavallista liiallisten latauspyyntöjen takia. IP-Osoitteen esto tarkoittaa sitä, ettet voi käyttää YouTubea (vaikka olisit kirjautunut) vähintään 2-3kk aikana kyseiseltä laitteelta. Spotube ei kanna yhtään vastuuta jos se tapahtuu.", + "by_clicking_accept_terms": "Painamalla 'hyväksy' hyväksyt seuraaviin ehtoihin:", + "download_agreement_1": "Tiedän että Piratoin musiikkia. Olen paha.", + "download_agreement_2": "Tuen Artisteja silloin kun pystyn, ja teen tämän vain koska minulla ei ole rahaa ostaa heidän taidetta", + "download_agreement_3": "Ymmärrän että minun YouTube voi estää IP-Osoitteeni ja en pidä Spotubea tai omistajiinsa/avustajia vastuullisena mistään omista teoistsani", + "decline": "Hylkää", + "accept": "Hyväksy", + "details": "Yksityiskohdat", + "youtube": "YouTube", + "channel": "Kanava", + "likes": "Tykkäykset", + "dislikes": "Epä-tykkäykset", + "views": "Näyttökerrat", + "streamUrl": "Suoratoiston URL", + "stop": "Lopeta", + "sort_newest": "Suodata uusimmista", + "sort_oldest": "Suodata vanhimmista", + "sleep_timer": "Uniajastin", + "mins": "{minutes} Minuuttia", + "hours": "{hours} Tuntia", + "hour": "{hours} Tunti", + "custom_hours": "Mukautetut tunnit", + "logs": "Lokit", + "developers": "Kehittäjät", + "not_logged_in": "Et ole kirjautunut sisään.", + "search_mode": "Hakutila", + "audio_source": "Äänilähde", + "ok": "Ok", + "failed_to_encrypt": "Salaaminen epäonnistui", + "encryption_failed_warning": "Spotube käyttää salausta tallentaakseen tietosi, mutta epäonnistui, joten se palaa epäturvalliseen tallennukseen\nJos käytät Linuxia, varmista että sinulla on turvallisuuspalvelu (gnome-keyring, kde-wallet, keepassxc jne) asennettu", + "querying_info": "Hankitaan tietoa...", + "piped_api_down": "Johdettu palvelinesiintymä on alhaalla", + "piped_down_error_instructions": "Johdettu palvelinesiintymä {pipedInstance} on alhaalla.\n\nVaihda joko ilmeytymä tia vahda 'API tyyppi' YouTuben viralliseen API\n\nKäynnistä sovellus uudestaan vaihdon jälkeen", + "you_are_offline": "Et ole yhdistetty verkkoon", + "connection_restored": "Verkkoyhteys palautettu", + "use_system_title_bar": "Käytä järjestelmäpalkkia", + "crunching_results": "Paloitellaan tuloksia...", + "search_to_get_results": "Hae saadakseen tuloksia", + "use_amoled_mode": "Pilkkopimeä tumma teema", + "pitch_dark_theme": "AMOLED Tila", + "normalize_audio": "Normalisoi audio", + "change_cover": "Vaihda koveri", + "add_cover": "Lisää koveri", + "restore_defaults": "Palauta oletukset", + "download_music_codec": "Ladatun musiikin codefc", + "streaming_music_codec": "Suoratoistetun musiikin codec", + "login_with_lastfm": "Kirjaudu sisään Last.fm:llä", + "connect": "Yhdistä", + "disconnect_lastfm": "Katkaise Last.fm", + "disconnect": "Katkaise", + "username": "Käyttäjänimi", + "password": "Salasana", + "login": "Kirjaudu", + "login_with_your_lastfm": "Kirjaudu Last.fm käyttäjälläsi", + "scrobble_to_lastfm": "Scrobble Last.fm:ään", + "go_to_album": "Mene albumiin", + "discord_rich_presence": "Discord Rich Presence", + "browse_all": "Selaa kaikki", + "genres": "Genret", + "explore_genres": "Seikkaile genrejä", + "friends": "Kaverit", + "no_lyrics_available": "Anteeksi, emme löytäneet lyriikoita tälle laululle", + "start_a_radio": "Aloita Radio", + "how_to_start_radio": "Kuinka haluat aloittaa radion?", + "replace_queue_question": "Haluatko korvata nykyisen jonon vai lisätä siihen?", + "endless_playback": "Loputon toisto", + "delete_playlist": "Poista soittolista", + "delete_playlist_confirmation": "Oletko varma että haluat poistaa tämän soittolistan?", + "local_tracks": "Paikalliset kappaleet", + "song_link": "Laulun linkki", + "skip_this_nonsense": "Ohita tämä hölynpöly", + "freedom_of_music": "“Musiikin vapaus”", + "freedom_of_music_palm": "“Musiikin vapaus käsissäsi”", + "get_started": "Aloitetaan", + "youtube_source_description": "Suositeltu ja toimii parhaiten.", + "piped_source_description": "Tuntuuko vapaalta? Sama kuin YouTube mutta paljon vapautta", + "jiosaavn_source_description": "Paras Etelä-Aasian alueelle.", + "highest_quality": "Korkein laatu: {quality}", + "select_audio_source": "Valitse äänilähde", + "endless_playback_description": "Lisää automaattisesti uusia lauluja\njonon perään", + "choose_your_region": "Valitse alueesi", + "choose_your_region_description": "Tämä auttaa Spotube näyttämään sinulle oikeaa sisältöä\nsijaintiasi varten.", + "choose_your_language": "Valitse kielesi", + "help_project_grow": "Auta tätä projektia kasvamaan", + "help_project_grow_description": "Spotube projekti minkä lähdekoodi on julkisesti saatavilla. Voit autta tätä projektia kasvamaan muutoksilla, ilmoittamalla bugeista, tai ehdottamalla uusia ominaisuuksia.", + "contribute_on_github": "Auta GitHub:ssa", + "donate_on_open_collective": "Lahjoita avoimessa kollektiivissa", + "browse_anonymously": "Selaa anonyyminä", + "enable_connect": "Ota käyttöön yhdistäminen", + "enable_connect_description": "Ohjaa Spotubea toiselta laitteelta", + "devices": "Laitteet", + "select": "Valitse", + "connect_client_alert": "{client} ohjaa sinua", + "this_device": "Tämä laite", + "remote": "Etä", + "local_library": "Paikallinen kirjasto", + "add_library_location": "Lisää kirjastoon", + "remove_library_location": "Poista kirjastosta", + "local_tab": "Paikallinen", + "stats": "Tilastot", + "and_n_more": "ja {count} lisää", + "recently_played": "Äskettäin soitetut", + "browse_more": "Selaa lisää", + "no_title": "Ei otsikkoa", + "not_playing": "Ei soi", + "epic_failure": "Epäonnistuminen!", + "added_num_tracks_to_queue": "Lisätty {tracks_length} kappaletta jonoon", + "spotube_has_an_update": "Spotubella on päivitys", + "download_now": "Lataa nyt", + "nightly_version": "Spotube Nightly {nightlyBuildNum} on julkaistu", + "release_version": "Spotube v{version} on julkaistu", + "read_the_latest": "Lue viimeisimmät", + "release_notes": "julkaisumuistiinpanot", + "pick_color_scheme": "Valitse värimaailma", + "save": "Tallenna", + "choose_the_device": "Valitse laite:", + "multiple_device_connected": "Useita laitteita on kytketty.\nValitse laite, jossa haluat toiminnon suorittaa", + "nothing_found": "Ei tuloksia", + "the_box_is_empty": "Laatikko on tyhjä", + "top_artists": "Suosituimmat artistit", + "top_albums": "Suosituimmat albumit", + "this_week": "Tällä viikolla", + "this_month": "Tässä kuussa", + "last_6_months": "Viimeiset 6 kuukautta", + "this_year": "Tänä vuonna", + "last_2_years": "Viimeiset 2 vuotta", + "all_time": "Kaikki ajat", + "powered_by_provider": "Tuottanut {providerName}", + "email": "Sähköposti", + "profile_followers": "Seuraajat", + "birthday": "Syntymäpäivä", + "subscription": "Tilaus", + "not_born": "Ei syntynyt", + "hacker": "Hakkeri", + "profile": "Profiili", + "no_name": "Ei nimeä", + "edit": "Muokkaa", + "user_profile": "Käyttäjäprofiili", + "count_plays": "{count} toistoa", + "streaming_fees_hypothetical": "Suoratoiston maksut (hypoteettinen)", + "minutes_listened": "Kuunneltuja minuutteja", + "streamed_songs": "Suoratoistettuja kappaleita", + "count_streams": "{count} suoratoistoa", + "owned_by_you": "Sinun omistama", + "copied_shareurl_to_clipboard": "{shareUrl} kopioitu leikepöydälle", + "spotify_hipotetical_calculation": "*Tämä on laskettu Spotifyn suoratoiston\nmaksun perusteella, joka on 0,003–0,005 dollaria.\nTämä on hypoteettinen laskelma, joka antaa käyttäjälle käsityksen\nsiitä, kuinka paljon he olisivat maksaneet artisteille,\njollei heidän kappaleensa olisi kuunneltu Spotifyssa.", + "count_mins": "{minutes} min", + "summary_minutes": "minuuttia", + "summary_listened_to_music": "Kuunneltu musiikkia", + "summary_songs": "kappaletta", + "summary_streamed_overall": "Suoratoistettu yhteensä", + "summary_owed_to_artists": "Maksettava artisteille\nTässä kuussa", + "summary_artists": "artisti", + "summary_music_reached_you": "Musiikki saavutti sinut", + "summary_full_albums": "täydet albumit", + "summary_got_your_love": "Sai rakkautesi", + "summary_playlists": "soittolistat", + "summary_were_on_repeat": "Olivat toistossa", + "total_money": "Yhteensä {money}" +} \ No newline at end of file diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index cabcb8e1e..4a41dec98 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -320,5 +320,69 @@ "select": "Sélectionner", "connect_client_alert": "Vous êtes contrôlé par {client}", "this_device": "Cet appareil", - "remote": "À distance" + "remote": "À distance", + "local_library": "Bibliothèque locale", + "add_library_location": "Ajouter à la bibliothèque", + "remove_library_location": "Retirer de la bibliothèque", + "local_tab": "Local", + "stats": "Statistiques", + "and_n_more": "et {count} de plus", + "recently_played": "Récemment joué", + "browse_more": "Parcourir plus", + "no_title": "Sans titre", + "not_playing": "Non joué", + "epic_failure": "Échec épique!", + "added_num_tracks_to_queue": "{tracks_length} morceaux ajoutés à la file d'attente", + "spotube_has_an_update": "Spotube a une mise à jour", + "download_now": "Télécharger maintenant", + "nightly_version": "Spotube Nightly {nightlyBuildNum} a été publié", + "release_version": "Spotube v{version} a été publié", + "read_the_latest": "Lisez les dernières ", + "release_notes": "notes de version", + "pick_color_scheme": "Choisissez le schéma de couleurs", + "save": "Sauvegarder", + "choose_the_device": "Choisissez l'appareil:", + "multiple_device_connected": "Plusieurs appareils sont connectés.\nChoisissez l'appareil sur lequel vous souhaitez effectuer cette action", + "nothing_found": "Rien trouvé", + "the_box_is_empty": "La boîte est vide", + "top_artists": "Meilleurs artistes", + "top_albums": "Meilleurs albums", + "this_week": "Cette semaine", + "this_month": "Ce mois-ci", + "last_6_months": "Les 6 derniers mois", + "this_year": "Cette année", + "last_2_years": "Les 2 dernières années", + "all_time": "De tous les temps", + "powered_by_provider": "Propulsé par {providerName}", + "email": "Email", + "profile_followers": "Abonnés", + "birthday": "Anniversaire", + "subscription": "Abonnement", + "not_born": "Non né", + "hacker": "Hacker", + "profile": "Profil", + "no_name": "Sans nom", + "edit": "Modifier", + "user_profile": "Profil utilisateur", + "count_plays": "{count} lectures", + "streaming_fees_hypothetical": "Frais de streaming (hypothétiques)", + "minutes_listened": "Minutes écoutées", + "streamed_songs": "Morceaux diffusés", + "count_streams": "{count} streams", + "owned_by_you": "Possédé par vous", + "copied_shareurl_to_clipboard": "{shareUrl} copié dans le presse-papier", + "spotify_hipotetical_calculation": "*Cela est calculé en fonction du\npaiement par stream de Spotify de 0,003 $ à 0,005 $.\nIl s'agit d'un calcul hypothétique pour donner\nune idée de combien vous auriez\npayé aux artistes si vous aviez\nécouté leur chanson sur Spotify.", + "count_mins": "{minutes} minutes", + "summary_minutes": "minutes", + "summary_listened_to_music": "A écouté de la musique", + "summary_songs": "morceaux", + "summary_streamed_overall": "Diffusé en général", + "summary_owed_to_artists": "Dû aux artistes\nCe mois-ci", + "summary_artists": "artistes", + "summary_music_reached_you": "La musique vous a atteint", + "summary_full_albums": "albums complets", + "summary_got_your_love": "A obtenu votre amour", + "summary_playlists": "playlists", + "summary_were_on_repeat": "Était en répétition", + "total_money": "Total {money}" } \ No newline at end of file diff --git a/lib/l10n/app_hi.arb b/lib/l10n/app_hi.arb index a72e136ec..a65e3f756 100644 --- a/lib/l10n/app_hi.arb +++ b/lib/l10n/app_hi.arb @@ -320,5 +320,69 @@ "select": "चयन करें", "connect_client_alert": "आप {client} द्वारा नियंत्रित हो रहे हैं", "this_device": "यह उपकरण", - "remote": "रिमोट" + "remote": "रिमोट", + "local_library": "स्थानीय पुस्तकालय", + "add_library_location": "पुस्तकालय में जोड़ें", + "remove_library_location": "पुस्तकालय से हटाएं", + "local_tab": "स्थानीय", + "stats": "आंकड़े", + "and_n_more": "और {count} और", + "recently_played": "हाल ही में खेले गए", + "browse_more": "अधिक ब्राउज़ करें", + "no_title": "कोई शीर्षक नहीं", + "not_playing": "नहीं चल रहा", + "epic_failure": "महान असफलता!", + "added_num_tracks_to_queue": "{tracks_length} ट्रैक्स कतार में जोड़े गए", + "spotube_has_an_update": "Spotube में एक अपडेट है", + "download_now": "अभी डाउनलोड करें", + "nightly_version": "Spotube Nightly {nightlyBuildNum} जारी किया गया है", + "release_version": "Spotube v{version} जारी किया गया है", + "read_the_latest": "नवीनतम पढ़ें", + "release_notes": "रिलीज़ नोट्स", + "pick_color_scheme": "रंग योजना चुनें", + "save": "सहेजें", + "choose_the_device": "उपकरण चुनें:", + "multiple_device_connected": "कई उपकरण जुड़े हुए हैं।\nउस उपकरण को चुनें जिस पर आप यह क्रिया करना चाहते हैं", + "nothing_found": "कुछ भी नहीं मिला", + "the_box_is_empty": "बॉक्स खाली है", + "top_artists": "शीर्ष कलाकार", + "top_albums": "शीर्ष एल्बम", + "this_week": "इस हफ्ते", + "this_month": "इस महीने", + "last_6_months": "पिछले 6 महीने", + "this_year": "इस साल", + "last_2_years": "पिछले 2 साल", + "all_time": "सभी समय", + "powered_by_provider": "{providerName} द्वारा संचालित", + "email": "ईमेल", + "profile_followers": "अनुयायी", + "birthday": "जन्मदिन", + "subscription": "सदस्यता", + "not_born": "अभी पैदा नहीं हुआ", + "hacker": "हैकर", + "profile": "प्रोफ़ाइल", + "no_name": "कोई नाम नहीं", + "edit": "संपादित करें", + "user_profile": "उपयोगकर्ता प्रोफ़ाइल", + "count_plays": "{count} प्ले", + "streaming_fees_hypothetical": "*Spotify की प्रति स्ट्रीम भुगतान के आधार पर\n$0.003 से $0.005 तक गणना की गई है। यह एक काल्पनिक\nगणना है जो उपयोगकर्ता को यह जानकारी देती है कि वे कितना भुगतान\nकरते यदि वे Spotify पर गाने सुनते।", + "count_mins": "{minutes} मिनट", + "summary_minutes": "मिनट", + "summary_listened_to_music": "सुनी गई संगीत", + "summary_songs": "गाने", + "summary_streamed_overall": "कुल स्ट्रीम", + "summary_owed_to_artists": "कलाकारों को देनदार\nइस महीने", + "summary_artists": "कलाकार", + "summary_music_reached_you": "संगीत आपके पास पहुंच गया", + "summary_full_albums": "पूरा एल्बम", + "summary_got_your_love": "आपका प्यार मिला", + "summary_playlists": "प्लेलिस्ट", + "summary_were_on_repeat": "दोहराया गया", + "total_money": "कुल {money}", + "minutes_listened": "सुनिएका मिनेटहरू", + "streamed_songs": "स्ट्रीम गरिएका गीतहरू", + "count_streams": "{count} स्ट्रिम", + "owned_by_you": "तपाईंले स्वामित्व गरेको", + "copied_shareurl_to_clipboard": "{shareUrl} क्लिपबोर्डमा कपी गरियो", + "spotify_hipotetical_calculation": "*यो Spotify को प्रति स्ट्रीम भुगतानको आधारमा\n$0.003 देखि $0.005 को बीचमा गणना गरिएको हो। यो एक काल्पनिक\nगणना हो जसले प्रयोगकर्तालाई देखाउँछ कि उनीहरूले कति\nअर्टिस्टहरूलाई तिनीहरूका गीतहरू Spotify मा सुनेमा\nभुक्तान गर्नुपर्ने थियो।" } \ No newline at end of file diff --git a/lib/l10n/app_id.arb b/lib/l10n/app_id.arb new file mode 100644 index 000000000..0a417c404 --- /dev/null +++ b/lib/l10n/app_id.arb @@ -0,0 +1,388 @@ +{ + "guest": "Tamu", + "browse": "Jelajahi", + "search": "Cari", + "library": "Pustaka", + "lyrics": "Lirik", + "settings": "Pengaturan", + "genre_categories_filter": "Urutkan kategori atau genre...", + "genre": "Genre", + "personalized": "Dipersonalisasi", + "featured": "Unggulan", + "new_releases": "Rilis Terbaru", + "songs": "Lagu", + "playing_track": "Memutar {track}", + "queue_clear_alert": "Ini akan menghapus antrian saat ini This will clear the current queue. {track_length} trek akan dihapus\nAnda ingin melanjutkan?", + "load_more": "Lebih Banyak", + "playlists": "Daftar Putar", + "artists": "Artis", + "albums": "Album", + "tracks": "Trek", + "downloads": "Unduhan", + "filter_playlists": "Urutkan daftar putar Anda...", + "liked_tracks": "Lagu Yang Disukai", + "liked_tracks_description": "Semua lagu yang Anda sukai", + "create_playlist": "Buat Daftar Putar", + "create_a_playlist": "Buat daftar putar", + "update_playlist": "Ubah daftar putar", + "create": "Buat", + "cancel": "Batal", + "update": "Ubah", + "playlist_name": "Nama Daftar Putar", + "name_of_playlist": "Nama daftar putar", + "description": "Deskripsi", + "public": "Publik", + "collaborative": "Kolaboratif", + "search_local_tracks": "Cari trek lokal...", + "play": "Putar", + "delete": "Hapus", + "none": "Tidak Ada", + "sort_a_z": "Urutkan berdasarkan A-Z", + "sort_z_a": "Urutkan berdasarkan Z-A", + "sort_artist": "Urutkan berdasarkan Artis", + "sort_album": "Urutkan berdasarkan Album", + "sort_duration": "Urutkan berdasarkan Durasi", + "sort_tracks": "Urutkan trek", + "currently_downloading": "Sedang Mengunduh ({tracks_length})", + "cancel_all": "Batalkan Semua", + "filter_artist": "Urutkan artis...", + "followers": "{followers} Pengikut", + "add_artist_to_blacklist": "Tambah artis ke daftar hitam", + "top_tracks": "Lagu Teratas", + "fans_also_like": "Penggemar juga menyukainya", + "loading": "Memuat...", + "artist": "Artis", + "blacklisted": "Masuk Daftar Hitam", + "following": "Mengikuti", + "follow": "Ikuti", + "artist_url_copied": "URL artis telah disalin", + "added_to_queue": "Menambah trek {tracks} ke antrean", + "filter_albums": "Urutkan album...", + "synced": "Disinkronkan", + "plain": "Normal", + "shuffle": "Acak", + "search_tracks": "Cari trek...", + "released": "Dirilis", + "error": "Kesalahan {error}", + "title": "Judul", + "time": "Waktu", + "more_actions": "Tindakan Lainnya", + "download_count": "Unduhan ({count})", + "add_count_to_playlist": "Menambah ({count}) ke Daftar Putar", + "add_count_to_queue": "Menambah ({count}) ke Antrian", + "play_count_next": "Mainkan ({count}) selanjutnya", + "album": "Album", + "copied_to_clipboard": "{data} telah disalin", + "add_to_following_playlists": "Menambah {track} ke Daftar Putar berikut", + "add": "Tambah", + "added_track_to_queue": "Menambah {track} ke antrian", + "add_to_queue": "Tambah ke antrian", + "track_will_play_next": "{track} akan diputar berikutnya", + "play_next": "Mainkan selanjutnya", + "removed_track_from_queue": "Menghapus {track} dari antrian", + "remove_from_queue": "Hapus dari antrian", + "remove_from_favorites": "Hapus dari favorit", + "save_as_favorite": "Simpan sebagai favorit", + "add_to_playlist": "Tambah ke daftar putar", + "remove_from_playlist": "Hapus dari daftar putar", + "add_to_blacklist": "Tambah ke daftar hitam", + "remove_from_blacklist": "Hapus dari daftar hitam", + "share": "Bagikan", + "mini_player": "Pemutar Mini", + "slide_to_seek": "Geser untuk maju atau mundur", + "shuffle_playlist": "Acak daftar putar", + "unshuffle_playlist": "Batalkan pengacakan daftar putar", + "previous_track": "Lagu sebelumnya", + "next_track": "Lagu berikutnya", + "pause_playback": "Jeda Pemutaran", + "resume_playback": "Lanjutkan Pemutaran", + "loop_track": "Ulangi Pemutaran", + "repeat_playlist": "Ulangi daftar putar", + "queue": "Antrian", + "alternative_track_sources": "Sumber trek alternatif", + "download_track": "Unduh lagu", + "tracks_in_queue": "{tracks} trek dalam antrian", + "clear_all": "Bersihkan semua", + "show_hide_ui_on_hover": "Tampil/Sembunyikan UI saat mengarahkan kursor", + "always_on_top": "Selalu di atas", + "exit_mini_player": "Keluar Pemutar Mini", + "download_location": "Lokasi unduhan", + "account": "Akun", + "login_with_spotify": "Masuk dengan Spotify", + "connect_with_spotify": "Hubungkan dengan Spotify", + "logout": "Keluar", + "logout_of_this_account": "Keluar dari akun", + "language_region": "Bahasa & Wilayah", + "language": "Bahasa", + "system_default": "Bawaan Sistem", + "market_place_region": "Wilayah Pasar", + "recommendation_country": "Negara Rekomendasi", + "appearance": "Tampilan", + "layout_mode": "Mode Tata Letak", + "override_layout_settings": "Ganti pengaturan mode tata letak responsif", + "adaptive": "Adaptif", + "compact": "Ringkas", + "extended": "Diperluas", + "theme": "Tema", + "dark": "Gelap", + "light": "Terang", + "system": "Sistem", + "accent_color": "Warna Aksen", + "sync_album_color": "Sinkronkan warna album", + "sync_album_color_description": "Menggunakan warna dominan sampul album sebagai warna aksen", + "playback": "Pemutaran", + "audio_quality": "Kualitas Suara", + "high": "Tinggi", + "low": "Rendah", + "pre_download_play": "Unduh dan putar", + "pre_download_play_description": "Daripada streaming audio, unduh byte dan mainkan (Direkomendasikan untuk pengguna bandwidth yang lebih tinggi)", + "skip_non_music": "Lewati segmen non-musik (SponsorBlock)", + "blacklist_description": "Lagu dan artis di daftar hitam", + "wait_for_download_to_finish": "Tunggu hingga unduhan saat ini selesai", + "desktop": "Desktop", + "close_behavior": "Tutup Perilaku", + "close": "Tutup", + "minimize_to_tray": "Perkecil ke tray", + "show_tray_icon": "Tampilkan tray ikon sistem", + "about": "Tentang", + "u_love_spotube": "Kami tahu Anda menyukai Spotube", + "check_for_updates": "Periksa pembaruan", + "about_spotube": "Tentang Spotube", + "blacklist": "Daftar Hitam", + "please_sponsor": "Silakan Sponsor/Menyumbang", + "spotube_description": "Spotube, klien Spotify yang ringan, lintas platform, dan gratis untuk semua", + "version": "Versi", + "build_number": "Nomor Pembuatan", + "founder": "Pendiri", + "repository": "Repositori", + "bug_issues": "Bug+Masalah", + "made_with": "Dibuat dengan ❤️ di Bangladesh🇧🇩", + "kingkor_roy_tirtho": "Kingkor Roy Tirtho", + "copyright": "© 2021-{current_year} Kingkor Roy Tirtho", + "license": "Lisensi", + "add_spotify_credentials": "Tambahkan kredensial Spotify Anda untuk memulai", + "credentials_will_not_be_shared_disclaimer": "Jangan khawatir, kredensial Anda tidak akan dikumpulkan atau dibagikan kepada siapa pun", + "know_how_to_login": "Tidak tahu bagaimana melakukan ini?", + "follow_step_by_step_guide": "Ikuti panduan Langkah demi Langkah", + "spotify_cookie": "Spotify {name} Cookie", + "cookie_name_cookie": "{name} Cookie", + "fill_in_all_fields": "Silakan isi semua kolom", + "submit": "Kirim", + "exit": "Keluar", + "previous": "Sebelumnya", + "next": "Berikutnya", + "done": "Selesai", + "step_1": "Langkah 1", + "first_go_to": "Pertama, Pergi ke", + "login_if_not_logged_in": "dan Masuk/Daftar jika Anda belum masuk", + "step_2": "Langkah 2", + "step_2_steps": "1. Setelah Anda masuk, tekan F12 atau Klik Kanan Mouse > Buka Browser Devtools.\n2. Lalu buka Tab \"Aplikasi\" (Chrome, Edge, Brave, dll.) atau Tab \"Penyimpanan\" (Firefox, Palemoon, dll.)\n3. Buka bagian \"Cookie\" lalu subbagian \"https://accounts.spotify.com\"", + "step_3": "Langkah 3", + "step_3_steps": "Salin nilai Cookie \"sp_dc\" ", + "success_emoji": "Berhasil🥳", + "success_message": "Sekarang Anda telah berhasil Masuk dengan akun Spotify Anda. Kerja bagus, sobat!", + "step_4": "Langkah 4", + "step_4_steps": "Tempel nilai \"sp_dc\" yang disalin", + "something_went_wrong": "Terjadi kesalahan", + "piped_instance": "Piped Server Instance", + "piped_description": "The Piped server instance untuk digunakan sebagai pencocokan trek", + "piped_warning": "Beberapa di antaranya mungkin tidak berfungsi dengan baik. Jadi gunakan dengan risiko Anda sendiri", + "generate_playlist": "Hasilkan Daftar Putar", + "track_exists": "Lagu {track} sudah ada", + "replace_downloaded_tracks": "Ganti semua trek yang diunduh", + "skip_download_tracks": "Lewati pengunduhan semua trek yang diunduh", + "do_you_want_to_replace": "Apakah Anda ingin mengganti track yang ada?", + "replace": "Ganti", + "skip": "Lewati", + "select_up_to_count_type": "Pilih hingga {count} {type}", + "select_genres": "Pilih Genre", + "add_genres": "Tambah Genre", + "country": "Negara", + "number_of_tracks_generate": "Jumlah trek yang akan dihasilkan", + "acousticness": "Akustik", + "danceability": "Menari", + "energy": "Energi", + "instrumentalness": "Instrumentalitas", + "liveness": "Kehidupan", + "loudness": "Kekerasan", + "speechiness": "Berbicara", + "valence": "Valensi", + "popularity": "Popularitas", + "key": "Kunci", + "duration": "Durasi (s)", + "tempo": "Tempo (BPM)", + "mode": "Mode", + "time_signature": "Tanda Tangan Waktu", + "short": "Pendek", + "medium": "Sedang", + "long": "Panjang", + "min": "Minimal", + "max": "Maksimal", + "target": "Target", + "moderate": "Sedang", + "deselect_all": "Batalkan Semua", + "select_all": "Pilih Semua", + "are_you_sure": "Anda yakin?", + "generating_playlist": "Menghasilkan daftar putar khusus Anda...", + "selected_count_tracks": "{count} lagu yang dipilih", + "download_warning": "Jika Anda mengunduh semua Lagu secara massal, Anda jelas membajak Musik & menyebabkan kerusakan pada masyarakat kreatif Musik. Saya harap Anda menyadari hal ini. Selalu berusaha menghormati & mendukung kerja keras Artis", + "download_ip_ban_warning": "BTW, IP Anda bisa diblokir di YouTube karena permintaan unduhan yang berlebihan dari biasanya. Blokir IP berarti Anda tidak dapat menggunakan YouTube (meskipun Anda masuk) setidaknya selama 2-3 bulan dari perangkat IP tersebut. Dan Spotube tidak bertanggung jawab jika hal ini terjadi", + "by_clicking_accept_terms": "Dengan mengklik 'terima' Anda menyetujui ketentuan berikut:", + "download_agreement_1": "Saya tahu saya membajak Musik. Saya buruk", + "download_agreement_2": "Saya akan mendukung Artis di mana pun saya bisa dan saya melakukan ini hanya karena saya tidak punya uang untuk membeli karya seni mereka", + "download_agreement_3": "Saya sepenuhnya menyadari bahwa IP saya dapat diblokir di YouTube & saya tidak menganggap Spotube atau pemilik/kontributornya bertanggung jawab atas kecelakaan apa pun yang disebabkan oleh tindakan saya saat ini", + "decline": "Menolak", + "accept": "Setuju", + "details": "Detail", + "youtube": "YouTube", + "channel": "Channel", + "likes": "Suka", + "dislikes": "Tidak Suka", + "views": "Dilihat", + "streamUrl": "URL Stream", + "stop": "Berhenti", + "sort_newest": "Urutkan yang baru ditambah", + "sort_oldest": "Urutkan yang paling lama ditambah", + "sleep_timer": "Pengatur Waktu Tidur", + "mins": "{minutes} Menit", + "hours": "{hours} Jam", + "hour": "{hours} Jam", + "custom_hours": "Jam Kostum", + "logs": "Log", + "developers": "Pengembang", + "not_logged_in": "Anda belum masuk", + "search_mode": "Mode Pencarian", + "audio_source": "Sumber Suara", + "ok": "OK", + "failed_to_encrypt": "Gagal mengenkripsi", + "encryption_failed_warning": "Spotube menggunakan enkripsi untuk menyimpan data Anda dengan aman. Namun gagal melakukannya. Jadi itu akan kembali ke penyimpanan yang tidak aman\nJika Anda menggunakan linux, pastikan Anda telah menginstal layanan rahasia (gnome-keyring, kde-wallet, keepassxc, dll)", + "querying_info": "Mencari informasi...", + "piped_api_down": "Piped API tidak aktif", + "piped_down_error_instructions": "Piped Instance {pipedInstance} saat ini tidak aktif\n\nUbah instance atau ubah 'jenis API' menjadi API YouTube resmi\n\nPastikan untuk memulai ulang aplikasi setelah perubahan", + "you_are_offline": "Anda sedang offline", + "connection_restored": "Koneksi internet Anda telah pulih", + "use_system_title_bar": "Gunakan bilah judul sistem", + "crunching_results": "Mengolah hasil...", + "search_to_get_results": "Cari untuk mendapatkan hasil", + "use_amoled_mode": "Tema gelap gulita", + "pitch_dark_theme": "Mode AMOLED", + "normalize_audio": "Normalisasi audio", + "change_cover": "Ganti sampul", + "add_cover": "Tambah sampul", + "restore_defaults": "Kembalikan semula", + "download_music_codec": "Unduh codec musik", + "streaming_music_codec": "Streaming codec musik", + "login_with_lastfm": "Masuk dengan Last.fm", + "connect": "Hubungkan", + "disconnect_lastfm": "Memutuskan Last.fm", + "disconnect": "Memutuskan", + "username": "Username", + "password": "Password", + "login": "Masuk", + "login_with_your_lastfm": "Masuk dengan Last.fm Anda", + "scrobble_to_lastfm": "Scrobble ke Last.fm", + "go_to_album": "Pergi ke Album", + "discord_rich_presence": "Discord Rich Presence", + "browse_all": "Lihat Semua", + "genres": "Genre", + "explore_genres": "Jelajahi Genre", + "friends": "Daftar Teman", + "no_lyrics_available": "Maaf, tidak dapat menemukan lirik untuk lagu ini", + "start_a_radio": "Putar Radio", + "how_to_start_radio": "Bagaimana Anda ingin memutar radio?", + "replace_queue_question": "Apakah Anda ingin mengganti antrean saat ini atau menambahkannya?", + "endless_playback": "Pemutaran Tanpa Akhir", + "delete_playlist": "Hapus Daftar Putar", + "delete_playlist_confirmation": "Anda yakin ingin menghapus daftar putar ini?", + "local_tracks": "Trek Lokal", + "song_link": "Tautan Lagu", + "skip_this_nonsense": "Lewati omong kosong ini", + "freedom_of_music": "“Kebebasan Musik”", + "freedom_of_music_palm": "“Kebebasan Musik di telapak tangan Anda”", + "get_started": "Mari kita mulai", + "youtube_source_description": "Direkomendasikan dan berfungsi paling baik.", + "piped_source_description": "Merasa bebas? Sama seperti YouTube tetapi banyak yang gratis.", + "jiosaavn_source_description": "Terbaik untuk wilayah Asia Selatan.", + "highest_quality": "Kualitas Terbaik: {quality}", + "select_audio_source": "Pilih Sumber Suara", + "endless_playback_description": "Tambahkan lagu baru secara otomatis\nke akhir antrean", + "choose_your_region": "Pilih wilayah Anda", + "choose_your_region_description": "Ini akan membantu Spotube menampilkan konten yang tepat\nuntuk lokasi Anda.", + "choose_your_language": "Pilih bahasa Anda", + "help_project_grow": "Bantu proyek ini berkembang", + "help_project_grow_description": "Spotube adalah proyek sumber terbuka. Anda dapat membantu proyek ini berkembang dengan berkontribusi pada proyek, melaporkan bug, atau menyarankan fitur baru.", + "contribute_on_github": "Berkontribusi di GitHub", + "donate_on_open_collective": "Donasi di Open Collective", + "browse_anonymously": "Jelajahi Secara Anonim", + "enable_connect": "Aktifkan Hubungkan", + "enable_connect_description": "Kontrol Spotube dari perangkat lain", + "devices": "Perangkat", + "select": "Pilih", + "connect_client_alert": "Anda dikendalikan oleh {client}", + "this_device": "Perangkat Ini", + "remote": "Remot", + "local_library": "Perpustakaan lokal", + "add_library_location": "Tambahkan ke perpustakaan", + "remove_library_location": "Hapus dari perpustakaan", + "local_tab": "Lokal", + "stats": "Statistik", + "and_n_more": "dan {count} lainnya", + "recently_played": "Baru saja diputar", + "browse_more": "Telusuri lebih banyak", + "no_title": "Tanpa judul", + "not_playing": "Tidak diputar", + "epic_failure": "Kegagalan epik!", + "added_num_tracks_to_queue": "Menambahkan {tracks_length} trek ke antrean", + "spotube_has_an_update": "Spotube memiliki pembaruan", + "download_now": "Unduh sekarang", + "nightly_version": "Spotube Nightly {nightlyBuildNum} telah dirilis", + "release_version": "Spotube v{version} telah dirilis", + "read_the_latest": "Baca yang terbaru ", + "release_notes": "catatan rilis", + "pick_color_scheme": "Pilih skema warna", + "save": "Simpan", + "choose_the_device": "Pilih perangkat:", + "multiple_device_connected": "Beberapa perangkat terhubung.\nPilih perangkat tempat Anda ingin melakukan tindakan ini", + "nothing_found": "Tidak ditemukan apa pun", + "the_box_is_empty": "Kotak kosong", + "top_artists": "Artis Teratas", + "top_albums": "Album Teratas", + "this_week": "Minggu ini", + "this_month": "Bulan ini", + "last_6_months": "6 bulan terakhir", + "this_year": "Tahun ini", + "last_2_years": "2 tahun terakhir", + "all_time": "Sepanjang waktu", + "powered_by_provider": "Didukung oleh {providerName}", + "email": "Email", + "profile_followers": "Pengikut", + "birthday": "Ulang Tahun", + "subscription": "Langganan", + "not_born": "Belum lahir", + "hacker": "Hacker", + "profile": "Profil", + "no_name": "Tanpa nama", + "edit": "Edit", + "user_profile": "Profil pengguna", + "count_plays": "{count} pemutaran", + "streaming_fees_hypothetical": "Biaya streaming (hipotetis)", + "minutes_listened": "Menit didengarkan", + "streamed_songs": "Lagu yang disiarkan", + "count_streams": "{count} streams", + "owned_by_you": "Dimiliki oleh Anda", + "copied_shareurl_to_clipboard": "{shareUrl} disalin ke clipboard", + "spotify_hipotetical_calculation": "*Ini dihitung berdasarkan pembayaran\nper stream Spotify dari $0,003 hingga $0,005.\nIni adalah perhitungan hipotetis untuk memberi\npengguna gambaran tentang berapa banyak\nmereka akan membayar kepada artis jika\nmereka mendengarkan lagu mereka di Spotify.", + "count_mins": "{minutes} menit", + "summary_minutes": "menit", + "summary_listened_to_music": "Mendengarkan musik", + "summary_songs": "lagu", + "summary_streamed_overall": "Disiarkan secara keseluruhan", + "summary_owed_to_artists": "Terhutang kepada artis\nBulan ini", + "summary_artists": "artis", + "summary_music_reached_you": "Musik mencapai Anda", + "summary_full_albums": "album lengkap", + "summary_got_your_love": "Mendapatkan cinta Anda", + "summary_playlists": "daftar putar", + "summary_were_on_repeat": "Sedang diulang", + "total_money": "Total {money}" +} \ No newline at end of file diff --git a/lib/l10n/app_it.arb b/lib/l10n/app_it.arb index bb1881d6c..6cbcbb6a5 100644 --- a/lib/l10n/app_it.arb +++ b/lib/l10n/app_it.arb @@ -321,5 +321,69 @@ "select": "Seleziona", "connect_client_alert": "Stai venendo controllato da {client}", "this_device": "Questo dispositivo", - "remote": "Remoto" + "remote": "Remoto", + "local_library": "Biblioteca locale", + "add_library_location": "Aggiungi alla biblioteca", + "remove_library_location": "Rimuovi dalla biblioteca", + "local_tab": "Locale", + "stats": "Statistiche", + "and_n_more": "e {count} in più", + "recently_played": "Riprodotti di recente", + "browse_more": "Esplora di più", + "no_title": "Nessun titolo", + "not_playing": "Non in riproduzione", + "epic_failure": "Fallimento epico!", + "added_num_tracks_to_queue": "Aggiunti {tracks_length} brani alla coda", + "spotube_has_an_update": "Spotube ha un aggiornamento", + "download_now": "Scarica ora", + "nightly_version": "Spotube Nightly {nightlyBuildNum} è stato rilasciato", + "release_version": "Spotube v{version} è stato rilasciato", + "read_the_latest": "Leggi l'ultimo ", + "release_notes": "note di rilascio", + "pick_color_scheme": "Scegli uno schema di colori", + "save": "Salva", + "choose_the_device": "Scegli il dispositivo:", + "multiple_device_connected": "Sono collegati più dispositivi.\nScegli il dispositivo su cui vuoi che venga eseguita questa azione", + "nothing_found": "Nessun risultato", + "the_box_is_empty": "La scatola è vuota", + "top_artists": "Artisti Top", + "top_albums": "Album Top", + "this_week": "Questa settimana", + "this_month": "Questo mese", + "last_6_months": "Ultimi 6 mesi", + "this_year": "Quest'anno", + "last_2_years": "Ultimi 2 anni", + "all_time": "Di tutti i tempi", + "powered_by_provider": "Sostenuto da {providerName}", + "email": "Email", + "profile_followers": "Follower", + "birthday": "Compleanno", + "subscription": "Abbonamento", + "not_born": "Non nato", + "hacker": "Hacker", + "profile": "Profilo", + "no_name": "Nessun nome", + "edit": "Modifica", + "user_profile": "Profilo utente", + "count_plays": "{count} riproduzioni", + "streaming_fees_hypothetical": "Spese di streaming (ipotetico)", + "minutes_listened": "Minuti ascoltati", + "streamed_songs": "Brani in streaming", + "count_streams": "{count} streaming", + "owned_by_you": "Di tua proprietà", + "copied_shareurl_to_clipboard": "Copiato {shareUrl} negli appunti", + "spotify_hipotetical_calculation": "*Questo è calcolato in base al pagamento per streaming di Spotify\nche va da $0.003 a $0.005. Questo è un calcolo ipotetico\nper dare all'utente un'idea di quanto avrebbe pagato agli artisti se avesse ascoltato\ne loro canzoni su Spotify.", + "count_mins": "{minutes} min", + "summary_minutes": "minuti", + "summary_listened_to_music": "Musica ascoltata", + "summary_songs": "brani", + "summary_streamed_overall": "Streaming complessivo", + "summary_owed_to_artists": "Dovuto agli artisti\nquesto mese", + "summary_artists": "dell'artista", + "summary_music_reached_you": "La musica ti ha raggiunto", + "summary_full_albums": "album completi", + "summary_got_your_love": "Ha ricevuto il tuo amore", + "summary_playlists": "playlist", + "summary_were_on_repeat": "Erano in ripetizione", + "total_money": "Totale {money}" } \ No newline at end of file diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index ab759404d..a26c8ba0d 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -320,5 +320,69 @@ "select": "選択する", "connect_client_alert": "{client} によって操作されています", "this_device": "このデバイス", - "remote": "リモート" + "remote": "リモート", + "local_library": "ローカルライブラリ", + "add_library_location": "ライブラリに追加", + "remove_library_location": "ライブラリから削除", + "local_tab": "ローカル", + "stats": "統計", + "and_n_more": "そして {count} つのアイテム", + "recently_played": "最近再生された", + "browse_more": "もっと見る", + "no_title": "タイトルなし", + "not_playing": "再生中ではありません", + "epic_failure": "壮大な失敗!", + "added_num_tracks_to_queue": "{tracks_length} 曲をキューに追加しました", + "spotube_has_an_update": "Spotube にアップデートがあります", + "download_now": "今すぐダウンロード", + "nightly_version": "Spotube Nightly {nightlyBuildNum} がリリースされました", + "release_version": "Spotube v{version} がリリースされました", + "read_the_latest": "最新の ", + "release_notes": "リリースノート", + "pick_color_scheme": "カラースキームを選択", + "save": "保存", + "choose_the_device": "デバイスを選択:", + "multiple_device_connected": "複数のデバイスが接続されています。\nこのアクションを実行するデバイスを選択してください", + "nothing_found": "何も見つかりませんでした", + "the_box_is_empty": "ボックスは空です", + "top_artists": "トップアーティスト", + "top_albums": "トップアルバム", + "this_week": "今週", + "this_month": "今月", + "last_6_months": "過去6か月", + "this_year": "今年", + "last_2_years": "過去2年間", + "all_time": "全期間", + "powered_by_provider": "{providerName} 提供", + "email": "メール", + "profile_followers": "フォロワー", + "birthday": "誕生日", + "subscription": "サブスクリプション", + "not_born": "未出生", + "hacker": "ハッカー", + "profile": "プロフィール", + "no_name": "名前なし", + "edit": "編集", + "user_profile": "ユーザープロフィール", + "count_plays": "{count} 回再生", + "streaming_fees_hypothetical": "*これは Spotify のストリームあたりの支払い\nが $0.003 から $0.005 であると仮定して計算されています。\nこれは、Spotify でその曲を聴いた場合にアーティストにいくら支払ったかの\n洞察を得るための仮定の計算です。", + "count_mins": "{minutes} 分", + "summary_minutes": "分", + "summary_listened_to_music": "音楽を聴いた", + "summary_songs": "曲", + "summary_streamed_overall": "全体のストリーミング", + "summary_owed_to_artists": "今月アーティストに支払うべき額", + "summary_artists": "アーティストの", + "summary_music_reached_you": "音楽があなたに届いた", + "summary_full_albums": "フルアルバム", + "summary_got_your_love": "あなたの愛を受け取った", + "summary_playlists": "プレイリスト", + "summary_were_on_repeat": "リピートしていた", + "total_money": "合計 {money}", + "minutes_listened": "リスニング時間", + "streamed_songs": "ストリーミングされた曲", + "count_streams": "{count} 回のストリーム", + "owned_by_you": "あなたが所有", + "copied_shareurl_to_clipboard": "{shareUrl} をクリップボードにコピーしました", + "spotify_hipotetical_calculation": "*これは、Spotifyのストリームごとの支払い\nが $0.003 から $0.005 の範囲で計算されています。これは仮想的な\n計算で、Spotify で曲を聴いた場合に、アーティストに\nどれくらい支払ったかをユーザーに示すためのものです。" } \ No newline at end of file diff --git a/lib/l10n/app_ka.arb b/lib/l10n/app_ka.arb new file mode 100644 index 000000000..66d7f8886 --- /dev/null +++ b/lib/l10n/app_ka.arb @@ -0,0 +1,388 @@ +{ + "guest": "სტუმარი", + "browse": "ნახვა", + "search": "ძებნა", + "library": "ბიბლიოთეკა", + "lyrics": "ტექსტები", + "settings": "კონფიგურაციები", + "genre_categories_filter": "კატეგორიების ან ჟანრების ფილტრი...", + "genre": "ჟანრი", + "personalized": "პეერსონალიზებული", + "featured": "გამორჩეული", + "new_releases": "ახალი გამოცემები", + "songs": "სიმღერები", + "playing_track": "უკრავს {track}", + "queue_clear_alert": "ეს გაასუფთავებს მიმდინარე რიგს. {track_length} ტრეკი წაიშლება\nᲒინდა გააგრძელო?", + "load_more": "მეტის ჩატვირთვა", + "playlists": "ფლეილისტები", + "artists": "არტისტები", + "albums": "ალბომები", + "tracks": "ტრეკები", + "downloads": "ჩამოტვირთვები", + "filter_playlists": "ფლეილისტების გაფილტვრა...", + "liked_tracks": "მოწონებული ტრეკები", + "liked_tracks_description": "ყველა შენი მოწონებული ტრეკი", + "create_playlist": "ფლეილისტის შექმნა", + "create_a_playlist": "ფლეილისტის შექმნა", + "update_playlist": "ფლეილისტის განახლება", + "create": "შექმნა", + "cancel": "გაუქმება", + "update": "განახლება", + "playlist_name": "ფლეილისტის სახელი", + "name_of_playlist": "ფლეილისტის სახელი", + "description": "აღწერა", + "public": "საჯარო", + "collaborative": "კოლაბორაციული", + "search_local_tracks": "ლოცალური ტრეკების ძებნა...", + "play": "დაკვრა", + "delete": "წაშლა", + "none": "არცერთი", + "sort_a_z": "დალაგება A-Z-ს მიხედვით", + "sort_z_a": "დალაგება Z-A-ს მიხედვით", + "sort_artist": "დალაგება არტისტის მიხედვით", + "sort_album": "დალაგება ალბომის მიხედვით", + "sort_duration": "დალაგება ხანგრძლივობის მიხედვით", + "sort_tracks": "ტრეკების დალაგება", + "currently_downloading": "მიმდინარეობს ჩამოტვირთვა ({tracks_length})", + "cancel_all": "ყველას გაუქმება", + "filter_artist": "არტისტების ფილტრი...", + "followers": "{followers} ფოლოვერები", + "add_artist_to_blacklist": "არტისტის შავ სიაში დამატება", + "top_tracks": "ტოპ ტრეკები", + "fans_also_like": "ფანებს ასევე მოსწონთ", + "loading": "იტვირთება...", + "artist": "არტისტი", + "blacklisted": "შავ სიაში მყოფი", + "following": "ფოლოვინგი", + "follow": "დაფოლოვება", + "artist_url_copied": "არტისტის ლინკი დაკოპირებულია", + "added_to_queue": "{tracks} ტრეკი დაემატა რიგში", + "filter_albums": "ალბომების გაფილტვრა...", + "synced": "სინქრონიზებული", + "plain": "Plain", + "shuffle": "რიგის არევა", + "search_tracks": "ტრეკების ძებნა...", + "released": "გამოშვებული", + "error": "შეცდომა {error}", + "title": "სათაური", + "time": "დრო", + "more_actions": "მეტი მოქმედებები", + "download_count": "გადმოწერა ({count})", + "add_count_to_playlist": "ფლეილისტში ({count})-ის დამატება", + "add_count_to_queue": "რიგში ({count})-ის დამატება", + "play_count_next": "შემდეგი ({count})-ის დაკვრა", + "album": "ალბომი", + "copied_to_clipboard": "{data} დაკოპირებულია", + "add_to_following_playlists": "დაამატე {track} ამ ფლეილისტებში", + "add": "დამატება", + "added_track_to_queue": "რიგში დაემატა {track}", + "add_to_queue": "რიგში დამატება", + "track_will_play_next": "{track} დაუკრავს შემდეგს", + "play_next": "შემდეგის დაკვრა", + "removed_track_from_queue": "რიგიდან წაიშალა {track}", + "remove_from_queue": "რიგიდან წაშლა", + "remove_from_favorites": "ფავორიტებიდან წაშლა", + "save_as_favorite": "ფავორიტებში დამატება", + "add_to_playlist": "ფლეილისტში დამატება", + "remove_from_playlist": "ფლეილისტიდან წაშლა", + "add_to_blacklist": "შავ სიაში დამატება", + "remove_from_blacklist": "შავი სიიდან წაშლა", + "share": "გაზიარება", + "mini_player": "მინი დამკვრელი", + "slide_to_seek": "გადახვევისთვის გაასრიალეთ წინ ან უკან", + "shuffle_playlist": "ფლეილისტის არევა", + "unshuffle_playlist": "ფლეილისტის დალაგება", + "previous_track": "წინა ტრეკი", + "next_track": "შემდეგი ტრეკი", + "pause_playback": "დაკვრის გაჩერება", + "resume_playback": "დაკვრის გაგრძელება", + "loop_track": "ტრეკის ლუპზე დაკვრა", + "repeat_playlist": "ფლეილისტის გამეორება", + "queue": "რიგი", + "alternative_track_sources": "ალტერნატიული ტრეკების წყაროები", + "download_track": "გადმოწერე ტრეკი", + "tracks_in_queue": "{tracks} ტრეკი რიგში", + "clear_all": "ყველას წაშლა", + "show_hide_ui_on_hover": "UI-ის ჩვენება/დამალვა ჰოვერზე", + "always_on_top": "ტოველთვის ზემოდან", + "exit_mini_player": "მინი დამკვრელიდან გამოსვლა", + "download_location": "ჩამოტვირთვის მდებარეობა", + "account": "ანგარიში", + "login_with_spotify": "შედით თქვენი Spotify ანგარიშით", + "connect_with_spotify": "დაუკავშირდით Spotify-ს", + "logout": "გასვლა", + "logout_of_this_account": "ანგარიშიდან გასვლა", + "language_region": "ენა და რეგიონი", + "language": "ენა", + "system_default": "სისტემის ნაგულისხმევი", + "market_place_region": "მარკეტფლეისის რეგიონი", + "recommendation_country": "რეკომენდირებული ქვეყანა", + "appearance": "გარეგნობა", + "layout_mode": "განლაგების რეჟიმი", + "override_layout_settings": "რესფონსივ განლაგების რეჟიმის კონფიგურაციაზე გადაწერა", + "adaptive": "ადაპტირებული", + "compact": "კომპაქტური", + "extended": "გაფართოებული", + "theme": "თემა", + "dark": "ბნელი", + "light": "ღია", + "system": "სისტემის", + "accent_color": "აქცენტის ფერი", + "sync_album_color": "ალბომის ფერის სინქრონიზაცია", + "sync_album_color_description": "დომინანტური ალბომის ფერის აქცენტის ფერად გამოყენება", + "playback": "დაკვრა", + "audio_quality": "აუდიოს ხარისხი", + "high": "მაღალი", + "low": "დაბალი", + "pre_download_play": "წინასწარ ჩამოტვირთვა და დაკვრა", + "pre_download_play_description": "აუდიოს სტრიმინგის ნაცვლად, ბაიტების ჩამოტვირთვა და დაკვრა (რეკომენდებულია უფრო მაღალი გამტარუნარიანობის მომხმარებლებისთვის)", + "skip_non_music": "არა მუსიკალური ნაწილის გამოტოვება (სპონსორის ბლოკი)", + "blacklist_description": "შავ სიაში მყოფი არტისტები და ტრეკები", + "wait_for_download_to_finish": "გთხოვთ, დაელოდოთ მიმდინარე ჩამოტვირთვის დასრულებას", + "desktop": "დესკტოპი", + "close_behavior": "დახურვის ქცევა", + "close": "დახურვა", + "minimize_to_tray": "მინიმიზაცია", + "show_tray_icon": "სისტემის აიკონის ჩვენება", + "about": "ჩვენს შესახებ", + "u_love_spotube": "We know you love Spotube", + "check_for_updates": "განახლებების შემოწმება", + "about_spotube": "Spotube-ს შესახებ", + "blacklist": "შავი სია", + "please_sponsor": "გთხოვთ დაგვასპონსოროთ", + "spotube_description": "Spotube, a lightweight, cross-platform, free-for-all spotify client", + "version": "ვერსია", + "build_number": "Build Number", + "founder": "დამფუძნებელი", + "repository": "რეპოზიტორია", + "bug_issues": "Bug+Issues", + "made_with": "Made with ❤️ in Bangladesh🇧🇩", + "kingkor_roy_tirtho": "Kingkor Roy Tirtho", + "copyright": "© 2021-{current_year} Kingkor Roy Tirtho", + "license": "ლიცენზია", + "add_spotify_credentials": "დასაწყებად დაამატეთ თქვენი Spotify მონაცემები", + "credentials_will_not_be_shared_disclaimer": "არ ინერვიულოთ, თქვენი მონაცემები არ იქნება შეგროვებული ან გაზიარებული ვინმესთან", + "know_how_to_login": "არ იცით როგორ გააკეთოთ ეს?", + "follow_step_by_step_guide": "მიჰყევით ნაბიჯ-ნაბიჯ სახელმძღვანელოს", + "spotify_cookie": "Spotify {name} ქუქი", + "cookie_name_cookie": "{name} ქუქი", + "fill_in_all_fields": "გთხოვთ შეავსოთ ყველა ველი", + "submit": "გაგზავნა", + "exit": "გამოსვლა", + "previous": "წინა", + "next": "შემდეგი", + "done": "მზადაა", + "step_1": "ნაბიჯი 1", + "first_go_to": "პირველი, გადადით", + "login_if_not_logged_in": "და შესვლა/რეგისტრაცია, თუ არ ხართ შესული", + "step_2": "ნაბიჯი 2", + "step_2_steps": "1. როცა შეხვალთ, დააჭირეთ F12-ს ან მაუსის მარჯვენა ღილაკს > Inspect to Open the Browser devtools.\n2. შემდეგ გახსენით \"Application\" განყოფილება (Chrome, Edge, Brave etc..) ან \"Storage\" განყოფილება (Firefox, Palemoon etc..)\n3. შედით \"Cookies\" სექციაში და შემდეგ \"https://accounts.spotify.com\" სუბსექციაში", + "step_3": "ნაბიჯი 3", + "step_3_steps": "დააკოპირეთ \"sp_dc\" ქუქი-ფაილის მნიშვნელობა", + "success_emoji": "წარმატება🥳", + "success_message": "თქვენ წარმატებით შეხვედით თქვენი Spotify ანგარიშით.", + "step_4": "ნაბიჯი 4", + "step_4_steps": "ჩასვით კოპირებული \"sp_dc\" მნიშვნელობა", + "something_went_wrong": "Რაღაც არასწორად წავიდა", + "piped_instance": "Piped Server Instance", + "piped_description": "The Piped server instance to use for track matching", + "piped_warning": "ზოგიერთი მათგანმა შეიძლება კარგად არ იმუშაოს. ", + "generate_playlist": "ფლეილისტის დაგენერირება", + "track_exists": "ტრეკი {track} უკვე არსებობს", + "replace_downloaded_tracks": "ყველა ჩამოტვირთული ტრეკის შეცვლა", + "skip_download_tracks": "ყველა ჩამოტვირთული ტრეკის გამოტოვება", + "do_you_want_to_replace": "გსურთ შეცვალოთ არსებული ტრეკი??", + "replace": "შეცვლა", + "skip": "გამოტოვება", + "select_up_to_count_type": "აირჩიე {count}-მდე {type}", + "select_genres": "ჟანრების არჩევა", + "add_genres": "ჟანრების დამატება", + "country": "ქვეყანა", + "number_of_tracks_generate": "დასაგენერირებელი ტრეკების რაოდენობა", + "acousticness": "Acousticness", + "danceability": "Danceability", + "energy": "Energy", + "instrumentalness": "Instrumentalness", + "liveness": "Liveness", + "loudness": "Loudness", + "speechiness": "Speechiness", + "valence": "Valence", + "popularity": "Popularity", + "key": "Key", + "duration": "Duration (s)", + "tempo": "Tempo (BPM)", + "mode": "Mode", + "time_signature": "Time Signature", + "short": "Short", + "medium": "საშუალო", + "long": "გრძელი", + "min": "მინიმალური", + "max": "მაქსიმალური", + "target": "სამიზნე", + "moderate": "საშუალო", + "deselect_all": "ყველა მონიშვნის გაუქმება", + "select_all": "ყველას მონიშვნა", + "are_you_sure": "Დარწმუნებული ხართ?", + "generating_playlist": "მიმდინარეობს თქვენი მორგებული ფლეილისტის გენერირება...", + "selected_count_tracks": "არჩეულია {count} ტრეკი", + "download_warning": "If you download all Tracks at bulk you're clearly pirating Music & causing damage to the creative society of Music. I hope you are aware of this. Always, try respecting & supporting Artist's hard work", + "download_ip_ban_warning": "BTW, your IP can get blocked on YouTube due excessive download requests than usual. IP block means you can't use YouTube (even if you're logged in) for at least 2-3 months from that IP device. And Spotube doesn't hold any responsibility if this ever happens", + "by_clicking_accept_terms": "By clicking 'accept' you agree to following terms:", + "download_agreement_1": "I know I'm pirating Music. I'm bad", + "download_agreement_2": "I'll support the Artist wherever I can and I'm only doing this because I don't have money to buy their art", + "download_agreement_3": "I'm completely aware that my IP can get blocked on YouTube & I don't hold Spotube or his owners/contributors responsible for any accidents caused by my current action", + "decline": "უარყოფა", + "accept": "დათანხმება", + "details": "დეტალები", + "youtube": "YouTube", + "channel": "Channel", + "likes": "მოწონებები", + "dislikes": "არ მოწონებები", + "views": "ნახვები", + "streamUrl": "სტრიმის ლინკი", + "stop": "გაჩერება", + "sort_newest": "ფალაგება სიახლის მიხედიტ", + "sort_oldest": "დალაგება სიძველის მიხედვით", + "sleep_timer": "ძილის ტაიმერი", + "mins": "{minutes} წუთი", + "hours": "{hours} საათი", + "hour": "{hours} საათი", + "custom_hours": "მორგებული საათები", + "logs": "ლოგები", + "developers": "დეველოპერები", + "not_logged_in": "არ ხარ დალოგინებული", + "search_mode": "ძებნის რეჟიმი", + "audio_source": "აუდიოს წყარო", + "ok": "ოკ", + "failed_to_encrypt": "დაშიფვრა ვერ მოხერხდა", + "encryption_failed_warning": "Spotube uses encryption to securely store your data. But failed to do so. So it'll fallback to insecure storage\nIf you're using linux, please make sure you've any secret-service (gnome-keyring, kde-wallet, keepassxc etc) installed", + "querying_info": "Querying info...", + "piped_api_down": "Piped API is down", + "piped_down_error_instructions": "The Piped instance {pipedInstance} is currently down\n\nEither change the instance or change the 'API type' to official YouTube API\n\nMake sure to restart the app after change", + "you_are_offline": "ამჟამად ხაზგარეშე ხართ", + "connection_restored": "თქვენი ინტერნეტ კავშირი აღდგა", + "use_system_title_bar": "სისტემის სათაურის ზოლის გამოყენება", + "crunching_results": "იტვირთება შედეგები...", + "search_to_get_results": "მოძებნეთ შედეგების მისაღებად", + "use_amoled_mode": "Pitch black dark theme", + "pitch_dark_theme": "AMOLED Mode", + "normalize_audio": "აუდიოს ნორმალიზება", + "change_cover": "Ქავერის შეცვლა", + "add_cover": "Ქავერის ფოტოს დამატება", + "restore_defaults": "ნაგულისხმევი პარამეტრების აღდგენა", + "download_music_codec": "მუსიკის კოდეკის გადმოწერა", + "streaming_music_codec": "სტრიმინგ მუსიკის კოდეკი", + "login_with_lastfm": "Last.fm-ით შესვლა", + "connect": "დაკავშირება", + "disconnect_lastfm": "Last.fm-იდან გამოსვლა", + "disconnect": "გამოსვლა", + "username": "მომხმარებელი", + "password": "პაროლი", + "login": "შესვლა", + "login_with_your_lastfm": "Last.fm ანგარიშით შესვლა", + "scrobble_to_lastfm": "Scrobble to Last.fm", + "go_to_album": "ალბომზე გადასვლა", + "discord_rich_presence": "Discord Rich Presence", + "browse_all": "ყველას ნახვა", + "genres": "ჟანრები", + "explore_genres": "შეისწავლეთ ჟანრები", + "friends": "მეგობრები", + "no_lyrics_available": "უკაცრავად, ამ ტრეკისთვის ტექსტის პოვნა შეუძლებელია", + "start_a_radio": "რადიოს ჩართვა", + "how_to_start_radio": "როგორ გნებავთ რადიოს ჩართვა?", + "replace_queue_question": "გნებავთ ჩაანაცვლოთ არსებული რიგი თუ დაამატოთ მასზე?", + "endless_playback": "დაუსრულებელი დაკვრა", + "delete_playlist": "ფლეილისტის წაშლა", + "delete_playlist_confirmation": "დარწმუნებული ხართ რომ გნებავთ ფლეილისტის წაშლა?", + "local_tracks": "ლოკალური ტრეკები", + "song_link": "ტრეკის ლინკი", + "skip_this_nonsense": "ამ სისულელის გამოტოვება", + "freedom_of_music": "“მუსიკის თავისუფლება”", + "freedom_of_music_palm": "“მუსიკის თავისუფლება შენს ხელის გულზე”", + "get_started": "დავიწყოთ", + "youtube_source_description": "რეკომენდებულია და მუშაობს საუკეთესოდ.", + "piped_source_description": "თავისუფლად გრძნობთ თავს? იგივეა, რაც YouTube, მაგრამ ბევრი თავისუფალი.", + "jiosaavn_source_description": "საუკეთესოა სამხრეთ აზიის რეგიონისთვის.", + "highest_quality": "საუკეთესო ხარისხი: {quality}", + "select_audio_source": "აუდიოს წყაროს არჩევა", + "endless_playback_description": "ახალი სიმთერების ავტომატურად რიგის ბოლოში დამატება", + "choose_your_region": "აირჩიე შენი რეგიონი", + "choose_your_region_description": "This will help Spotube show you the right content\nfor your location.", + "choose_your_language": "აირჩიე ენა", + "help_project_grow": "დაეხმარეთ ამ პროექტს განვითარებაში", + "help_project_grow_description": "Spotube is an open-source project. You can help this project grow by contributing to the project, reporting bugs, or suggesting new features.", + "contribute_on_github": "GitHub-ზე კონტრიბუცია", + "donate_on_open_collective": "Open Collective-ზე დონაცია", + "browse_anonymously": "ანონიმურად ნახვა", + "enable_connect": "დაკავშირების ჩართვა", + "enable_connect_description": "აკონტროლე Spotube სხვა მოწყობილობებიდან", + "devices": "მოწყობილობები", + "select": "არჩევა", + "connect_client_alert": "თქვენ კონტროლირებული ხართ {client} მოწყობილობით", + "this_device": "ეს მოწყობილობა", + "remote": "დისტანციური", + "local_library": "ადგილობრივი ბიბლიოთეკა", + "add_library_location": "ბიბლიოთეკაში დამატება", + "remove_library_location": "ბიბლიოთეკიდან წაშლა", + "local_tab": "ადგილობრივი", + "stats": "სტატისტიკა", + "and_n_more": "და {count} მეტი", + "recently_played": "მიუწვდელი", + "browse_more": "დაიცალეთ მეტი", + "no_title": "არ აქვს სათაური", + "not_playing": "არ ერთვის", + "epic_failure": "ეპიკური მარცხი!", + "added_num_tracks_to_queue": "დამატებული {tracks_length} ტრეკი რიგში", + "spotube_has_an_update": "Spotube-ს აქვს განახლება", + "download_now": "ჩამოტვირთეთ ახლავე", + "nightly_version": "Spotube Nightly {nightlyBuildNum} გამოშვებულია", + "release_version": "Spotube v{version} გამოშვებულია", + "read_the_latest": "წაიკითხეთ უახლესი ", + "release_notes": "გამოშვების შენიშვნები", + "pick_color_scheme": "აირჩიეთ ფერის სქემა", + "save": "შეინახეთ", + "choose_the_device": "აირჩიეთ მოწყობილობა:", + "multiple_device_connected": "დაკავშირებულია რამდენიმე მოწყობილობა.\nაირჩიეთ მოწყობილობა, რომელზეც უნდა განხორციელდეს ეს მოქმედება", + "nothing_found": "არაფერი მოიძებნა", + "the_box_is_empty": "კვადრატია ცარიელი", + "top_artists": "ტოპ არტისტები", + "top_albums": "ტოპ ალბომები", + "this_week": "ამ კვირას", + "this_month": "ამ თვეში", + "last_6_months": "ბოლო 6 თვე", + "this_year": "ამ წელს", + "last_2_years": "ბოლო 2 წელი", + "all_time": "ყველა დრო", + "powered_by_provider": "{providerName}-ით გაწვდილი", + "email": "ელ. ფოსტა", + "profile_followers": "გამყვანები", + "birthday": "დაბადების დღე", + "subscription": "გამოწერა", + "not_born": "არ დაბადებულა", + "hacker": "ჰაკერი", + "profile": "პროფილი", + "no_name": "არ არის სახელი", + "edit": "რედაქტირება", + "user_profile": "მომხმარებლის პროფილი", + "count_plays": "{count} გაწვდვა", + "streaming_fees_hypothetical": "*ეს рассчитывается на основе выплат за поток от Spotify\nот $0.003 до $0.005. ეს ჰიპოთეტური გამოთვლა იძლევა მომხმარებელს წარმოდგენას იმაზე, რამდენად\nგადახდილი იქნებოდა არტისტებისთვის, თუ მათ მოუსმინოს Spotify-ს ტრეკებს.", + "count_mins": "{minutes} წუთი", + "summary_minutes": "წუთები", + "summary_listened_to_music": "მუსიკა გაწვდილი", + "summary_songs": "მელოდია", + "summary_streamed_overall": "გაწვდილი საერთო", + "summary_owed_to_artists": "გადასახადი არტისტებს\nამ თვეში", + "summary_artists": "არტისტების", + "summary_music_reached_you": "მუსიკა ჩაგივარდა", + "summary_full_albums": "სრული ალბომები", + "summary_got_your_love": "მოსულა თქვენი სიყვარული", + "summary_playlists": "პლეილისტები", + "summary_were_on_repeat": "გადაწვდილი იყო", + "total_money": "მთლიანი {money}", + "minutes_listened": "წუთები მოუსმინეს", + "streamed_songs": "სტრიმირებული სიმღერები", + "count_streams": "{count} სტრიმი", + "owned_by_you": "შენ მიერ საკუთრებული", + "copied_shareurl_to_clipboard": "{shareUrl} აიღო კლიპბორდზე", + "spotify_hipotetical_calculation": "*ეს გამოითვლება Spotify-ის თითოეულ სტრიმზე\nგადახდის შესაბამისად, რომელიც $0.003 დან $0.005-მდეა. ეს არის ჰიპოთეტური\nგამოთვლა, რომელიც აჩვენებს მომხმარებელს რამდენი გადაიხდიდა\nარტისტებს, თუკი ისინი უსმენდნენ მათ სიმღერებს Spotify-ზე." +} \ No newline at end of file diff --git a/lib/l10n/app_ko.arb b/lib/l10n/app_ko.arb index c94f81425..10036ba5b 100644 --- a/lib/l10n/app_ko.arb +++ b/lib/l10n/app_ko.arb @@ -321,5 +321,69 @@ "select": "선택", "connect_client_alert": "{client}님에 의해 제어되고 있습니다", "this_device": "이 장치", - "remote": "원격" + "remote": "원격", + "local_library": "로컬 도서관", + "add_library_location": "도서관에 추가", + "remove_library_location": "도서관에서 제거", + "local_tab": "로컬", + "stats": "통계", + "and_n_more": "그리고 {count}개 더", + "recently_played": "최근 재생", + "browse_more": "더 보기", + "no_title": "제목 없음", + "not_playing": "재생 중이 아님", + "epic_failure": "서사적 실패!", + "added_num_tracks_to_queue": "{tracks_length} 곡을 대기열에 추가했습니다", + "spotube_has_an_update": "Spotube에 업데이트가 있습니다", + "download_now": "지금 다운로드", + "nightly_version": "Spotube Nightly {nightlyBuildNum}이 출시되었습니다", + "release_version": "Spotube v{version}이 출시되었습니다", + "read_the_latest": "최신 ", + "release_notes": "릴리스 노트", + "pick_color_scheme": "색상 테마 선택", + "save": "저장", + "choose_the_device": "디바이스 선택:", + "multiple_device_connected": "여러 디바이스가 연결되어 있습니다.\n이 작업을 실행할 디바이스를 선택하세요", + "nothing_found": "찾을 수 없음", + "the_box_is_empty": "상자가 비어 있습니다", + "top_artists": "톱 아티스트", + "top_albums": "톱 앨범", + "this_week": "이번 주", + "this_month": "이번 달", + "last_6_months": "지난 6개월", + "this_year": "올해", + "last_2_years": "지난 2년", + "all_time": "모든 시간", + "powered_by_provider": "{providerName} 제공", + "email": "이메일", + "profile_followers": "팔로워", + "birthday": "생일", + "subscription": "구독", + "not_born": "태어나지 않음", + "hacker": "해커", + "profile": "프로필", + "no_name": "이름 없음", + "edit": "편집", + "user_profile": "사용자 프로필", + "count_plays": "{count} 재생", + "streaming_fees_hypothetical": "*이것은 Spotify의 스트림당 지급액\n$0.003에서 $0.005를 기준으로 계산된 것입니다.\n이것은 사용자가 Spotify에서 곡을 들었을 때\n아티스트에게 지불했을 금액에 대한 통찰을 제공하기 위한\n가상의 계산입니다.", + "count_mins": "{minutes} 분", + "summary_minutes": "분", + "summary_listened_to_music": "듣는 음악", + "summary_songs": "곡", + "summary_streamed_overall": "전체 스트리밍", + "summary_owed_to_artists": "이번 달 아티스트에게 지급해야 할 금액", + "summary_artists": "아티스트의", + "summary_music_reached_you": "음악이 도달함", + "summary_full_albums": "전체 앨범", + "summary_got_your_love": "당신의 사랑을 받음", + "summary_playlists": "플레이리스트", + "summary_were_on_repeat": "반복 재생됨", + "total_money": "총 {money}", + "minutes_listened": "청취한 시간", + "streamed_songs": "스트리밍된 곡", + "count_streams": "{count} 스트림", + "owned_by_you": "당신이 소유", + "copied_shareurl_to_clipboard": "{shareUrl}를 클립보드에 복사했습니다", + "spotify_hipotetical_calculation": "*Spotify의 스트림당 지불금 $0.003에서 $0.005까지의\n기준으로 계산되었습니다. 이는 사용자가 Spotify에서\n곡을 들을 때 아티스트에게 얼마를 지불했을지를\n알려주기 위한 가상의 계산입니다." } \ No newline at end of file diff --git a/lib/l10n/app_ne.arb b/lib/l10n/app_ne.arb index 4085b00e7..ce2a1e4b9 100644 --- a/lib/l10n/app_ne.arb +++ b/lib/l10n/app_ne.arb @@ -320,5 +320,69 @@ "select": "चयन गर्नुहोस्", "connect_client_alert": "तपाईंलाई {client} द्वारा नियन्त्रित गरिएको छ", "this_device": "यो उपकरण", - "remote": "दूरसंचार" + "remote": "दूरसंचार", + "local_library": "स्थानिय पुस्तकालय", + "add_library_location": "पुस्तकालयमा थप्नुहोस्", + "remove_library_location": "पुस्तकालयबाट हटाउनुहोस्", + "local_tab": "स्थानिय", + "stats": "तथ्याङ्क", + "and_n_more": "राम्रो {count} थप", + "recently_played": "हालै खेलेको", + "browse_more": "थप हेर्नुहोस्", + "no_title": "शीर्षक छैन", + "not_playing": "खेलिरहेको छैन", + "epic_failure": "महाकवि असफलता!", + "added_num_tracks_to_queue": "{tracks_length} ट्र्याकहरू तालिकामा थपिएका छन्", + "spotube_has_an_update": "Spotube मा अपडेट छ", + "download_now": "अहिले डाउनलोड गर्नुहोस्", + "nightly_version": "Spotube Nightly {nightlyBuildNum} रिलिज गरिएको छ", + "release_version": "Spotube v{version} रिलिज गरिएको छ", + "read_the_latest": "अर्को ", + "release_notes": "रिलिज नोटहरू", + "pick_color_scheme": "रंग योजना चयन गर्नुहोस्", + "save": "सुरक्षित गर्नुहोस्", + "choose_the_device": "उपकरण चयन गर्नुहोस्:", + "multiple_device_connected": "धेरै उपकरण जडान गरिएको छ।\nयो क्रियाकलाप गर्ने उपकरण चयन गर्नुहोस्", + "nothing_found": "केही फेला परेन", + "the_box_is_empty": "बक्स खाली छ", + "top_artists": "शीर्ष कलाकारहरू", + "top_albums": "शीर्ष एल्बमहरू", + "this_week": "यो हप्ता", + "this_month": "यो महिना", + "last_6_months": "पछिल्लो ६ महिना", + "this_year": "यो वर्ष", + "last_2_years": "पछिल्लो २ वर्ष", + "all_time": "सबै समय", + "powered_by_provider": "{providerName} द्वारा शक्ति प्राप्त", + "email": "ईमेल", + "profile_followers": "अनुयायीहरू", + "birthday": "जन्मदिन", + "subscription": "सदस्यता", + "not_born": "जन्मिएको छैन", + "hacker": "ह्याकर", + "profile": "प्रोफाइल", + "no_name": "नाम छैन", + "edit": "सम्पादन गर्नुहोस्", + "user_profile": "प्रयोगकर्ता प्रोफाइल", + "count_plays": "{count} खेलाइन्छ", + "streaming_fees_hypothetical": "*यो Spotify को प्रति स्ट्रिमको आधारमा गणना गरिएको छ\n$0.003 देखि $0.005 बीचको भुक्तानी। यो एक काल्पनिक गणना हो\nउपयोगकर्तालाई यो थाहा दिनको लागि कि उनीहरूले अर्टिस्टहरूलाई\nSpotify मा गीत सुनेको भए कति भुक्तानी गर्ने थिए।", + "count_mins": "{minutes} मिनेट", + "summary_minutes": "मिनेट", + "summary_listened_to_music": "सङ्गीत सुन्नु", + "summary_songs": "गीतहरू", + "summary_streamed_overall": "सामान्य रूपले स्ट्रीम गरिएको", + "summary_owed_to_artists": "यस महिना कलाकारहरूलाई देन", + "summary_artists": "कलाकारको", + "summary_music_reached_you": "सङ्गीत तपाईंलाई पुग्यो", + "summary_full_albums": "पूर्ण एल्बमहरू", + "summary_got_your_love": "तपाईंको माया प्राप्त गरियो", + "summary_playlists": "प्लेइस्ट", + "summary_were_on_repeat": "पुनरावृत्ति गरियो", + "total_money": "कुल {money}", + "minutes_listened": "सुनिएका मिनेटहरू", + "streamed_songs": "स्ट्रीम गरिएका गीतहरू", + "count_streams": "{count} स्ट्रिम", + "owned_by_you": "तपाईंले स्वामित्व गरेको", + "copied_shareurl_to_clipboard": "{shareUrl} क्लिपबोर्डमा कपी गरियो", + "spotify_hipotetical_calculation": "*यो Spotify को प्रति स्ट्रीम भुगतानको आधारमा\n$0.003 देखि $0.005 को बीचमा गणना गरिएको हो। यो एक काल्पनिक\nगणना हो जसले प्रयोगकर्तालाई देखाउँछ कि उनीहरूले कति\nअर्टिस्टहरूलाई तिनीहरूका गीतहरू Spotify मा सुनेमा\nभुक्तान गर्नुपर्ने थियो।" } \ No newline at end of file diff --git a/lib/l10n/app_nl.arb b/lib/l10n/app_nl.arb index 0a04c40b0..5e22446d3 100644 --- a/lib/l10n/app_nl.arb +++ b/lib/l10n/app_nl.arb @@ -321,5 +321,69 @@ "select": "Selecteren", "connect_client_alert": "Je wordt gecontroleerd door {client}", "this_device": "Dit apparaat", - "remote": "Afstandsbediening" + "remote": "Afstandsbediening", + "local_library": "Lokale bibliotheek", + "add_library_location": "Toevoegen aan bibliotheek", + "remove_library_location": "Verwijderen uit bibliotheek", + "local_tab": "Lokaal", + "stats": "Statistieken", + "and_n_more": "en {count} meer", + "recently_played": "Onlangs afgespeeld", + "browse_more": "Meer bekijken", + "no_title": "Geen titel", + "not_playing": "Niet aan het afspelen", + "epic_failure": "Epische mislukking!", + "added_num_tracks_to_queue": "{tracks_length} nummers aan de wachtrij toegevoegd", + "spotube_has_an_update": "Spotube heeft een update", + "download_now": "Nu downloaden", + "nightly_version": "Spotube Nightly {nightlyBuildNum} is uitgebracht", + "release_version": "Spotube v{version} is uitgebracht", + "read_the_latest": "Lees de nieuwste ", + "release_notes": "release-opmerkingen", + "pick_color_scheme": "Kies kleurenschema", + "save": "Opslaan", + "choose_the_device": "Kies het apparaat:", + "multiple_device_connected": "Er zijn meerdere apparaten verbonden.\nKies het apparaat waarop je deze actie wilt uitvoeren", + "nothing_found": "Niets gevonden", + "the_box_is_empty": "De doos is leeg", + "top_artists": "Topartiesten", + "top_albums": "Topalbums", + "this_week": "Deze week", + "this_month": "Deze maand", + "last_6_months": "Laatste 6 maanden", + "this_year": "Dit jaar", + "last_2_years": "Laatste 2 jaar", + "all_time": "All time", + "powered_by_provider": "Aangedreven door {providerName}", + "email": "E-mail", + "profile_followers": "Volgers", + "birthday": "Verjaardag", + "subscription": "Abonnement", + "not_born": "Niet geboren", + "hacker": "Hacker", + "profile": "Profiel", + "no_name": "Geen naam", + "edit": "Bewerken", + "user_profile": "Gebruikersprofiel", + "count_plays": "{count} afspeelbeurten", + "streaming_fees_hypothetical": "*Dit is berekend op basis van Spotify's uitbetaling per stream\nvan $0.003 tot $0.005. Dit is een hypothetische\nberekening om gebruikers inzicht te geven in hoeveel ze\naan de artiesten zouden hebben betaald als ze hun lied op Spotify zouden hebben beluisterd.", + "count_mins": "{minutes} min", + "summary_minutes": "minuten", + "summary_listened_to_music": "Beluisterde muziek", + "summary_songs": "nummers", + "summary_streamed_overall": "Totaal gestreamd", + "summary_owed_to_artists": "Te betalen aan artiesten\ndeze maand", + "summary_artists": "van de artiest", + "summary_music_reached_you": "Muziek heeft je bereikt", + "summary_full_albums": "volledige albums", + "summary_got_your_love": "Kreeg je liefde", + "summary_playlists": "afspeellijsten", + "summary_were_on_repeat": "Was op herhaling", + "total_money": "Totaal {money}", + "minutes_listened": "Luistertijd", + "streamed_songs": "Gestreamde nummers", + "count_streams": "{count} streams", + "owned_by_you": "Bezit door jou", + "copied_shareurl_to_clipboard": "{shareUrl} gekopieerd naar klembord", + "spotify_hipotetical_calculation": "*Dit is berekend op basis van Spotify's betaling per stream\nvan $0.003 tot $0.005. Dit is een hypothetische\nberekening om de gebruiker inzicht te geven in hoeveel ze\naan de artiesten zouden hebben betaald als ze hun liedjes op Spotify\nzouden luisteren." } \ No newline at end of file diff --git a/lib/l10n/app_pl.arb b/lib/l10n/app_pl.arb index 9ce311870..06449ad95 100644 --- a/lib/l10n/app_pl.arb +++ b/lib/l10n/app_pl.arb @@ -320,5 +320,69 @@ "select": "Wybierz", "connect_client_alert": "Jesteś sterowany przez {client}", "this_device": "To urządzenie", - "remote": "Zdalny" + "remote": "Zdalny", + "local_library": "Biblioteka lokalna", + "add_library_location": "Dodaj do biblioteki", + "remove_library_location": "Usuń z biblioteki", + "local_tab": "Lokalny", + "stats": "Statystyki", + "and_n_more": "i {count} więcej", + "recently_played": "Ostatnio odtwarzane", + "browse_more": "Zobacz więcej", + "no_title": "Brak tytułu", + "not_playing": "Nie odtwarzane", + "epic_failure": "Epicka porażka!", + "added_num_tracks_to_queue": "Dodano {tracks_length} utworów do kolejki", + "spotube_has_an_update": "Spotube ma aktualizację", + "download_now": "Pobierz teraz", + "nightly_version": "Spotube Nightly {nightlyBuildNum} został wydany", + "release_version": "Spotube v{version} został wydany", + "read_the_latest": "Przeczytaj najnowsze ", + "release_notes": "notatki o wersji", + "pick_color_scheme": "Wybierz schemat kolorów", + "save": "Zapisz", + "choose_the_device": "Wybierz urządzenie:", + "multiple_device_connected": "Jest wiele urządzeń podłączonych.\nWybierz urządzenie, na którym chcesz wykonać tę akcję", + "nothing_found": "Nic nie znaleziono", + "the_box_is_empty": "Pudełko jest puste", + "top_artists": "Najlepsi artyści", + "top_albums": "Najlepsze albumy", + "this_week": "W tym tygodniu", + "this_month": "W tym miesiącu", + "last_6_months": "Ostatnie 6 miesięcy", + "this_year": "W tym roku", + "last_2_years": "Ostatnie 2 lata", + "all_time": "Wszystkie czasy", + "powered_by_provider": "Napędzane przez {providerName}", + "email": "E-mail", + "profile_followers": "Obserwujący", + "birthday": "Data urodzenia", + "subscription": "Subskrypcja", + "not_born": "Nie urodzony", + "hacker": "Haker", + "profile": "Profil", + "no_name": "Brak nazwy", + "edit": "Edytuj", + "user_profile": "Profil użytkownika", + "count_plays": "{count} odtworzeń", + "streaming_fees_hypothetical": "*Obliczone na podstawie wypłaty Spotify za stream\nod $0.003 do $0.005. Jest to hipotetyczne\nobliczenie, które ma na celu pokazanie, ile\nużytkownik zapłaciłby artystom, gdyby odsłuchał\ntych utworów na Spotify.", + "count_mins": "{minutes} min", + "summary_minutes": "minuty", + "summary_listened_to_music": "Słuchana muzyka", + "summary_songs": "utwory", + "summary_streamed_overall": "Ogółem streamowane", + "summary_owed_to_artists": "Do zapłaty artystom\nw tym miesiącu", + "summary_artists": "artystów", + "summary_music_reached_you": "Muzyka dotarła do Ciebie", + "summary_full_albums": "pełne albumy", + "summary_got_your_love": "Otrzymał Twoją miłość", + "summary_playlists": "playlisty", + "summary_were_on_repeat": "Były na powtarzaniu", + "total_money": "Łącznie {money}", + "minutes_listened": "Minuty odsłuchane", + "streamed_songs": "Strumieniowane utwory", + "count_streams": "{count} strumieni", + "owned_by_you": "Własność Twoja", + "copied_shareurl_to_clipboard": "{shareUrl} skopiowano do schowka", + "spotify_hipotetical_calculation": "*Obliczone na podstawie płatności Spotify za strumień\nw zakresie od $0.003 do $0.005. Jest to hipotetyczne\nobliczenie mające na celu pokazanie użytkownikowi, ile\nzapłaciliby artystom, gdyby słuchali ich utworów na Spotify." } \ No newline at end of file diff --git a/lib/l10n/app_pt.arb b/lib/l10n/app_pt.arb index 537325894..7231d15a2 100644 --- a/lib/l10n/app_pt.arb +++ b/lib/l10n/app_pt.arb @@ -320,5 +320,69 @@ "select": "Selecionar", "connect_client_alert": "Você está sendo controlado por {client}", "this_device": "Este dispositivo", - "remote": "Remoto" + "remote": "Remoto", + "local_library": "Biblioteca local", + "add_library_location": "Adicionar à biblioteca", + "remove_library_location": "Remover da biblioteca", + "local_tab": "Local", + "stats": "Estatísticas", + "and_n_more": "e {count} mais", + "recently_played": "Reproduzido Recentemente", + "browse_more": "Ver Mais", + "no_title": "Sem Título", + "not_playing": "Não está a reproduzir", + "epic_failure": "Fracasso épico!", + "added_num_tracks_to_queue": "Adicionados {tracks_length} faixas à fila", + "spotube_has_an_update": "Spotube tem uma atualização", + "download_now": "Baixar Agora", + "nightly_version": "Spotube Nightly {nightlyBuildNum} foi lançado", + "release_version": "Spotube v{version} foi lançado", + "read_the_latest": "Leia o mais recente ", + "release_notes": "notas de versão", + "pick_color_scheme": "Escolha o esquema de cores", + "save": "Salvar", + "choose_the_device": "Escolha o dispositivo:", + "multiple_device_connected": "Há vários dispositivos conectados.\nEscolha o dispositivo no qual deseja executar esta ação", + "nothing_found": "Nada encontrado", + "the_box_is_empty": "A caixa está vazia", + "top_artists": "Principais Artistas", + "top_albums": "Principais Álbuns", + "this_week": "Esta semana", + "this_month": "Este mês", + "last_6_months": "Últimos 6 meses", + "this_year": "Este ano", + "last_2_years": "Últimos 2 anos", + "all_time": "De todos os tempos", + "powered_by_provider": "Desenvolvido por {providerName}", + "email": "E-mail", + "profile_followers": "Seguidores", + "birthday": "Aniversário", + "subscription": "Assinatura", + "not_born": "Não nascido", + "hacker": "Hacker", + "profile": "Perfil", + "no_name": "Sem Nome", + "edit": "Editar", + "user_profile": "Perfil do Usuário", + "count_plays": "{count} reproduzidos", + "streaming_fees_hypothetical": "*Calculado com base no pagamento por stream do Spotify\nque varia de $0.003 a $0.005. Isso é um cálculo hipotético\npara fornecer uma visão ao usuário sobre quanto eles\nteriam pago aos artistas se estivessem ouvindo\no seu som no Spotify.", + "count_mins": "{minutes} min", + "summary_minutes": "minutos", + "summary_listened_to_music": "Música ouvida", + "summary_songs": "faixas", + "summary_streamed_overall": "Total de streams", + "summary_owed_to_artists": "Devido aos artistas\neste mês", + "summary_artists": "artista", + "summary_music_reached_you": "A música chegou até você", + "summary_full_albums": "álbuns completos", + "summary_got_your_love": "Recebeu seu amor", + "summary_playlists": "playlists", + "summary_were_on_repeat": "Estavam em repetição", + "total_money": "Total {money}", + "minutes_listened": "Minutos ouvidos", + "streamed_songs": "Músicas transmitidas", + "count_streams": "{count} streams", + "owned_by_you": "De sua propriedade", + "copied_shareurl_to_clipboard": "{shareUrl} copiado para a área de transferência", + "spotify_hipotetical_calculation": "*Isso é calculado com base no pagamento por stream do Spotify\nque varia de $0.003 a $0.005. Esta é uma cálculo hipotético\npara dar ao usuário uma visão de quanto teriam pago aos artistas\nse eles ouvissem suas músicas no Spotify." } \ No newline at end of file diff --git a/lib/l10n/app_ru.arb b/lib/l10n/app_ru.arb index a18e02e7d..7cffb42a6 100644 --- a/lib/l10n/app_ru.arb +++ b/lib/l10n/app_ru.arb @@ -8,16 +8,16 @@ "genre_categories_filter": "Фильтр по категориям или жанрам...", "genre": "Жанр", "personalized": "Персонализированный", - "featured": "Будующий", - "new_releases": "Новые", - "songs": "Песни", + "featured": "Популярное", + "new_releases": "Новое", + "songs": "Треки", "playing_track": "Играет {track}", "queue_clear_alert": "Это удалит текущую очередь. {track_length} треков будет удалено. Вы хотите продолжить?", "load_more": "Загрузить больше", "playlists": "Плейлисты", "artists": "Исполнители", "albums": "Альбомы", - "tracks": "Трек", + "tracks": "Треки", "downloads": "Загрузки", "filter_playlists": "Применить фильтры к вашим плейлистам...", "liked_tracks": "Понравившиеся треки", @@ -25,20 +25,22 @@ "create_playlist": "Создание плейлиста", "create_a_playlist": "Создать плейлист", "create": "Создать", - "cancel": "Отменить", + "cancel": "Отмена", + "update": "Обновить", "playlist_name": "Назвать плейлист", "name_of_playlist": "Название плейлиста", "description": "Описание", - "public": "Публичные", + "public": "Публичный", "collaborative": "Совместный", "search_local_tracks": "Поиск песен на вашем устройстве...", "play": "Играть", "delete": "Удалить", - "none": "Никто", + "none": "Пусто", "sort_a_z": "Сортировка по алфавиту", "sort_z_a": "Сортировка по алфавиту в обратную сторону", "sort_artist": "Сортировать по исполнителю", "sort_album": "Сортировать по альбомам", + "sort_duration": "Сортировать по длительности", "sort_tracks": "Сортировать треки", "currently_downloading": "Загружается ({tracks_length})", "cancel_all": "Отменить все", @@ -104,6 +106,9 @@ "always_on_top": "Всегда сверху", "exit_mini_player": "Выйти из мини-плеера", "download_location": "Место загрузки", + "local_library": "Локальная библиотека", + "add_library_location": "Добавить в библиотеку", + "remove_library_location": "Удалить из библиотеки", "account": "Аккаунт", "login_with_spotify": "Войдите с помощью своей учетной записи Spotify", "connect_with_spotify": "Подключитесь к Spotify", @@ -141,7 +146,7 @@ "close": "Закрыть", "minimize_to_tray": "Свернуть", "show_tray_icon": "Показать значок на панели задач", - "about": "О", + "about": "О нас", "u_love_spotube": "Мы знаем что вам нравится Spotube", "check_for_updates": "Проверьте наличие обновлений", "about_spotube": "О Spotube", @@ -175,9 +180,11 @@ "step_2": "Шаг 2", "step_2_steps": "1. После входа в систему нажмите F12 или щелкните правой кнопкой мыши > «Проверить», чтобы открыть инструменты разработчика браузера.\n2. Затем перейдите на вкладку \"Application\" (Chrome, Edge, Brave и т.д..) or \"Storage\" (Firefox, Palemoon и т.д..)\n3. Перейдите в раздел \"Cookies\", а затем в подраздел \"https://accounts.spotify.com\"", "step_3": "Шаг 3", - "success_emoji": "Успешно 🥳", + "step_3_steps": "Скопируйте значение Cookie \"sp_dc\"", + "success_emoji": "Успешно🥳", "success_message": "Теперь вы успешно вошли в свою учетную запись Spotify. Отличная работа, приятель!", "step_4": "Шаг 4", + "step_4_steps": "Вставьте скопированное значение \"sp_dc\"", "something_went_wrong": "Что-то пошло не так", "piped_instance": "Экземпляр сервера Piped", "piped_description": "Серверный экземпляр Piped для сопоставления треков", @@ -205,7 +212,7 @@ "popularity": "Популярность", "key": "Ключ", "duration": "Продолжительность (с)", - "tempo": "Время (BPM)", + "tempo": "Темп (BPM)", "mode": "Режим", "time_signature": "Тактовый размер", "short": "Короткий", @@ -257,8 +264,6 @@ "you_are_offline": "Нет доступа к сети", "connection_restored": "Ваше интернет-соединение восстановлено", "use_system_title_bar": "Использовать системную панель заголовка", - "update_playlist": "Обновить плейлист", - "update": "Обновить", "crunching_results": "Обработка результатов...", "search_to_get_results": "Поиск для получения результатов", "use_amoled_mode": "Режим AMOLED", @@ -283,11 +288,8 @@ "browse_all": "Просмотреть все", "genres": "Жанры", "explore_genres": "Исследовать жанры", - "step_3_steps": "Скопируйте значение файла cookie \"sp_dc\"", - "step_4_steps": "Вставьте скопированное значение \"sp_dc\"", "friends": "Друзья", "no_lyrics_available": "Извините, не удается найти текст для этого трека", - "sort_duration": "Сортировка по Длительности", "start_a_radio": "Запустить радио", "how_to_start_radio": "Как вы хотите запустить радио?", "replace_queue_question": "Хотите заменить текущую очередь или добавить к ней?", @@ -295,6 +297,7 @@ "delete_playlist": "Удалить плейлист", "delete_playlist_confirmation": "Вы уверены, что хотите удалить этот плейлист?", "local_tracks": "Локальные треки", + "local_tab": "Локальное", "song_link": "Ссылка на песню", "skip_this_nonsense": "Пропустить этот бред", "freedom_of_music": "“Свобода музыки”", @@ -320,5 +323,66 @@ "select": "Выбрать", "connect_client_alert": "Вас контролирует {client}", "this_device": "Это устройство", - "remote": "Дистанционное управление" + "remote": "Дистанционное управление", + "stats": "Статистика", + "update_playlist": "Обновить плейлист", + "and_n_more": "и {count} еще", + "recently_played": "Недавно воспроизведено", + "browse_more": "Посмотреть больше", + "no_title": "Без названия", + "not_playing": "Не воспроизводится", + "epic_failure": "Эпическое фиаско!", + "added_num_tracks_to_queue": "Добавлено {tracks_length} треков в очередь", + "spotube_has_an_update": "В Spotube доступно обновление", + "download_now": "Скачать сейчас", + "nightly_version": "Spotube Nightly {nightlyBuildNum} выпущен", + "release_version": "Spotube v{version} выпущен", + "read_the_latest": "Читать последние ", + "release_notes": "заметки о версии", + "pick_color_scheme": "Выберите цветовую схему", + "save": "Сохранить", + "choose_the_device": "Выберите устройство:", + "multiple_device_connected": "Подключено несколько устройств.\nВыберите устройство, на котором вы хотите выполнить это действие", + "nothing_found": "Ничего не найдено", + "the_box_is_empty": "Коробка пуста", + "top_artists": "Лучшие артисты", + "top_albums": "Лучшие альбомы", + "this_week": "На этой неделе", + "this_month": "В этом месяце", + "last_6_months": "Последние 6 месяцев", + "this_year": "В этом году", + "last_2_years": "Последние 2 года", + "all_time": "Все время", + "powered_by_provider": "При поддержке {providerName}", + "email": "Электронная почта", + "profile_followers": "Подписчики", + "birthday": "День рождения", + "subscription": "Подписка", + "not_born": "Не рожден", + "hacker": "Хакер", + "profile": "Профиль", + "no_name": "Без имени", + "edit": "Редактировать", + "user_profile": "Профиль пользователя", + "count_plays": "{count} воспроизведений", + "streaming_fees_hypothetical": "*Рассчитано на основе выплат Spotify за стрим\nот $0.003 до $0.005. Это гипотетический\nрасчет, чтобы показать пользователю, сколько бы он\nзаплатил артистам, если бы слушал их песни на Spotify.", + "count_mins": "{minutes} мин", + "summary_minutes": "минуты", + "summary_listened_to_music": "Слушанная музыка", + "summary_songs": "песни", + "summary_streamed_overall": "Всего стримов", + "summary_owed_to_artists": "К выплате артистам\nв этом месяце", + "summary_artists": "артиста", + "summary_music_reached_you": "Музыка дошла до вас", + "summary_full_albums": "полные альбомы", + "summary_got_your_love": "Получил вашу любовь", + "summary_playlists": "плейлисты", + "summary_were_on_repeat": "Были на повторе", + "total_money": "Всего {money}", + "minutes_listened": "Минут прослушивания", + "streamed_songs": "Стримленные песни", + "count_streams": "{count} стримов", + "owned_by_you": "Ваша собственность", + "copied_shareurl_to_clipboard": "{shareUrl} скопировано в буфер обмена", + "spotify_hipotetical_calculation": "*Это рассчитано на основе выплат Spotify за стрим\nот $0.003 до $0.005. Это гипотетический расчет,\nчтобы дать пользователю представление о том, сколько бы он\nзаплатил артистам, если бы слушал их песни на Spotify." } \ No newline at end of file diff --git a/lib/l10n/app_th.arb b/lib/l10n/app_th.arb index 866929fa9..3cac73f7f 100644 --- a/lib/l10n/app_th.arb +++ b/lib/l10n/app_th.arb @@ -321,5 +321,69 @@ "select": "เลือก", "connect_client_alert": "คุณกำลังถูกควบคุมโดย {client}", "this_device": "อุปกรณ์นี้", - "remote": "ระยะไกล" + "remote": "ระยะไกล", + "local_library": "ห้องสมุดท้องถิ่น", + "add_library_location": "เพิ่มในห้องสมุด", + "remove_library_location": "ลบออกจากห้องสมุด", + "local_tab": "ท้องถิ่น", + "stats": "สถิติ", + "and_n_more": "และ {count} อีก", + "recently_played": "เพลงที่เพิ่งเล่น", + "browse_more": "ดูเพิ่มเติม", + "no_title": "ไม่มีชื่อ", + "not_playing": "ไม่เล่น", + "epic_failure": "ล้มเหลวอย่างยิ่ง!", + "added_num_tracks_to_queue": "เพิ่ม {tracks_length} เพลงในคิว", + "spotube_has_an_update": "Spotube มีการอัปเดต", + "download_now": "ดาวน์โหลดตอนนี้", + "nightly_version": "Spotube Nightly {nightlyBuildNum} ได้รับการปล่อยออกมา", + "release_version": "Spotube v{version} ได้รับการปล่อยออกมา", + "read_the_latest": "อ่านข่าวสารล่าสุด ", + "release_notes": "บันทึกการปล่อย", + "pick_color_scheme": "เลือกธีมสี", + "save": "บันทึก", + "choose_the_device": "เลือกอุปกรณ์:", + "multiple_device_connected": "มีอุปกรณ์เชื่อมต่อหลายเครื่อง\nเลือกอุปกรณ์ที่คุณต้องการให้การดำเนินการนี้เกิดขึ้น", + "nothing_found": "ไม่พบข้อมูล", + "the_box_is_empty": "กล่องว่างเปล่า", + "top_artists": "ศิลปินยอดนิยม", + "top_albums": "อัลบั้มยอดนิยม", + "this_week": "สัปดาห์นี้", + "this_month": "เดือนนี้", + "last_6_months": "6 เดือนที่ผ่านมา", + "this_year": "ปีนี้", + "last_2_years": "2 ปีที่ผ่านมา", + "all_time": "ตลอดกาล", + "powered_by_provider": "ขับเคลื่อนโดย {providerName}", + "email": "อีเมล", + "profile_followers": "ผู้ติดตาม", + "birthday": "วันเกิด", + "subscription": "การสมัครสมาชิก", + "not_born": "ยังไม่เกิด", + "hacker": "แฮ็กเกอร์", + "profile": "โปรไฟล์", + "no_name": "ไม่มีชื่อ", + "edit": "แก้ไข", + "user_profile": "โปรไฟล์ผู้ใช้", + "count_plays": "{count} การเล่น", + "streaming_fees_hypothetical": "*คำนวณจากการจ่ายเงินต่อการสตรีมของ Spotify\nระหว่าง $0.003 ถึง $0.005 นี่เป็นการคำนวณสมมุติ\nเพื่อให้ข้อมูลแก่ผู้ใช้เกี่ยวกับจำนวนเงินที่พวกเขา\nอาจจะจ่ายให้กับศิลปินหากพวกเขาฟังเพลงของพวกเขาใน Spotify", + "count_mins": "{minutes} นาที", + "summary_minutes": "นาที", + "summary_listened_to_music": "ฟังเพลง", + "summary_songs": "เพลง", + "summary_streamed_overall": "สตรีมทั้งหมด", + "summary_owed_to_artists": "ค้างชำระให้ศิลปิน\nในเดือนนี้", + "summary_artists": "ศิลปิน", + "summary_music_reached_you": "เพลงมาถึงคุณ", + "summary_full_albums": "อัลบั้มเต็ม", + "summary_got_your_love": "ได้รับความรักของคุณ", + "summary_playlists": "เพลย์ลิสต์", + "summary_were_on_repeat": "อยู่ในโหมดซ้ำ", + "total_money": "รวม {money}", + "minutes_listened": "เวลาที่ฟัง", + "streamed_songs": "เพลงที่สตรีม", + "count_streams": "{count} สตรีม", + "owned_by_you": "เป็นเจ้าของโดยคุณ", + "copied_shareurl_to_clipboard": "{shareUrl} คัดลอกไปที่คลิปบอร์ดแล้ว", + "spotify_hipotetical_calculation": "*คำนวณตามการจ่ายต่อสตรีมของ Spotify\nซึ่งอยู่ในช่วง $0.003 ถึง $0.005 นี่เป็นการคำนวณสมมุติ\nเพื่อให้ผู้ใช้ทราบว่าพวกเขาจะจ่ายเงินให้ศิลปินเท่าไหร่\nหากพวกเขาฟังเพลงของพวกเขาใน Spotify." } \ No newline at end of file diff --git a/lib/l10n/app_tr.arb b/lib/l10n/app_tr.arb index a4050853d..b5a0ec1ee 100644 --- a/lib/l10n/app_tr.arb +++ b/lib/l10n/app_tr.arb @@ -3,13 +3,13 @@ "browse": "Göz at", "search": "Ara", "library": "Kütüphane", - "lyrics": "Şarkı Sözleri", + "lyrics": "Şarkı sözleri", "settings": "Ayarlar", - "genre_categories_filter": "Kategorileri veya türleri filtrele...", + "genre_categories_filter": "Kategorileri veya türleri filtreleyin...", "genre": "Tür", "personalized": "Kişiselleştirilmiş", - "featured": "Öne Çıkanlar", - "new_releases": "Yeni Çıkanlar", + "featured": "Öne çıkanlar", + "new_releases": "Yeni çıkanlar", "songs": "Şarkılar", "playing_track": "{track} oynatılıyor", "queue_clear_alert": "Bu, mevcut kuyruğu temizleyecektir. {track_length} parça kaldırılacak\nDevam etmek istiyor musunuz?", @@ -20,15 +20,15 @@ "tracks": "Parçalar", "downloads": "İndirilenler", "filter_playlists": "Oynatma listelerinizi filtreleyin...", - "liked_tracks": "Beğenilen Parçalar", + "liked_tracks": "Beğenilen parçalar", "liked_tracks_description": "Beğendiğiniz tüm parçalar", - "create_playlist": "Oynatma Listesi Oluştur", - "create_a_playlist": "Bir oynatma listesi oluşturun", + "create_playlist": "Oynatma listesi oluştur", + "create_a_playlist": "Bir oynatma listesi oluştur", "update_playlist": "Oynatma listesini güncelle", "create": "Oluştur", "cancel": "İptal", "update": "Güncelle", - "playlist_name": "Oynatma Listesi Adı", + "playlist_name": "Oynatma listesi adı", "name_of_playlist": "Oynatma listesinin adı", "description": "Açıklama", "public": "Halka açık", @@ -39,16 +39,16 @@ "none": "Yok", "sort_a_z": "A - Z'ye göre sırala", "sort_z_a": "Z - A'ya göre sırala", - "sort_artist": "Sanatçıya Göre Sırala", - "sort_album": "Albüme Göre Sırala", - "sort_duration": "Süreye Göre Sırala", - "sort_tracks": "Parçaları Sırala", - "currently_downloading": "Şu An İndirilenler ({tracks_length})", - "cancel_all": "Tümünü İptal Et", - "filter_artist": "Sanatçıları filtrele...", + "sort_artist": "Sanatçıya göre sırala", + "sort_album": "Albüme göre sırala", + "sort_duration": "Süreye göre sırala", + "sort_tracks": "Parçaları sırala", + "currently_downloading": "Şu anda indirilenler ({tracks_length})", + "cancel_all": "Tümünü iptal et", + "filter_artist": "Sanatçıları filtreleyin...", "followers": "{followers} Takipçiler", "add_artist_to_blacklist": "Sanatçıyı kara listeye ekle", - "top_tracks": "En İyi Parçalar", + "top_tracks": "En iyi parçalar", "fans_also_like": "Hayranlar ayrıca şunları da beğendi", "loading": "Yükleniyor...", "artist": "Sanatçı", @@ -57,7 +57,7 @@ "follow": "Takip et", "artist_url_copied": "Sanatçı bağlantısı panoya kopyalandı", "added_to_queue": "Kuyruğa {tracks} parçası eklendi", - "filter_albums": "Albümleri filtrele...", + "filter_albums": "Albümleri filtreleyin...", "synced": "Senkronize edildi", "plain": "Sade", "shuffle": "Karıştır", @@ -68,19 +68,19 @@ "time": "Zaman", "more_actions": "Daha fazla eylem", "download_count": "İndir ({count})", - "add_count_to_playlist": "Oynatma Listesine ({count}) ekle", - "add_count_to_queue": "Kuyruğa ({count}) ekle", - "play_count_next": "({count}) sonrakini oynat", + "add_count_to_playlist": "Oynatma Listesine ekle ({count})", + "add_count_to_queue": "Kuyruğa ekle ({count})", + "play_count_next": "Sonrakini oynat ({count})", "album": "Albüm", "copied_to_clipboard": "{data} panoya kopyalandı", - "add_to_following_playlists": "{track} parçasını aşağıdaki Oynatma Listelerine ekle", + "add_to_following_playlists": "{track} parçasını aşağıdaki oynatma listelerine ekle", "add": "Ekle", "added_track_to_queue": "{track} kuyruğa eklendi", "add_to_queue": "Kuyruğa ekle", "track_will_play_next": "{track} bir sonraki çalacak", "play_next": "Sonrakini oynat", - "removed_track_from_queue": "{track} sıradan kaldırıldı", - "remove_from_queue": "Sıradan kaldır", + "removed_track_from_queue": "{track} kuyruktan kaldırıldı", + "remove_from_queue": "Kuyruktan kaldır", "remove_from_favorites": "Favorilerden kaldır", "save_as_favorite": "Favori olarak kaydet", "add_to_playlist": "Oynatma listesine ekle", @@ -88,7 +88,7 @@ "add_to_blacklist": "Kara listeye ekle", "remove_from_blacklist": "Kara listeden kaldır", "share": "Paylaş", - "mini_player": "Mini Oynatıcı", + "mini_player": "Mini oynatıcı", "slide_to_seek": "İleri veya geri arama yapmak için kaydırın", "shuffle_playlist": "Oynatma listesini karıştır", "unshuffle_playlist": "Oynatma listesinin karışıklığını kaldır", @@ -98,27 +98,27 @@ "resume_playback": "Oynatmayı sürdür", "loop_track": "Döngü parçası", "repeat_playlist": "Oynatma listesini tekrarla", - "queue": "Sıra", - "alternative_track_sources": "Alternatif yol kaynakları", + "queue": "Kuyruk", + "alternative_track_sources": "Alternatif parça kaynakları", "download_track": "Parçayı indir", - "tracks_in_queue": "{tracks} parça sırada", + "tracks_in_queue": "{tracks} parça kuyrukta", "clear_all": "Tümünü temizle", "show_hide_ui_on_hover": "Fareyle üzerine gelindiğinde kullanıcı arayüzünü göster/gizle", "always_on_top": "Her zaman üstte", "exit_mini_player": "Mini oynatıcıdan çık", "download_location": "İndirme konumu", "account": "Hesap", - "login_with_spotify": "Spotify hesabınızla giriş yapın", + "login_with_spotify": "Spotify hesabı ile giriş yap", "connect_with_spotify": "Spotify ile bağlan", - "logout": "Çıkış Yap", - "logout_of_this_account": "Bu hesaptan çıkış yap", - "language_region": "Dil ve Bölge", - "language": "Dil", - "system_default": "Sistem Varsayılanı", - "market_place_region": "Pazaryeri Bölgesi", - "recommendation_country": "Tavsiye Edilen Ülke", + "logout": "Çıkış yap", + "logout_of_this_account": "Hesaptan çıkış yap", + "language_region": "Dil ve bölge", + "language": "Tercih edilen dil", + "system_default": "Sistem varsayılanı", + "market_place_region": "Tercih edilen bölge", + "recommendation_country": "Tavsiye edilen ülke", "appearance": "Görünüm", - "layout_mode": "Düzen Modu", + "layout_mode": "Düzen modu", "override_layout_settings": "Duyarlı düzen modu ayarlarını geçersiz kıl", "adaptive": "Uyarlanabilir", "compact": "Sıkıştırılmış", @@ -127,35 +127,35 @@ "dark": "Koyu", "light": "Açık", "system": "Sistem", - "accent_color": "Vurgu Rengi", + "accent_color": "Vurgu rengi", "sync_album_color": "Albüm rengini senkronize et", "sync_album_color_description": "Vurgu rengi olarak albüm resminin baskın rengini kullanır", "playback": "Oynatma", - "audio_quality": "Ses Kalitesi", + "audio_quality": "Ses kalitesi", "high": "Yüksek", "low": "Düşük", - "pre_download_play": "Ön yükleme ve oynatma", - "pre_download_play_description": "Ses akışı yerine baytları indirin ve oynatın (Daha yüksek bant genişliğine sahip kullanıcılar için önerilir)", - "skip_non_music": "Müzik olmayan bölümleri atla (SponsorBlock)", + "pre_download_play": "Önceden indir ve oynat", + "pre_download_play_description": "Ses akışı yerine baytları indir ve oynat (Daha yüksek bant genişliğine sahip kullanıcılar için önerilir)", + "skip_non_music": "Müzik olmayan bölümleri atlat (SponsorBlock)", "blacklist_description": "Kara listeye alınan parçalar ve sanatçılar", "wait_for_download_to_finish": "Lütfen mevcut indirme işleminin tamamlanmasını bekleyin", "desktop": "Masaüstü", - "close_behavior": "Kapatma Davranışı", + "close_behavior": "Kapatma davranışı", "close": "Kapat", "minimize_to_tray": "Tepsiye küçült", "show_tray_icon": "Sistem tepsisi simgesini göster", "about": "Hakkında", "u_love_spotube": "Spotube'u sevdiğinizi biliyoruz", "check_for_updates": "Güncellemeleri kontrol et", - "about_spotube": "Spotube Hakkında", + "about_spotube": "Spotube hakkında", "blacklist": "Kara liste", "please_sponsor": "Sponsor Ol/Bağış Yap", - "spotube_description": "Spotube, hafif, platformlar arası, herkes için ücretsiz bir spotify istemcisidir", + "spotube_description": "Spotube, hafif, platformlar arası uyumlu ve herkes için ücretsiz bir Spotify istemcisidir.", "version": "Sürüm", - "build_number": "Derleme Numarası", - "founder": "Kurucu", + "build_number": "Derleme numarası", + "founder": "Geliştirici", "repository": "Depo", - "bug_issues": "Hata+Sorunlar", + "bug_issues": "Hata + Sorunlar", "made_with": "❤️ ile Bangladeş'te yapıldı", "kingkor_roy_tirtho": "Kingkor Roy Tirtho", "copyright": "© 2021-{current_year} Kingkor Roy Tirtho", @@ -163,31 +163,31 @@ "add_spotify_credentials": "Başlamak için spotify kimlik bilgilerinizi ekleyin", "credentials_will_not_be_shared_disclaimer": "Endişelenmeyin, kimlik bilgilerinizden hiçbiri toplanmayacak veya kimseyle paylaşılmayacak", "know_how_to_login": "Bunu nasıl yapacağınızı bilmiyor musunuz?", - "follow_step_by_step_guide": "Adım Adım kılavuzu takip edin", - "spotify_cookie": "Spotify {name} Çerezi", - "cookie_name_cookie": "{name} Çerezi", + "follow_step_by_step_guide": "Adım adım kılavuzu takip edin", + "spotify_cookie": "Spotify {name} çerezi", + "cookie_name_cookie": "{name} çerezi", "fill_in_all_fields": "Lütfen tüm alanları doldurun", - "submit": "Gönder", + "submit": "Başvur", "exit": "Çık", "previous": "Önceki", "next": "Sonraki", "done": "Bitti", "step_1": "1. Adım", "first_go_to": "İlk olarak şuraya gidin:", - "login_if_not_logged_in": "ve oturum açmadıysanız Oturum Açın/Kaydolun", + "login_if_not_logged_in": "ve oturum açmadıysanız Oturum açın/Kaydolun", "step_2": "2. Adım", - "step_2_steps": "1. Giriş yaptıktan sonra, Tarayıcı geliştirme araçlarını açmak için F12 veya Fareye Sağ Tıklayın > İncele'ye basın.\n2. Ardından \"Uygulama\" Sekmesine (Chrome, Edge, Brave vb.) veya \"Depolama\" Sekmesine (Firefox, Palemoon vb.) gidin.\n3. \"Çerezler\" bölümüne ve ardından \"https://accounts.spotify.com\" alt bölümüne gidin", + "step_2_steps": "1. Oturum açtıktan sonra, tarayıcı geliştirme araçlarını açmak için F12'ye veya fareye sağ tıklayın > İncele'ye basın.\n2. Daha sonra \"Uygulama\" sekmesine (Chrome, Edge, Brave vb..) veya \"Depolama\" sekmesine (Firefox, Palemoon vb..) gidin\n3. \"Çerezler\" bölümüne, ardından \"https://accounts.spotify.com\" alt bölümüne gidin", "step_3": "3. Adım", "step_3_steps": "\"sp_dc\" Çerezinin değerini kopyalayın", "success_emoji": "Başarılı🥳", - "success_message": "Artık Spotify hesabınızla başarıyla giriş yaptınız. Aferin, dostum!", + "success_message": "Artık Spotify hesabınızla başarıyla giriş yaptınız. Tebrik ederim!", "step_4": "4. Adım", "step_4_steps": "Kopyalanan \"sp_dc\" değerini yapıştırın", "something_went_wrong": "Bir hata oluştu", - "piped_instance": "Piped Sunucu Örneği", + "piped_instance": "Piped sunucu örneği", "piped_description": "Parça eşleştirme için kullanılacak Piped sunucu örneği", "piped_warning": "Bazıları iyi çalışmayabilir. Yani riski size ait olmak üzere kullanın", - "generate_playlist": "Oynatma Listesi Oluştur", + "generate_playlist": "Oynatma listesi oluştur", "track_exists": "{track} parçası zaten var", "replace_downloaded_tracks": "İndirilen tüm parçaları değiştir", "skip_download_tracks": "İndirilen tüm parçaları indirmeyi atla", @@ -195,8 +195,8 @@ "replace": "Değiştir", "skip": "Atla", "select_up_to_count_type": "En fazla {count} {type} seçin", - "select_genres": "Türleri Seç", - "add_genres": "Tür Ekle", + "select_genres": "Türleri seç", + "add_genres": "Tür ekle", "country": "Ülke", "number_of_tracks_generate": "Oluşturulacak parça sayısı", "acousticness": "Akustiklik", @@ -212,7 +212,7 @@ "duration": "Süre (sn)", "tempo": "Tempo (BPM)", "mode": "Mod", - "time_signature": "Zaman İmzası", + "time_signature": "Zaman imzası", "short": "Kısa", "medium": "Orta", "long": "Uzun", @@ -220,29 +220,29 @@ "max": "Maks", "target": "Hedef", "moderate": "Orta", - "deselect_all": "Tüm Seçimleri Kaldır", - "select_all": "Tümünü Seç", + "deselect_all": "Tüm seçimleri kaldır", + "select_all": "Tümünü seç", "are_you_sure": "Emin misiniz?", "generating_playlist": "Özel oynatma listeniz oluşturuluyor...", "selected_count_tracks": "{count} parça seçildi", - "download_warning": "Tüm Parçaları toplu olarak indirirseniz, açıkça Müzik korsanlığı yapıyor ve Müziğin yaratıcı toplumuna zarar veriyorsunuz demektir. Umarım bunun farkındasınızdır. Her zaman, Sanatçının sıkı çalışmasına saygı duymaya ve desteklemeye çalışın", - "download_ip_ban_warning": "Bu arada, IP'niz normalden daha fazla indirme isteği nedeniyle YouTube'da engellenebilir. IP engelleme, YouTube'u (oturum açmış olsanız bile) o IP cihazından en az 2 -3 ay kullanamayacağınız anlamına gelir. Ve eğer böyle bir şey olursa Spotube'un hiçbir sorumluluğu yok", + "download_warning": "Tüm şarkıları toplu olarak indiriyorsanız, açıkça müzik korsanlığı yapıyorsunuz ve müzik dünyasının yaratıcı topluluğuna zarar veriyorsunuz demektir. Umuyorum bunun farkındasınızdır. Her zaman, sanatçıların emeğine saygı göstermeyi ve desteklemeyi deneyin.", + "download_ip_ban_warning": "Ayrıca, normalden fazla indirme istekleri nedeniyle YouTube'da IP'niz engellenebilir. IP engeli, en az 2-3 ay boyunca YouTube'u (hatta oturum açmış olsanız bile) o IP cihazından kullanamayacağınız anlamına gelir. Ve eğer böyle bir durum yaşanırsa, Spotube bundan hiçbir sorumluluk kabul etmez.", "by_clicking_accept_terms": "\"Kabul et\" e tıklayarak aşağıdaki şartları kabul etmiş olursunuz:", - "download_agreement_1": "Müzik korsanlığı yaptığımı biliyorum. Ben kötüyüm", + "download_agreement_1": "Müzik korsanlığı yaptığımı biliyorum. Ben fakir biriyim.", "download_agreement_2": "Sanatçıyı elimden geldiğince destekleyeceğim ve bunu sadece sanatını satın alacak param olmadığı için yapıyorum", - "download_agreement_3": "IP adresimin YouTube'da engellenebileceğinin tamamen farkındayım ve mevcut işlemimden kaynaklanan herhangi bir kazadan Spotube'u veya sahiplerini/katkıda bulunanlarını sorumlu tutmuyorum", + "download_agreement_3": "YouTube'da IP'min engellenebileceğinin tamamen farkındayım ve mevcut eylemlerimden kaynaklanan herhangi bir kaza için Spotube'u veya sahiplerini/katkıda bulunanları sorumlu tutmuyorum.", "decline": "Reddet", "accept": "Kabul et", "details": "Detaylar", "youtube": "YouTube", "channel": "Kanal", - "likes": "Beğeniler", + "likes": "Beğenenler", "dislikes": "Beğenmeyenler", "views": "İzlenmeler", "streamUrl": "Akış bağlantısı", "stop": "Durdur", - "sort_newest": "En yeniye göre sırala", - "sort_oldest": "Eklenen en eskiye göre sırala", + "sort_newest": "En yeni eklenene göre sırala.", + "sort_oldest": "En eski eklenene göre sırala", "sleep_timer": "Uyku Zamanlayıcısı", "mins": "{minutes} Dakika", "hours": "{hours} Saatler", @@ -251,11 +251,11 @@ "logs": "Günlükler", "developers": "Geliştiriciler", "not_logged_in": "Giriş yapmadınız", - "search_mode": "Arama Modu", - "audio_source": "Ses Kaynağı", + "search_mode": "Arama modu", + "audio_source": "Ses kaynağı", "ok": "Tamam", "failed_to_encrypt": "Şifreleme başarısız oldu", - "encryption_failed_warning": "Spotube, verilerinizi güvenli bir şekilde saklamak için şifreleme kullanır. Ama başaramadı. Bu yüzden güvensiz depolamaya geri dönecek\nLinux kullanıyorsanız, lütfen herhangi bir gizli servisin (gnome - anahtarlık, kde - cüzdan, keepassxc vb.) yüklü olduğundan emin olun", + "encryption_failed_warning": "Spotube, verilerinizi güvenli bir şekilde depolamak için şifreleme kullanır. Ancak bunu başaramadı. Bu nedenle, güvensiz depolamaya geri dönecektir\nLinux kullanıyorsanız, lütfen gnome-keyring, kde-wallet, keepassxc vb. herhangi bir gizli servisin yüklü olduğundan emin olun.", "querying_info": "Bilgi sorgulanıyor...", "piped_api_down": "Piped API kapalı", "piped_down_error_instructions": "Piped örneği {pipedInstance} şu anda kapalı\n\nÖrneği değiştirin veya 'API türünü' resmi YouTube API'si olarak değiştirin\n\nDeğişiklikten sonra uygulamayı yeniden başlattığınızdan emin olun", @@ -263,8 +263,8 @@ "connection_restored": "İnternet bağlantınız geri yüklendi", "use_system_title_bar": "Sistem başlık çubuğunu kullan", "crunching_results": "Sonuçlar...", - "search_to_get_results": "Sonuç almak için ara", - "use_amoled_mode": "AMOLED Modunu Kullan", + "search_to_get_results": "Sonuç almak için arayın", + "use_amoled_mode": "AMOLED modu kullan", "pitch_dark_theme": "Zifiri karanlık koyu tema", "normalize_audio": "Sesi normalleştir", "change_cover": "Kapağı değiştir", @@ -277,48 +277,112 @@ "disconnect_lastfm": "Last.fm bağlantısını kes", "disconnect": "Bağlantıyı kes", "username": "Kullanıcı adı", - "password": "Parola", - "login": "Giriş", + "password": "Şifre", + "login": "Giriş yap", "login_with_your_lastfm": "Last.fm hesabınızla giriş yapın", "scrobble_to_lastfm": "Last.fm için Scrobble", - "go_to_album": "Albüme Git", - "discord_rich_presence": "Discord Zengin Varlığı", - "browse_all": "Tümüne Göz At", - "genres": "Müzik Türleri", - "explore_genres": "Türleri Keşfet", + "go_to_album": "Albüme git", + "discord_rich_presence": "Discord zengin varlığı", + "browse_all": "Tümüne göz at", + "genres": "Müzik türleri", + "explore_genres": "Türleri keşfet", "friends": "Arkadaşlar", "no_lyrics_available": "Üzgünüz, bu parçanın sözleri bulunamıyor", - "start_a_radio": "Radyo Başlat", + "start_a_radio": "Radyo başlat", "how_to_start_radio": "Radyoyu nasıl başlatmak istersiniz?", "replace_queue_question": "Mevcut kuyruğu değiştirmek mi yoksa eklemek mi istersiniz?", - "endless_playback": "Sonsuz Olarak Oynat", - "delete_playlist": "Oynatma Listesini Sil", + "endless_playback": "Sonsuz olarak oynat", + "delete_playlist": "Oynatma listesini sil", "delete_playlist_confirmation": "Bu oynatma listesini silmek istediğinizden emin misiniz?", - "local_tracks": "Yerel Parçalar", - "song_link": "Şarkı Bağlantısı", + "local_tracks": "Yerel parçalar", + "song_link": "Şarkı bağlantısı", "skip_this_nonsense": "Bu saçmalığı atla", - "freedom_of_music": "“Müzik Özgürlüğü”", - "freedom_of_music_palm": "“Müzik Özgürlüğü avucunuzun içinde”", + "freedom_of_music": "“Müzik özgürlüğü”", + "freedom_of_music_palm": "“Müzik özgürlüğü avucunuzun içinde”", "get_started": "Haydi başlayalım", "youtube_source_description": "Tavsiye edilir ve en iyi şekilde çalışır.", - "piped_source_description": "Özgür hissediyor musunuz? YouTube ile aynı ama çok daha fazla ücretsiz.", + "piped_source_description": "Özgür hissediyor musunuz? YouTube ile aynı, ama çok daha özgür.", "jiosaavn_source_description": "Güney Asya bölgesi için en iyisi.", - "highest_quality": "En Yüksek Kalite: {quality}", - "select_audio_source": "Ses Kaynağını Seç", - "endless_playback_description": "Yeni şarkıları otomatik olarak \nkuyruğun sonuna ekle", + "highest_quality": "En yüksek kalite: {quality}", + "select_audio_source": "Ses kaynağını seçin", + "endless_playback_description": "Yeni şarkıları otomatik olarak\nkuyruğun sonuna ekle", "choose_your_region": "Bölgenizi seçin", - "choose_your_region_description": "Bu, Spotube'un size doğru içeriği göstermesine yardımcı olacaktır\nkonumunuz için.", + "choose_your_region_description": "Bu, Spotube'un konumunuza uygun içerikleri göstermesine yardımcı olacaktır.", "choose_your_language": "Dilinizi seçin", - "help_project_grow": "Bu projenin büyümesine yardımcı ol", + "help_project_grow": "Bu projenin büyümesine yardımcı olun", "help_project_grow_description": "Spotube açık kaynaklı bir projedir. Projeye katkıda bulunarak, hataları bildirerek veya yeni özellikler önererek bu projenin büyümesine yardımcı olabilirsiniz.", - "contribute_on_github": "GitHub'a katkıda bulunun", - "donate_on_open_collective": "Open Collective'e bağış yap", - "browse_anonymously": "Anonim Olarak Göz at", - "enable_connect": "Bağlantıyı Etkinleştir", + "contribute_on_github": "GitHub'da katkıda bulun", + "donate_on_open_collective": "Open Collective'de bağış yap", + "browse_anonymously": "Anonim olarak giriş yap", + "enable_connect": "Bağlanmayı etkinleştir", "enable_connect_description": "Spotube'u diğer cihazlardan kontrol edin", "devices": "Cihazlar", "select": "Seç", "connect_client_alert": "{client} tarafından kontrol ediliyorsun.", - "this_device": "Bu Cihaz", - "remote": "Yönet" + "this_device": "Bu cihaz", + "remote": "Yönet", + "local_library": "Yerel kütüphane", + "add_library_location": "Kütüphaneye ekle", + "remove_library_location": "Kütüphaneden çıkar", + "local_tab": "Yerel", + "stats": "İstatistikler", + "and_n_more": "ve {count} daha", + "recently_played": "Son Çalınanlar", + "browse_more": "Daha Fazla Göz At", + "no_title": "Başlık Yok", + "not_playing": "Çalmıyor", + "epic_failure": "Efsanevi başarısızlık!", + "added_num_tracks_to_queue": "{tracks_length} şarkı sıraya eklendi", + "spotube_has_an_update": "Spotube bir güncelleme aldı", + "download_now": "Şimdi İndir", + "nightly_version": "Spotube Nightly {nightlyBuildNum} yayımlandı", + "release_version": "Spotube v{version} yayımlandı", + "read_the_latest": "Son haberleri oku", + "release_notes": "sürüm notları", + "pick_color_scheme": "Renk şeması seç", + "save": "Kaydet", + "choose_the_device": "Cihazı seçin:", + "multiple_device_connected": "Birden fazla cihaz bağlı.\nBu işlemi gerçekleştirmek istediğiniz cihazı seçin", + "nothing_found": "Hiçbir şey bulunamadı", + "the_box_is_empty": "Kutu boş", + "top_artists": "En İyi Sanatçılar", + "top_albums": "En İyi Albümler", + "this_week": "Bu hafta", + "this_month": "Bu ay", + "last_6_months": "Son 6 ay", + "this_year": "Bu yıl", + "last_2_years": "Son 2 yıl", + "all_time": "Tüm zamanlar", + "powered_by_provider": "{providerName} tarafından desteklenmektedir", + "email": "E-posta", + "profile_followers": "Takipçiler", + "birthday": "Doğum Günü", + "subscription": "Abonelik", + "not_born": "Henüz doğmadı", + "hacker": "Hacker", + "profile": "Profil", + "no_name": "İsim Yok", + "edit": "Düzenle", + "user_profile": "Kullanıcı Profili", + "count_plays": "{count} çalma", + "streaming_fees_hypothetical": "*Spotify'ın akış başına ödeme miktarına\n$0.003 ile $0.005 arasında hesaplanmıştır. Bu, kullanıcıya\nSpotify'da şarkılarını dinlerse sanatçılara ne kadar ödeme\nyapmış olabileceğini göstermek için hipotetik bir hesaplamadır.", + "count_mins": "{minutes} dk", + "summary_minutes": "dakika", + "summary_listened_to_music": "Dinlenen müzik", + "summary_songs": "şarkılar", + "summary_streamed_overall": "Genel olarak akış", + "summary_owed_to_artists": "Sanatçılara borç\nbu ay", + "summary_artists": "sanatçının", + "summary_music_reached_you": "Müzik sana ulaştı", + "summary_full_albums": "tam albümler", + "summary_got_your_love": "Sevgini aldı", + "summary_playlists": "çalma listeleri", + "summary_were_on_repeat": "Tekrarda vardı", + "total_money": "Toplam {money}", + "minutes_listened": "Dinlenilen Dakikalar", + "streamed_songs": "Yayınlanan Şarkılar", + "count_streams": "{count} yayın", + "owned_by_you": "Sahip olduğunuz", + "copied_shareurl_to_clipboard": "{shareUrl} panoya kopyalandı", + "spotify_hipotetical_calculation": "*Bu, Spotify'ın her yayın başına ödemenin\n$0.003 ile $0.005 arasında olduğu varsayımıyla hesaplanmıştır. Bu\nhipotetik bir hesaplamadır, kullanıcıya şarkılarını Spotify'da dinlediklerinde\nsanatçılara ne kadar ödeme yapacaklarını gösterir." } \ No newline at end of file diff --git a/lib/l10n/app_uk.arb b/lib/l10n/app_uk.arb index 4208a3d2c..013a64b75 100644 --- a/lib/l10n/app_uk.arb +++ b/lib/l10n/app_uk.arb @@ -320,5 +320,69 @@ "select": "Вибрати", "connect_client_alert": "Вас керує {client}", "this_device": "Цей пристрій", - "remote": "Віддалений" + "remote": "Віддалений", + "local_library": "Місцева бібліотека", + "add_library_location": "Додати до бібліотеки", + "remove_library_location": "Видалити з бібліотеки", + "local_tab": "Місцевий", + "stats": "Статистика", + "and_n_more": "і {count} більше", + "recently_played": "Нещодавно Відтворене", + "browse_more": "Переглянути Більше", + "no_title": "Без Назви", + "not_playing": "Не Відтворюється", + "epic_failure": "Епічний провал!", + "added_num_tracks_to_queue": "Додано {tracks_length} треків до черги", + "spotube_has_an_update": "Spotube має оновлення", + "download_now": "Завантажити Зараз", + "nightly_version": "Spotube Nightly {nightlyBuildNum} було випущено", + "release_version": "Spotube v{version} було випущено", + "read_the_latest": "Читати останні новини", + "release_notes": "ноти про випуск", + "pick_color_scheme": "Оберіть кольорову схему", + "save": "Зберегти", + "choose_the_device": "Виберіть пристрій:", + "multiple_device_connected": "Підключено кілька пристроїв.\nВиберіть пристрій, на якому ви хочете виконати цю дію", + "nothing_found": "Нічого не знайдено", + "the_box_is_empty": "Коробка порожня", + "top_artists": "Топ Артисти", + "top_albums": "Топ Альбоми", + "this_week": "Цього тижня", + "this_month": "Цього місяця", + "last_6_months": "Останні 6 місяців", + "this_year": "Цього року", + "last_2_years": "Останні 2 роки", + "all_time": "Усі часи", + "powered_by_provider": "Забезпечено {providerName}", + "email": "Електронна пошта", + "profile_followers": "Підписники", + "birthday": "День народження", + "subscription": "Підписка", + "not_born": "Ще не народжений", + "hacker": "Хакер", + "profile": "Профіль", + "no_name": "Без імені", + "edit": "Редагувати", + "user_profile": "Профіль користувача", + "count_plays": "{count} відтворень", + "streaming_fees_hypothetical": "*Розраховано на основі виплат Spotify за стримінг\nвід $0.003 до $0.005. Це гіпотетичний\nрозрахунок, щоб дати уявлення користувачу про те, скільки б він\nзаплатив артистам, якби слухав їхні пісні на Spotify.", + "count_mins": "{minutes} хв", + "summary_minutes": "хвилини", + "summary_listened_to_music": "Прослухана музика", + "summary_songs": "пісні", + "summary_streamed_overall": "Загалом стримів", + "summary_owed_to_artists": "Заборгованість артистам\nцього місяця", + "summary_artists": "артистів", + "summary_music_reached_you": "Музика досягла вас", + "summary_full_albums": "повні альбоми", + "summary_got_your_love": "Отримав вашу любов", + "summary_playlists": "плейлисти", + "summary_were_on_repeat": "Були на повторі", + "total_money": "Загалом {money}", + "minutes_listened": "Хвилини прослуховування", + "streamed_songs": "Стримлені пісні", + "count_streams": "{count} стримів", + "owned_by_you": "Ваша власність", + "copied_shareurl_to_clipboard": "{shareUrl} скопійовано в буфер обміну", + "spotify_hipotetical_calculation": "*Це розраховано на основі виплат Spotify за стрім\nвід $0.003 до $0.005. Це гіпотетичний розрахунок,\nщоб дати користувачеві уявлення про те, скільки б він заплатив\nартистам, якби слухав їхні пісні на Spotify." } \ No newline at end of file diff --git a/lib/l10n/app_vi.arb b/lib/l10n/app_vi.arb index 6115fc0ce..5791793e0 100644 --- a/lib/l10n/app_vi.arb +++ b/lib/l10n/app_vi.arb @@ -320,5 +320,69 @@ "select": "Chọn", "connect_client_alert": "Bạn đang được điều khiển bởi {client}", "this_device": "Thiết bị này", - "remote": "Từ xa" + "remote": "Từ xa", + "local_library": "Thư viện địa phương", + "add_library_location": "Thêm vào thư viện", + "remove_library_location": "Xóa khỏi thư viện", + "local_tab": "Địa phương", + "stats": "Thống kê", + "and_n_more": "và {count} cái khác", + "recently_played": "Gần đây đã phát", + "browse_more": "Xem thêm", + "no_title": "Không có tiêu đề", + "not_playing": "Không phát", + "epic_failure": "Thất bại hoàn toàn!", + "added_num_tracks_to_queue": "Đã thêm {tracks_length} bài hát vào danh sách phát", + "spotube_has_an_update": "Spotube có bản cập nhật", + "download_now": "Tải về ngay", + "nightly_version": "Spotube Nightly {nightlyBuildNum} đã được phát hành", + "release_version": "Spotube v{version} đã được phát hành", + "read_the_latest": "Đọc tin mới nhất", + "release_notes": "ghi chú phát hành", + "pick_color_scheme": "Chọn chủ đề màu sắc", + "save": "Lưu", + "choose_the_device": "Chọn thiết bị:", + "multiple_device_connected": "Có nhiều thiết bị kết nối.\nChọn thiết bị mà bạn muốn thực hiện hành động này", + "nothing_found": "Không tìm thấy gì", + "the_box_is_empty": "Hộp trống", + "top_artists": "Những Nghệ Sĩ Hàng Đầu", + "top_albums": "Những Album Hàng Đầu", + "this_week": "Tuần này", + "this_month": "Tháng này", + "last_6_months": "6 tháng qua", + "this_year": "Năm nay", + "last_2_years": "2 năm qua", + "all_time": "Mọi thời đại", + "powered_by_provider": "Cung cấp bởi {providerName}", + "email": "Email", + "profile_followers": "Người theo dõi", + "birthday": "Ngày sinh", + "subscription": "Gói cước", + "not_born": "Chưa sinh", + "hacker": "Tin tặc", + "profile": "Hồ sơ", + "no_name": "Không có tên", + "edit": "Chỉnh sửa", + "user_profile": "Hồ sơ người dùng", + "count_plays": "{count} lần phát", + "streaming_fees_hypothetical": "*Tính toán dựa trên thanh toán của Spotify cho mỗi lần phát\ntừ $0.003 đến $0.005. Đây là một tính toán giả định để\ngive người dùng cái nhìn về số tiền họ sẽ chi trả cho các nghệ sĩ nếu họ nghe\nbài hát của họ trên Spotify.", + "count_mins": "{minutes} phút", + "summary_minutes": "phút", + "summary_listened_to_music": "Đã nghe nhạc", + "summary_songs": "bài hát", + "summary_streamed_overall": "Stream tổng cộng", + "summary_owed_to_artists": "Nợ nghệ sĩ\ntrong tháng này", + "summary_artists": "nghệ sĩ", + "summary_music_reached_you": "Âm nhạc đã đến với bạn", + "summary_full_albums": "album đầy đủ", + "summary_got_your_love": "Nhận được tình yêu của bạn", + "summary_playlists": "danh sách phát", + "summary_were_on_repeat": "Đã được phát lại", + "total_money": "Tổng cộng {money}", + "minutes_listened": "Thời gian nghe", + "streamed_songs": "Bài hát đã phát", + "count_streams": "{count} lượt phát", + "owned_by_you": "Thuộc sở hữu của bạn", + "copied_shareurl_to_clipboard": "{shareUrl} đã sao chép vào bảng tạm", + "spotify_hipotetical_calculation": "*Được tính toán dựa trên khoản thanh toán của Spotify cho mỗi lượt phát\ntừ $0.003 đến $0.005. Đây là một tính toán giả định để\ncung cấp cho người dùng cái nhìn về số tiền họ sẽ phải trả\ncho các nghệ sĩ nếu họ nghe bài hát của họ trên Spotify." } \ No newline at end of file diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index da5254a32..914472138 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -320,5 +320,69 @@ "select": "选择", "connect_client_alert": "您正在被 {client} 控制", "this_device": "此设备", - "remote": "远程" + "remote": "远程", + "local_library": "本地图书馆", + "add_library_location": "添加到图书馆", + "remove_library_location": "从图书馆中删除", + "local_tab": "本地", + "stats": "统计", + "and_n_more": "和 {count} 更多", + "recently_played": "最近播放", + "browse_more": "浏览更多", + "no_title": "没有标题", + "not_playing": "未播放", + "epic_failure": "史诗级失败!", + "added_num_tracks_to_queue": "已将 {tracks_length} 首曲目添加到队列", + "spotube_has_an_update": "Spotube 有更新", + "download_now": "立即下载", + "nightly_version": "Spotube Nightly {nightlyBuildNum} 已发布", + "release_version": "Spotube v{version} 已发布", + "read_the_latest": "阅读最新", + "release_notes": "版本说明", + "pick_color_scheme": "选择配色方案", + "save": "保存", + "choose_the_device": "选择设备:", + "multiple_device_connected": "已连接多个设备。\n选择您希望执行此操作的设备", + "nothing_found": "未找到任何内容", + "the_box_is_empty": "箱子为空", + "top_artists": "热门艺术家", + "top_albums": "热门专辑", + "this_week": "本周", + "this_month": "本月", + "last_6_months": "过去6个月", + "this_year": "今年", + "last_2_years": "过去2年", + "all_time": "所有时间", + "powered_by_provider": "由 {providerName} 提供支持", + "email": "电子邮件", + "profile_followers": "关注者", + "birthday": "生日", + "subscription": "订阅", + "not_born": "尚未出生", + "hacker": "黑客", + "profile": "个人资料", + "no_name": "无名", + "edit": "编辑", + "user_profile": "用户资料", + "count_plays": "{count} 次播放", + "streaming_fees_hypothetical": "*基于 Spotify 每次播放的支付金额\n从 $0.003 到 $0.005 计算。这是一个假设性的\n计算,旨在让用户了解如果他们在 Spotify 上收听\n这些歌曲,可能会付给艺术家的金额。", + "count_mins": "{minutes} 分钟", + "summary_minutes": "分钟", + "summary_listened_to_music": "听音乐", + "summary_songs": "歌曲", + "summary_streamed_overall": "总体流媒体", + "summary_owed_to_artists": "本月欠艺术家的", + "summary_artists": "艺术家的", + "summary_music_reached_you": "音乐触及了你", + "summary_full_albums": "完整专辑", + "summary_got_your_love": "获得了你的爱", + "summary_playlists": "播放列表", + "summary_were_on_repeat": "已重复播放", + "total_money": "总计 {money}", + "minutes_listened": "听的分钟数", + "streamed_songs": "已流媒体歌曲", + "count_streams": "{count} 次流媒体", + "owned_by_you": "由您拥有", + "copied_shareurl_to_clipboard": "{shareUrl} 已复制到剪贴板", + "spotify_hipotetical_calculation": "*根据 Spotify 每次流媒体的支付金额\n$0.003 到 $0.005 进行计算。这是一个假设性的\n计算,用于给用户了解他们如果在 Spotify 上\n收听歌曲会支付给艺术家的金额。" } \ No newline at end of file diff --git a/lib/l10n/l10n.dart b/lib/l10n/l10n.dart index ef3685fa3..ebdc4b618 100644 --- a/lib/l10n/l10n.dart +++ b/lib/l10n/l10n.dart @@ -7,7 +7,7 @@ /// TexturedPolak@github => Polish /// yuri-val@github => Ukrainian /// energywave@github, ncvescera@github, OpenCode@github => Italian -/// mdksec@github, mikropsoft@github => Turkish +/// mikropsoft@github => Turkish /// Stephan-P@github, SecularSteve@github => Dutch /// doannc2212@github => Vietnamese /// sappho192@github => Korean @@ -28,11 +28,14 @@ class L10n { const Locale('de', 'GE'), const Locale('es', 'ES'), const Locale('fa', 'IR'), + const Locale('fi', 'FI'), const Locale('fr', 'FR'), const Locale('ne', 'NP'), const Locale('hi', 'IN'), + const Locale('id', 'ID'), const Locale('it', 'IT'), const Locale('ja', 'JP'), + const Locale('ka', 'GE'), const Locale('ko', 'KR'), const Locale('nl', 'NL'), const Locale('pl', 'PL'), @@ -43,5 +46,6 @@ class L10n { const Locale('tr', 'TR'), const Locale('zh', 'CN'), const Locale('vi', 'VN'), + const Locale('eu', 'ES'), ]; } diff --git a/lib/main.dart b/lib/main.dart index 0bb72932f..64710f47c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,180 +1,137 @@ -import 'package:catcher_2/catcher_2.dart'; -import 'package:dart_discord_rpc/dart_discord_rpc.dart'; -import 'package:device_preview/device_preview.dart'; +import 'dart:async'; + +import 'package:desktop_webview_window/desktop_webview_window.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; +import 'package:flutter_discord_rpc/flutter_discord_rpc.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:hive/hive.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:local_notifier/local_notifier.dart'; import 'package:media_kit/media_kit.dart'; import 'package:metadata_god/metadata_god.dart'; -import 'package:shared_preferences/shared_preferences.dart'; +import 'package:smtc_windows/smtc_windows.dart'; +import 'package:spotube/collections/env.dart'; import 'package:spotube/collections/initializers.dart'; import 'package:spotube/collections/routes.dart'; import 'package:spotube/collections/intents.dart'; import 'package:spotube/hooks/configurators/use_close_behavior.dart'; import 'package:spotube/hooks/configurators/use_deep_linking.dart'; import 'package:spotube/hooks/configurators/use_disable_battery_optimizations.dart'; +import 'package:spotube/hooks/configurators/use_fix_window_stretching.dart'; import 'package:spotube/hooks/configurators/use_get_storage_perms.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/audio_player/audio_player_streams.dart'; +import 'package:spotube/provider/database/database.dart'; +import 'package:spotube/provider/server/bonsoir.dart'; +import 'package:spotube/provider/server/server.dart'; +import 'package:spotube/provider/tray_manager/tray_manager.dart'; import 'package:spotube/l10n/l10n.dart'; -import 'package:spotube/models/logger.dart'; -import 'package:spotube/models/skip_segment.dart'; -import 'package:spotube/models/source_match.dart'; import 'package:spotube/provider/connect/clients.dart'; -import 'package:spotube/provider/connect/server.dart'; import 'package:spotube/provider/palette_provider.dart'; -import 'package:spotube/provider/server/server.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; import 'package:spotube/services/cli/cli.dart'; +import 'package:spotube/services/kv_store/encrypted_kv_store.dart'; import 'package:spotube/services/kv_store/kv_store.dart'; +import 'package:spotube/services/logger/logger.dart'; +import 'package:spotube/services/wm_tools/wm_tools.dart'; import 'package:spotube/themes/theme.dart'; -import 'package:spotube/utils/persisted_state_notifier.dart'; +import 'package:spotube/utils/migrations/hive.dart'; +import 'package:spotube/utils/migrations/sandbox.dart'; +import 'package:spotube/utils/platform.dart'; import 'package:system_theme/system_theme.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:spotube/hooks/configurators/use_init_sys_tray.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_native_splash/flutter_native_splash.dart'; import 'package:flutter_displaymode/flutter_displaymode.dart'; import 'package:timezone/data/latest.dart' as tz; +import 'package:window_manager/window_manager.dart'; Future main(List rawArgs) async { + if (rawArgs.contains("web_view_title_bar")) { + WidgetsFlutterBinding.ensureInitialized(); + if (runWebViewTitleBarWidget(rawArgs)) { + return; + } + } final arguments = await startCLI(rawArgs); + AppLogger.initialize(arguments["verbose"]); - final widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); + AppLogger.runZoned(() async { + final widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); - await registerWindowsScheme("spotify"); + await registerWindowsScheme("spotify"); - tz.initializeTimeZones(); + tz.initializeTimeZones(); - FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding); + FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding); - MediaKit.ensureInitialized(); + MediaKit.ensureInitialized(); - // force High Refresh Rate on some Android devices (like One Plus) - if (DesktopTools.platform.isAndroid) { - await FlutterDisplayMode.setHighRefreshRate(); - } + await migrateMacOsFromSandboxToNoSandbox(); - if (DesktopTools.platform.isDesktop) { - await DesktopTools.window.setPreventClose(true); - } + // force High Refresh Rate on some Android devices (like One Plus) + if (kIsAndroid) { + await FlutterDisplayMode.setHighRefreshRate(); + } - await SystemTheme.accentColor.load(); + if (kIsDesktop) { + await windowManager.setPreventClose(true); + } - if (!kIsWeb) { - MetadataGod.initialize(); - } + await SystemTheme.accentColor.load(); - if (DesktopTools.platform.isWindows || DesktopTools.platform.isLinux) { - DiscordRPC.initialize(); - } + if (!kIsWeb) { + MetadataGod.initialize(); + } - await KVStoreService.initialize(); + if (kIsDesktop) { + await FlutterDiscordRPC.initialize(Env.discordAppId); + } - final hiveCacheDir = - kIsWeb ? null : (await getApplicationSupportDirectory()).path; + if(kIsWindows){ + await SMTCWindows.initialize(); + } - Hive.init(hiveCacheDir); + await KVStoreService.initialize(); + await EncryptedKvStoreService.initialize(); - Hive.registerAdapter(SkipSegmentAdapter()); + final hiveCacheDir = + kIsWeb ? null : (await getApplicationSupportDirectory()).path; - Hive.registerAdapter(SourceMatchAdapter()); - Hive.registerAdapter(SourceTypeAdapter()); + Hive.init(hiveCacheDir); - // Cache versioning entities with Adapter - SourceMatch.version = 'v1'; - SkipSegment.version = 'v1'; + final database = AppDatabase(); - await Hive.openLazyBox( - SourceMatch.boxName, - path: hiveCacheDir, - ); - await Hive.openLazyBox( - SkipSegment.boxName, - path: hiveCacheDir, - ); - await PersistedStateNotifier.initializeBoxes( - path: hiveCacheDir, - ); + await migrateFromHiveToDrift(database); - await DesktopTools.ensureInitialized( - DesktopWindowOptions( - hideTitleBar: true, - title: "Spotube", - backgroundColor: Colors.transparent, - minimumSize: const Size(300, 700), - ), - ); + if (kIsDesktop) { + await localNotifier.setup(appName: "Spotube"); + await WindowManagerTools.initialize(); + } - Catcher2( - enableLogger: arguments["verbose"], - debugConfig: Catcher2Options( - SilentReportMode(), - [ - ConsoleHandler( - enableDeviceParameters: false, - enableApplicationParameters: false, - ), - if (!kIsWeb) FileHandler(await getLogsPath(), printLogs: false), - ], - ), - releaseConfig: Catcher2Options( - SilentReportMode(), - [ - if (arguments["verbose"] ?? false) ConsoleHandler(), - if (!kIsWeb) - FileHandler( - await getLogsPath(), - printLogs: false, - ), - ], - ), - runAppFunction: () { - runApp( - ProviderScope( - child: DevicePreview( - availableLocales: L10n.all, - enabled: false, - data: const DevicePreviewData( - isEnabled: false, - orientation: Orientation.portrait, - ), - builder: (context) { - return const Spotube(); - }, - ), - ), - ); - }, - ); + runApp( + ProviderScope( + overrides: [ + databaseProvider.overrideWith((ref) => database), + ], + observers: const [ + AppLoggerProviderObserver(), + ], + child: const Spotube(), + ), + ); + }); } -class Spotube extends StatefulHookConsumerWidget { +class Spotube extends HookConsumerWidget { const Spotube({super.key}); @override - SpotubeState createState() => SpotubeState(); - - static SpotubeState of(BuildContext context) => - context.findAncestorStateOfType()!; -} - -class SpotubeState extends ConsumerState { - final logger = getLogger(Spotube); - SharedPreferences? localStorage; - - @override - void initState() { - super.initState(); - SharedPreferences.getInstance().then(((value) => localStorage = value)); - } - - @override - Widget build(BuildContext context) { + Widget build(BuildContext context, ref) { final themeMode = ref.watch(userPreferencesProvider.select((s) => s.themeMode)); final accentMaterialColor = @@ -186,18 +143,21 @@ class SpotubeState extends ConsumerState { ref.watch(paletteProvider.select((s) => s?.dominantColor?.color)); final router = ref.watch(routerProvider); - ref.listen(playbackServerProvider, (_, __) {}); - ref.listen(connectServerProvider, (_, __) {}); + ref.listen(audioPlayerStreamListenersProvider, (_, __) {}); + ref.listen(bonsoirProvider, (_, __) {}); ref.listen(connectClientsProvider, (_, __) {}); + ref.listen(serverProvider, (_, __) {}); + ref.listen(trayManagerProvider, (_, __) {}); + useFixWindowStretching(); useDisableBatteryOptimizations(); - useInitSysTray(ref); useDeepLinking(ref); useCloseBehavior(ref); useGetStoragePermissions(ref); useEffect(() { FlutterNativeSplash.remove(); + return () { /// For enabling hot reload for audio player if (!kDebugMode) return; @@ -231,12 +191,8 @@ class SpotubeState extends ConsumerState { debugShowCheckedModeBanner: false, title: 'Spotube', builder: (context, child) { - return DevicePreview.appBuilder( - context, - DesktopTools.platform.isDesktop && !DesktopTools.platform.isMacOS - ? DragToResizeArea(child: child!) - : child, - ); + if (kIsDesktop && !kIsMacOS) return DragToResizeArea(child: child!); + return child!; }, themeMode: themeMode, theme: lightTheme, diff --git a/lib/models/connect/connect.dart b/lib/models/connect/connect.dart index efb373150..a70520ad6 100644 --- a/lib/models/connect/connect.dart +++ b/lib/models/connect/connect.dart @@ -4,10 +4,9 @@ import 'dart:async'; import 'dart:convert'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:spotify/spotify.dart'; -import 'package:spotube/extensions/track.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist.dart'; -import 'package:spotube/services/audio_player/loop_mode.dart'; +import 'package:media_kit/media_kit.dart' hide Track; +import 'package:spotify/spotify.dart' hide Playlist; +import 'package:spotube/provider/audio_player/state.dart'; part 'connect.freezed.dart'; part 'connect.g.dart'; diff --git a/lib/models/connect/connect.freezed.dart b/lib/models/connect/connect.freezed.dart index dcbd783dc..088cfbd1a 100644 --- a/lib/models/connect/connect.freezed.dart +++ b/lib/models/connect/connect.freezed.dart @@ -12,20 +12,93 @@ part of 'connect.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); WebSocketLoadEventData _$WebSocketLoadEventDataFromJson( Map json) { - return _WebSocketLoadEventData.fromJson(json); + switch (json['runtimeType']) { + case 'playlist': + return WebSocketLoadEventDataPlaylist.fromJson(json); + case 'album': + return WebSocketLoadEventDataAlbum.fromJson(json); + + default: + throw CheckedFromJsonException( + json, + 'runtimeType', + 'WebSocketLoadEventData', + 'Invalid union type "${json['runtimeType']}"!'); + } } /// @nodoc mixin _$WebSocketLoadEventData { @JsonKey(name: 'tracks', toJson: _tracksJson) List get tracks => throw _privateConstructorUsedError; - String? get collectionId => throw _privateConstructorUsedError; + Object? get collection => throw _privateConstructorUsedError; int? get initialIndex => throw _privateConstructorUsedError; - + @optionalTypeArgs + TResult when({ + required TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + PlaylistSimple? collection, + int? initialIndex) + playlist, + required TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + AlbumSimple? collection, + int? initialIndex) + album, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + PlaylistSimple? collection, + int? initialIndex)? + playlist, + TResult? Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + AlbumSimple? collection, + int? initialIndex)? + album, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + PlaylistSimple? collection, + int? initialIndex)? + playlist, + TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + AlbumSimple? collection, + int? initialIndex)? + album, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(WebSocketLoadEventDataPlaylist value) playlist, + required TResult Function(WebSocketLoadEventDataAlbum value) album, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(WebSocketLoadEventDataPlaylist value)? playlist, + TResult? Function(WebSocketLoadEventDataAlbum value)? album, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(WebSocketLoadEventDataPlaylist value)? playlist, + TResult Function(WebSocketLoadEventDataAlbum value)? album, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) $WebSocketLoadEventDataCopyWith get copyWith => @@ -40,7 +113,6 @@ abstract class $WebSocketLoadEventDataCopyWith<$Res> { @useResult $Res call( {@JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, - String? collectionId, int? initialIndex}); } @@ -59,7 +131,6 @@ class _$WebSocketLoadEventDataCopyWithImpl<$Res, @override $Res call({ Object? tracks = null, - Object? collectionId = freezed, Object? initialIndex = freezed, }) { return _then(_value.copyWith( @@ -67,10 +138,6 @@ class _$WebSocketLoadEventDataCopyWithImpl<$Res, ? _value.tracks : tracks // ignore: cast_nullable_to_non_nullable as List, - collectionId: freezed == collectionId - ? _value.collectionId - : collectionId // ignore: cast_nullable_to_non_nullable - as String?, initialIndex: freezed == initialIndex ? _value.initialIndex : initialIndex // ignore: cast_nullable_to_non_nullable @@ -80,46 +147,279 @@ class _$WebSocketLoadEventDataCopyWithImpl<$Res, } /// @nodoc -abstract class _$$WebSocketLoadEventDataImplCopyWith<$Res> +abstract class _$$WebSocketLoadEventDataPlaylistImplCopyWith<$Res> + implements $WebSocketLoadEventDataCopyWith<$Res> { + factory _$$WebSocketLoadEventDataPlaylistImplCopyWith( + _$WebSocketLoadEventDataPlaylistImpl value, + $Res Function(_$WebSocketLoadEventDataPlaylistImpl) then) = + __$$WebSocketLoadEventDataPlaylistImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + PlaylistSimple? collection, + int? initialIndex}); +} + +/// @nodoc +class __$$WebSocketLoadEventDataPlaylistImplCopyWithImpl<$Res> + extends _$WebSocketLoadEventDataCopyWithImpl<$Res, + _$WebSocketLoadEventDataPlaylistImpl> + implements _$$WebSocketLoadEventDataPlaylistImplCopyWith<$Res> { + __$$WebSocketLoadEventDataPlaylistImplCopyWithImpl( + _$WebSocketLoadEventDataPlaylistImpl _value, + $Res Function(_$WebSocketLoadEventDataPlaylistImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? tracks = null, + Object? collection = freezed, + Object? initialIndex = freezed, + }) { + return _then(_$WebSocketLoadEventDataPlaylistImpl( + tracks: null == tracks + ? _value._tracks + : tracks // ignore: cast_nullable_to_non_nullable + as List, + collection: freezed == collection + ? _value.collection + : collection // ignore: cast_nullable_to_non_nullable + as PlaylistSimple?, + initialIndex: freezed == initialIndex + ? _value.initialIndex + : initialIndex // ignore: cast_nullable_to_non_nullable + as int?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$WebSocketLoadEventDataPlaylistImpl + extends WebSocketLoadEventDataPlaylist { + _$WebSocketLoadEventDataPlaylistImpl( + {@JsonKey(name: 'tracks', toJson: _tracksJson) + required final List tracks, + this.collection, + this.initialIndex, + final String? $type}) + : _tracks = tracks, + $type = $type ?? 'playlist', + super._(); + + factory _$WebSocketLoadEventDataPlaylistImpl.fromJson( + Map json) => + _$$WebSocketLoadEventDataPlaylistImplFromJson(json); + + final List _tracks; + @override + @JsonKey(name: 'tracks', toJson: _tracksJson) + List get tracks { + if (_tracks is EqualUnmodifiableListView) return _tracks; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_tracks); + } + + @override + final PlaylistSimple? collection; + @override + final int? initialIndex; + + @JsonKey(name: 'runtimeType') + final String $type; + + @override + String toString() { + return 'WebSocketLoadEventData.playlist(tracks: $tracks, collection: $collection, initialIndex: $initialIndex)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$WebSocketLoadEventDataPlaylistImpl && + const DeepCollectionEquality().equals(other._tracks, _tracks) && + (identical(other.collection, collection) || + other.collection == collection) && + (identical(other.initialIndex, initialIndex) || + other.initialIndex == initialIndex)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, + const DeepCollectionEquality().hash(_tracks), collection, initialIndex); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$WebSocketLoadEventDataPlaylistImplCopyWith< + _$WebSocketLoadEventDataPlaylistImpl> + get copyWith => __$$WebSocketLoadEventDataPlaylistImplCopyWithImpl< + _$WebSocketLoadEventDataPlaylistImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + PlaylistSimple? collection, + int? initialIndex) + playlist, + required TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + AlbumSimple? collection, + int? initialIndex) + album, + }) { + return playlist(tracks, collection, initialIndex); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + PlaylistSimple? collection, + int? initialIndex)? + playlist, + TResult? Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + AlbumSimple? collection, + int? initialIndex)? + album, + }) { + return playlist?.call(tracks, collection, initialIndex); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + PlaylistSimple? collection, + int? initialIndex)? + playlist, + TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + AlbumSimple? collection, + int? initialIndex)? + album, + required TResult orElse(), + }) { + if (playlist != null) { + return playlist(tracks, collection, initialIndex); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(WebSocketLoadEventDataPlaylist value) playlist, + required TResult Function(WebSocketLoadEventDataAlbum value) album, + }) { + return playlist(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(WebSocketLoadEventDataPlaylist value)? playlist, + TResult? Function(WebSocketLoadEventDataAlbum value)? album, + }) { + return playlist?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(WebSocketLoadEventDataPlaylist value)? playlist, + TResult Function(WebSocketLoadEventDataAlbum value)? album, + required TResult orElse(), + }) { + if (playlist != null) { + return playlist(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$WebSocketLoadEventDataPlaylistImplToJson( + this, + ); + } +} + +abstract class WebSocketLoadEventDataPlaylist extends WebSocketLoadEventData { + factory WebSocketLoadEventDataPlaylist( + {@JsonKey(name: 'tracks', toJson: _tracksJson) + required final List tracks, + final PlaylistSimple? collection, + final int? initialIndex}) = _$WebSocketLoadEventDataPlaylistImpl; + WebSocketLoadEventDataPlaylist._() : super._(); + + factory WebSocketLoadEventDataPlaylist.fromJson(Map json) = + _$WebSocketLoadEventDataPlaylistImpl.fromJson; + + @override + @JsonKey(name: 'tracks', toJson: _tracksJson) + List get tracks; + @override + PlaylistSimple? get collection; + @override + int? get initialIndex; + @override + @JsonKey(ignore: true) + _$$WebSocketLoadEventDataPlaylistImplCopyWith< + _$WebSocketLoadEventDataPlaylistImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$WebSocketLoadEventDataAlbumImplCopyWith<$Res> implements $WebSocketLoadEventDataCopyWith<$Res> { - factory _$$WebSocketLoadEventDataImplCopyWith( - _$WebSocketLoadEventDataImpl value, - $Res Function(_$WebSocketLoadEventDataImpl) then) = - __$$WebSocketLoadEventDataImplCopyWithImpl<$Res>; + factory _$$WebSocketLoadEventDataAlbumImplCopyWith( + _$WebSocketLoadEventDataAlbumImpl value, + $Res Function(_$WebSocketLoadEventDataAlbumImpl) then) = + __$$WebSocketLoadEventDataAlbumImplCopyWithImpl<$Res>; @override @useResult $Res call( {@JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, - String? collectionId, + AlbumSimple? collection, int? initialIndex}); } /// @nodoc -class __$$WebSocketLoadEventDataImplCopyWithImpl<$Res> +class __$$WebSocketLoadEventDataAlbumImplCopyWithImpl<$Res> extends _$WebSocketLoadEventDataCopyWithImpl<$Res, - _$WebSocketLoadEventDataImpl> - implements _$$WebSocketLoadEventDataImplCopyWith<$Res> { - __$$WebSocketLoadEventDataImplCopyWithImpl( - _$WebSocketLoadEventDataImpl _value, - $Res Function(_$WebSocketLoadEventDataImpl) _then) + _$WebSocketLoadEventDataAlbumImpl> + implements _$$WebSocketLoadEventDataAlbumImplCopyWith<$Res> { + __$$WebSocketLoadEventDataAlbumImplCopyWithImpl( + _$WebSocketLoadEventDataAlbumImpl _value, + $Res Function(_$WebSocketLoadEventDataAlbumImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @override $Res call({ Object? tracks = null, - Object? collectionId = freezed, + Object? collection = freezed, Object? initialIndex = freezed, }) { - return _then(_$WebSocketLoadEventDataImpl( + return _then(_$WebSocketLoadEventDataAlbumImpl( tracks: null == tracks ? _value._tracks : tracks // ignore: cast_nullable_to_non_nullable as List, - collectionId: freezed == collectionId - ? _value.collectionId - : collectionId // ignore: cast_nullable_to_non_nullable - as String?, + collection: freezed == collection + ? _value.collection + : collection // ignore: cast_nullable_to_non_nullable + as AlbumSimple?, initialIndex: freezed == initialIndex ? _value.initialIndex : initialIndex // ignore: cast_nullable_to_non_nullable @@ -130,16 +430,20 @@ class __$$WebSocketLoadEventDataImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$WebSocketLoadEventDataImpl implements _WebSocketLoadEventData { - _$WebSocketLoadEventDataImpl( +class _$WebSocketLoadEventDataAlbumImpl extends WebSocketLoadEventDataAlbum { + _$WebSocketLoadEventDataAlbumImpl( {@JsonKey(name: 'tracks', toJson: _tracksJson) required final List tracks, - this.collectionId, - this.initialIndex}) - : _tracks = tracks; + this.collection, + this.initialIndex, + final String? $type}) + : _tracks = tracks, + $type = $type ?? 'album', + super._(); - factory _$WebSocketLoadEventDataImpl.fromJson(Map json) => - _$$WebSocketLoadEventDataImplFromJson(json); + factory _$WebSocketLoadEventDataAlbumImpl.fromJson( + Map json) => + _$$WebSocketLoadEventDataAlbumImplFromJson(json); final List _tracks; @override @@ -151,23 +455,26 @@ class _$WebSocketLoadEventDataImpl implements _WebSocketLoadEventData { } @override - final String? collectionId; + final AlbumSimple? collection; @override final int? initialIndex; + @JsonKey(name: 'runtimeType') + final String $type; + @override String toString() { - return 'WebSocketLoadEventData(tracks: $tracks, collectionId: $collectionId, initialIndex: $initialIndex)'; + return 'WebSocketLoadEventData.album(tracks: $tracks, collection: $collection, initialIndex: $initialIndex)'; } @override bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$WebSocketLoadEventDataImpl && + other is _$WebSocketLoadEventDataAlbumImpl && const DeepCollectionEquality().equals(other._tracks, _tracks) && - (identical(other.collectionId, collectionId) || - other.collectionId == collectionId) && + (identical(other.collection, collection) || + other.collection == collection) && (identical(other.initialIndex, initialIndex) || other.initialIndex == initialIndex)); } @@ -175,42 +482,129 @@ class _$WebSocketLoadEventDataImpl implements _WebSocketLoadEventData { @JsonKey(ignore: true) @override int get hashCode => Object.hash(runtimeType, - const DeepCollectionEquality().hash(_tracks), collectionId, initialIndex); + const DeepCollectionEquality().hash(_tracks), collection, initialIndex); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$WebSocketLoadEventDataImplCopyWith<_$WebSocketLoadEventDataImpl> - get copyWith => __$$WebSocketLoadEventDataImplCopyWithImpl< - _$WebSocketLoadEventDataImpl>(this, _$identity); + _$$WebSocketLoadEventDataAlbumImplCopyWith<_$WebSocketLoadEventDataAlbumImpl> + get copyWith => __$$WebSocketLoadEventDataAlbumImplCopyWithImpl< + _$WebSocketLoadEventDataAlbumImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + PlaylistSimple? collection, + int? initialIndex) + playlist, + required TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + AlbumSimple? collection, + int? initialIndex) + album, + }) { + return album(tracks, collection, initialIndex); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + PlaylistSimple? collection, + int? initialIndex)? + playlist, + TResult? Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + AlbumSimple? collection, + int? initialIndex)? + album, + }) { + return album?.call(tracks, collection, initialIndex); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + PlaylistSimple? collection, + int? initialIndex)? + playlist, + TResult Function( + @JsonKey(name: 'tracks', toJson: _tracksJson) List tracks, + AlbumSimple? collection, + int? initialIndex)? + album, + required TResult orElse(), + }) { + if (album != null) { + return album(tracks, collection, initialIndex); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(WebSocketLoadEventDataPlaylist value) playlist, + required TResult Function(WebSocketLoadEventDataAlbum value) album, + }) { + return album(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(WebSocketLoadEventDataPlaylist value)? playlist, + TResult? Function(WebSocketLoadEventDataAlbum value)? album, + }) { + return album?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(WebSocketLoadEventDataPlaylist value)? playlist, + TResult Function(WebSocketLoadEventDataAlbum value)? album, + required TResult orElse(), + }) { + if (album != null) { + return album(this); + } + return orElse(); + } @override Map toJson() { - return _$$WebSocketLoadEventDataImplToJson( + return _$$WebSocketLoadEventDataAlbumImplToJson( this, ); } } -abstract class _WebSocketLoadEventData implements WebSocketLoadEventData { - factory _WebSocketLoadEventData( +abstract class WebSocketLoadEventDataAlbum extends WebSocketLoadEventData { + factory WebSocketLoadEventDataAlbum( {@JsonKey(name: 'tracks', toJson: _tracksJson) required final List tracks, - final String? collectionId, - final int? initialIndex}) = _$WebSocketLoadEventDataImpl; + final AlbumSimple? collection, + final int? initialIndex}) = _$WebSocketLoadEventDataAlbumImpl; + WebSocketLoadEventDataAlbum._() : super._(); - factory _WebSocketLoadEventData.fromJson(Map json) = - _$WebSocketLoadEventDataImpl.fromJson; + factory WebSocketLoadEventDataAlbum.fromJson(Map json) = + _$WebSocketLoadEventDataAlbumImpl.fromJson; @override @JsonKey(name: 'tracks', toJson: _tracksJson) List get tracks; @override - String? get collectionId; + AlbumSimple? get collection; @override int? get initialIndex; @override @JsonKey(ignore: true) - _$$WebSocketLoadEventDataImplCopyWith<_$WebSocketLoadEventDataImpl> + _$$WebSocketLoadEventDataAlbumImplCopyWith<_$WebSocketLoadEventDataAlbumImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/lib/models/connect/connect.g.dart b/lib/models/connect/connect.g.dart index f636e0350..f297024b9 100644 --- a/lib/models/connect/connect.g.dart +++ b/lib/models/connect/connect.g.dart @@ -6,20 +6,48 @@ part of 'connect.dart'; // JsonSerializableGenerator // ************************************************************************** -_$WebSocketLoadEventDataImpl _$$WebSocketLoadEventDataImplFromJson( - Map json) => - _$WebSocketLoadEventDataImpl( +_$WebSocketLoadEventDataPlaylistImpl + _$$WebSocketLoadEventDataPlaylistImplFromJson(Map json) => + _$WebSocketLoadEventDataPlaylistImpl( + tracks: (json['tracks'] as List) + .map((e) => Track.fromJson(Map.from(e as Map))) + .toList(), + collection: json['collection'] == null + ? null + : PlaylistSimple.fromJson( + Map.from(json['collection'] as Map)), + initialIndex: json['initialIndex'] as int?, + $type: json['runtimeType'] as String?, + ); + +Map _$$WebSocketLoadEventDataPlaylistImplToJson( + _$WebSocketLoadEventDataPlaylistImpl instance) => + { + 'tracks': _tracksJson(instance.tracks), + 'collection': instance.collection?.toJson(), + 'initialIndex': instance.initialIndex, + 'runtimeType': instance.$type, + }; + +_$WebSocketLoadEventDataAlbumImpl _$$WebSocketLoadEventDataAlbumImplFromJson( + Map json) => + _$WebSocketLoadEventDataAlbumImpl( tracks: (json['tracks'] as List) - .map((e) => Track.fromJson(e as Map)) + .map((e) => Track.fromJson(Map.from(e as Map))) .toList(), - collectionId: json['collectionId'] as String?, + collection: json['collection'] == null + ? null + : AlbumSimple.fromJson( + Map.from(json['collection'] as Map)), initialIndex: json['initialIndex'] as int?, + $type: json['runtimeType'] as String?, ); -Map _$$WebSocketLoadEventDataImplToJson( - _$WebSocketLoadEventDataImpl instance) => +Map _$$WebSocketLoadEventDataAlbumImplToJson( + _$WebSocketLoadEventDataAlbumImpl instance) => { 'tracks': _tracksJson(instance.tracks), - 'collectionId': instance.collectionId, + 'collection': instance.collection?.toJson(), 'initialIndex': instance.initialIndex, + 'runtimeType': instance.$type, }; diff --git a/lib/models/connect/load.dart b/lib/models/connect/load.dart index d750cddd2..bf0e164db 100644 --- a/lib/models/connect/load.dart +++ b/lib/models/connect/load.dart @@ -6,14 +6,27 @@ List> _tracksJson(List tracks) { @freezed class WebSocketLoadEventData with _$WebSocketLoadEventData { - factory WebSocketLoadEventData({ + const WebSocketLoadEventData._(); + + factory WebSocketLoadEventData.playlist({ @JsonKey(name: 'tracks', toJson: _tracksJson) required List tracks, - String? collectionId, + PlaylistSimple? collection, int? initialIndex, - }) = _WebSocketLoadEventData; + }) = WebSocketLoadEventDataPlaylist; + + factory WebSocketLoadEventData.album({ + @JsonKey(name: 'tracks', toJson: _tracksJson) required List tracks, + AlbumSimple? collection, + int? initialIndex, + }) = WebSocketLoadEventDataAlbum; factory WebSocketLoadEventData.fromJson(Map json) => _$WebSocketLoadEventDataFromJson(json); + + String? get collectionId => when( + playlist: (tracks, collection, _) => collection?.id, + album: (tracks, collection, _) => collection?.id, + ); } class WebSocketLoadEvent extends WebSocketEvent { diff --git a/lib/models/connect/ws_event.dart b/lib/models/connect/ws_event.dart index 2d7213b1b..d10476461 100644 --- a/lib/models/connect/ws_event.dart +++ b/lib/models/connect/ws_event.dart @@ -183,7 +183,7 @@ class WebSocketEvent { if (type == WsEvent.loop) { await callback( WebSocketLoopEvent( - PlaybackLoopMode.fromString(data as String), + PlaylistMode.values.firstWhere((e) => e.name == data as String), ), ); } @@ -224,12 +224,16 @@ class WebSocketEvent { } } -class WebSocketLoopEvent extends WebSocketEvent { - WebSocketLoopEvent(PlaybackLoopMode data) : super(WsEvent.loop, data); +class WebSocketLoopEvent extends WebSocketEvent { + WebSocketLoopEvent(PlaylistMode data) : super(WsEvent.loop, data); WebSocketLoopEvent.fromJson(Map json) : super( - WsEvent.loop, PlaybackLoopMode.fromString(json["data"] as String)); + WsEvent.loop, + PlaylistMode.values.firstWhere( + (e) => e.name == json["data"] as String, + ), + ); @override String toJson() { @@ -321,12 +325,12 @@ class WebSocketErrorEvent extends WebSocketEvent { WebSocketErrorEvent(String data) : super(WsEvent.error, data); } -class WebSocketQueueEvent extends WebSocketEvent { - WebSocketQueueEvent(ProxyPlaylist data) : super(WsEvent.queue, data); +class WebSocketQueueEvent extends WebSocketEvent { + WebSocketQueueEvent(AudioPlayerState data) : super(WsEvent.queue, data); factory WebSocketQueueEvent.fromJson(Map json) => WebSocketQueueEvent( - ProxyPlaylist.fromJsonRaw(json), + AudioPlayerState.fromJson(json), ); } diff --git a/lib/models/current_playlist.dart b/lib/models/current_playlist.dart index 53ea2799b..7e55e3939 100644 --- a/lib/models/current_playlist.dart +++ b/lib/models/current_playlist.dart @@ -1,6 +1,5 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/extensions/track.dart'; import 'package:spotube/services/sourced_track/sourced_track.dart'; class CurrentPlaylist { diff --git a/lib/models/database/database.dart b/lib/models/database/database.dart new file mode 100644 index 000000000..412e68683 --- /dev/null +++ b/lib/models/database/database.dart @@ -0,0 +1,85 @@ +library database; + +import 'dart:convert'; +import 'dart:io'; + +import 'package:drift/drift.dart'; +import 'package:encrypt/encrypt.dart'; +import 'package:media_kit/media_kit.dart' hide Track; +import 'package:path/path.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:spotify/spotify.dart' hide Playlist; +import 'package:spotube/models/lyrics.dart'; +import 'package:spotube/services/kv_store/encrypted_kv_store.dart'; +import 'package:spotube/services/kv_store/kv_store.dart'; +import 'package:spotube/services/sourced_track/enums.dart'; +import 'package:flutter/material.dart' hide Table, Key, View; +import 'package:spotube/modules/settings/color_scheme_picker_dialog.dart'; +import 'package:drift/native.dart'; +import 'package:sqlite3/sqlite3.dart'; +import 'package:sqlite3_flutter_libs/sqlite3_flutter_libs.dart'; + +part 'database.g.dart'; + +part 'tables/authentication.dart'; +part 'tables/blacklist.dart'; +part 'tables/preferences.dart'; +part 'tables/scrobbler.dart'; +part 'tables/skip_segment.dart'; +part 'tables/source_match.dart'; +part 'tables/audio_player_state.dart'; +part 'tables/history.dart'; +part 'tables/lyrics.dart'; + +part 'typeconverters/color.dart'; +part 'typeconverters/locale.dart'; +part 'typeconverters/string_list.dart'; +part 'typeconverters/encrypted_text.dart'; +part 'typeconverters/map.dart'; +part 'typeconverters/subtitle.dart'; + +@DriftDatabase( + tables: [ + AuthenticationTable, + BlacklistTable, + PreferencesTable, + ScrobblerTable, + SkipSegmentTable, + SourceMatchTable, + AudioPlayerStateTable, + PlaylistTable, + PlaylistMediaTable, + HistoryTable, + LyricsTable, + ], +) +class AppDatabase extends _$AppDatabase { + AppDatabase() : super(_openConnection()); + + @override + int get schemaVersion => 1; +} + +LazyDatabase _openConnection() { + // the LazyDatabase util lets us find the right location for the file async. + return LazyDatabase(() async { + // put the database file, called db.sqlite here, into the documents folder + // for your app. + final dbFolder = await getApplicationSupportDirectory(); + final file = File(join(dbFolder.path, 'db.sqlite')); + + // Also work around limitations on old Android versions + if (Platform.isAndroid) { + await applyWorkaroundToOpenSqlite3OnOldAndroidVersions(); + } + + // Make sqlite3 pick a more suitable location for temporary files - the + // one from the system may be inaccessible due to sandboxing. + final cacheBase = (await getTemporaryDirectory()).path; + // We can't access /tmp on Android, which sqlite3 would try by default. + // Explicitly tell it about the correct temporary directory. + sqlite3.tempDirectory = cacheBase; + + return NativeDatabase.createInBackground(file); + }); +} diff --git a/lib/models/database/database.g.dart b/lib/models/database/database.g.dart new file mode 100644 index 000000000..1e585fa87 --- /dev/null +++ b/lib/models/database/database.g.dart @@ -0,0 +1,5841 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'database.dart'; + +// ignore_for_file: type=lint +class $AuthenticationTableTable extends AuthenticationTable + with TableInfo<$AuthenticationTableTable, AuthenticationTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $AuthenticationTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _cookieMeta = const VerificationMeta('cookie'); + @override + late final GeneratedColumnWithTypeConverter cookie = + GeneratedColumn('cookie', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter( + $AuthenticationTableTable.$convertercookie); + static const VerificationMeta _accessTokenMeta = + const VerificationMeta('accessToken'); + @override + late final GeneratedColumnWithTypeConverter + accessToken = GeneratedColumn('access_token', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter( + $AuthenticationTableTable.$converteraccessToken); + static const VerificationMeta _expirationMeta = + const VerificationMeta('expiration'); + @override + late final GeneratedColumn expiration = GeneratedColumn( + 'expiration', aliasedName, false, + type: DriftSqlType.dateTime, requiredDuringInsert: true); + @override + List get $columns => [id, cookie, accessToken, expiration]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'authentication_table'; + @override + VerificationContext validateIntegrity( + Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + context.handle(_cookieMeta, const VerificationResult.success()); + context.handle(_accessTokenMeta, const VerificationResult.success()); + if (data.containsKey('expiration')) { + context.handle( + _expirationMeta, + expiration.isAcceptableOrUnknown( + data['expiration']!, _expirationMeta)); + } else if (isInserting) { + context.missing(_expirationMeta); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + AuthenticationTableData map(Map data, + {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return AuthenticationTableData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + cookie: $AuthenticationTableTable.$convertercookie.fromSql( + attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}cookie'])!), + accessToken: $AuthenticationTableTable.$converteraccessToken.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}access_token'])!), + expiration: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}expiration'])!, + ); + } + + @override + $AuthenticationTableTable createAlias(String alias) { + return $AuthenticationTableTable(attachedDatabase, alias); + } + + static TypeConverter $convertercookie = + EncryptedTextConverter(); + static TypeConverter $converteraccessToken = + EncryptedTextConverter(); +} + +class AuthenticationTableData extends DataClass + implements Insertable { + final int id; + final DecryptedText cookie; + final DecryptedText accessToken; + final DateTime expiration; + const AuthenticationTableData( + {required this.id, + required this.cookie, + required this.accessToken, + required this.expiration}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + { + map['cookie'] = Variable( + $AuthenticationTableTable.$convertercookie.toSql(cookie)); + } + { + map['access_token'] = Variable( + $AuthenticationTableTable.$converteraccessToken.toSql(accessToken)); + } + map['expiration'] = Variable(expiration); + return map; + } + + AuthenticationTableCompanion toCompanion(bool nullToAbsent) { + return AuthenticationTableCompanion( + id: Value(id), + cookie: Value(cookie), + accessToken: Value(accessToken), + expiration: Value(expiration), + ); + } + + factory AuthenticationTableData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return AuthenticationTableData( + id: serializer.fromJson(json['id']), + cookie: serializer.fromJson(json['cookie']), + accessToken: serializer.fromJson(json['accessToken']), + expiration: serializer.fromJson(json['expiration']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'cookie': serializer.toJson(cookie), + 'accessToken': serializer.toJson(accessToken), + 'expiration': serializer.toJson(expiration), + }; + } + + AuthenticationTableData copyWith( + {int? id, + DecryptedText? cookie, + DecryptedText? accessToken, + DateTime? expiration}) => + AuthenticationTableData( + id: id ?? this.id, + cookie: cookie ?? this.cookie, + accessToken: accessToken ?? this.accessToken, + expiration: expiration ?? this.expiration, + ); + @override + String toString() { + return (StringBuffer('AuthenticationTableData(') + ..write('id: $id, ') + ..write('cookie: $cookie, ') + ..write('accessToken: $accessToken, ') + ..write('expiration: $expiration') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, cookie, accessToken, expiration); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is AuthenticationTableData && + other.id == this.id && + other.cookie == this.cookie && + other.accessToken == this.accessToken && + other.expiration == this.expiration); +} + +class AuthenticationTableCompanion + extends UpdateCompanion { + final Value id; + final Value cookie; + final Value accessToken; + final Value expiration; + const AuthenticationTableCompanion({ + this.id = const Value.absent(), + this.cookie = const Value.absent(), + this.accessToken = const Value.absent(), + this.expiration = const Value.absent(), + }); + AuthenticationTableCompanion.insert({ + this.id = const Value.absent(), + required DecryptedText cookie, + required DecryptedText accessToken, + required DateTime expiration, + }) : cookie = Value(cookie), + accessToken = Value(accessToken), + expiration = Value(expiration); + static Insertable custom({ + Expression? id, + Expression? cookie, + Expression? accessToken, + Expression? expiration, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (cookie != null) 'cookie': cookie, + if (accessToken != null) 'access_token': accessToken, + if (expiration != null) 'expiration': expiration, + }); + } + + AuthenticationTableCompanion copyWith( + {Value? id, + Value? cookie, + Value? accessToken, + Value? expiration}) { + return AuthenticationTableCompanion( + id: id ?? this.id, + cookie: cookie ?? this.cookie, + accessToken: accessToken ?? this.accessToken, + expiration: expiration ?? this.expiration, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (cookie.present) { + map['cookie'] = Variable( + $AuthenticationTableTable.$convertercookie.toSql(cookie.value)); + } + if (accessToken.present) { + map['access_token'] = Variable($AuthenticationTableTable + .$converteraccessToken + .toSql(accessToken.value)); + } + if (expiration.present) { + map['expiration'] = Variable(expiration.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('AuthenticationTableCompanion(') + ..write('id: $id, ') + ..write('cookie: $cookie, ') + ..write('accessToken: $accessToken, ') + ..write('expiration: $expiration') + ..write(')')) + .toString(); + } +} + +class $BlacklistTableTable extends BlacklistTable + with TableInfo<$BlacklistTableTable, BlacklistTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $BlacklistTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _nameMeta = const VerificationMeta('name'); + @override + late final GeneratedColumn name = GeneratedColumn( + 'name', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _elementTypeMeta = + const VerificationMeta('elementType'); + @override + late final GeneratedColumnWithTypeConverter + elementType = GeneratedColumn('element_type', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter( + $BlacklistTableTable.$converterelementType); + static const VerificationMeta _elementIdMeta = + const VerificationMeta('elementId'); + @override + late final GeneratedColumn elementId = GeneratedColumn( + 'element_id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + @override + List get $columns => [id, name, elementType, elementId]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'blacklist_table'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + if (data.containsKey('name')) { + context.handle( + _nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta)); + } else if (isInserting) { + context.missing(_nameMeta); + } + context.handle(_elementTypeMeta, const VerificationResult.success()); + if (data.containsKey('element_id')) { + context.handle(_elementIdMeta, + elementId.isAcceptableOrUnknown(data['element_id']!, _elementIdMeta)); + } else if (isInserting) { + context.missing(_elementIdMeta); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + BlacklistTableData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return BlacklistTableData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + name: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}name'])!, + elementType: $BlacklistTableTable.$converterelementType.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}element_type'])!), + elementId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}element_id'])!, + ); + } + + @override + $BlacklistTableTable createAlias(String alias) { + return $BlacklistTableTable(attachedDatabase, alias); + } + + static JsonTypeConverter2 + $converterelementType = + const EnumNameConverter(BlacklistedType.values); +} + +class BlacklistTableData extends DataClass + implements Insertable { + final int id; + final String name; + final BlacklistedType elementType; + final String elementId; + const BlacklistTableData( + {required this.id, + required this.name, + required this.elementType, + required this.elementId}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['name'] = Variable(name); + { + map['element_type'] = Variable( + $BlacklistTableTable.$converterelementType.toSql(elementType)); + } + map['element_id'] = Variable(elementId); + return map; + } + + BlacklistTableCompanion toCompanion(bool nullToAbsent) { + return BlacklistTableCompanion( + id: Value(id), + name: Value(name), + elementType: Value(elementType), + elementId: Value(elementId), + ); + } + + factory BlacklistTableData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return BlacklistTableData( + id: serializer.fromJson(json['id']), + name: serializer.fromJson(json['name']), + elementType: $BlacklistTableTable.$converterelementType + .fromJson(serializer.fromJson(json['elementType'])), + elementId: serializer.fromJson(json['elementId']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'name': serializer.toJson(name), + 'elementType': serializer.toJson( + $BlacklistTableTable.$converterelementType.toJson(elementType)), + 'elementId': serializer.toJson(elementId), + }; + } + + BlacklistTableData copyWith( + {int? id, + String? name, + BlacklistedType? elementType, + String? elementId}) => + BlacklistTableData( + id: id ?? this.id, + name: name ?? this.name, + elementType: elementType ?? this.elementType, + elementId: elementId ?? this.elementId, + ); + @override + String toString() { + return (StringBuffer('BlacklistTableData(') + ..write('id: $id, ') + ..write('name: $name, ') + ..write('elementType: $elementType, ') + ..write('elementId: $elementId') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, name, elementType, elementId); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is BlacklistTableData && + other.id == this.id && + other.name == this.name && + other.elementType == this.elementType && + other.elementId == this.elementId); +} + +class BlacklistTableCompanion extends UpdateCompanion { + final Value id; + final Value name; + final Value elementType; + final Value elementId; + const BlacklistTableCompanion({ + this.id = const Value.absent(), + this.name = const Value.absent(), + this.elementType = const Value.absent(), + this.elementId = const Value.absent(), + }); + BlacklistTableCompanion.insert({ + this.id = const Value.absent(), + required String name, + required BlacklistedType elementType, + required String elementId, + }) : name = Value(name), + elementType = Value(elementType), + elementId = Value(elementId); + static Insertable custom({ + Expression? id, + Expression? name, + Expression? elementType, + Expression? elementId, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (name != null) 'name': name, + if (elementType != null) 'element_type': elementType, + if (elementId != null) 'element_id': elementId, + }); + } + + BlacklistTableCompanion copyWith( + {Value? id, + Value? name, + Value? elementType, + Value? elementId}) { + return BlacklistTableCompanion( + id: id ?? this.id, + name: name ?? this.name, + elementType: elementType ?? this.elementType, + elementId: elementId ?? this.elementId, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (elementType.present) { + map['element_type'] = Variable( + $BlacklistTableTable.$converterelementType.toSql(elementType.value)); + } + if (elementId.present) { + map['element_id'] = Variable(elementId.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('BlacklistTableCompanion(') + ..write('id: $id, ') + ..write('name: $name, ') + ..write('elementType: $elementType, ') + ..write('elementId: $elementId') + ..write(')')) + .toString(); + } +} + +class $PreferencesTableTable extends PreferencesTable + with TableInfo<$PreferencesTableTable, PreferencesTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $PreferencesTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _audioQualityMeta = + const VerificationMeta('audioQuality'); + @override + late final GeneratedColumnWithTypeConverter + audioQuality = GeneratedColumn( + 'audio_quality', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: Constant(SourceQualities.high.name)) + .withConverter( + $PreferencesTableTable.$converteraudioQuality); + static const VerificationMeta _albumColorSyncMeta = + const VerificationMeta('albumColorSync'); + @override + late final GeneratedColumn albumColorSync = GeneratedColumn( + 'album_color_sync', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'CHECK ("album_color_sync" IN (0, 1))'), + defaultValue: const Constant(true)); + static const VerificationMeta _amoledDarkThemeMeta = + const VerificationMeta('amoledDarkTheme'); + @override + late final GeneratedColumn amoledDarkTheme = GeneratedColumn( + 'amoled_dark_theme', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'CHECK ("amoled_dark_theme" IN (0, 1))'), + defaultValue: const Constant(false)); + static const VerificationMeta _checkUpdateMeta = + const VerificationMeta('checkUpdate'); + @override + late final GeneratedColumn checkUpdate = GeneratedColumn( + 'check_update', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'CHECK ("check_update" IN (0, 1))'), + defaultValue: const Constant(true)); + static const VerificationMeta _normalizeAudioMeta = + const VerificationMeta('normalizeAudio'); + @override + late final GeneratedColumn normalizeAudio = GeneratedColumn( + 'normalize_audio', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'CHECK ("normalize_audio" IN (0, 1))'), + defaultValue: const Constant(false)); + static const VerificationMeta _showSystemTrayIconMeta = + const VerificationMeta('showSystemTrayIcon'); + @override + late final GeneratedColumn showSystemTrayIcon = GeneratedColumn( + 'show_system_tray_icon', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'CHECK ("show_system_tray_icon" IN (0, 1))'), + defaultValue: const Constant(false)); + static const VerificationMeta _systemTitleBarMeta = + const VerificationMeta('systemTitleBar'); + @override + late final GeneratedColumn systemTitleBar = GeneratedColumn( + 'system_title_bar', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'CHECK ("system_title_bar" IN (0, 1))'), + defaultValue: const Constant(false)); + static const VerificationMeta _skipNonMusicMeta = + const VerificationMeta('skipNonMusic'); + @override + late final GeneratedColumn skipNonMusic = GeneratedColumn( + 'skip_non_music', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'CHECK ("skip_non_music" IN (0, 1))'), + defaultValue: const Constant(false)); + static const VerificationMeta _closeBehaviorMeta = + const VerificationMeta('closeBehavior'); + @override + late final GeneratedColumnWithTypeConverter + closeBehavior = GeneratedColumn( + 'close_behavior', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: Constant(CloseBehavior.close.name)) + .withConverter( + $PreferencesTableTable.$convertercloseBehavior); + static const VerificationMeta _accentColorSchemeMeta = + const VerificationMeta('accentColorScheme'); + @override + late final GeneratedColumnWithTypeConverter + accentColorScheme = GeneratedColumn( + 'accent_color_scheme', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: const Constant("Blue:0xFF2196F3")) + .withConverter( + $PreferencesTableTable.$converteraccentColorScheme); + static const VerificationMeta _layoutModeMeta = + const VerificationMeta('layoutMode'); + @override + late final GeneratedColumnWithTypeConverter layoutMode = + GeneratedColumn('layout_mode', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: Constant(LayoutMode.adaptive.name)) + .withConverter( + $PreferencesTableTable.$converterlayoutMode); + static const VerificationMeta _localeMeta = const VerificationMeta('locale'); + @override + late final GeneratedColumnWithTypeConverter locale = + GeneratedColumn('locale', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: const Constant( + '{"languageCode":"system","countryCode":"system"}')) + .withConverter($PreferencesTableTable.$converterlocale); + static const VerificationMeta _marketMeta = const VerificationMeta('market'); + @override + late final GeneratedColumnWithTypeConverter market = + GeneratedColumn('market', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: Constant(Market.US.name)) + .withConverter($PreferencesTableTable.$convertermarket); + static const VerificationMeta _searchModeMeta = + const VerificationMeta('searchMode'); + @override + late final GeneratedColumnWithTypeConverter searchMode = + GeneratedColumn('search_mode', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: Constant(SearchMode.youtube.name)) + .withConverter( + $PreferencesTableTable.$convertersearchMode); + static const VerificationMeta _downloadLocationMeta = + const VerificationMeta('downloadLocation'); + @override + late final GeneratedColumn downloadLocation = GeneratedColumn( + 'download_location', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: const Constant("")); + static const VerificationMeta _localLibraryLocationMeta = + const VerificationMeta('localLibraryLocation'); + @override + late final GeneratedColumnWithTypeConverter, String> + localLibraryLocation = GeneratedColumn( + 'local_library_location', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: const Constant("")) + .withConverter>( + $PreferencesTableTable.$converterlocalLibraryLocation); + static const VerificationMeta _pipedInstanceMeta = + const VerificationMeta('pipedInstance'); + @override + late final GeneratedColumn pipedInstance = GeneratedColumn( + 'piped_instance', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: const Constant("https://pipedapi.kavin.rocks")); + static const VerificationMeta _themeModeMeta = + const VerificationMeta('themeMode'); + @override + late final GeneratedColumnWithTypeConverter themeMode = + GeneratedColumn('theme_mode', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: Constant(ThemeMode.system.name)) + .withConverter($PreferencesTableTable.$converterthemeMode); + static const VerificationMeta _audioSourceMeta = + const VerificationMeta('audioSource'); + @override + late final GeneratedColumnWithTypeConverter audioSource = + GeneratedColumn('audio_source', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: Constant(AudioSource.youtube.name)) + .withConverter( + $PreferencesTableTable.$converteraudioSource); + static const VerificationMeta _streamMusicCodecMeta = + const VerificationMeta('streamMusicCodec'); + @override + late final GeneratedColumnWithTypeConverter + streamMusicCodec = GeneratedColumn( + 'stream_music_codec', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: Constant(SourceCodecs.weba.name)) + .withConverter( + $PreferencesTableTable.$converterstreamMusicCodec); + static const VerificationMeta _downloadMusicCodecMeta = + const VerificationMeta('downloadMusicCodec'); + @override + late final GeneratedColumnWithTypeConverter + downloadMusicCodec = GeneratedColumn( + 'download_music_codec', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: Constant(SourceCodecs.m4a.name)) + .withConverter( + $PreferencesTableTable.$converterdownloadMusicCodec); + static const VerificationMeta _discordPresenceMeta = + const VerificationMeta('discordPresence'); + @override + late final GeneratedColumn discordPresence = GeneratedColumn( + 'discord_presence', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'CHECK ("discord_presence" IN (0, 1))'), + defaultValue: const Constant(true)); + static const VerificationMeta _endlessPlaybackMeta = + const VerificationMeta('endlessPlayback'); + @override + late final GeneratedColumn endlessPlayback = GeneratedColumn( + 'endless_playback', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'CHECK ("endless_playback" IN (0, 1))'), + defaultValue: const Constant(true)); + static const VerificationMeta _enableConnectMeta = + const VerificationMeta('enableConnect'); + @override + late final GeneratedColumn enableConnect = GeneratedColumn( + 'enable_connect', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'CHECK ("enable_connect" IN (0, 1))'), + defaultValue: const Constant(false)); + @override + List get $columns => [ + id, + audioQuality, + albumColorSync, + amoledDarkTheme, + checkUpdate, + normalizeAudio, + showSystemTrayIcon, + systemTitleBar, + skipNonMusic, + closeBehavior, + accentColorScheme, + layoutMode, + locale, + market, + searchMode, + downloadLocation, + localLibraryLocation, + pipedInstance, + themeMode, + audioSource, + streamMusicCodec, + downloadMusicCodec, + discordPresence, + endlessPlayback, + enableConnect + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'preferences_table'; + @override + VerificationContext validateIntegrity( + Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + context.handle(_audioQualityMeta, const VerificationResult.success()); + if (data.containsKey('album_color_sync')) { + context.handle( + _albumColorSyncMeta, + albumColorSync.isAcceptableOrUnknown( + data['album_color_sync']!, _albumColorSyncMeta)); + } + if (data.containsKey('amoled_dark_theme')) { + context.handle( + _amoledDarkThemeMeta, + amoledDarkTheme.isAcceptableOrUnknown( + data['amoled_dark_theme']!, _amoledDarkThemeMeta)); + } + if (data.containsKey('check_update')) { + context.handle( + _checkUpdateMeta, + checkUpdate.isAcceptableOrUnknown( + data['check_update']!, _checkUpdateMeta)); + } + if (data.containsKey('normalize_audio')) { + context.handle( + _normalizeAudioMeta, + normalizeAudio.isAcceptableOrUnknown( + data['normalize_audio']!, _normalizeAudioMeta)); + } + if (data.containsKey('show_system_tray_icon')) { + context.handle( + _showSystemTrayIconMeta, + showSystemTrayIcon.isAcceptableOrUnknown( + data['show_system_tray_icon']!, _showSystemTrayIconMeta)); + } + if (data.containsKey('system_title_bar')) { + context.handle( + _systemTitleBarMeta, + systemTitleBar.isAcceptableOrUnknown( + data['system_title_bar']!, _systemTitleBarMeta)); + } + if (data.containsKey('skip_non_music')) { + context.handle( + _skipNonMusicMeta, + skipNonMusic.isAcceptableOrUnknown( + data['skip_non_music']!, _skipNonMusicMeta)); + } + context.handle(_closeBehaviorMeta, const VerificationResult.success()); + context.handle(_accentColorSchemeMeta, const VerificationResult.success()); + context.handle(_layoutModeMeta, const VerificationResult.success()); + context.handle(_localeMeta, const VerificationResult.success()); + context.handle(_marketMeta, const VerificationResult.success()); + context.handle(_searchModeMeta, const VerificationResult.success()); + if (data.containsKey('download_location')) { + context.handle( + _downloadLocationMeta, + downloadLocation.isAcceptableOrUnknown( + data['download_location']!, _downloadLocationMeta)); + } + context.handle( + _localLibraryLocationMeta, const VerificationResult.success()); + if (data.containsKey('piped_instance')) { + context.handle( + _pipedInstanceMeta, + pipedInstance.isAcceptableOrUnknown( + data['piped_instance']!, _pipedInstanceMeta)); + } + context.handle(_themeModeMeta, const VerificationResult.success()); + context.handle(_audioSourceMeta, const VerificationResult.success()); + context.handle(_streamMusicCodecMeta, const VerificationResult.success()); + context.handle(_downloadMusicCodecMeta, const VerificationResult.success()); + if (data.containsKey('discord_presence')) { + context.handle( + _discordPresenceMeta, + discordPresence.isAcceptableOrUnknown( + data['discord_presence']!, _discordPresenceMeta)); + } + if (data.containsKey('endless_playback')) { + context.handle( + _endlessPlaybackMeta, + endlessPlayback.isAcceptableOrUnknown( + data['endless_playback']!, _endlessPlaybackMeta)); + } + if (data.containsKey('enable_connect')) { + context.handle( + _enableConnectMeta, + enableConnect.isAcceptableOrUnknown( + data['enable_connect']!, _enableConnectMeta)); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + PreferencesTableData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return PreferencesTableData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + audioQuality: $PreferencesTableTable.$converteraudioQuality.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}audio_quality'])!), + albumColorSync: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}album_color_sync'])!, + amoledDarkTheme: attachedDatabase.typeMapping.read( + DriftSqlType.bool, data['${effectivePrefix}amoled_dark_theme'])!, + checkUpdate: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}check_update'])!, + normalizeAudio: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}normalize_audio'])!, + showSystemTrayIcon: attachedDatabase.typeMapping.read( + DriftSqlType.bool, data['${effectivePrefix}show_system_tray_icon'])!, + systemTitleBar: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}system_title_bar'])!, + skipNonMusic: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}skip_non_music'])!, + closeBehavior: $PreferencesTableTable.$convertercloseBehavior.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}close_behavior'])!), + accentColorScheme: $PreferencesTableTable.$converteraccentColorScheme + .fromSql(attachedDatabase.typeMapping.read(DriftSqlType.string, + data['${effectivePrefix}accent_color_scheme'])!), + layoutMode: $PreferencesTableTable.$converterlayoutMode.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}layout_mode'])!), + locale: $PreferencesTableTable.$converterlocale.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}locale'])!), + market: $PreferencesTableTable.$convertermarket.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}market'])!), + searchMode: $PreferencesTableTable.$convertersearchMode.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}search_mode'])!), + downloadLocation: attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}download_location'])!, + localLibraryLocation: $PreferencesTableTable + .$converterlocalLibraryLocation + .fromSql(attachedDatabase.typeMapping.read(DriftSqlType.string, + data['${effectivePrefix}local_library_location'])!), + pipedInstance: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}piped_instance'])!, + themeMode: $PreferencesTableTable.$converterthemeMode.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}theme_mode'])!), + audioSource: $PreferencesTableTable.$converteraudioSource.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}audio_source'])!), + streamMusicCodec: $PreferencesTableTable.$converterstreamMusicCodec + .fromSql(attachedDatabase.typeMapping.read(DriftSqlType.string, + data['${effectivePrefix}stream_music_codec'])!), + downloadMusicCodec: $PreferencesTableTable.$converterdownloadMusicCodec + .fromSql(attachedDatabase.typeMapping.read(DriftSqlType.string, + data['${effectivePrefix}download_music_codec'])!), + discordPresence: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}discord_presence'])!, + endlessPlayback: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}endless_playback'])!, + enableConnect: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}enable_connect'])!, + ); + } + + @override + $PreferencesTableTable createAlias(String alias) { + return $PreferencesTableTable(attachedDatabase, alias); + } + + static JsonTypeConverter2 + $converteraudioQuality = + const EnumNameConverter(SourceQualities.values); + static JsonTypeConverter2 + $convertercloseBehavior = + const EnumNameConverter(CloseBehavior.values); + static TypeConverter $converteraccentColorScheme = + const SpotubeColorConverter(); + static JsonTypeConverter2 $converterlayoutMode = + const EnumNameConverter(LayoutMode.values); + static TypeConverter $converterlocale = + const LocaleConverter(); + static JsonTypeConverter2 $convertermarket = + const EnumNameConverter(Market.values); + static JsonTypeConverter2 $convertersearchMode = + const EnumNameConverter(SearchMode.values); + static TypeConverter, String> $converterlocalLibraryLocation = + const StringListConverter(); + static JsonTypeConverter2 $converterthemeMode = + const EnumNameConverter(ThemeMode.values); + static JsonTypeConverter2 $converteraudioSource = + const EnumNameConverter(AudioSource.values); + static JsonTypeConverter2 + $converterstreamMusicCodec = + const EnumNameConverter(SourceCodecs.values); + static JsonTypeConverter2 + $converterdownloadMusicCodec = + const EnumNameConverter(SourceCodecs.values); +} + +class PreferencesTableData extends DataClass + implements Insertable { + final int id; + final SourceQualities audioQuality; + final bool albumColorSync; + final bool amoledDarkTheme; + final bool checkUpdate; + final bool normalizeAudio; + final bool showSystemTrayIcon; + final bool systemTitleBar; + final bool skipNonMusic; + final CloseBehavior closeBehavior; + final SpotubeColor accentColorScheme; + final LayoutMode layoutMode; + final Locale locale; + final Market market; + final SearchMode searchMode; + final String downloadLocation; + final List localLibraryLocation; + final String pipedInstance; + final ThemeMode themeMode; + final AudioSource audioSource; + final SourceCodecs streamMusicCodec; + final SourceCodecs downloadMusicCodec; + final bool discordPresence; + final bool endlessPlayback; + final bool enableConnect; + const PreferencesTableData( + {required this.id, + required this.audioQuality, + required this.albumColorSync, + required this.amoledDarkTheme, + required this.checkUpdate, + required this.normalizeAudio, + required this.showSystemTrayIcon, + required this.systemTitleBar, + required this.skipNonMusic, + required this.closeBehavior, + required this.accentColorScheme, + required this.layoutMode, + required this.locale, + required this.market, + required this.searchMode, + required this.downloadLocation, + required this.localLibraryLocation, + required this.pipedInstance, + required this.themeMode, + required this.audioSource, + required this.streamMusicCodec, + required this.downloadMusicCodec, + required this.discordPresence, + required this.endlessPlayback, + required this.enableConnect}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + { + map['audio_quality'] = Variable( + $PreferencesTableTable.$converteraudioQuality.toSql(audioQuality)); + } + map['album_color_sync'] = Variable(albumColorSync); + map['amoled_dark_theme'] = Variable(amoledDarkTheme); + map['check_update'] = Variable(checkUpdate); + map['normalize_audio'] = Variable(normalizeAudio); + map['show_system_tray_icon'] = Variable(showSystemTrayIcon); + map['system_title_bar'] = Variable(systemTitleBar); + map['skip_non_music'] = Variable(skipNonMusic); + { + map['close_behavior'] = Variable( + $PreferencesTableTable.$convertercloseBehavior.toSql(closeBehavior)); + } + { + map['accent_color_scheme'] = Variable($PreferencesTableTable + .$converteraccentColorScheme + .toSql(accentColorScheme)); + } + { + map['layout_mode'] = Variable( + $PreferencesTableTable.$converterlayoutMode.toSql(layoutMode)); + } + { + map['locale'] = Variable( + $PreferencesTableTable.$converterlocale.toSql(locale)); + } + { + map['market'] = Variable( + $PreferencesTableTable.$convertermarket.toSql(market)); + } + { + map['search_mode'] = Variable( + $PreferencesTableTable.$convertersearchMode.toSql(searchMode)); + } + map['download_location'] = Variable(downloadLocation); + { + map['local_library_location'] = Variable($PreferencesTableTable + .$converterlocalLibraryLocation + .toSql(localLibraryLocation)); + } + map['piped_instance'] = Variable(pipedInstance); + { + map['theme_mode'] = Variable( + $PreferencesTableTable.$converterthemeMode.toSql(themeMode)); + } + { + map['audio_source'] = Variable( + $PreferencesTableTable.$converteraudioSource.toSql(audioSource)); + } + { + map['stream_music_codec'] = Variable($PreferencesTableTable + .$converterstreamMusicCodec + .toSql(streamMusicCodec)); + } + { + map['download_music_codec'] = Variable($PreferencesTableTable + .$converterdownloadMusicCodec + .toSql(downloadMusicCodec)); + } + map['discord_presence'] = Variable(discordPresence); + map['endless_playback'] = Variable(endlessPlayback); + map['enable_connect'] = Variable(enableConnect); + return map; + } + + PreferencesTableCompanion toCompanion(bool nullToAbsent) { + return PreferencesTableCompanion( + id: Value(id), + audioQuality: Value(audioQuality), + albumColorSync: Value(albumColorSync), + amoledDarkTheme: Value(amoledDarkTheme), + checkUpdate: Value(checkUpdate), + normalizeAudio: Value(normalizeAudio), + showSystemTrayIcon: Value(showSystemTrayIcon), + systemTitleBar: Value(systemTitleBar), + skipNonMusic: Value(skipNonMusic), + closeBehavior: Value(closeBehavior), + accentColorScheme: Value(accentColorScheme), + layoutMode: Value(layoutMode), + locale: Value(locale), + market: Value(market), + searchMode: Value(searchMode), + downloadLocation: Value(downloadLocation), + localLibraryLocation: Value(localLibraryLocation), + pipedInstance: Value(pipedInstance), + themeMode: Value(themeMode), + audioSource: Value(audioSource), + streamMusicCodec: Value(streamMusicCodec), + downloadMusicCodec: Value(downloadMusicCodec), + discordPresence: Value(discordPresence), + endlessPlayback: Value(endlessPlayback), + enableConnect: Value(enableConnect), + ); + } + + factory PreferencesTableData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return PreferencesTableData( + id: serializer.fromJson(json['id']), + audioQuality: $PreferencesTableTable.$converteraudioQuality + .fromJson(serializer.fromJson(json['audioQuality'])), + albumColorSync: serializer.fromJson(json['albumColorSync']), + amoledDarkTheme: serializer.fromJson(json['amoledDarkTheme']), + checkUpdate: serializer.fromJson(json['checkUpdate']), + normalizeAudio: serializer.fromJson(json['normalizeAudio']), + showSystemTrayIcon: serializer.fromJson(json['showSystemTrayIcon']), + systemTitleBar: serializer.fromJson(json['systemTitleBar']), + skipNonMusic: serializer.fromJson(json['skipNonMusic']), + closeBehavior: $PreferencesTableTable.$convertercloseBehavior + .fromJson(serializer.fromJson(json['closeBehavior'])), + accentColorScheme: + serializer.fromJson(json['accentColorScheme']), + layoutMode: $PreferencesTableTable.$converterlayoutMode + .fromJson(serializer.fromJson(json['layoutMode'])), + locale: serializer.fromJson(json['locale']), + market: $PreferencesTableTable.$convertermarket + .fromJson(serializer.fromJson(json['market'])), + searchMode: $PreferencesTableTable.$convertersearchMode + .fromJson(serializer.fromJson(json['searchMode'])), + downloadLocation: serializer.fromJson(json['downloadLocation']), + localLibraryLocation: + serializer.fromJson>(json['localLibraryLocation']), + pipedInstance: serializer.fromJson(json['pipedInstance']), + themeMode: $PreferencesTableTable.$converterthemeMode + .fromJson(serializer.fromJson(json['themeMode'])), + audioSource: $PreferencesTableTable.$converteraudioSource + .fromJson(serializer.fromJson(json['audioSource'])), + streamMusicCodec: $PreferencesTableTable.$converterstreamMusicCodec + .fromJson(serializer.fromJson(json['streamMusicCodec'])), + downloadMusicCodec: $PreferencesTableTable.$converterdownloadMusicCodec + .fromJson(serializer.fromJson(json['downloadMusicCodec'])), + discordPresence: serializer.fromJson(json['discordPresence']), + endlessPlayback: serializer.fromJson(json['endlessPlayback']), + enableConnect: serializer.fromJson(json['enableConnect']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'audioQuality': serializer.toJson( + $PreferencesTableTable.$converteraudioQuality.toJson(audioQuality)), + 'albumColorSync': serializer.toJson(albumColorSync), + 'amoledDarkTheme': serializer.toJson(amoledDarkTheme), + 'checkUpdate': serializer.toJson(checkUpdate), + 'normalizeAudio': serializer.toJson(normalizeAudio), + 'showSystemTrayIcon': serializer.toJson(showSystemTrayIcon), + 'systemTitleBar': serializer.toJson(systemTitleBar), + 'skipNonMusic': serializer.toJson(skipNonMusic), + 'closeBehavior': serializer.toJson( + $PreferencesTableTable.$convertercloseBehavior.toJson(closeBehavior)), + 'accentColorScheme': serializer.toJson(accentColorScheme), + 'layoutMode': serializer.toJson( + $PreferencesTableTable.$converterlayoutMode.toJson(layoutMode)), + 'locale': serializer.toJson(locale), + 'market': serializer.toJson( + $PreferencesTableTable.$convertermarket.toJson(market)), + 'searchMode': serializer.toJson( + $PreferencesTableTable.$convertersearchMode.toJson(searchMode)), + 'downloadLocation': serializer.toJson(downloadLocation), + 'localLibraryLocation': + serializer.toJson>(localLibraryLocation), + 'pipedInstance': serializer.toJson(pipedInstance), + 'themeMode': serializer.toJson( + $PreferencesTableTable.$converterthemeMode.toJson(themeMode)), + 'audioSource': serializer.toJson( + $PreferencesTableTable.$converteraudioSource.toJson(audioSource)), + 'streamMusicCodec': serializer.toJson($PreferencesTableTable + .$converterstreamMusicCodec + .toJson(streamMusicCodec)), + 'downloadMusicCodec': serializer.toJson($PreferencesTableTable + .$converterdownloadMusicCodec + .toJson(downloadMusicCodec)), + 'discordPresence': serializer.toJson(discordPresence), + 'endlessPlayback': serializer.toJson(endlessPlayback), + 'enableConnect': serializer.toJson(enableConnect), + }; + } + + PreferencesTableData copyWith( + {int? id, + SourceQualities? audioQuality, + bool? albumColorSync, + bool? amoledDarkTheme, + bool? checkUpdate, + bool? normalizeAudio, + bool? showSystemTrayIcon, + bool? systemTitleBar, + bool? skipNonMusic, + CloseBehavior? closeBehavior, + SpotubeColor? accentColorScheme, + LayoutMode? layoutMode, + Locale? locale, + Market? market, + SearchMode? searchMode, + String? downloadLocation, + List? localLibraryLocation, + String? pipedInstance, + ThemeMode? themeMode, + AudioSource? audioSource, + SourceCodecs? streamMusicCodec, + SourceCodecs? downloadMusicCodec, + bool? discordPresence, + bool? endlessPlayback, + bool? enableConnect}) => + PreferencesTableData( + id: id ?? this.id, + audioQuality: audioQuality ?? this.audioQuality, + albumColorSync: albumColorSync ?? this.albumColorSync, + amoledDarkTheme: amoledDarkTheme ?? this.amoledDarkTheme, + checkUpdate: checkUpdate ?? this.checkUpdate, + normalizeAudio: normalizeAudio ?? this.normalizeAudio, + showSystemTrayIcon: showSystemTrayIcon ?? this.showSystemTrayIcon, + systemTitleBar: systemTitleBar ?? this.systemTitleBar, + skipNonMusic: skipNonMusic ?? this.skipNonMusic, + closeBehavior: closeBehavior ?? this.closeBehavior, + accentColorScheme: accentColorScheme ?? this.accentColorScheme, + layoutMode: layoutMode ?? this.layoutMode, + locale: locale ?? this.locale, + market: market ?? this.market, + searchMode: searchMode ?? this.searchMode, + downloadLocation: downloadLocation ?? this.downloadLocation, + localLibraryLocation: localLibraryLocation ?? this.localLibraryLocation, + pipedInstance: pipedInstance ?? this.pipedInstance, + themeMode: themeMode ?? this.themeMode, + audioSource: audioSource ?? this.audioSource, + streamMusicCodec: streamMusicCodec ?? this.streamMusicCodec, + downloadMusicCodec: downloadMusicCodec ?? this.downloadMusicCodec, + discordPresence: discordPresence ?? this.discordPresence, + endlessPlayback: endlessPlayback ?? this.endlessPlayback, + enableConnect: enableConnect ?? this.enableConnect, + ); + @override + String toString() { + return (StringBuffer('PreferencesTableData(') + ..write('id: $id, ') + ..write('audioQuality: $audioQuality, ') + ..write('albumColorSync: $albumColorSync, ') + ..write('amoledDarkTheme: $amoledDarkTheme, ') + ..write('checkUpdate: $checkUpdate, ') + ..write('normalizeAudio: $normalizeAudio, ') + ..write('showSystemTrayIcon: $showSystemTrayIcon, ') + ..write('systemTitleBar: $systemTitleBar, ') + ..write('skipNonMusic: $skipNonMusic, ') + ..write('closeBehavior: $closeBehavior, ') + ..write('accentColorScheme: $accentColorScheme, ') + ..write('layoutMode: $layoutMode, ') + ..write('locale: $locale, ') + ..write('market: $market, ') + ..write('searchMode: $searchMode, ') + ..write('downloadLocation: $downloadLocation, ') + ..write('localLibraryLocation: $localLibraryLocation, ') + ..write('pipedInstance: $pipedInstance, ') + ..write('themeMode: $themeMode, ') + ..write('audioSource: $audioSource, ') + ..write('streamMusicCodec: $streamMusicCodec, ') + ..write('downloadMusicCodec: $downloadMusicCodec, ') + ..write('discordPresence: $discordPresence, ') + ..write('endlessPlayback: $endlessPlayback, ') + ..write('enableConnect: $enableConnect') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hashAll([ + id, + audioQuality, + albumColorSync, + amoledDarkTheme, + checkUpdate, + normalizeAudio, + showSystemTrayIcon, + systemTitleBar, + skipNonMusic, + closeBehavior, + accentColorScheme, + layoutMode, + locale, + market, + searchMode, + downloadLocation, + localLibraryLocation, + pipedInstance, + themeMode, + audioSource, + streamMusicCodec, + downloadMusicCodec, + discordPresence, + endlessPlayback, + enableConnect + ]); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is PreferencesTableData && + other.id == this.id && + other.audioQuality == this.audioQuality && + other.albumColorSync == this.albumColorSync && + other.amoledDarkTheme == this.amoledDarkTheme && + other.checkUpdate == this.checkUpdate && + other.normalizeAudio == this.normalizeAudio && + other.showSystemTrayIcon == this.showSystemTrayIcon && + other.systemTitleBar == this.systemTitleBar && + other.skipNonMusic == this.skipNonMusic && + other.closeBehavior == this.closeBehavior && + other.accentColorScheme == this.accentColorScheme && + other.layoutMode == this.layoutMode && + other.locale == this.locale && + other.market == this.market && + other.searchMode == this.searchMode && + other.downloadLocation == this.downloadLocation && + other.localLibraryLocation == this.localLibraryLocation && + other.pipedInstance == this.pipedInstance && + other.themeMode == this.themeMode && + other.audioSource == this.audioSource && + other.streamMusicCodec == this.streamMusicCodec && + other.downloadMusicCodec == this.downloadMusicCodec && + other.discordPresence == this.discordPresence && + other.endlessPlayback == this.endlessPlayback && + other.enableConnect == this.enableConnect); +} + +class PreferencesTableCompanion extends UpdateCompanion { + final Value id; + final Value audioQuality; + final Value albumColorSync; + final Value amoledDarkTheme; + final Value checkUpdate; + final Value normalizeAudio; + final Value showSystemTrayIcon; + final Value systemTitleBar; + final Value skipNonMusic; + final Value closeBehavior; + final Value accentColorScheme; + final Value layoutMode; + final Value locale; + final Value market; + final Value searchMode; + final Value downloadLocation; + final Value> localLibraryLocation; + final Value pipedInstance; + final Value themeMode; + final Value audioSource; + final Value streamMusicCodec; + final Value downloadMusicCodec; + final Value discordPresence; + final Value endlessPlayback; + final Value enableConnect; + const PreferencesTableCompanion({ + this.id = const Value.absent(), + this.audioQuality = const Value.absent(), + this.albumColorSync = const Value.absent(), + this.amoledDarkTheme = const Value.absent(), + this.checkUpdate = const Value.absent(), + this.normalizeAudio = const Value.absent(), + this.showSystemTrayIcon = const Value.absent(), + this.systemTitleBar = const Value.absent(), + this.skipNonMusic = const Value.absent(), + this.closeBehavior = const Value.absent(), + this.accentColorScheme = const Value.absent(), + this.layoutMode = const Value.absent(), + this.locale = const Value.absent(), + this.market = const Value.absent(), + this.searchMode = const Value.absent(), + this.downloadLocation = const Value.absent(), + this.localLibraryLocation = const Value.absent(), + this.pipedInstance = const Value.absent(), + this.themeMode = const Value.absent(), + this.audioSource = const Value.absent(), + this.streamMusicCodec = const Value.absent(), + this.downloadMusicCodec = const Value.absent(), + this.discordPresence = const Value.absent(), + this.endlessPlayback = const Value.absent(), + this.enableConnect = const Value.absent(), + }); + PreferencesTableCompanion.insert({ + this.id = const Value.absent(), + this.audioQuality = const Value.absent(), + this.albumColorSync = const Value.absent(), + this.amoledDarkTheme = const Value.absent(), + this.checkUpdate = const Value.absent(), + this.normalizeAudio = const Value.absent(), + this.showSystemTrayIcon = const Value.absent(), + this.systemTitleBar = const Value.absent(), + this.skipNonMusic = const Value.absent(), + this.closeBehavior = const Value.absent(), + this.accentColorScheme = const Value.absent(), + this.layoutMode = const Value.absent(), + this.locale = const Value.absent(), + this.market = const Value.absent(), + this.searchMode = const Value.absent(), + this.downloadLocation = const Value.absent(), + this.localLibraryLocation = const Value.absent(), + this.pipedInstance = const Value.absent(), + this.themeMode = const Value.absent(), + this.audioSource = const Value.absent(), + this.streamMusicCodec = const Value.absent(), + this.downloadMusicCodec = const Value.absent(), + this.discordPresence = const Value.absent(), + this.endlessPlayback = const Value.absent(), + this.enableConnect = const Value.absent(), + }); + static Insertable custom({ + Expression? id, + Expression? audioQuality, + Expression? albumColorSync, + Expression? amoledDarkTheme, + Expression? checkUpdate, + Expression? normalizeAudio, + Expression? showSystemTrayIcon, + Expression? systemTitleBar, + Expression? skipNonMusic, + Expression? closeBehavior, + Expression? accentColorScheme, + Expression? layoutMode, + Expression? locale, + Expression? market, + Expression? searchMode, + Expression? downloadLocation, + Expression? localLibraryLocation, + Expression? pipedInstance, + Expression? themeMode, + Expression? audioSource, + Expression? streamMusicCodec, + Expression? downloadMusicCodec, + Expression? discordPresence, + Expression? endlessPlayback, + Expression? enableConnect, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (audioQuality != null) 'audio_quality': audioQuality, + if (albumColorSync != null) 'album_color_sync': albumColorSync, + if (amoledDarkTheme != null) 'amoled_dark_theme': amoledDarkTheme, + if (checkUpdate != null) 'check_update': checkUpdate, + if (normalizeAudio != null) 'normalize_audio': normalizeAudio, + if (showSystemTrayIcon != null) + 'show_system_tray_icon': showSystemTrayIcon, + if (systemTitleBar != null) 'system_title_bar': systemTitleBar, + if (skipNonMusic != null) 'skip_non_music': skipNonMusic, + if (closeBehavior != null) 'close_behavior': closeBehavior, + if (accentColorScheme != null) 'accent_color_scheme': accentColorScheme, + if (layoutMode != null) 'layout_mode': layoutMode, + if (locale != null) 'locale': locale, + if (market != null) 'market': market, + if (searchMode != null) 'search_mode': searchMode, + if (downloadLocation != null) 'download_location': downloadLocation, + if (localLibraryLocation != null) + 'local_library_location': localLibraryLocation, + if (pipedInstance != null) 'piped_instance': pipedInstance, + if (themeMode != null) 'theme_mode': themeMode, + if (audioSource != null) 'audio_source': audioSource, + if (streamMusicCodec != null) 'stream_music_codec': streamMusicCodec, + if (downloadMusicCodec != null) + 'download_music_codec': downloadMusicCodec, + if (discordPresence != null) 'discord_presence': discordPresence, + if (endlessPlayback != null) 'endless_playback': endlessPlayback, + if (enableConnect != null) 'enable_connect': enableConnect, + }); + } + + PreferencesTableCompanion copyWith( + {Value? id, + Value? audioQuality, + Value? albumColorSync, + Value? amoledDarkTheme, + Value? checkUpdate, + Value? normalizeAudio, + Value? showSystemTrayIcon, + Value? systemTitleBar, + Value? skipNonMusic, + Value? closeBehavior, + Value? accentColorScheme, + Value? layoutMode, + Value? locale, + Value? market, + Value? searchMode, + Value? downloadLocation, + Value>? localLibraryLocation, + Value? pipedInstance, + Value? themeMode, + Value? audioSource, + Value? streamMusicCodec, + Value? downloadMusicCodec, + Value? discordPresence, + Value? endlessPlayback, + Value? enableConnect}) { + return PreferencesTableCompanion( + id: id ?? this.id, + audioQuality: audioQuality ?? this.audioQuality, + albumColorSync: albumColorSync ?? this.albumColorSync, + amoledDarkTheme: amoledDarkTheme ?? this.amoledDarkTheme, + checkUpdate: checkUpdate ?? this.checkUpdate, + normalizeAudio: normalizeAudio ?? this.normalizeAudio, + showSystemTrayIcon: showSystemTrayIcon ?? this.showSystemTrayIcon, + systemTitleBar: systemTitleBar ?? this.systemTitleBar, + skipNonMusic: skipNonMusic ?? this.skipNonMusic, + closeBehavior: closeBehavior ?? this.closeBehavior, + accentColorScheme: accentColorScheme ?? this.accentColorScheme, + layoutMode: layoutMode ?? this.layoutMode, + locale: locale ?? this.locale, + market: market ?? this.market, + searchMode: searchMode ?? this.searchMode, + downloadLocation: downloadLocation ?? this.downloadLocation, + localLibraryLocation: localLibraryLocation ?? this.localLibraryLocation, + pipedInstance: pipedInstance ?? this.pipedInstance, + themeMode: themeMode ?? this.themeMode, + audioSource: audioSource ?? this.audioSource, + streamMusicCodec: streamMusicCodec ?? this.streamMusicCodec, + downloadMusicCodec: downloadMusicCodec ?? this.downloadMusicCodec, + discordPresence: discordPresence ?? this.discordPresence, + endlessPlayback: endlessPlayback ?? this.endlessPlayback, + enableConnect: enableConnect ?? this.enableConnect, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (audioQuality.present) { + map['audio_quality'] = Variable($PreferencesTableTable + .$converteraudioQuality + .toSql(audioQuality.value)); + } + if (albumColorSync.present) { + map['album_color_sync'] = Variable(albumColorSync.value); + } + if (amoledDarkTheme.present) { + map['amoled_dark_theme'] = Variable(amoledDarkTheme.value); + } + if (checkUpdate.present) { + map['check_update'] = Variable(checkUpdate.value); + } + if (normalizeAudio.present) { + map['normalize_audio'] = Variable(normalizeAudio.value); + } + if (showSystemTrayIcon.present) { + map['show_system_tray_icon'] = Variable(showSystemTrayIcon.value); + } + if (systemTitleBar.present) { + map['system_title_bar'] = Variable(systemTitleBar.value); + } + if (skipNonMusic.present) { + map['skip_non_music'] = Variable(skipNonMusic.value); + } + if (closeBehavior.present) { + map['close_behavior'] = Variable($PreferencesTableTable + .$convertercloseBehavior + .toSql(closeBehavior.value)); + } + if (accentColorScheme.present) { + map['accent_color_scheme'] = Variable($PreferencesTableTable + .$converteraccentColorScheme + .toSql(accentColorScheme.value)); + } + if (layoutMode.present) { + map['layout_mode'] = Variable( + $PreferencesTableTable.$converterlayoutMode.toSql(layoutMode.value)); + } + if (locale.present) { + map['locale'] = Variable( + $PreferencesTableTable.$converterlocale.toSql(locale.value)); + } + if (market.present) { + map['market'] = Variable( + $PreferencesTableTable.$convertermarket.toSql(market.value)); + } + if (searchMode.present) { + map['search_mode'] = Variable( + $PreferencesTableTable.$convertersearchMode.toSql(searchMode.value)); + } + if (downloadLocation.present) { + map['download_location'] = Variable(downloadLocation.value); + } + if (localLibraryLocation.present) { + map['local_library_location'] = Variable($PreferencesTableTable + .$converterlocalLibraryLocation + .toSql(localLibraryLocation.value)); + } + if (pipedInstance.present) { + map['piped_instance'] = Variable(pipedInstance.value); + } + if (themeMode.present) { + map['theme_mode'] = Variable( + $PreferencesTableTable.$converterthemeMode.toSql(themeMode.value)); + } + if (audioSource.present) { + map['audio_source'] = Variable($PreferencesTableTable + .$converteraudioSource + .toSql(audioSource.value)); + } + if (streamMusicCodec.present) { + map['stream_music_codec'] = Variable($PreferencesTableTable + .$converterstreamMusicCodec + .toSql(streamMusicCodec.value)); + } + if (downloadMusicCodec.present) { + map['download_music_codec'] = Variable($PreferencesTableTable + .$converterdownloadMusicCodec + .toSql(downloadMusicCodec.value)); + } + if (discordPresence.present) { + map['discord_presence'] = Variable(discordPresence.value); + } + if (endlessPlayback.present) { + map['endless_playback'] = Variable(endlessPlayback.value); + } + if (enableConnect.present) { + map['enable_connect'] = Variable(enableConnect.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('PreferencesTableCompanion(') + ..write('id: $id, ') + ..write('audioQuality: $audioQuality, ') + ..write('albumColorSync: $albumColorSync, ') + ..write('amoledDarkTheme: $amoledDarkTheme, ') + ..write('checkUpdate: $checkUpdate, ') + ..write('normalizeAudio: $normalizeAudio, ') + ..write('showSystemTrayIcon: $showSystemTrayIcon, ') + ..write('systemTitleBar: $systemTitleBar, ') + ..write('skipNonMusic: $skipNonMusic, ') + ..write('closeBehavior: $closeBehavior, ') + ..write('accentColorScheme: $accentColorScheme, ') + ..write('layoutMode: $layoutMode, ') + ..write('locale: $locale, ') + ..write('market: $market, ') + ..write('searchMode: $searchMode, ') + ..write('downloadLocation: $downloadLocation, ') + ..write('localLibraryLocation: $localLibraryLocation, ') + ..write('pipedInstance: $pipedInstance, ') + ..write('themeMode: $themeMode, ') + ..write('audioSource: $audioSource, ') + ..write('streamMusicCodec: $streamMusicCodec, ') + ..write('downloadMusicCodec: $downloadMusicCodec, ') + ..write('discordPresence: $discordPresence, ') + ..write('endlessPlayback: $endlessPlayback, ') + ..write('enableConnect: $enableConnect') + ..write(')')) + .toString(); + } +} + +class $ScrobblerTableTable extends ScrobblerTable + with TableInfo<$ScrobblerTableTable, ScrobblerTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $ScrobblerTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + @override + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: currentDateAndTime); + static const VerificationMeta _usernameMeta = + const VerificationMeta('username'); + @override + late final GeneratedColumn username = GeneratedColumn( + 'username', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _passwordHashMeta = + const VerificationMeta('passwordHash'); + @override + late final GeneratedColumnWithTypeConverter + passwordHash = GeneratedColumn( + 'password_hash', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter( + $ScrobblerTableTable.$converterpasswordHash); + @override + List get $columns => [id, createdAt, username, passwordHash]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'scrobbler_table'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + if (data.containsKey('created_at')) { + context.handle(_createdAtMeta, + createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); + } + if (data.containsKey('username')) { + context.handle(_usernameMeta, + username.isAcceptableOrUnknown(data['username']!, _usernameMeta)); + } else if (isInserting) { + context.missing(_usernameMeta); + } + context.handle(_passwordHashMeta, const VerificationResult.success()); + return context; + } + + @override + Set get $primaryKey => {id}; + @override + ScrobblerTableData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ScrobblerTableData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + username: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}username'])!, + passwordHash: $ScrobblerTableTable.$converterpasswordHash.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}password_hash'])!), + ); + } + + @override + $ScrobblerTableTable createAlias(String alias) { + return $ScrobblerTableTable(attachedDatabase, alias); + } + + static TypeConverter $converterpasswordHash = + EncryptedTextConverter(); +} + +class ScrobblerTableData extends DataClass + implements Insertable { + final int id; + final DateTime createdAt; + final String username; + final DecryptedText passwordHash; + const ScrobblerTableData( + {required this.id, + required this.createdAt, + required this.username, + required this.passwordHash}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['created_at'] = Variable(createdAt); + map['username'] = Variable(username); + { + map['password_hash'] = Variable( + $ScrobblerTableTable.$converterpasswordHash.toSql(passwordHash)); + } + return map; + } + + ScrobblerTableCompanion toCompanion(bool nullToAbsent) { + return ScrobblerTableCompanion( + id: Value(id), + createdAt: Value(createdAt), + username: Value(username), + passwordHash: Value(passwordHash), + ); + } + + factory ScrobblerTableData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ScrobblerTableData( + id: serializer.fromJson(json['id']), + createdAt: serializer.fromJson(json['createdAt']), + username: serializer.fromJson(json['username']), + passwordHash: serializer.fromJson(json['passwordHash']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'createdAt': serializer.toJson(createdAt), + 'username': serializer.toJson(username), + 'passwordHash': serializer.toJson(passwordHash), + }; + } + + ScrobblerTableData copyWith( + {int? id, + DateTime? createdAt, + String? username, + DecryptedText? passwordHash}) => + ScrobblerTableData( + id: id ?? this.id, + createdAt: createdAt ?? this.createdAt, + username: username ?? this.username, + passwordHash: passwordHash ?? this.passwordHash, + ); + @override + String toString() { + return (StringBuffer('ScrobblerTableData(') + ..write('id: $id, ') + ..write('createdAt: $createdAt, ') + ..write('username: $username, ') + ..write('passwordHash: $passwordHash') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, createdAt, username, passwordHash); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ScrobblerTableData && + other.id == this.id && + other.createdAt == this.createdAt && + other.username == this.username && + other.passwordHash == this.passwordHash); +} + +class ScrobblerTableCompanion extends UpdateCompanion { + final Value id; + final Value createdAt; + final Value username; + final Value passwordHash; + const ScrobblerTableCompanion({ + this.id = const Value.absent(), + this.createdAt = const Value.absent(), + this.username = const Value.absent(), + this.passwordHash = const Value.absent(), + }); + ScrobblerTableCompanion.insert({ + this.id = const Value.absent(), + this.createdAt = const Value.absent(), + required String username, + required DecryptedText passwordHash, + }) : username = Value(username), + passwordHash = Value(passwordHash); + static Insertable custom({ + Expression? id, + Expression? createdAt, + Expression? username, + Expression? passwordHash, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (createdAt != null) 'created_at': createdAt, + if (username != null) 'username': username, + if (passwordHash != null) 'password_hash': passwordHash, + }); + } + + ScrobblerTableCompanion copyWith( + {Value? id, + Value? createdAt, + Value? username, + Value? passwordHash}) { + return ScrobblerTableCompanion( + id: id ?? this.id, + createdAt: createdAt ?? this.createdAt, + username: username ?? this.username, + passwordHash: passwordHash ?? this.passwordHash, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (username.present) { + map['username'] = Variable(username.value); + } + if (passwordHash.present) { + map['password_hash'] = Variable($ScrobblerTableTable + .$converterpasswordHash + .toSql(passwordHash.value)); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ScrobblerTableCompanion(') + ..write('id: $id, ') + ..write('createdAt: $createdAt, ') + ..write('username: $username, ') + ..write('passwordHash: $passwordHash') + ..write(')')) + .toString(); + } +} + +class $SkipSegmentTableTable extends SkipSegmentTable + with TableInfo<$SkipSegmentTableTable, SkipSegmentTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $SkipSegmentTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _startMeta = const VerificationMeta('start'); + @override + late final GeneratedColumn start = GeneratedColumn( + 'start', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true); + static const VerificationMeta _endMeta = const VerificationMeta('end'); + @override + late final GeneratedColumn end = GeneratedColumn( + 'end', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true); + static const VerificationMeta _trackIdMeta = + const VerificationMeta('trackId'); + @override + late final GeneratedColumn trackId = GeneratedColumn( + 'track_id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + @override + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: currentDateAndTime); + @override + List get $columns => [id, start, end, trackId, createdAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'skip_segment_table'; + @override + VerificationContext validateIntegrity( + Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + if (data.containsKey('start')) { + context.handle( + _startMeta, start.isAcceptableOrUnknown(data['start']!, _startMeta)); + } else if (isInserting) { + context.missing(_startMeta); + } + if (data.containsKey('end')) { + context.handle( + _endMeta, end.isAcceptableOrUnknown(data['end']!, _endMeta)); + } else if (isInserting) { + context.missing(_endMeta); + } + if (data.containsKey('track_id')) { + context.handle(_trackIdMeta, + trackId.isAcceptableOrUnknown(data['track_id']!, _trackIdMeta)); + } else if (isInserting) { + context.missing(_trackIdMeta); + } + if (data.containsKey('created_at')) { + context.handle(_createdAtMeta, + createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + SkipSegmentTableData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return SkipSegmentTableData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + start: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}start'])!, + end: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}end'])!, + trackId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}track_id'])!, + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + ); + } + + @override + $SkipSegmentTableTable createAlias(String alias) { + return $SkipSegmentTableTable(attachedDatabase, alias); + } +} + +class SkipSegmentTableData extends DataClass + implements Insertable { + final int id; + final int start; + final int end; + final String trackId; + final DateTime createdAt; + const SkipSegmentTableData( + {required this.id, + required this.start, + required this.end, + required this.trackId, + required this.createdAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['start'] = Variable(start); + map['end'] = Variable(end); + map['track_id'] = Variable(trackId); + map['created_at'] = Variable(createdAt); + return map; + } + + SkipSegmentTableCompanion toCompanion(bool nullToAbsent) { + return SkipSegmentTableCompanion( + id: Value(id), + start: Value(start), + end: Value(end), + trackId: Value(trackId), + createdAt: Value(createdAt), + ); + } + + factory SkipSegmentTableData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return SkipSegmentTableData( + id: serializer.fromJson(json['id']), + start: serializer.fromJson(json['start']), + end: serializer.fromJson(json['end']), + trackId: serializer.fromJson(json['trackId']), + createdAt: serializer.fromJson(json['createdAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'start': serializer.toJson(start), + 'end': serializer.toJson(end), + 'trackId': serializer.toJson(trackId), + 'createdAt': serializer.toJson(createdAt), + }; + } + + SkipSegmentTableData copyWith( + {int? id, + int? start, + int? end, + String? trackId, + DateTime? createdAt}) => + SkipSegmentTableData( + id: id ?? this.id, + start: start ?? this.start, + end: end ?? this.end, + trackId: trackId ?? this.trackId, + createdAt: createdAt ?? this.createdAt, + ); + @override + String toString() { + return (StringBuffer('SkipSegmentTableData(') + ..write('id: $id, ') + ..write('start: $start, ') + ..write('end: $end, ') + ..write('trackId: $trackId, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, start, end, trackId, createdAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is SkipSegmentTableData && + other.id == this.id && + other.start == this.start && + other.end == this.end && + other.trackId == this.trackId && + other.createdAt == this.createdAt); +} + +class SkipSegmentTableCompanion extends UpdateCompanion { + final Value id; + final Value start; + final Value end; + final Value trackId; + final Value createdAt; + const SkipSegmentTableCompanion({ + this.id = const Value.absent(), + this.start = const Value.absent(), + this.end = const Value.absent(), + this.trackId = const Value.absent(), + this.createdAt = const Value.absent(), + }); + SkipSegmentTableCompanion.insert({ + this.id = const Value.absent(), + required int start, + required int end, + required String trackId, + this.createdAt = const Value.absent(), + }) : start = Value(start), + end = Value(end), + trackId = Value(trackId); + static Insertable custom({ + Expression? id, + Expression? start, + Expression? end, + Expression? trackId, + Expression? createdAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (start != null) 'start': start, + if (end != null) 'end': end, + if (trackId != null) 'track_id': trackId, + if (createdAt != null) 'created_at': createdAt, + }); + } + + SkipSegmentTableCompanion copyWith( + {Value? id, + Value? start, + Value? end, + Value? trackId, + Value? createdAt}) { + return SkipSegmentTableCompanion( + id: id ?? this.id, + start: start ?? this.start, + end: end ?? this.end, + trackId: trackId ?? this.trackId, + createdAt: createdAt ?? this.createdAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (start.present) { + map['start'] = Variable(start.value); + } + if (end.present) { + map['end'] = Variable(end.value); + } + if (trackId.present) { + map['track_id'] = Variable(trackId.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('SkipSegmentTableCompanion(') + ..write('id: $id, ') + ..write('start: $start, ') + ..write('end: $end, ') + ..write('trackId: $trackId, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } +} + +class $SourceMatchTableTable extends SourceMatchTable + with TableInfo<$SourceMatchTableTable, SourceMatchTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $SourceMatchTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _trackIdMeta = + const VerificationMeta('trackId'); + @override + late final GeneratedColumn trackId = GeneratedColumn( + 'track_id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _sourceIdMeta = + const VerificationMeta('sourceId'); + @override + late final GeneratedColumn sourceId = GeneratedColumn( + 'source_id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _sourceTypeMeta = + const VerificationMeta('sourceType'); + @override + late final GeneratedColumnWithTypeConverter sourceType = + GeneratedColumn('source_type', aliasedName, false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: Constant(SourceType.youtube.name)) + .withConverter( + $SourceMatchTableTable.$convertersourceType); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + @override + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: currentDateAndTime); + @override + List get $columns => + [id, trackId, sourceId, sourceType, createdAt]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'source_match_table'; + @override + VerificationContext validateIntegrity( + Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + if (data.containsKey('track_id')) { + context.handle(_trackIdMeta, + trackId.isAcceptableOrUnknown(data['track_id']!, _trackIdMeta)); + } else if (isInserting) { + context.missing(_trackIdMeta); + } + if (data.containsKey('source_id')) { + context.handle(_sourceIdMeta, + sourceId.isAcceptableOrUnknown(data['source_id']!, _sourceIdMeta)); + } else if (isInserting) { + context.missing(_sourceIdMeta); + } + context.handle(_sourceTypeMeta, const VerificationResult.success()); + if (data.containsKey('created_at')) { + context.handle(_createdAtMeta, + createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + SourceMatchTableData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return SourceMatchTableData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + trackId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}track_id'])!, + sourceId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}source_id'])!, + sourceType: $SourceMatchTableTable.$convertersourceType.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}source_type'])!), + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + ); + } + + @override + $SourceMatchTableTable createAlias(String alias) { + return $SourceMatchTableTable(attachedDatabase, alias); + } + + static JsonTypeConverter2 $convertersourceType = + const EnumNameConverter(SourceType.values); +} + +class SourceMatchTableData extends DataClass + implements Insertable { + final int id; + final String trackId; + final String sourceId; + final SourceType sourceType; + final DateTime createdAt; + const SourceMatchTableData( + {required this.id, + required this.trackId, + required this.sourceId, + required this.sourceType, + required this.createdAt}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['track_id'] = Variable(trackId); + map['source_id'] = Variable(sourceId); + { + map['source_type'] = Variable( + $SourceMatchTableTable.$convertersourceType.toSql(sourceType)); + } + map['created_at'] = Variable(createdAt); + return map; + } + + SourceMatchTableCompanion toCompanion(bool nullToAbsent) { + return SourceMatchTableCompanion( + id: Value(id), + trackId: Value(trackId), + sourceId: Value(sourceId), + sourceType: Value(sourceType), + createdAt: Value(createdAt), + ); + } + + factory SourceMatchTableData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return SourceMatchTableData( + id: serializer.fromJson(json['id']), + trackId: serializer.fromJson(json['trackId']), + sourceId: serializer.fromJson(json['sourceId']), + sourceType: $SourceMatchTableTable.$convertersourceType + .fromJson(serializer.fromJson(json['sourceType'])), + createdAt: serializer.fromJson(json['createdAt']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'trackId': serializer.toJson(trackId), + 'sourceId': serializer.toJson(sourceId), + 'sourceType': serializer.toJson( + $SourceMatchTableTable.$convertersourceType.toJson(sourceType)), + 'createdAt': serializer.toJson(createdAt), + }; + } + + SourceMatchTableData copyWith( + {int? id, + String? trackId, + String? sourceId, + SourceType? sourceType, + DateTime? createdAt}) => + SourceMatchTableData( + id: id ?? this.id, + trackId: trackId ?? this.trackId, + sourceId: sourceId ?? this.sourceId, + sourceType: sourceType ?? this.sourceType, + createdAt: createdAt ?? this.createdAt, + ); + @override + String toString() { + return (StringBuffer('SourceMatchTableData(') + ..write('id: $id, ') + ..write('trackId: $trackId, ') + ..write('sourceId: $sourceId, ') + ..write('sourceType: $sourceType, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, trackId, sourceId, sourceType, createdAt); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is SourceMatchTableData && + other.id == this.id && + other.trackId == this.trackId && + other.sourceId == this.sourceId && + other.sourceType == this.sourceType && + other.createdAt == this.createdAt); +} + +class SourceMatchTableCompanion extends UpdateCompanion { + final Value id; + final Value trackId; + final Value sourceId; + final Value sourceType; + final Value createdAt; + const SourceMatchTableCompanion({ + this.id = const Value.absent(), + this.trackId = const Value.absent(), + this.sourceId = const Value.absent(), + this.sourceType = const Value.absent(), + this.createdAt = const Value.absent(), + }); + SourceMatchTableCompanion.insert({ + this.id = const Value.absent(), + required String trackId, + required String sourceId, + this.sourceType = const Value.absent(), + this.createdAt = const Value.absent(), + }) : trackId = Value(trackId), + sourceId = Value(sourceId); + static Insertable custom({ + Expression? id, + Expression? trackId, + Expression? sourceId, + Expression? sourceType, + Expression? createdAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (trackId != null) 'track_id': trackId, + if (sourceId != null) 'source_id': sourceId, + if (sourceType != null) 'source_type': sourceType, + if (createdAt != null) 'created_at': createdAt, + }); + } + + SourceMatchTableCompanion copyWith( + {Value? id, + Value? trackId, + Value? sourceId, + Value? sourceType, + Value? createdAt}) { + return SourceMatchTableCompanion( + id: id ?? this.id, + trackId: trackId ?? this.trackId, + sourceId: sourceId ?? this.sourceId, + sourceType: sourceType ?? this.sourceType, + createdAt: createdAt ?? this.createdAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (trackId.present) { + map['track_id'] = Variable(trackId.value); + } + if (sourceId.present) { + map['source_id'] = Variable(sourceId.value); + } + if (sourceType.present) { + map['source_type'] = Variable( + $SourceMatchTableTable.$convertersourceType.toSql(sourceType.value)); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('SourceMatchTableCompanion(') + ..write('id: $id, ') + ..write('trackId: $trackId, ') + ..write('sourceId: $sourceId, ') + ..write('sourceType: $sourceType, ') + ..write('createdAt: $createdAt') + ..write(')')) + .toString(); + } +} + +class $AudioPlayerStateTableTable extends AudioPlayerStateTable + with TableInfo<$AudioPlayerStateTableTable, AudioPlayerStateTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $AudioPlayerStateTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _playingMeta = + const VerificationMeta('playing'); + @override + late final GeneratedColumn playing = GeneratedColumn( + 'playing', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: true, + defaultConstraints: + GeneratedColumn.constraintIsAlways('CHECK ("playing" IN (0, 1))')); + static const VerificationMeta _loopModeMeta = + const VerificationMeta('loopMode'); + @override + late final GeneratedColumnWithTypeConverter loopMode = + GeneratedColumn('loop_mode', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter( + $AudioPlayerStateTableTable.$converterloopMode); + static const VerificationMeta _shuffledMeta = + const VerificationMeta('shuffled'); + @override + late final GeneratedColumn shuffled = GeneratedColumn( + 'shuffled', aliasedName, false, + type: DriftSqlType.bool, + requiredDuringInsert: true, + defaultConstraints: + GeneratedColumn.constraintIsAlways('CHECK ("shuffled" IN (0, 1))')); + static const VerificationMeta _collectionsMeta = + const VerificationMeta('collections'); + @override + late final GeneratedColumnWithTypeConverter, String> + collections = GeneratedColumn('collections', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter>( + $AudioPlayerStateTableTable.$convertercollections); + @override + List get $columns => + [id, playing, loopMode, shuffled, collections]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'audio_player_state_table'; + @override + VerificationContext validateIntegrity( + Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + if (data.containsKey('playing')) { + context.handle(_playingMeta, + playing.isAcceptableOrUnknown(data['playing']!, _playingMeta)); + } else if (isInserting) { + context.missing(_playingMeta); + } + context.handle(_loopModeMeta, const VerificationResult.success()); + if (data.containsKey('shuffled')) { + context.handle(_shuffledMeta, + shuffled.isAcceptableOrUnknown(data['shuffled']!, _shuffledMeta)); + } else if (isInserting) { + context.missing(_shuffledMeta); + } + context.handle(_collectionsMeta, const VerificationResult.success()); + return context; + } + + @override + Set get $primaryKey => {id}; + @override + AudioPlayerStateTableData map(Map data, + {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return AudioPlayerStateTableData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + playing: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}playing'])!, + loopMode: $AudioPlayerStateTableTable.$converterloopMode.fromSql( + attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}loop_mode'])!), + shuffled: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}shuffled'])!, + collections: $AudioPlayerStateTableTable.$convertercollections.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}collections'])!), + ); + } + + @override + $AudioPlayerStateTableTable createAlias(String alias) { + return $AudioPlayerStateTableTable(attachedDatabase, alias); + } + + static JsonTypeConverter2 $converterloopMode = + const EnumNameConverter(PlaylistMode.values); + static TypeConverter, String> $convertercollections = + const StringListConverter(); +} + +class AudioPlayerStateTableData extends DataClass + implements Insertable { + final int id; + final bool playing; + final PlaylistMode loopMode; + final bool shuffled; + final List collections; + const AudioPlayerStateTableData( + {required this.id, + required this.playing, + required this.loopMode, + required this.shuffled, + required this.collections}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['playing'] = Variable(playing); + { + map['loop_mode'] = Variable( + $AudioPlayerStateTableTable.$converterloopMode.toSql(loopMode)); + } + map['shuffled'] = Variable(shuffled); + { + map['collections'] = Variable( + $AudioPlayerStateTableTable.$convertercollections.toSql(collections)); + } + return map; + } + + AudioPlayerStateTableCompanion toCompanion(bool nullToAbsent) { + return AudioPlayerStateTableCompanion( + id: Value(id), + playing: Value(playing), + loopMode: Value(loopMode), + shuffled: Value(shuffled), + collections: Value(collections), + ); + } + + factory AudioPlayerStateTableData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return AudioPlayerStateTableData( + id: serializer.fromJson(json['id']), + playing: serializer.fromJson(json['playing']), + loopMode: $AudioPlayerStateTableTable.$converterloopMode + .fromJson(serializer.fromJson(json['loopMode'])), + shuffled: serializer.fromJson(json['shuffled']), + collections: serializer.fromJson>(json['collections']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'playing': serializer.toJson(playing), + 'loopMode': serializer.toJson( + $AudioPlayerStateTableTable.$converterloopMode.toJson(loopMode)), + 'shuffled': serializer.toJson(shuffled), + 'collections': serializer.toJson>(collections), + }; + } + + AudioPlayerStateTableData copyWith( + {int? id, + bool? playing, + PlaylistMode? loopMode, + bool? shuffled, + List? collections}) => + AudioPlayerStateTableData( + id: id ?? this.id, + playing: playing ?? this.playing, + loopMode: loopMode ?? this.loopMode, + shuffled: shuffled ?? this.shuffled, + collections: collections ?? this.collections, + ); + @override + String toString() { + return (StringBuffer('AudioPlayerStateTableData(') + ..write('id: $id, ') + ..write('playing: $playing, ') + ..write('loopMode: $loopMode, ') + ..write('shuffled: $shuffled, ') + ..write('collections: $collections') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, playing, loopMode, shuffled, collections); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is AudioPlayerStateTableData && + other.id == this.id && + other.playing == this.playing && + other.loopMode == this.loopMode && + other.shuffled == this.shuffled && + other.collections == this.collections); +} + +class AudioPlayerStateTableCompanion + extends UpdateCompanion { + final Value id; + final Value playing; + final Value loopMode; + final Value shuffled; + final Value> collections; + const AudioPlayerStateTableCompanion({ + this.id = const Value.absent(), + this.playing = const Value.absent(), + this.loopMode = const Value.absent(), + this.shuffled = const Value.absent(), + this.collections = const Value.absent(), + }); + AudioPlayerStateTableCompanion.insert({ + this.id = const Value.absent(), + required bool playing, + required PlaylistMode loopMode, + required bool shuffled, + required List collections, + }) : playing = Value(playing), + loopMode = Value(loopMode), + shuffled = Value(shuffled), + collections = Value(collections); + static Insertable custom({ + Expression? id, + Expression? playing, + Expression? loopMode, + Expression? shuffled, + Expression? collections, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (playing != null) 'playing': playing, + if (loopMode != null) 'loop_mode': loopMode, + if (shuffled != null) 'shuffled': shuffled, + if (collections != null) 'collections': collections, + }); + } + + AudioPlayerStateTableCompanion copyWith( + {Value? id, + Value? playing, + Value? loopMode, + Value? shuffled, + Value>? collections}) { + return AudioPlayerStateTableCompanion( + id: id ?? this.id, + playing: playing ?? this.playing, + loopMode: loopMode ?? this.loopMode, + shuffled: shuffled ?? this.shuffled, + collections: collections ?? this.collections, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (playing.present) { + map['playing'] = Variable(playing.value); + } + if (loopMode.present) { + map['loop_mode'] = Variable( + $AudioPlayerStateTableTable.$converterloopMode.toSql(loopMode.value)); + } + if (shuffled.present) { + map['shuffled'] = Variable(shuffled.value); + } + if (collections.present) { + map['collections'] = Variable($AudioPlayerStateTableTable + .$convertercollections + .toSql(collections.value)); + } + return map; + } + + @override + String toString() { + return (StringBuffer('AudioPlayerStateTableCompanion(') + ..write('id: $id, ') + ..write('playing: $playing, ') + ..write('loopMode: $loopMode, ') + ..write('shuffled: $shuffled, ') + ..write('collections: $collections') + ..write(')')) + .toString(); + } +} + +class $PlaylistTableTable extends PlaylistTable + with TableInfo<$PlaylistTableTable, PlaylistTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $PlaylistTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _audioPlayerStateIdMeta = + const VerificationMeta('audioPlayerStateId'); + @override + late final GeneratedColumn audioPlayerStateId = GeneratedColumn( + 'audio_player_state_id', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'REFERENCES audio_player_state_table (id)')); + static const VerificationMeta _indexMeta = const VerificationMeta('index'); + @override + late final GeneratedColumn index = GeneratedColumn( + 'index', aliasedName, false, + type: DriftSqlType.int, requiredDuringInsert: true); + @override + List get $columns => [id, audioPlayerStateId, index]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'playlist_table'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + if (data.containsKey('audio_player_state_id')) { + context.handle( + _audioPlayerStateIdMeta, + audioPlayerStateId.isAcceptableOrUnknown( + data['audio_player_state_id']!, _audioPlayerStateIdMeta)); + } else if (isInserting) { + context.missing(_audioPlayerStateIdMeta); + } + if (data.containsKey('index')) { + context.handle( + _indexMeta, index.isAcceptableOrUnknown(data['index']!, _indexMeta)); + } else if (isInserting) { + context.missing(_indexMeta); + } + return context; + } + + @override + Set get $primaryKey => {id}; + @override + PlaylistTableData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return PlaylistTableData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + audioPlayerStateId: attachedDatabase.typeMapping.read( + DriftSqlType.int, data['${effectivePrefix}audio_player_state_id'])!, + index: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}index'])!, + ); + } + + @override + $PlaylistTableTable createAlias(String alias) { + return $PlaylistTableTable(attachedDatabase, alias); + } +} + +class PlaylistTableData extends DataClass + implements Insertable { + final int id; + final int audioPlayerStateId; + final int index; + const PlaylistTableData( + {required this.id, + required this.audioPlayerStateId, + required this.index}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['audio_player_state_id'] = Variable(audioPlayerStateId); + map['index'] = Variable(index); + return map; + } + + PlaylistTableCompanion toCompanion(bool nullToAbsent) { + return PlaylistTableCompanion( + id: Value(id), + audioPlayerStateId: Value(audioPlayerStateId), + index: Value(index), + ); + } + + factory PlaylistTableData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return PlaylistTableData( + id: serializer.fromJson(json['id']), + audioPlayerStateId: serializer.fromJson(json['audioPlayerStateId']), + index: serializer.fromJson(json['index']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'audioPlayerStateId': serializer.toJson(audioPlayerStateId), + 'index': serializer.toJson(index), + }; + } + + PlaylistTableData copyWith({int? id, int? audioPlayerStateId, int? index}) => + PlaylistTableData( + id: id ?? this.id, + audioPlayerStateId: audioPlayerStateId ?? this.audioPlayerStateId, + index: index ?? this.index, + ); + @override + String toString() { + return (StringBuffer('PlaylistTableData(') + ..write('id: $id, ') + ..write('audioPlayerStateId: $audioPlayerStateId, ') + ..write('index: $index') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, audioPlayerStateId, index); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is PlaylistTableData && + other.id == this.id && + other.audioPlayerStateId == this.audioPlayerStateId && + other.index == this.index); +} + +class PlaylistTableCompanion extends UpdateCompanion { + final Value id; + final Value audioPlayerStateId; + final Value index; + const PlaylistTableCompanion({ + this.id = const Value.absent(), + this.audioPlayerStateId = const Value.absent(), + this.index = const Value.absent(), + }); + PlaylistTableCompanion.insert({ + this.id = const Value.absent(), + required int audioPlayerStateId, + required int index, + }) : audioPlayerStateId = Value(audioPlayerStateId), + index = Value(index); + static Insertable custom({ + Expression? id, + Expression? audioPlayerStateId, + Expression? index, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (audioPlayerStateId != null) + 'audio_player_state_id': audioPlayerStateId, + if (index != null) 'index': index, + }); + } + + PlaylistTableCompanion copyWith( + {Value? id, Value? audioPlayerStateId, Value? index}) { + return PlaylistTableCompanion( + id: id ?? this.id, + audioPlayerStateId: audioPlayerStateId ?? this.audioPlayerStateId, + index: index ?? this.index, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (audioPlayerStateId.present) { + map['audio_player_state_id'] = Variable(audioPlayerStateId.value); + } + if (index.present) { + map['index'] = Variable(index.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('PlaylistTableCompanion(') + ..write('id: $id, ') + ..write('audioPlayerStateId: $audioPlayerStateId, ') + ..write('index: $index') + ..write(')')) + .toString(); + } +} + +class $PlaylistMediaTableTable extends PlaylistMediaTable + with TableInfo<$PlaylistMediaTableTable, PlaylistMediaTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $PlaylistMediaTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _playlistIdMeta = + const VerificationMeta('playlistId'); + @override + late final GeneratedColumn playlistId = GeneratedColumn( + 'playlist_id', aliasedName, false, + type: DriftSqlType.int, + requiredDuringInsert: true, + defaultConstraints: + GeneratedColumn.constraintIsAlways('REFERENCES playlist_table (id)')); + static const VerificationMeta _uriMeta = const VerificationMeta('uri'); + @override + late final GeneratedColumn uri = GeneratedColumn( + 'uri', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _extrasMeta = const VerificationMeta('extras'); + @override + late final GeneratedColumnWithTypeConverter?, String> + extras = GeneratedColumn('extras', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $PlaylistMediaTableTable.$converterextrasn); + static const VerificationMeta _httpHeadersMeta = + const VerificationMeta('httpHeaders'); + @override + late final GeneratedColumnWithTypeConverter?, String> + httpHeaders = GeneratedColumn('http_headers', aliasedName, true, + type: DriftSqlType.string, requiredDuringInsert: false) + .withConverter?>( + $PlaylistMediaTableTable.$converterhttpHeadersn); + @override + List get $columns => + [id, playlistId, uri, extras, httpHeaders]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'playlist_media_table'; + @override + VerificationContext validateIntegrity( + Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + if (data.containsKey('playlist_id')) { + context.handle( + _playlistIdMeta, + playlistId.isAcceptableOrUnknown( + data['playlist_id']!, _playlistIdMeta)); + } else if (isInserting) { + context.missing(_playlistIdMeta); + } + if (data.containsKey('uri')) { + context.handle( + _uriMeta, uri.isAcceptableOrUnknown(data['uri']!, _uriMeta)); + } else if (isInserting) { + context.missing(_uriMeta); + } + context.handle(_extrasMeta, const VerificationResult.success()); + context.handle(_httpHeadersMeta, const VerificationResult.success()); + return context; + } + + @override + Set get $primaryKey => {id}; + @override + PlaylistMediaTableData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return PlaylistMediaTableData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + playlistId: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}playlist_id'])!, + uri: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}uri'])!, + extras: $PlaylistMediaTableTable.$converterextrasn.fromSql( + attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}extras'])), + httpHeaders: $PlaylistMediaTableTable.$converterhttpHeadersn.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.string, data['${effectivePrefix}http_headers'])), + ); + } + + @override + $PlaylistMediaTableTable createAlias(String alias) { + return $PlaylistMediaTableTable(attachedDatabase, alias); + } + + static TypeConverter, String> $converterextras = + const MapTypeConverter(); + static TypeConverter?, String?> $converterextrasn = + NullAwareTypeConverter.wrap($converterextras); + static TypeConverter, String> $converterhttpHeaders = + const MapTypeConverter(); + static TypeConverter?, String?> $converterhttpHeadersn = + NullAwareTypeConverter.wrap($converterhttpHeaders); +} + +class PlaylistMediaTableData extends DataClass + implements Insertable { + final int id; + final int playlistId; + final String uri; + final Map? extras; + final Map? httpHeaders; + const PlaylistMediaTableData( + {required this.id, + required this.playlistId, + required this.uri, + this.extras, + this.httpHeaders}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['playlist_id'] = Variable(playlistId); + map['uri'] = Variable(uri); + if (!nullToAbsent || extras != null) { + map['extras'] = Variable( + $PlaylistMediaTableTable.$converterextrasn.toSql(extras)); + } + if (!nullToAbsent || httpHeaders != null) { + map['http_headers'] = Variable( + $PlaylistMediaTableTable.$converterhttpHeadersn.toSql(httpHeaders)); + } + return map; + } + + PlaylistMediaTableCompanion toCompanion(bool nullToAbsent) { + return PlaylistMediaTableCompanion( + id: Value(id), + playlistId: Value(playlistId), + uri: Value(uri), + extras: + extras == null && nullToAbsent ? const Value.absent() : Value(extras), + httpHeaders: httpHeaders == null && nullToAbsent + ? const Value.absent() + : Value(httpHeaders), + ); + } + + factory PlaylistMediaTableData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return PlaylistMediaTableData( + id: serializer.fromJson(json['id']), + playlistId: serializer.fromJson(json['playlistId']), + uri: serializer.fromJson(json['uri']), + extras: serializer.fromJson?>(json['extras']), + httpHeaders: + serializer.fromJson?>(json['httpHeaders']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'playlistId': serializer.toJson(playlistId), + 'uri': serializer.toJson(uri), + 'extras': serializer.toJson?>(extras), + 'httpHeaders': serializer.toJson?>(httpHeaders), + }; + } + + PlaylistMediaTableData copyWith( + {int? id, + int? playlistId, + String? uri, + Value?> extras = const Value.absent(), + Value?> httpHeaders = const Value.absent()}) => + PlaylistMediaTableData( + id: id ?? this.id, + playlistId: playlistId ?? this.playlistId, + uri: uri ?? this.uri, + extras: extras.present ? extras.value : this.extras, + httpHeaders: httpHeaders.present ? httpHeaders.value : this.httpHeaders, + ); + @override + String toString() { + return (StringBuffer('PlaylistMediaTableData(') + ..write('id: $id, ') + ..write('playlistId: $playlistId, ') + ..write('uri: $uri, ') + ..write('extras: $extras, ') + ..write('httpHeaders: $httpHeaders') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, playlistId, uri, extras, httpHeaders); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is PlaylistMediaTableData && + other.id == this.id && + other.playlistId == this.playlistId && + other.uri == this.uri && + other.extras == this.extras && + other.httpHeaders == this.httpHeaders); +} + +class PlaylistMediaTableCompanion + extends UpdateCompanion { + final Value id; + final Value playlistId; + final Value uri; + final Value?> extras; + final Value?> httpHeaders; + const PlaylistMediaTableCompanion({ + this.id = const Value.absent(), + this.playlistId = const Value.absent(), + this.uri = const Value.absent(), + this.extras = const Value.absent(), + this.httpHeaders = const Value.absent(), + }); + PlaylistMediaTableCompanion.insert({ + this.id = const Value.absent(), + required int playlistId, + required String uri, + this.extras = const Value.absent(), + this.httpHeaders = const Value.absent(), + }) : playlistId = Value(playlistId), + uri = Value(uri); + static Insertable custom({ + Expression? id, + Expression? playlistId, + Expression? uri, + Expression? extras, + Expression? httpHeaders, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (playlistId != null) 'playlist_id': playlistId, + if (uri != null) 'uri': uri, + if (extras != null) 'extras': extras, + if (httpHeaders != null) 'http_headers': httpHeaders, + }); + } + + PlaylistMediaTableCompanion copyWith( + {Value? id, + Value? playlistId, + Value? uri, + Value?>? extras, + Value?>? httpHeaders}) { + return PlaylistMediaTableCompanion( + id: id ?? this.id, + playlistId: playlistId ?? this.playlistId, + uri: uri ?? this.uri, + extras: extras ?? this.extras, + httpHeaders: httpHeaders ?? this.httpHeaders, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (playlistId.present) { + map['playlist_id'] = Variable(playlistId.value); + } + if (uri.present) { + map['uri'] = Variable(uri.value); + } + if (extras.present) { + map['extras'] = Variable( + $PlaylistMediaTableTable.$converterextrasn.toSql(extras.value)); + } + if (httpHeaders.present) { + map['http_headers'] = Variable($PlaylistMediaTableTable + .$converterhttpHeadersn + .toSql(httpHeaders.value)); + } + return map; + } + + @override + String toString() { + return (StringBuffer('PlaylistMediaTableCompanion(') + ..write('id: $id, ') + ..write('playlistId: $playlistId, ') + ..write('uri: $uri, ') + ..write('extras: $extras, ') + ..write('httpHeaders: $httpHeaders') + ..write(')')) + .toString(); + } +} + +class $HistoryTableTable extends HistoryTable + with TableInfo<$HistoryTableTable, HistoryTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $HistoryTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _createdAtMeta = + const VerificationMeta('createdAt'); + @override + late final GeneratedColumn createdAt = GeneratedColumn( + 'created_at', aliasedName, false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: currentDateAndTime); + static const VerificationMeta _typeMeta = const VerificationMeta('type'); + @override + late final GeneratedColumnWithTypeConverter type = + GeneratedColumn('type', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter($HistoryTableTable.$convertertype); + static const VerificationMeta _itemIdMeta = const VerificationMeta('itemId'); + @override + late final GeneratedColumn itemId = GeneratedColumn( + 'item_id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _dataMeta = const VerificationMeta('data'); + @override + late final GeneratedColumnWithTypeConverter, String> + data = GeneratedColumn('data', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter>( + $HistoryTableTable.$converterdata); + @override + List get $columns => [id, createdAt, type, itemId, data]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'history_table'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + if (data.containsKey('created_at')) { + context.handle(_createdAtMeta, + createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta)); + } + context.handle(_typeMeta, const VerificationResult.success()); + if (data.containsKey('item_id')) { + context.handle(_itemIdMeta, + itemId.isAcceptableOrUnknown(data['item_id']!, _itemIdMeta)); + } else if (isInserting) { + context.missing(_itemIdMeta); + } + context.handle(_dataMeta, const VerificationResult.success()); + return context; + } + + @override + Set get $primaryKey => {id}; + @override + HistoryTableData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return HistoryTableData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + createdAt: attachedDatabase.typeMapping + .read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!, + type: $HistoryTableTable.$convertertype.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}type'])!), + itemId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}item_id'])!, + data: $HistoryTableTable.$converterdata.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}data'])!), + ); + } + + @override + $HistoryTableTable createAlias(String alias) { + return $HistoryTableTable(attachedDatabase, alias); + } + + static JsonTypeConverter2 $convertertype = + const EnumNameConverter(HistoryEntryType.values); + static TypeConverter, String> $converterdata = + const MapTypeConverter(); +} + +class HistoryTableData extends DataClass + implements Insertable { + final int id; + final DateTime createdAt; + final HistoryEntryType type; + final String itemId; + final Map data; + const HistoryTableData( + {required this.id, + required this.createdAt, + required this.type, + required this.itemId, + required this.data}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['created_at'] = Variable(createdAt); + { + map['type'] = + Variable($HistoryTableTable.$convertertype.toSql(type)); + } + map['item_id'] = Variable(itemId); + { + map['data'] = + Variable($HistoryTableTable.$converterdata.toSql(data)); + } + return map; + } + + HistoryTableCompanion toCompanion(bool nullToAbsent) { + return HistoryTableCompanion( + id: Value(id), + createdAt: Value(createdAt), + type: Value(type), + itemId: Value(itemId), + data: Value(data), + ); + } + + factory HistoryTableData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return HistoryTableData( + id: serializer.fromJson(json['id']), + createdAt: serializer.fromJson(json['createdAt']), + type: $HistoryTableTable.$convertertype + .fromJson(serializer.fromJson(json['type'])), + itemId: serializer.fromJson(json['itemId']), + data: serializer.fromJson>(json['data']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'createdAt': serializer.toJson(createdAt), + 'type': serializer + .toJson($HistoryTableTable.$convertertype.toJson(type)), + 'itemId': serializer.toJson(itemId), + 'data': serializer.toJson>(data), + }; + } + + HistoryTableData copyWith( + {int? id, + DateTime? createdAt, + HistoryEntryType? type, + String? itemId, + Map? data}) => + HistoryTableData( + id: id ?? this.id, + createdAt: createdAt ?? this.createdAt, + type: type ?? this.type, + itemId: itemId ?? this.itemId, + data: data ?? this.data, + ); + @override + String toString() { + return (StringBuffer('HistoryTableData(') + ..write('id: $id, ') + ..write('createdAt: $createdAt, ') + ..write('type: $type, ') + ..write('itemId: $itemId, ') + ..write('data: $data') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, createdAt, type, itemId, data); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is HistoryTableData && + other.id == this.id && + other.createdAt == this.createdAt && + other.type == this.type && + other.itemId == this.itemId && + other.data == this.data); +} + +class HistoryTableCompanion extends UpdateCompanion { + final Value id; + final Value createdAt; + final Value type; + final Value itemId; + final Value> data; + const HistoryTableCompanion({ + this.id = const Value.absent(), + this.createdAt = const Value.absent(), + this.type = const Value.absent(), + this.itemId = const Value.absent(), + this.data = const Value.absent(), + }); + HistoryTableCompanion.insert({ + this.id = const Value.absent(), + this.createdAt = const Value.absent(), + required HistoryEntryType type, + required String itemId, + required Map data, + }) : type = Value(type), + itemId = Value(itemId), + data = Value(data); + static Insertable custom({ + Expression? id, + Expression? createdAt, + Expression? type, + Expression? itemId, + Expression? data, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (createdAt != null) 'created_at': createdAt, + if (type != null) 'type': type, + if (itemId != null) 'item_id': itemId, + if (data != null) 'data': data, + }); + } + + HistoryTableCompanion copyWith( + {Value? id, + Value? createdAt, + Value? type, + Value? itemId, + Value>? data}) { + return HistoryTableCompanion( + id: id ?? this.id, + createdAt: createdAt ?? this.createdAt, + type: type ?? this.type, + itemId: itemId ?? this.itemId, + data: data ?? this.data, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (createdAt.present) { + map['created_at'] = Variable(createdAt.value); + } + if (type.present) { + map['type'] = + Variable($HistoryTableTable.$convertertype.toSql(type.value)); + } + if (itemId.present) { + map['item_id'] = Variable(itemId.value); + } + if (data.present) { + map['data'] = + Variable($HistoryTableTable.$converterdata.toSql(data.value)); + } + return map; + } + + @override + String toString() { + return (StringBuffer('HistoryTableCompanion(') + ..write('id: $id, ') + ..write('createdAt: $createdAt, ') + ..write('type: $type, ') + ..write('itemId: $itemId, ') + ..write('data: $data') + ..write(')')) + .toString(); + } +} + +class $LyricsTableTable extends LyricsTable + with TableInfo<$LyricsTableTable, LyricsTableData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + $LyricsTableTable(this.attachedDatabase, [this._alias]); + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', aliasedName, false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: + GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT')); + static const VerificationMeta _trackIdMeta = + const VerificationMeta('trackId'); + @override + late final GeneratedColumn trackId = GeneratedColumn( + 'track_id', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true); + static const VerificationMeta _dataMeta = const VerificationMeta('data'); + @override + late final GeneratedColumnWithTypeConverter data = + GeneratedColumn('data', aliasedName, false, + type: DriftSqlType.string, requiredDuringInsert: true) + .withConverter($LyricsTableTable.$converterdata); + @override + List get $columns => [id, trackId, data]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'lyrics_table'; + @override + VerificationContext validateIntegrity(Insertable instance, + {bool isInserting = false}) { + final context = VerificationContext(); + final data = instance.toColumns(true); + if (data.containsKey('id')) { + context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta)); + } + if (data.containsKey('track_id')) { + context.handle(_trackIdMeta, + trackId.isAcceptableOrUnknown(data['track_id']!, _trackIdMeta)); + } else if (isInserting) { + context.missing(_trackIdMeta); + } + context.handle(_dataMeta, const VerificationResult.success()); + return context; + } + + @override + Set get $primaryKey => {id}; + @override + LyricsTableData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return LyricsTableData( + id: attachedDatabase.typeMapping + .read(DriftSqlType.int, data['${effectivePrefix}id'])!, + trackId: attachedDatabase.typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}track_id'])!, + data: $LyricsTableTable.$converterdata.fromSql(attachedDatabase + .typeMapping + .read(DriftSqlType.string, data['${effectivePrefix}data'])!), + ); + } + + @override + $LyricsTableTable createAlias(String alias) { + return $LyricsTableTable(attachedDatabase, alias); + } + + static TypeConverter $converterdata = + SubtitleTypeConverter(); +} + +class LyricsTableData extends DataClass implements Insertable { + final int id; + final String trackId; + final SubtitleSimple data; + const LyricsTableData( + {required this.id, required this.trackId, required this.data}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['track_id'] = Variable(trackId); + { + map['data'] = + Variable($LyricsTableTable.$converterdata.toSql(data)); + } + return map; + } + + LyricsTableCompanion toCompanion(bool nullToAbsent) { + return LyricsTableCompanion( + id: Value(id), + trackId: Value(trackId), + data: Value(data), + ); + } + + factory LyricsTableData.fromJson(Map json, + {ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return LyricsTableData( + id: serializer.fromJson(json['id']), + trackId: serializer.fromJson(json['trackId']), + data: serializer.fromJson(json['data']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'trackId': serializer.toJson(trackId), + 'data': serializer.toJson(data), + }; + } + + LyricsTableData copyWith({int? id, String? trackId, SubtitleSimple? data}) => + LyricsTableData( + id: id ?? this.id, + trackId: trackId ?? this.trackId, + data: data ?? this.data, + ); + @override + String toString() { + return (StringBuffer('LyricsTableData(') + ..write('id: $id, ') + ..write('trackId: $trackId, ') + ..write('data: $data') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, trackId, data); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is LyricsTableData && + other.id == this.id && + other.trackId == this.trackId && + other.data == this.data); +} + +class LyricsTableCompanion extends UpdateCompanion { + final Value id; + final Value trackId; + final Value data; + const LyricsTableCompanion({ + this.id = const Value.absent(), + this.trackId = const Value.absent(), + this.data = const Value.absent(), + }); + LyricsTableCompanion.insert({ + this.id = const Value.absent(), + required String trackId, + required SubtitleSimple data, + }) : trackId = Value(trackId), + data = Value(data); + static Insertable custom({ + Expression? id, + Expression? trackId, + Expression? data, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (trackId != null) 'track_id': trackId, + if (data != null) 'data': data, + }); + } + + LyricsTableCompanion copyWith( + {Value? id, Value? trackId, Value? data}) { + return LyricsTableCompanion( + id: id ?? this.id, + trackId: trackId ?? this.trackId, + data: data ?? this.data, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (trackId.present) { + map['track_id'] = Variable(trackId.value); + } + if (data.present) { + map['data'] = + Variable($LyricsTableTable.$converterdata.toSql(data.value)); + } + return map; + } + + @override + String toString() { + return (StringBuffer('LyricsTableCompanion(') + ..write('id: $id, ') + ..write('trackId: $trackId, ') + ..write('data: $data') + ..write(')')) + .toString(); + } +} + +abstract class _$AppDatabase extends GeneratedDatabase { + _$AppDatabase(QueryExecutor e) : super(e); + _$AppDatabaseManager get managers => _$AppDatabaseManager(this); + late final $AuthenticationTableTable authenticationTable = + $AuthenticationTableTable(this); + late final $BlacklistTableTable blacklistTable = $BlacklistTableTable(this); + late final $PreferencesTableTable preferencesTable = + $PreferencesTableTable(this); + late final $ScrobblerTableTable scrobblerTable = $ScrobblerTableTable(this); + late final $SkipSegmentTableTable skipSegmentTable = + $SkipSegmentTableTable(this); + late final $SourceMatchTableTable sourceMatchTable = + $SourceMatchTableTable(this); + late final $AudioPlayerStateTableTable audioPlayerStateTable = + $AudioPlayerStateTableTable(this); + late final $PlaylistTableTable playlistTable = $PlaylistTableTable(this); + late final $PlaylistMediaTableTable playlistMediaTable = + $PlaylistMediaTableTable(this); + late final $HistoryTableTable historyTable = $HistoryTableTable(this); + late final $LyricsTableTable lyricsTable = $LyricsTableTable(this); + late final Index uniqueBlacklist = Index('unique_blacklist', + 'CREATE UNIQUE INDEX unique_blacklist ON blacklist_table (element_type, element_id)'); + late final Index uniqTrackMatch = Index('uniq_track_match', + 'CREATE UNIQUE INDEX uniq_track_match ON source_match_table (track_id, source_id, source_type)'); + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => [ + authenticationTable, + blacklistTable, + preferencesTable, + scrobblerTable, + skipSegmentTable, + sourceMatchTable, + audioPlayerStateTable, + playlistTable, + playlistMediaTable, + historyTable, + lyricsTable, + uniqueBlacklist, + uniqTrackMatch + ]; +} + +typedef $$AuthenticationTableTableInsertCompanionBuilder + = AuthenticationTableCompanion Function({ + Value id, + required DecryptedText cookie, + required DecryptedText accessToken, + required DateTime expiration, +}); +typedef $$AuthenticationTableTableUpdateCompanionBuilder + = AuthenticationTableCompanion Function({ + Value id, + Value cookie, + Value accessToken, + Value expiration, +}); + +class $$AuthenticationTableTableTableManager extends RootTableManager< + _$AppDatabase, + $AuthenticationTableTable, + AuthenticationTableData, + $$AuthenticationTableTableFilterComposer, + $$AuthenticationTableTableOrderingComposer, + $$AuthenticationTableTableProcessedTableManager, + $$AuthenticationTableTableInsertCompanionBuilder, + $$AuthenticationTableTableUpdateCompanionBuilder> { + $$AuthenticationTableTableTableManager( + _$AppDatabase db, $AuthenticationTableTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: $$AuthenticationTableTableFilterComposer( + ComposerState(db, table)), + orderingComposer: $$AuthenticationTableTableOrderingComposer( + ComposerState(db, table)), + getChildManagerBuilder: (p) => + $$AuthenticationTableTableProcessedTableManager(p), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value cookie = const Value.absent(), + Value accessToken = const Value.absent(), + Value expiration = const Value.absent(), + }) => + AuthenticationTableCompanion( + id: id, + cookie: cookie, + accessToken: accessToken, + expiration: expiration, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + required DecryptedText cookie, + required DecryptedText accessToken, + required DateTime expiration, + }) => + AuthenticationTableCompanion.insert( + id: id, + cookie: cookie, + accessToken: accessToken, + expiration: expiration, + ), + )); +} + +class $$AuthenticationTableTableProcessedTableManager + extends ProcessedTableManager< + _$AppDatabase, + $AuthenticationTableTable, + AuthenticationTableData, + $$AuthenticationTableTableFilterComposer, + $$AuthenticationTableTableOrderingComposer, + $$AuthenticationTableTableProcessedTableManager, + $$AuthenticationTableTableInsertCompanionBuilder, + $$AuthenticationTableTableUpdateCompanionBuilder> { + $$AuthenticationTableTableProcessedTableManager(super.$state); +} + +class $$AuthenticationTableTableFilterComposer + extends FilterComposer<_$AppDatabase, $AuthenticationTableTable> { + $$AuthenticationTableTableFilterComposer(super.$state); + ColumnFilters get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get cookie => $state.composableBuilder( + column: $state.table.cookie, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get accessToken => $state.composableBuilder( + column: $state.table.accessToken, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnFilters get expiration => $state.composableBuilder( + column: $state.table.expiration, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); +} + +class $$AuthenticationTableTableOrderingComposer + extends OrderingComposer<_$AppDatabase, $AuthenticationTableTable> { + $$AuthenticationTableTableOrderingComposer(super.$state); + ColumnOrderings get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get cookie => $state.composableBuilder( + column: $state.table.cookie, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get accessToken => $state.composableBuilder( + column: $state.table.accessToken, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get expiration => $state.composableBuilder( + column: $state.table.expiration, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); +} + +typedef $$BlacklistTableTableInsertCompanionBuilder = BlacklistTableCompanion + Function({ + Value id, + required String name, + required BlacklistedType elementType, + required String elementId, +}); +typedef $$BlacklistTableTableUpdateCompanionBuilder = BlacklistTableCompanion + Function({ + Value id, + Value name, + Value elementType, + Value elementId, +}); + +class $$BlacklistTableTableTableManager extends RootTableManager< + _$AppDatabase, + $BlacklistTableTable, + BlacklistTableData, + $$BlacklistTableTableFilterComposer, + $$BlacklistTableTableOrderingComposer, + $$BlacklistTableTableProcessedTableManager, + $$BlacklistTableTableInsertCompanionBuilder, + $$BlacklistTableTableUpdateCompanionBuilder> { + $$BlacklistTableTableTableManager( + _$AppDatabase db, $BlacklistTableTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: + $$BlacklistTableTableFilterComposer(ComposerState(db, table)), + orderingComposer: + $$BlacklistTableTableOrderingComposer(ComposerState(db, table)), + getChildManagerBuilder: (p) => + $$BlacklistTableTableProcessedTableManager(p), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value name = const Value.absent(), + Value elementType = const Value.absent(), + Value elementId = const Value.absent(), + }) => + BlacklistTableCompanion( + id: id, + name: name, + elementType: elementType, + elementId: elementId, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + required String name, + required BlacklistedType elementType, + required String elementId, + }) => + BlacklistTableCompanion.insert( + id: id, + name: name, + elementType: elementType, + elementId: elementId, + ), + )); +} + +class $$BlacklistTableTableProcessedTableManager extends ProcessedTableManager< + _$AppDatabase, + $BlacklistTableTable, + BlacklistTableData, + $$BlacklistTableTableFilterComposer, + $$BlacklistTableTableOrderingComposer, + $$BlacklistTableTableProcessedTableManager, + $$BlacklistTableTableInsertCompanionBuilder, + $$BlacklistTableTableUpdateCompanionBuilder> { + $$BlacklistTableTableProcessedTableManager(super.$state); +} + +class $$BlacklistTableTableFilterComposer + extends FilterComposer<_$AppDatabase, $BlacklistTableTable> { + $$BlacklistTableTableFilterComposer(super.$state); + ColumnFilters get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get name => $state.composableBuilder( + column: $state.table.name, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get elementType => $state.composableBuilder( + column: $state.table.elementType, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnFilters get elementId => $state.composableBuilder( + column: $state.table.elementId, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); +} + +class $$BlacklistTableTableOrderingComposer + extends OrderingComposer<_$AppDatabase, $BlacklistTableTable> { + $$BlacklistTableTableOrderingComposer(super.$state); + ColumnOrderings get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get name => $state.composableBuilder( + column: $state.table.name, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get elementType => $state.composableBuilder( + column: $state.table.elementType, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get elementId => $state.composableBuilder( + column: $state.table.elementId, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); +} + +typedef $$PreferencesTableTableInsertCompanionBuilder + = PreferencesTableCompanion Function({ + Value id, + Value audioQuality, + Value albumColorSync, + Value amoledDarkTheme, + Value checkUpdate, + Value normalizeAudio, + Value showSystemTrayIcon, + Value systemTitleBar, + Value skipNonMusic, + Value closeBehavior, + Value accentColorScheme, + Value layoutMode, + Value locale, + Value market, + Value searchMode, + Value downloadLocation, + Value> localLibraryLocation, + Value pipedInstance, + Value themeMode, + Value audioSource, + Value streamMusicCodec, + Value downloadMusicCodec, + Value discordPresence, + Value endlessPlayback, + Value enableConnect, +}); +typedef $$PreferencesTableTableUpdateCompanionBuilder + = PreferencesTableCompanion Function({ + Value id, + Value audioQuality, + Value albumColorSync, + Value amoledDarkTheme, + Value checkUpdate, + Value normalizeAudio, + Value showSystemTrayIcon, + Value systemTitleBar, + Value skipNonMusic, + Value closeBehavior, + Value accentColorScheme, + Value layoutMode, + Value locale, + Value market, + Value searchMode, + Value downloadLocation, + Value> localLibraryLocation, + Value pipedInstance, + Value themeMode, + Value audioSource, + Value streamMusicCodec, + Value downloadMusicCodec, + Value discordPresence, + Value endlessPlayback, + Value enableConnect, +}); + +class $$PreferencesTableTableTableManager extends RootTableManager< + _$AppDatabase, + $PreferencesTableTable, + PreferencesTableData, + $$PreferencesTableTableFilterComposer, + $$PreferencesTableTableOrderingComposer, + $$PreferencesTableTableProcessedTableManager, + $$PreferencesTableTableInsertCompanionBuilder, + $$PreferencesTableTableUpdateCompanionBuilder> { + $$PreferencesTableTableTableManager( + _$AppDatabase db, $PreferencesTableTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: + $$PreferencesTableTableFilterComposer(ComposerState(db, table)), + orderingComposer: + $$PreferencesTableTableOrderingComposer(ComposerState(db, table)), + getChildManagerBuilder: (p) => + $$PreferencesTableTableProcessedTableManager(p), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value audioQuality = const Value.absent(), + Value albumColorSync = const Value.absent(), + Value amoledDarkTheme = const Value.absent(), + Value checkUpdate = const Value.absent(), + Value normalizeAudio = const Value.absent(), + Value showSystemTrayIcon = const Value.absent(), + Value systemTitleBar = const Value.absent(), + Value skipNonMusic = const Value.absent(), + Value closeBehavior = const Value.absent(), + Value accentColorScheme = const Value.absent(), + Value layoutMode = const Value.absent(), + Value locale = const Value.absent(), + Value market = const Value.absent(), + Value searchMode = const Value.absent(), + Value downloadLocation = const Value.absent(), + Value> localLibraryLocation = const Value.absent(), + Value pipedInstance = const Value.absent(), + Value themeMode = const Value.absent(), + Value audioSource = const Value.absent(), + Value streamMusicCodec = const Value.absent(), + Value downloadMusicCodec = const Value.absent(), + Value discordPresence = const Value.absent(), + Value endlessPlayback = const Value.absent(), + Value enableConnect = const Value.absent(), + }) => + PreferencesTableCompanion( + id: id, + audioQuality: audioQuality, + albumColorSync: albumColorSync, + amoledDarkTheme: amoledDarkTheme, + checkUpdate: checkUpdate, + normalizeAudio: normalizeAudio, + showSystemTrayIcon: showSystemTrayIcon, + systemTitleBar: systemTitleBar, + skipNonMusic: skipNonMusic, + closeBehavior: closeBehavior, + accentColorScheme: accentColorScheme, + layoutMode: layoutMode, + locale: locale, + market: market, + searchMode: searchMode, + downloadLocation: downloadLocation, + localLibraryLocation: localLibraryLocation, + pipedInstance: pipedInstance, + themeMode: themeMode, + audioSource: audioSource, + streamMusicCodec: streamMusicCodec, + downloadMusicCodec: downloadMusicCodec, + discordPresence: discordPresence, + endlessPlayback: endlessPlayback, + enableConnect: enableConnect, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + Value audioQuality = const Value.absent(), + Value albumColorSync = const Value.absent(), + Value amoledDarkTheme = const Value.absent(), + Value checkUpdate = const Value.absent(), + Value normalizeAudio = const Value.absent(), + Value showSystemTrayIcon = const Value.absent(), + Value systemTitleBar = const Value.absent(), + Value skipNonMusic = const Value.absent(), + Value closeBehavior = const Value.absent(), + Value accentColorScheme = const Value.absent(), + Value layoutMode = const Value.absent(), + Value locale = const Value.absent(), + Value market = const Value.absent(), + Value searchMode = const Value.absent(), + Value downloadLocation = const Value.absent(), + Value> localLibraryLocation = const Value.absent(), + Value pipedInstance = const Value.absent(), + Value themeMode = const Value.absent(), + Value audioSource = const Value.absent(), + Value streamMusicCodec = const Value.absent(), + Value downloadMusicCodec = const Value.absent(), + Value discordPresence = const Value.absent(), + Value endlessPlayback = const Value.absent(), + Value enableConnect = const Value.absent(), + }) => + PreferencesTableCompanion.insert( + id: id, + audioQuality: audioQuality, + albumColorSync: albumColorSync, + amoledDarkTheme: amoledDarkTheme, + checkUpdate: checkUpdate, + normalizeAudio: normalizeAudio, + showSystemTrayIcon: showSystemTrayIcon, + systemTitleBar: systemTitleBar, + skipNonMusic: skipNonMusic, + closeBehavior: closeBehavior, + accentColorScheme: accentColorScheme, + layoutMode: layoutMode, + locale: locale, + market: market, + searchMode: searchMode, + downloadLocation: downloadLocation, + localLibraryLocation: localLibraryLocation, + pipedInstance: pipedInstance, + themeMode: themeMode, + audioSource: audioSource, + streamMusicCodec: streamMusicCodec, + downloadMusicCodec: downloadMusicCodec, + discordPresence: discordPresence, + endlessPlayback: endlessPlayback, + enableConnect: enableConnect, + ), + )); +} + +class $$PreferencesTableTableProcessedTableManager + extends ProcessedTableManager< + _$AppDatabase, + $PreferencesTableTable, + PreferencesTableData, + $$PreferencesTableTableFilterComposer, + $$PreferencesTableTableOrderingComposer, + $$PreferencesTableTableProcessedTableManager, + $$PreferencesTableTableInsertCompanionBuilder, + $$PreferencesTableTableUpdateCompanionBuilder> { + $$PreferencesTableTableProcessedTableManager(super.$state); +} + +class $$PreferencesTableTableFilterComposer + extends FilterComposer<_$AppDatabase, $PreferencesTableTable> { + $$PreferencesTableTableFilterComposer(super.$state); + ColumnFilters get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get audioQuality => $state.composableBuilder( + column: $state.table.audioQuality, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnFilters get albumColorSync => $state.composableBuilder( + column: $state.table.albumColorSync, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get amoledDarkTheme => $state.composableBuilder( + column: $state.table.amoledDarkTheme, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get checkUpdate => $state.composableBuilder( + column: $state.table.checkUpdate, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get normalizeAudio => $state.composableBuilder( + column: $state.table.normalizeAudio, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get showSystemTrayIcon => $state.composableBuilder( + column: $state.table.showSystemTrayIcon, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get systemTitleBar => $state.composableBuilder( + column: $state.table.systemTitleBar, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get skipNonMusic => $state.composableBuilder( + column: $state.table.skipNonMusic, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get closeBehavior => $state.composableBuilder( + column: $state.table.closeBehavior, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get accentColorScheme => $state.composableBuilder( + column: $state.table.accentColorScheme, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get layoutMode => $state.composableBuilder( + column: $state.table.layoutMode, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters get locale => + $state.composableBuilder( + column: $state.table.locale, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters get market => + $state.composableBuilder( + column: $state.table.market, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get searchMode => $state.composableBuilder( + column: $state.table.searchMode, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnFilters get downloadLocation => $state.composableBuilder( + column: $state.table.downloadLocation, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters, List, String> + get localLibraryLocation => $state.composableBuilder( + column: $state.table.localLibraryLocation, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnFilters get pipedInstance => $state.composableBuilder( + column: $state.table.pipedInstance, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters get themeMode => + $state.composableBuilder( + column: $state.table.themeMode, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get audioSource => $state.composableBuilder( + column: $state.table.audioSource, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get streamMusicCodec => $state.composableBuilder( + column: $state.table.streamMusicCodec, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get downloadMusicCodec => $state.composableBuilder( + column: $state.table.downloadMusicCodec, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnFilters get discordPresence => $state.composableBuilder( + column: $state.table.discordPresence, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get endlessPlayback => $state.composableBuilder( + column: $state.table.endlessPlayback, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get enableConnect => $state.composableBuilder( + column: $state.table.enableConnect, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); +} + +class $$PreferencesTableTableOrderingComposer + extends OrderingComposer<_$AppDatabase, $PreferencesTableTable> { + $$PreferencesTableTableOrderingComposer(super.$state); + ColumnOrderings get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get audioQuality => $state.composableBuilder( + column: $state.table.audioQuality, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get albumColorSync => $state.composableBuilder( + column: $state.table.albumColorSync, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get amoledDarkTheme => $state.composableBuilder( + column: $state.table.amoledDarkTheme, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get checkUpdate => $state.composableBuilder( + column: $state.table.checkUpdate, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get normalizeAudio => $state.composableBuilder( + column: $state.table.normalizeAudio, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get showSystemTrayIcon => $state.composableBuilder( + column: $state.table.showSystemTrayIcon, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get systemTitleBar => $state.composableBuilder( + column: $state.table.systemTitleBar, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get skipNonMusic => $state.composableBuilder( + column: $state.table.skipNonMusic, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get closeBehavior => $state.composableBuilder( + column: $state.table.closeBehavior, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get accentColorScheme => $state.composableBuilder( + column: $state.table.accentColorScheme, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get layoutMode => $state.composableBuilder( + column: $state.table.layoutMode, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get locale => $state.composableBuilder( + column: $state.table.locale, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get market => $state.composableBuilder( + column: $state.table.market, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get searchMode => $state.composableBuilder( + column: $state.table.searchMode, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get downloadLocation => $state.composableBuilder( + column: $state.table.downloadLocation, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get localLibraryLocation => $state.composableBuilder( + column: $state.table.localLibraryLocation, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get pipedInstance => $state.composableBuilder( + column: $state.table.pipedInstance, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get themeMode => $state.composableBuilder( + column: $state.table.themeMode, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get audioSource => $state.composableBuilder( + column: $state.table.audioSource, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get streamMusicCodec => $state.composableBuilder( + column: $state.table.streamMusicCodec, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get downloadMusicCodec => $state.composableBuilder( + column: $state.table.downloadMusicCodec, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get discordPresence => $state.composableBuilder( + column: $state.table.discordPresence, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get endlessPlayback => $state.composableBuilder( + column: $state.table.endlessPlayback, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get enableConnect => $state.composableBuilder( + column: $state.table.enableConnect, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); +} + +typedef $$ScrobblerTableTableInsertCompanionBuilder = ScrobblerTableCompanion + Function({ + Value id, + Value createdAt, + required String username, + required DecryptedText passwordHash, +}); +typedef $$ScrobblerTableTableUpdateCompanionBuilder = ScrobblerTableCompanion + Function({ + Value id, + Value createdAt, + Value username, + Value passwordHash, +}); + +class $$ScrobblerTableTableTableManager extends RootTableManager< + _$AppDatabase, + $ScrobblerTableTable, + ScrobblerTableData, + $$ScrobblerTableTableFilterComposer, + $$ScrobblerTableTableOrderingComposer, + $$ScrobblerTableTableProcessedTableManager, + $$ScrobblerTableTableInsertCompanionBuilder, + $$ScrobblerTableTableUpdateCompanionBuilder> { + $$ScrobblerTableTableTableManager( + _$AppDatabase db, $ScrobblerTableTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: + $$ScrobblerTableTableFilterComposer(ComposerState(db, table)), + orderingComposer: + $$ScrobblerTableTableOrderingComposer(ComposerState(db, table)), + getChildManagerBuilder: (p) => + $$ScrobblerTableTableProcessedTableManager(p), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value createdAt = const Value.absent(), + Value username = const Value.absent(), + Value passwordHash = const Value.absent(), + }) => + ScrobblerTableCompanion( + id: id, + createdAt: createdAt, + username: username, + passwordHash: passwordHash, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + Value createdAt = const Value.absent(), + required String username, + required DecryptedText passwordHash, + }) => + ScrobblerTableCompanion.insert( + id: id, + createdAt: createdAt, + username: username, + passwordHash: passwordHash, + ), + )); +} + +class $$ScrobblerTableTableProcessedTableManager extends ProcessedTableManager< + _$AppDatabase, + $ScrobblerTableTable, + ScrobblerTableData, + $$ScrobblerTableTableFilterComposer, + $$ScrobblerTableTableOrderingComposer, + $$ScrobblerTableTableProcessedTableManager, + $$ScrobblerTableTableInsertCompanionBuilder, + $$ScrobblerTableTableUpdateCompanionBuilder> { + $$ScrobblerTableTableProcessedTableManager(super.$state); +} + +class $$ScrobblerTableTableFilterComposer + extends FilterComposer<_$AppDatabase, $ScrobblerTableTable> { + $$ScrobblerTableTableFilterComposer(super.$state); + ColumnFilters get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get createdAt => $state.composableBuilder( + column: $state.table.createdAt, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get username => $state.composableBuilder( + column: $state.table.username, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get passwordHash => $state.composableBuilder( + column: $state.table.passwordHash, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); +} + +class $$ScrobblerTableTableOrderingComposer + extends OrderingComposer<_$AppDatabase, $ScrobblerTableTable> { + $$ScrobblerTableTableOrderingComposer(super.$state); + ColumnOrderings get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get createdAt => $state.composableBuilder( + column: $state.table.createdAt, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get username => $state.composableBuilder( + column: $state.table.username, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get passwordHash => $state.composableBuilder( + column: $state.table.passwordHash, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); +} + +typedef $$SkipSegmentTableTableInsertCompanionBuilder + = SkipSegmentTableCompanion Function({ + Value id, + required int start, + required int end, + required String trackId, + Value createdAt, +}); +typedef $$SkipSegmentTableTableUpdateCompanionBuilder + = SkipSegmentTableCompanion Function({ + Value id, + Value start, + Value end, + Value trackId, + Value createdAt, +}); + +class $$SkipSegmentTableTableTableManager extends RootTableManager< + _$AppDatabase, + $SkipSegmentTableTable, + SkipSegmentTableData, + $$SkipSegmentTableTableFilterComposer, + $$SkipSegmentTableTableOrderingComposer, + $$SkipSegmentTableTableProcessedTableManager, + $$SkipSegmentTableTableInsertCompanionBuilder, + $$SkipSegmentTableTableUpdateCompanionBuilder> { + $$SkipSegmentTableTableTableManager( + _$AppDatabase db, $SkipSegmentTableTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: + $$SkipSegmentTableTableFilterComposer(ComposerState(db, table)), + orderingComposer: + $$SkipSegmentTableTableOrderingComposer(ComposerState(db, table)), + getChildManagerBuilder: (p) => + $$SkipSegmentTableTableProcessedTableManager(p), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value start = const Value.absent(), + Value end = const Value.absent(), + Value trackId = const Value.absent(), + Value createdAt = const Value.absent(), + }) => + SkipSegmentTableCompanion( + id: id, + start: start, + end: end, + trackId: trackId, + createdAt: createdAt, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + required int start, + required int end, + required String trackId, + Value createdAt = const Value.absent(), + }) => + SkipSegmentTableCompanion.insert( + id: id, + start: start, + end: end, + trackId: trackId, + createdAt: createdAt, + ), + )); +} + +class $$SkipSegmentTableTableProcessedTableManager + extends ProcessedTableManager< + _$AppDatabase, + $SkipSegmentTableTable, + SkipSegmentTableData, + $$SkipSegmentTableTableFilterComposer, + $$SkipSegmentTableTableOrderingComposer, + $$SkipSegmentTableTableProcessedTableManager, + $$SkipSegmentTableTableInsertCompanionBuilder, + $$SkipSegmentTableTableUpdateCompanionBuilder> { + $$SkipSegmentTableTableProcessedTableManager(super.$state); +} + +class $$SkipSegmentTableTableFilterComposer + extends FilterComposer<_$AppDatabase, $SkipSegmentTableTable> { + $$SkipSegmentTableTableFilterComposer(super.$state); + ColumnFilters get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get start => $state.composableBuilder( + column: $state.table.start, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get end => $state.composableBuilder( + column: $state.table.end, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get trackId => $state.composableBuilder( + column: $state.table.trackId, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get createdAt => $state.composableBuilder( + column: $state.table.createdAt, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); +} + +class $$SkipSegmentTableTableOrderingComposer + extends OrderingComposer<_$AppDatabase, $SkipSegmentTableTable> { + $$SkipSegmentTableTableOrderingComposer(super.$state); + ColumnOrderings get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get start => $state.composableBuilder( + column: $state.table.start, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get end => $state.composableBuilder( + column: $state.table.end, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get trackId => $state.composableBuilder( + column: $state.table.trackId, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get createdAt => $state.composableBuilder( + column: $state.table.createdAt, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); +} + +typedef $$SourceMatchTableTableInsertCompanionBuilder + = SourceMatchTableCompanion Function({ + Value id, + required String trackId, + required String sourceId, + Value sourceType, + Value createdAt, +}); +typedef $$SourceMatchTableTableUpdateCompanionBuilder + = SourceMatchTableCompanion Function({ + Value id, + Value trackId, + Value sourceId, + Value sourceType, + Value createdAt, +}); + +class $$SourceMatchTableTableTableManager extends RootTableManager< + _$AppDatabase, + $SourceMatchTableTable, + SourceMatchTableData, + $$SourceMatchTableTableFilterComposer, + $$SourceMatchTableTableOrderingComposer, + $$SourceMatchTableTableProcessedTableManager, + $$SourceMatchTableTableInsertCompanionBuilder, + $$SourceMatchTableTableUpdateCompanionBuilder> { + $$SourceMatchTableTableTableManager( + _$AppDatabase db, $SourceMatchTableTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: + $$SourceMatchTableTableFilterComposer(ComposerState(db, table)), + orderingComposer: + $$SourceMatchTableTableOrderingComposer(ComposerState(db, table)), + getChildManagerBuilder: (p) => + $$SourceMatchTableTableProcessedTableManager(p), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value trackId = const Value.absent(), + Value sourceId = const Value.absent(), + Value sourceType = const Value.absent(), + Value createdAt = const Value.absent(), + }) => + SourceMatchTableCompanion( + id: id, + trackId: trackId, + sourceId: sourceId, + sourceType: sourceType, + createdAt: createdAt, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + required String trackId, + required String sourceId, + Value sourceType = const Value.absent(), + Value createdAt = const Value.absent(), + }) => + SourceMatchTableCompanion.insert( + id: id, + trackId: trackId, + sourceId: sourceId, + sourceType: sourceType, + createdAt: createdAt, + ), + )); +} + +class $$SourceMatchTableTableProcessedTableManager + extends ProcessedTableManager< + _$AppDatabase, + $SourceMatchTableTable, + SourceMatchTableData, + $$SourceMatchTableTableFilterComposer, + $$SourceMatchTableTableOrderingComposer, + $$SourceMatchTableTableProcessedTableManager, + $$SourceMatchTableTableInsertCompanionBuilder, + $$SourceMatchTableTableUpdateCompanionBuilder> { + $$SourceMatchTableTableProcessedTableManager(super.$state); +} + +class $$SourceMatchTableTableFilterComposer + extends FilterComposer<_$AppDatabase, $SourceMatchTableTable> { + $$SourceMatchTableTableFilterComposer(super.$state); + ColumnFilters get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get trackId => $state.composableBuilder( + column: $state.table.trackId, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get sourceId => $state.composableBuilder( + column: $state.table.sourceId, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get sourceType => $state.composableBuilder( + column: $state.table.sourceType, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnFilters get createdAt => $state.composableBuilder( + column: $state.table.createdAt, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); +} + +class $$SourceMatchTableTableOrderingComposer + extends OrderingComposer<_$AppDatabase, $SourceMatchTableTable> { + $$SourceMatchTableTableOrderingComposer(super.$state); + ColumnOrderings get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get trackId => $state.composableBuilder( + column: $state.table.trackId, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get sourceId => $state.composableBuilder( + column: $state.table.sourceId, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get sourceType => $state.composableBuilder( + column: $state.table.sourceType, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get createdAt => $state.composableBuilder( + column: $state.table.createdAt, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); +} + +typedef $$AudioPlayerStateTableTableInsertCompanionBuilder + = AudioPlayerStateTableCompanion Function({ + Value id, + required bool playing, + required PlaylistMode loopMode, + required bool shuffled, + required List collections, +}); +typedef $$AudioPlayerStateTableTableUpdateCompanionBuilder + = AudioPlayerStateTableCompanion Function({ + Value id, + Value playing, + Value loopMode, + Value shuffled, + Value> collections, +}); + +class $$AudioPlayerStateTableTableTableManager extends RootTableManager< + _$AppDatabase, + $AudioPlayerStateTableTable, + AudioPlayerStateTableData, + $$AudioPlayerStateTableTableFilterComposer, + $$AudioPlayerStateTableTableOrderingComposer, + $$AudioPlayerStateTableTableProcessedTableManager, + $$AudioPlayerStateTableTableInsertCompanionBuilder, + $$AudioPlayerStateTableTableUpdateCompanionBuilder> { + $$AudioPlayerStateTableTableTableManager( + _$AppDatabase db, $AudioPlayerStateTableTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: $$AudioPlayerStateTableTableFilterComposer( + ComposerState(db, table)), + orderingComposer: $$AudioPlayerStateTableTableOrderingComposer( + ComposerState(db, table)), + getChildManagerBuilder: (p) => + $$AudioPlayerStateTableTableProcessedTableManager(p), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value playing = const Value.absent(), + Value loopMode = const Value.absent(), + Value shuffled = const Value.absent(), + Value> collections = const Value.absent(), + }) => + AudioPlayerStateTableCompanion( + id: id, + playing: playing, + loopMode: loopMode, + shuffled: shuffled, + collections: collections, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + required bool playing, + required PlaylistMode loopMode, + required bool shuffled, + required List collections, + }) => + AudioPlayerStateTableCompanion.insert( + id: id, + playing: playing, + loopMode: loopMode, + shuffled: shuffled, + collections: collections, + ), + )); +} + +class $$AudioPlayerStateTableTableProcessedTableManager + extends ProcessedTableManager< + _$AppDatabase, + $AudioPlayerStateTableTable, + AudioPlayerStateTableData, + $$AudioPlayerStateTableTableFilterComposer, + $$AudioPlayerStateTableTableOrderingComposer, + $$AudioPlayerStateTableTableProcessedTableManager, + $$AudioPlayerStateTableTableInsertCompanionBuilder, + $$AudioPlayerStateTableTableUpdateCompanionBuilder> { + $$AudioPlayerStateTableTableProcessedTableManager(super.$state); +} + +class $$AudioPlayerStateTableTableFilterComposer + extends FilterComposer<_$AppDatabase, $AudioPlayerStateTableTable> { + $$AudioPlayerStateTableTableFilterComposer(super.$state); + ColumnFilters get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get playing => $state.composableBuilder( + column: $state.table.playing, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get loopMode => $state.composableBuilder( + column: $state.table.loopMode, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnFilters get shuffled => $state.composableBuilder( + column: $state.table.shuffled, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters, List, String> + get collections => $state.composableBuilder( + column: $state.table.collections, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ComposableFilter playlistTableRefs( + ComposableFilter Function($$PlaylistTableTableFilterComposer f) f) { + final $$PlaylistTableTableFilterComposer composer = $state.composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $state.db.playlistTable, + getReferencedColumn: (t) => t.audioPlayerStateId, + builder: (joinBuilder, parentComposers) => + $$PlaylistTableTableFilterComposer(ComposerState($state.db, + $state.db.playlistTable, joinBuilder, parentComposers))); + return f(composer); + } +} + +class $$AudioPlayerStateTableTableOrderingComposer + extends OrderingComposer<_$AppDatabase, $AudioPlayerStateTableTable> { + $$AudioPlayerStateTableTableOrderingComposer(super.$state); + ColumnOrderings get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get playing => $state.composableBuilder( + column: $state.table.playing, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get loopMode => $state.composableBuilder( + column: $state.table.loopMode, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get shuffled => $state.composableBuilder( + column: $state.table.shuffled, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get collections => $state.composableBuilder( + column: $state.table.collections, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); +} + +typedef $$PlaylistTableTableInsertCompanionBuilder = PlaylistTableCompanion + Function({ + Value id, + required int audioPlayerStateId, + required int index, +}); +typedef $$PlaylistTableTableUpdateCompanionBuilder = PlaylistTableCompanion + Function({ + Value id, + Value audioPlayerStateId, + Value index, +}); + +class $$PlaylistTableTableTableManager extends RootTableManager< + _$AppDatabase, + $PlaylistTableTable, + PlaylistTableData, + $$PlaylistTableTableFilterComposer, + $$PlaylistTableTableOrderingComposer, + $$PlaylistTableTableProcessedTableManager, + $$PlaylistTableTableInsertCompanionBuilder, + $$PlaylistTableTableUpdateCompanionBuilder> { + $$PlaylistTableTableTableManager(_$AppDatabase db, $PlaylistTableTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: + $$PlaylistTableTableFilterComposer(ComposerState(db, table)), + orderingComposer: + $$PlaylistTableTableOrderingComposer(ComposerState(db, table)), + getChildManagerBuilder: (p) => + $$PlaylistTableTableProcessedTableManager(p), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value audioPlayerStateId = const Value.absent(), + Value index = const Value.absent(), + }) => + PlaylistTableCompanion( + id: id, + audioPlayerStateId: audioPlayerStateId, + index: index, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + required int audioPlayerStateId, + required int index, + }) => + PlaylistTableCompanion.insert( + id: id, + audioPlayerStateId: audioPlayerStateId, + index: index, + ), + )); +} + +class $$PlaylistTableTableProcessedTableManager extends ProcessedTableManager< + _$AppDatabase, + $PlaylistTableTable, + PlaylistTableData, + $$PlaylistTableTableFilterComposer, + $$PlaylistTableTableOrderingComposer, + $$PlaylistTableTableProcessedTableManager, + $$PlaylistTableTableInsertCompanionBuilder, + $$PlaylistTableTableUpdateCompanionBuilder> { + $$PlaylistTableTableProcessedTableManager(super.$state); +} + +class $$PlaylistTableTableFilterComposer + extends FilterComposer<_$AppDatabase, $PlaylistTableTable> { + $$PlaylistTableTableFilterComposer(super.$state); + ColumnFilters get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get index => $state.composableBuilder( + column: $state.table.index, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + $$AudioPlayerStateTableTableFilterComposer get audioPlayerStateId { + final $$AudioPlayerStateTableTableFilterComposer composer = + $state.composerBuilder( + composer: this, + getCurrentColumn: (t) => t.audioPlayerStateId, + referencedTable: $state.db.audioPlayerStateTable, + getReferencedColumn: (t) => t.id, + builder: (joinBuilder, parentComposers) => + $$AudioPlayerStateTableTableFilterComposer(ComposerState( + $state.db, + $state.db.audioPlayerStateTable, + joinBuilder, + parentComposers))); + return composer; + } + + ComposableFilter playlistMediaTableRefs( + ComposableFilter Function($$PlaylistMediaTableTableFilterComposer f) f) { + final $$PlaylistMediaTableTableFilterComposer composer = $state + .composerBuilder( + composer: this, + getCurrentColumn: (t) => t.id, + referencedTable: $state.db.playlistMediaTable, + getReferencedColumn: (t) => t.playlistId, + builder: (joinBuilder, parentComposers) => + $$PlaylistMediaTableTableFilterComposer(ComposerState( + $state.db, + $state.db.playlistMediaTable, + joinBuilder, + parentComposers))); + return f(composer); + } +} + +class $$PlaylistTableTableOrderingComposer + extends OrderingComposer<_$AppDatabase, $PlaylistTableTable> { + $$PlaylistTableTableOrderingComposer(super.$state); + ColumnOrderings get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get index => $state.composableBuilder( + column: $state.table.index, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + $$AudioPlayerStateTableTableOrderingComposer get audioPlayerStateId { + final $$AudioPlayerStateTableTableOrderingComposer composer = + $state.composerBuilder( + composer: this, + getCurrentColumn: (t) => t.audioPlayerStateId, + referencedTable: $state.db.audioPlayerStateTable, + getReferencedColumn: (t) => t.id, + builder: (joinBuilder, parentComposers) => + $$AudioPlayerStateTableTableOrderingComposer(ComposerState( + $state.db, + $state.db.audioPlayerStateTable, + joinBuilder, + parentComposers))); + return composer; + } +} + +typedef $$PlaylistMediaTableTableInsertCompanionBuilder + = PlaylistMediaTableCompanion Function({ + Value id, + required int playlistId, + required String uri, + Value?> extras, + Value?> httpHeaders, +}); +typedef $$PlaylistMediaTableTableUpdateCompanionBuilder + = PlaylistMediaTableCompanion Function({ + Value id, + Value playlistId, + Value uri, + Value?> extras, + Value?> httpHeaders, +}); + +class $$PlaylistMediaTableTableTableManager extends RootTableManager< + _$AppDatabase, + $PlaylistMediaTableTable, + PlaylistMediaTableData, + $$PlaylistMediaTableTableFilterComposer, + $$PlaylistMediaTableTableOrderingComposer, + $$PlaylistMediaTableTableProcessedTableManager, + $$PlaylistMediaTableTableInsertCompanionBuilder, + $$PlaylistMediaTableTableUpdateCompanionBuilder> { + $$PlaylistMediaTableTableTableManager( + _$AppDatabase db, $PlaylistMediaTableTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: + $$PlaylistMediaTableTableFilterComposer(ComposerState(db, table)), + orderingComposer: $$PlaylistMediaTableTableOrderingComposer( + ComposerState(db, table)), + getChildManagerBuilder: (p) => + $$PlaylistMediaTableTableProcessedTableManager(p), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value playlistId = const Value.absent(), + Value uri = const Value.absent(), + Value?> extras = const Value.absent(), + Value?> httpHeaders = const Value.absent(), + }) => + PlaylistMediaTableCompanion( + id: id, + playlistId: playlistId, + uri: uri, + extras: extras, + httpHeaders: httpHeaders, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + required int playlistId, + required String uri, + Value?> extras = const Value.absent(), + Value?> httpHeaders = const Value.absent(), + }) => + PlaylistMediaTableCompanion.insert( + id: id, + playlistId: playlistId, + uri: uri, + extras: extras, + httpHeaders: httpHeaders, + ), + )); +} + +class $$PlaylistMediaTableTableProcessedTableManager + extends ProcessedTableManager< + _$AppDatabase, + $PlaylistMediaTableTable, + PlaylistMediaTableData, + $$PlaylistMediaTableTableFilterComposer, + $$PlaylistMediaTableTableOrderingComposer, + $$PlaylistMediaTableTableProcessedTableManager, + $$PlaylistMediaTableTableInsertCompanionBuilder, + $$PlaylistMediaTableTableUpdateCompanionBuilder> { + $$PlaylistMediaTableTableProcessedTableManager(super.$state); +} + +class $$PlaylistMediaTableTableFilterComposer + extends FilterComposer<_$AppDatabase, $PlaylistMediaTableTable> { + $$PlaylistMediaTableTableFilterComposer(super.$state); + ColumnFilters get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get uri => $state.composableBuilder( + column: $state.table.uri, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters?, Map, + String> + get extras => $state.composableBuilder( + column: $state.table.extras, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters?, Map, + String> + get httpHeaders => $state.composableBuilder( + column: $state.table.httpHeaders, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + $$PlaylistTableTableFilterComposer get playlistId { + final $$PlaylistTableTableFilterComposer composer = $state.composerBuilder( + composer: this, + getCurrentColumn: (t) => t.playlistId, + referencedTable: $state.db.playlistTable, + getReferencedColumn: (t) => t.id, + builder: (joinBuilder, parentComposers) => + $$PlaylistTableTableFilterComposer(ComposerState($state.db, + $state.db.playlistTable, joinBuilder, parentComposers))); + return composer; + } +} + +class $$PlaylistMediaTableTableOrderingComposer + extends OrderingComposer<_$AppDatabase, $PlaylistMediaTableTable> { + $$PlaylistMediaTableTableOrderingComposer(super.$state); + ColumnOrderings get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get uri => $state.composableBuilder( + column: $state.table.uri, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get extras => $state.composableBuilder( + column: $state.table.extras, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get httpHeaders => $state.composableBuilder( + column: $state.table.httpHeaders, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + $$PlaylistTableTableOrderingComposer get playlistId { + final $$PlaylistTableTableOrderingComposer composer = + $state.composerBuilder( + composer: this, + getCurrentColumn: (t) => t.playlistId, + referencedTable: $state.db.playlistTable, + getReferencedColumn: (t) => t.id, + builder: (joinBuilder, parentComposers) => + $$PlaylistTableTableOrderingComposer(ComposerState($state.db, + $state.db.playlistTable, joinBuilder, parentComposers))); + return composer; + } +} + +typedef $$HistoryTableTableInsertCompanionBuilder = HistoryTableCompanion + Function({ + Value id, + Value createdAt, + required HistoryEntryType type, + required String itemId, + required Map data, +}); +typedef $$HistoryTableTableUpdateCompanionBuilder = HistoryTableCompanion + Function({ + Value id, + Value createdAt, + Value type, + Value itemId, + Value> data, +}); + +class $$HistoryTableTableTableManager extends RootTableManager< + _$AppDatabase, + $HistoryTableTable, + HistoryTableData, + $$HistoryTableTableFilterComposer, + $$HistoryTableTableOrderingComposer, + $$HistoryTableTableProcessedTableManager, + $$HistoryTableTableInsertCompanionBuilder, + $$HistoryTableTableUpdateCompanionBuilder> { + $$HistoryTableTableTableManager(_$AppDatabase db, $HistoryTableTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: + $$HistoryTableTableFilterComposer(ComposerState(db, table)), + orderingComposer: + $$HistoryTableTableOrderingComposer(ComposerState(db, table)), + getChildManagerBuilder: (p) => + $$HistoryTableTableProcessedTableManager(p), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value createdAt = const Value.absent(), + Value type = const Value.absent(), + Value itemId = const Value.absent(), + Value> data = const Value.absent(), + }) => + HistoryTableCompanion( + id: id, + createdAt: createdAt, + type: type, + itemId: itemId, + data: data, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + Value createdAt = const Value.absent(), + required HistoryEntryType type, + required String itemId, + required Map data, + }) => + HistoryTableCompanion.insert( + id: id, + createdAt: createdAt, + type: type, + itemId: itemId, + data: data, + ), + )); +} + +class $$HistoryTableTableProcessedTableManager extends ProcessedTableManager< + _$AppDatabase, + $HistoryTableTable, + HistoryTableData, + $$HistoryTableTableFilterComposer, + $$HistoryTableTableOrderingComposer, + $$HistoryTableTableProcessedTableManager, + $$HistoryTableTableInsertCompanionBuilder, + $$HistoryTableTableUpdateCompanionBuilder> { + $$HistoryTableTableProcessedTableManager(super.$state); +} + +class $$HistoryTableTableFilterComposer + extends FilterComposer<_$AppDatabase, $HistoryTableTable> { + $$HistoryTableTableFilterComposer(super.$state); + ColumnFilters get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get createdAt => $state.composableBuilder( + column: $state.table.createdAt, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get type => $state.composableBuilder( + column: $state.table.type, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); + + ColumnFilters get itemId => $state.composableBuilder( + column: $state.table.itemId, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters, Map, + String> + get data => $state.composableBuilder( + column: $state.table.data, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); +} + +class $$HistoryTableTableOrderingComposer + extends OrderingComposer<_$AppDatabase, $HistoryTableTable> { + $$HistoryTableTableOrderingComposer(super.$state); + ColumnOrderings get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get createdAt => $state.composableBuilder( + column: $state.table.createdAt, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get type => $state.composableBuilder( + column: $state.table.type, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get itemId => $state.composableBuilder( + column: $state.table.itemId, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get data => $state.composableBuilder( + column: $state.table.data, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); +} + +typedef $$LyricsTableTableInsertCompanionBuilder = LyricsTableCompanion + Function({ + Value id, + required String trackId, + required SubtitleSimple data, +}); +typedef $$LyricsTableTableUpdateCompanionBuilder = LyricsTableCompanion + Function({ + Value id, + Value trackId, + Value data, +}); + +class $$LyricsTableTableTableManager extends RootTableManager< + _$AppDatabase, + $LyricsTableTable, + LyricsTableData, + $$LyricsTableTableFilterComposer, + $$LyricsTableTableOrderingComposer, + $$LyricsTableTableProcessedTableManager, + $$LyricsTableTableInsertCompanionBuilder, + $$LyricsTableTableUpdateCompanionBuilder> { + $$LyricsTableTableTableManager(_$AppDatabase db, $LyricsTableTable table) + : super(TableManagerState( + db: db, + table: table, + filteringComposer: + $$LyricsTableTableFilterComposer(ComposerState(db, table)), + orderingComposer: + $$LyricsTableTableOrderingComposer(ComposerState(db, table)), + getChildManagerBuilder: (p) => + $$LyricsTableTableProcessedTableManager(p), + getUpdateCompanionBuilder: ({ + Value id = const Value.absent(), + Value trackId = const Value.absent(), + Value data = const Value.absent(), + }) => + LyricsTableCompanion( + id: id, + trackId: trackId, + data: data, + ), + getInsertCompanionBuilder: ({ + Value id = const Value.absent(), + required String trackId, + required SubtitleSimple data, + }) => + LyricsTableCompanion.insert( + id: id, + trackId: trackId, + data: data, + ), + )); +} + +class $$LyricsTableTableProcessedTableManager extends ProcessedTableManager< + _$AppDatabase, + $LyricsTableTable, + LyricsTableData, + $$LyricsTableTableFilterComposer, + $$LyricsTableTableOrderingComposer, + $$LyricsTableTableProcessedTableManager, + $$LyricsTableTableInsertCompanionBuilder, + $$LyricsTableTableUpdateCompanionBuilder> { + $$LyricsTableTableProcessedTableManager(super.$state); +} + +class $$LyricsTableTableFilterComposer + extends FilterComposer<_$AppDatabase, $LyricsTableTable> { + $$LyricsTableTableFilterComposer(super.$state); + ColumnFilters get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnFilters get trackId => $state.composableBuilder( + column: $state.table.trackId, + builder: (column, joinBuilders) => + ColumnFilters(column, joinBuilders: joinBuilders)); + + ColumnWithTypeConverterFilters + get data => $state.composableBuilder( + column: $state.table.data, + builder: (column, joinBuilders) => ColumnWithTypeConverterFilters( + column, + joinBuilders: joinBuilders)); +} + +class $$LyricsTableTableOrderingComposer + extends OrderingComposer<_$AppDatabase, $LyricsTableTable> { + $$LyricsTableTableOrderingComposer(super.$state); + ColumnOrderings get id => $state.composableBuilder( + column: $state.table.id, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get trackId => $state.composableBuilder( + column: $state.table.trackId, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); + + ColumnOrderings get data => $state.composableBuilder( + column: $state.table.data, + builder: (column, joinBuilders) => + ColumnOrderings(column, joinBuilders: joinBuilders)); +} + +class _$AppDatabaseManager { + final _$AppDatabase _db; + _$AppDatabaseManager(this._db); + $$AuthenticationTableTableTableManager get authenticationTable => + $$AuthenticationTableTableTableManager(_db, _db.authenticationTable); + $$BlacklistTableTableTableManager get blacklistTable => + $$BlacklistTableTableTableManager(_db, _db.blacklistTable); + $$PreferencesTableTableTableManager get preferencesTable => + $$PreferencesTableTableTableManager(_db, _db.preferencesTable); + $$ScrobblerTableTableTableManager get scrobblerTable => + $$ScrobblerTableTableTableManager(_db, _db.scrobblerTable); + $$SkipSegmentTableTableTableManager get skipSegmentTable => + $$SkipSegmentTableTableTableManager(_db, _db.skipSegmentTable); + $$SourceMatchTableTableTableManager get sourceMatchTable => + $$SourceMatchTableTableTableManager(_db, _db.sourceMatchTable); + $$AudioPlayerStateTableTableTableManager get audioPlayerStateTable => + $$AudioPlayerStateTableTableTableManager(_db, _db.audioPlayerStateTable); + $$PlaylistTableTableTableManager get playlistTable => + $$PlaylistTableTableTableManager(_db, _db.playlistTable); + $$PlaylistMediaTableTableTableManager get playlistMediaTable => + $$PlaylistMediaTableTableTableManager(_db, _db.playlistMediaTable); + $$HistoryTableTableTableManager get historyTable => + $$HistoryTableTableTableManager(_db, _db.historyTable); + $$LyricsTableTableTableManager get lyricsTable => + $$LyricsTableTableTableManager(_db, _db.lyricsTable); +} diff --git a/lib/models/database/tables/audio_player_state.dart b/lib/models/database/tables/audio_player_state.dart new file mode 100644 index 000000000..3e49cf6f6 --- /dev/null +++ b/lib/models/database/tables/audio_player_state.dart @@ -0,0 +1,27 @@ +part of '../database.dart'; + +class AudioPlayerStateTable extends Table { + IntColumn get id => integer().autoIncrement()(); + BoolColumn get playing => boolean()(); + TextColumn get loopMode => textEnum()(); + BoolColumn get shuffled => boolean()(); + TextColumn get collections => text().map(const StringListConverter())(); +} + +class PlaylistTable extends Table { + IntColumn get id => integer().autoIncrement()(); + IntColumn get audioPlayerStateId => + integer().references(AudioPlayerStateTable, #id)(); + IntColumn get index => integer()(); +} + +class PlaylistMediaTable extends Table { + IntColumn get id => integer().autoIncrement()(); + IntColumn get playlistId => integer().references(PlaylistTable, #id)(); + + TextColumn get uri => text()(); + TextColumn get extras => + text().nullable().map(const MapTypeConverter())(); + TextColumn get httpHeaders => + text().nullable().map(const MapTypeConverter())(); +} diff --git a/lib/models/database/tables/authentication.dart b/lib/models/database/tables/authentication.dart new file mode 100644 index 000000000..960419527 --- /dev/null +++ b/lib/models/database/tables/authentication.dart @@ -0,0 +1,8 @@ +part of '../database.dart'; + +class AuthenticationTable extends Table { + IntColumn get id => integer().autoIncrement()(); + TextColumn get cookie => text().map(EncryptedTextConverter())(); + TextColumn get accessToken => text().map(EncryptedTextConverter())(); + DateTimeColumn get expiration => dateTime()(); +} diff --git a/lib/models/database/tables/blacklist.dart b/lib/models/database/tables/blacklist.dart new file mode 100644 index 000000000..8a8d9dee8 --- /dev/null +++ b/lib/models/database/tables/blacklist.dart @@ -0,0 +1,18 @@ +part of '../database.dart'; + +enum BlacklistedType { + artist, + track; +} + +@TableIndex( + name: "unique_blacklist", + unique: true, + columns: {#elementType, #elementId}, +) +class BlacklistTable extends Table { + IntColumn get id => integer().autoIncrement()(); + TextColumn get name => text()(); + TextColumn get elementType => textEnum()(); + TextColumn get elementId => text()(); +} diff --git a/lib/models/database/tables/history.dart b/lib/models/database/tables/history.dart new file mode 100644 index 000000000..23c16f17e --- /dev/null +++ b/lib/models/database/tables/history.dart @@ -0,0 +1,25 @@ +part of '../database.dart'; + +enum HistoryEntryType { + playlist, + album, + track, +} + +class HistoryTable extends Table { + IntColumn get id => integer().autoIncrement()(); + DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)(); + TextColumn get type => textEnum()(); + TextColumn get itemId => text()(); + TextColumn get data => + text().map(const MapTypeConverter())(); +} + +extension HistoryItemParseExtension on HistoryTableData { + PlaylistSimple? get playlist => + type == HistoryEntryType.playlist ? PlaylistSimple.fromJson(data) : null; + AlbumSimple? get album => + type == HistoryEntryType.album ? AlbumSimple.fromJson(data) : null; + Track? get track => + type == HistoryEntryType.track ? Track.fromJson(data) : null; +} diff --git a/lib/models/database/tables/lyrics.dart b/lib/models/database/tables/lyrics.dart new file mode 100644 index 000000000..7c4c7f8f3 --- /dev/null +++ b/lib/models/database/tables/lyrics.dart @@ -0,0 +1,8 @@ +part of '../database.dart'; + +class LyricsTable extends Table { + IntColumn get id => integer().autoIncrement()(); + + TextColumn get trackId => text()(); + TextColumn get data => text().map(SubtitleTypeConverter())(); +} diff --git a/lib/models/database/tables/preferences.dart b/lib/models/database/tables/preferences.dart new file mode 100644 index 000000000..ae4ec1e80 --- /dev/null +++ b/lib/models/database/tables/preferences.dart @@ -0,0 +1,125 @@ +part of '../database.dart'; + +enum LayoutMode { + compact, + extended, + adaptive, +} + +enum CloseBehavior { + minimizeToTray, + close, +} + +enum AudioSource { + youtube, + piped, + jiosaavn; + + String get label => name[0].toUpperCase() + name.substring(1); +} + +enum MusicCodec { + m4a._("M4a (Best for downloaded music)"), + weba._("WebA (Best for streamed music)\nDoesn't support audio metadata"); + + final String label; + const MusicCodec._(this.label); +} + +enum SearchMode { + youtube._("YouTube"), + youtubeMusic._("YouTube Music"); + + final String label; + + const SearchMode._(this.label); + + factory SearchMode.fromString(String key) { + return SearchMode.values.firstWhere((e) => e.name == key); + } +} + +class PreferencesTable extends Table { + IntColumn get id => integer().autoIncrement()(); + TextColumn get audioQuality => textEnum() + .withDefault(Constant(SourceQualities.high.name))(); + BoolColumn get albumColorSync => + boolean().withDefault(const Constant(true))(); + BoolColumn get amoledDarkTheme => + boolean().withDefault(const Constant(false))(); + BoolColumn get checkUpdate => boolean().withDefault(const Constant(true))(); + BoolColumn get normalizeAudio => + boolean().withDefault(const Constant(false))(); + BoolColumn get showSystemTrayIcon => + boolean().withDefault(const Constant(false))(); + BoolColumn get systemTitleBar => + boolean().withDefault(const Constant(false))(); + BoolColumn get skipNonMusic => boolean().withDefault(const Constant(false))(); + TextColumn get closeBehavior => textEnum() + .withDefault(Constant(CloseBehavior.close.name))(); + TextColumn get accentColorScheme => text() + .withDefault(const Constant("Blue:0xFF2196F3")) + .map(const SpotubeColorConverter())(); + TextColumn get layoutMode => + textEnum().withDefault(Constant(LayoutMode.adaptive.name))(); + TextColumn get locale => text() + .withDefault( + const Constant('{"languageCode":"system","countryCode":"system"}'), + ) + .map(const LocaleConverter())(); + TextColumn get market => + textEnum().withDefault(Constant(Market.US.name))(); + TextColumn get searchMode => + textEnum().withDefault(Constant(SearchMode.youtube.name))(); + TextColumn get downloadLocation => text().withDefault(const Constant(""))(); + TextColumn get localLibraryLocation => + text().withDefault(const Constant("")).map(const StringListConverter())(); + TextColumn get pipedInstance => + text().withDefault(const Constant("https://pipedapi.kavin.rocks"))(); + TextColumn get themeMode => + textEnum().withDefault(Constant(ThemeMode.system.name))(); + TextColumn get audioSource => + textEnum().withDefault(Constant(AudioSource.youtube.name))(); + TextColumn get streamMusicCodec => + textEnum().withDefault(Constant(SourceCodecs.weba.name))(); + TextColumn get downloadMusicCodec => + textEnum().withDefault(Constant(SourceCodecs.m4a.name))(); + BoolColumn get discordPresence => + boolean().withDefault(const Constant(true))(); + BoolColumn get endlessPlayback => + boolean().withDefault(const Constant(true))(); + BoolColumn get enableConnect => + boolean().withDefault(const Constant(false))(); + + // Default values as PreferencesTableData + static PreferencesTableData defaults() { + return PreferencesTableData( + id: 0, + audioQuality: SourceQualities.high, + albumColorSync: true, + amoledDarkTheme: false, + checkUpdate: true, + normalizeAudio: false, + showSystemTrayIcon: false, + systemTitleBar: false, + skipNonMusic: false, + closeBehavior: CloseBehavior.close, + accentColorScheme: SpotubeColor(Colors.blue.value, name: "Blue"), + layoutMode: LayoutMode.adaptive, + locale: const Locale("system", "system"), + market: Market.US, + searchMode: SearchMode.youtube, + downloadLocation: "", + localLibraryLocation: [], + pipedInstance: "https://pipedapi.kavin.rocks", + themeMode: ThemeMode.system, + audioSource: AudioSource.youtube, + streamMusicCodec: SourceCodecs.weba, + downloadMusicCodec: SourceCodecs.m4a, + discordPresence: true, + endlessPlayback: true, + enableConnect: false, + ); + } +} diff --git a/lib/models/database/tables/scrobbler.dart b/lib/models/database/tables/scrobbler.dart new file mode 100644 index 000000000..481c441e9 --- /dev/null +++ b/lib/models/database/tables/scrobbler.dart @@ -0,0 +1,8 @@ +part of '../database.dart'; + +class ScrobblerTable extends Table { + IntColumn get id => integer().autoIncrement()(); + DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)(); + TextColumn get username => text()(); + TextColumn get passwordHash => text().map(EncryptedTextConverter())(); +} diff --git a/lib/models/database/tables/skip_segment.dart b/lib/models/database/tables/skip_segment.dart new file mode 100644 index 000000000..719f26171 --- /dev/null +++ b/lib/models/database/tables/skip_segment.dart @@ -0,0 +1,9 @@ +part of '../database.dart'; + +class SkipSegmentTable extends Table { + IntColumn get id => integer().autoIncrement()(); + IntColumn get start => integer()(); + IntColumn get end => integer()(); + TextColumn get trackId => text()(); + DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)(); +} diff --git a/lib/models/database/tables/source_match.dart b/lib/models/database/tables/source_match.dart new file mode 100644 index 000000000..78d0eb059 --- /dev/null +++ b/lib/models/database/tables/source_match.dart @@ -0,0 +1,25 @@ +part of '../database.dart'; + +enum SourceType { + youtube._("YouTube"), + youtubeMusic._("YouTube Music"), + jiosaavn._("JioSaavn"); + + final String label; + + const SourceType._(this.label); +} + +@TableIndex( + name: "uniq_track_match", + columns: {#trackId, #sourceId, #sourceType}, + unique: true, +) +class SourceMatchTable extends Table { + IntColumn get id => integer().autoIncrement()(); + TextColumn get trackId => text()(); + TextColumn get sourceId => text()(); + TextColumn get sourceType => + textEnum().withDefault(Constant(SourceType.youtube.name))(); + DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)(); +} diff --git a/lib/models/database/typeconverters/color.dart b/lib/models/database/typeconverters/color.dart new file mode 100644 index 000000000..70c273747 --- /dev/null +++ b/lib/models/database/typeconverters/color.dart @@ -0,0 +1,29 @@ +part of '../database.dart'; + +class ColorConverter extends TypeConverter { + const ColorConverter(); + + @override + Color fromSql(int fromDb) { + return Color(fromDb); + } + + @override + int toSql(Color value) { + return value.value; + } +} + +class SpotubeColorConverter extends TypeConverter { + const SpotubeColorConverter(); + + @override + SpotubeColor fromSql(String fromDb) { + return SpotubeColor.fromString(fromDb); + } + + @override + String toSql(SpotubeColor value) { + return value.toString(); + } +} diff --git a/lib/models/database/typeconverters/encrypted_text.dart b/lib/models/database/typeconverters/encrypted_text.dart new file mode 100644 index 000000000..6afa82106 --- /dev/null +++ b/lib/models/database/typeconverters/encrypted_text.dart @@ -0,0 +1,44 @@ +part of '../database.dart'; + +class DecryptedText { + final String value; + const DecryptedText(this.value); + + static Encrypter? _encrypter; + + factory DecryptedText.decrypted(String value) { + _encrypter ??= Encrypter( + Salsa20( + Key.fromUtf8(EncryptedKvStoreService.encryptionKeySync), + ), + ); + + return DecryptedText( + _encrypter!.decrypt( + Encrypted.fromBase64(value), + iv: KVStoreService.ivKey, + ), + ); + } + + String encrypt() { + _encrypter ??= Encrypter( + Salsa20( + Key.fromUtf8(EncryptedKvStoreService.encryptionKeySync), + ), + ); + return _encrypter!.encrypt(value, iv: KVStoreService.ivKey).base64; + } +} + +class EncryptedTextConverter extends TypeConverter { + @override + DecryptedText fromSql(String fromDb) { + return DecryptedText.decrypted(fromDb); + } + + @override + String toSql(DecryptedText value) { + return value.encrypt(); + } +} diff --git a/lib/models/database/typeconverters/locale.dart b/lib/models/database/typeconverters/locale.dart new file mode 100644 index 000000000..c460088e3 --- /dev/null +++ b/lib/models/database/typeconverters/locale.dart @@ -0,0 +1,19 @@ +part of '../database.dart'; + +class LocaleConverter extends TypeConverter { + const LocaleConverter(); + + @override + Locale fromSql(String fromDb) { + final rawMap = jsonDecode(fromDb) as Map; + return Locale(rawMap["languageCode"], rawMap["countryCode"]); + } + + @override + String toSql(Locale value) { + return jsonEncode({ + "languageCode": value.languageCode, + "countryCode": value.countryCode, + }); + } +} diff --git a/lib/models/database/typeconverters/map.dart b/lib/models/database/typeconverters/map.dart new file mode 100644 index 000000000..0b0ff7e09 --- /dev/null +++ b/lib/models/database/typeconverters/map.dart @@ -0,0 +1,15 @@ +part of '../database.dart'; + +class MapTypeConverter extends TypeConverter, String> { + const MapTypeConverter(); + + @override + fromSql(String fromDb) { + return json.decode(fromDb) as Map; + } + + @override + toSql(value) { + return json.encode(value); + } +} diff --git a/lib/models/database/typeconverters/string_list.dart b/lib/models/database/typeconverters/string_list.dart new file mode 100644 index 000000000..466ae4c4e --- /dev/null +++ b/lib/models/database/typeconverters/string_list.dart @@ -0,0 +1,15 @@ +part of '../database.dart'; + +class StringListConverter extends TypeConverter, String> { + const StringListConverter(); + + @override + List fromSql(String fromDb) { + return fromDb.split(",").where((e) => e.isNotEmpty).toList(); + } + + @override + String toSql(List value) { + return value.join(","); + } +} diff --git a/lib/models/database/typeconverters/subtitle.dart b/lib/models/database/typeconverters/subtitle.dart new file mode 100644 index 000000000..25fa4ad51 --- /dev/null +++ b/lib/models/database/typeconverters/subtitle.dart @@ -0,0 +1,13 @@ +part of '../database.dart'; + +class SubtitleTypeConverter extends TypeConverter { + @override + SubtitleSimple fromSql(String fromDb) { + return SubtitleSimple.fromJson(jsonDecode(fromDb)); + } + + @override + String toSql(SubtitleSimple value) { + return jsonEncode(value.toJson()); + } +} diff --git a/lib/models/local_track.dart b/lib/models/local_track.dart index 923f5f261..def3b64f9 100644 --- a/lib/models/local_track.dart +++ b/lib/models/local_track.dart @@ -1,5 +1,4 @@ import 'package:spotify/spotify.dart'; -import 'package:spotube/extensions/track.dart'; class LocalTrack extends Track { final String path; @@ -35,9 +34,10 @@ class LocalTrack extends Track { ); } + @override Map toJson() { return { - ...TrackExtensions.trackToJson(this), + ...super.toJson(), 'path': path, }; } diff --git a/lib/models/logger.dart b/lib/models/logger.dart deleted file mode 100644 index 4f687d093..000000000 --- a/lib/models/logger.dart +++ /dev/null @@ -1,74 +0,0 @@ -import 'dart:io'; - -import 'package:flutter/foundation.dart'; -import 'package:logger/logger.dart'; -import 'package:path_provider/path_provider.dart'; -import 'package:path/path.dart' as path; -import 'package:spotube/utils/platform.dart'; - -final _loggerFactory = SpotubeLogger(); -final logEnv = { - if (!kIsWeb) ...Platform.environment, -}; - -SpotubeLogger getLogger(T owner) { - _loggerFactory.owner = owner is String ? owner : owner.toString(); - return _loggerFactory; -} - -Future getLogsPath() async { - String dir = (await getApplicationDocumentsDirectory()).path; - if (kIsAndroid) { - dir = (await getExternalStorageDirectory())?.path ?? ""; - } - - if (kIsMacOS) { - dir = path.join((await getLibraryDirectory()).path, "Logs"); - } - final file = File(path.join(dir, ".spotube_logs")); - if (!await file.exists()) { - await file.create(); - } - return file; -} - -class SpotubeLogger extends Logger { - String? owner; - SpotubeLogger([this.owner]) : super(filter: _SpotubeLogFilter()); - - @override - void log(Level level, dynamic message, - {Object? error, StackTrace? stackTrace, DateTime? time}) async { - if (!kIsWeb) { - if (level == Level.error) { - String dir = (await getApplicationDocumentsDirectory()).path; - - if (kIsAndroid) { - dir = (await getExternalStorageDirectory())?.path ?? ""; - } - - if (kIsMacOS) { - dir = path.join((await getLibraryDirectory()).path, "Logs"); - } - - await File(path.join(dir, ".spotube_logs")).writeAsString( - "[${DateTime.now()}]\n$message\n$stackTrace", - mode: FileMode.writeOnlyAppend); - } - } - - super.log(level, "[$owner] $message", error: error, stackTrace: stackTrace); - } -} - -class _SpotubeLogFilter extends DevelopmentFilter { - @override - bool shouldLog(LogEvent event) { - if ((logEnv["DEBUG"] == "true" && event.level == Level.debug) || - (logEnv["VERBOSE"] == "true" && event.level == Level.trace) || - (logEnv["ERROR"] == "true" && event.level == Level.error)) { - return true; - } - return super.shouldLog(event); - } -} diff --git a/lib/models/skip_segment.dart b/lib/models/skip_segment.dart deleted file mode 100644 index 90f20f5a9..000000000 --- a/lib/models/skip_segment.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:hive/hive.dart'; - -part 'skip_segment.g.dart'; - -@HiveType(typeId: 2) -class SkipSegment { - @HiveField(0) - final int start; - @HiveField(1) - final int end; - SkipSegment(this.start, this.end); - - static String version = 'v1'; - static final boxName = "oss.krtirtho.spotube.skip_segments.$version"; - static LazyBox get box => Hive.lazyBox(boxName); - - SkipSegment.fromJson(Map json) - : start = json['start'], - end = json['end']; - - Map toJson() => { - 'start': start, - 'end': end, - }; -} diff --git a/lib/models/skip_segment.g.dart b/lib/models/skip_segment.g.dart deleted file mode 100644 index f2ad4459a..000000000 --- a/lib/models/skip_segment.g.dart +++ /dev/null @@ -1,44 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'skip_segment.dart'; - -// ************************************************************************** -// TypeAdapterGenerator -// ************************************************************************** - -class SkipSegmentAdapter extends TypeAdapter { - @override - final int typeId = 2; - - @override - SkipSegment read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return SkipSegment( - fields[0] as int, - fields[1] as int, - ); - } - - @override - void write(BinaryWriter writer, SkipSegment obj) { - writer - ..writeByte(2) - ..writeByte(0) - ..write(obj.start) - ..writeByte(1) - ..write(obj.end); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is SkipSegmentAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} diff --git a/lib/models/source_match.dart b/lib/models/source_match.dart deleted file mode 100644 index 57a9f9634..000000000 --- a/lib/models/source_match.dart +++ /dev/null @@ -1,54 +0,0 @@ -import 'package:hive/hive.dart'; -import 'package:json_annotation/json_annotation.dart'; - -part 'source_match.g.dart'; - -@JsonEnum() -@HiveType(typeId: 5) -enum SourceType { - @HiveField(0) - youtube._("YouTube"), - - @HiveField(1) - youtubeMusic._("YouTube Music"), - - @HiveField(2) - jiosaavn._("JioSaavn"); - - final String label; - - const SourceType._(this.label); -} - -@JsonSerializable() -@HiveType(typeId: 6) -class SourceMatch { - @HiveField(0) - String id; - - @HiveField(1) - String sourceId; - - @HiveField(2) - SourceType sourceType; - - @HiveField(3) - DateTime createdAt; - - SourceMatch({ - required this.id, - required this.sourceId, - required this.sourceType, - required this.createdAt, - }); - - factory SourceMatch.fromJson(Map json) => - _$SourceMatchFromJson(json); - - Map toJson() => _$SourceMatchToJson(this); - - static String version = 'v1'; - static final boxName = "oss.krtirtho.spotube.source_matches.$version"; - - static LazyBox get box => Hive.lazyBox(boxName); -} diff --git a/lib/models/source_match.g.dart b/lib/models/source_match.g.dart deleted file mode 100644 index 11f34bf34..000000000 --- a/lib/models/source_match.g.dart +++ /dev/null @@ -1,119 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'source_match.dart'; - -// ************************************************************************** -// TypeAdapterGenerator -// ************************************************************************** - -class SourceMatchAdapter extends TypeAdapter { - @override - final int typeId = 6; - - @override - SourceMatch read(BinaryReader reader) { - final numOfFields = reader.readByte(); - final fields = { - for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), - }; - return SourceMatch( - id: fields[0] as String, - sourceId: fields[1] as String, - sourceType: fields[2] as SourceType, - createdAt: fields[3] as DateTime, - ); - } - - @override - void write(BinaryWriter writer, SourceMatch obj) { - writer - ..writeByte(4) - ..writeByte(0) - ..write(obj.id) - ..writeByte(1) - ..write(obj.sourceId) - ..writeByte(2) - ..write(obj.sourceType) - ..writeByte(3) - ..write(obj.createdAt); - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is SourceMatchAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} - -class SourceTypeAdapter extends TypeAdapter { - @override - final int typeId = 5; - - @override - SourceType read(BinaryReader reader) { - switch (reader.readByte()) { - case 0: - return SourceType.youtube; - case 1: - return SourceType.youtubeMusic; - case 2: - return SourceType.jiosaavn; - default: - return SourceType.youtube; - } - } - - @override - void write(BinaryWriter writer, SourceType obj) { - switch (obj) { - case SourceType.youtube: - writer.writeByte(0); - break; - case SourceType.youtubeMusic: - writer.writeByte(1); - break; - case SourceType.jiosaavn: - writer.writeByte(2); - break; - } - } - - @override - int get hashCode => typeId.hashCode; - - @override - bool operator ==(Object other) => - identical(this, other) || - other is SourceTypeAdapter && - runtimeType == other.runtimeType && - typeId == other.typeId; -} - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -SourceMatch _$SourceMatchFromJson(Map json) => SourceMatch( - id: json['id'] as String, - sourceId: json['sourceId'] as String, - sourceType: $enumDecode(_$SourceTypeEnumMap, json['sourceType']), - createdAt: DateTime.parse(json['createdAt'] as String), - ); - -Map _$SourceMatchToJson(SourceMatch instance) => - { - 'id': instance.id, - 'sourceId': instance.sourceId, - 'sourceType': _$SourceTypeEnumMap[instance.sourceType]!, - 'createdAt': instance.createdAt.toIso8601String(), - }; - -const _$SourceTypeEnumMap = { - SourceType.youtube: 'youtube', - SourceType.youtubeMusic: 'youtubeMusic', - SourceType.jiosaavn: 'jiosaavn', -}; diff --git a/lib/models/spotify/home_feed.freezed.dart b/lib/models/spotify/home_feed.freezed.dart index 97c4ffc77..c2bb2aba1 100644 --- a/lib/models/spotify/home_feed.freezed.dart +++ b/lib/models/spotify/home_feed.freezed.dart @@ -12,7 +12,7 @@ part of 'home_feed.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); SpotifySectionPlaylist _$SpotifySectionPlaylistFromJson( Map json) { diff --git a/lib/models/spotify/home_feed.g.dart b/lib/models/spotify/home_feed.g.dart index 73a4f9093..fceb3db42 100644 --- a/lib/models/spotify/home_feed.g.dart +++ b/lib/models/spotify/home_feed.g.dart @@ -6,14 +6,13 @@ part of 'home_feed.dart'; // JsonSerializableGenerator // ************************************************************************** -_$SpotifySectionPlaylistImpl _$$SpotifySectionPlaylistImplFromJson( - Map json) => +_$SpotifySectionPlaylistImpl _$$SpotifySectionPlaylistImplFromJson(Map json) => _$SpotifySectionPlaylistImpl( description: json['description'] as String, format: json['format'] as String, images: (json['images'] as List) - .map((e) => - SpotifySectionItemImage.fromJson(e as Map)) + .map((e) => SpotifySectionItemImage.fromJson( + Map.from(e as Map))) .toList(), name: json['name'] as String, owner: json['owner'] as String, @@ -25,20 +24,19 @@ Map _$$SpotifySectionPlaylistImplToJson( { 'description': instance.description, 'format': instance.format, - 'images': instance.images, + 'images': instance.images.map((e) => e.toJson()).toList(), 'name': instance.name, 'owner': instance.owner, 'uri': instance.uri, }; -_$SpotifySectionArtistImpl _$$SpotifySectionArtistImplFromJson( - Map json) => +_$SpotifySectionArtistImpl _$$SpotifySectionArtistImplFromJson(Map json) => _$SpotifySectionArtistImpl( name: json['name'] as String, uri: json['uri'] as String, images: (json['images'] as List) - .map((e) => - SpotifySectionItemImage.fromJson(e as Map)) + .map((e) => SpotifySectionItemImage.fromJson( + Map.from(e as Map))) .toList(), ); @@ -47,19 +45,18 @@ Map _$$SpotifySectionArtistImplToJson( { 'name': instance.name, 'uri': instance.uri, - 'images': instance.images, + 'images': instance.images.map((e) => e.toJson()).toList(), }; -_$SpotifySectionAlbumImpl _$$SpotifySectionAlbumImplFromJson( - Map json) => +_$SpotifySectionAlbumImpl _$$SpotifySectionAlbumImplFromJson(Map json) => _$SpotifySectionAlbumImpl( artists: (json['artists'] as List) - .map((e) => - SpotifySectionAlbumArtist.fromJson(e as Map)) + .map((e) => SpotifySectionAlbumArtist.fromJson( + Map.from(e as Map))) .toList(), images: (json['images'] as List) - .map((e) => - SpotifySectionItemImage.fromJson(e as Map)) + .map((e) => SpotifySectionItemImage.fromJson( + Map.from(e as Map))) .toList(), name: json['name'] as String, uri: json['uri'] as String, @@ -68,14 +65,14 @@ _$SpotifySectionAlbumImpl _$$SpotifySectionAlbumImplFromJson( Map _$$SpotifySectionAlbumImplToJson( _$SpotifySectionAlbumImpl instance) => { - 'artists': instance.artists, - 'images': instance.images, + 'artists': instance.artists.map((e) => e.toJson()).toList(), + 'images': instance.images.map((e) => e.toJson()).toList(), 'name': instance.name, 'uri': instance.uri, }; _$SpotifySectionAlbumArtistImpl _$$SpotifySectionAlbumArtistImplFromJson( - Map json) => + Map json) => _$SpotifySectionAlbumArtistImpl( name: json['name'] as String, uri: json['uri'] as String, @@ -89,7 +86,7 @@ Map _$$SpotifySectionAlbumArtistImplToJson( }; _$SpotifySectionItemImageImpl _$$SpotifySectionItemImageImplFromJson( - Map json) => + Map json) => _$SpotifySectionItemImageImpl( height: json['height'] as num?, url: json['url'] as String, @@ -105,40 +102,40 @@ Map _$$SpotifySectionItemImageImplToJson( }; _$SpotifyHomeFeedSectionItemImpl _$$SpotifyHomeFeedSectionItemImplFromJson( - Map json) => + Map json) => _$SpotifyHomeFeedSectionItemImpl( typename: json['typename'] as String, playlist: json['playlist'] == null ? null : SpotifySectionPlaylist.fromJson( - json['playlist'] as Map), + Map.from(json['playlist'] as Map)), artist: json['artist'] == null ? null : SpotifySectionArtist.fromJson( - json['artist'] as Map), + Map.from(json['artist'] as Map)), album: json['album'] == null ? null - : SpotifySectionAlbum.fromJson(json['album'] as Map), + : SpotifySectionAlbum.fromJson( + Map.from(json['album'] as Map)), ); Map _$$SpotifyHomeFeedSectionItemImplToJson( _$SpotifyHomeFeedSectionItemImpl instance) => { 'typename': instance.typename, - 'playlist': instance.playlist, - 'artist': instance.artist, - 'album': instance.album, + 'playlist': instance.playlist?.toJson(), + 'artist': instance.artist?.toJson(), + 'album': instance.album?.toJson(), }; -_$SpotifyHomeFeedSectionImpl _$$SpotifyHomeFeedSectionImplFromJson( - Map json) => +_$SpotifyHomeFeedSectionImpl _$$SpotifyHomeFeedSectionImplFromJson(Map json) => _$SpotifyHomeFeedSectionImpl( typename: json['typename'] as String, title: json['title'] as String?, uri: json['uri'] as String, items: (json['items'] as List) - .map((e) => - SpotifyHomeFeedSectionItem.fromJson(e as Map)) + .map((e) => SpotifyHomeFeedSectionItem.fromJson( + Map.from(e as Map))) .toList(), ); @@ -148,16 +145,15 @@ Map _$$SpotifyHomeFeedSectionImplToJson( 'typename': instance.typename, 'title': instance.title, 'uri': instance.uri, - 'items': instance.items, + 'items': instance.items.map((e) => e.toJson()).toList(), }; -_$SpotifyHomeFeedImpl _$$SpotifyHomeFeedImplFromJson( - Map json) => +_$SpotifyHomeFeedImpl _$$SpotifyHomeFeedImplFromJson(Map json) => _$SpotifyHomeFeedImpl( greeting: json['greeting'] as String, sections: (json['sections'] as List) - .map( - (e) => SpotifyHomeFeedSection.fromJson(e as Map)) + .map((e) => SpotifyHomeFeedSection.fromJson( + Map.from(e as Map))) .toList(), ); @@ -165,5 +161,5 @@ Map _$$SpotifyHomeFeedImplToJson( _$SpotifyHomeFeedImpl instance) => { 'greeting': instance.greeting, - 'sections': instance.sections, + 'sections': instance.sections.map((e) => e.toJson()).toList(), }; diff --git a/lib/models/spotify/recommendation_seeds.freezed.dart b/lib/models/spotify/recommendation_seeds.freezed.dart index 4cfcce12a..adf4aab85 100644 --- a/lib/models/spotify/recommendation_seeds.freezed.dart +++ b/lib/models/spotify/recommendation_seeds.freezed.dart @@ -12,7 +12,7 @@ part of 'recommendation_seeds.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); /// @nodoc mixin _$GeneratePlaylistProviderInput { diff --git a/lib/models/spotify/recommendation_seeds.g.dart b/lib/models/spotify/recommendation_seeds.g.dart index bdfa3a074..accb2ed1d 100644 --- a/lib/models/spotify/recommendation_seeds.g.dart +++ b/lib/models/spotify/recommendation_seeds.g.dart @@ -6,8 +6,7 @@ part of 'recommendation_seeds.dart'; // JsonSerializableGenerator // ************************************************************************** -_$RecommendationSeedsImpl _$$RecommendationSeedsImplFromJson( - Map json) => +_$RecommendationSeedsImpl _$$RecommendationSeedsImplFromJson(Map json) => _$RecommendationSeedsImpl( acousticness: json['acousticness'] as num?, danceability: json['danceability'] as num?, diff --git a/lib/models/spotify_friends.g.dart b/lib/models/spotify_friends.g.dart index 4a32dd094..a1248429e 100644 --- a/lib/models/spotify_friends.g.dart +++ b/lib/models/spotify_friends.g.dart @@ -6,60 +6,55 @@ part of 'spotify_friends.dart'; // JsonSerializableGenerator // ************************************************************************** -SpotifyFriend _$SpotifyFriendFromJson(Map json) => - SpotifyFriend( +SpotifyFriend _$SpotifyFriendFromJson(Map json) => SpotifyFriend( uri: json['uri'] as String, name: json['name'] as String, imageUrl: json['imageUrl'] as String, ); -SpotifyActivityArtist _$SpotifyActivityArtistFromJson( - Map json) => +SpotifyActivityArtist _$SpotifyActivityArtistFromJson(Map json) => SpotifyActivityArtist( uri: json['uri'] as String, name: json['name'] as String, ); -SpotifyActivityAlbum _$SpotifyActivityAlbumFromJson( - Map json) => +SpotifyActivityAlbum _$SpotifyActivityAlbumFromJson(Map json) => SpotifyActivityAlbum( uri: json['uri'] as String, name: json['name'] as String, ); -SpotifyActivityContext _$SpotifyActivityContextFromJson( - Map json) => +SpotifyActivityContext _$SpotifyActivityContextFromJson(Map json) => SpotifyActivityContext( uri: json['uri'] as String, name: json['name'] as String, index: json['index'] as num, ); -SpotifyActivityTrack _$SpotifyActivityTrackFromJson( - Map json) => +SpotifyActivityTrack _$SpotifyActivityTrackFromJson(Map json) => SpotifyActivityTrack( uri: json['uri'] as String, name: json['name'] as String, imageUrl: json['imageUrl'] as String, artist: SpotifyActivityArtist.fromJson( - json['artist'] as Map), - album: - SpotifyActivityAlbum.fromJson(json['album'] as Map), + Map.from(json['artist'] as Map)), + album: SpotifyActivityAlbum.fromJson( + Map.from(json['album'] as Map)), context: SpotifyActivityContext.fromJson( - json['context'] as Map), + Map.from(json['context'] as Map)), ); -SpotifyFriendActivity _$SpotifyFriendActivityFromJson( - Map json) => +SpotifyFriendActivity _$SpotifyFriendActivityFromJson(Map json) => SpotifyFriendActivity( - user: SpotifyFriend.fromJson(json['user'] as Map), - track: - SpotifyActivityTrack.fromJson(json['track'] as Map), + user: SpotifyFriend.fromJson( + Map.from(json['user'] as Map)), + track: SpotifyActivityTrack.fromJson( + Map.from(json['track'] as Map)), ); -SpotifyFriends _$SpotifyFriendsFromJson(Map json) => - SpotifyFriends( +SpotifyFriends _$SpotifyFriendsFromJson(Map json) => SpotifyFriends( friends: (json['friends'] as List) - .map((e) => SpotifyFriendActivity.fromJson(e as Map)) + .map((e) => SpotifyFriendActivity.fromJson( + Map.from(e as Map))) .toList(), ); diff --git a/lib/components/album/album_card.dart b/lib/modules/album/album_card.dart similarity index 77% rename from lib/components/album/album_card.dart rename to lib/modules/album/album_card.dart index a71fbf03e..dd914fad9 100644 --- a/lib/components/album/album_card.dart +++ b/lib/modules/album/album_card.dart @@ -2,15 +2,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/dialogs/select_device_dialog.dart'; -import 'package:spotube/components/shared/playbutton_card.dart'; +import 'package:spotube/components/dialogs/select_device_dialog.dart'; +import 'package:spotube/components/playbutton_card.dart'; import 'package:spotube/extensions/artist_simple.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/extensions/track.dart'; import 'package:spotube/models/connect/connect.dart'; +import 'package:spotube/pages/album/album.dart'; +import 'package:spotube/provider/audio_player/querying_track_info.dart'; import 'package:spotube/provider/connect/connect.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/history/history.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; import 'package:spotube/utils/service_utils.dart'; @@ -28,10 +31,12 @@ class AlbumCard extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { - final playlist = ref.watch(proxyPlaylistProvider); + final playlist = ref.watch(audioPlayerProvider); final playing = useStream(audioPlayer.playingStream).data ?? audioPlayer.isPlaying; - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); + final playlistNotifier = ref.watch(audioPlayerProvider.notifier); + final historyNotifier = ref.read(playbackHistoryActionsProvider); + final isFetchingActiveTrack = ref.watch(queryingTrackInfoProvider); bool isPlaylistPlaying = useMemoized( () => playlist.containsCollection(album.id!), @@ -56,13 +61,20 @@ class AlbumCard extends HookConsumerWidget { ), margin: const EdgeInsets.symmetric(horizontal: 10), isPlaying: isPlaylistPlaying, - isLoading: (isPlaylistPlaying && playlist.isFetching == true) || - updating.value, + isLoading: + (isPlaylistPlaying && isFetchingActiveTrack) || updating.value, title: album.name!, description: "${album.albumType?.formatted} • ${album.artists?.asString() ?? ""}", onTap: () { - ServiceUtils.push(context, "/album/${album.id}", extra: album); + ServiceUtils.pushNamed( + context, + AlbumPage.name, + pathParameters: { + "id": album.id!, + }, + extra: album, + ); }, onPlaybuttonPressed: () async { updating.value = true; @@ -79,14 +91,15 @@ class AlbumCard extends HookConsumerWidget { if (isRemoteDevice) { final remotePlayback = ref.read(connectProvider.notifier); await remotePlayback.load( - WebSocketLoadEventData( + WebSocketLoadEventData.album( tracks: fetchedTracks, - collectionId: album.id!, + collection: album, ), ); } else { await playlistNotifier.load(fetchedTracks, autoPlay: true); playlistNotifier.addCollection(album.id!); + historyNotifier.addAlbums([album]); } } finally { updating.value = false; @@ -104,6 +117,7 @@ class AlbumCard extends HookConsumerWidget { if (fetchedTracks.isEmpty) return; playlistNotifier.addTracks(fetchedTracks); playlistNotifier.addCollection(album.id!); + historyNotifier.addAlbums([album]); if (context.mounted) { final snackbar = SnackBar( content: Text( diff --git a/lib/components/artist/artist_album_list.dart b/lib/modules/artist/artist_album_list.dart similarity index 82% rename from lib/components/artist/artist_album_list.dart rename to lib/modules/artist/artist_album_list.dart index a91327cea..a2dd80066 100644 --- a/lib/components/artist/artist_album_list.dart +++ b/lib/modules/artist/artist_album_list.dart @@ -1,20 +1,18 @@ import 'package:flutter/material.dart' hide Page; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; +import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/models/logger.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class ArtistAlbumList extends HookConsumerWidget { final String artistId; - ArtistAlbumList( + + const ArtistAlbumList( this.artistId, { super.key, }); - final logger = getLogger(ArtistAlbumList); - @override Widget build(BuildContext context, ref) { final albumsQuery = ref.watch(artistAlbumsProvider(artistId)); diff --git a/lib/components/artist/artist_card.dart b/lib/modules/artist/artist_card.dart similarity index 87% rename from lib/components/artist/artist_card.dart rename to lib/modules/artist/artist_card.dart index cc8485d5c..add2608d9 100644 --- a/lib/components/artist/artist_card.dart +++ b/lib/modules/artist/artist_card.dart @@ -4,11 +4,12 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/hooks/utils/use_breakpoint_value.dart'; import 'package:spotube/hooks/utils/use_brightness_value.dart'; +import 'package:spotube/pages/artist/artist.dart'; import 'package:spotube/provider/blacklist_provider.dart'; import 'package:spotube/utils/service_utils.dart'; @@ -26,8 +27,8 @@ class ArtistCard extends HookConsumerWidget { ); final isBlackListed = ref.watch( blacklistProvider.select( - (blacklist) => blacklist.contains( - BlacklistedElement.artist(artist.id!, artist.name!), + (blacklist) => blacklist.asData?.value.any( + (element) => element.elementId == artist.id, ), ), ); @@ -45,16 +46,16 @@ class ArtistCard extends HookConsumerWidget { width: size, margin: const EdgeInsets.symmetric(vertical: 5), child: Material( - shadowColor: theme.colorScheme.background, + shadowColor: theme.colorScheme.surface, color: Color.lerp( - theme.colorScheme.surfaceVariant, + theme.colorScheme.surfaceContainerHighest, theme.colorScheme.surface, useBrightnessValue(.9, .7), ), elevation: 3, shape: RoundedRectangleBorder( borderRadius: radius, - side: isBlackListed + side: isBlackListed == true ? const BorderSide( color: Colors.red, width: 2, @@ -63,7 +64,13 @@ class ArtistCard extends HookConsumerWidget { ), child: InkWell( onTap: () { - ServiceUtils.push(context, "/artist/${artist.id}"); + ServiceUtils.pushNamed( + context, + ArtistPage.name, + pathParameters: { + "id": artist.id!, + }, + ); }, borderRadius: radius, child: Padding( diff --git a/lib/components/connect/connect_device.dart b/lib/modules/connect/connect_device.dart similarity index 94% rename from lib/components/connect/connect_device.dart rename to lib/modules/connect/connect_device.dart index 3ac585df5..f48885344 100644 --- a/lib/components/connect/connect_device.dart +++ b/lib/modules/connect/connect_device.dart @@ -3,6 +3,7 @@ import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; import 'package:spotube/extensions/context.dart'; +import 'package:spotube/pages/connect/connect.dart'; import 'package:spotube/provider/connect/clients.dart'; import 'package:spotube/utils/service_utils.dart'; @@ -22,7 +23,7 @@ class ConnectDeviceButton extends HookConsumerWidget { width: double.infinity, child: TextButton( onPressed: () { - ServiceUtils.push(context, "/connect"); + ServiceUtils.pushNamed(context, ConnectPage.name); }, style: FilledButton.styleFrom( shape: RoundedRectangleBorder( @@ -59,7 +60,7 @@ class ConnectDeviceButton extends HookConsumerWidget { clipBehavior: Clip.hardEdge, child: InkWell( onTap: () { - ServiceUtils.push(context, "/connect"); + ServiceUtils.pushNamed(context, ConnectPage.name); }, borderRadius: BorderRadius.circular(50), child: Ink( @@ -111,7 +112,7 @@ class ConnectDeviceButton extends HookConsumerWidget { foregroundColor: colorScheme.onPrimary, ), onPressed: () { - ServiceUtils.push(context, "/connect"); + ServiceUtils.pushNamed(context, ConnectPage.name); }, ), ), diff --git a/lib/components/connect/local_devices.dart b/lib/modules/connect/local_devices.dart similarity index 100% rename from lib/components/connect/local_devices.dart rename to lib/modules/connect/local_devices.dart diff --git a/lib/components/getting_started/blur_card.dart b/lib/modules/getting_started/blur_card.dart similarity index 100% rename from lib/components/getting_started/blur_card.dart rename to lib/modules/getting_started/blur_card.dart diff --git a/lib/components/home/sections/featured.dart b/lib/modules/home/sections/featured.dart similarity index 90% rename from lib/components/home/sections/featured.dart rename to lib/modules/home/sections/featured.dart index 0db5a1e83..4f30c3421 100644 --- a/lib/components/home/sections/featured.dart +++ b/lib/modules/home/sections/featured.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart' hide Page; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; +import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/spotify/spotify.dart'; diff --git a/lib/components/home/sections/feed.dart b/lib/modules/home/sections/feed.dart similarity index 73% rename from lib/components/home/sections/feed.dart rename to lib/modules/home/sections/feed.dart index 793cd2c3b..8685fe19b 100644 --- a/lib/components/home/sections/feed.dart +++ b/lib/modules/home/sections/feed.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; +import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/pages/home/feed/feed_section.dart'; import 'package:spotube/provider/spotify/views/home.dart'; import 'package:spotube/utils/service_utils.dart'; @@ -32,17 +34,22 @@ class HomePageFeedSection extends HookConsumerWidget { else if (item.playlist != null) item.playlist!.asPlaylist ], - title: Text(section.title ?? "No Titel"), + title: Text(section.title ?? context.l10n.no_title), hasNextPage: false, isLoadingNextPage: false, onFetchMore: () {}, titleTrailing: Directionality( textDirection: TextDirection.rtl, child: TextButton.icon( - label: const Text("Browse More"), + label: Text(context.l10n.browse_more), icon: const Icon(SpotubeIcons.angleRight), - onPressed: () => - ServiceUtils.push(context, "/feeds/${section.uri}"), + onPressed: () => ServiceUtils.pushNamed( + context, + HomeFeedSectionPage.name, + pathParameters: { + "feedId": section.uri, + }, + ), ), ), ); diff --git a/lib/components/home/sections/friends.dart b/lib/modules/home/sections/friends.dart similarity index 69% rename from lib/components/home/sections/friends.dart rename to lib/modules/home/sections/friends.dart index 35ec09b0f..6f59c209f 100644 --- a/lib/components/home/sections/friends.dart +++ b/lib/modules/home/sections/friends.dart @@ -1,12 +1,15 @@ import 'dart:ui'; import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotube/collections/fake.dart'; -import 'package:spotube/components/home/sections/friends/friend_item.dart'; +import 'package:spotube/modules/home/sections/friends/friend_item.dart'; +import 'package:spotube/extensions/context.dart'; import 'package:spotube/hooks/utils/use_breakpoint_value.dart'; import 'package:spotube/models/spotify_friends.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class HomePageFriendsSection extends HookConsumerWidget { @@ -14,6 +17,7 @@ class HomePageFriendsSection extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { + final auth = ref.watch(authenticationProvider); final friendsQuery = ref.watch(friendsProvider); final friends = friendsQuery.asData?.value.friends ?? FakeData.friends.friends; @@ -27,32 +31,36 @@ class HomePageFriendsSection extends HookConsumerWidget { xxl: 7, ); - final friendGroup = friends.fold>>( - [], - (previousValue, element) { - if (previousValue.isEmpty) { - return [ - [element] - ]; - } + final friendGroup = useMemoized( + () => friends.fold>>( + [], + (previousValue, element) { + if (previousValue.isEmpty) { + return [ + [element] + ]; + } + + final lastGroup = previousValue.last; + if (lastGroup.length < groupCount) { + return [ + ...previousValue.sublist(0, previousValue.length - 1), + [...lastGroup, element] + ]; + } - final lastGroup = previousValue.last; - if (lastGroup.length < groupCount) { return [ - ...previousValue.sublist(0, previousValue.length - 1), - [...lastGroup, element] + ...previousValue, + [element] ]; - } - - return [ - ...previousValue, - [element] - ]; - }, + }, + ), + [friends, groupCount], ); if (friendsQuery.isLoading || - friendsQuery.asData?.value.friends.isEmpty == true) { + friendsQuery.asData?.value.friends.isEmpty == true || + auth.asData?.value == null) { return const SliverToBoxAdapter( child: SizedBox.shrink(), ); @@ -66,7 +74,7 @@ class HomePageFriendsSection extends HookConsumerWidget { child: Padding( padding: const EdgeInsets.all(8.0), child: Text( - 'Friends', + context.l10n.friends, style: Theme.of(context).textTheme.titleMedium, ), ), diff --git a/lib/components/home/sections/friends/friend_item.dart b/lib/modules/home/sections/friends/friend_item.dart similarity index 80% rename from lib/components/home/sections/friends/friend_item.dart rename to lib/modules/home/sections/friends/friend_item.dart index b883e2cc4..773a4a8c1 100644 --- a/lib/components/home/sections/friends/friend_item.dart +++ b/lib/modules/home/sections/friends/friend_item.dart @@ -4,8 +4,11 @@ import 'package:gap/gap.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/models/spotify_friends.dart'; +import 'package:spotube/pages/album/album.dart'; +import 'package:spotube/pages/artist/artist.dart'; +import 'package:spotube/pages/track/track.dart'; import 'package:spotube/provider/spotify_provider.dart'; class FriendItem extends HookConsumerWidget { @@ -27,7 +30,7 @@ class FriendItem extends HookConsumerWidget { return Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( - color: colorScheme.surfaceVariant.withOpacity(0.3), + color: colorScheme.surfaceContainerHighest.withOpacity(0.3), borderRadius: BorderRadius.circular(15), ), constraints: const BoxConstraints( @@ -57,7 +60,9 @@ class FriendItem extends HookConsumerWidget { text: friend.track.name, recognizer: TapGestureRecognizer() ..onTap = () { - context.push("/track/${friend.track.id}"); + context.pushNamed(TrackPage.name, pathParameters: { + "id": friend.track.id, + }); }, ), const TextSpan(text: " • "), @@ -71,8 +76,12 @@ class FriendItem extends HookConsumerWidget { text: " ${friend.track.artist.name}", recognizer: TapGestureRecognizer() ..onTap = () { - context.push( - "/artist/${friend.track.artist.id}", + context.pushNamed( + ArtistPage.name, + pathParameters: { + "id": friend.track.artist.id, + }, + extra: friend.track.artist, ); }, ), @@ -105,8 +114,11 @@ class FriendItem extends HookConsumerWidget { final album = await spotify.albums.get(friend.track.album.id); if (context.mounted) { - context.push( - "/album/${friend.track.album.id}", + context.pushNamed( + AlbumPage.name, + pathParameters: { + "id": friend.track.album.id, + }, extra: album, ); } diff --git a/lib/components/home/sections/genres.dart b/lib/modules/home/sections/genres.dart similarity index 89% rename from lib/components/home/sections/genres.dart rename to lib/modules/home/sections/genres.dart index ac2644f0b..5f2dfa5ed 100644 --- a/lib/components/home/sections/genres.dart +++ b/lib/modules/home/sections/genres.dart @@ -10,9 +10,11 @@ import 'package:spotify/spotify.dart'; import 'package:spotube/collections/fake.dart'; import 'package:spotube/collections/gradients.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; +import 'package:spotube/pages/home/genres/genre_playlists.dart'; +import 'package:spotube/pages/home/genres/genres.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class HomeGenresSection extends HookConsumerWidget { @@ -50,11 +52,11 @@ class HomeGenresSection extends HookConsumerWidget { textDirection: TextDirection.rtl, child: TextButton.icon( onPressed: () { - context.push('/genres'); + context.pushNamed(GenrePage.name); }, icon: const Icon(SpotubeIcons.angleRight), label: Text( - "Browse All", + context.l10n.browse_all, style: textTheme.bodyMedium?.copyWith( color: colorScheme.secondary, ), @@ -110,7 +112,13 @@ class HomeGenresSection extends HookConsumerWidget { return InkWell( onTap: () { - context.push('/genre/${category.id}', extra: category); + context.pushNamed( + GenrePlaylistsPage.name, + pathParameters: { + "categoryId": category.id!, + }, + extra: category, + ); }, borderRadius: BorderRadius.circular(8), child: Ink( @@ -126,7 +134,7 @@ class HomeGenresSection extends HookConsumerWidget { child: Ink( decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), - color: colorScheme.surfaceVariant, + color: colorScheme.surfaceContainerHighest, gradient: categoriesQuery.isLoading ? null : gradient, ), padding: const EdgeInsets.symmetric(horizontal: 16), diff --git a/lib/components/home/sections/made_for_user.dart b/lib/modules/home/sections/made_for_user.dart similarity index 91% rename from lib/components/home/sections/made_for_user.dart rename to lib/modules/home/sections/made_for_user.dart index d1d269f6f..1b9854d39 100644 --- a/lib/components/home/sections/made_for_user.dart +++ b/lib/modules/home/sections/made_for_user.dart @@ -1,7 +1,7 @@ import 'package:flutter/widgets.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; +import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class HomeMadeForUserSection extends HookConsumerWidget { diff --git a/lib/components/home/sections/new_releases.dart b/lib/modules/home/sections/new_releases.dart similarity index 83% rename from lib/components/home/sections/new_releases.dart rename to lib/modules/home/sections/new_releases.dart index 82bc0e8cd..e2b327414 100644 --- a/lib/components/home/sections/new_releases.dart +++ b/lib/modules/home/sections/new_releases.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart' hide Page; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; +import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class HomeNewReleasesSection extends HookConsumerWidget { @@ -18,7 +18,7 @@ class HomeNewReleasesSection extends HookConsumerWidget { final albums = ref.watch(userArtistAlbumReleasesProvider); - if (auth == null || + if (auth.asData?.value == null || newReleases.isLoading || newReleases.asData?.value.items.isEmpty == true) { return const SizedBox.shrink(); diff --git a/lib/modules/home/sections/recent.dart b/lib/modules/home/sections/recent.dart new file mode 100644 index 000000000..43c0459d9 --- /dev/null +++ b/lib/modules/home/sections/recent.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotube/collections/fake.dart'; +import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/history/recent.dart'; + +class HomeRecentlyPlayedSection extends HookConsumerWidget { + const HomeRecentlyPlayedSection({super.key}); + + @override + Widget build(BuildContext context, ref) { + final history = ref.watch(recentlyPlayedItems); + final historyData = + history.asData?.value ?? FakeData.historyRecentlyPlayedItems; + + if (history.asData?.value.isEmpty == true) { + return const SizedBox(); + } + + return Skeletonizer( + enabled: history.isLoading, + child: HorizontalPlaybuttonCardView( + title: Text(context.l10n.recently_played), + items: [ + for (final item in historyData) + if (item.playlist != null) + item.playlist + else if (item.album != null) + item.album + ], + hasNextPage: false, + isLoadingNextPage: false, + onFetchMore: () {}, + ), + ); + } +} diff --git a/lib/modules/library/local_folder/local_folder_item.dart b/lib/modules/library/local_folder/local_folder_item.dart new file mode 100644 index 000000000..02e47a534 --- /dev/null +++ b/lib/modules/library/local_folder/local_folder_item.dart @@ -0,0 +1,199 @@ +import 'dart:math'; + +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:go_router/go_router.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:path/path.dart'; +import 'package:spotube/collections/spotube_icons.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/extensions/constrains.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/extensions/image.dart'; +import 'package:spotube/hooks/utils/use_brightness_value.dart'; +import 'package:spotube/pages/library/local_folder.dart'; +import 'package:spotube/provider/local_tracks/local_tracks_provider.dart'; +import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; + +class LocalFolderItem extends HookConsumerWidget { + final String folder; + const LocalFolderItem({super.key, required this.folder}); + + @override + Widget build(BuildContext context, ref) { + final ThemeData(:colorScheme) = Theme.of(context); + final mediaQuery = MediaQuery.of(context); + + final lerpValue = useBrightnessValue(.9, .7); + + final downloadFolder = + ref.watch(userPreferencesProvider.select((s) => s.downloadLocation)); + + final isDownloadFolder = folder == downloadFolder; + + final Uri(:pathSegments) = Uri.parse( + folder + .replaceFirst(RegExp(r'^/Volumes/[^/]+/Users/'), "") + .replaceFirst(r'C:\Users\', "") + .replaceFirst(r'/home/', ""), + ); + + // if length > 5, we ... all the middle segments after 2 and the last 2 + final segments = pathSegments.length > 5 + ? [ + ...pathSegments.take(2), + "...", + ...pathSegments.skip(pathSegments.length - 3).toList() + ..removeLast(), + ] + : pathSegments.take(max(pathSegments.length - 1, 0)).toList(); + + final trackSnapshot = ref.watch( + localTracksProvider.select( + (s) => s.whenData((tracks) => tracks[folder]?.take(4).toList()), + ), + ); + + final tracks = trackSnapshot.value ?? []; + + return InkWell( + onTap: () { + context.goNamed( + LocalLibraryPage.name, + queryParameters: { + if (isDownloadFolder) "downloads": "true", + }, + extra: folder, + ); + }, + borderRadius: BorderRadius.circular(8), + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8), + color: Color.lerp( + colorScheme.surfaceContainerHighest, + colorScheme.surface, + lerpValue, + ), + ), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + if (tracks.isEmpty) + Card( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Icon( + SpotubeIcons.folder, + size: mediaQuery.smAndDown + ? 95 + : mediaQuery.mdAndDown + ? 100 + : 142, + ), + ), + ) + else + ClipRRect( + borderRadius: BorderRadius.circular(8), + child: GridView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: max((tracks.length / 2).ceil(), 2), + ), + itemCount: tracks.length, + itemBuilder: (context, index) { + final track = tracks[index]; + return UniversalImage( + path: (track.album?.images).asUrlString( + placeholder: ImagePlaceholder.albumArt, + ), + fit: BoxFit.cover, + ); + }, + ), + ), + const Gap(8), + Stack( + children: [ + Center( + child: Text( + isDownloadFolder + ? context.l10n.downloads + : basename(folder), + style: const TextStyle(fontWeight: FontWeight.bold), + textAlign: TextAlign.center, + ), + ), + if (!isDownloadFolder) + Align( + alignment: Alignment.topRight, + child: PopupMenuButton( + child: const Padding( + padding: EdgeInsets.all(3), + child: Icon(Icons.more_vert), + ), + itemBuilder: (context) { + return [ + PopupMenuItem( + child: ListTile( + leading: const Icon(SpotubeIcons.folderRemove), + iconColor: colorScheme.error, + title: + Text(context.l10n.remove_library_location), + onTap: () { + final libraryLocations = ref + .read(userPreferencesProvider) + .localLibraryLocation; + ref + .read(userPreferencesProvider.notifier) + .setLocalLibraryLocation( + libraryLocations + .where((e) => e != folder) + .toList(), + ); + }, + ), + ) + ]; + }, + ), + ), + ], + ), + const Spacer(), + Wrap( + spacing: 2, + runSpacing: 2, + children: [ + for (final MapEntry(key: index, value: segment) + in segments.asMap().entries) + Text.rich( + TextSpan( + children: [ + if (index != 0) + TextSpan( + text: "/ ", + style: TextStyle(color: colorScheme.primary), + ), + TextSpan(text: segment), + ], + ), + style: TextStyle( + fontSize: 10, + color: colorScheme.tertiary, + ), + ), + ], + ), + const Spacer(), + ], + ), + ), + ), + ); + } +} diff --git a/lib/components/library/playlist_generate/multi_select_field.dart b/lib/modules/library/playlist_generate/multi_select_field.dart similarity index 98% rename from lib/components/library/playlist_generate/multi_select_field.dart rename to lib/modules/library/playlist_generate/multi_select_field.dart index e54fc2ba3..7118d57df 100644 --- a/lib/components/library/playlist_generate/multi_select_field.dart +++ b/lib/modules/library/playlist_generate/multi_select_field.dart @@ -71,7 +71,7 @@ class MultiSelectField extends HookWidget { : theme.colorScheme.onSurface.withOpacity(0.1), ), ), - mouseCursor: MaterialStateMouseCursor.textable, + mouseCursor: WidgetStateMouseCursor.textable, onPressed: !enabled ? null : () async { @@ -187,7 +187,7 @@ class _MultiSelectDialog extends HookWidget { return AlertDialog( scrollable: true, - title: dialogTitle ?? const Text('Select'), + title: dialogTitle ?? Text(context.l10n.select), contentPadding: mediaQuery.mdAndUp ? null : const EdgeInsets.all(16), insetPadding: const EdgeInsets.all(16), actions: [ diff --git a/lib/components/library/playlist_generate/recommendation_attribute_dials.dart b/lib/modules/library/playlist_generate/recommendation_attribute_dials.dart similarity index 100% rename from lib/components/library/playlist_generate/recommendation_attribute_dials.dart rename to lib/modules/library/playlist_generate/recommendation_attribute_dials.dart diff --git a/lib/components/library/playlist_generate/recommendation_attribute_fields.dart b/lib/modules/library/playlist_generate/recommendation_attribute_fields.dart similarity index 98% rename from lib/components/library/playlist_generate/recommendation_attribute_fields.dart rename to lib/modules/library/playlist_generate/recommendation_attribute_fields.dart index 754373600..7feff03ae 100644 --- a/lib/components/library/playlist_generate/recommendation_attribute_fields.dart +++ b/lib/modules/library/playlist_generate/recommendation_attribute_fields.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; -import 'package:spotube/components/library/playlist_generate/recommendation_attribute_dials.dart'; +import 'package:spotube/modules/library/playlist_generate/recommendation_attribute_dials.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/pages/library/playlist_generate/playlist_generate.dart'; diff --git a/lib/components/library/playlist_generate/seeds_multi_autocomplete.dart b/lib/modules/library/playlist_generate/seeds_multi_autocomplete.dart similarity index 100% rename from lib/components/library/playlist_generate/seeds_multi_autocomplete.dart rename to lib/modules/library/playlist_generate/seeds_multi_autocomplete.dart diff --git a/lib/components/library/playlist_generate/simple_track_tile.dart b/lib/modules/library/playlist_generate/simple_track_tile.dart similarity index 94% rename from lib/components/library/playlist_generate/simple_track_tile.dart rename to lib/modules/library/playlist_generate/simple_track_tile.dart index cf4ddb1aa..e6cc281f3 100644 --- a/lib/components/library/playlist_generate/simple_track_tile.dart +++ b/lib/modules/library/playlist_generate/simple_track_tile.dart @@ -3,7 +3,7 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/extensions/image.dart'; class SimpleTrackTile extends HookWidget { diff --git a/lib/components/library/user_albums.dart b/lib/modules/library/user_albums.dart similarity index 91% rename from lib/components/library/user_albums.dart rename to lib/modules/library/user_albums.dart index e1b821131..c2c91293e 100644 --- a/lib/components/library/user_albums.dart +++ b/lib/modules/library/user_albums.dart @@ -8,13 +8,13 @@ import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotube/collections/fake.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/album/album_card.dart'; -import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart'; -import 'package:spotube/components/shared/fallbacks/anonymous_fallback.dart'; -import 'package:spotube/components/shared/waypoint.dart'; +import 'package:spotube/modules/album/album_card.dart'; +import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart'; +import 'package:spotube/components/fallbacks/anonymous_fallback.dart'; +import 'package:spotube/components/waypoint.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class UserAlbums extends HookConsumerWidget { @@ -46,7 +46,7 @@ class UserAlbums extends HookConsumerWidget { []; }, [albumsQuery.asData?.value, searchText.value]); - if (auth == null) { + if (auth.asData?.value == null) { return const AnonymousFallback(); } diff --git a/lib/components/library/user_artists.dart b/lib/modules/library/user_artists.dart similarity index 92% rename from lib/components/library/user_artists.dart rename to lib/modules/library/user_artists.dart index 0ef0ff39d..dd097080a 100644 --- a/lib/components/library/user_artists.dart +++ b/lib/modules/library/user_artists.dart @@ -8,13 +8,13 @@ import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotube/collections/fake.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/fallbacks/anonymous_fallback.dart'; -import 'package:spotube/components/artist/artist_card.dart'; -import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart'; -import 'package:spotube/components/shared/waypoint.dart'; +import 'package:spotube/components/fallbacks/anonymous_fallback.dart'; +import 'package:spotube/modules/artist/artist_card.dart'; +import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart'; +import 'package:spotube/components/waypoint.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class UserArtists extends HookConsumerWidget { @@ -48,7 +48,7 @@ class UserArtists extends HookConsumerWidget { final controller = useScrollController(); - if (auth == null) { + if (auth.asData?.value == null) { return const AnonymousFallback(); } diff --git a/lib/components/library/user_downloads.dart b/lib/modules/library/user_downloads.dart similarity index 92% rename from lib/components/library/user_downloads.dart rename to lib/modules/library/user_downloads.dart index 3a1162e60..7fe9800cf 100644 --- a/lib/components/library/user_downloads.dart +++ b/lib/modules/library/user_downloads.dart @@ -2,7 +2,7 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/components/library/user_downloads/download_item.dart'; +import 'package:spotube/modules/library/user_downloads/download_item.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/download_manager_provider.dart'; @@ -31,7 +31,7 @@ class UserDownloads extends HookConsumerWidget { context.l10n .currently_downloading(downloadManager.$downloadCount), maxLines: 1, - style: Theme.of(context).textTheme.headlineMedium, + style: Theme.of(context).textTheme.titleMedium, ), ), const SizedBox(width: 10), diff --git a/lib/components/library/user_downloads/download_item.dart b/lib/modules/library/user_downloads/download_item.dart similarity index 92% rename from lib/components/library/user_downloads/download_item.dart rename to lib/modules/library/user_downloads/download_item.dart index a145fdad7..c4bd7bcef 100644 --- a/lib/components/library/user_downloads/download_item.dart +++ b/lib/modules/library/user_downloads/download_item.dart @@ -3,13 +3,15 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/links/artist_link.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/links/artist_link.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; +import 'package:spotube/pages/track/track.dart'; import 'package:spotube/provider/download_manager_provider.dart'; import 'package:spotube/services/download_manager/download_status.dart'; import 'package:spotube/services/sourced_track/sourced_track.dart'; +import 'package:spotube/utils/service_utils.dart'; class DownloadItem extends HookConsumerWidget { final Track track; @@ -62,6 +64,13 @@ class DownloadItem extends HookConsumerWidget { subtitle: ArtistLink( artists: track.artists ?? [], mainAxisAlignment: WrapAlignment.start, + onOverflowArtistClick: () => ServiceUtils.pushNamed( + context, + TrackPage.name, + pathParameters: { + "id": track.id!, + }, + ), ), trailing: isQueryingSourceInfo ? Text( diff --git a/lib/modules/library/user_local_tracks.dart b/lib/modules/library/user_local_tracks.dart new file mode 100644 index 000000000..926b4e80c --- /dev/null +++ b/lib/modules/library/user_local_tracks.dart @@ -0,0 +1,101 @@ +import 'package:file_picker/file_picker.dart'; +import 'package:file_selector/file_selector.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:gap/gap.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; + +import 'package:spotube/collections/spotube_icons.dart'; +import 'package:spotube/modules/library/local_folder/local_folder_item.dart'; +import 'package:spotube/extensions/constrains.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/provider/local_tracks/local_tracks_provider.dart'; +import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +import 'package:spotube/utils/platform.dart'; +// ignore: depend_on_referenced_packages + +enum SortBy { + none, + ascending, + descending, + newest, + oldest, + duration, + artist, + album, +} + +class UserLocalTracks extends HookConsumerWidget { + const UserLocalTracks({super.key}); + + @override + Widget build(BuildContext context, ref) { + final preferencesNotifier = ref.watch(userPreferencesProvider.notifier); + final preferences = ref.watch(userPreferencesProvider); + + final addLocalLibraryLocation = useCallback(() async { + if (kIsMobile || kIsMacOS) { + final dirStr = await FilePicker.platform.getDirectoryPath( + initialDirectory: preferences.downloadLocation, + ); + if (dirStr == null) return; + if (preferences.localLibraryLocation.contains(dirStr)) return; + preferencesNotifier.setLocalLibraryLocation( + [...preferences.localLibraryLocation, dirStr]); + } else { + String? dirStr = await getDirectoryPath( + initialDirectory: preferences.downloadLocation, + ); + if (dirStr == null) return; + if (preferences.localLibraryLocation.contains(dirStr)) return; + preferencesNotifier.setLocalLibraryLocation( + [...preferences.localLibraryLocation, dirStr]); + } + }, [preferences.localLibraryLocation]); + + // This is just to pre-load the tracks. + // For now, this gets all of them. + ref.watch(localTracksProvider); + + return LayoutBuilder(builder: (context, constrains) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 12.0), + child: Column( + children: [ + Align( + alignment: Alignment.centerRight, + child: TextButton.icon( + icon: const Icon(SpotubeIcons.folderAdd), + label: Text(context.l10n.add_library_location), + onPressed: addLocalLibraryLocation, + ), + ), + const Gap(8), + Expanded( + child: GridView.builder( + gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( + maxCrossAxisExtent: 200, + mainAxisExtent: constrains.isXs + ? 210 + : constrains.mdAndDown + ? 280 + : 250, + crossAxisSpacing: 10, + mainAxisSpacing: 10, + ), + itemCount: preferences.localLibraryLocation.length + 1, + itemBuilder: (context, index) { + return LocalFolderItem( + folder: index == 0 + ? preferences.downloadLocation + : preferences.localLibraryLocation[index - 1], + ); + }, + ), + ), + ], + ), + ); + }); + } +} diff --git a/lib/components/library/user_playlists.dart b/lib/modules/library/user_playlists.dart similarity index 88% rename from lib/components/library/user_playlists.dart rename to lib/modules/library/user_playlists.dart index 069dfad95..577f96559 100644 --- a/lib/components/library/user_playlists.dart +++ b/lib/modules/library/user_playlists.dart @@ -3,23 +3,24 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:fuzzywuzzy/fuzzywuzzy.dart'; import 'package:collection/collection.dart'; import 'package:gap/gap.dart'; -import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/fake.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/playlist/playlist_create_dialog.dart'; -import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart'; -import 'package:spotube/components/shared/fallbacks/anonymous_fallback.dart'; -import 'package:spotube/components/playlist/playlist_card.dart'; -import 'package:spotube/components/shared/waypoint.dart'; +import 'package:spotube/modules/playlist/playlist_create_dialog.dart'; +import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart'; +import 'package:spotube/components/fallbacks/anonymous_fallback.dart'; +import 'package:spotube/modules/playlist/playlist_card.dart'; +import 'package:spotube/components/waypoint.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/pages/library/playlist_generate/playlist_generate.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:spotube/utils/platform.dart'; +import 'package:spotube/utils/service_utils.dart'; class UserPlaylists extends HookConsumerWidget { const UserPlaylists({super.key}); @@ -74,7 +75,7 @@ class UserPlaylists extends HookConsumerWidget { final controller = useScrollController(); - if (auth == null) { + if (auth.asData?.value == null) { return const AnonymousFallback(); } @@ -110,7 +111,8 @@ class UserPlaylists extends HookConsumerWidget { icon: const Icon(SpotubeIcons.magic), label: Text(context.l10n.generate_playlist), onPressed: () { - GoRouter.of(context).push("/library/generate"); + ServiceUtils.pushNamed( + context, PlaylistGeneratorPage.name); }, ), const Gap(10), diff --git a/lib/components/lyrics/use_synced_lyrics.dart b/lib/modules/lyrics/use_synced_lyrics.dart similarity index 100% rename from lib/components/lyrics/use_synced_lyrics.dart rename to lib/modules/lyrics/use_synced_lyrics.dart diff --git a/lib/components/lyrics/zoom_controls.dart b/lib/modules/lyrics/zoom_controls.dart similarity index 100% rename from lib/components/lyrics/zoom_controls.dart rename to lib/modules/lyrics/zoom_controls.dart diff --git a/lib/components/player/player.dart b/lib/modules/player/player.dart similarity index 89% rename from lib/components/player/player.dart rename to lib/modules/player/player.dart index 493410585..3202eedad 100644 --- a/lib/components/player/player.dart +++ b/lib/modules/player/player.dart @@ -6,16 +6,16 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/player/player_actions.dart'; -import 'package:spotube/components/player/player_controls.dart'; -import 'package:spotube/components/player/player_queue.dart'; -import 'package:spotube/components/player/volume_slider.dart'; -import 'package:spotube/components/shared/animated_gradient.dart'; -import 'package:spotube/components/shared/dialogs/track_details_dialog.dart'; -import 'package:spotube/components/shared/links/artist_link.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/panels/sliding_up_panel.dart'; +import 'package:spotube/modules/player/player_actions.dart'; +import 'package:spotube/modules/player/player_controls.dart'; +import 'package:spotube/modules/player/player_queue.dart'; +import 'package:spotube/modules/player/volume_slider.dart'; +import 'package:spotube/components/animated_gradient.dart'; +import 'package:spotube/components/dialogs/track_details_dialog.dart'; +import 'package:spotube/components/links/artist_link.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/panels/sliding_up_panel.dart'; import 'package:spotube/extensions/artist_simple.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; @@ -24,11 +24,13 @@ import 'package:spotube/hooks/utils/use_custom_status_bar_color.dart'; import 'package:spotube/hooks/utils/use_palette_color.dart'; import 'package:spotube/models/local_track.dart'; import 'package:spotube/pages/lyrics/lyrics.dart'; -import 'package:spotube/provider/authentication_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/pages/track/track.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/server/active_sourced_track.dart'; import 'package:spotube/provider/volume_provider.dart'; import 'package:spotube/services/sourced_track/sources/youtube.dart'; +import 'package:spotube/utils/service_utils.dart'; import 'package:url_launcher/url_launcher_string.dart'; @@ -47,7 +49,7 @@ class PlayerView extends HookConsumerWidget { final auth = ref.watch(authenticationProvider); final sourcedCurrentTrack = ref.watch(activeSourcedTrackProvider); final currentActiveTrack = - ref.watch(proxyPlaylistProvider.select((s) => s.activeTrack)); + ref.watch(audioPlayerProvider.select((s) => s.activeTrack)); final currentTrack = sourcedCurrentTrack ?? currentActiveTrack; final isLocalTrack = currentTrack is LocalTrack; final mediaQuery = MediaQuery.of(context); @@ -231,7 +233,8 @@ class PlayerView extends HookConsumerWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ AutoSizeText( - currentTrack?.name ?? "Not playing", + currentTrack?.name ?? + context.l10n.not_playing, style: TextStyle( color: titleTextColor, fontSize: 22, @@ -260,6 +263,14 @@ class PlayerView extends HookConsumerWidget { panelController.close(); GoRouter.of(context).push(route); }, + onOverflowArtistClick: () => + ServiceUtils.pushNamed( + context, + TrackPage.name, + pathParameters: { + "id": currentTrack!.id!, + }, + ), ), ], ), @@ -267,7 +278,7 @@ class PlayerView extends HookConsumerWidget { const SizedBox(height: 10), PlayerControls(palette: palette), const SizedBox(height: 25), - PlayerActions( + const PlayerActions( mainAxisAlignment: MainAxisAlignment.spaceEvenly, showQueue: false, ), @@ -309,15 +320,13 @@ class PlayerView extends HookConsumerWidget { builder: (context) => Consumer( builder: (context, ref, _) { final playlist = ref.watch( - proxyPlaylistProvider, - ); - final playlistNotifier = - ref.read( - proxyPlaylistProvider - .notifier, + audioPlayerProvider, ); + final playlistNotifier = ref + .read(audioPlayerProvider + .notifier); return PlayerQueue - .fromProxyPlaylistNotifier( + .fromAudioPlayerNotifier( floating: false, playlist: playlist, notifier: playlistNotifier, @@ -328,8 +337,9 @@ class PlayerView extends HookConsumerWidget { } : null), ), - if (auth != null) const SizedBox(width: 10), - if (auth != null) + if (auth.asData?.value != null) + const SizedBox(width: 10), + if (auth.asData?.value != null) Expanded( child: OutlinedButton.icon( label: Text(context.l10n.lyrics), diff --git a/lib/components/player/player_actions.dart b/lib/modules/player/player_actions.dart similarity index 91% rename from lib/components/player/player_actions.dart rename to lib/modules/player/player_actions.dart index d28c3900c..a47c992d7 100644 --- a/lib/components/player/player_actions.dart +++ b/lib/modules/player/player_actions.dart @@ -4,17 +4,16 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/player/sibling_tracks_sheet.dart'; -import 'package:spotube/components/shared/adaptive/adaptive_pop_sheet_list.dart'; -import 'package:spotube/components/shared/heart_button.dart'; +import 'package:spotube/modules/player/sibling_tracks_sheet.dart'; +import 'package:spotube/components/adaptive/adaptive_pop_sheet_list.dart'; +import 'package:spotube/components/heart_button/heart_button.dart'; import 'package:spotube/extensions/artist_simple.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/duration.dart'; import 'package:spotube/models/local_track.dart'; -import 'package:spotube/models/logger.dart'; import 'package:spotube/provider/download_manager_provider.dart'; -import 'package:spotube/provider/authentication_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/sleep_timer_provider.dart'; class PlayerActions extends HookConsumerWidget { @@ -22,18 +21,18 @@ class PlayerActions extends HookConsumerWidget { final bool floatingQueue; final bool showQueue; final List? extraActions; - PlayerActions({ + + const PlayerActions({ this.mainAxisAlignment = MainAxisAlignment.center, this.floatingQueue = true, this.showQueue = true, this.extraActions, super.key, }); - final logger = getLogger(PlayerActions); @override Widget build(BuildContext context, ref) { - final playlist = ref.watch(proxyPlaylistProvider); + final playlist = ref.watch(audioPlayerProvider); final isLocalTrack = playlist.activeTrack is LocalTrack; ref.watch(downloadManagerProvider); final downloader = ref.watch(downloadManagerProvider.notifier); @@ -129,7 +128,9 @@ class PlayerActions extends HookConsumerWidget { ? () => downloader.addToQueue(playlist.activeTrack!) : null, ), - if (playlist.activeTrack != null && !isLocalTrack && auth != null) + if (playlist.activeTrack != null && + !isLocalTrack && + auth.asData?.value != null) TrackHeartButton(track: playlist.activeTrack!), AdaptivePopSheetList( offset: Offset(0, -50 * (sleepTimerEntries.values.length + 2)), diff --git a/lib/components/player/player_controls.dart b/lib/modules/player/player_controls.dart similarity index 75% rename from lib/components/player/player_controls.dart rename to lib/modules/player/player_controls.dart index 7683de199..c88f62582 100644 --- a/lib/components/player/player_controls.dart +++ b/lib/modules/player/player_controls.dart @@ -2,30 +2,28 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:media_kit/media_kit.dart'; import 'package:palette_generator/palette_generator.dart'; import 'package:spotube/collections/spotube_icons.dart'; import 'package:spotube/collections/intents.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/duration.dart'; -import 'package:spotube/components/player/use_progress.dart'; -import 'package:spotube/models/logger.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/modules/player/use_progress.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/provider/audio_player/querying_track_info.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; -import 'package:spotube/services/audio_player/loop_mode.dart'; class PlayerControls extends HookConsumerWidget { final PaletteGenerator? palette; final bool compact; - PlayerControls({ + const PlayerControls({ this.palette, this.compact = false, super.key, }); - final logger = getLogger(PlayerControls); - static FocusNode focusNode = FocusNode(); @override @@ -43,8 +41,7 @@ class PlayerControls extends HookConsumerWidget { SeekIntent: SeekAction(), }, []); - final playlist = ref.watch(proxyPlaylistProvider); - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); + final isFetchingActiveTrack = ref.watch(queryingTrackInfoProvider); final playing = useStream(audioPlayer.playingStream).data ?? audioPlayer.isPlaying; @@ -132,7 +129,7 @@ class PlayerControls extends HookConsumerWidget { // than total duration. Keeping it resolved value: progress.value.toDouble(), secondaryTrackValue: bufferProgress, - onChanged: playlist.isFetching == true + onChanged: isFetchingActiveTrack ? null : (v) { progress.value = v; @@ -183,7 +180,7 @@ class PlayerControls extends HookConsumerWidget { : context.l10n.shuffle_playlist, icon: const Icon(SpotubeIcons.shuffle), style: shuffled ? activeButtonStyle : buttonStyle, - onPressed: playlist.isFetching == true + onPressed: isFetchingActiveTrack ? null : () { if (shuffled) { @@ -198,15 +195,15 @@ class PlayerControls extends HookConsumerWidget { tooltip: context.l10n.previous_track, icon: const Icon(SpotubeIcons.skipBack), style: buttonStyle, - onPressed: playlist.isFetching == true + onPressed: isFetchingActiveTrack ? null - : playlistNotifier.previous, + : audioPlayer.skipToPrevious, ), IconButton( tooltip: playing ? context.l10n.pause_playback : context.l10n.resume_playback, - icon: playlist.isFetching == true + icon: isFetchingActiveTrack ? SizedBox( height: 20, width: 20, @@ -219,7 +216,7 @@ class PlayerControls extends HookConsumerWidget { playing ? SpotubeIcons.pause : SpotubeIcons.play, ), style: resumePauseStyle, - onPressed: playlist.isFetching == true + onPressed: isFetchingActiveTrack ? null : Actions.handler( context, @@ -230,45 +227,41 @@ class PlayerControls extends HookConsumerWidget { tooltip: context.l10n.next_track, icon: const Icon(SpotubeIcons.skipForward), style: buttonStyle, - onPressed: playlist.isFetching == true - ? null - : playlistNotifier.next, + onPressed: + isFetchingActiveTrack ? null : audioPlayer.skipToNext, ), - StreamBuilder( - stream: audioPlayer.loopModeStream, - builder: (context, snapshot) { - final loopMode = snapshot.data ?? PlaybackLoopMode.none; - return IconButton( - tooltip: loopMode == PlaybackLoopMode.one - ? context.l10n.loop_track - : loopMode == PlaybackLoopMode.all - ? context.l10n.repeat_playlist - : null, - icon: Icon( - loopMode == PlaybackLoopMode.one - ? SpotubeIcons.repeatOne - : SpotubeIcons.repeat, - ), - style: loopMode == PlaybackLoopMode.one || - loopMode == PlaybackLoopMode.all - ? activeButtonStyle - : buttonStyle, - onPressed: playlist.isFetching == true - ? null - : () async { - audioPlayer.setLoopMode( - switch (loopMode) { - PlaybackLoopMode.all => - PlaybackLoopMode.one, - PlaybackLoopMode.one => - PlaybackLoopMode.none, - PlaybackLoopMode.none => - PlaybackLoopMode.all, - }, - ); + Consumer(builder: (context, ref, _) { + final loopMode = ref + .watch(audioPlayerProvider.select((s) => s.loopMode)); + + return IconButton( + tooltip: loopMode == PlaylistMode.single + ? context.l10n.loop_track + : loopMode == PlaylistMode.loop + ? context.l10n.repeat_playlist + : null, + icon: Icon( + loopMode == PlaylistMode.single + ? SpotubeIcons.repeatOne + : SpotubeIcons.repeat, + ), + style: loopMode == PlaylistMode.single || + loopMode == PlaylistMode.loop + ? activeButtonStyle + : buttonStyle, + onPressed: isFetchingActiveTrack + ? null + : () async { + await audioPlayer.setLoopMode( + switch (loopMode) { + PlaylistMode.loop => PlaylistMode.single, + PlaylistMode.single => PlaylistMode.none, + PlaylistMode.none => PlaylistMode.loop, }, - ); - }), + ); + }, + ); + }), ], ), const SizedBox(height: 5) diff --git a/lib/components/player/player_overlay.dart b/lib/modules/player/player_overlay.dart similarity index 88% rename from lib/components/player/player_overlay.dart rename to lib/modules/player/player_overlay.dart index 168e022d2..2322bcbac 100644 --- a/lib/components/player/player_overlay.dart +++ b/lib/modules/player/player_overlay.dart @@ -4,14 +4,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/components/player/player_track_details.dart'; -import 'package:spotube/components/root/spotube_navigation_bar.dart'; -import 'package:spotube/components/shared/panels/sliding_up_panel.dart'; +import 'package:spotube/modules/player/player_track_details.dart'; +import 'package:spotube/modules/root/spotube_navigation_bar.dart'; +import 'package:spotube/components/panels/sliding_up_panel.dart'; import 'package:spotube/collections/spotube_icons.dart'; import 'package:spotube/collections/intents.dart'; -import 'package:spotube/components/player/use_progress.dart'; -import 'package:spotube/components/player/player.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/modules/player/use_progress.dart'; +import 'package:spotube/modules/player/player.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/provider/audio_player/querying_track_info.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; class PlayerOverlay extends HookConsumerWidget { @@ -24,8 +25,8 @@ class PlayerOverlay extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); - final playlist = ref.watch(proxyPlaylistProvider); + final isFetchingActiveTrack = ref.watch(queryingTrackInfoProvider); + final playlist = ref.watch(audioPlayerProvider); final canShow = playlist.activeTrack != null; final playing = @@ -127,14 +128,14 @@ class PlayerOverlay extends HookConsumerWidget { SpotubeIcons.skipBack, color: textColor, ), - onPressed: playlist.isFetching + onPressed: isFetchingActiveTrack ? null - : playlistNotifier.previous, + : audioPlayer.skipToPrevious, ), Consumer( builder: (context, ref, _) { return IconButton( - icon: playlist.isFetching + icon: isFetchingActiveTrack ? const SizedBox( height: 20, width: 20, @@ -158,9 +159,9 @@ class PlayerOverlay extends HookConsumerWidget { SpotubeIcons.skipForward, color: textColor, ), - onPressed: playlist.isFetching + onPressed: isFetchingActiveTrack ? null - : playlistNotifier.next, + : audioPlayer.skipToNext, ), ], ), diff --git a/lib/components/player/player_queue.dart b/lib/modules/player/player_queue.dart similarity index 94% rename from lib/components/player/player_queue.dart rename to lib/modules/player/player_queue.dart index 914d7bc97..369b95d25 100644 --- a/lib/components/player/player_queue.dart +++ b/lib/modules/player/player_queue.dart @@ -11,19 +11,19 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:scroll_to_index/scroll_to_index.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/fallbacks/not_found.dart'; -import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart'; -import 'package:spotube/components/shared/track_tile/track_tile.dart'; +import 'package:spotube/components/fallbacks/not_found.dart'; +import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart'; +import 'package:spotube/components/track_tile/track_tile.dart'; import 'package:spotube/extensions/artist_simple.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/hooks/controllers/use_auto_scroll_controller.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/provider/audio_player/state.dart'; class PlayerQueue extends HookConsumerWidget { final bool floating; - final ProxyPlaylist playlist; + final AudioPlayerState playlist; final Future Function(Track track) onJump; final Future Function(String trackId) onRemove; @@ -40,10 +40,10 @@ class PlayerQueue extends HookConsumerWidget { super.key, }); - PlayerQueue.fromProxyPlaylistNotifier({ + PlayerQueue.fromAudioPlayerNotifier({ this.floating = true, required this.playlist, - required ProxyPlaylistNotifier notifier, + required AudioPlayerNotifier notifier, super.key, }) : onJump = notifier.jumpToTrack, onRemove = notifier.removeTrack, @@ -93,11 +93,10 @@ class PlayerQueue extends HookConsumerWidget { ); useEffect(() { - if (playlist.active == null) return null; + if (playlist.activeTrack == null) return null; - if (playlist.active! < 0) return; controller.scrollToIndex( - playlist.active!, + playlist.playlist.index, preferPosition: AutoScrollPosition.middle, ); return null; @@ -122,7 +121,8 @@ class PlayerQueue extends HookConsumerWidget { top: 5.0, ), decoration: BoxDecoration( - color: theme.colorScheme.surfaceVariant.withOpacity(0.5), + color: + theme.colorScheme.surfaceContainerHighest.withOpacity(0.5), borderRadius: borderRadius, ), child: CallbackShortcuts( diff --git a/lib/components/player/player_track_details.dart b/lib/modules/player/player_track_details.dart similarity index 82% rename from lib/components/player/player_track_details.dart rename to lib/modules/player/player_track_details.dart index 4746fe51a..8d3b99fad 100644 --- a/lib/components/player/player_track_details.dart +++ b/lib/modules/player/player_track_details.dart @@ -3,13 +3,14 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/assets.gen.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/links/artist_link.dart'; -import 'package:spotube/components/shared/links/link_text.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/links/artist_link.dart'; +import 'package:spotube/components/links/link_text.dart'; import 'package:spotube/extensions/artist_simple.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/image.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/pages/track/track.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/utils/service_utils.dart'; class PlayerTrackDetails extends HookConsumerWidget { @@ -21,7 +22,7 @@ class PlayerTrackDetails extends HookConsumerWidget { Widget build(BuildContext context, ref) { final theme = Theme.of(context); final mediaQuery = MediaQuery.of(context); - final playback = ref.watch(proxyPlaylistProvider); + final playback = ref.watch(audioPlayerProvider); return Row( children: [ @@ -81,6 +82,13 @@ class PlayerTrackDetails extends HookConsumerWidget { onRouteChange: (route) { ServiceUtils.push(context, route); }, + onOverflowArtistClick: () => ServiceUtils.pushNamed( + context, + TrackPage.name, + pathParameters: { + "id": track!.id!, + }, + ), ) ], ), diff --git a/lib/components/player/sibling_tracks_sheet.dart b/lib/modules/player/sibling_tracks_sheet.dart similarity index 93% rename from lib/components/player/sibling_tracks_sheet.dart rename to lib/modules/player/sibling_tracks_sheet.dart index 99b7b430f..b58a58946 100644 --- a/lib/components/player/sibling_tracks_sheet.dart +++ b/lib/modules/player/sibling_tracks_sheet.dart @@ -7,17 +7,19 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart'; import 'package:spotube/extensions/artist_simple.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/duration.dart'; import 'package:spotube/hooks/utils/use_debounce.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/provider/audio_player/querying_track_info.dart'; import 'package:spotube/provider/server/active_sourced_track.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; + import 'package:spotube/services/sourced_track/models/source_info.dart'; import 'package:spotube/services/sourced_track/models/video_info.dart'; import 'package:spotube/services/sourced_track/sourced_track.dart'; @@ -52,7 +54,8 @@ class SiblingTracksSheet extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { final theme = Theme.of(context); - final playlist = ref.watch(proxyPlaylistProvider); + final playlist = ref.watch(audioPlayerProvider); + final isFetchingActiveTrack = ref.watch(queryingTrackInfoProvider); final preferences = ref.watch(userPreferencesProvider); final isSearching = useState(false); @@ -128,13 +131,13 @@ class SiblingTracksSheet extends HookConsumerWidget { ]); final siblings = useMemoized( - () => playlist.isFetching == false + () => !isFetchingActiveTrack ? [ (activeTrack as SourcedTrack).sourceInfo, ...activeTrack.siblings, ] : [], - [playlist.isFetching, activeTrack], + [activeTrack, isFetchingActiveTrack], ); final borderRadius = floating @@ -174,12 +177,12 @@ class SiblingTracksSheet extends HookConsumerWidget { Text(" • ${sourceInfo.artist}"), ], ), - enabled: playlist.isFetching != true, - selected: playlist.isFetching != true && + enabled: !isFetchingActiveTrack, + selected: !isFetchingActiveTrack && sourceInfo.id == (activeTrack as SourcedTrack).sourceInfo.id, selectedTileColor: theme.popupMenuTheme.color, onTap: () { - if (playlist.isFetching == false && + if (!isFetchingActiveTrack && sourceInfo.id != (activeTrack as SourcedTrack).sourceInfo.id) { activeTrackNotifier.swapSibling(sourceInfo); Navigator.of(context).pop(); @@ -187,7 +190,7 @@ class SiblingTracksSheet extends HookConsumerWidget { }, ); }, - [playlist.isFetching, activeTrack, siblings], + [activeTrack, siblings], ); final mediaQuery = MediaQuery.of(context); @@ -208,7 +211,8 @@ class SiblingTracksSheet extends HookConsumerWidget { : mediaQuery.size.height * .6, decoration: BoxDecoration( borderRadius: borderRadius, - color: theme.colorScheme.surfaceVariant.withOpacity(.5), + color: + theme.colorScheme.surfaceContainerHighest.withOpacity(.5), ), child: Scaffold( backgroundColor: Colors.transparent, diff --git a/lib/components/player/use_progress.dart b/lib/modules/player/use_progress.dart similarity index 76% rename from lib/components/player/use_progress.dart rename to lib/modules/player/use_progress.dart index 15a979af7..eaea638e2 100644 --- a/lib/components/player/use_progress.dart +++ b/lib/modules/player/use_progress.dart @@ -1,4 +1,3 @@ -import 'package:async/async.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; @@ -19,26 +18,13 @@ import 'package:spotube/services/audio_player/audio_player.dart'; final sliderValue = position.value.inSeconds; useEffect(() { - final durationOperation = - CancelableOperation.fromFuture(audioPlayer.duration); - durationOperation.then((value) { - if (value != null) { - duration.value = value; - } - }); + duration.value = audioPlayer.duration; final durationSubscription = audioPlayer.durationStream.listen((event) { duration.value = event; }); - final positionOperation = - CancelableOperation.fromFuture(audioPlayer.position); - - positionOperation.then((value) { - if (value != null) { - position.value = value; - } - }); + position.value = audioPlayer.position; var lastPosition = position.value; @@ -54,9 +40,7 @@ import 'package:spotube/services/audio_player/audio_player.dart'; }); return () { - positionOperation.cancel(); positionSubscription.cancel(); - durationOperation.cancel(); durationSubscription.cancel(); }; }, []); diff --git a/lib/components/player/volume_slider.dart b/lib/modules/player/volume_slider.dart similarity index 84% rename from lib/components/player/volume_slider.dart rename to lib/modules/player/volume_slider.dart index 102bbef6e..8483143b2 100644 --- a/lib/components/player/volume_slider.dart +++ b/lib/modules/player/volume_slider.dart @@ -1,6 +1,5 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; - import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; @@ -31,11 +30,17 @@ class VolumeSlider extends HookConsumerWidget { } } }, - child: Slider( - min: 0, - max: 1, - value: value, - onChanged: onChanged, + child: SliderTheme( + data: const SliderThemeData( + showValueIndicator: ShowValueIndicator.always, + ), + child: Slider( + min: 0, + max: 1, + label: (value * 100).toStringAsFixed(0), + value: value, + onChanged: onChanged, + ), ), ); return Row( diff --git a/lib/components/playlist/playlist_card.dart b/lib/modules/playlist/playlist_card.dart similarity index 57% rename from lib/components/playlist/playlist_card.dart rename to lib/modules/playlist/playlist_card.dart index ae6f20e5f..df683a801 100644 --- a/lib/components/playlist/playlist_card.dart +++ b/lib/modules/playlist/playlist_card.dart @@ -2,12 +2,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/dialogs/select_device_dialog.dart'; -import 'package:spotube/components/shared/playbutton_card.dart'; +import 'package:spotube/components/dialogs/select_device_dialog.dart'; +import 'package:spotube/components/playbutton_card.dart'; +import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/models/connect/connect.dart'; +import 'package:spotube/pages/playlist/playlist.dart'; +import 'package:spotube/provider/audio_player/querying_track_info.dart'; import 'package:spotube/provider/connect/connect.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/history/history.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; import 'package:spotube/utils/service_utils.dart'; @@ -20,8 +24,11 @@ class PlaylistCard extends HookConsumerWidget { }); @override Widget build(BuildContext context, ref) { - final playlistQueue = ref.watch(proxyPlaylistProvider); - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); + final playlistQueue = ref.watch(audioPlayerProvider); + final playlistNotifier = ref.watch(audioPlayerProvider.notifier); + final isFetchingActiveTrack = ref.watch(queryingTrackInfoProvider); + final historyNotifier = ref.read(playbackHistoryActionsProvider); + final playing = useStream(audioPlayer.playingStream).data ?? audioPlayer.isPlaying; bool isPlaylistPlaying = useMemoized( @@ -32,12 +39,23 @@ class PlaylistCard extends HookConsumerWidget { final updating = useState(false); final me = ref.watch(meProvider); - Future> fetchAllTracks() async { + Future> fetchInitialTracks() async { if (playlist.id == 'user-liked-tracks') { return await ref.read(likedTracksProvider.future); } - await ref.read(playlistTracksProvider(playlist.id!).future); + final result = + await ref.read(playlistTracksProvider(playlist.id!).future); + + return result.items; + } + + Future> fetchAllTracks() async { + final initialTracks = await fetchInitialTracks(); + + if (playlist.id == 'user-liked-tracks') { + return initialTracks; + } return ref.read(playlistTracksProvider(playlist.id!).notifier).fetchAll(); } @@ -50,14 +68,16 @@ class PlaylistCard extends HookConsumerWidget { placeholder: ImagePlaceholder.collection, ), isPlaying: isPlaylistPlaying, - isLoading: - (isPlaylistPlaying && playlistQueue.isFetching) || updating.value, + isLoading: (isPlaylistPlaying && isFetchingActiveTrack) || updating.value, isOwner: playlist.owner?.id == me.asData?.value.id && me.asData?.value.id != null, onTap: () { - ServiceUtils.push( + ServiceUtils.pushNamed( context, - "/playlist/${playlist.id}", + PlaylistPage.name, + pathParameters: { + "id": playlist.id!, + }, extra: playlist, ); }, @@ -70,22 +90,29 @@ class PlaylistCard extends HookConsumerWidget { return audioPlayer.resume(); } - List fetchedTracks = await fetchAllTracks(); + final fetchedInitialTracks = await fetchInitialTracks(); - if (fetchedTracks.isEmpty || !context.mounted) return; + if (fetchedInitialTracks.isEmpty || !context.mounted) return; final isRemoteDevice = await showSelectDeviceDialog(context, ref); if (isRemoteDevice) { final remotePlayback = ref.read(connectProvider.notifier); + final allTracks = await fetchAllTracks(); await remotePlayback.load( - WebSocketLoadEventData( - tracks: fetchedTracks, - collectionId: playlist.id!, + WebSocketLoadEventData.playlist( + tracks: allTracks, + collection: playlist, ), ); } else { - await playlistNotifier.load(fetchedTracks, autoPlay: true); + await playlistNotifier.load(fetchedInitialTracks, autoPlay: true); playlistNotifier.addCollection(playlist.id!); + historyNotifier.addPlaylists([playlist]); + + final allTracks = await fetchAllTracks(); + + await playlistNotifier + .addTracks(allTracks.sublist(fetchedInitialTracks.length)); } } finally { if (context.mounted) { @@ -98,20 +125,22 @@ class PlaylistCard extends HookConsumerWidget { try { if (isPlaylistPlaying) return; - final fetchedTracks = await fetchAllTracks(); + final fetchedInitialTracks = await fetchAllTracks(); - if (fetchedTracks.isEmpty) return; + if (fetchedInitialTracks.isEmpty) return; - playlistNotifier.addTracks(fetchedTracks); + playlistNotifier.addTracks(fetchedInitialTracks); playlistNotifier.addCollection(playlist.id!); + historyNotifier.addPlaylists([playlist]); if (context.mounted) { final snackbar = SnackBar( - content: Text("Added ${fetchedTracks.length} tracks to queue"), + content: Text(context.l10n + .added_num_tracks_to_queue(fetchedInitialTracks.length)), action: SnackBarAction( label: "Undo", onPressed: () { playlistNotifier - .removeTracks(fetchedTracks.map((e) => e.id!)); + .removeTracks(fetchedInitialTracks.map((e) => e.id!)); }, ), ); diff --git a/lib/components/playlist/playlist_create_dialog.dart b/lib/modules/playlist/playlist_create_dialog.dart similarity index 97% rename from lib/components/playlist/playlist_create_dialog.dart rename to lib/modules/playlist/playlist_create_dialog.dart index bac98b64f..78680a1c5 100644 --- a/lib/components/playlist/playlist_create_dialog.dart +++ b/lib/modules/playlist/playlist_create_dialog.dart @@ -11,10 +11,11 @@ import 'package:image_picker/image_picker.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; +import 'package:spotube/extensions/string.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:spotube/provider/spotify_provider.dart'; @@ -54,7 +55,7 @@ class PlaylistCreateDialog extends HookConsumerWidget { text: updatingPlaylist?.name, ); final description = useTextEditingController( - text: updatingPlaylist?.description, + text: updatingPlaylist?.description?.unescapeHtml(), ); final public = useState( updatingPlaylist?.public ?? false, @@ -75,7 +76,7 @@ class PlaylistCreateDialog extends HookConsumerWidget { scaffold.showSnackBar( SnackBar( content: Text( - l10n.error(error.message ?? "Epic failure!"), + l10n.error(error.message ?? context.l10n.epic_failure), style: theme.textTheme.bodyMedium!.copyWith( color: theme.colorScheme.onError, ), diff --git a/lib/components/root/bottom_player.dart b/lib/modules/root/bottom_player.dart similarity index 75% rename from lib/components/root/bottom_player.dart rename to lib/modules/root/bottom_player.dart index 06250131e..7f37c4720 100644 --- a/lib/components/root/bottom_player.dart +++ b/lib/modules/root/bottom_player.dart @@ -1,38 +1,37 @@ import 'dart:ui'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/player/player_actions.dart'; -import 'package:spotube/components/player/player_overlay.dart'; -import 'package:spotube/components/player/player_track_details.dart'; -import 'package:spotube/components/player/player_controls.dart'; -import 'package:spotube/components/player/volume_slider.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/modules/player/player_actions.dart'; +import 'package:spotube/modules/player/player_overlay.dart'; +import 'package:spotube/modules/player/player_track_details.dart'; +import 'package:spotube/modules/player/player_controls.dart'; +import 'package:spotube/modules/player/volume_slider.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/hooks/utils/use_brightness_value.dart'; -import 'package:spotube/models/logger.dart'; import 'package:flutter/material.dart'; -import 'package:spotube/provider/authentication_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; + import 'package:spotube/provider/volume_provider.dart'; import 'package:spotube/utils/platform.dart'; +import 'package:window_manager/window_manager.dart'; class BottomPlayer extends HookConsumerWidget { - BottomPlayer({super.key}); + const BottomPlayer({super.key}); - final logger = getLogger(BottomPlayer); @override Widget build(BuildContext context, ref) { final auth = ref.watch(authenticationProvider); - final playlist = ref.watch(proxyPlaylistProvider); + final playlist = ref.watch(audioPlayerProvider); final layoutMode = ref.watch(userPreferencesProvider.select((s) => s.layoutMode)); @@ -49,7 +48,7 @@ class BottomPlayer extends HookConsumerWidget { ); final theme = Theme.of(context); - final bg = theme.colorScheme.surfaceVariant; + final bg = theme.colorScheme.surfaceContainerHighest; final bgColor = useBrightnessValue( Color.lerp(bg, Colors.white, 0.7), @@ -78,10 +77,10 @@ class BottomPlayer extends HookConsumerWidget { child: PlayerTrackDetails(track: playlist.activeTrack), ), // controls - Flexible( + const Flexible( flex: 3, child: Padding( - padding: const EdgeInsets.only(top: 5), + padding: EdgeInsets.only(top: 5), child: PlayerControls(), ), ), @@ -90,24 +89,24 @@ class BottomPlayer extends HookConsumerWidget { children: [ PlayerActions( extraActions: [ - if (auth != null) + if (auth.asData?.value != null) IconButton( tooltip: context.l10n.mini_player, icon: const Icon(SpotubeIcons.miniPlayer), onPressed: () async { - final prevSize = - await DesktopTools.window.getSize(); - await DesktopTools.window.setMinimumSize( + if (!kIsDesktop) return; + + final prevSize = await windowManager.getSize(); + await windowManager.setMinimumSize( const Size(300, 300), ); - await DesktopTools.window.setAlwaysOnTop(true); + await windowManager.setAlwaysOnTop(true); if (!kIsLinux) { - await DesktopTools.window.setHasShadow(false); + await windowManager.setHasShadow(false); } - await DesktopTools.window + await windowManager .setAlignment(Alignment.topRight); - await DesktopTools.window - .setSize(const Size(400, 500)); + await windowManager.setSize(const Size(400, 500)); await Future.delayed( const Duration(milliseconds: 100), () async { diff --git a/lib/components/root/sidebar.dart b/lib/modules/root/sidebar.dart similarity index 76% rename from lib/components/root/sidebar.dart rename to lib/modules/root/sidebar.dart index a100ca8e9..f29644fba 100644 --- a/lib/components/root/sidebar.dart +++ b/lib/modules/root/sidebar.dart @@ -9,30 +9,30 @@ import 'package:sidebarx/sidebarx.dart'; import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/side_bar_tiles.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/connect/connect_device.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/modules/connect/connect_device.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/hooks/utils/use_brightness_value.dart'; import 'package:spotube/hooks/controllers/use_sidebarx_controller.dart'; +import 'package:spotube/pages/profile/profile.dart'; +import 'package:spotube/pages/settings/settings.dart'; import 'package:spotube/provider/download_manager_provider.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; + import 'package:spotube/utils/platform.dart'; import 'package:spotube/utils/service_utils.dart'; +import 'package:window_manager/window_manager.dart'; class Sidebar extends HookConsumerWidget { - final int? selectedIndex; - final void Function(int) onSelectedIndexChanged; final Widget child; const Sidebar({ - required this.selectedIndex, - required this.onSelectedIndexChanged, required this.child, super.key, }); @@ -47,12 +47,9 @@ class Sidebar extends HookConsumerWidget { ); } - static void goToSettings(BuildContext context) { - GoRouter.of(context).go("/settings"); - } - @override Widget build(BuildContext context, WidgetRef ref) { + final routerState = GoRouterState.of(context); final mediaQuery = MediaQuery.of(context); final downloadCount = ref.watch(downloadManagerProvider).$downloadCount; @@ -60,42 +57,28 @@ class Sidebar extends HookConsumerWidget { final layoutMode = ref.watch(userPreferencesProvider.select((s) => s.layoutMode)); + final sidebarTileList = useMemoized( + () => getSidebarTileList(context.l10n), + [context.l10n], + ); + + final selectedIndex = sidebarTileList.indexWhere( + (e) => routerState.namedLocation(e.name) == routerState.matchedLocation, + ); + final controller = useSidebarXController( - selectedIndex: selectedIndex ?? 0, + selectedIndex: selectedIndex, extended: mediaQuery.lgAndUp, ); final theme = Theme.of(context); - final bg = theme.colorScheme.surfaceVariant; + final bg = theme.colorScheme.surfaceContainerHighest; final bgColor = useBrightnessValue( - Color.lerp(bg, Colors.white, 0.7), + Color.lerp(bg, Colors.white, 0.6), Color.lerp(bg, Colors.black, 0.45)!, ); - final sidebarTileList = useMemoized( - () => getSidebarTileList(context.l10n), - [context.l10n], - ); - - useEffect(() { - if (controller.selectedIndex != selectedIndex && selectedIndex != null) { - controller.selectIndex(selectedIndex!); - } - return null; - }, [selectedIndex]); - - useEffect(() { - void listener() { - onSelectedIndexChanged(controller.selectedIndex); - } - - controller.addListener(listener); - return () { - controller.removeListener(listener); - }; - }, [controller]); - useEffect(() { if (!context.mounted) return; if (mediaQuery.lgAndUp && !controller.extended) { @@ -106,6 +89,13 @@ class Sidebar extends HookConsumerWidget { return null; }, [mediaQuery, controller]); + useEffect(() { + if (controller.selectedIndex != selectedIndex) { + controller.selectIndex(selectedIndex); + } + return null; + }, [selectedIndex]); + if (layoutMode == LayoutMode.compact || (mediaQuery.smAndDown && layoutMode == LayoutMode.adaptive)) { return Scaffold(body: child); @@ -119,23 +109,28 @@ class Sidebar extends HookConsumerWidget { items: sidebarTileList.mapIndexed( (index, e) { return SidebarXItem( - iconWidget: Badge( - backgroundColor: theme.colorScheme.primary, - isLabelVisible: e.title == "Library" && downloadCount > 0, - label: Text( - downloadCount.toString(), - style: const TextStyle( - color: Colors.white, - fontSize: 10, + onTap: () { + context.goNamed(e.name); + }, + iconBuilder: (selected, hovered) { + return Badge( + backgroundColor: theme.colorScheme.primary, + isLabelVisible: e.title == "Library" && downloadCount > 0, + label: Text( + downloadCount.toString(), + style: const TextStyle( + color: Colors.white, + fontSize: 10, + ), ), - ), - child: Icon( - e.icon, - color: selectedIndex == index - ? theme.colorScheme.primary - : null, - ), - ), + child: Icon( + e.icon, + color: selected || hovered + ? theme.colorScheme.primary + : null, + ), + ); + }, label: e.title, ); }, @@ -214,22 +209,24 @@ class SidebarHeader extends HookWidget { ); } - return Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - if (kIsMacOS) const SizedBox(height: 25), - Row( - children: [ - Sidebar.brandLogo(), - const SizedBox(width: 10), - Text( - "Spotube", - style: theme.textTheme.titleLarge, - ), - ], - ), - ], + return DragToMoveArea( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + children: [ + if (kIsMacOS) const SizedBox(height: 25), + Row( + children: [ + Sidebar.brandLogo(), + const SizedBox(width: 10), + Text( + "Spotube", + style: theme.textTheme.titleLarge, + ), + ], + ), + ], + ), ), ); } @@ -257,7 +254,7 @@ class SidebarFooter extends HookConsumerWidget { if (mediaQuery.mdAndDown) { return IconButton( icon: const Icon(SpotubeIcons.settings), - onPressed: () => Sidebar.goToSettings(context), + onPressed: () => ServiceUtils.navigateNamed(context, SettingsPage.name), ); } @@ -272,13 +269,13 @@ class SidebarFooter extends HookConsumerWidget { mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - if (auth != null && data == null) + if (auth.asData?.value != null && data == null) const CircularProgressIndicator() else if (data != null) Flexible( child: InkWell( onTap: () { - ServiceUtils.push(context, "/profile"); + ServiceUtils.pushNamed(context, ProfilePage.name); }, borderRadius: BorderRadius.circular(30), child: Row( @@ -310,7 +307,7 @@ class SidebarFooter extends HookConsumerWidget { IconButton( icon: const Icon(SpotubeIcons.settings), onPressed: () { - Sidebar.goToSettings(context); + ServiceUtils.pushNamed(context, SettingsPage.name); }, ), ], diff --git a/lib/components/root/spotube_navigation_bar.dart b/lib/modules/root/spotube_navigation_bar.dart similarity index 75% rename from lib/components/root/spotube_navigation_bar.dart rename to lib/modules/root/spotube_navigation_bar.dart index 489399e5d..978891b8a 100644 --- a/lib/components/root/spotube_navigation_bar.dart +++ b/lib/modules/root/spotube_navigation_bar.dart @@ -3,55 +3,55 @@ import 'dart:ui'; import 'package:curved_navigation_bar/curved_navigation_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/side_bar_tiles.dart'; -import 'package:spotube/components/root/sidebar.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/hooks/utils/use_brightness_value.dart'; +import 'package:spotube/models/database/database.dart'; import 'package:spotube/provider/download_manager_provider.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; + +import 'package:spotube/utils/service_utils.dart'; final navigationPanelHeight = StateProvider((ref) => 50); class SpotubeNavigationBar extends HookConsumerWidget { - final int? selectedIndex; - final void Function(int) onSelectedIndexChanged; - const SpotubeNavigationBar({ - required this.selectedIndex, - required this.onSelectedIndexChanged, super.key, }); @override Widget build(BuildContext context, ref) { final theme = Theme.of(context); + final routerState = GoRouterState.of(context); + final downloadCount = ref.watch(downloadManagerProvider).$downloadCount; final mediaQuery = MediaQuery.of(context); final layoutMode = ref.watch(userPreferencesProvider.select((s) => s.layoutMode)); - final insideSelectedIndex = useState(selectedIndex ?? 0); - final buttonColor = useBrightnessValue( theme.colorScheme.inversePrimary, theme.colorScheme.primary.withOpacity(0.2), ); - final navbarTileList = - useMemoized(() => getNavbarTileList(context.l10n), [context.l10n]); + final navbarTileList = useMemoized( + () => getNavbarTileList(context.l10n), + [context.l10n], + ); final panelHeight = ref.watch(navigationPanelHeight); - useEffect(() { - if (selectedIndex != null) { - insideSelectedIndex.value = selectedIndex!; - } - return null; - }, [selectedIndex]); + final selectedIndex = useMemoized(() { + final index = navbarTileList.indexWhere( + (e) => routerState.namedLocation(e.name) == routerState.matchedLocation, + ); + + return index == -1 ? 0 : index; + }, [navbarTileList, routerState.matchedLocation]); if (layoutMode == LayoutMode.extended || (mediaQuery.mdAndUp && layoutMode == LayoutMode.adaptive) || @@ -69,7 +69,7 @@ class SpotubeNavigationBar extends HookConsumerWidget { backgroundColor: theme.colorScheme.secondaryContainer.withOpacity(0.72), buttonBackgroundColor: buttonColor, - color: theme.colorScheme.background, + color: theme.colorScheme.surface, height: panelHeight, animationDuration: const Duration(milliseconds: 350), items: navbarTileList.map( @@ -91,14 +91,9 @@ class SpotubeNavigationBar extends HookConsumerWidget { }); }, ).toList(), - index: insideSelectedIndex.value, + index: selectedIndex, onTap: (i) { - insideSelectedIndex.value = i; - if (navbarTileList[i].id == "settings") { - Sidebar.goToSettings(context); - return; - } - onSelectedIndexChanged(i); + ServiceUtils.navigateNamed(context, navbarTileList[i].name); }, ), ), diff --git a/lib/modules/root/update_dialog.dart b/lib/modules/root/update_dialog.dart new file mode 100644 index 000000000..27b857df4 --- /dev/null +++ b/lib/modules/root/update_dialog.dart @@ -0,0 +1,57 @@ +import 'package:flutter/material.dart'; +import 'package:spotube/components/links/anchor_button.dart'; +import 'package:url_launcher/url_launcher_string.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:version/version.dart'; + +class RootAppUpdateDialog extends StatelessWidget { + final Version? version; + final int? nightlyBuildNum; + + const RootAppUpdateDialog({super.key, this.version}) : nightlyBuildNum = null; + const RootAppUpdateDialog.nightly({super.key, required this.nightlyBuildNum}) + : version = null; + + @override + Widget build(BuildContext context) { + const url = "https://spotube.krtirtho.dev/downloads"; + const nightlyUrl = "https://spotube.krtirtho.dev/downloads/nightly"; + return AlertDialog( + title: Text(context.l10n.spotube_has_an_update), + actions: [ + FilledButton( + child: Text(context.l10n.download_now), + onPressed: () => launchUrlString( + nightlyBuildNum != null ? nightlyUrl : url, + mode: LaunchMode.externalApplication, + ), + ), + ], + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + nightlyBuildNum != null + ? context.l10n.nightly_version(nightlyBuildNum!) + : context.l10n.release_version(version!), + ), + if (nightlyBuildNum == null) + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text(context.l10n.read_the_latest), + AnchorButton( + context.l10n.release_notes, + style: const TextStyle(color: Colors.blue), + onTap: () => launchUrlString( + url, + mode: LaunchMode.externalApplication, + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/components/settings/color_scheme_picker_dialog.dart b/lib/modules/settings/color_scheme_picker_dialog.dart similarity index 95% rename from lib/components/settings/color_scheme_picker_dialog.dart rename to lib/modules/settings/color_scheme_picker_dialog.dart index 8d0983752..f29335055 100644 --- a/lib/components/settings/color_scheme_picker_dialog.dart +++ b/lib/modules/settings/color_scheme_picker_dialog.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; import 'package:system_theme/system_theme.dart'; @@ -69,17 +70,17 @@ class ColorSchemePickerDialog extends HookConsumerWidget { } return AlertDialog( - title: const Text("Pick color scheme"), + title: Text(context.l10n.pick_color_scheme), actions: [ OutlinedButton( - child: const Text("Cancel"), + child: Text(context.l10n.cancel), onPressed: () { Navigator.pop(context); }, ), FilledButton( onPressed: onOk, - child: const Text("Save"), + child: Text(context.l10n.save), ), ], content: SizedBox( @@ -179,9 +180,9 @@ class ColorTile extends StatelessWidget { colorScheme.primaryContainer, colorScheme.secondary, colorScheme.secondaryContainer, - colorScheme.background, colorScheme.surface, - colorScheme.surfaceVariant, + colorScheme.surface, + colorScheme.surfaceContainerHighest, colorScheme.onPrimary, colorScheme.onSurface, ]; diff --git a/lib/components/settings/section_card_with_heading.dart b/lib/modules/settings/section_card_with_heading.dart similarity index 100% rename from lib/components/settings/section_card_with_heading.dart rename to lib/modules/settings/section_card_with_heading.dart diff --git a/lib/modules/stats/common/album_item.dart b/lib/modules/stats/common/album_item.dart new file mode 100644 index 000000000..eec687176 --- /dev/null +++ b/lib/modules/stats/common/album_item.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/modules/album/album_card.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/links/artist_link.dart'; +import 'package:spotube/extensions/image.dart'; +import 'package:spotube/pages/album/album.dart'; +import 'package:spotube/utils/service_utils.dart'; + +class StatsAlbumItem extends StatelessWidget { + final AlbumSimple album; + final Widget info; + const StatsAlbumItem({super.key, required this.album, required this.info}); + + @override + Widget build(BuildContext context) { + return ListTile( + horizontalTitleGap: 8, + leading: ClipRRect( + borderRadius: BorderRadius.circular(4), + child: UniversalImage( + path: (album.images).asUrlString( + placeholder: ImagePlaceholder.albumArt, + ), + width: 40, + height: 40, + ), + ), + title: Text(album.name!), + subtitle: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text("${album.albumType?.formatted} • "), + Flexible( + child: ArtistLink( + artists: album.artists ?? [], + mainAxisAlignment: WrapAlignment.start, + onOverflowArtistClick: () => ServiceUtils.pushNamed( + context, + AlbumPage.name, + pathParameters: { + "id": album.id!, + }, + ), + ), + ), + ], + ), + trailing: info, + onTap: () { + ServiceUtils.pushNamed( + context, + AlbumPage.name, + pathParameters: {"id": album.id!}, + extra: album, + ); + }, + ); + } +} diff --git a/lib/modules/stats/common/artist_item.dart b/lib/modules/stats/common/artist_item.dart new file mode 100644 index 000000000..7e7281da4 --- /dev/null +++ b/lib/modules/stats/common/artist_item.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/extensions/image.dart'; +import 'package:spotube/pages/artist/artist.dart'; +import 'package:spotube/utils/service_utils.dart'; + +class StatsArtistItem extends StatelessWidget { + final Artist artist; + final Widget info; + const StatsArtistItem({ + super.key, + required this.artist, + required this.info, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + title: Text(artist.name!), + horizontalTitleGap: 8, + leading: CircleAvatar( + backgroundImage: UniversalImage.imageProvider( + (artist.images).asUrlString( + placeholder: ImagePlaceholder.artist, + ), + ), + ), + trailing: info, + onTap: () { + ServiceUtils.pushNamed( + context, + ArtistPage.name, + pathParameters: {"id": artist.id!}, + ); + }, + ); + } +} diff --git a/lib/modules/stats/common/playlist_item.dart b/lib/modules/stats/common/playlist_item.dart new file mode 100644 index 000000000..515c97b37 --- /dev/null +++ b/lib/modules/stats/common/playlist_item.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/extensions/image.dart'; +import 'package:spotube/extensions/string.dart'; +import 'package:spotube/pages/playlist/playlist.dart'; +import 'package:spotube/utils/service_utils.dart'; + +class StatsPlaylistItem extends StatelessWidget { + final PlaylistSimple playlist; + final Widget info; + const StatsPlaylistItem( + {super.key, required this.playlist, required this.info}); + + @override + Widget build(BuildContext context) { + return ListTile( + horizontalTitleGap: 8, + leading: ClipRRect( + borderRadius: BorderRadius.circular(4), + child: UniversalImage( + path: (playlist.images).asUrlString( + placeholder: ImagePlaceholder.collection, + ), + width: 40, + height: 40, + ), + ), + title: Text(playlist.name!), + subtitle: Text( + playlist.description?.unescapeHtml() ?? '', + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + trailing: info, + onTap: () { + ServiceUtils.pushNamed( + context, + PlaylistPage.name, + pathParameters: {"id": playlist.id!}, + extra: playlist, + ); + }, + ); + } +} diff --git a/lib/modules/stats/common/track_item.dart b/lib/modules/stats/common/track_item.dart new file mode 100644 index 000000000..44e813405 --- /dev/null +++ b/lib/modules/stats/common/track_item.dart @@ -0,0 +1,56 @@ +import 'package:flutter/material.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/links/artist_link.dart'; +import 'package:spotube/extensions/image.dart'; +import 'package:spotube/pages/track/track.dart'; +import 'package:spotube/utils/service_utils.dart'; + +class StatsTrackItem extends StatelessWidget { + final Track track; + final Widget info; + const StatsTrackItem({ + super.key, + required this.track, + required this.info, + }); + + @override + Widget build(BuildContext context) { + return ListTile( + horizontalTitleGap: 8, + leading: ClipRRect( + borderRadius: BorderRadius.circular(4), + child: UniversalImage( + path: (track.album?.images).asUrlString( + placeholder: ImagePlaceholder.albumArt, + ), + width: 40, + height: 40, + ), + ), + title: Text(track.name!), + subtitle: ArtistLink( + artists: track.artists!, + mainAxisAlignment: WrapAlignment.start, + onOverflowArtistClick: () => ServiceUtils.pushNamed( + context, + TrackPage.name, + pathParameters: { + "id": track.id!, + }, + ), + ), + trailing: info, + onTap: () { + ServiceUtils.pushNamed( + context, + TrackPage.name, + pathParameters: { + "id": track.id!, + }, + ); + }, + ); + } +} diff --git a/lib/modules/stats/summary/summary.dart b/lib/modules/stats/summary/summary.dart new file mode 100644 index 000000000..46068fece --- /dev/null +++ b/lib/modules/stats/summary/summary.dart @@ -0,0 +1,107 @@ +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotube/collections/fake.dart'; +import 'package:spotube/collections/formatters.dart'; +import 'package:spotube/modules/stats/summary/summary_card.dart'; +import 'package:spotube/extensions/constrains.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/pages/stats/albums/albums.dart'; +import 'package:spotube/pages/stats/artists/artists.dart'; +import 'package:spotube/pages/stats/fees/fees.dart'; +import 'package:spotube/pages/stats/minutes/minutes.dart'; +import 'package:spotube/pages/stats/playlists/playlists.dart'; +import 'package:spotube/pages/stats/streams/streams.dart'; +import 'package:spotube/provider/history/summary.dart'; +import 'package:spotube/utils/service_utils.dart'; + +class StatsPageSummarySection extends HookConsumerWidget { + const StatsPageSummarySection({super.key}); + + @override + Widget build(BuildContext context, ref) { + final summary = ref.watch(playbackHistorySummaryProvider); + final summaryData = summary.asData?.value ?? FakeData.historySummary; + + return Skeletonizer.sliver( + enabled: summary.isLoading, + child: SliverPadding( + padding: const EdgeInsets.all(10), + sliver: SliverLayoutBuilder(builder: (context, constrains) { + return SliverGrid( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: constrains.isXs + ? 2 + : constrains.smAndDown + ? 3 + : constrains.mdAndDown + ? 4 + : constrains.lgAndDown + ? 5 + : 6, + mainAxisSpacing: 10, + crossAxisSpacing: 10, + childAspectRatio: constrains.isXs ? 1.3 : 1.5, + ), + delegate: SliverChildListDelegate([ + SummaryCard( + title: summaryData.duration.inMinutes.toDouble(), + unit: context.l10n.summary_minutes, + description: context.l10n.summary_listened_to_music, + color: Colors.purple, + onTap: () { + ServiceUtils.pushNamed(context, StatsMinutesPage.name); + }, + ), + SummaryCard( + title: summaryData.tracks.toDouble(), + unit: context.l10n.summary_songs, + description: context.l10n.summary_streamed_overall, + color: Colors.lightBlue, + onTap: () { + ServiceUtils.pushNamed(context, StatsStreamsPage.name); + }, + ), + SummaryCard.unformatted( + title: usdFormatter.format(summaryData.fees.toDouble()), + unit: "", + description: context.l10n.summary_owed_to_artists, + color: Colors.green, + onTap: () { + ServiceUtils.pushNamed(context, StatsStreamFeesPage.name); + }, + ), + SummaryCard( + title: summaryData.artists.toDouble(), + unit: context.l10n.summary_artists, + description: context.l10n.summary_music_reached_you, + color: Colors.yellow, + onTap: () { + ServiceUtils.pushNamed(context, StatsArtistsPage.name); + }, + ), + SummaryCard( + title: summaryData.albums.toDouble(), + unit: context.l10n.summary_full_albums, + description: context.l10n.summary_got_your_love, + color: Colors.pink, + onTap: () { + ServiceUtils.pushNamed(context, StatsAlbumsPage.name); + }, + ), + SummaryCard( + title: summaryData.playlists.toDouble(), + unit: context.l10n.summary_playlists, + description: context.l10n.summary_were_on_repeat, + color: Colors.teal, + onTap: () { + ServiceUtils.pushNamed(context, StatsPlaylistsPage.name); + }, + ), + ]), + ); + }), + ), + ); + } +} diff --git a/lib/modules/stats/summary/summary_card.dart b/lib/modules/stats/summary/summary_card.dart new file mode 100644 index 000000000..243c50e87 --- /dev/null +++ b/lib/modules/stats/summary/summary_card.dart @@ -0,0 +1,86 @@ +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:spotube/collections/formatters.dart'; + +class SummaryCard extends StatelessWidget { + final String title; + final String unit; + final String description; + final VoidCallback? onTap; + + final MaterialColor color; + + SummaryCard({ + super.key, + required double title, + required this.unit, + required this.description, + required this.color, + this.onTap, + }) : title = compactNumberFormatter.format(title); + + const SummaryCard.unformatted({ + super.key, + required this.title, + required this.unit, + required this.description, + required this.color, + this.onTap, + }); + + @override + Widget build(BuildContext context) { + final ThemeData(:textTheme, :brightness) = Theme.of(context); + + final descriptionNewLines = description.split("").where((s) => s == "\n"); + + return Card( + color: brightness == Brightness.dark ? color.shade100 : color.shade50, + child: InkWell( + borderRadius: BorderRadius.circular(16), + onTap: onTap, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 15), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AutoSizeText.rich( + TextSpan( + children: [ + TextSpan( + text: title, + style: textTheme.headlineLarge?.copyWith( + color: color.shade900, + ), + ), + TextSpan( + text: " $unit", + style: textTheme.titleMedium?.copyWith( + color: color.shade900, + ), + ), + ], + ), + maxLines: 1, + ), + const Gap(5), + AutoSizeText( + description, + maxLines: description.contains("\n") + ? descriptionNewLines.length + 1 + : 1, + minFontSize: 9, + style: textTheme.labelMedium!.copyWith( + color: color.shade900, + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/modules/stats/top/albums.dart b/lib/modules/stats/top/albums.dart new file mode 100644 index 000000000..e401340e6 --- /dev/null +++ b/lib/modules/stats/top/albums.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotube/collections/formatters.dart'; +import 'package:spotube/modules/stats/common/album_item.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/history/top/albums.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; +import 'package:very_good_infinite_list/very_good_infinite_list.dart'; + +class TopAlbums extends HookConsumerWidget { + const TopAlbums({super.key}); + + @override + Widget build(BuildContext context, ref) { + final historyDuration = ref.watch(playbackHistoryTopDurationProvider); + final topAlbums = ref.watch(historyTopAlbumsProvider(historyDuration)); + final topAlbumsNotifier = + ref.watch(historyTopAlbumsProvider(historyDuration).notifier); + + final albumsData = topAlbums.asData?.value.items ?? []; + + return Skeletonizer.sliver( + enabled: topAlbums.isLoading && !topAlbums.isLoadingNextPage, + child: SliverInfiniteList( + onFetchData: () async { + await topAlbumsNotifier.fetchMore(); + }, + hasError: topAlbums.hasError, + isLoading: topAlbums.isLoading && !topAlbums.isLoadingNextPage, + hasReachedMax: topAlbums.asData?.value.hasMore ?? true, + itemCount: albumsData.length, + itemBuilder: (context, index) { + final album = albumsData[index]; + return StatsAlbumItem( + album: album.album, + info: Text( + context.l10n + .count_plays(compactNumberFormatter.format(album.count)), + ), + ); + }, + ), + ); + } +} diff --git a/lib/modules/stats/top/artists.dart b/lib/modules/stats/top/artists.dart new file mode 100644 index 000000000..3e4e098d4 --- /dev/null +++ b/lib/modules/stats/top/artists.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotube/collections/formatters.dart'; +import 'package:spotube/modules/stats/common/artist_item.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/history/top/tracks.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; +import 'package:very_good_infinite_list/very_good_infinite_list.dart'; + +class TopArtists extends HookConsumerWidget { + const TopArtists({super.key}); + + @override + Widget build(BuildContext context, ref) { + final historyDuration = ref.watch(playbackHistoryTopDurationProvider); + final topTracks = ref.watch( + historyTopTracksProvider(historyDuration), + ); + final topTracksNotifier = + ref.watch(historyTopTracksProvider(historyDuration).notifier); + + final artistsData = useMemoized( + () => topTracks.asData?.value.artists ?? [], [topTracks.asData?.value]); + + return Skeletonizer.sliver( + enabled: topTracks.isLoading && !topTracks.isLoadingNextPage, + child: SliverInfiniteList( + onFetchData: () async { + await topTracksNotifier.fetchMore(); + }, + hasError: topTracks.hasError, + isLoading: topTracks.isLoading && !topTracks.isLoadingNextPage, + hasReachedMax: topTracks.asData?.value.hasMore ?? true, + itemCount: artistsData.length, + itemBuilder: (context, index) { + final artist = artistsData[index]; + return StatsArtistItem( + artist: artist.artist, + info: Text( + context.l10n + .count_plays(compactNumberFormatter.format(artist.count)), + ), + ); + }, + ), + ); + } +} diff --git a/lib/modules/stats/top/top.dart b/lib/modules/stats/top/top.dart new file mode 100644 index 000000000..643064aa4 --- /dev/null +++ b/lib/modules/stats/top/top.dart @@ -0,0 +1,107 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/components/themed_button_tab_bar.dart'; +import 'package:spotube/modules/stats/top/albums.dart'; +import 'package:spotube/modules/stats/top/artists.dart'; +import 'package:spotube/modules/stats/top/tracks.dart'; +import 'package:spotube/extensions/context.dart'; + +import 'package:spotube/provider/history/top.dart'; + +class StatsPageTopSection extends HookConsumerWidget { + const StatsPageTopSection({super.key}); + + @override + Widget build(BuildContext context, ref) { + final tabController = useTabController(initialLength: 3); + final historyDuration = ref.watch(playbackHistoryTopDurationProvider); + final historyDurationNotifier = + ref.watch(playbackHistoryTopDurationProvider.notifier); + + return SliverMainAxisGroup( + slivers: [ + SliverAppBar( + floating: true, + flexibleSpace: ThemedButtonsTabBar( + controller: tabController, + tabs: [ + Tab( + child: Padding( + padding: const EdgeInsets.all(5), + child: Text(context.l10n.top_tracks), + ), + ), + Tab( + child: Padding( + padding: const EdgeInsets.all(5), + child: Text(context.l10n.top_artists), + ), + ), + Tab( + child: Padding( + padding: const EdgeInsets.all(5), + child: Text(context.l10n.top_albums), + ), + ), + ], + ), + ), + SliverToBoxAdapter( + child: Align( + alignment: Alignment.centerRight, + child: DropdownButton( + style: Theme.of(context).textTheme.bodySmall!, + isDense: true, + padding: const EdgeInsets.all(4), + borderRadius: BorderRadius.circular(4), + underline: const SizedBox(), + value: historyDuration, + onChanged: (value) { + if (value == null) return; + historyDurationNotifier.update((_) => value); + }, + icon: const Icon(Icons.arrow_drop_down), + items: [ + DropdownMenuItem( + value: HistoryDuration.days7, + child: Text(context.l10n.this_week), + ), + DropdownMenuItem( + value: HistoryDuration.days30, + child: Text(context.l10n.this_month), + ), + DropdownMenuItem( + value: HistoryDuration.months6, + child: Text(context.l10n.last_6_months), + ), + DropdownMenuItem( + value: HistoryDuration.year, + child: Text(context.l10n.this_year), + ), + DropdownMenuItem( + value: HistoryDuration.years2, + child: Text(context.l10n.last_2_years), + ), + DropdownMenuItem( + value: HistoryDuration.allTime, + child: Text(context.l10n.all_time), + ), + ], + ), + ), + ), + ListenableBuilder( + listenable: tabController, + builder: (context, _) { + return switch (tabController.index) { + 1 => const TopArtists(), + 2 => const TopAlbums(), + _ => const TopTracks(), + }; + }, + ), + ], + ); + } +} diff --git a/lib/modules/stats/top/tracks.dart b/lib/modules/stats/top/tracks.dart new file mode 100644 index 000000000..7fba220de --- /dev/null +++ b/lib/modules/stats/top/tracks.dart @@ -0,0 +1,49 @@ +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotube/collections/formatters.dart'; +import 'package:spotube/modules/stats/common/track_item.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/history/top/tracks.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; +import 'package:very_good_infinite_list/very_good_infinite_list.dart'; + +class TopTracks extends HookConsumerWidget { + const TopTracks({super.key}); + + @override + Widget build(BuildContext context, ref) { + final historyDuration = ref.watch(playbackHistoryTopDurationProvider); + final topTracks = ref.watch( + historyTopTracksProvider(historyDuration), + ); + final topTracksNotifier = + ref.watch(historyTopTracksProvider(historyDuration).notifier); + + final tracksData = topTracks.asData?.value.items ?? []; + + return Skeletonizer.sliver( + enabled: topTracks.isLoading && !topTracks.isLoadingNextPage, + child: SliverInfiniteList( + onFetchData: () async { + await topTracksNotifier.fetchMore(); + }, + hasError: topTracks.hasError, + isLoading: topTracks.isLoading && !topTracks.isLoadingNextPage, + hasReachedMax: topTracks.asData?.value.hasMore ?? true, + itemCount: tracksData.length, + itemBuilder: (context, index) { + final track = tracksData[index]; + return StatsTrackItem( + track: track.track, + info: Text( + context.l10n + .count_plays(compactNumberFormatter.format(track.count)), + ), + ); + }, + ), + ); + } +} diff --git a/lib/pages/album/album.dart b/lib/pages/album/album.dart index b24b69f43..0c6cfd693 100644 --- a/lib/pages/album/album.dart +++ b/lib/pages/album/album.dart @@ -1,13 +1,15 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/tracks_view/track_view.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_props.dart'; +import 'package:spotube/components/tracks_view/track_view.dart'; +import 'package:spotube/components/tracks_view/track_view_props.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class AlbumPage extends HookConsumerWidget { + static const name = "album"; + final AlbumSimple album; const AlbumPage({ super.key, @@ -22,7 +24,7 @@ class AlbumPage extends HookConsumerWidget { final isSavedAlbum = ref.watch(albumsIsSavedProvider(album.id!)); return InheritedTrackView( - collectionId: album.id!, + collection: album, image: album.images.asUrlString( placeholder: ImagePlaceholder.albumArt, ), @@ -44,7 +46,8 @@ class AlbumPage extends HookConsumerWidget { }, ), routePath: "/album/${album.id}", - shareUrl: album.externalUrls!.spotify!, + shareUrl: album.externalUrls?.spotify ?? + "https://open.spotify.com/album/${album.id}", isLiked: isSavedAlbum.asData?.value ?? false, onHeart: isSavedAlbum.asData?.value == null ? null diff --git a/lib/pages/artist/artist.dart b/lib/pages/artist/artist.dart index c3b046910..70ad72de5 100644 --- a/lib/pages/artist/artist.dart +++ b/lib/pages/artist/artist.dart @@ -4,10 +4,10 @@ import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:skeletonizer/skeletonizer.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; -import 'package:spotube/components/artist/artist_album_list.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/modules/artist/artist_album_list.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/models/logger.dart'; + import 'package:spotube/pages/artist/section/footer.dart'; import 'package:spotube/pages/artist/section/header.dart'; import 'package:spotube/pages/artist/section/related_artists.dart'; @@ -15,9 +15,10 @@ import 'package:spotube/pages/artist/section/top_tracks.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class ArtistPage extends HookConsumerWidget { + static const name = "artist"; + final String artistId; - final logger = getLogger(ArtistPage); - ArtistPage(this.artistId, {super.key}); + const ArtistPage(this.artistId, {super.key}); @override Widget build(BuildContext context, ref) { diff --git a/lib/pages/artist/section/footer.dart b/lib/pages/artist/section/footer.dart index 4707b9394..abe864106 100644 --- a/lib/pages/artist/section/footer.dart +++ b/lib/pages/artist/section/footer.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/provider/spotify/spotify.dart'; diff --git a/lib/pages/artist/section/header.dart b/lib/pages/artist/section/header.dart index 5bad674ee..713e0d266 100644 --- a/lib/pages/artist/section/header.dart +++ b/lib/pages/artist/section/header.dart @@ -5,12 +5,13 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotube/collections/fake.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/hooks/utils/use_breakpoint_value.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/blacklist_provider.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:spotube/utils/primitive_utils.dart'; @@ -39,10 +40,9 @@ class ArtistPageHeader extends HookConsumerWidget { ); final auth = ref.watch(authenticationProvider); - final blacklist = ref.watch(blacklistProvider); - final isBlackListed = blacklist.contains( - BlacklistedElement.artist(artistId, artist.name!), - ); + ref.watch(blacklistProvider); + final blacklistNotifier = ref.watch(blacklistProvider.notifier); + final isBlackListed = blacklistNotifier.containsArtist(artist); final image = artist.images.asUrlString( placeholder: ImagePlaceholder.artist, @@ -135,7 +135,7 @@ class ArtistPageHeader extends HookConsumerWidget { child: Row( mainAxisSize: MainAxisSize.min, children: [ - if (auth != null) + if (auth.asData?.value != null) Consumer( builder: (context, ref, _) { final isFollowingQuery = ref @@ -187,14 +187,16 @@ class ArtistPageHeader extends HookConsumerWidget { ), onPressed: () async { if (isBlackListed) { - ref.read(blacklistProvider.notifier).remove( - BlacklistedElement.artist( - artist.id!, artist.name!), - ); + await ref + .read(blacklistProvider.notifier) + .remove(artist.id!); } else { - ref.read(blacklistProvider.notifier).add( - BlacklistedElement.artist( - artist.id!, artist.name!), + await ref.read(blacklistProvider.notifier).add( + BlacklistTableCompanion.insert( + name: artist.name!, + elementId: artist.id!, + elementType: BlacklistedType.artist, + ), ); } }, diff --git a/lib/pages/artist/section/related_artists.dart b/lib/pages/artist/section/related_artists.dart index 7fc48dedf..066f73fdc 100644 --- a/lib/pages/artist/section/related_artists.dart +++ b/lib/pages/artist/section/related_artists.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/components/artist/artist_card.dart'; +import 'package:spotube/modules/artist/artist_card.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class ArtistPageRelatedArtists extends ConsumerWidget { diff --git a/lib/pages/artist/section/top_tracks.dart b/lib/pages/artist/section/top_tracks.dart index 9d4078997..d52ed470f 100644 --- a/lib/pages/artist/section/top_tracks.dart +++ b/lib/pages/artist/section/top_tracks.dart @@ -4,12 +4,12 @@ import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/fake.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/dialogs/select_device_dialog.dart'; -import 'package:spotube/components/shared/track_tile/track_tile.dart'; +import 'package:spotube/components/dialogs/select_device_dialog.dart'; +import 'package:spotube/components/track_tile/track_tile.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/models/connect/connect.dart'; import 'package:spotube/provider/connect/connect.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class ArtistPageTopTracks extends HookConsumerWidget { @@ -21,8 +21,8 @@ class ArtistPageTopTracks extends HookConsumerWidget { final theme = Theme.of(context); final scaffoldMessenger = ScaffoldMessenger.of(context); - final playlist = ref.watch(proxyPlaylistProvider); - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); + final playlist = ref.watch(audioPlayerProvider); + final playlistNotifier = ref.watch(audioPlayerProvider.notifier); final topTracksQuery = ref.watch(artistTopTracksProvider(artistId)); final isPlaylistPlaying = playlist.containsTracks( @@ -52,8 +52,9 @@ class ArtistPageTopTracks extends HookConsumerWidget { if (!isPlaylistPlaying) { await remotePlayback.load( - WebSocketLoadEventData( + WebSocketLoadEventData.playlist( tracks: tracks, + collection: null, initialIndex: tracks.indexWhere((s) => s.id == currentTrack?.id), ), ); diff --git a/lib/pages/connect/connect.dart b/lib/pages/connect/connect.dart index cbdb446e7..d3b0d0cbb 100644 --- a/lib/pages/connect/connect.dart +++ b/lib/pages/connect/connect.dart @@ -2,13 +2,16 @@ import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/connect/local_devices.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/modules/connect/local_devices.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/context.dart'; +import 'package:spotube/pages/connect/control/control.dart'; import 'package:spotube/provider/connect/clients.dart'; import 'package:spotube/utils/service_utils.dart'; class ConnectPage extends HookConsumerWidget { + static const name = "connect"; + const ConnectPage({super.key}); @override @@ -65,9 +68,9 @@ class ConnectPage extends HookConsumerWidget { selected: selected, onTap: () { if (selected) { - ServiceUtils.push( + ServiceUtils.pushNamed( context, - "/connect/control", + ConnectControlPage.name, ); } else { connectClientsNotifier.resolveService(device); diff --git a/lib/pages/connect/control/control.dart b/lib/pages/connect/control/control.dart index b78f0ed32..cae0bd1b9 100644 --- a/lib/pages/connect/control/control.dart +++ b/lib/pages/connect/control/control.dart @@ -3,19 +3,20 @@ import 'package:gap/gap.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/player/player_queue.dart'; -import 'package:spotube/components/player/volume_slider.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/links/anchor_button.dart'; -import 'package:spotube/components/shared/links/artist_link.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/modules/player/player_queue.dart'; +import 'package:spotube/modules/player/volume_slider.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/links/anchor_button.dart'; +import 'package:spotube/components/links/artist_link.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/duration.dart'; import 'package:spotube/extensions/image.dart'; +import 'package:spotube/pages/track/track.dart'; import 'package:spotube/provider/connect/clients.dart'; import 'package:spotube/provider/connect/connect.dart'; -import 'package:spotube/services/audio_player/loop_mode.dart'; +import 'package:media_kit/media_kit.dart' hide Track; import 'package:spotube/utils/service_utils.dart'; class RemotePlayerQueue extends ConsumerWidget { @@ -46,6 +47,8 @@ class RemotePlayerQueue extends ConsumerWidget { } class ConnectControlPage extends HookConsumerWidget { + static const name = "connect_control"; + const ConnectControlPage({super.key}); @override @@ -125,9 +128,13 @@ class ConnectControlPage extends HookConsumerWidget { playlist.activeTrack?.name ?? "", style: textTheme.titleLarge!, onTap: () { - ServiceUtils.push( + if (playlist.activeTrack == null) return; + ServiceUtils.pushNamed( context, - "/track/${playlist.activeTrack?.id}", + TrackPage.name, + pathParameters: { + "id": playlist.activeTrack!.id!, + }, ); }, ), @@ -137,6 +144,14 @@ class ConnectControlPage extends HookConsumerWidget { artists: playlist.activeTrack?.artists ?? [], textStyle: textTheme.bodyMedium!, mainAxisAlignment: WrapAlignment.start, + onOverflowArtistClick: () => + ServiceUtils.pushNamed( + context, + TrackPage.name, + pathParameters: { + "id": playlist.activeTrack!.id!, + }, + ), ), ), ], @@ -237,18 +252,18 @@ class ConnectControlPage extends HookConsumerWidget { : connectNotifier.next, ), IconButton( - tooltip: loopMode == PlaybackLoopMode.one + tooltip: loopMode == PlaylistMode.single ? context.l10n.loop_track - : loopMode == PlaybackLoopMode.all + : loopMode == PlaylistMode.loop ? context.l10n.repeat_playlist : null, icon: Icon( - loopMode == PlaybackLoopMode.one + loopMode == PlaylistMode.single ? SpotubeIcons.repeatOne : SpotubeIcons.repeat, ), - style: loopMode == PlaybackLoopMode.one || - loopMode == PlaybackLoopMode.all + style: loopMode == PlaylistMode.single || + loopMode == PlaylistMode.loop ? activeButtonStyle : buttonStyle, onPressed: playlist.activeTrack == null @@ -256,12 +271,11 @@ class ConnectControlPage extends HookConsumerWidget { : () async { connectNotifier.setLoopMode( switch (loopMode) { - PlaybackLoopMode.all => - PlaybackLoopMode.one, - PlaybackLoopMode.one => - PlaybackLoopMode.none, - PlaybackLoopMode.none => - PlaybackLoopMode.all, + PlaylistMode.loop => + PlaylistMode.single, + PlaylistMode.single => + PlaylistMode.none, + PlaylistMode.none => PlaylistMode.loop, }, ); }, diff --git a/lib/pages/desktop_login/desktop_login.dart b/lib/pages/desktop_login/desktop_login.dart deleted file mode 100644 index 9c0610911..000000000 --- a/lib/pages/desktop_login/desktop_login.dart +++ /dev/null @@ -1,76 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; - -import 'package:spotube/collections/assets.gen.dart'; -import 'package:spotube/components/desktop_login/login_form.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; -import 'package:spotube/extensions/constrains.dart'; -import 'package:spotube/extensions/context.dart'; - -class DesktopLoginPage extends HookConsumerWidget { - const DesktopLoginPage({super.key}); - - @override - Widget build(BuildContext context, ref) { - final mediaQuery = MediaQuery.of(context); - final theme = Theme.of(context); - final color = theme.colorScheme.surfaceVariant.withOpacity(.3); - - return SafeArea( - child: Scaffold( - appBar: const PageWindowTitleBar( - leading: BackButton(), - ), - body: SingleChildScrollView( - child: Center( - child: Container( - margin: const EdgeInsets.all(10), - padding: const EdgeInsets.all(10), - decoration: BoxDecoration( - color: color, - borderRadius: BorderRadius.circular(10), - ), - child: Column( - children: [ - Assets.spotubeLogoPng.image( - width: MediaQuery.of(context).size.width * - (mediaQuery.mdAndDown ? .5 : .3), - ), - Text( - context.l10n.add_spotify_credentials, - style: theme.textTheme.titleMedium, - ), - Text( - context.l10n.credentials_will_not_be_shared_disclaimer, - style: theme.textTheme.labelMedium, - ), - const SizedBox(height: 10), - TokenLoginForm( - onDone: () => GoRouter.of(context).go("/"), - ), - const SizedBox(height: 10), - Wrap( - alignment: WrapAlignment.center, - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - Text(context.l10n.know_how_to_login), - TextButton( - child: Text( - context.l10n.follow_step_by_step_guide, - ), - onPressed: () => GoRouter.of(context).push( - "/login-tutorial", - ), - ), - ], - ), - ], - ), - ), - ), - ), - ), - ); - } -} diff --git a/lib/pages/desktop_login/login_tutorial.dart b/lib/pages/desktop_login/login_tutorial.dart deleted file mode 100644 index 83b04af18..000000000 --- a/lib/pages/desktop_login/login_tutorial.dart +++ /dev/null @@ -1,124 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:go_router/go_router.dart'; -import 'package:introduction_screen/introduction_screen.dart'; - -import 'package:spotube/collections/assets.gen.dart'; -import 'package:spotube/components/desktop_login/login_form.dart'; -import 'package:spotube/components/shared/links/hyper_link.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; -import 'package:spotube/extensions/context.dart'; -import 'package:spotube/provider/authentication_provider.dart'; -import 'package:spotube/utils/service_utils.dart'; - -class LoginTutorial extends ConsumerWidget { - const LoginTutorial({super.key}); - - @override - Widget build(BuildContext context, ref) { - ref.watch(authenticationProvider); - final authenticationNotifier = ref.watch(authenticationProvider.notifier); - final key = GlobalKey>(); - final theme = Theme.of(context); - - final pageDecoration = PageDecoration( - bodyTextStyle: theme.textTheme.bodyMedium!, - titleTextStyle: theme.textTheme.headlineMedium!, - ); - return Scaffold( - appBar: PageWindowTitleBar( - leading: TextButton( - child: Text(context.l10n.exit), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), - body: IntroductionScreen( - key: key, - globalBackgroundColor: theme.scaffoldBackgroundColor, - overrideBack: OutlinedButton( - child: Center(child: Text(context.l10n.previous)), - onPressed: () { - (key.currentState as IntroductionScreenState).previous(); - }, - ), - overrideNext: FilledButton( - child: Center(child: Text(context.l10n.next)), - onPressed: () { - (key.currentState as IntroductionScreenState).next(); - }, - ), - showBackButton: true, - overrideDone: FilledButton( - onPressed: authenticationNotifier.isLoggedIn - ? () { - ServiceUtils.push(context, "/"); - } - : null, - child: Center(child: Text(context.l10n.done)), - ), - pages: [ - PageViewModel( - decoration: pageDecoration, - title: context.l10n.step_1, - image: Assets.tutorial.step1.image(), - bodyWidget: Wrap( - children: [ - Text(context.l10n.first_go_to), - const SizedBox(width: 5), - const Hyperlink( - "accounts.spotify.com ", - "https://accounts.spotify.com", - ), - Text(context.l10n.login_if_not_logged_in), - ], - ), - ), - PageViewModel( - decoration: pageDecoration, - title: context.l10n.step_2, - image: Assets.tutorial.step2.image(), - bodyWidget: - Text(context.l10n.step_2_steps, textAlign: TextAlign.left), - ), - PageViewModel( - decoration: pageDecoration, - title: context.l10n.step_3, - image: Assets.tutorial.step3.image(), - bodyWidget: - Text(context.l10n.step_3_steps, textAlign: TextAlign.left), - ), - if (authenticationNotifier.isLoggedIn) - PageViewModel( - decoration: pageDecoration.copyWith( - bodyAlignment: Alignment.center, - ), - title: context.l10n.success_emoji, - image: Assets.success.image(), - body: context.l10n.success_message, - ) - else - PageViewModel( - decoration: pageDecoration, - title: context.l10n.step_4, - bodyWidget: Column( - children: [ - Text( - context.l10n.step_4_steps, - style: theme.textTheme.labelMedium, - ), - const SizedBox(height: 10), - TokenLoginForm( - onDone: () { - GoRouter.of(context).go("/"); - }, - ), - ], - ), - ), - ], - ), - ); - } -} diff --git a/lib/pages/getting_started/getting_started.dart b/lib/pages/getting_started/getting_started.dart index cbab03b9c..0159a77f4 100644 --- a/lib/pages/getting_started/getting_started.dart +++ b/lib/pages/getting_started/getting_started.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/assets.gen.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/pages/getting_started/sections/greeting.dart'; import 'package:spotube/pages/getting_started/sections/playback.dart'; @@ -12,6 +12,8 @@ import 'package:spotube/provider/user_preferences/user_preferences_provider.dart import 'package:spotube/themes/theme.dart'; class GettingStarting extends HookConsumerWidget { + static const name = "getting_started"; + const GettingStarting({super.key}); @override diff --git a/lib/pages/getting_started/sections/greeting.dart b/lib/pages/getting_started/sections/greeting.dart index 563e43de9..6d6493513 100644 --- a/lib/pages/getting_started/sections/greeting.dart +++ b/lib/pages/getting_started/sections/greeting.dart @@ -3,7 +3,7 @@ import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/getting_started/blur_card.dart'; +import 'package:spotube/modules/getting_started/blur_card.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/utils/platform.dart'; diff --git a/lib/pages/getting_started/sections/playback.dart b/lib/pages/getting_started/sections/playback.dart index 298cf8391..e7087afd7 100644 --- a/lib/pages/getting_started/sections/playback.dart +++ b/lib/pages/getting_started/sections/playback.dart @@ -4,11 +4,11 @@ import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/assets.gen.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/getting_started/blur_card.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/modules/getting_started/blur_card.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/string.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; final audioSourceToIconMap = { AudioSource.youtube: const Icon( diff --git a/lib/pages/getting_started/sections/region.dart b/lib/pages/getting_started/sections/region.dart index 9303392cc..9e31a273c 100644 --- a/lib/pages/getting_started/sections/region.dart +++ b/lib/pages/getting_started/sections/region.dart @@ -4,7 +4,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/language_codes.dart'; import 'package:spotube/collections/spotify_markets.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/getting_started/blur_card.dart'; +import 'package:spotube/modules/getting_started/blur_card.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/l10n/l10n.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; @@ -55,14 +55,14 @@ class GettingStartedPageLanguageRegionSection extends HookConsumerWidget { ), const Gap(16), DropdownMenu( - initialSelection: preferences.recommendationMarket, + initialSelection: preferences.market, onSelected: (value) { if (value == null) return; ref .read(userPreferencesProvider.notifier) .setRecommendationMarket(value); }, - hintText: preferences.recommendationMarket.name, + hintText: preferences.market.name, label: Text(context.l10n.market_place_region), inputDecorationTheme: const InputDecorationTheme(isDense: true), diff --git a/lib/pages/getting_started/sections/support.dart b/lib/pages/getting_started/sections/support.dart index 468234257..b449def53 100644 --- a/lib/pages/getting_started/sections/support.dart +++ b/lib/pages/getting_started/sections/support.dart @@ -3,8 +3,10 @@ import 'package:gap/gap.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/getting_started/blur_card.dart'; +import 'package:spotube/modules/getting_started/blur_card.dart'; import 'package:spotube/extensions/context.dart'; +import 'package:spotube/pages/home/home.dart'; +import 'package:spotube/pages/mobile_login/mobile_login.dart'; import 'package:spotube/services/kv_store/kv_store.dart'; import 'package:url_launcher/url_launcher_string.dart'; @@ -104,7 +106,7 @@ class GettingStartedScreenSupportSection extends HookConsumerWidget { onPressed: () async { await KVStoreService.setDoneGettingStarted(true); if (context.mounted) { - context.go("/"); + context.goNamed(HomePage.name); } }, ), @@ -120,7 +122,7 @@ class GettingStartedScreenSupportSection extends HookConsumerWidget { onPressed: () async { await KVStoreService.setDoneGettingStarted(true); if (context.mounted) { - context.push("/login"); + context.pushNamed(WebViewLogin.name); } }, ), diff --git a/lib/pages/home/feed/feed_section.dart b/lib/pages/home/feed/feed_section.dart index c945251c2..bcfc0b81f 100644 --- a/lib/pages/home/feed/feed_section.dart +++ b/lib/pages/home/feed/feed_section.dart @@ -2,14 +2,16 @@ import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotube/collections/fake.dart'; -import 'package:spotube/components/album/album_card.dart'; -import 'package:spotube/components/artist/artist_card.dart'; -import 'package:spotube/components/playlist/playlist_card.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/modules/album/album_card.dart'; +import 'package:spotube/modules/artist/artist_card.dart'; +import 'package:spotube/modules/playlist/playlist_card.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/provider/spotify/views/home_section.dart'; class HomeFeedSectionPage extends HookConsumerWidget { + static const name = "home_feed_section"; + final String sectionUri; const HomeFeedSectionPage({super.key, required this.sectionUri}); diff --git a/lib/pages/home/genres/genre_playlists.dart b/lib/pages/home/genres/genre_playlists.dart index d80b4513a..58436bcf1 100644 --- a/lib/pages/home/genres/genre_playlists.dart +++ b/lib/pages/home/genres/genre_playlists.dart @@ -5,16 +5,18 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotify/spotify.dart' hide Offset; import 'package:spotube/collections/fake.dart'; -import 'package:spotube/components/playlist/playlist_card.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; -import 'package:spotube/components/shared/waypoint.dart'; +import 'package:spotube/modules/playlist/playlist_card.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/components/waypoint.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:collection/collection.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; +import 'package:spotube/utils/platform.dart'; class GenrePlaylistsPage extends HookConsumerWidget { + static const name = "genre_playlists"; + final Category category; const GenrePlaylistsPage({super.key, required this.category}); @@ -27,7 +29,7 @@ class GenrePlaylistsPage extends HookConsumerWidget { final scrollController = useScrollController(); return Scaffold( - appBar: DesktopTools.platform.isDesktop + appBar: kIsDesktop ? const PageWindowTitleBar( leading: BackButton(color: Colors.white), backgroundColor: Colors.transparent, @@ -53,12 +55,12 @@ class GenrePlaylistsPage extends HookConsumerWidget { controller: scrollController, slivers: [ SliverAppBar( - automaticallyImplyLeading: DesktopTools.platform.isMobile, + automaticallyImplyLeading: kIsMobile, expandedHeight: mediaQuery.mdAndDown ? 200 : 150, title: const Text(""), backgroundColor: Colors.transparent, flexibleSpace: FlexibleSpaceBar( - centerTitle: DesktopTools.platform.isDesktop, + centerTitle: kIsDesktop, title: Text( category.name!, style: Theme.of(context).textTheme.headlineMedium?.copyWith( diff --git a/lib/pages/home/genres/genres.dart b/lib/pages/home/genres/genres.dart index 291ce737b..4846d633c 100644 --- a/lib/pages/home/genres/genres.dart +++ b/lib/pages/home/genres/genres.dart @@ -6,12 +6,14 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/gradients.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; +import 'package:spotube/pages/home/genres/genre_playlists.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class GenrePage extends HookConsumerWidget { + static const name = "genre"; const GenrePage({super.key}); @override @@ -47,7 +49,13 @@ class GenrePage extends HookConsumerWidget { return InkWell( borderRadius: BorderRadius.circular(8), onTap: () { - context.push("/genre/${category.id}", extra: category); + context.pushNamed( + GenrePlaylistsPage.name, + pathParameters: { + "categoryId": category.id!, + }, + extra: category, + ); }, child: Ink( padding: const EdgeInsets.all(8), diff --git a/lib/pages/home/home.dart b/lib/pages/home/home.dart index 31f26bee3..efdca4f79 100644 --- a/lib/pages/home/home.dart +++ b/lib/pages/home/home.dart @@ -3,28 +3,33 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/assets.gen.dart'; -import 'package:spotube/components/connect/connect_device.dart'; -import 'package:spotube/components/home/sections/featured.dart'; -import 'package:spotube/components/home/sections/feed.dart'; -import 'package:spotube/components/home/sections/friends.dart'; -import 'package:spotube/components/home/sections/genres.dart'; -import 'package:spotube/components/home/sections/made_for_user.dart'; -import 'package:spotube/components/home/sections/new_releases.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/collections/spotube_icons.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/modules/connect/connect_device.dart'; +import 'package:spotube/modules/home/sections/featured.dart'; +import 'package:spotube/modules/home/sections/feed.dart'; +import 'package:spotube/modules/home/sections/friends.dart'; +import 'package:spotube/modules/home/sections/genres.dart'; +import 'package:spotube/modules/home/sections/made_for_user.dart'; +import 'package:spotube/modules/home/sections/new_releases.dart'; +import 'package:spotube/modules/home/sections/recent.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/constrains.dart'; -import 'package:spotube/extensions/image.dart'; -import 'package:spotube/provider/spotify/spotify.dart'; +import 'package:spotube/pages/settings/settings.dart'; +import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; import 'package:spotube/utils/platform.dart'; import 'package:spotube/utils/service_utils.dart'; class HomePage extends HookConsumerWidget { + static const name = "home"; const HomePage({super.key}); @override Widget build(BuildContext context, ref) { final controller = useScrollController(); final mediaQuery = MediaQuery.of(context); + final layoutMode = + ref.watch(userPreferencesProvider.select((s) => s.layoutMode)); return SafeArea( bottom: false, @@ -33,39 +38,27 @@ class HomePage extends HookConsumerWidget { body: CustomScrollView( controller: controller, slivers: [ - if (mediaQuery.mdAndDown) + if (mediaQuery.smAndDown || layoutMode == LayoutMode.compact) SliverAppBar( floating: true, title: Assets.spotubeLogoPng.image(height: 45), actions: [ const ConnectDeviceButton(), const Gap(10), - Consumer(builder: (context, ref, _) { - final me = ref.watch(meProvider); - final meData = me.asData?.value; - - return IconButton( - icon: CircleAvatar( - backgroundImage: UniversalImage.imageProvider( - (meData?.images).asUrlString( - placeholder: ImagePlaceholder.artist, - ), - ), - ), - style: IconButton.styleFrom( - padding: EdgeInsets.zero, - ), - onPressed: () { - ServiceUtils.push(context, "/profile"); - }, - ); - }), + IconButton( + icon: const Icon(SpotubeIcons.settings, size: 20), + onPressed: () { + ServiceUtils.pushNamed(context, SettingsPage.name); + }, + ), const Gap(10), ], ) else if (kIsMacOS) const SliverGap(10), const HomeGenresSection(), + const SliverGap(10), + const SliverToBoxAdapter(child: HomeRecentlyPlayedSection()), const SliverToBoxAdapter(child: HomeFeaturedSection()), const HomePageFriendsSection(), const SliverToBoxAdapter(child: HomeNewReleasesSection()), diff --git a/lib/pages/lastfm_login/lastfm_login.dart b/lib/pages/lastfm_login/lastfm_login.dart index b6aeef2ec..8107e627c 100644 --- a/lib/pages/lastfm_login/lastfm_login.dart +++ b/lib/pages/lastfm_login/lastfm_login.dart @@ -4,12 +4,13 @@ import 'package:form_validator/form_validator.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/dialogs/prompt_dialog.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/components/dialogs/prompt_dialog.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/provider/scrobbler_provider.dart'; +import 'package:spotube/provider/scrobbler/scrobbler.dart'; class LastFMLoginPage extends HookConsumerWidget { + static const name = "lastfm_login"; const LastFMLoginPage({super.key}); @override diff --git a/lib/pages/library/library.dart b/lib/pages/library/library.dart index ccdb6a352..a0bc1bb7e 100644 --- a/lib/pages/library/library.dart +++ b/lib/pages/library/library.dart @@ -1,17 +1,19 @@ import 'package:flutter/material.dart' hide Image; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/components/library/user_local_tracks.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; -import 'package:spotube/components/library/user_albums.dart'; -import 'package:spotube/components/library/user_artists.dart'; -import 'package:spotube/components/library/user_downloads.dart'; -import 'package:spotube/components/library/user_playlists.dart'; -import 'package:spotube/components/shared/themed_button_tab_bar.dart'; +import 'package:spotube/modules/library/user_local_tracks.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/modules/library/user_albums.dart'; +import 'package:spotube/modules/library/user_artists.dart'; +import 'package:spotube/modules/library/user_downloads.dart'; +import 'package:spotube/modules/library/user_playlists.dart'; +import 'package:spotube/components/themed_button_tab_bar.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/download_manager_provider.dart'; class LibraryPage extends HookConsumerWidget { + static const name = "library"; + const LibraryPage({super.key}); @override Widget build(BuildContext context, ref) { @@ -27,7 +29,7 @@ class LibraryPage extends HookConsumerWidget { leading: ThemedButtonsTabBar( tabs: [ Tab(text: " ${context.l10n.playlists} "), - Tab(text: " ${context.l10n.local_tracks} "), + Tab(text: " ${context.l10n.local_tab} "), Tab( child: Badge( isLabelVisible: downloadingCount > 0, diff --git a/lib/pages/library/local_folder.dart b/lib/pages/library/local_folder.dart new file mode 100644 index 000000000..ad1d5d827 --- /dev/null +++ b/lib/pages/library/local_folder.dart @@ -0,0 +1,241 @@ +import 'package:collection/collection.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:fuzzywuzzy/fuzzywuzzy.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotube/collections/fake.dart'; +import 'package:spotube/collections/spotube_icons.dart'; +import 'package:spotube/modules/library/user_local_tracks.dart'; +import 'package:spotube/components/expandable_search/expandable_search.dart'; +import 'package:spotube/components/fallbacks/not_found.dart'; +import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/components/sort_tracks_dropdown.dart'; +import 'package:spotube/components/track_tile/track_tile.dart'; +import 'package:spotube/extensions/artist_simple.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/models/local_track.dart'; +import 'package:spotube/provider/local_tracks/local_tracks_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/utils/service_utils.dart'; + +class LocalLibraryPage extends HookConsumerWidget { + static const name = "local_library_page"; + + final String location; + final bool isDownloads; + const LocalLibraryPage(this.location, {super.key, this.isDownloads = false}); + + Future playLocalTracks( + WidgetRef ref, + List tracks, { + LocalTrack? currentTrack, + }) async { + final playlist = ref.read(audioPlayerProvider); + final playback = ref.read(audioPlayerProvider.notifier); + currentTrack ??= tracks.first; + final isPlaylistPlaying = playlist.containsTracks(tracks); + if (!isPlaylistPlaying) { + var indexWhere = tracks.indexWhere((s) => s.id == currentTrack?.id); + await playback.load( + tracks, + initialIndex: indexWhere, + autoPlay: true, + ); + } else if (isPlaylistPlaying && + currentTrack.id != null && + currentTrack.id != playlist.activeTrack?.id) { + await playback.jumpToTrack(currentTrack); + } + } + + @override + Widget build(BuildContext context, ref) { + final sortBy = useState(SortBy.none); + final playlist = ref.watch(audioPlayerProvider); + final trackSnapshot = ref.watch(localTracksProvider); + final isPlaylistPlaying = playlist.containsTracks( + trackSnapshot.asData?.value.values.flattened.toList() ?? []); + + final searchController = useTextEditingController(); + useValueListenable(searchController); + final searchFocus = useFocusNode(); + final isFiltering = useState(false); + + final controller = useScrollController(); + + return SafeArea( + bottom: false, + child: Scaffold( + appBar: PageWindowTitleBar( + leading: const BackButton(), + centerTitle: true, + title: Text(isDownloads ? context.l10n.downloads : location), + backgroundColor: Colors.transparent, + ), + body: Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + children: [ + const SizedBox(width: 5), + FilledButton( + onPressed: trackSnapshot.asData?.value != null + ? () async { + if (trackSnapshot.asData?.value.isNotEmpty == + true) { + if (!isPlaylistPlaying) { + await playLocalTracks( + ref, + trackSnapshot.asData!.value[location] ?? [], + ); + } + } + } + : null, + child: Row( + children: [ + Text(context.l10n.play), + Icon( + isPlaylistPlaying + ? SpotubeIcons.stop + : SpotubeIcons.play, + ) + ], + ), + ), + const Spacer(), + ExpandableSearchButton( + isFiltering: isFiltering.value, + onPressed: (value) => isFiltering.value = value, + searchFocus: searchFocus, + ), + const SizedBox(width: 10), + SortTracksDropdown( + value: sortBy.value, + onChanged: (value) { + sortBy.value = value; + }, + ), + const SizedBox(width: 5), + FilledButton( + child: const Icon(SpotubeIcons.refresh), + onPressed: () { + ref.invalidate(localTracksProvider); + }, + ) + ], + ), + ), + ExpandableSearchField( + searchController: searchController, + searchFocus: searchFocus, + isFiltering: isFiltering.value, + onChangeFiltering: (value) => isFiltering.value = value, + ), + trackSnapshot.when( + data: (tracks) { + final sortedTracks = useMemoized(() { + return ServiceUtils.sortTracks( + tracks[location] ?? [], sortBy.value); + }, [sortBy.value, tracks]); + + final filteredTracks = useMemoized(() { + if (searchController.text.isEmpty) { + return sortedTracks; + } + return sortedTracks + .map((e) => ( + weightedRatio( + "${e.name} - ${e.artists?.asString() ?? ""}", + searchController.text, + ), + e, + )) + .toList() + .sorted( + (a, b) => b.$1.compareTo(a.$1), + ) + .where((e) => e.$1 > 50) + .map((e) => e.$2) + .toList() + .toList(); + }, [searchController.text, sortedTracks]); + + if (!trackSnapshot.isLoading && filteredTracks.isEmpty) { + return const Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [NotFound()], + ), + ); + } + + return Expanded( + child: RefreshIndicator( + onRefresh: () async { + ref.invalidate(localTracksProvider); + }, + child: InterScrollbar( + controller: controller, + child: Skeletonizer( + enabled: trackSnapshot.isLoading, + child: ListView.builder( + controller: controller, + physics: const AlwaysScrollableScrollPhysics(), + itemCount: trackSnapshot.isLoading + ? 5 + : filteredTracks.length, + itemBuilder: (context, index) { + if (trackSnapshot.isLoading) { + return TrackTile( + playlist: playlist, + track: FakeData.track, + index: index, + ); + } + + final track = filteredTracks[index]; + return TrackTile( + index: index, + playlist: playlist, + track: track, + userPlaylist: false, + onTap: () async { + await playLocalTracks( + ref, + sortedTracks, + currentTrack: track, + ); + }, + ); + }, + ), + ), + ), + ), + ); + }, + loading: () => Expanded( + child: Skeletonizer( + enabled: true, + child: ListView.builder( + itemCount: 5, + itemBuilder: (context, index) => TrackTile( + track: FakeData.track, + index: index, + playlist: playlist, + ), + ), + ), + ), + error: (error, stackTrace) => + Text(error.toString() + stackTrace.toString()), + ) + ], + )), + ); + } +} diff --git a/lib/pages/library/playlist_generate/playlist_generate.dart b/lib/pages/library/playlist_generate/playlist_generate.dart index 5044090d2..b62013c5c 100644 --- a/lib/pages/library/playlist_generate/playlist_generate.dart +++ b/lib/pages/library/playlist_generate/playlist_generate.dart @@ -6,13 +6,13 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotify_markets.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/library/playlist_generate/multi_select_field.dart'; -import 'package:spotube/components/library/playlist_generate/recommendation_attribute_dials.dart'; -import 'package:spotube/components/library/playlist_generate/recommendation_attribute_fields.dart'; -import 'package:spotube/components/library/playlist_generate/seeds_multi_autocomplete.dart'; -import 'package:spotube/components/library/playlist_generate/simple_track_tile.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/modules/library/playlist_generate/multi_select_field.dart'; +import 'package:spotube/modules/library/playlist_generate/recommendation_attribute_dials.dart'; +import 'package:spotube/modules/library/playlist_generate/recommendation_attribute_fields.dart'; +import 'package:spotube/modules/library/playlist_generate/seeds_multi_autocomplete.dart'; +import 'package:spotube/modules/library/playlist_generate/simple_track_tile.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; @@ -24,6 +24,8 @@ import 'package:spotube/provider/user_preferences/user_preferences_provider.dart const RecommendationAttribute zeroValues = (min: 0, target: 0, max: 0); class PlaylistGeneratorPage extends HookConsumerWidget { + static const name = "playlist_generator"; + const PlaylistGeneratorPage({super.key}); @override @@ -37,7 +39,7 @@ class PlaylistGeneratorPage extends HookConsumerWidget { final genresCollection = ref.watch(categoryGenresProvider); final limit = useValueNotifier(10); - final market = useValueNotifier(preferences.recommendationMarket); + final market = useValueNotifier(preferences.market); final genres = useState>([]); final artists = useState>([]); diff --git a/lib/pages/library/playlist_generate/playlist_generate_result.dart b/lib/pages/library/playlist_generate/playlist_generate_result.dart index 01b73267f..3bdc3b52d 100644 --- a/lib/pages/library/playlist_generate/playlist_generate_result.dart +++ b/lib/pages/library/playlist_generate/playlist_generate_result.dart @@ -4,16 +4,19 @@ import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/library/playlist_generate/simple_track_tile.dart'; -import 'package:spotube/components/playlist/playlist_create_dialog.dart'; -import 'package:spotube/components/shared/dialogs/playlist_add_track_dialog.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/modules/library/playlist_generate/simple_track_tile.dart'; +import 'package:spotube/modules/playlist/playlist_create_dialog.dart'; +import 'package:spotube/components/dialogs/playlist_add_track_dialog.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/models/spotify/recommendation_seeds.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/pages/playlist/playlist.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class PlaylistGenerateResultPage extends HookConsumerWidget { + static const name = "playlist_generate_result"; + final GeneratePlaylistProviderInput state; const PlaylistGenerateResultPage({ @@ -25,7 +28,7 @@ class PlaylistGenerateResultPage extends HookConsumerWidget { Widget build(BuildContext context, ref) { final router = GoRouter.of(context); final scaffoldMessenger = ScaffoldMessenger.of(context); - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); + final playlistNotifier = ref.watch(audioPlayerProvider.notifier); final generatedPlaylist = ref.watch(generatePlaylistProvider(state)); @@ -78,9 +81,12 @@ class PlaylistGenerateResultPage extends HookConsumerWidget { ? null : () async { await playlistNotifier.load( - generatedPlaylist.asData!.value.where( - (e) => selectedTracks.value.contains(e.id!), - ), + generatedPlaylist.asData!.value + .where( + (e) => selectedTracks.value + .contains(e.id!), + ) + .toList(), autoPlay: true, ); }, @@ -123,8 +129,11 @@ class PlaylistGenerateResultPage extends HookConsumerWidget { ); if (playlist != null) { - router.go( - '/playlist/${playlist.id}', + router.goNamed( + PlaylistPage.name, + pathParameters: { + "id": playlist.id!, + }, extra: playlist, ); } diff --git a/lib/pages/lyrics/lyrics.dart b/lib/pages/lyrics/lyrics.dart index ca13864a3..a81e3ba6c 100644 --- a/lib/pages/lyrics/lyrics.dart +++ b/lib/pages/lyrics/lyrics.dart @@ -6,10 +6,10 @@ import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/fallbacks/anonymous_fallback.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/themed_button_tab_bar.dart'; +import 'package:spotube/components/fallbacks/anonymous_fallback.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/themed_button_tab_bar.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; @@ -17,18 +17,20 @@ import 'package:spotube/hooks/utils/use_custom_status_bar_color.dart'; import 'package:spotube/hooks/utils/use_palette_color.dart'; import 'package:spotube/pages/lyrics/plain_lyrics.dart'; import 'package:spotube/pages/lyrics/synced_lyrics.dart'; -import 'package:spotube/provider/authentication_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/utils/platform.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class LyricsPage extends HookConsumerWidget { + static const name = "lyrics"; + final bool isModal; const LyricsPage({super.key, this.isModal = false}); @override Widget build(BuildContext context, ref) { - final playlist = ref.watch(proxyPlaylistProvider); + final playlist = ref.watch(audioPlayerProvider); String albumArt = useMemoized( () => (playlist.activeTrack?.album?.images).asUrlString( index: (playlist.activeTrack?.album?.images?.length ?? 1) - 1, @@ -60,7 +62,7 @@ class LyricsPage extends HookConsumerWidget { const Spacer(), Consumer( builder: (context, ref, child) { - final playback = ref.watch(proxyPlaylistProvider); + final playback = ref.watch(audioPlayerProvider); final lyric = ref.watch(syncedLyricsProvider(playback.activeTrack)); final providerName = lyric.asData?.value.provider; @@ -71,7 +73,7 @@ class LyricsPage extends HookConsumerWidget { return Align( alignment: Alignment.bottomRight, - child: Text("Powered by $providerName"), + child: Text(context.l10n.powered_by_provider(providerName)), ); }, ), @@ -82,7 +84,7 @@ class LyricsPage extends HookConsumerWidget { final auth = ref.watch(authenticationProvider); - if (auth == null) { + if (auth.asData?.value == null) { return Scaffold( appBar: !kIsMacOS && !isModal ? const PageWindowTitleBar() : null, body: const AnonymousFallback(), @@ -98,7 +100,7 @@ class LyricsPage extends HookConsumerWidget { child: Container( clipBehavior: Clip.hardEdge, decoration: BoxDecoration( - color: Theme.of(context).colorScheme.background.withOpacity(.4), + color: Theme.of(context).colorScheme.surface.withOpacity(.4), borderRadius: const BorderRadius.only( topLeft: Radius.circular(10), topRight: Radius.circular(10), diff --git a/lib/pages/lyrics/mini_lyrics.dart b/lib/pages/lyrics/mini_lyrics.dart index 1e4d46416..dbff563df 100644 --- a/lib/pages/lyrics/mini_lyrics.dart +++ b/lib/pages/lyrics/mini_lyrics.dart @@ -1,25 +1,27 @@ import 'package:flutter/material.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:gap/gap.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:palette_generator/palette_generator.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/player/player_controls.dart'; -import 'package:spotube/components/player/player_queue.dart'; -import 'package:spotube/components/root/sidebar.dart'; -import 'package:spotube/components/shared/fallbacks/anonymous_fallback.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/modules/player/player_controls.dart'; +import 'package:spotube/modules/player/player_queue.dart'; +import 'package:spotube/modules/root/sidebar.dart'; +import 'package:spotube/components/fallbacks/anonymous_fallback.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/hooks/utils/use_force_update.dart'; import 'package:spotube/pages/lyrics/plain_lyrics.dart'; import 'package:spotube/pages/lyrics/synced_lyrics.dart'; -import 'package:spotube/provider/authentication_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/utils/platform.dart'; +import 'package:window_manager/window_manager.dart'; class MiniLyricsPage extends HookConsumerWidget { + static const name = "mini_lyrics"; + final Size prevSize; const MiniLyricsPage({super.key, required this.prevSize}); @@ -29,22 +31,24 @@ class MiniLyricsPage extends HookConsumerWidget { final update = useForceUpdate(); final wasMaximized = useRef(false); - final playlistQueue = ref.watch(proxyPlaylistProvider); + final playlistQueue = ref.watch(audioPlayerProvider); final areaActive = useState(false); final hoverMode = useState(true); final showLyrics = useState(true); useEffect(() { - WidgetsBinding.instance.addPostFrameCallback((_) async { - wasMaximized.value = await DesktopTools.window.isMaximized(); - }); + if (kIsDesktop) { + WidgetsBinding.instance.addPostFrameCallback((_) async { + wasMaximized.value = await windowManager.isMaximized(); + }); + } return null; }, []); final auth = ref.watch(authenticationProvider); - if (auth == null) { + if (auth.asData?.value == null) { return const Scaffold( appBar: PageWindowTitleBar(), body: AnonymousFallback(), @@ -77,12 +81,13 @@ class MiniLyricsPage extends HookConsumerWidget { firstChild: DragToMoveArea( child: Row( children: [ - const SizedBox(width: 10), - SizedBox( - height: 30, - width: 30, - child: Sidebar.brandLogo(), - ), + const Gap(10), + if (!kIsMacOS) + SizedBox( + height: 30, + width: 30, + child: Sidebar.brandLogo(), + ), const Spacer(), if (showLyrics.value) SizedBox( @@ -103,8 +108,7 @@ class MiniLyricsPage extends HookConsumerWidget { : const Icon(SpotubeIcons.lyricsOff), style: ButtonStyle( foregroundColor: showLyrics.value - ? MaterialStateProperty.all( - theme.colorScheme.primary) + ? WidgetStateProperty.all(theme.colorScheme.primary) : null, ), onPressed: () async { @@ -112,11 +116,13 @@ class MiniLyricsPage extends HookConsumerWidget { areaActive.value = true; hoverMode.value = false; - await DesktopTools.window.setSize( - showLyrics.value - ? const Size(400, 500) - : const Size(400, 150), - ); + if (kIsDesktop) { + await windowManager.setSize( + showLyrics.value + ? const Size(400, 500) + : const Size(400, 150), + ); + } }, ), IconButton( @@ -126,8 +132,7 @@ class MiniLyricsPage extends HookConsumerWidget { : const Icon(SpotubeIcons.hoverOff), style: ButtonStyle( foregroundColor: hoverMode.value - ? MaterialStateProperty.all( - theme.colorScheme.primary) + ? WidgetStateProperty.all(theme.colorScheme.primary) : null, ), onPressed: () async { @@ -135,33 +140,34 @@ class MiniLyricsPage extends HookConsumerWidget { hoverMode.value = !hoverMode.value; }, ), - FutureBuilder( - future: DesktopTools.window.isAlwaysOnTop(), - builder: (context, snapshot) { - return IconButton( - tooltip: context.l10n.always_on_top, - icon: Icon( - snapshot.data == true - ? SpotubeIcons.pinOn - : SpotubeIcons.pinOff, - ), - style: ButtonStyle( - foregroundColor: snapshot.data == true - ? MaterialStateProperty.all( - theme.colorScheme.primary) - : null, - ), - onPressed: snapshot.data == null - ? null - : () async { - await DesktopTools.window.setAlwaysOnTop( - snapshot.data == true ? false : true, - ); - update(); - }, - ); - }, - ), + if (kIsDesktop) + FutureBuilder( + future: windowManager.isAlwaysOnTop(), + builder: (context, snapshot) { + return IconButton( + tooltip: context.l10n.always_on_top, + icon: Icon( + snapshot.data == true + ? SpotubeIcons.pinOn + : SpotubeIcons.pinOff, + ), + style: ButtonStyle( + foregroundColor: snapshot.data == true + ? WidgetStateProperty.all( + theme.colorScheme.primary) + : null, + ), + onPressed: snapshot.data == null + ? null + : () async { + await windowManager.setAlwaysOnTop( + snapshot.data == true ? false : true, + ); + update(); + }, + ); + }, + ), ], ), ), @@ -179,12 +185,12 @@ class MiniLyricsPage extends HookConsumerWidget { child: TabBarView( children: [ SyncedLyrics( - palette: PaletteColor(theme.colorScheme.background, 0), + palette: PaletteColor(theme.colorScheme.surface, 0), isModal: true, defaultTextZoom: 65, ), PlainLyrics( - palette: PaletteColor(theme.colorScheme.background, 0), + palette: PaletteColor(theme.colorScheme.surface, 0), isModal: true, defaultTextZoom: 65, ), @@ -223,14 +229,13 @@ class MiniLyricsPage extends HookConsumerWidget { builder: (context) { return Consumer(builder: (context, ref, _) { final playlist = - ref.watch(proxyPlaylistProvider); + ref.watch(audioPlayerProvider); - return PlayerQueue - .fromProxyPlaylistNotifier( + return PlayerQueue.fromAudioPlayerNotifier( floating: true, playlist: playlist, notifier: ref - .read(proxyPlaylistProvider.notifier), + .read(audioPlayerProvider.notifier), ); }); }, @@ -238,24 +243,25 @@ class MiniLyricsPage extends HookConsumerWidget { } : null, ), - Flexible(child: PlayerControls(compact: true)), + const Flexible(child: PlayerControls(compact: true)), IconButton( tooltip: context.l10n.exit_mini_player, icon: const Icon(SpotubeIcons.maximize), onPressed: () async { + if (!kIsDesktop) return; + try { - await DesktopTools.window + await windowManager .setMinimumSize(const Size(300, 700)); - await DesktopTools.window.setAlwaysOnTop(false); + await windowManager.setAlwaysOnTop(false); if (wasMaximized.value) { - await DesktopTools.window.maximize(); + await windowManager.maximize(); } else { - await DesktopTools.window.setSize(prevSize); + await windowManager.setSize(prevSize); } - await DesktopTools.window - .setAlignment(Alignment.center); + await windowManager.setAlignment(Alignment.center); if (!kIsLinux) { - await DesktopTools.window.setHasShadow(true); + await windowManager.setHasShadow(true); } await Future.delayed( const Duration(milliseconds: 200)); diff --git a/lib/pages/lyrics/plain_lyrics.dart b/lib/pages/lyrics/plain_lyrics.dart index b3a55a275..7c571d5f3 100644 --- a/lib/pages/lyrics/plain_lyrics.dart +++ b/lib/pages/lyrics/plain_lyrics.dart @@ -5,13 +5,13 @@ import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:palette_generator/palette_generator.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/lyrics/zoom_controls.dart'; -import 'package:spotube/components/shared/shimmers/shimmer_lyrics.dart'; +import 'package:spotube/modules/lyrics/zoom_controls.dart'; +import 'package:spotube/components/shimmers/shimmer_lyrics.dart'; import 'package:spotube/extensions/artist_simple.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class PlainLyrics extends HookConsumerWidget { @@ -27,7 +27,7 @@ class PlainLyrics extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { - final playlist = ref.watch(proxyPlaylistProvider); + final playlist = ref.watch(audioPlayerProvider); final lyricsQuery = ref.watch(syncedLyricsProvider(playlist.activeTrack)); final mediaQuery = MediaQuery.of(context); final textTheme = Theme.of(context).textTheme; diff --git a/lib/pages/lyrics/synced_lyrics.dart b/lib/pages/lyrics/synced_lyrics.dart index 0e0fff2e4..643c10640 100644 --- a/lib/pages/lyrics/synced_lyrics.dart +++ b/lib/pages/lyrics/synced_lyrics.dart @@ -1,18 +1,20 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:palette_generator/palette_generator.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/lyrics/zoom_controls.dart'; -import 'package:spotube/components/shared/shimmers/shimmer_lyrics.dart'; +import 'package:spotube/modules/lyrics/zoom_controls.dart'; +import 'package:spotube/components/shimmers/shimmer_lyrics.dart'; import 'package:spotube/extensions/artist_simple.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/hooks/controllers/use_auto_scroll_controller.dart'; -import 'package:spotube/components/lyrics/use_synced_lyrics.dart'; +import 'package:spotube/modules/lyrics/use_synced_lyrics.dart'; import 'package:scroll_to_index/scroll_to_index.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; @@ -32,7 +34,7 @@ class SyncedLyrics extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { - final playlist = ref.watch(proxyPlaylistProvider); + final playlist = ref.watch(audioPlayerProvider); final mediaQuery = MediaQuery.of(context); final controller = useAutoScrollController(); @@ -54,9 +56,13 @@ class SyncedLyrics extends HookConsumerWidget { final textTheme = Theme.of(context).textTheme; ref.listen( - proxyPlaylistProvider.select((s) => s.activeTrack), + audioPlayerProvider.select((s) => s.activeTrack), (previous, next) { - controller.scrollToIndex(0); + controller.animateTo( + 0, + duration: const Duration(milliseconds: 500), + curve: Curves.easeInOut, + ); ref.read(syncedLyricsDelayProvider.notifier).state = 0; }, ); @@ -69,6 +75,23 @@ class SyncedLyrics extends HookConsumerWidget { final bodyTextTheme = textTheme.bodyLarge?.copyWith( color: palette.bodyTextColor, ); + + useEffect(() { + StreamSubscription? subscription; + WidgetsBinding.instance.addPostFrameCallback((_) { + subscription = audioPlayer.positionStream.listen((event) { + if (event > Duration.zero) return; + controller.animateTo( + 0, + duration: const Duration(milliseconds: 500), + curve: Curves.easeInOut, + ); + }); + }); + + return subscription?.cancel; + }, [controller]); + return Stack( children: [ CustomScrollView( @@ -80,7 +103,7 @@ class SyncedLyrics extends HookConsumerWidget { backgroundColor: Colors.transparent, centerTitle: true, title: Text( - playlist.activeTrack?.name ?? "Not Playing", + playlist.activeTrack?.name ?? context.l10n.not_playing, style: headlineTextStyle, ), bottom: PreferredSize( @@ -139,14 +162,12 @@ class SyncedLyrics extends HookConsumerWidget { textAlign: TextAlign.center, child: InkWell( onTap: () async { - final duration = - await audioPlayer.duration ?? - Duration.zero; final time = Duration( seconds: lyricSlice.time.inSeconds - delay, ); - if (time > duration || time.isNegative) { + if (time > audioPlayer.duration || + time.isNegative) { return; } audioPlayer.seek(time); diff --git a/lib/pages/mobile_login/mobile_login.dart b/lib/pages/mobile_login/mobile_login.dart index 0a1ff8b35..290c2b2f9 100644 --- a/lib/pages/mobile_login/mobile_login.dart +++ b/lib/pages/mobile_login/mobile_login.dart @@ -3,10 +3,11 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/utils/platform.dart'; class WebViewLogin extends HookConsumerWidget { + static const name = "login"; const WebViewLogin({super.key}); @override @@ -52,9 +53,7 @@ class WebViewLogin extends HookConsumerWidget { final cookieHeader = "sp_dc=${cookies.firstWhere((element) => element.name == "sp_dc").value}"; - authenticationNotifier.setCredentials( - await AuthenticationCredentials.fromCookie(cookieHeader), - ); + await authenticationNotifier.login(cookieHeader); if (context.mounted) { // ignore: use_build_context_synchronously GoRouter.of(context).go("/"); diff --git a/lib/pages/playlist/liked_playlist.dart b/lib/pages/playlist/liked_playlist.dart index 72983518a..942f46d50 100644 --- a/lib/pages/playlist/liked_playlist.dart +++ b/lib/pages/playlist/liked_playlist.dart @@ -1,11 +1,14 @@ import 'package:flutter/widgets.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/tracks_view/track_view.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_props.dart'; +import 'package:spotube/components/tracks_view/track_view.dart'; +import 'package:spotube/components/tracks_view/track_view_props.dart'; +import 'package:spotube/pages/playlist/playlist.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class LikedPlaylistPage extends HookConsumerWidget { + static const name = PlaylistPage.name; + final PlaylistSimple playlist; const LikedPlaylistPage({ super.key, @@ -18,7 +21,7 @@ class LikedPlaylistPage extends HookConsumerWidget { final tracks = likedTracks.asData?.value ?? []; return InheritedTrackView( - collectionId: playlist.id!, + collection: playlist, image: "assets/liked-tracks.jpg", pagination: PaginationProps( hasNextPage: false, diff --git a/lib/pages/playlist/playlist.dart b/lib/pages/playlist/playlist.dart index d9d224e04..e1b33e982 100644 --- a/lib/pages/playlist/playlist.dart +++ b/lib/pages/playlist/playlist.dart @@ -1,35 +1,52 @@ +import 'package:collection/collection.dart'; import 'package:flutter/material.dart' hide Page; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/dialogs/prompt_dialog.dart'; -import 'package:spotube/components/shared/tracks_view/sections/body/use_is_user_playlist.dart'; -import 'package:spotube/components/shared/tracks_view/track_view.dart'; -import 'package:spotube/components/shared/tracks_view/track_view_props.dart'; +import 'package:spotube/components/dialogs/prompt_dialog.dart'; +import 'package:spotube/components/tracks_view/sections/body/use_is_user_playlist.dart'; +import 'package:spotube/components/tracks_view/track_view.dart'; +import 'package:spotube/components/tracks_view/track_view_props.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class PlaylistPage extends HookConsumerWidget { - final PlaylistSimple playlist; + static const name = "playlist"; + + final PlaylistSimple _playlist; const PlaylistPage({ super.key, - required this.playlist, - }); + required PlaylistSimple playlist, + }) : _playlist = playlist; @override Widget build(BuildContext context, ref) { + final playlist = ref + .watch( + favoritePlaylistsProvider.select( + (value) => value.whenData( + (value) => + value.items.firstWhereOrNull((s) => s.id == _playlist.id), + ), + ), + ) + .asData + ?.value ?? + _playlist; + final tracks = ref.watch(playlistTracksProvider(playlist.id!)); final tracksNotifier = ref.watch(playlistTracksProvider(playlist.id!).notifier); final isFavoritePlaylist = ref.watch(isFavoritePlaylistProvider(playlist.id!)); + final favoritePlaylistsNotifier = ref.watch(favoritePlaylistsProvider.notifier); final isUserPlaylist = useIsUserPlaylist(ref, playlist.id!); return InheritedTrackView( - collectionId: playlist.id!, + collection: playlist, image: playlist.images.asUrlString( placeholder: ImagePlaceholder.collection, ), @@ -49,7 +66,8 @@ class PlaylistPage extends HookConsumerWidget { tracks: tracks.asData?.value.items ?? [], routePath: '/playlist/${playlist.id}', isLiked: isFavoritePlaylist.asData?.value ?? false, - shareUrl: playlist.externalUrls?.spotify ?? "", + shareUrl: playlist.externalUrls?.spotify ?? + "https://open.spotify.com/playlist/${playlist.id}", onHeart: isFavoritePlaylist.asData?.value == null ? null : () async { diff --git a/lib/pages/profile/profile.dart b/lib/pages/profile/profile.dart index 52b69835d..9e51793d0 100644 --- a/lib/pages/profile/profile.dart +++ b/lib/pages/profile/profile.dart @@ -7,13 +7,16 @@ import 'package:sliver_tools/sliver_tools.dart'; import 'package:spotube/collections/fake.dart'; import 'package:spotube/collections/spotify_markets.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:url_launcher/url_launcher_string.dart'; class ProfilePage extends HookConsumerWidget { + static const name = "profile"; + const ProfilePage({super.key}); @override @@ -25,21 +28,22 @@ class ProfilePage extends HookConsumerWidget { final userProperties = useMemoized( () => { - "Email": meData.email ?? "N/A", - "Followers": meData.followers?.total.toString() ?? "N/A", - "Birthday": meData.birthdate ?? "Not born", - "Country": spotifyMarkets + context.l10n.email: meData.email ?? "N/A", + context.l10n.profile_followers: + meData.followers?.total.toString() ?? "N/A", + context.l10n.birthday: meData.birthdate ?? context.l10n.not_born, + context.l10n.country: spotifyMarkets .firstWhere((market) => market.$1 == meData.country) .$2, - "Subscription": meData.product ?? "Hacker", + context.l10n.subscription: meData.product ?? context.l10n.hacker, }, [meData], ); return SafeArea( child: Scaffold( - appBar: const PageWindowTitleBar( - title: Text("Profile"), + appBar: PageWindowTitleBar( + title: Text(context.l10n.profile), titleSpacing: 0, automaticallyImplyLeading: true, centerTitle: false, @@ -70,7 +74,7 @@ class ProfilePage extends HookConsumerWidget { const SliverGap(10), SliverToBoxAdapter( child: Text( - meData.displayName ?? "No Name", + meData.displayName ?? context.l10n.no_name, style: textTheme.titleLarge, textAlign: TextAlign.center, ), @@ -83,7 +87,7 @@ class ProfilePage extends HookConsumerWidget { mainAxisAlignment: MainAxisAlignment.end, children: [ TextButton.icon( - label: const Text("Edit"), + label: Text(context.l10n.edit), icon: const Icon(SpotubeIcons.edit), onPressed: () { launchUrlString( diff --git a/lib/pages/root/root_app.dart b/lib/pages/root/root_app.dart index 56ea43a64..f7aedf63e 100644 --- a/lib/pages/root/root_app.dart +++ b/lib/pages/root/root_app.dart @@ -2,32 +2,24 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/player/player_queue.dart'; -import 'package:spotube/components/shared/dialogs/replace_downloaded_dialog.dart'; -import 'package:spotube/components/root/bottom_player.dart'; -import 'package:spotube/components/root/sidebar.dart'; -import 'package:spotube/components/root/spotube_navigation_bar.dart'; +import 'package:spotube/modules/player/player_queue.dart'; +import 'package:spotube/components/dialogs/replace_downloaded_dialog.dart'; +import 'package:spotube/modules/root/bottom_player.dart'; +import 'package:spotube/modules/root/sidebar.dart'; +import 'package:spotube/modules/root/spotube_navigation_bar.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/hooks/configurators/use_endless_playback.dart'; -import 'package:spotube/hooks/configurators/use_update_checker.dart'; -import 'package:spotube/provider/connect/server.dart'; +import 'package:spotube/pages/home/home.dart'; import 'package:spotube/provider/download_manager_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/provider/server/routes/connect.dart'; import 'package:spotube/services/connectivity_adapter.dart'; -import 'package:spotube/utils/persisted_state_notifier.dart'; - -const rootPaths = { - "/": 0, - "/search": 1, - "/library": 2, - "/lyrics": 3, -}; +import 'package:spotube/utils/platform.dart'; +import 'package:spotube/utils/service_utils.dart'; class RootApp extends HookConsumerWidget { final Widget child; @@ -38,21 +30,15 @@ class RootApp extends HookConsumerWidget { @override Widget build(BuildContext context, ref) { - final isMounted = useIsMounted(); final showingDialogCompleter = useRef(Completer()..complete()); final downloader = ref.watch(downloadManagerProvider); final scaffoldMessenger = ScaffoldMessenger.of(context); final theme = Theme.of(context); - final location = GoRouterState.of(context).matchedLocation; + final connectRoutes = ref.watch(serverConnectRoutesProvider); useEffect(() { WidgetsBinding.instance.addPostFrameCallback((_) async { - final sharedPreferences = await SharedPreferences.getInstance(); - - if (sharedPreferences.getBool(kIsUsingEncryption) == false && - context.mounted) { - await PersistedStateNotifier.showNoEncryptionDialog(context); - } + ServiceUtils.checkForUpdates(context, ref); }); final subscriptions = [ @@ -96,7 +82,7 @@ class RootApp extends HookConsumerWidget { ); } }), - connectClientStream.listen((clientOrigin) { + connectRoutes.connectClientStream.listen((clientOrigin) { scaffoldMessenger.showSnackBar( SnackBar( backgroundColor: Colors.yellow[600], @@ -129,7 +115,7 @@ class RootApp extends HookConsumerWidget { useEffect(() { downloader.onFileExists = (track) async { - if (!isMounted()) return false; + if (!context.mounted) return false; if (!showingDialogCompleter.value.isCompleted) { await showingDialogCompleter.value.future; @@ -161,7 +147,6 @@ class RootApp extends HookConsumerWidget { }, [downloader]); // checks for latest version of the application - useUpdateChecker(ref); useEndlessPlayback(ref); @@ -179,35 +164,21 @@ class RootApp extends HookConsumerWidget { return null; }, [backgroundColor]); - void onSelectIndexChanged(int d) { - final invertedRouteMap = - rootPaths.map((key, value) => MapEntry(value, key)); - - if (context.mounted) { - WidgetsBinding.instance.addPostFrameCallback((_) { - GoRouter.of(context).go(invertedRouteMap[d]!); - }); - } - } - // ignore: deprecated_member_use return WillPopScope( onWillPop: () async { - if (rootPaths[location] != 0) { - onSelectIndexChanged(0); + final routerState = GoRouterState.of(context); + if (routerState.matchedLocation != "/") { + context.goNamed(HomePage.name); return false; } return true; }, child: Scaffold( - body: Sidebar( - selectedIndex: rootPaths[location], - onSelectedIndexChanged: onSelectIndexChanged, - child: child, - ), + body: Sidebar(child: child), extendBody: true, drawerScrimColor: Colors.transparent, - endDrawer: DesktopTools.platform.isDesktop + endDrawer: kIsDesktop ? Container( constraints: const BoxConstraints(maxWidth: 800), decoration: BoxDecoration( @@ -221,11 +192,11 @@ class RootApp extends HookConsumerWidget { ), child: Consumer( builder: (context, ref, _) { - final playlist = ref.watch(proxyPlaylistProvider); + final playlist = ref.watch(audioPlayerProvider); final playlistNotifier = - ref.read(proxyPlaylistProvider.notifier); + ref.read(audioPlayerProvider.notifier); - return PlayerQueue.fromProxyPlaylistNotifier( + return PlayerQueue.fromAudioPlayerNotifier( floating: true, playlist: playlist, notifier: playlistNotifier, @@ -234,14 +205,11 @@ class RootApp extends HookConsumerWidget { ), ) : null, - bottomNavigationBar: Column( + bottomNavigationBar: const Column( mainAxisSize: MainAxisSize.min, children: [ BottomPlayer(), - SpotubeNavigationBar( - selectedIndex: rootPaths[location], - onSelectedIndexChanged: onSelectIndexChanged, - ), + SpotubeNavigationBar(), ], ), ), diff --git a/lib/pages/search/search.dart b/lib/pages/search/search.dart index e9ada2365..d5de12f0e 100644 --- a/lib/pages/search/search.dart +++ b/lib/pages/search/search.dart @@ -5,13 +5,14 @@ import 'package:flutter/material.dart' hide Page; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:fuzzywuzzy/fuzzywuzzy.dart'; import 'package:gap/gap.dart'; +import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart'; -import 'package:spotube/components/shared/fallbacks/anonymous_fallback.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart'; +import 'package:spotube/components/fallbacks/anonymous_fallback.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/hooks/utils/use_force_update.dart'; @@ -19,13 +20,15 @@ import 'package:spotube/pages/search/sections/albums.dart'; import 'package:spotube/pages/search/sections/artists.dart'; import 'package:spotube/pages/search/sections/playlists.dart'; import 'package:spotube/pages/search/sections/tracks.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:spotube/services/kv_store/kv_store.dart'; import 'package:spotube/utils/platform.dart'; class SearchPage extends HookConsumerWidget { + static const name = "search"; + const SearchPage({super.key}); @override @@ -34,8 +37,7 @@ class SearchPage extends HookConsumerWidget { final searchTerm = ref.watch(searchTermStateProvider); final controller = useSearchController(); - ref.watch(authenticationProvider); - final authenticationNotifier = ref.watch(authenticationProvider.notifier); + final auth = ref.watch(authenticationProvider); final mediaQuery = MediaQuery.of(context); final searchTrack = ref.watch(searchProvider(SearchType.track)); @@ -85,99 +87,117 @@ class SearchPage extends HookConsumerWidget { return SafeArea( bottom: false, child: Scaffold( - appBar: kIsDesktop && !kIsMacOS ? const PageWindowTitleBar() : null, - body: !authenticationNotifier.isLoggedIn + appBar: kIsDesktop && !kIsMacOS + ? const PageWindowTitleBar(automaticallyImplyLeading: true) + : null, + body: auth.asData?.value == null ? const AnonymousFallback() : Column( children: [ - Container( - padding: const EdgeInsets.symmetric( - horizontal: 20, - vertical: 10, - ), - color: theme.scaffoldBackgroundColor, - child: SearchAnchor( - searchController: controller, - viewBuilder: (_) => HookBuilder(builder: (context) { - final searchController = useListenable(controller); - final update = useForceUpdate(); - final suggestions = searchController.text.isEmpty - ? KVStoreService.recentSearches - : KVStoreService.recentSearches - .where( - (s) => - weightedRatio( - s.toLowerCase(), - searchController.text.toLowerCase(), - ) > - 50, - ) - .toList(); - - return ListView.builder( - itemCount: suggestions.length, - itemBuilder: (context, index) { - final suggestion = suggestions[index]; - - return ListTile( - leading: const Icon(SpotubeIcons.history), - title: Text(suggestion), - trailing: IconButton( - icon: const Icon(SpotubeIcons.trash), - onPressed: () { + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if ((kIsMobile || kIsMacOS) && context.canPop()) + const BackButton() + else + const Gap(20), + Expanded( + child: Padding( + padding: const EdgeInsets.only( + right: 20, + top: 20, + bottom: 20, + ), + child: SearchAnchor( + searchController: controller, + viewBuilder: (_) => HookBuilder(builder: (context) { + final searchController = + useListenable(controller); + final update = useForceUpdate(); + final suggestions = searchController.text.isEmpty + ? KVStoreService.recentSearches + : KVStoreService.recentSearches + .where( + (s) => + weightedRatio( + s.toLowerCase(), + searchController.text + .toLowerCase(), + ) > + 50, + ) + .toList(); + + return ListView.builder( + itemCount: suggestions.length, + itemBuilder: (context, index) { + final suggestion = suggestions[index]; + + return ListTile( + leading: const Icon(SpotubeIcons.history), + title: Text(suggestion), + trailing: IconButton( + icon: const Icon(SpotubeIcons.trash), + onPressed: () { + KVStoreService.setRecentSearches( + KVStoreService.recentSearches + .where((s) => s != suggestion) + .toList(), + ); + update(); + }, + ), + onTap: () { + controller.closeView(suggestion); + ref + .read( + searchTermStateProvider.notifier) + .state = suggestion; + }, + ); + }, + ); + }), + suggestionsBuilder: (context, controller) { + return []; + }, + viewOnSubmitted: (value) async { + controller.closeView(value); + Timer( + const Duration(milliseconds: 50), + () { + ref + .read(searchTermStateProvider.notifier) + .state = value; + if (value.trim().isEmpty) { + return; + } KVStoreService.setRecentSearches( - KVStoreService.recentSearches - .where((s) => s != suggestion) - .toList(), + { + value, + ...KVStoreService.recentSearches, + }.toList(), ); - update(); }, - ), - onTap: () { - controller.closeView(suggestion); - ref - .read(searchTermStateProvider.notifier) - .state = suggestion; - }, - ); - }, - ); - }), - suggestionsBuilder: (context, controller) { - return []; - }, - viewOnSubmitted: (value) async { - controller.closeView(value); - Timer( - const Duration(milliseconds: 50), - () { - ref.read(searchTermStateProvider.notifier).state = - value; - if (value.trim().isEmpty) { - return; - } - KVStoreService.setRecentSearches( - { - value, - ...KVStoreService.recentSearches, - }.toList(), - ); - }, - ); - }, - builder: (context, controller) { - return SearchBar( - autoFocus: queries.none((s) => - s.asData?.value != null && !s.hasError) && - !kIsMobile, - controller: controller, - leading: const Icon(SpotubeIcons.search), - hintText: "${context.l10n.search}...", - onTap: controller.openView, - onChanged: (_) => controller.openView(), - ); - }, - ), + ); + }, + builder: (context, controller) { + return SearchBar( + autoFocus: queries.none((s) => + s.asData?.value != null && + !s.hasError) && + !kIsMobile, + controller: controller, + leading: const Icon(SpotubeIcons.search), + hintText: "${context.l10n.search}...", + onTap: controller.openView, + onChanged: (_) => controller.openView(), + ); + }, + ), + ), + ), + ], ), Expanded( child: AnimatedSwitcher( @@ -191,7 +211,7 @@ class SearchPage extends HookConsumerWidget { Icon( SpotubeIcons.web, size: 120, - color: theme.colorScheme.onBackground + color: theme.colorScheme.onSurface .withOpacity(0.7), ), const SizedBox(height: 20), @@ -199,7 +219,7 @@ class SearchPage extends HookConsumerWidget { context.l10n.search_to_get_results, style: theme.textTheme.titleLarge?.copyWith( fontWeight: FontWeight.w900, - color: theme.colorScheme.onBackground + color: theme.colorScheme.onSurface .withOpacity(0.5), ), ), @@ -225,7 +245,7 @@ class SearchPage extends HookConsumerWidget { style: TextStyle( fontSize: 20, fontWeight: FontWeight.w900, - color: theme.colorScheme.onBackground + color: theme.colorScheme.onSurface .withOpacity(0.7), ), ), diff --git a/lib/pages/search/sections/albums.dart b/lib/pages/search/sections/albums.dart index d15c34ff3..857eb59ca 100644 --- a/lib/pages/search/sections/albums.dart +++ b/lib/pages/search/sections/albums.dart @@ -3,7 +3,7 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; +import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; import 'package:spotube/extensions/album_simple.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/spotify/spotify.dart'; diff --git a/lib/pages/search/sections/artists.dart b/lib/pages/search/sections/artists.dart index bb8063dcf..162955804 100644 --- a/lib/pages/search/sections/artists.dart +++ b/lib/pages/search/sections/artists.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart' hide Page; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; +import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/spotify/spotify.dart'; diff --git a/lib/pages/search/sections/playlists.dart b/lib/pages/search/sections/playlists.dart index 13ff483d3..3799f9fa0 100644 --- a/lib/pages/search/sections/playlists.dart +++ b/lib/pages/search/sections/playlists.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart' hide Page; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; +import 'package:spotube/components/horizontal_playbutton_card_view/horizontal_playbutton_card_view.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/spotify/spotify.dart'; diff --git a/lib/pages/search/sections/tracks.dart b/lib/pages/search/sections/tracks.dart index 48dabc139..6ec8f685e 100644 --- a/lib/pages/search/sections/tracks.dart +++ b/lib/pages/search/sections/tracks.dart @@ -2,13 +2,13 @@ import 'package:collection/collection.dart'; import 'package:flutter/material.dart' hide Page; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/dialogs/prompt_dialog.dart'; -import 'package:spotube/components/shared/dialogs/select_device_dialog.dart'; -import 'package:spotube/components/shared/track_tile/track_tile.dart'; +import 'package:spotube/components/dialogs/prompt_dialog.dart'; +import 'package:spotube/components/dialogs/select_device_dialog.dart'; +import 'package:spotube/components/track_tile/track_tile.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/models/connect/connect.dart'; import 'package:spotube/provider/connect/connect.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/spotify/spotify.dart'; class SearchTracksSection extends HookConsumerWidget { @@ -24,8 +24,8 @@ class SearchTracksSection extends HookConsumerWidget { ref.watch(searchProvider(SearchType.track).notifier); final tracks = searchTrack.asData?.value.items.cast() ?? []; - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); - final playlist = ref.watch(proxyPlaylistProvider); + final playlistNotifier = ref.watch(audioPlayerProvider.notifier); + final playlist = ref.watch(audioPlayerProvider); final theme = Theme.of(context); return Column( @@ -76,7 +76,7 @@ class SearchTracksSection extends HookConsumerWidget { if (shouldPlay) { await remotePlayback.load( - WebSocketLoadEventData( + WebSocketLoadEventData.playlist( tracks: [track], ), ); @@ -113,7 +113,7 @@ class SearchTracksSection extends HookConsumerWidget { child: TextButton( onPressed: searchTrack.isLoadingNextPage ? null - : () => searchTrackNotifier.fetchMore, + : searchTrackNotifier.fetchMore, child: searchTrack.isLoadingNextPage ? const CircularProgressIndicator() : Text(context.l10n.load_more), diff --git a/lib/pages/settings/about.dart b/lib/pages/settings/about.dart index 21b8117b1..4d093cfe5 100644 --- a/lib/pages/settings/about.dart +++ b/lib/pages/settings/about.dart @@ -1,9 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:spotube/collections/assets.gen.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/links/hyper_link.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/collections/env.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/links/hyper_link.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/hooks/controllers/use_package_info.dart'; @@ -16,6 +17,8 @@ final _licenseProvider = FutureProvider((ref) async { }); class AboutSpotube extends HookConsumerWidget { + static const name = "about"; + const AboutSpotube({super.key}); @override @@ -72,6 +75,13 @@ class AboutSpotube extends HookConsumerWidget { Text("v${packageInfo.version}") ], ), + TableRow( + children: [ + Text(context.l10n.channel), + colon, + Text(Env.releaseChannel.name) + ], + ), TableRow( children: [ Text(context.l10n.build_number), diff --git a/lib/pages/settings/blacklist.dart b/lib/pages/settings/blacklist.dart index 9dd85c507..1f018dab6 100644 --- a/lib/pages/settings/blacklist.dart +++ b/lib/pages/settings/blacklist.dart @@ -5,12 +5,14 @@ import 'package:fuzzywuzzy/fuzzywuzzy.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/blacklist_provider.dart'; class BlackListPage extends HookConsumerWidget { + static const name = "blacklist"; + const BlackListPage({super.key}); @override @@ -22,19 +24,21 @@ class BlackListPage extends HookConsumerWidget { final filteredBlacklist = useMemoized( () { if (searchText.value.isEmpty) { - return blacklist; + return blacklist.asData?.value ?? []; } - return blacklist - .map( - (e) => ( - weightedRatio("${e.name} ${e.type.name}", searchText.value), - e, - ), - ) - .sorted((a, b) => b.$1.compareTo(a.$1)) - .where((e) => e.$1 > 50) - .map((e) => e.$2) - .toList(); + return blacklist.asData?.value + .map( + (e) => ( + weightedRatio( + "${e.name} ${e.elementType.name}", searchText.value), + e, + ), + ) + .sorted((a, b) => b.$1.compareTo(a.$1)) + .where((e) => e.$1 > 50) + .map((e) => e.$2) + .toList() ?? + []; }, [blacklist, searchText.value], ); @@ -68,14 +72,14 @@ class BlackListPage extends HookConsumerWidget { final item = filteredBlacklist.elementAt(index); return ListTile( leading: Text("${index + 1}."), - title: Text("${item.name} (${item.type.name})"), - subtitle: Text(item.id), + title: Text("${item.name} (${item.elementType.name})"), + subtitle: Text(item.elementId), trailing: IconButton( icon: Icon(SpotubeIcons.trash, color: Colors.red[400]), onPressed: () { ref .read(blacklistProvider.notifier) - .remove(filteredBlacklist.elementAt(index)); + .remove(filteredBlacklist.elementAt(index).elementId); }, ), ); diff --git a/lib/pages/settings/logs.dart b/lib/pages/settings/logs.dart index b07ebbb1a..91087b7e6 100644 --- a/lib/pages/settings/logs.dart +++ b/lib/pages/settings/logs.dart @@ -1,75 +1,23 @@ -import 'dart:async'; -import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/settings/section_card_with_heading.dart'; -import 'package:spotube/components/shared/inter_scrollbar/inter_scrollbar.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/components/inter_scrollbar/inter_scrollbar.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/models/logger.dart'; +import 'package:spotube/provider/logs/logs_provider.dart'; -class LogsPage extends HookWidget { - const LogsPage({super.key}); - - List<({DateTime? date, String body})> parseLogs(String raw) { - return raw - .split( - "======================================================================", - ) - .map( - (line) { - DateTime? date; - line = line - .replaceAll( - "============================== CATCHER LOG ==============================", - "", - ) - .split("\n") - .map((l) { - if (l.startsWith("Crash occurred on")) { - date = DateTime.parse( - l.split("Crash occurred on")[1].trim(), - ); - return ""; - } - return l; - }) - .where((l) => l.replaceAll("\n", "").trim().isNotEmpty) - .join("\n"); +class LogsPage extends HookConsumerWidget { + static const name = "logs"; - return ( - date: date, - body: line, - ); - }, - ) - .where((e) => e.date != null && e.body.isNotEmpty) - .toList() - ..sort((a, b) => b.date!.compareTo(a.date!)); - } + const LogsPage({super.key}); @override - Widget build(BuildContext context) { + Widget build(BuildContext context, ref) { final controller = useScrollController(); - final logs = useState>([]); - final rawLogs = useRef(""); - final path = useRef(null); - - useEffect(() { - final timer = Timer.periodic(const Duration(seconds: 5), (t) async { - path.value ??= await getLogsPath(); - final raw = await path.value!.readAsString(); - final hasChanged = rawLogs.value != raw; - rawLogs.value = raw; - if (hasChanged) logs.value = parseLogs(rawLogs.value); - }); - return () { - timer.cancel(); - }; - }, []); + final logsQuery = ref.watch(logsProvider); return Scaffold( appBar: PageWindowTitleBar( @@ -80,7 +28,9 @@ class LogsPage extends HookWidget { icon: const Icon(SpotubeIcons.clipboard), iconSize: 16, onPressed: () async { - await Clipboard.setData(ClipboardData(text: rawLogs.value)); + final logsSnapshot = await ref.read(logsProvider.future); + + await Clipboard.setData(ClipboardData(text: logsSnapshot)); if (context.mounted) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -93,52 +43,22 @@ class LogsPage extends HookWidget { ], ), body: SafeArea( - child: InterScrollbar( - controller: controller, - child: ListView.builder( - controller: controller, - itemCount: logs.value.length, - itemBuilder: (context, index) { - final log = logs.value[index]; - return Stack( - children: [ - SectionCardWithHeading( - heading: log.date.toString(), - children: [ - Padding( - padding: const EdgeInsets.all(12.0), - child: SelectableText(log.body), - ), - ], - ), - Positioned( - right: 10, - top: 0, - child: IconButton( - icon: const Icon(SpotubeIcons.clipboard), - onPressed: () async { - await Clipboard.setData( - ClipboardData(text: log.body), - ); - if (context.mounted) { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - context.l10n.copied_to_clipboard( - log.date.toString(), - ), - ), - ), - ); - } - }, - ), + child: switch (logsQuery) { + AsyncData(:final value) => Card( + child: InterScrollbar( + controller: controller, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: SingleChildScrollView( + controller: controller, + child: Text(value), ), - ], - ); - }, - ), - ), + ), + ), + ), + AsyncError(:final error) => Center(child: Text(error.toString())), + _ => const Center(child: CircularProgressIndicator()), + }, ), ); } diff --git a/lib/pages/settings/sections/about.dart b/lib/pages/settings/sections/about.dart index a8d72cc0d..dfb5272b5 100644 --- a/lib/pages/settings/sections/about.dart +++ b/lib/pages/settings/sections/about.dart @@ -4,8 +4,8 @@ import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/env.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/settings/section_card_with_heading.dart'; -import 'package:spotube/components/shared/adaptive/adaptive_list_tile.dart'; +import 'package:spotube/modules/settings/section_card_with_heading.dart'; +import 'package:spotube/components/adaptive/adaptive_list_tile.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; import 'package:url_launcher/url_launcher_string.dart'; @@ -43,10 +43,9 @@ class SettingsAboutSection extends HookConsumerWidget { ), trailing: (context, update) => FilledButton( style: ButtonStyle( - backgroundColor: MaterialStatePropertyAll(Colors.red[100]), - foregroundColor: - const MaterialStatePropertyAll(Colors.pinkAccent), - padding: const MaterialStatePropertyAll(EdgeInsets.all(15)), + backgroundColor: WidgetStatePropertyAll(Colors.red[100]), + foregroundColor: const WidgetStatePropertyAll(Colors.pinkAccent), + padding: const WidgetStatePropertyAll(EdgeInsets.all(15)), ), onPressed: () { launchUrlString( diff --git a/lib/pages/settings/sections/accounts.dart b/lib/pages/settings/sections/accounts.dart index ab3a7c92f..c670e96dd 100644 --- a/lib/pages/settings/sections/accounts.dart +++ b/lib/pages/settings/sections/accounts.dart @@ -1,13 +1,25 @@ +import 'dart:io'; + import 'package:auto_size_text/auto_size_text.dart'; +import 'package:desktop_webview_window/desktop_webview_window.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:path/path.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/settings/section_card_with_heading.dart'; +import 'package:spotube/modules/settings/section_card_with_heading.dart'; +import 'package:spotube/components/image/universal_image.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; -import 'package:spotube/provider/authentication_provider.dart'; -import 'package:spotube/provider/scrobbler_provider.dart'; +import 'package:spotube/extensions/image.dart'; +import 'package:spotube/pages/mobile_login/mobile_login.dart'; +import 'package:spotube/pages/profile/profile.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; +import 'package:spotube/provider/scrobbler/scrobbler.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; +import 'package:spotube/utils/platform.dart'; +import 'package:spotube/utils/service_utils.dart'; class SettingsAccountSection extends HookConsumerWidget { const SettingsAccountSection({super.key}); @@ -15,19 +27,87 @@ class SettingsAccountSection extends HookConsumerWidget { @override Widget build(context, ref) { final theme = Theme.of(context); + final router = GoRouter.of(context); + final auth = ref.watch(authenticationProvider); + final authNotifier = ref.watch(authenticationProvider.notifier); final scrobbler = ref.watch(scrobblerProvider); - final router = GoRouter.of(context); + final me = ref.watch(meProvider); + final meData = me.asData?.value; final logoutBtnStyle = FilledButton.styleFrom( backgroundColor: Colors.red, foregroundColor: Colors.white, ); + void onLogin() async { + if (kIsMobile) { + router.pushNamed(WebViewLogin.name); + return; + } + + final exp = RegExp(r"https:\/\/accounts.spotify.com\/.+\/status"); + final applicationSupportDir = await getApplicationSupportDirectory(); + final userDataFolder = Directory( + join(applicationSupportDir.path, "webview_window_Webview2")); + + if (!await userDataFolder.exists()) { + await userDataFolder.create(); + } + + final webview = await WebviewWindow.create( + configuration: CreateConfiguration( + title: "Spotify Login", + titleBarTopPadding: kIsMacOS ? 20 : 0, + windowHeight: 720, + windowWidth: 1280, + userDataFolderWindows: userDataFolder.path, + ), + ); + webview + ..setBrightness(theme.colorScheme.brightness) + ..launch("https://accounts.spotify.com/") + ..setOnUrlRequestCallback((url) { + if (exp.hasMatch(url)) { + webview.getAllCookies().then((cookies) async { + final cookieHeader = + "sp_dc=${cookies.firstWhere((element) => element.name.contains("sp_dc")).value.replaceAll("\u0000", "")}"; + + await authNotifier.login(cookieHeader); + + webview.close(); + if (context.mounted) { + context.go("/"); + } + }); + } + + return true; + }); + } + return SectionCardWithHeading( heading: context.l10n.account, children: [ - if (auth == null) + if (auth.asData?.value != null) + ListTile( + leading: const Icon(SpotubeIcons.user), + title: Text(context.l10n.user_profile), + trailing: Padding( + padding: const EdgeInsets.all(8.0), + child: CircleAvatar( + backgroundImage: UniversalImage.imageProvider( + (meData?.images).asUrlString( + placeholder: ImagePlaceholder.artist, + ), + ), + ), + ), + onTap: () { + ServiceUtils.pushNamed(context, ProfilePage.name); + }, + ), + if (auth.asData?.value == null) LayoutBuilder(builder: (context, constrains) { return ListTile( leading: Icon( @@ -44,19 +124,13 @@ class SettingsAccountSection extends HookConsumerWidget { ), ), ), - onTap: constrains.mdAndUp - ? null - : () { - router.push("/login"); - }, + onTap: constrains.mdAndUp ? null : onLogin, trailing: constrains.smAndDown ? null : FilledButton( - onPressed: () { - router.push("/login"); - }, + onPressed: onLogin, style: ButtonStyle( - shape: MaterialStateProperty.all( + shape: WidgetStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(25.0), ), @@ -93,7 +167,7 @@ class SettingsAccountSection extends HookConsumerWidget { ), ); }), - if (scrobbler == null) + if (scrobbler.asData?.value == null) ListTile( leading: const Icon(SpotubeIcons.lastFm), title: Text(context.l10n.login_with_lastfm), diff --git a/lib/pages/settings/sections/appearance.dart b/lib/pages/settings/sections/appearance.dart index 25bd40052..f97add426 100644 --- a/lib/pages/settings/sections/appearance.dart +++ b/lib/pages/settings/sections/appearance.dart @@ -3,12 +3,12 @@ import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/settings/color_scheme_picker_dialog.dart'; -import 'package:spotube/components/settings/section_card_with_heading.dart'; -import 'package:spotube/components/shared/adaptive/adaptive_select_tile.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/modules/settings/color_scheme_picker_dialog.dart'; +import 'package:spotube/modules/settings/section_card_with_heading.dart'; +import 'package:spotube/components/adaptive/adaptive_select_tile.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; class SettingsAppearanceSection extends HookConsumerWidget { final bool isGettingStarted; diff --git a/lib/pages/settings/sections/desktop.dart b/lib/pages/settings/sections/desktop.dart index 4e4408d9b..c61f01500 100644 --- a/lib/pages/settings/sections/desktop.dart +++ b/lib/pages/settings/sections/desktop.dart @@ -1,13 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; import 'package:gap/gap.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/settings/section_card_with_heading.dart'; -import 'package:spotube/components/shared/adaptive/adaptive_select_tile.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/modules/settings/section_card_with_heading.dart'; +import 'package:spotube/components/adaptive/adaptive_select_tile.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; class SettingsDesktopSection extends HookConsumerWidget { const SettingsDesktopSection({super.key}); @@ -53,13 +52,12 @@ class SettingsDesktopSection extends HookConsumerWidget { value: preferences.systemTitleBar, onChanged: preferencesNotifier.setSystemTitleBar, ), - if (!DesktopTools.platform.isMacOS) - SwitchListTile( - secondary: const Icon(SpotubeIcons.discord), - title: Text(context.l10n.discord_rich_presence), - value: preferences.discordPresence, - onChanged: preferencesNotifier.setDiscordPresence, - ), + SwitchListTile( + secondary: const Icon(SpotubeIcons.discord), + title: Text(context.l10n.discord_rich_presence), + value: preferences.discordPresence, + onChanged: preferencesNotifier.setDiscordPresence, + ), ], ); } diff --git a/lib/pages/settings/sections/developers.dart b/lib/pages/settings/sections/developers.dart index a22cf9f13..f33fe8437 100644 --- a/lib/pages/settings/sections/developers.dart +++ b/lib/pages/settings/sections/developers.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:go_router/go_router.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/settings/section_card_with_heading.dart'; +import 'package:spotube/modules/settings/section_card_with_heading.dart'; import 'package:spotube/extensions/context.dart'; class SettingsDevelopersSection extends HookWidget { diff --git a/lib/pages/settings/sections/downloads.dart b/lib/pages/settings/sections/downloads.dart index 1f25028ec..8e679a7d5 100644 --- a/lib/pages/settings/sections/downloads.dart +++ b/lib/pages/settings/sections/downloads.dart @@ -1,13 +1,13 @@ import 'package:file_picker/file_picker.dart'; import 'package:file_selector/file_selector.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/settings/section_card_with_heading.dart'; +import 'package:spotube/modules/settings/section_card_with_heading.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +import 'package:spotube/utils/platform.dart'; class SettingsDownloadsSection extends HookConsumerWidget { const SettingsDownloadsSection({super.key}); @@ -18,7 +18,7 @@ class SettingsDownloadsSection extends HookConsumerWidget { final preferences = ref.watch(userPreferencesProvider); final pickDownloadLocation = useCallback(() async { - if (DesktopTools.platform.isMobile || DesktopTools.platform.isMacOS) { + if (kIsMobile || kIsMacOS) { final dirStr = await FilePicker.platform.getDirectoryPath( initialDirectory: preferences.downloadLocation, ); diff --git a/lib/pages/settings/sections/language_region.dart b/lib/pages/settings/sections/language_region.dart index 76670c771..18c2d088e 100644 --- a/lib/pages/settings/sections/language_region.dart +++ b/lib/pages/settings/sections/language_region.dart @@ -5,8 +5,8 @@ import 'package:spotify/spotify.dart'; import 'package:spotube/collections/language_codes.dart'; import 'package:spotube/collections/spotify_markets.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/settings/section_card_with_heading.dart'; -import 'package:spotube/components/shared/adaptive/adaptive_select_tile.dart'; +import 'package:spotube/modules/settings/section_card_with_heading.dart'; +import 'package:spotube/components/adaptive/adaptive_select_tile.dart'; import 'package:spotube/extensions/constrains.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/l10n/l10n.dart'; @@ -57,7 +57,7 @@ class SettingsLanguageRegionSection extends HookConsumerWidget { secondary: const Icon(SpotubeIcons.shoppingBag), title: Text(context.l10n.market_place_region), subtitle: Text(context.l10n.recommendation_country), - value: preferences.recommendationMarket, + value: preferences.market, onChanged: (value) { if (value == null) return; preferencesNotifier.setRecommendationMarket(value); diff --git a/lib/pages/settings/sections/playback.dart b/lib/pages/settings/sections/playback.dart index eeae98cbd..6273c557f 100644 --- a/lib/pages/settings/sections/playback.dart +++ b/lib/pages/settings/sections/playback.dart @@ -6,12 +6,13 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:piped_client/piped_client.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/settings/section_card_with_heading.dart'; -import 'package:spotube/components/shared/adaptive/adaptive_select_tile.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/modules/settings/section_card_with_heading.dart'; +import 'package:spotube/components/adaptive/adaptive_select_tile.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/provider/piped_instances_provider.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; + import 'package:spotube/services/sourced_track/enums.dart'; class SettingsPlaybackSection extends HookConsumerWidget { diff --git a/lib/pages/settings/settings.dart b/lib/pages/settings/settings.dart index d2a750573..8bce4bcfd 100644 --- a/lib/pages/settings/settings.dart +++ b/lib/pages/settings/settings.dart @@ -1,9 +1,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/pages/settings/sections/about.dart'; import 'package:spotube/pages/settings/sections/accounts.dart'; @@ -14,8 +13,11 @@ import 'package:spotube/pages/settings/sections/downloads.dart'; import 'package:spotube/pages/settings/sections/language_region.dart'; import 'package:spotube/pages/settings/sections/playback.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +import 'package:spotube/utils/platform.dart'; class SettingsPage extends HookConsumerWidget { + static const name = "settings"; + const SettingsPage({super.key}); @override @@ -29,6 +31,7 @@ class SettingsPage extends HookConsumerWidget { appBar: PageWindowTitleBar( title: Text(context.l10n.settings), centerTitle: true, + automaticallyImplyLeading: true, ), body: Scrollbar( controller: controller, @@ -45,8 +48,7 @@ class SettingsPage extends HookConsumerWidget { const SettingsAppearanceSection(), const SettingsPlaybackSection(), const SettingsDownloadsSection(), - if (DesktopTools.platform.isDesktop) - const SettingsDesktopSection(), + if (kIsDesktop) const SettingsDesktopSection(), if (!kIsWeb) const SettingsDevelopersSection(), const SettingsAboutSection(), Center( diff --git a/lib/pages/stats/albums/albums.dart b/lib/pages/stats/albums/albums.dart new file mode 100644 index 000000000..e14a2f320 --- /dev/null +++ b/lib/pages/stats/albums/albums.dart @@ -0,0 +1,55 @@ +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotube/collections/formatters.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/modules/stats/common/album_item.dart'; +import 'package:spotube/extensions/context.dart'; + +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/history/top/albums.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; +import 'package:very_good_infinite_list/very_good_infinite_list.dart'; + +class StatsAlbumsPage extends HookConsumerWidget { + static const name = "stats_albums"; + const StatsAlbumsPage({super.key}); + + @override + Widget build(BuildContext context, ref) { + final topAlbums = + ref.watch(historyTopAlbumsProvider(HistoryDuration.allTime)); + final topAlbumsNotifier = + ref.watch(historyTopAlbumsProvider(HistoryDuration.allTime).notifier); + + final albumsData = topAlbums.asData?.value.items ?? []; + + return Scaffold( + appBar: PageWindowTitleBar( + automaticallyImplyLeading: true, + centerTitle: false, + title: Text(context.l10n.albums), + ), + body: Skeletonizer( + enabled: topAlbums.isLoading && !topAlbums.isLoadingNextPage, + child: InfiniteList( + onFetchData: () async { + await topAlbumsNotifier.fetchMore(); + }, + hasError: topAlbums.hasError, + isLoading: topAlbums.isLoading && !topAlbums.isLoadingNextPage, + hasReachedMax: topAlbums.asData?.value.hasMore ?? true, + itemCount: albumsData.length, + itemBuilder: (context, index) { + final album = albumsData[index]; + return StatsAlbumItem( + album: album.album, + info: Text(context.l10n + .count_plays(compactNumberFormatter.format(album.count))), + ); + }, + ), + ), + ); + } +} diff --git a/lib/pages/stats/artists/artists.dart b/lib/pages/stats/artists/artists.dart new file mode 100644 index 000000000..436bbb57c --- /dev/null +++ b/lib/pages/stats/artists/artists.dart @@ -0,0 +1,58 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotube/collections/formatters.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/modules/stats/common/artist_item.dart'; +import 'package:spotube/extensions/context.dart'; + +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/history/top/tracks.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; +import 'package:very_good_infinite_list/very_good_infinite_list.dart'; + +class StatsArtistsPage extends HookConsumerWidget { + static const name = "stats_artists"; + const StatsArtistsPage({super.key}); + + @override + Widget build(BuildContext context, ref) { + final topTracks = ref.watch( + historyTopTracksProvider(HistoryDuration.allTime), + ); + final topTracksNotifier = + ref.watch(historyTopTracksProvider(HistoryDuration.allTime).notifier); + + final artistsData = useMemoized( + () => topTracks.asData?.value.artists ?? [], [topTracks.asData?.value]); + + return Scaffold( + appBar: PageWindowTitleBar( + automaticallyImplyLeading: true, + centerTitle: false, + title: Text(context.l10n.artists), + ), + body: Skeletonizer( + enabled: topTracks.isLoading && !topTracks.isLoadingNextPage, + child: InfiniteList( + onFetchData: () async { + await topTracksNotifier.fetchMore(); + }, + hasError: topTracks.hasError, + isLoading: topTracks.isLoading && !topTracks.isLoadingNextPage, + hasReachedMax: topTracks.asData?.value.hasMore ?? true, + itemCount: artistsData.length, + itemBuilder: (context, index) { + final artist = artistsData[index]; + return StatsArtistItem( + artist: artist.artist, + info: Text(context.l10n + .count_plays(compactNumberFormatter.format(artist.count))), + ); + }, + ), + ), + ); + } +} diff --git a/lib/pages/stats/fees/fees.dart b/lib/pages/stats/fees/fees.dart new file mode 100644 index 000000000..da62fb307 --- /dev/null +++ b/lib/pages/stats/fees/fees.dart @@ -0,0 +1,138 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:sliver_tools/sliver_tools.dart'; +import 'package:spotube/collections/formatters.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/modules/stats/common/artist_item.dart'; +import 'package:spotube/extensions/context.dart'; + +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/history/top/tracks.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; +import 'package:very_good_infinite_list/very_good_infinite_list.dart'; + +class StatsStreamFeesPage extends HookConsumerWidget { + static const name = "stats_stream_fees"; + + const StatsStreamFeesPage({super.key}); + + @override + Widget build(BuildContext context, ref) { + final ThemeData(:textTheme, :hintColor) = Theme.of(context); + final duration = useState(HistoryDuration.days30); + + final topTracks = ref.watch( + historyTopTracksProvider(duration.value), + ); + final topTracksNotifier = + ref.watch(historyTopTracksProvider(duration.value).notifier); + + final artistsData = useMemoized( + () => topTracks.asData?.value.artists ?? [], [topTracks.asData?.value]); + + final total = useMemoized( + () => artistsData.fold( + 0, + (previousValue, element) => previousValue + element.count * 0.005, + ), + [artistsData], + ); + + return Scaffold( + appBar: PageWindowTitleBar( + automaticallyImplyLeading: true, + centerTitle: false, + title: Text(context.l10n.streaming_fees_hypothetical), + ), + body: CustomScrollView( + slivers: [ + SliverCrossAxisConstrained( + maxCrossAxisExtent: 600, + alignment: -1, + child: SliverPadding( + padding: const EdgeInsets.all(16.0), + sliver: SliverToBoxAdapter( + child: Text( + context.l10n.spotify_hipotetical_calculation, + style: textTheme.bodySmall?.copyWith( + color: hintColor, + ), + ), + ), + ), + ), + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + context.l10n.total_money(usdFormatter.format(total)), + style: textTheme.titleLarge, + ), + DropdownButton( + value: duration.value, + onChanged: (value) { + if (value == null) return; + duration.value = value; + }, + items: [ + DropdownMenuItem( + value: HistoryDuration.days7, + child: Text(context.l10n.this_week), + ), + DropdownMenuItem( + value: HistoryDuration.days30, + child: Text(context.l10n.this_month), + ), + DropdownMenuItem( + value: HistoryDuration.months6, + child: Text(context.l10n.last_6_months), + ), + DropdownMenuItem( + value: HistoryDuration.year, + child: Text(context.l10n.this_year), + ), + DropdownMenuItem( + value: HistoryDuration.years2, + child: Text(context.l10n.last_2_years), + ), + DropdownMenuItem( + value: HistoryDuration.allTime, + child: Text(context.l10n.all_time), + ), + ], + ), + ], + ), + ), + ), + SliverSafeArea( + sliver: Skeletonizer.sliver( + enabled: topTracks.isLoading && !topTracks.isLoadingNextPage, + child: SliverInfiniteList( + onFetchData: () async { + await topTracksNotifier.fetchMore(); + }, + hasError: topTracks.hasError, + isLoading: topTracks.isLoading && !topTracks.isLoadingNextPage, + hasReachedMax: topTracks.asData?.value.hasMore ?? true, + itemCount: artistsData.length, + itemBuilder: (context, index) { + final artist = artistsData[index]; + return StatsArtistItem( + artist: artist.artist, + info: Text(usdFormatter.format(artist.count * 0.005)), + ); + }, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages/stats/minutes/minutes.dart b/lib/pages/stats/minutes/minutes.dart new file mode 100644 index 000000000..35bea3abd --- /dev/null +++ b/lib/pages/stats/minutes/minutes.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotube/collections/formatters.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/modules/stats/common/track_item.dart'; +import 'package:spotube/extensions/context.dart'; + +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/history/top/tracks.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; +import 'package:very_good_infinite_list/very_good_infinite_list.dart'; + +class StatsMinutesPage extends HookConsumerWidget { + static const name = "stats_minutes"; + + const StatsMinutesPage({super.key}); + + @override + Widget build(BuildContext context, ref) { + final topTracks = ref.watch( + historyTopTracksProvider(HistoryDuration.allTime), + ); + final topTracksNotifier = + ref.watch(historyTopTracksProvider(HistoryDuration.allTime).notifier); + + final tracksData = topTracks.asData?.value.items ?? []; + + return Scaffold( + appBar: PageWindowTitleBar( + title: Text(context.l10n.minutes_listened), + centerTitle: false, + automaticallyImplyLeading: true, + ), + body: Skeletonizer( + enabled: topTracks.isLoading && !topTracks.isLoadingNextPage, + child: InfiniteList( + separatorBuilder: (context, index) => const Gap(8), + onFetchData: () async { + await topTracksNotifier.fetchMore(); + }, + hasError: topTracks.hasError, + isLoading: topTracks.isLoading && !topTracks.isLoadingNextPage, + hasReachedMax: topTracks.asData?.value.hasMore ?? true, + itemCount: tracksData.length, + itemBuilder: (context, index) { + final track = tracksData[index]; + return StatsTrackItem( + track: track.track, + info: Text( + context.l10n + .count_plays(compactNumberFormatter.format(track.count)), + ), + ); + }, + ), + ), + ); + } +} diff --git a/lib/pages/stats/playlists/playlists.dart b/lib/pages/stats/playlists/playlists.dart new file mode 100644 index 000000000..4e83b0a27 --- /dev/null +++ b/lib/pages/stats/playlists/playlists.dart @@ -0,0 +1,58 @@ +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotube/collections/formatters.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/modules/stats/common/playlist_item.dart'; +import 'package:spotube/extensions/context.dart'; + +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/history/top/playlists.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; +import 'package:very_good_infinite_list/very_good_infinite_list.dart'; + +class StatsPlaylistsPage extends HookConsumerWidget { + static const name = "stats_playlists"; + const StatsPlaylistsPage({super.key}); + + @override + Widget build(BuildContext context, ref) { + final topPlaylists = + ref.watch(historyTopPlaylistsProvider(HistoryDuration.allTime)); + + final topPlaylistsNotifier = ref + .watch(historyTopPlaylistsProvider(HistoryDuration.allTime).notifier); + + final playlistsData = topPlaylists.asData?.value.items ?? []; + + return Scaffold( + appBar: PageWindowTitleBar( + automaticallyImplyLeading: true, + centerTitle: false, + title: Text(context.l10n.playlists), + ), + body: Skeletonizer( + enabled: topPlaylists.isLoading && !topPlaylists.isLoadingNextPage, + child: InfiniteList( + onFetchData: () async { + await topPlaylistsNotifier.fetchMore(); + }, + hasError: topPlaylists.hasError, + isLoading: topPlaylists.isLoading && !topPlaylists.isLoadingNextPage, + hasReachedMax: topPlaylists.asData?.value.hasMore ?? true, + itemCount: playlistsData.length, + itemBuilder: (context, index) { + final playlist = playlistsData[index]; + return StatsPlaylistItem( + playlist: playlist.playlist, + info: Text( + context.l10n + .count_plays(compactNumberFormatter.format(playlist.count)), + ), + ); + }, + ), + ), + ); + } +} diff --git a/lib/pages/stats/stats.dart b/lib/pages/stats/stats.dart new file mode 100644 index 000000000..b2dc03c25 --- /dev/null +++ b/lib/pages/stats/stats.dart @@ -0,0 +1,35 @@ +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/modules/stats/summary/summary.dart'; +import 'package:spotube/modules/stats/top/top.dart'; +import 'package:spotube/utils/platform.dart'; + +class StatsPage extends HookConsumerWidget { + static const name = "stats"; + + const StatsPage({super.key}); + + @override + Widget build(BuildContext context, ref) { + return SafeArea( + bottom: false, + child: Scaffold( + appBar: kIsMacOS || kIsMobile ? null : const PageWindowTitleBar(), + body: CustomScrollView( + slivers: [ + if (kIsMacOS) const SliverGap(20), + const StatsPageSummarySection(), + const StatsPageTopSection(), + const SliverToBoxAdapter( + child: SafeArea( + child: SizedBox(), + ), + ) + ], + ), + ), + ); + } +} diff --git a/lib/pages/stats/streams/streams.dart b/lib/pages/stats/streams/streams.dart new file mode 100644 index 000000000..5c90e8791 --- /dev/null +++ b/lib/pages/stats/streams/streams.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:skeletonizer/skeletonizer.dart'; +import 'package:spotube/collections/formatters.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/modules/stats/common/track_item.dart'; +import 'package:spotube/extensions/context.dart'; + +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/history/top/tracks.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; +import 'package:very_good_infinite_list/very_good_infinite_list.dart'; + +class StatsStreamsPage extends HookConsumerWidget { + static const name = "stats_streams"; + + const StatsStreamsPage({super.key}); + + @override + Widget build(BuildContext context, ref) { + final topTracks = ref.watch( + historyTopTracksProvider(HistoryDuration.allTime), + ); + final topTracksNotifier = + ref.watch(historyTopTracksProvider(HistoryDuration.allTime).notifier); + + final tracksData = topTracks.asData?.value.items ?? []; + + return Scaffold( + appBar: PageWindowTitleBar( + title: Text(context.l10n.streamed_songs), + centerTitle: false, + automaticallyImplyLeading: true, + ), + body: Skeletonizer( + enabled: topTracks.isLoading && !topTracks.isLoadingNextPage, + child: InfiniteList( + separatorBuilder: (context, index) => const Gap(8), + onFetchData: () async { + await topTracksNotifier.fetchMore(); + }, + hasError: topTracks.hasError, + isLoading: topTracks.isLoading && !topTracks.isLoadingNextPage, + hasReachedMax: topTracks.asData?.value.hasMore ?? true, + itemCount: tracksData.length, + itemBuilder: (context, index) { + final track = tracksData[index]; + return StatsTrackItem( + track: track.track, + info: Text( + context.l10n.count_mins(compactNumberFormatter + .format(track.count * track.track.duration!.inMinutes)), + ), + ); + }, + ), + ), + ); + } +} diff --git a/lib/pages/track/track.dart b/lib/pages/track/track.dart index fc90d19a9..6f3af0e4b 100644 --- a/lib/pages/track/track.dart +++ b/lib/pages/track/track.dart @@ -6,21 +6,23 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:skeletonizer/skeletonizer.dart'; import 'package:spotube/collections/fake.dart'; import 'package:spotube/collections/spotube_icons.dart'; -import 'package:spotube/components/shared/heart_button.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/components/shared/links/artist_link.dart'; -import 'package:spotube/components/shared/links/link_text.dart'; -import 'package:spotube/components/shared/page_window_title_bar.dart'; -import 'package:spotube/components/shared/track_tile/track_options.dart'; +import 'package:spotube/components/heart_button/heart_button.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/components/links/artist_link.dart'; +import 'package:spotube/components/links/link_text.dart'; +import 'package:spotube/components/titlebar/titlebar.dart'; +import 'package:spotube/components/track_tile/track_options.dart'; import 'package:spotube/extensions/context.dart'; import 'package:spotube/extensions/image.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/spotify/spotify.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; import 'package:spotube/extensions/constrains.dart'; class TrackPage extends HookConsumerWidget { + static const name = "track"; + final String trackId; const TrackPage({ super.key, @@ -32,8 +34,8 @@ class TrackPage extends HookConsumerWidget { final ThemeData(:textTheme, :colorScheme) = Theme.of(context); final mediaQuery = MediaQuery.of(context); - final playlist = ref.watch(proxyPlaylistProvider); - final playlistNotifier = ref.watch(proxyPlaylistProvider.notifier); + final playlist = ref.watch(audioPlayerProvider); + final playlistNotifier = ref.watch(audioPlayerProvider.notifier); final isActive = playlist.activeTrack?.id == trackId; @@ -146,7 +148,12 @@ class TrackPage extends HookConsumerWidget { children: [ const Icon(SpotubeIcons.artist), const Gap(5), - ArtistLink(artists: track.artists!), + Flexible( + child: ArtistLink( + artists: track.artists!, + hideOverflowArtist: false, + ), + ), ], ), const Gap(10), diff --git a/lib/provider/audio_player/audio_player.dart b/lib/provider/audio_player/audio_player.dart new file mode 100644 index 000000000..c40f683d1 --- /dev/null +++ b/lib/provider/audio_player/audio_player.dart @@ -0,0 +1,328 @@ +import 'dart:math'; + +import 'package:drift/drift.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:media_kit/media_kit.dart' hide Track; +import 'package:spotify/spotify.dart' hide Playlist; +import 'package:spotube/extensions/track.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/models/local_track.dart'; +import 'package:spotube/provider/audio_player/state.dart'; +import 'package:spotube/provider/blacklist_provider.dart'; +import 'package:spotube/provider/database/database.dart'; +import 'package:spotube/provider/discord_provider.dart'; +import 'package:spotube/provider/server/sourced_track.dart'; +import 'package:spotube/services/audio_player/audio_player.dart'; + +class AudioPlayerNotifier extends Notifier { + BlackListNotifier get _blacklist => ref.read(blacklistProvider.notifier); + + Future _syncSavedState() async { + final database = ref.read(databaseProvider); + + var playerState = + await database.select(database.audioPlayerStateTable).getSingleOrNull(); + + if (playerState == null) { + await database.into(database.audioPlayerStateTable).insert( + AudioPlayerStateTableCompanion.insert( + playing: audioPlayer.isPlaying, + loopMode: audioPlayer.loopMode, + shuffled: audioPlayer.isShuffled, + collections: [], + id: const Value(0), + ), + ); + + playerState = + await database.select(database.audioPlayerStateTable).getSingle(); + } else { + await audioPlayer.setLoopMode(playerState.loopMode); + await audioPlayer.setShuffle(playerState.shuffled); + } + + var playlist = + await database.select(database.playlistTable).getSingleOrNull(); + var medias = await database.select(database.playlistMediaTable).get(); + + if (playlist == null) { + await database.into(database.playlistTable).insert( + PlaylistTableCompanion.insert( + audioPlayerStateId: 0, + index: audioPlayer.playlist.index, + id: const Value(0), + ), + ); + + playlist = await database.select(database.playlistTable).getSingle(); + } + + if (medias.isEmpty && audioPlayer.playlist.medias.isNotEmpty) { + await database.batch((batch) { + batch.insertAll( + database.playlistMediaTable, + [ + for (final media in audioPlayer.playlist.medias) + PlaylistMediaTableCompanion.insert( + playlistId: playlist!.id, + uri: media.uri, + extras: Value(media.extras), + httpHeaders: Value(media.httpHeaders), + ), + ], + ); + }); + } else if (medias.isNotEmpty) { + await audioPlayer.openPlaylist( + medias + .map( + (media) => SpotubeMedia.fromMedia( + Media( + media.uri, + extras: media.extras, + httpHeaders: media.httpHeaders, + ), + ), + ) + .toList(), + initialIndex: playlist.index, + autoPlay: false, + ); + } + + if (playerState.collections.isNotEmpty) { + state = state.copyWith( + collections: playerState.collections, + ); + } + } + + Future _updatePlayerState( + AudioPlayerStateTableCompanion companion, + ) async { + final database = ref.read(databaseProvider); + + await (database.update(database.audioPlayerStateTable) + ..where((tb) => tb.id.equals(0))) + .write(companion); + } + + Future _updatePlaylist( + Playlist playlist, + ) async { + final database = ref.read(databaseProvider); + + await database.batch((batch) { + batch.update( + database.playlistTable, + PlaylistTableCompanion(index: Value(playlist.index)), + where: (tb) => tb.id.equals(0), + ); + + batch.deleteAll(database.playlistMediaTable); + + if (playlist.medias.isEmpty) return; + batch.insertAll( + database.playlistMediaTable, + [ + for (final media in playlist.medias) + PlaylistMediaTableCompanion.insert( + playlistId: 0, + uri: media.uri, + extras: Value(media.extras), + httpHeaders: Value(media.httpHeaders), + ), + ], + ); + }); + } + + @override + build() { + final subscriptions = [ + audioPlayer.playingStream.listen((playing) async { + state = state.copyWith(playing: playing); + + await _updatePlayerState( + AudioPlayerStateTableCompanion( + playing: Value(playing), + ), + ); + }), + audioPlayer.loopModeStream.listen((loopMode) async { + state = state.copyWith(loopMode: loopMode); + + await _updatePlayerState( + AudioPlayerStateTableCompanion( + loopMode: Value(loopMode), + ), + ); + }), + audioPlayer.shuffledStream.listen((shuffled) async { + state = state.copyWith(shuffled: shuffled); + + await _updatePlayerState( + AudioPlayerStateTableCompanion( + shuffled: Value(shuffled), + ), + ); + }), + audioPlayer.playlistStream.listen((playlist) async { + state = state.copyWith(playlist: playlist); + + await _updatePlaylist(playlist); + }), + ]; + + _syncSavedState(); + + ref.onDispose(() { + for (final subscription in subscriptions) { + subscription.cancel(); + } + }); + + return AudioPlayerState( + loopMode: audioPlayer.loopMode, + playing: audioPlayer.isPlaying, + playlist: audioPlayer.playlist, + shuffled: audioPlayer.isShuffled, + collections: [], + ); + } + + // Collection related methods + Future addCollections(List collectionIds) async { + state = state.copyWith(collections: [ + ...state.collections, + ...collectionIds, + ]); + + await _updatePlayerState( + AudioPlayerStateTableCompanion( + collections: Value(state.collections), + ), + ); + } + + Future addCollection(String collectionId) async { + await addCollections([collectionId]); + } + + Future removeCollections(List collectionIds) async { + state = state.copyWith( + collections: state.collections + .where((element) => !collectionIds.contains(element)) + .toList(), + ); + + await _updatePlayerState( + AudioPlayerStateTableCompanion( + collections: Value(state.collections), + ), + ); + } + + Future removeCollection(String collectionId) async { + await removeCollections([collectionId]); + } + + // Tracks related methods + + Future addTracksAtFirst(Iterable tracks) async { + if (state.tracks.length == 1) { + return addTracks(tracks); + } + + tracks = _blacklist.filter(tracks).toList() as List; + + for (int i = 0; i < tracks.length; i++) { + final track = tracks.elementAt(i); + + await audioPlayer.addTrackAt( + SpotubeMedia(track), + max(state.playlist.index, 0) + i + 1, + ); + } + } + + Future addTrack(Track track) async { + if (_blacklist.contains(track)) return; + await audioPlayer.addTrack(SpotubeMedia(track)); + } + + Future addTracks(Iterable tracks) async { + tracks = _blacklist.filter(tracks).toList() as List; + for (final track in tracks) { + await audioPlayer.addTrack(SpotubeMedia(track)); + } + } + + Future removeTrack(String trackId) async { + final index = state.tracks.indexWhere((element) => element.id == trackId); + + if (index == -1) return; + + await audioPlayer.removeTrack(index); + } + + Future removeTracks(Iterable trackIds) async { + for (final trackId in trackIds) { + await removeTrack(trackId); + } + } + + Future load( + List tracks, { + int initialIndex = 0, + bool autoPlay = false, + }) async { + final medias = + (_blacklist.filter(tracks).toList() as List).asMediaList(); + + // Giving the initial track a boost so MediaKit won't skip + // because of timeout + final intendedActiveTrack = medias.elementAt(initialIndex); + if (intendedActiveTrack.track is! LocalTrack) { + await ref.read(sourcedTrackProvider(intendedActiveTrack).future); + } + + if (medias.isEmpty) return; + + await removeCollections(state.collections); + + await audioPlayer.openPlaylist( + medias.map((s) => s as Media).toList(), + initialIndex: initialIndex, + autoPlay: autoPlay, + ); + } + + Future jumpToTrack(Track track) async { + final index = + state.tracks.toList().indexWhere((element) => element.id == track.id); + if (index == -1) return; + await audioPlayer.jumpTo(index); + } + + Future moveTrack(int oldIndex, int newIndex) async { + if (oldIndex == newIndex || + newIndex < 0 || + oldIndex < 0 || + newIndex > state.tracks.length - 1 || + oldIndex > state.tracks.length - 1) return; + + await audioPlayer.moveTrack(oldIndex, newIndex); + } + + Future stop() async { + await audioPlayer.stop(); + await removeCollections(state.collections); + ref.read(discordProvider.notifier).clear(); + } +} + +final audioPlayerProvider = + NotifierProvider( + () => AudioPlayerNotifier(), +); diff --git a/lib/provider/audio_player/audio_player_streams.dart b/lib/provider/audio_player/audio_player_streams.dart new file mode 100644 index 000000000..845f12ea8 --- /dev/null +++ b/lib/provider/audio_player/audio_player_streams.dart @@ -0,0 +1,152 @@ +import 'dart:async'; + +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:palette_generator/palette_generator.dart'; +import 'package:spotube/components/image/universal_image.dart'; +import 'package:spotube/extensions/image.dart'; +import 'package:spotube/models/local_track.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/provider/audio_player/state.dart'; +import 'package:spotube/provider/discord_provider.dart'; +import 'package:spotube/provider/history/history.dart'; +import 'package:spotube/provider/palette_provider.dart'; +import 'package:spotube/provider/skip_segments/skip_segments.dart'; +import 'package:spotube/provider/scrobbler/scrobbler.dart'; +import 'package:spotube/provider/server/sourced_track.dart'; +import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +import 'package:spotube/services/audio_player/audio_player.dart'; +import 'package:spotube/services/audio_services/audio_services.dart'; +import 'package:spotube/services/logger/logger.dart'; + +class AudioPlayerStreamListeners { + final Ref ref; + late final AudioServices notificationService; + AudioPlayerStreamListeners(this.ref) { + AudioServices.create(ref, ref.read(audioPlayerProvider.notifier)).then( + (value) => notificationService = value, + ); + + final subscriptions = [ + subscribeToPlaylist(), + subscribeToSkipSponsor(), + subscribeToScrobbleChanged(), + subscribeToPosition(), + subscribeToPlayerError(), + ]; + + ref.onDispose(() { + for (final subscription in subscriptions) { + subscription.cancel(); + } + }); + } + + ScrobblerNotifier get scrobbler => ref.read(scrobblerProvider.notifier); + UserPreferences get preferences => ref.read(userPreferencesProvider); + DiscordNotifier get discord => ref.read(discordProvider.notifier); + AudioPlayerState get audioPlayerState => ref.read(audioPlayerProvider); + PlaybackHistoryActions get history => + ref.read(playbackHistoryActionsProvider); + + Future updatePalette() async { + final palette = ref.read(paletteProvider); + if (!preferences.albumColorSync) { + if (palette != null) ref.read(paletteProvider.notifier).state = null; + return; + } + return Future.microtask(() async { + final activeTrack = ref.read(audioPlayerProvider).activeTrack; + if (activeTrack == null) return; + + final palette = await PaletteGenerator.fromImageProvider( + UniversalImage.imageProvider( + (activeTrack.album?.images).asUrlString( + placeholder: ImagePlaceholder.albumArt, + ), + height: 50, + width: 50, + ), + ); + ref.read(paletteProvider.notifier).state = palette; + }); + } + + StreamSubscription subscribeToPlaylist() { + return audioPlayer.playlistStream.listen((mpvPlaylist) { + notificationService.addTrack(audioPlayerState.activeTrack!); + discord.updatePresence(audioPlayerState.activeTrack!); + updatePalette(); + }); + } + + StreamSubscription subscribeToSkipSponsor() { + return audioPlayer.positionStream.listen((position) async { + final currentSegments = await ref.read(segmentProvider.future); + + if (currentSegments?.segments.isNotEmpty != true || + position < const Duration(seconds: 3)) return; + + for (final segment in currentSegments!.segments) { + final seconds = position.inSeconds; + + if (seconds < segment.start || seconds >= segment.end) continue; + + await audioPlayer.seek(Duration(seconds: segment.end + 1)); + } + }); + } + + StreamSubscription subscribeToScrobbleChanged() { + String? lastScrobbled; + return audioPlayer.positionStream.listen((position) { + try { + final uid = audioPlayerState.activeTrack is LocalTrack + ? (audioPlayerState.activeTrack as LocalTrack).path + : audioPlayerState.activeTrack?.id; + + if (audioPlayerState.activeTrack == null || + lastScrobbled == uid || + position.inSeconds < 30) { + return; + } + + scrobbler.scrobble(audioPlayerState.activeTrack!); + history.addTrack(audioPlayerState.activeTrack!); + lastScrobbled = uid; + } catch (e, stack) { + AppLogger.reportError(e, stack); + } + }); + } + + StreamSubscription subscribeToPosition() { + String lastTrack = ""; // used to prevent multiple calls to the same track + return audioPlayer.positionStream.listen((event) async { + if (event < const Duration(seconds: 3) || + audioPlayerState.playlist.index == -1 || + audioPlayerState.playlist.index == + audioPlayerState.tracks.length - 1) { + return; + } + final nextTrack = SpotubeMedia.fromMedia(audioPlayerState.playlist.medias + .elementAt(audioPlayerState.playlist.index + 1)); + + if (lastTrack == nextTrack.track.id || nextTrack.track is LocalTrack) { + return; + } + + try { + await ref.read(sourcedTrackProvider(nextTrack).future); + } finally { + lastTrack = nextTrack.track.id!; + } + }); + } + + StreamSubscription subscribeToPlayerError() { + return audioPlayer.errorStream.listen((event) {}); + } +} + +final audioPlayerStreamListenersProvider = + Provider(AudioPlayerStreamListeners.new); diff --git a/lib/provider/audio_player/querying_track_info.dart b/lib/provider/audio_player/querying_track_info.dart new file mode 100644 index 000000000..55590d481 --- /dev/null +++ b/lib/provider/audio_player/querying_track_info.dart @@ -0,0 +1,24 @@ +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/provider/server/sourced_track.dart'; +import 'package:spotube/services/audio_player/audio_player.dart'; + +final queryingTrackInfoProvider = Provider((ref) { + final media = audioPlayer.playlist.index == -1 || + audioPlayer.playlist.medias.isEmpty + ? null + : audioPlayer.playlist.medias.elementAtOrNull(audioPlayer.playlist.index); + final audioPlayerActiveTrack = + media == null ? null : SpotubeMedia.fromMedia(media); + + final activeMedia = ref.watch(audioPlayerProvider.select( + (s) => s.activeMedia == null + ? null + : SpotubeMedia.fromMedia(s.activeMedia!), + )) ?? + audioPlayerActiveTrack; + + if (activeMedia == null) return false; + + return ref.watch(sourcedTrackProvider(activeMedia)).isLoading; +}); diff --git a/lib/provider/audio_player/state.dart b/lib/provider/audio_player/state.dart new file mode 100644 index 000000000..0e3004f51 --- /dev/null +++ b/lib/provider/audio_player/state.dart @@ -0,0 +1,108 @@ +import 'package:media_kit/media_kit.dart' hide Track; +import 'package:spotify/spotify.dart' hide Playlist; +import 'package:spotube/services/audio_player/audio_player.dart'; + +class AudioPlayerState { + final bool playing; + final PlaylistMode loopMode; + final bool shuffled; + final Playlist playlist; + + final List tracks; + final List collections; + + AudioPlayerState({ + required this.playing, + required this.loopMode, + required this.shuffled, + required this.playlist, + required this.collections, + List? tracks, + }) : tracks = tracks ?? + playlist.medias + .map((media) => SpotubeMedia.fromMedia(media).track) + .toList(); + + factory AudioPlayerState.fromJson(Map json) { + return AudioPlayerState( + playing: json['playing'], + loopMode: PlaylistMode.values.firstWhere( + (e) => e.name == json['loopMode'], + orElse: () => audioPlayer.loopMode, + ), + shuffled: json['shuffled'], + playlist: Playlist( + json['playlist']['medias'] + .map( + (media) => SpotubeMedia.fromMedia(Media( + media['uri'], + extras: media['extras'], + httpHeaders: media['httpHeaders'], + )), + ) + .cast() + .toList(), + index: json['playlist']['index'], + ), + collections: List.from(json['collections']), + ); + } + + Map toJson() { + return { + 'playing': playing, + 'loopMode': loopMode.name, + 'shuffled': shuffled, + 'playlist': { + 'medias': playlist.medias + .map((media) => { + 'uri': media.uri, + 'extras': media.extras, + 'httpHeaders': media.httpHeaders, + }) + .toList(), + 'index': playlist.index, + }, + 'collections': collections, + }; + } + + AudioPlayerState copyWith({ + bool? playing, + PlaylistMode? loopMode, + bool? shuffled, + Playlist? playlist, + List? collections, + }) { + return AudioPlayerState( + playing: playing ?? this.playing, + loopMode: loopMode ?? this.loopMode, + shuffled: shuffled ?? this.shuffled, + playlist: playlist ?? this.playlist, + collections: collections ?? this.collections, + tracks: playlist == null ? tracks : null, + ); + } + + Track? get activeTrack { + if (playlist.index == -1) return null; + return tracks.elementAtOrNull(playlist.index); + } + + Media? get activeMedia { + if (playlist.index == -1 || playlist.medias.isEmpty) return null; + return playlist.medias.elementAt(playlist.index); + } + + bool containsTrack(Track track) { + return tracks.any((t) => t.id == track.id); + } + + bool containsTracks(List tracks) { + return tracks.every(containsTrack); + } + + bool containsCollection(String collectionId) { + return collections.contains(collectionId); + } +} diff --git a/lib/provider/authentication/authentication.dart b/lib/provider/authentication/authentication.dart new file mode 100644 index 000000000..05a05972c --- /dev/null +++ b/lib/provider/authentication/authentication.dart @@ -0,0 +1,173 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:collection/collection.dart'; +import 'package:desktop_webview_window/desktop_webview_window.dart'; +import 'package:dio/dio.dart'; +import 'package:dio/io.dart'; +import 'package:drift/drift.dart'; +import 'package:flutter_inappwebview/flutter_inappwebview.dart' + hide X509Certificate; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/collections/routes.dart'; +import 'package:spotube/components/dialogs/prompt_dialog.dart'; +import 'package:spotube/extensions/context.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; +import 'package:spotube/utils/platform.dart'; + +extension ExpirationAuthenticationTableData on AuthenticationTableData { + bool get isExpired => DateTime.now().isAfter(expiration); + + String? getCookie(String key) => cookie.value + .split("; ") + .firstWhereOrNull((c) => c.trim().startsWith("$key=")) + ?.trim() + .split("=") + .last + .replaceAll(";", ""); +} + +class AuthenticationNotifier extends AsyncNotifier { + static final Dio dio = () { + final dio = Dio(); + + (dio.httpClientAdapter as IOHttpClientAdapter) + .createHttpClient = () => HttpClient() + ..badCertificateCallback = (X509Certificate cert, String host, int port) { + return host.endsWith("spotify.com") && port == 443; + }; + + return dio; + }(); + + @override + build() async { + final database = ref.watch(databaseProvider); + + final data = await (database.select(database.authenticationTable) + ..where((s) => s.id.equals(0))) + .getSingleOrNull(); + + Timer? refreshTimer; + + ref.listenSelf((prevData, newData) async { + if (newData.asData?.value == null) return; + + if (newData.asData!.value!.isExpired) { + await refreshCredentials(); + } + + // set the refresh timer + refreshTimer?.cancel(); + refreshTimer = Timer( + newData.asData!.value!.expiration.difference(DateTime.now()), + () => refreshCredentials(), + ); + }); + + final subscription = + database.select(database.authenticationTable).watch().listen( + (event) { + state = AsyncData(event.isEmpty ? null : event.first); + }, + ); + + ref.onDispose(() { + subscription.cancel(); + refreshTimer?.cancel(); + }); + + return data; + } + + Future refreshCredentials() async { + final database = ref.read(databaseProvider); + final refreshedCredentials = + await credentialsFromCookie(state.asData!.value!.cookie.value); + + await database + .update(database.authenticationTable) + .replace(refreshedCredentials); + } + + Future login(String cookie) async { + final database = ref.read(databaseProvider); + final refreshedCredentials = await credentialsFromCookie(cookie); + + await database + .into(database.authenticationTable) + .insert(refreshedCredentials, mode: InsertMode.replace); + } + + Future credentialsFromCookie( + String cookie, + ) async { + try { + final spDc = cookie + .split("; ") + .firstWhereOrNull((c) => c.trim().startsWith("sp_dc=")) + ?.trim(); + final res = await dio.getUri( + Uri.parse( + "https://open.spotify.com/get_access_token?reason=transport&productType=web_player", + ), + options: Options( + headers: { + "Cookie": spDc ?? "", + "User-Agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" + }, + validateStatus: (status) => true, + ), + ); + final body = res.data; + + if ((res.statusCode ?? 500) >= 400) { + throw Exception( + "Failed to get access token: ${body['error'] ?? res.statusMessage}", + ); + } + + return AuthenticationTableCompanion.insert( + id: const Value(0), + cookie: DecryptedText("${res.headers["set-cookie"]?.join(";")}; $spDc"), + accessToken: DecryptedText(body['accessToken']), + expiration: DateTime.fromMillisecondsSinceEpoch( + body['accessTokenExpirationTimestampMs'], + ), + ); + } catch (e) { + if (rootNavigatorKey.currentContext != null) { + showPromptDialog( + context: rootNavigatorKey.currentContext!, + title: rootNavigatorKey.currentContext!.l10n + .error("Authentication Failure"), + message: e.toString(), + cancelText: null, + ); + } + rethrow; + } + } + + Future logout() async { + state = const AsyncData(null); + final database = ref.read(databaseProvider); + await (database.delete(database.authenticationTable) + ..where((s) => s.id.equals(0))) + .go(); + if (kIsMobile) { + WebStorageManager.instance().deleteAllData(); + CookieManager.instance().deleteAllCookies(); + } + if (kIsDesktop) { + await WebviewWindow.clearAll(); + } + } +} + +final authenticationProvider = + AsyncNotifierProvider( + () => AuthenticationNotifier(), +); diff --git a/lib/provider/authentication_provider.dart b/lib/provider/authentication_provider.dart deleted file mode 100644 index a82f82c0c..000000000 --- a/lib/provider/authentication_provider.dart +++ /dev/null @@ -1,170 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; - -import 'package:collection/collection.dart'; -import 'package:flutter_inappwebview/flutter_inappwebview.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:http/http.dart'; -import 'package:spotube/collections/routes.dart'; -import 'package:spotube/components/shared/dialogs/prompt_dialog.dart'; -import 'package:spotube/extensions/context.dart'; -import 'package:spotube/utils/persisted_state_notifier.dart'; -import 'package:spotube/utils/platform.dart'; - -class AuthenticationCredentials { - String cookie; - String accessToken; - DateTime expiration; - - bool get isExpired => DateTime.now().isAfter(expiration); - - AuthenticationCredentials({ - required this.cookie, - required this.accessToken, - required this.expiration, - }); - - static Future fromCookie(String cookie) async { - try { - final spDc = cookie - .split("; ") - .firstWhereOrNull((c) => c.trim().startsWith("sp_dc=")) - ?.trim(); - final res = await get( - Uri.parse( - "https://open.spotify.com/get_access_token?reason=transport&productType=web_player", - ), - headers: { - "Cookie": spDc ?? "", - "User-Agent": - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36" - }, - ); - final body = jsonDecode(res.body); - - if (res.statusCode >= 400) { - throw Exception( - "Failed to get access token: ${body['error'] ?? res.reasonPhrase}", - ); - } - - return AuthenticationCredentials( - cookie: "${res.headers["set-cookie"]}; $spDc", - accessToken: body['accessToken'], - expiration: DateTime.fromMillisecondsSinceEpoch( - body['accessTokenExpirationTimestampMs'], - ), - ); - } catch (e) { - if (rootNavigatorKey?.currentContext != null) { - showPromptDialog( - context: rootNavigatorKey!.currentContext!, - title: rootNavigatorKey!.currentContext!.l10n - .error("Authentication Failure"), - message: e.toString(), - cancelText: null, - ); - } - rethrow; - } - } - - /// Returns the cookie value - String? getCookie(String key) => cookie - .split("; ") - .firstWhereOrNull((c) => c.trim().startsWith("$key=")) - ?.trim() - .split("=") - .last - .replaceAll(";", ""); - - factory AuthenticationCredentials.fromJson(Map json) { - return AuthenticationCredentials( - cookie: json['cookie'] as String, - accessToken: json['accessToken'] as String, - expiration: DateTime.parse(json['expiration'] as String), - ); - } - - Map toJson() { - return { - 'cookie': cookie, - 'accessToken': accessToken, - 'expiration': expiration.toIso8601String(), - }; - } - - AuthenticationCredentials copyWith({ - String? cookie, - String? accessToken, - DateTime? expiration, - }) { - return AuthenticationCredentials( - cookie: cookie ?? this.cookie, - accessToken: accessToken ?? this.accessToken, - expiration: expiration ?? this.expiration, - ); - } -} - -class AuthenticationNotifier - extends PersistedStateNotifier { - bool get isLoggedIn => state != null; - - AuthenticationNotifier() : super(null, "authentication", encrypted: true); - - Timer? _refreshTimer; - - @override - FutureOr onInit() async { - super.onInit(); - if (isLoggedIn && state!.isExpired) { - await refreshCredentials(); - } - - addListener((state) { - _refreshTimer?.cancel(); - if (isLoggedIn && !state!.isExpired) { - _refreshTimer = Timer( - state.expiration.difference(DateTime.now()), - () => refreshCredentials(), - ); - } - }); - } - - void setCredentials(AuthenticationCredentials credentials) { - state = credentials; - } - - Future logout() async { - state = null; - if (kIsMobile) { - WebStorageManager.instance().deleteAllData(); - CookieManager.instance().deleteAllCookies(); - } - } - - Future refreshCredentials() async { - if (!isLoggedIn) { - return; - } - - state = await AuthenticationCredentials.fromCookie(state!.cookie); - } - - @override - FutureOr fromJson(Map json) { - return AuthenticationCredentials.fromJson(json); - } - - @override - Map toJson() { - return state?.toJson() ?? {}; - } -} - -final authenticationProvider = - StateNotifierProvider( - (ref) => AuthenticationNotifier(), -); diff --git a/lib/provider/blacklist_provider.dart b/lib/provider/blacklist_provider.dart index 4f4881128..a51d399fd 100644 --- a/lib/provider/blacklist_provider.dart +++ b/lib/provider/blacklist_provider.dart @@ -2,69 +2,59 @@ import 'package:collection/collection.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/models/current_playlist.dart'; -import 'package:spotube/utils/persisted_state_notifier.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; -enum BlacklistedType { - artist, - track; - - static BlacklistedType fromName(String name) => - BlacklistedType.values.firstWhere((e) => e.name == name); -} - -class BlacklistedElement { - final String id; - final String name; - final BlacklistedType type; - - BlacklistedElement.artist(this.id, this.name) : type = BlacklistedType.artist; - - BlacklistedElement.track(this.id, this.name) : type = BlacklistedType.track; - - BlacklistedElement.fromJson(Map json) - : id = json['id'], - name = json['name'], - type = BlacklistedType.fromName(json['type']); +class BlackListNotifier extends AsyncNotifier> { + @override + build() async { + final database = ref.watch(databaseProvider); - Map toJson() => {'id': id, 'type': type.name, 'name': name}; + final subscription = database + .select(database.blacklistTable) + .watch() + .listen((event) => state = AsyncData(event)); - @override - operator ==(other) => - other is BlacklistedElement && - other.id == id && - other.type == type && - other.name == name; + ref.onDispose(() { + subscription.cancel(); + }); - @override - int get hashCode => id.hashCode ^ type.hashCode ^ name.hashCode; -} + return await database.select(database.blacklistTable).get(); + } -class BlackListNotifier - extends PersistedStateNotifier> { - BlackListNotifier() : super({}, "blacklist"); + AppDatabase get _database => ref.read(databaseProvider); - void add(BlacklistedElement element) { - state = state.union({element}); + Future add(BlacklistTableCompanion element) async { + _database.into(_database.blacklistTable).insert(element); } - void remove(BlacklistedElement element) { - state = state.difference({element}); + Future remove(String elementId) async { + await (_database.delete(_database.blacklistTable) + ..where((tbl) => tbl.elementId.equals(elementId))) + .go(); } bool contains(TrackSimple track) { final containsTrack = - state.contains(BlacklistedElement.track(track.id!, track.name!)); + state.asData?.value.any((element) => element.elementId == track.id) ?? + false; final containsTrackArtists = track.artists?.any( - (artist) => state.contains( - BlacklistedElement.artist(artist.id!, artist.name ?? "Spotify"), - ), + (artist) => + state.asData?.value.any((el) => el.elementId == artist.id) ?? + false, ) ?? false; return containsTrack || containsTrackArtists; } + bool containsArtist(ArtistSimple artist) { + return state.asData?.value + .any((element) => element.elementId == artist.id) ?? + false; + } + /// Filters the non blacklisted tracks from the given [tracks] Iterable filter(Iterable tracks) { return tracks.whereNot(contains).toList(); @@ -75,34 +65,12 @@ class BlackListNotifier id: playlist.id, name: playlist.name, thumbnail: playlist.thumbnail, - tracks: playlist.tracks.where( - (track) { - return !state - .contains(BlacklistedElement.track(track.id!, track.name!)) && - !(track.artists ?? []).any( - (artist) => state.contains( - BlacklistedElement.artist(artist.id!, artist.name!), - ), - ); - }, - ).toList(), + tracks: playlist.tracks.where((track) => !contains(track)).toList(), ); } - - @override - Set fromJson(Map json) { - return json['blacklist'] - .map((e) => BlacklistedElement.fromJson(e)) - .toSet(); - } - - @override - Map toJson() { - return {'blacklist': state.map((e) => e.toJson()).toList()}; - } } final blacklistProvider = - StateNotifierProvider>((ref) { - return BlackListNotifier(); -}); + AsyncNotifierProvider>( + () => BlackListNotifier(), +); diff --git a/lib/provider/connect/connect.dart b/lib/provider/connect/connect.dart index 6360c750b..000a28af0 100644 --- a/lib/provider/connect/connect.dart +++ b/lib/provider/connect/connect.dart @@ -1,13 +1,14 @@ import 'dart:convert'; -import 'package:catcher_2/catcher_2.dart'; +import 'package:media_kit/media_kit.dart' hide Track; +import 'package:spotube/provider/audio_player/state.dart'; +import 'package:spotube/services/audio_player/audio_player.dart'; +import 'package:spotube/services/logger/logger.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:spotify/spotify.dart'; +import 'package:spotify/spotify.dart' hide Playlist; import 'package:spotube/models/connect/connect.dart'; -import 'package:spotube/models/logger.dart'; + import 'package:spotube/provider/connect/clients.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist.dart'; -import 'package:spotube/services/audio_player/loop_mode.dart'; import 'package:web_socket_channel/web_socket_channel.dart'; import 'package:web_socket_channel/status.dart' as status; @@ -27,20 +28,24 @@ final shuffleProvider = StateProvider( (ref) => false, ); -final loopModeProvider = StateProvider( - (ref) => PlaybackLoopMode.none, +final loopModeProvider = StateProvider( + (ref) => PlaylistMode.none, ); -final queueProvider = StateProvider( - (ref) => ProxyPlaylist({}), +final queueProvider = StateProvider( + (ref) => AudioPlayerState( + playing: audioPlayer.isPlaying, + loopMode: audioPlayer.loopMode, + shuffled: audioPlayer.isShuffled, + playlist: audioPlayer.playlist, + collections: [], + ), ); final volumeProvider = StateProvider( (ref) => 1.0, ); -final logger = getLogger('ConnectNotifier'); - class ConnectNotifier extends AsyncNotifier { @override build() async { @@ -51,7 +56,7 @@ class ConnectNotifier extends AsyncNotifier { final service = connectClients.asData!.value.resolvedService!; - logger.t( + AppLogger.log.t( '♾️ Connecting to ${service.name}: ws://${service.host}:${service.port}/ws', ); @@ -61,7 +66,7 @@ class ConnectNotifier extends AsyncNotifier { await channel.ready; - logger.t( + AppLogger.log.t( '✅ Connected to ${service.name}: ws://${service.host}:${service.port}/ws', ); @@ -99,10 +104,7 @@ class ConnectNotifier extends AsyncNotifier { }); }, onError: (error) { - Catcher2.reportCheckedError( - error, - StackTrace.current, - ); + AppLogger.reportError(error, StackTrace.current); }, ); @@ -113,7 +115,7 @@ class ConnectNotifier extends AsyncNotifier { return channel; } catch (e, stack) { - Catcher2.reportCheckedError(e, stack); + AppLogger.reportError(e, stack); rethrow; } } @@ -161,7 +163,7 @@ class ConnectNotifier extends AsyncNotifier { emit(WebSocketShuffleEvent(value)); } - Future setLoopMode(PlaybackLoopMode value) async { + Future setLoopMode(PlaylistMode value) async { emit(WebSocketLoopEvent(value)); } diff --git a/lib/provider/connect/server.dart b/lib/provider/connect/server.dart deleted file mode 100644 index ebf53e437..000000000 --- a/lib/provider/connect/server.dart +++ /dev/null @@ -1,261 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; -import 'dart:io'; -import 'dart:math'; - -import 'package:catcher_2/catcher_2.dart'; -import 'package:shelf/shelf.dart'; -import 'package:shelf/shelf_io.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:shelf_router/shelf_router.dart'; -import 'package:shelf_web_socket/shelf_web_socket.dart'; -import 'package:spotube/models/connect/connect.dart'; -import 'package:spotube/models/logger.dart'; -import 'package:spotube/provider/connect/clients.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/services/audio_player/audio_player.dart'; -import 'package:bonsoir/bonsoir.dart'; -import 'package:spotube/services/device_info/device_info.dart'; -import 'package:spotube/utils/primitive_utils.dart'; -import 'package:web_socket_channel/web_socket_channel.dart'; -import 'package:spotube/provider/volume_provider.dart'; - -final logger = getLogger('ConnectServer'); -final _connectClientStreamController = StreamController.broadcast(); - -Stream get connectClientStream => _connectClientStreamController.stream; - -final connectServerProvider = FutureProvider((ref) async { - final enabled = - ref.watch(userPreferencesProvider.select((s) => s.enableConnect)); - final resolvedService = await ref - .watch(connectClientsProvider.selectAsync((s) => s.resolvedService)); - final playbackNotifier = ref.read(proxyPlaylistProvider.notifier); - - if (!enabled || resolvedService != null) { - return null; - } - - final app = Router(); - - app.get( - "/ping", - (Request req) { - return Response.ok("pong"); - }, - ); - - final subscriptions = []; - - FutureOr websocket(Request req) => webSocketHandler( - (WebSocketChannel channel, String? protocol) async { - final context = - (req.context["shelf.io.connection_info"] as HttpConnectionInfo?); - final origin = - "${context?.remoteAddress.host}:${context?.remotePort}"; - _connectClientStreamController.add(origin); - - ref.listen( - proxyPlaylistProvider, - (previous, next) { - channel.sink.add( - WebSocketQueueEvent(next).toJson(), - ); - }, - fireImmediately: true, - ); - - // because audioPlayer events doesn't fireImmediately - channel.sink.add( - WebSocketPlayingEvent(audioPlayer.isPlaying).toJson(), - ); - channel.sink.add( - WebSocketPositionEvent(await audioPlayer.position ?? Duration.zero) - .toJson(), - ); - channel.sink.add( - WebSocketDurationEvent(await audioPlayer.duration ?? Duration.zero) - .toJson(), - ); - channel.sink.add( - WebSocketShuffleEvent(await audioPlayer.isShuffled).toJson(), - ); - channel.sink.add( - WebSocketLoopEvent(audioPlayer.loopMode).toJson(), - ); - channel.sink.add( - WebSocketVolumeEvent(audioPlayer.volume).toJson(), - ); - - subscriptions.addAll([ - audioPlayer.positionStream.listen( - (position) { - channel.sink.add( - WebSocketPositionEvent(position).toJson(), - ); - }, - ), - audioPlayer.playingStream.listen( - (playing) { - channel.sink.add( - WebSocketPlayingEvent(playing).toJson(), - ); - }, - ), - audioPlayer.durationStream.listen( - (duration) { - channel.sink.add( - WebSocketDurationEvent(duration).toJson(), - ); - }, - ), - audioPlayer.shuffledStream.listen( - (shuffled) { - channel.sink.add( - WebSocketShuffleEvent(shuffled).toJson(), - ); - }, - ), - audioPlayer.loopModeStream.listen( - (loopMode) { - channel.sink.add( - WebSocketLoopEvent(loopMode).toJson(), - ); - }, - ), - audioPlayer.volumeStream.listen( - (volume) { - channel.sink.add( - WebSocketVolumeEvent(volume).toJson(), - ); - }, - ), - channel.stream.listen( - (message) { - try { - final event = WebSocketEvent.fromJson( - jsonDecode(message), - (data) => data, - ); - - event.onLoad((event) async { - await playbackNotifier.load( - event.data.tracks, - autoPlay: true, - initialIndex: event.data.initialIndex ?? 0, - ); - - if (event.data.collectionId != null) { - playbackNotifier.addCollection(event.data.collectionId!); - } - }); - - event.onPause((event) async { - await audioPlayer.pause(); - }); - - event.onResume((event) async { - await audioPlayer.resume(); - }); - - event.onStop((event) async { - await audioPlayer.stop(); - }); - - event.onNext((event) async { - await playbackNotifier.next(); - }); - - event.onPrevious((event) async { - await playbackNotifier.previous(); - }); - - event.onJump((event) async { - await playbackNotifier.jumpTo(event.data); - }); - - event.onSeek((event) async { - await audioPlayer.seek(event.data); - }); - - event.onShuffle((event) async { - await audioPlayer.setShuffle(event.data); - }); - - event.onLoop((event) async { - await audioPlayer.setLoopMode(event.data); - }); - - event.onAddTrack((event) async { - await playbackNotifier.addTrack(event.data); - }); - - event.onRemoveTrack((event) async { - await playbackNotifier.removeTrack(event.data); - }); - - event.onReorder((event) async { - await playbackNotifier.moveTrack( - event.data.oldIndex, - event.data.newIndex, - ); - }); - - event.onVolume((event) async { - ref.read(volumeProvider.notifier).setVolume(event.data); - }); - } catch (e, stackTrace) { - Catcher2.reportCheckedError(e, stackTrace); - channel.sink.add(WebSocketErrorEvent(e.toString()).toJson()); - } - }, - onDone: () { - logger.i('Connection closed'); - }, - ), - ]); - }, - )(req); - - final port = Random().nextInt(17000) + 3000; - - final server = await serve( - (request) { - if (request.url.path.startsWith('ws')) { - return websocket(request); - } - return app(request); - }, - InternetAddress.anyIPv4, - port, - ); - - logger.i('Server running on http://${server.address.host}:${server.port}'); - - final service = BonsoirService( - name: await DeviceInfoService.instance.computerName(), - type: '_spotube._tcp', - port: port, - attributes: { - "id": PrimitiveUtils.uuid.v4(), - "deviceId": await DeviceInfoService.instance.deviceId(), - }, - ); - - final broadcast = BonsoirBroadcast(service: service); - - await broadcast.ready; - await broadcast.start(); - - ref.onDispose(() async { - logger.i('Stopping server'); - for (final subscription in subscriptions) { - await subscription.cancel(); - } - await broadcast.stop(); - await server.close(); - }); - - return app; -}); diff --git a/lib/provider/custom_spotify_endpoint_provider.dart b/lib/provider/custom_spotify_endpoint_provider.dart index 4634549a4..ad0c389a4 100644 --- a/lib/provider/custom_spotify_endpoint_provider.dart +++ b/lib/provider/custom_spotify_endpoint_provider.dart @@ -1,10 +1,10 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/spotify_provider.dart'; import 'package:spotube/services/custom_spotify_endpoints/spotify_endpoints.dart'; final customSpotifyEndpointProvider = Provider((ref) { ref.watch(spotifyProvider); final auth = ref.watch(authenticationProvider); - return CustomSpotifyEndpoints(auth?.accessToken ?? ""); + return CustomSpotifyEndpoints(auth.asData?.value?.accessToken.value ?? ""); }); diff --git a/lib/provider/database/database.dart b/lib/provider/database/database.dart new file mode 100644 index 000000000..95976e56b --- /dev/null +++ b/lib/provider/database/database.dart @@ -0,0 +1,4 @@ +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/models/database/database.dart'; + +final databaseProvider = Provider((ref) => AppDatabase()); diff --git a/lib/provider/discord_provider.dart b/lib/provider/discord_provider.dart index ca8eecfa7..8f8cb375a 100644 --- a/lib/provider/discord_provider.dart +++ b/lib/provider/discord_provider.dart @@ -1,69 +1,104 @@ -import 'package:dart_discord_rpc/dart_discord_rpc.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; +import 'dart:async'; + +import 'package:flutter_discord_rpc/flutter_discord_rpc.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/collections/env.dart'; import 'package:spotube/extensions/artist_simple.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +import 'package:spotube/services/audio_player/audio_player.dart'; +import 'package:spotube/utils/platform.dart'; + +class DiscordNotifier extends AsyncNotifier { + @override + FutureOr build() async { + final enabled = ref.watch( + userPreferencesProvider.select((s) => s.discordPresence && kIsDesktop)); + + var lastPosition = audioPlayer.position; -class Discord extends ChangeNotifier { - final DiscordRPC? discordRPC; - final bool isEnabled; + final subscriptions = [ + FlutterDiscordRPC.instance.isConnectedStream.listen((connected) async { + final playback = ref.read(audioPlayerProvider); + if (connected && playback.activeTrack != null) { + await updatePresence(playback.activeTrack!); + } + }), + audioPlayer.playerStateStream.listen((state) async { + final playback = ref.read(audioPlayerProvider); + if (playback.activeTrack == null) return; - Discord(this.isEnabled) - : discordRPC = (DesktopTools.platform.isWindows || - DesktopTools.platform.isLinux) && - isEnabled - ? DiscordRPC(applicationId: Env.discordAppId) - : null { - discordRPC?.start(autoRegister: true); + await updatePresence(ref.read(audioPlayerProvider).activeTrack!); + }), + audioPlayer.positionStream.listen((position) async { + final playback = ref.read(audioPlayerProvider); + if (playback.activeTrack != null) { + final diff = position.inMilliseconds - lastPosition.inMilliseconds; + if (diff > 500 || diff < -500) { + await updatePresence(ref.read(audioPlayerProvider).activeTrack!); + } + } + lastPosition = position; + }) + ]; + + ref.onDispose(() async { + for (final subscription in subscriptions) { + subscription.cancel(); + } + await close(); + await FlutterDiscordRPC.instance.dispose(); + }); + + if (!enabled && FlutterDiscordRPC.instance.isConnected) { + await clear(); + await close(); + } else { + await FlutterDiscordRPC.instance.connect(autoRetry: true); + } } - void updatePresence(Track track) { - clear(); - final artistNames = track.artists?.asString() ?? ""; - discordRPC?.updatePresence( - DiscordPresence( - details: "Song: ${track.name} by $artistNames", - state: "Vibing in Music", - startTimeStamp: DateTime.now().millisecondsSinceEpoch, - largeImageKey: "spotube-logo-foreground", - largeImageText: "Spotube", - smallImageKey: "spotube-logo-foreground", - smallImageText: "Spotube", + Future updatePresence(Track track) async { + final artistNames = track.artists?.asString(); + final isPlaying = audioPlayer.isPlaying; + final position = audioPlayer.position; + + await FlutterDiscordRPC.instance.setActivity( + activity: RPCActivity( + details: track.name, + state: artistNames != null ? "by $artistNames" : null, + assets: RPCAssets( + largeImage: + track.album?.images?.first.url ?? "spotube-logo-foreground", + largeText: track.album?.name ?? "Unknown album", + smallImage: "spotube-logo-foreground", + smallText: "Spotube", + ), + buttons: [ + RPCButton( + label: "Listen on Spotify", + url: track.externalUrls?.spotify ?? + "https://open.spotify.com/tracks/${track.id}", + ), + ], + timestamps: RPCTimestamps( + start: isPlaying + ? DateTime.now().millisecondsSinceEpoch - position.inMilliseconds + : null, + ), + activityType: ActivityType.listening, ), ); } - void clear() { - discordRPC?.clearPresence(); - } - - void shutdown() { - discordRPC?.shutDown(); + Future clear() async { + await FlutterDiscordRPC.instance.clearActivity(); } - @override - void dispose() { - clear(); - shutdown(); - super.dispose(); + Future close() async { + await FlutterDiscordRPC.instance.disconnect(); } } -final discordProvider = ChangeNotifierProvider( - (ref) { - final isEnabled = - ref.watch(userPreferencesProvider.select((s) => s.discordPresence)); - final playback = ref.read(proxyPlaylistProvider); - final discord = Discord(isEnabled); - - if (playback.activeTrack != null) { - discord.updatePresence(playback.activeTrack!); - } - - return discord; - }, -); +final discordProvider = + AsyncNotifierProvider(() => DiscordNotifier()); diff --git a/lib/provider/download_manager_provider.dart b/lib/provider/download_manager_provider.dart index c964f982e..ec6ffc184 100644 --- a/lib/provider/download_manager_provider.dart +++ b/lib/provider/download_manager_provider.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:io'; -import 'package:catcher_2/catcher_2.dart'; +import 'package:spotube/services/logger/logger.dart'; import 'package:collection/collection.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; @@ -70,7 +70,7 @@ class DownloadManagerProvider extends ChangeNotifier { trackNumber: track.trackNumber, discNumber: track.discNumber, durationMs: track.durationMs?.toDouble() ?? 0.0, - fileSize: await file.length(), + fileSize: BigInt.from(await file.length()), trackTotal: track.album?.tracks?.length ?? 0, picture: imageBytes != null ? Picture( @@ -130,7 +130,7 @@ class DownloadManagerProvider extends ChangeNotifier { return Uint8List.fromList(bytes); } catch (e, stackTrace) { - Catcher2.reportCheckedError(e, stackTrace); + AppLogger.reportError(e, stackTrace); return null; } } @@ -216,7 +216,7 @@ class DownloadManagerProvider extends ChangeNotifier { ); } } catch (e) { - Catcher2.reportCheckedError(e, StackTrace.current); + AppLogger.reportError(e, StackTrace.current); continue; } } diff --git a/lib/provider/history/history.dart b/lib/provider/history/history.dart new file mode 100644 index 000000000..0c20a9e5c --- /dev/null +++ b/lib/provider/history/history.dart @@ -0,0 +1,68 @@ +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; + +class PlaybackHistoryActions { + final Ref ref; + AppDatabase get _db => ref.read(databaseProvider); + + PlaybackHistoryActions(this.ref); + + Future _batchInsertHistoryEntries( + List entries) async { + await _db.batch((batch) { + batch.insertAll(_db.historyTable, entries); + }); + } + + Future addPlaylists(List playlists) async { + await _batchInsertHistoryEntries([ + for (final playlist in playlists) + HistoryTableCompanion.insert( + type: HistoryEntryType.playlist, + itemId: playlist.id!, + data: playlist.toJson(), + ), + ]); + } + + Future addAlbums(List albums) async { + await _batchInsertHistoryEntries([ + for (final albums in albums) + HistoryTableCompanion.insert( + type: HistoryEntryType.album, + itemId: albums.id!, + data: albums.toJson(), + ), + ]); + } + + Future addTracks(List tracks) async { + await _batchInsertHistoryEntries([ + for (final track in tracks) + HistoryTableCompanion.insert( + type: HistoryEntryType.track, + itemId: track.id!, + data: track.toJson(), + ), + ]); + } + + Future addTrack(Track track) async { + await _db.into(_db.historyTable).insert( + HistoryTableCompanion.insert( + type: HistoryEntryType.track, + itemId: track.id!, + data: track.toJson(), + ), + ); + } + + Future clear() async { + _db.delete(_db.historyTable).go(); + } +} + +final playbackHistoryActionsProvider = + Provider((ref) => PlaybackHistoryActions(ref)); diff --git a/lib/provider/history/recent.dart b/lib/provider/history/recent.dart new file mode 100644 index 000000000..ef393a17a --- /dev/null +++ b/lib/provider/history/recent.dart @@ -0,0 +1,62 @@ +import 'package:collection/collection.dart'; +import 'package:drift/drift.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; + +class RecentlyPlayedItemNotifier extends AsyncNotifier> { + @override + build() async { + final database = ref.watch(databaseProvider); + + final uniqueItemIds = await (database.selectOnly( + database.historyTable, + distinct: true, + ) + ..addColumns([database.historyTable.itemId, database.historyTable.id]) + ..where( + database.historyTable.type.isInValues([ + HistoryEntryType.playlist, + HistoryEntryType.album, + ]), + ) + ..limit(10) + ..orderBy([ + OrderingTerm( + expression: database.historyTable.createdAt, + mode: OrderingMode.desc, + ), + ])) + .map( + (row) => row.read(database.historyTable.id), + ) + .get() + .then((value) => value.whereNotNull().toList()); + + final query = database.select(database.historyTable) + ..where( + (tbl) => tbl.id.isIn(uniqueItemIds), + ) + ..orderBy([ + (tbl) => OrderingTerm( + expression: tbl.createdAt, + mode: OrderingMode.desc, + ), + ]); + + final subscription = query.watch().listen((event) { + state = AsyncData(event); + }); + + ref.onDispose(() => subscription.cancel()); + + final items = await query.get(); + + return items; + } +} + +final recentlyPlayedItems = + AsyncNotifierProvider>( + () => RecentlyPlayedItemNotifier(), +); diff --git a/lib/provider/history/summary.dart b/lib/provider/history/summary.dart new file mode 100644 index 000000000..99df4c11a --- /dev/null +++ b/lib/provider/history/summary.dart @@ -0,0 +1,197 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:drift/drift.dart'; +import 'package:drift/extensions/json1.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; + +class PlaybackHistorySummary { + final Duration duration; + final int tracks; + final int artists; + final double fees; + final int albums; + final int playlists; + + const PlaybackHistorySummary({ + required this.duration, + required this.tracks, + required this.artists, + required this.fees, + required this.albums, + required this.playlists, + }); + + PlaybackHistorySummary copyWith({ + Duration? duration, + int? tracks, + int? artists, + double? fees, + int? albums, + int? playlists, + }) { + return PlaybackHistorySummary( + duration: duration ?? this.duration, + tracks: tracks ?? this.tracks, + artists: artists ?? this.artists, + fees: fees ?? this.fees, + albums: albums ?? this.albums, + playlists: playlists ?? this.playlists, + ); + } +} + +class PlaybackHistorySummaryNotifier + extends AsyncNotifier { + @override + build() async { + final database = ref.watch(databaseProvider); + + final uniqItemIdCountingCol = + database.historyTable.itemId.count(distinct: true); + final itemIdCountingCol = database.historyTable.itemId.count(); + final durationSumJsonColumn = + database.historyTable.data.jsonExtract(r"$.duration_ms").sum(); + final artistCountingCol = + database.historyTable.data.jsonExtract(r"$.artists"); + + final totalTracksListenedQuery = (database.selectOnly(database.historyTable) + ..addColumns([uniqItemIdCountingCol]) + ..where( + database.historyTable.type.equals(HistoryEntryType.track.name))) + .map((row) => row.read(uniqItemIdCountingCol)); + + final totalDurationListenedQuery = (database + .selectOnly(database.historyTable) + ..addColumns([durationSumJsonColumn]) + ..where( + database.historyTable.type.equals(HistoryEntryType.track.name))) + .map( + (row) => Duration(milliseconds: row.read(durationSumJsonColumn) ?? 0), + ); + + final totalArtistsListenedQuery = + (database.selectOnly(database.historyTable) + ..addColumns([artistCountingCol]) + ..where( + database.historyTable.type.equals(HistoryEntryType.track.name), + )) + .map( + (row) { + final data = jsonDecode(row.read(artistCountingCol)!) as List; + return data.map((e) => e['id'] as String).cast().toList(); + }, + ); + + final totalAlbumsListenedQuery = (database.selectOnly(database.historyTable) + ..addColumns([uniqItemIdCountingCol]) + ..where( + database.historyTable.type.equals(HistoryEntryType.album.name))) + .map((row) => row.read(uniqItemIdCountingCol)); + + final totalPlaylistsListenedQuery = + (database.selectOnly(database.historyTable) + ..addColumns([uniqItemIdCountingCol]) + ..where( + database.historyTable.type + .equals(HistoryEntryType.playlist.name), + )) + .map((row) => row.read(uniqItemIdCountingCol)); + + final oldestDate = DateTime.now().copyWith(day: 1, hour: 0, minute: 0); + final newestDate = DateTime.now().copyWith(day: 30, hour: 23, minute: 59); + final totalTracksListenedThisMonthQuery = + (database.selectOnly(database.historyTable) + ..addColumns([itemIdCountingCol]) + ..where( + database.historyTable.type.equals( + HistoryEntryType.track.name, + ) & + database.historyTable.createdAt + .isBetweenValues(oldestDate, newestDate), + )) + .map((row) => row.read(itemIdCountingCol)); + + final subscriptions = [ + totalTracksListenedQuery.watchSingle().listen((event) { + if (event == null || state.asData == null) return; + state = AsyncData(state.asData!.value.copyWith( + tracks: event, + )); + }), + totalDurationListenedQuery.watchSingle().listen((event) { + if (state.asData == null) return; + state = AsyncData(state.asData!.value.copyWith( + duration: event, + )); + }), + totalArtistsListenedQuery.watch().listen((event) { + if (state.asData == null) return; + state = AsyncData(state.asData!.value.copyWith( + artists: event.expand((e) => e).toSet().length, + )); + }), + totalAlbumsListenedQuery.watchSingle().listen((event) { + if (event == null || state.asData == null) return; + state = AsyncData(state.asData!.value.copyWith( + albums: event, + )); + }), + totalPlaylistsListenedQuery.watchSingle().listen((event) { + if (event == null || state.asData == null) return; + state = AsyncData(state.asData!.value.copyWith( + playlists: event, + )); + }), + totalTracksListenedThisMonthQuery.watchSingle().listen((event) { + if (event == null || state.asData == null) return; + state = AsyncData(state.asData!.value.copyWith( + fees: event * 0.005, + )); + }), + ]; + + ref.onDispose(() { + for (final subscription in subscriptions) { + subscription.cancel(); + } + }); + + return database.transaction(() async { + final totalTracksListened = + await totalTracksListenedQuery.getSingle() ?? 0; + + final totalDurationListened = + await totalDurationListenedQuery.getSingle(); + + final totalArtistsListened = await totalArtistsListenedQuery + .get() + .then((value) => value.expand((e) => e).toSet().length); + + final totalAlbumsListened = + await totalAlbumsListenedQuery.getSingle() ?? 0; + + final totalPlaylistsListened = + await totalPlaylistsListenedQuery.getSingle() ?? 0; + + final totalTracksListenedThisMonth = + await totalTracksListenedThisMonthQuery.getSingle() ?? 0; + + return PlaybackHistorySummary( + duration: totalDurationListened, + tracks: totalTracksListened, + artists: totalArtistsListened, + fees: totalTracksListenedThisMonth * 0.005, + albums: totalAlbumsListened, + playlists: totalPlaylistsListened, + ); + }); + } +} + +final playbackHistorySummaryProvider = AsyncNotifierProvider< + PlaybackHistorySummaryNotifier, PlaybackHistorySummary>( + () => PlaybackHistorySummaryNotifier(), +); diff --git a/lib/provider/history/top.dart b/lib/provider/history/top.dart new file mode 100644 index 000000000..b52e65e20 --- /dev/null +++ b/lib/provider/history/top.dart @@ -0,0 +1,17 @@ +import 'package:hooks_riverpod/hooks_riverpod.dart'; + +enum HistoryDuration { + allTime(Duration(days: 365 * 2003)), + days7(Duration(days: 7)), + days30(Duration(days: 30)), + months6(Duration(days: 30 * 6)), + year(Duration(days: 365)), + years2(Duration(days: 365 * 2)); + + final Duration duration; + + const HistoryDuration(this.duration); +} + +final playbackHistoryTopDurationProvider = + StateProvider((ref) => HistoryDuration.days30); diff --git a/lib/provider/history/top/albums.dart b/lib/provider/history/top/albums.dart new file mode 100644 index 000000000..7448a8496 --- /dev/null +++ b/lib/provider/history/top/albums.dart @@ -0,0 +1,136 @@ +import 'dart:convert'; + +import 'package:collection/collection.dart'; +import 'package:drift/drift.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/provider/database/database.dart'; +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; + +typedef PlaybackHistoryAlbum = ({int count, AlbumSimple album}); + +class HistoryTopAlbumsState extends PaginatedState { + HistoryTopAlbumsState({ + required super.items, + required super.offset, + required super.limit, + required super.hasMore, + }); + + @override + HistoryTopAlbumsState copyWith({ + List? items, + int? offset, + int? limit, + bool? hasMore, + }) { + return HistoryTopAlbumsState( + items: items ?? this.items, + offset: offset ?? this.offset, + limit: limit ?? this.limit, + hasMore: hasMore ?? this.hasMore, + ); + } +} + +class HistoryTopAlbumsNotifier extends FamilyPaginatedAsyncNotifier< + PlaybackHistoryAlbum, HistoryTopAlbumsState, HistoryDuration> { + HistoryTopAlbumsNotifier() : super(); + + Selectable createAlbumsQuery({int? limit, int? offset}) { + final database = ref.read(databaseProvider); + + final duration = switch (arg) { + HistoryDuration.allTime => '0', + HistoryDuration.days7 => "strftime('%s', 'now', 'weekday 0', '-7 days')", + HistoryDuration.days30 => "strftime('%s', 'now', 'start of month')", + HistoryDuration.months6 => + "strftime('%s', date('now', '-5 months', 'start of month'))", + HistoryDuration.year => "strftime('%s', date('now', 'start of year'))", + HistoryDuration.years2 => + "strftime('%s', date('now', '-1 years', 'start of year'))", + }; + + return database.customSelect( + """ + SELECT + history_table.created_at, + """ + r""" + json_extract(history_table.data, '$.album') as data, + json_extract(history_table.data, '$.album.id') as item_id, + 'album' as type + """ + """ + FROM history_table + WHERE type = 'track' AND + created_at >= $duration + UNION ALL + SELECT + history_table.created_at, + history_table.data, + history_table.item_id, + history_table.type + FROM history_table + WHERE type = 'album' AND + created_at >= $duration + ORDER BY created_at desc + ${limit != null && offset != null ? 'LIMIT $limit OFFSET $offset' : ''} + """, + readsFrom: {database.historyTable}, + ).map((row) { + final data = row.read('data'); + final album = AlbumSimple.fromJson(jsonDecode(data)); + return album; + }); + } + + @override + fetch(arg, offset, limit) async { + final albumsQuery = createAlbumsQuery(limit: limit, offset: offset); + + return getAlbumsWithCount(await albumsQuery.get()); + } + + @override + build(arg) async { + final albums = await fetch(arg, 0, 20); + + final subscription = createAlbumsQuery().watch().listen((event) { + if (state.asData == null) return; + state = AsyncData(state.asData!.value.copyWith( + items: getAlbumsWithCount(event), + hasMore: false, + )); + }); + + ref.onDispose(() { + subscription.cancel(); + }); + + return HistoryTopAlbumsState( + items: albums, + offset: albums.length, + limit: 20, + hasMore: true, + ); + } + + List getAlbumsWithCount( + List albumsWithTrackAlbums, + ) { + return groupBy(albumsWithTrackAlbums, (album) => album.id!) + .entries + .map((entry) { + return (count: entry.value.length, album: entry.value.first); + }) + .sorted((a, b) => b.count.compareTo(a.count)) + .toList(); + } +} + +final historyTopAlbumsProvider = AsyncNotifierProviderFamily< + HistoryTopAlbumsNotifier, HistoryTopAlbumsState, HistoryDuration>( + () => HistoryTopAlbumsNotifier(), +); diff --git a/lib/provider/history/top/playlists.dart b/lib/provider/history/top/playlists.dart new file mode 100644 index 000000000..04071f7a4 --- /dev/null +++ b/lib/provider/history/top/playlists.dart @@ -0,0 +1,104 @@ +import 'package:collection/collection.dart'; +import 'package:drift/drift.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; + +typedef PlaybackHistoryPlaylist = ({int count, PlaylistSimple playlist}); + +class HistoryTopPlaylistsState extends PaginatedState { + HistoryTopPlaylistsState({ + required super.items, + required super.offset, + required super.limit, + required super.hasMore, + }); + + @override + HistoryTopPlaylistsState copyWith({ + List? items, + int? offset, + int? limit, + bool? hasMore, + }) { + return HistoryTopPlaylistsState( + items: items ?? this.items, + offset: offset ?? this.offset, + limit: limit ?? this.limit, + hasMore: hasMore ?? this.hasMore, + ); + } +} + +class HistoryTopPlaylistsNotifier extends FamilyPaginatedAsyncNotifier< + PlaybackHistoryPlaylist, HistoryTopPlaylistsState, HistoryDuration> { + HistoryTopPlaylistsNotifier() : super(); + + SimpleSelectStatement<$HistoryTableTable, HistoryTableData> + createPlaylistsQuery() { + final database = ref.read(databaseProvider); + + return database.select(database.historyTable) + ..where( + (tbl) => + tbl.type.equalsValue(HistoryEntryType.playlist) & + tbl.createdAt.isBiggerOrEqualValue( + DateTime.now().subtract(arg.duration), + ), + ); + } + + @override + fetch(arg, offset, limit) async { + final playlistsQuery = createPlaylistsQuery()..limit(limit, offset: offset); + + return getPlaylistsWithCount(await playlistsQuery.get()); + } + + @override + build(arg) async { + final playlists = await fetch(arg, 0, 20); + + final subscription = createPlaylistsQuery().watch().listen((event) { + if (state.asData == null) return; + state = AsyncData(state.asData!.value.copyWith( + items: getPlaylistsWithCount(event), + hasMore: false, + )); + }); + + ref.onDispose(() { + subscription.cancel(); + }); + + return HistoryTopPlaylistsState( + items: playlists, + offset: playlists.length, + limit: 20, + hasMore: true, + ); + } + + List getPlaylistsWithCount( + List playlists, + ) { + return groupBy(playlists, (playlist) => playlist.playlist!.id!) + .entries + .map((entry) { + return ( + count: entry.value.length, + playlist: entry.value.first.playlist!, + ); + }) + .sorted((a, b) => b.count.compareTo(a.count)) + .toList(); + } +} + +final historyTopPlaylistsProvider = AsyncNotifierProviderFamily< + HistoryTopPlaylistsNotifier, HistoryTopPlaylistsState, HistoryDuration>( + () => HistoryTopPlaylistsNotifier(), +); diff --git a/lib/provider/history/top/tracks.dart b/lib/provider/history/top/tracks.dart new file mode 100644 index 000000000..56795cc6c --- /dev/null +++ b/lib/provider/history/top/tracks.dart @@ -0,0 +1,136 @@ +import 'package:collection/collection.dart'; +import 'package:drift/drift.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; +import 'package:spotube/provider/history/top.dart'; +import 'package:spotube/provider/spotify/spotify.dart'; + +typedef PlaybackHistoryTrack = ({int count, Track track}); +typedef PlaybackHistoryArtist = ({int count, Artist artist}); + +class HistoryTopTracksState extends PaginatedState { + HistoryTopTracksState({ + required super.items, + required super.offset, + required super.limit, + required super.hasMore, + }); + + List get artists { + return getArtistsWithCount( + items.expand((e) => e.track.artists ?? []), + ); + } + + List getArtistsWithCount(Iterable artists) { + return groupBy(artists, (artist) => artist.id!) + .entries + .map((entry) { + return (count: entry.value.length, artist: entry.value.first); + }) + .sorted((a, b) => b.count.compareTo(a.count)) + .toList(); + } + + @override + HistoryTopTracksState copyWith({ + List? items, + int? offset, + int? limit, + bool? hasMore, + }) { + return HistoryTopTracksState( + items: items ?? this.items, + offset: offset ?? this.offset, + limit: limit ?? this.limit, + hasMore: hasMore ?? this.hasMore, + ); + } +} + +class HistoryTopTracksNotifier extends FamilyPaginatedAsyncNotifier< + PlaybackHistoryTrack, HistoryTopTracksState, HistoryDuration> { + HistoryTopTracksNotifier() : super(); + + SimpleSelectStatement<$HistoryTableTable, HistoryTableData> + createTracksQuery() { + final database = ref.read(databaseProvider); + + return database.select(database.historyTable) + ..where( + (tbl) => + tbl.type.equalsValue(HistoryEntryType.track) & + tbl.createdAt.isBiggerOrEqualValue(switch (arg) { + HistoryDuration.allTime => DateTime(1970), + // from start of the week + HistoryDuration.days7 => DateTime.now() + .subtract(Duration(days: DateTime.now().weekday - 1)), + // from start of the month + HistoryDuration.days30 => + DateTime.now().subtract(Duration(days: DateTime.now().day - 1)), + // from start of the 6th month + HistoryDuration.months6 => DateTime.now() + .subtract(Duration(days: DateTime.now().day - 1)) + .subtract(const Duration(days: 30 * 6)), + // from start of the year + HistoryDuration.year => DateTime.now() + .subtract(Duration(days: DateTime.now().day - 1)) + .subtract(const Duration(days: 30 * 12)), + HistoryDuration.years2 => DateTime.now() + .subtract(Duration(days: DateTime.now().day - 1)) + .subtract(const Duration(days: 30 * 12 * 2)), + }), + ); + } + + @override + fetch(arg, offset, limit) async { + final tracksQuery = createTracksQuery()..limit(limit, offset: offset); + + return getTracksWithCount(await tracksQuery.get()); + } + + @override + build(arg) async { + final tracks = await fetch(arg, 0, 20); + + final subscription = createTracksQuery().watch().listen((event) { + if (state.asData == null) return; + state = AsyncData(state.asData!.value.copyWith( + items: getTracksWithCount(event), + hasMore: false, + )); + }); + + ref.onDispose(() { + subscription.cancel(); + }); + + return HistoryTopTracksState( + items: tracks, + offset: tracks.length, + limit: 20, + hasMore: true, + ); + } + + List getTracksWithCount(List tracks) { + return groupBy( + tracks, + (track) => track.track!.id!, + ) + .entries + .map((entry) { + return (count: entry.value.length, track: entry.value.first.track!); + }) + .sorted((a, b) => b.count.compareTo(a.count)) + .toList(); + } +} + +final historyTopTracksProvider = AsyncNotifierProviderFamily< + HistoryTopTracksNotifier, HistoryTopTracksState, HistoryDuration>( + () => HistoryTopTracksNotifier(), +); diff --git a/lib/provider/local_tracks/local_tracks_provider.dart b/lib/provider/local_tracks/local_tracks_provider.dart new file mode 100644 index 000000000..ca22d8419 --- /dev/null +++ b/lib/provider/local_tracks/local_tracks_provider.dart @@ -0,0 +1,129 @@ +import 'dart:async'; +import 'dart:io'; + +import 'package:spotube/services/logger/logger.dart'; +import 'package:flutter/foundation.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:metadata_god/metadata_god.dart'; +import 'package:mime/mime.dart'; +import 'package:path/path.dart'; +import 'package:path_provider/path_provider.dart'; + +import 'package:spotify/spotify.dart'; +import 'package:spotube/extensions/track.dart'; +import 'package:spotube/models/local_track.dart'; +import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +// ignore: depend_on_referenced_packages +import 'package:flutter_rust_bridge/flutter_rust_bridge.dart' show FrbException; + +const supportedAudioTypes = [ + "audio/webm", + "audio/ogg", + "audio/mpeg", + "audio/mp4", + "audio/opus", + "audio/wav", + "audio/aac", +]; + +const imgMimeToExt = { + "image/png": ".png", + "image/jpeg": ".jpg", + "image/webp": ".webp", + "image/gif": ".gif", +}; + +final localTracksProvider = + FutureProvider>>((ref) async { + try { + if (kIsWeb) return {}; + final Map> libraryToTracks = {}; + + final downloadLocation = ref.watch( + userPreferencesProvider.select((s) => s.downloadLocation), + ); + final downloadDir = Directory(downloadLocation); + if (!await downloadDir.exists()) { + await downloadDir.create(recursive: true); + } + final localLibraryLocations = ref.watch( + userPreferencesProvider.select((s) => s.localLibraryLocation), + ); + + for (final location in [downloadLocation, ...localLibraryLocations]) { + if (location.isEmpty) continue; + final entities = []; + if (await Directory(location).exists()) { + try { + final dirEntities = + await Directory(location).list(recursive: true).toList(); + + entities.addAll( + dirEntities + .where( + (e) => + e is File && + supportedAudioTypes.contains(lookupMimeType(e.path)), + ) + .cast(), + ); + } catch (e, stack) { + AppLogger.reportError(e, stack); + } + } + + final List> filesWithMetadata = []; + + for (final file in entities) { + try { + final metadata = await MetadataGod.readMetadata(file: file.path); + + await Future.delayed(const Duration(milliseconds: 50)); + + final imageFile = File(join( + (await getTemporaryDirectory()).path, + "spotube", + basenameWithoutExtension(file.path) + + imgMimeToExt[metadata.picture?.mimeType ?? "image/jpeg"]!, + )); + if (!await imageFile.exists() && metadata.picture != null) { + await imageFile.create(recursive: true); + await imageFile.writeAsBytes( + metadata.picture?.data ?? [], + mode: FileMode.writeOnly, + ); + } + + filesWithMetadata.add( + {"metadata": metadata, "file": file, "art": imageFile.path}, + ); + } catch (e, stack) { + if (e case FrbException() || TimeoutException()) { + filesWithMetadata.add({"file": file}); + } + AppLogger.reportError(e, stack); + continue; + } + } + + final tracksFromMetadata = filesWithMetadata + .map( + (fileWithMetadata) => LocalTrack.fromTrack( + track: Track().fromFile( + fileWithMetadata["file"], + metadata: fileWithMetadata["metadata"], + art: fileWithMetadata["art"], + ), + path: fileWithMetadata["file"].path, + ), + ) + .toList(); + + libraryToTracks[location] = tracksFromMetadata; + } + return libraryToTracks; + } catch (e, stack) { + AppLogger.reportError(e, stack); + return {}; + } +}); diff --git a/lib/provider/logs/logs_provider.dart b/lib/provider/logs/logs_provider.dart new file mode 100644 index 000000000..b0e95caed --- /dev/null +++ b/lib/provider/logs/logs_provider.dart @@ -0,0 +1,12 @@ +import 'dart:convert'; + +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/services/logger/logger.dart'; + +final logsProvider = StreamProvider.autoDispose((ref) async* { + final file = await AppLogger.getLogsPath(); + final stream = file.openRead().transform(utf8.decoder); + await for (final line in stream) { + yield line; + } +}); diff --git a/lib/provider/piped_instances_provider.dart b/lib/provider/piped_instances_provider.dart index d571f7308..3c5d5f043 100644 --- a/lib/provider/piped_instances_provider.dart +++ b/lib/provider/piped_instances_provider.dart @@ -1,4 +1,4 @@ -import 'package:catcher_2/catcher_2.dart'; +import 'package:spotube/services/logger/logger.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:piped_client/piped_client.dart'; import 'package:spotube/services/sourced_track/sources/piped.dart'; @@ -10,7 +10,7 @@ final pipedInstancesFutureProvider = FutureProvider>( return await pipedClient.instanceList(); } catch (e, stack) { - Catcher2.reportCheckedError(e, stack); + AppLogger.reportError(e, stack); return []; } }, diff --git a/lib/provider/proxy_playlist/player_listeners.dart b/lib/provider/proxy_playlist/player_listeners.dart deleted file mode 100644 index f86ad3d47..000000000 --- a/lib/provider/proxy_playlist/player_listeners.dart +++ /dev/null @@ -1,88 +0,0 @@ -// ignore_for_file: invalid_use_of_protected_member - -import 'dart:async'; - -import 'package:catcher_2/catcher_2.dart'; -import 'package:spotube/models/local_track.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; -import 'package:spotube/provider/proxy_playlist/skip_segments.dart'; -import 'package:spotube/provider/server/sourced_track.dart'; -import 'package:spotube/services/audio_player/audio_player.dart'; - -extension ProxyPlaylistListeners on ProxyPlaylistNotifier { - StreamSubscription subscribeToPlaylist() { - return audioPlayer.playlistStream.listen((playlist) { - state = state.copyWith( - tracks: playlist.medias - .map((media) => SpotubeMedia.fromMedia(media).track) - .toSet(), - active: playlist.index, - ); - - notificationService.addTrack(state.activeTrack!); - discord.updatePresence(state.activeTrack!); - updatePalette(); - }); - } - - StreamSubscription subscribeToSkipSponsor() { - return audioPlayer.positionStream.listen((position) async { - final currentSegments = await ref.read(segmentProvider.future); - - if (currentSegments?.segments.isNotEmpty != true || - position < const Duration(seconds: 3)) return; - - for (final segment in currentSegments!.segments) { - final seconds = position.inSeconds; - - if (seconds < segment.start || seconds >= segment.end) continue; - - await audioPlayer.seek(Duration(seconds: segment.end + 1)); - } - }); - } - - StreamSubscription subscribeToScrobbleChanged() { - String? lastScrobbled; - return audioPlayer.positionStream.listen((position) { - try { - final uid = state.activeTrack is LocalTrack - ? (state.activeTrack as LocalTrack).path - : state.activeTrack?.id; - - if (state.activeTrack == null || - lastScrobbled == uid || - position.inSeconds < 30) { - return; - } - - scrobbler.scrobble(state.activeTrack!); - lastScrobbled = uid; - } catch (e, stack) { - Catcher2.reportCheckedError(e, stack); - } - }); - } - - StreamSubscription subscribeToPosition() { - String lastTrack = ""; // used to prevent multiple calls to the same track - return audioPlayer.positionStream.listen((event) async { - if (event < const Duration(seconds: 3) || - state.active == null || - state.active == state.tracks.length - 1) return; - final nextTrack = state.tracks.elementAt(state.active! + 1); - - if (lastTrack == nextTrack.id || nextTrack is LocalTrack) return; - - try { - await ref.read(sourcedTrackProvider(nextTrack).future); - } finally { - lastTrack = nextTrack.id!; - } - }); - } - - StreamSubscription subscribeToPlayerError() { - return audioPlayer.errorStream.listen((event) {}); - } -} diff --git a/lib/provider/proxy_playlist/proxy_playlist.dart b/lib/provider/proxy_playlist/proxy_playlist.dart deleted file mode 100644 index f70301ff4..000000000 --- a/lib/provider/proxy_playlist/proxy_playlist.dart +++ /dev/null @@ -1,93 +0,0 @@ -import 'package:collection/collection.dart'; -import 'package:spotify/spotify.dart'; -import 'package:spotube/extensions/track.dart'; -import 'package:spotube/models/local_track.dart'; -import 'package:spotube/services/sourced_track/sourced_track.dart'; - -class ProxyPlaylist { - final Set tracks; - final Set collections; - final int? active; - - ProxyPlaylist(this.tracks, [this.active, this.collections = const {}]); - - factory ProxyPlaylist.fromJson( - Map json, - ) { - return ProxyPlaylist( - List.castFrom>( - json['tracks'] ?? >[], - ).map((t) => _makeAppropriateTrack(t)).toSet(), - json['active'] as int?, - json['collections'] == null - ? {} - : (json['collections'] as List).toSet().cast(), - ); - } - - factory ProxyPlaylist.fromJsonRaw(Map json) => ProxyPlaylist( - json['tracks'] == null - ? {} - : (json['tracks'] as List).map((t) => Track.fromJson(t)).toSet(), - json['active'] as int?, - json['collections'] == null - ? {} - : (json['collections'] as List).toSet().cast(), - ); - - Track? get activeTrack => - active == null || active == -1 ? null : tracks.elementAtOrNull(active!); - - bool get isFetching => activeTrack == null && tracks.isNotEmpty; - - bool containsCollection(String collection) { - return collections.contains(collection); - } - - bool containsTrack(TrackSimple track) { - return tracks.firstWhereOrNull((element) => element.id == track.id) != null; - } - - bool containsTracks(Iterable tracks) { - if (tracks.isEmpty) return false; - return tracks.every(containsTrack); - } - - static Track _makeAppropriateTrack(Map track) { - if (track.containsKey("path")) { - return LocalTrack.fromJson(track); - } else { - return Track.fromJson(track); - } - } - - /// To make sure proper instance method is used for JSON serialization - /// Otherwise default super.toJson() is used - static Map _makeAppropriateTrackJson(Track track) { - return switch (track.runtimeType) { - LocalTrack() => track.toJson(), - SourcedTrack() => track.toJson(), - _ => track.toJson(), - }; - } - - Map toJson() { - return { - 'tracks': tracks.map(_makeAppropriateTrackJson).toList(), - 'active': active, - 'collections': collections.toList(), - }; - } - - ProxyPlaylist copyWith({ - Set? tracks, - int? active, - Set? collections, - }) { - return ProxyPlaylist( - tracks ?? this.tracks, - active ?? this.active, - collections ?? this.collections, - ); - } -} diff --git a/lib/provider/proxy_playlist/proxy_playlist_provider.dart b/lib/provider/proxy_playlist/proxy_playlist_provider.dart deleted file mode 100644 index 9811a1f8e..000000000 --- a/lib/provider/proxy_playlist/proxy_playlist_provider.dart +++ /dev/null @@ -1,237 +0,0 @@ -import 'dart:async'; -import 'dart:math'; - -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:palette_generator/palette_generator.dart'; -import 'package:spotify/spotify.dart'; -import 'package:spotube/components/shared/image/universal_image.dart'; -import 'package:spotube/extensions/image.dart'; -import 'package:spotube/extensions/track.dart'; -import 'package:spotube/models/local_track.dart'; - -import 'package:spotube/provider/blacklist_provider.dart'; -import 'package:spotube/provider/palette_provider.dart'; -import 'package:spotube/provider/proxy_playlist/player_listeners.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist.dart'; -import 'package:spotube/provider/scrobbler_provider.dart'; -import 'package:spotube/provider/server/sourced_track.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; -import 'package:spotube/services/audio_player/audio_player.dart'; -import 'package:spotube/services/audio_services/audio_services.dart'; -import 'package:spotube/provider/discord_provider.dart'; - -import 'package:spotube/utils/persisted_state_notifier.dart'; - -class ProxyPlaylistNotifier extends PersistedStateNotifier { - final Ref ref; - late final AudioServices notificationService; - - ScrobblerNotifier get scrobbler => ref.read(scrobblerProvider.notifier); - UserPreferences get preferences => ref.read(userPreferencesProvider); - ProxyPlaylist get playlist => state; - BlackListNotifier get blacklist => ref.read(blacklistProvider.notifier); - Discord get discord => ref.read(discordProvider); - - List _subscriptions = []; - - ProxyPlaylistNotifier(this.ref) : super(ProxyPlaylist({}), "playlist") { - AudioServices.create(ref, this).then( - (value) => notificationService = value, - ); - - _subscriptions = [ - // These are subscription methods from player_listeners.dart - subscribeToPlaylist(), - subscribeToSkipSponsor(), - subscribeToPosition(), - subscribeToScrobbleChanged(), - ]; - } - // Basic methods for adding or removing tracks to playlist - - Future addTrack(Track track) async { - if (blacklist.contains(track)) return; - await audioPlayer.addTrack(SpotubeMedia(track)); - } - - Future addTracks(Iterable tracks) async { - tracks = blacklist.filter(tracks).toList() as List; - for (final track in tracks) { - await audioPlayer.addTrack(SpotubeMedia(track)); - } - } - - void addCollection(String collectionId) { - state = state.copyWith(collections: { - ...state.collections, - collectionId, - }); - } - - void removeCollection(String collectionId) { - state = state.copyWith(collections: { - ...state.collections..remove(collectionId), - }); - } - - Future removeTrack(String trackId) async { - final trackIndex = - state.tracks.toList().indexWhere((element) => element.id == trackId); - if (trackIndex == -1) return; - await audioPlayer.removeTrack(trackIndex); - } - - Future removeTracks(Iterable tracksIds) async { - final tracks = state.tracks.map((t) => t.id!).toList(); - - for (final track in tracks) { - final index = tracks.indexOf(track); - if (index == -1) continue; - await audioPlayer.removeTrack(index); - } - } - - Future load( - Iterable tracks, { - int initialIndex = 0, - bool autoPlay = false, - }) async { - tracks = blacklist.filter(tracks).toList() as List; - - state = state.copyWith(collections: {}); - - // Giving the initial track a boost so MediaKit won't skip - // because of timeout - final intendedActiveTrack = tracks.elementAt(initialIndex); - if (intendedActiveTrack is! LocalTrack) { - await ref.read(sourcedTrackProvider(intendedActiveTrack).future); - } - - await audioPlayer.openPlaylist( - tracks.asMediaList(), - initialIndex: initialIndex, - autoPlay: autoPlay, - ); - } - - Future jumpTo(int index) async { - await audioPlayer.jumpTo(index); - } - - Future jumpToTrack(Track track) async { - final index = - state.tracks.toList().indexWhere((element) => element.id == track.id); - if (index == -1) return; - await jumpTo(index); - } - - Future moveTrack(int oldIndex, int newIndex) async { - if (oldIndex == newIndex || - newIndex < 0 || - oldIndex < 0 || - newIndex > state.tracks.length - 1 || - oldIndex > state.tracks.length - 1) return; - - await audioPlayer.moveTrack(oldIndex, newIndex); - } - - Future addTracksAtFirst(Iterable tracks) async { - if (state.tracks.length == 1) { - return addTracks(tracks); - } - - tracks = blacklist.filter(tracks).toList() as List; - - for (int i = 0; i < tracks.length; i++) { - final track = tracks.elementAt(i); - - await audioPlayer.addTrackAt( - SpotubeMedia(track), - (state.active ?? 0) + i + 1, - ); - } - } - - Future next() async { - await audioPlayer.skipToNext(); - } - - Future previous() async { - await audioPlayer.skipToPrevious(); - } - - Future stop() async { - state = ProxyPlaylist({}); - await audioPlayer.stop(); - discord.clear(); - } - - Future updatePalette() async { - final palette = ref.read(paletteProvider); - if (!preferences.albumColorSync) { - if (palette != null) ref.read(paletteProvider.notifier).state = null; - return; - } - return Future.microtask(() async { - if (state.activeTrack == null) return; - - final palette = await PaletteGenerator.fromImageProvider( - UniversalImage.imageProvider( - (state.activeTrack?.album?.images).asUrlString( - placeholder: ImagePlaceholder.albumArt, - ), - height: 50, - width: 50, - ), - ); - ref.read(paletteProvider.notifier).state = palette; - }); - } - - @override - set state(state) { - super.state = state; - if (state.tracks.isEmpty && ref.read(paletteProvider) != null) { - ref.read(paletteProvider.notifier).state = null; - } else { - updatePalette(); - } - } - - @override - onInit() async { - if (state.tracks.isEmpty) return null; - final oldCollections = state.collections; - await load( - state.tracks, - initialIndex: max(state.active ?? 0, 0), - autoPlay: false, - ); - state = state.copyWith(collections: oldCollections); - } - - @override - FutureOr fromJson(Map json) { - return ProxyPlaylist.fromJson(json); - } - - @override - Map toJson() { - final json = state.toJson(); - return json; - } - - @override - void dispose() { - for (final subscription in _subscriptions) { - subscription.cancel(); - } - super.dispose(); - } -} - -final proxyPlaylistProvider = - StateNotifierProvider( - (ref) => ProxyPlaylistNotifier(ref), -); diff --git a/lib/provider/proxy_playlist/skip_segments.dart b/lib/provider/proxy_playlist/skip_segments.dart deleted file mode 100644 index 2d90eea63..000000000 --- a/lib/provider/proxy_playlist/skip_segments.dart +++ /dev/null @@ -1,104 +0,0 @@ -import 'dart:convert'; - -import 'package:catcher_2/catcher_2.dart'; -import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:http/http.dart'; -import 'package:spotube/models/skip_segment.dart'; -import 'package:spotube/provider/server/active_sourced_track.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; - -class SourcedSegments { - final String source; - final List segments; - - SourcedSegments({required this.source, required this.segments}); -} - -Future> getAndCacheSkipSegments(String id) async { - try { - final cached = await SkipSegment.box.get(id) as List?; - if (cached != null && cached.isNotEmpty) { - return List.castFrom( - cached - .map( - (json) => SkipSegment.fromJson( - Map.castFrom(json), - ), - ) - .toList(), - ); - } - - final res = await get(Uri( - scheme: "https", - host: "sponsor.ajay.app", - path: "/api/skipSegments", - queryParameters: { - "videoID": id, - "category": [ - 'sponsor', - 'selfpromo', - 'interaction', - 'intro', - 'outro', - 'music_offtopic' - ], - "actionType": 'skip' - }, - )); - - if (res.body == "Not Found") { - return List.castFrom([]); - } - - final data = jsonDecode(res.body) as List; - final segments = data.map((obj) { - final start = obj["segment"].first.toInt(); - final end = obj["segment"].last.toInt(); - return SkipSegment(start, end); - }).toList(); - - await SkipSegment.box.put( - id, - segments.map((e) => e.toJson()).toList(), - ); - return List.castFrom(segments); - } catch (e, stack) { - await SkipSegment.box.put(id, []); - Catcher2.reportCheckedError(e, stack); - return List.castFrom([]); - } -} - -final segmentProvider = FutureProvider( - (ref) async { - final track = ref.watch(activeSourcedTrackProvider); - if (track == null) return null; - - final skipNonMusic = ref.watch( - userPreferencesProvider.select( - (s) { - final isPipedYTMusicMode = s.audioSource == AudioSource.piped && - s.searchMode == SearchMode.youtubeMusic; - - return s.skipNonMusic && !isPipedYTMusicMode; - }, - ), - ); - - if (!skipNonMusic) { - return SourcedSegments( - segments: [], - source: track.sourceInfo.id, - ); - } - - final segments = await getAndCacheSkipSegments(track.sourceInfo.id); - - return SourcedSegments( - source: track.sourceInfo.id, - segments: segments, - ); - }, -); diff --git a/lib/provider/scrobbler/scrobbler.dart b/lib/provider/scrobbler/scrobbler.dart new file mode 100644 index 000000000..76559d698 --- /dev/null +++ b/lib/provider/scrobbler/scrobbler.dart @@ -0,0 +1,130 @@ +import 'dart:async'; + +import 'package:drift/drift.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:scrobblenaut/scrobblenaut.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/collections/env.dart'; +import 'package:spotube/extensions/artist_simple.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; +import 'package:spotube/services/logger/logger.dart'; + +class ScrobblerNotifier extends AsyncNotifier { + final StreamController _scrobbleController = + StreamController.broadcast(); + @override + build() async { + final database = ref.watch(databaseProvider); + + final loginInfo = await (database.select(database.scrobblerTable) + ..where((t) => t.id.equals(0))) + .getSingleOrNull(); + + final subscription = + database.select(database.scrobblerTable).watch().listen((event) async { + if (event.isNotEmpty) { + state = await AsyncValue.guard( + () async => Scrobblenaut( + lastFM: await LastFM.authenticateWithPasswordHash( + apiKey: Env.lastFmApiKey, + apiSecret: Env.lastFmApiSecret, + username: event.first.username, + passwordHash: event.first.passwordHash.value, + ), + ), + ); + } else { + state = const AsyncValue.data(null); + } + }); + + final scrobblerSubscription = + _scrobbleController.stream.listen((track) async { + try { + await state.asData?.value?.track.scrobble( + artist: track.artists!.first.name!, + track: track.name!, + album: track.album!.name!, + chosenByUser: true, + duration: track.duration, + timestamp: DateTime.now().toUtc(), + trackNumber: track.trackNumber, + ); + } catch (e, stackTrace) { + AppLogger.reportError(e, stackTrace); + } + }); + + ref.onDispose(() { + subscription.cancel(); + scrobblerSubscription.cancel(); + }); + + if (loginInfo == null) { + return null; + } + + return Scrobblenaut( + lastFM: await LastFM.authenticateWithPasswordHash( + apiKey: Env.lastFmApiKey, + apiSecret: Env.lastFmApiSecret, + username: loginInfo.username, + passwordHash: loginInfo.passwordHash.value, + ), + ); + } + + Future login( + String username, + String password, + ) async { + final database = ref.read(databaseProvider); + + final lastFm = await LastFM.authenticate( + apiKey: Env.lastFmApiKey, + apiSecret: Env.lastFmApiSecret, + username: username, + password: password, + ); + + if (!lastFm.isAuth) throw Exception("Invalid credentials"); + + await database.into(database.scrobblerTable).insert( + ScrobblerTableCompanion.insert( + id: const Value(0), + username: username, + passwordHash: DecryptedText(lastFm.passwordHash!), + ), + ); + } + + Future logout() async { + state = const AsyncValue.data(null); + final database = ref.read(databaseProvider); + await database.delete(database.scrobblerTable).go(); + } + + void scrobble(Track track) { + _scrobbleController.add(track); + } + + Future love(Track track) async { + await state.asData?.value?.track.love( + artist: track.artists!.asString(), + track: track.name!, + ); + } + + Future unlove(Track track) async { + await state.asData?.value?.track.unLove( + artist: track.artists!.asString(), + track: track.name!, + ); + } +} + +final scrobblerProvider = + AsyncNotifierProvider( + () => ScrobblerNotifier(), +); diff --git a/lib/provider/scrobbler_provider.dart b/lib/provider/scrobbler_provider.dart deleted file mode 100644 index 9ad2a58ba..000000000 --- a/lib/provider/scrobbler_provider.dart +++ /dev/null @@ -1,129 +0,0 @@ -import 'dart:async'; - -import 'package:catcher_2/catcher_2.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:scrobblenaut/scrobblenaut.dart'; -import 'package:spotify/spotify.dart'; -import 'package:spotube/collections/env.dart'; -import 'package:spotube/extensions/artist_simple.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; -import 'package:spotube/utils/persisted_state_notifier.dart'; - -class ScrobblerState { - final String username; - final String passwordHash; - - final Scrobblenaut scrobblenaut; - - ScrobblerState({ - required this.username, - required this.passwordHash, - required this.scrobblenaut, - }); - - Map toJson() { - return { - 'username': username, - 'passwordHash': passwordHash, - }; - } -} - -class ScrobblerNotifier extends PersistedStateNotifier { - final Scrobblenaut? scrobblenaut; - - /// Directly scrobbling in set state of [ProxyPlaylistNotifier] - /// brings extra latency in playback - final StreamController _scrobbleController = - StreamController.broadcast(); - - ScrobblerNotifier() - : scrobblenaut = null, - super(null, "scrobbler", encrypted: true) { - _scrobbleController.stream.listen((track) async { - try { - await state?.scrobblenaut.track.scrobble( - artist: track.artists!.first.name!, - track: track.name!, - album: track.album!.name!, - chosenByUser: true, - duration: track.duration, - timestamp: DateTime.now().toUtc(), - trackNumber: track.trackNumber, - ); - } catch (e, stackTrace) { - Catcher2.reportCheckedError(e, stackTrace); - } - }); - } - - Future login( - String username, - String password, - ) async { - final lastFm = await LastFM.authenticate( - apiKey: Env.lastFmApiKey, - apiSecret: Env.lastFmApiSecret, - username: username, - password: password, - ); - if (!lastFm.isAuth) throw Exception("Invalid credentials"); - state = ScrobblerState( - username: username, - passwordHash: lastFm.passwordHash!, - scrobblenaut: Scrobblenaut(lastFM: lastFm), - ); - } - - Future logout() async { - state = null; - } - - void scrobble(Track track) { - _scrobbleController.add(track); - } - - Future love(Track track) async { - await state?.scrobblenaut.track.love( - artist: track.artists!.asString(), - track: track.name!, - ); - } - - Future unlove(Track track) async { - await state?.scrobblenaut.track.unLove( - artist: track.artists!.asString(), - track: track.name!, - ); - } - - @override - FutureOr fromJson(Map json) async { - if (json.isEmpty) { - return null; - } - - return ScrobblerState( - username: json['username'], - passwordHash: json['passwordHash'], - scrobblenaut: Scrobblenaut( - lastFM: await LastFM.authenticateWithPasswordHash( - apiKey: Env.lastFmApiKey, - apiSecret: Env.lastFmApiSecret, - username: json["username"], - passwordHash: json["passwordHash"], - ), - ), - ); - } - - @override - Map toJson() { - return state?.toJson() ?? {}; - } -} - -final scrobblerProvider = - StateNotifierProvider( - (ref) => ScrobblerNotifier(), -); diff --git a/lib/provider/server/active_sourced_track.dart b/lib/provider/server/active_sourced_track.dart index 410b788cb..685896ec0 100644 --- a/lib/provider/server/active_sourced_track.dart +++ b/lib/provider/server/active_sourced_track.dart @@ -1,5 +1,5 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; import 'package:spotube/services/sourced_track/models/source_info.dart'; import 'package:spotube/services/sourced_track/sourced_track.dart'; @@ -28,7 +28,7 @@ class ActiveSourcedTrackNotifier extends Notifier { state = newTrack; await audioPlayer.pause(); - final playbackNotifier = ref.read(proxyPlaylistProvider.notifier); + final playbackNotifier = ref.read(audioPlayerProvider.notifier); final oldActiveIndex = audioPlayer.currentIndex; await playbackNotifier.addTracksAtFirst([newTrack]); diff --git a/lib/provider/server/bonsoir.dart b/lib/provider/server/bonsoir.dart new file mode 100644 index 000000000..fcc40e54f --- /dev/null +++ b/lib/provider/server/bonsoir.dart @@ -0,0 +1,41 @@ +import 'package:bonsoir/bonsoir.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/provider/connect/clients.dart'; +import 'package:spotube/provider/server/server.dart'; +import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +import 'package:spotube/services/device_info/device_info.dart'; +import 'package:spotube/utils/primitive_utils.dart'; + +final bonsoirProvider = FutureProvider((ref) async { + final enabled = ref.watch( + userPreferencesProvider.select((s) => s.enableConnect), + ); + final resolvedService = await ref.watch( + connectClientsProvider.selectAsync((s) => s.resolvedService), + ); + + if (!enabled || resolvedService != null) { + return null; + } + + final (server: _, :port) = await ref.watch(serverProvider.future); + + final service = BonsoirService( + name: await DeviceInfoService.instance.computerName(), + type: '_spotube._tcp', + port: port, + attributes: { + "id": PrimitiveUtils.uuid.v4(), + "deviceId": await DeviceInfoService.instance.deviceId(), + }, + ); + + final broadcast = BonsoirBroadcast(service: service); + + await broadcast.ready; + await broadcast.start(); + + ref.onDispose(() async { + await broadcast.stop(); + }); +}); diff --git a/lib/provider/server/pipeline.dart b/lib/provider/server/pipeline.dart new file mode 100644 index 000000000..8f97ce89b --- /dev/null +++ b/lib/provider/server/pipeline.dart @@ -0,0 +1,11 @@ +import 'package:flutter/foundation.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:shelf/shelf.dart'; + +final pipelineProvider = Provider((ref) { + const pipeline = Pipeline(); + if (kDebugMode) { + pipeline.addMiddleware(logRequests()); + } + return pipeline; +}); diff --git a/lib/provider/server/router.dart b/lib/provider/server/router.dart new file mode 100644 index 000000000..e2a579cc6 --- /dev/null +++ b/lib/provider/server/router.dart @@ -0,0 +1,20 @@ +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:shelf/shelf.dart'; +import 'package:shelf_router/shelf_router.dart'; +import 'package:spotube/provider/server/routes/connect.dart'; +import 'package:spotube/provider/server/routes/playback.dart'; + +final serverRouterProvider = Provider((ref) { + final playbackRoutes = ref.watch(serverPlaybackRoutesProvider); + final connectRoutes = ref.watch(serverConnectRoutesProvider); + + final router = Router(); + + router.get("/ping", (Request request) => Response.ok("pong")); + + router.get("/stream/", playbackRoutes.getStreamTrackId); + + router.all("/ws", connectRoutes.websocket); + + return router; +}); diff --git a/lib/provider/server/routes/connect.dart b/lib/provider/server/routes/connect.dart new file mode 100644 index 000000000..0d35b4734 --- /dev/null +++ b/lib/provider/server/routes/connect.dart @@ -0,0 +1,203 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; + +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:shelf/shelf.dart'; +import 'package:shelf_web_socket/shelf_web_socket.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/models/connect/connect.dart'; + +import 'package:spotube/provider/history/history.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/provider/volume_provider.dart'; +import 'package:spotube/services/audio_player/audio_player.dart'; +import 'package:spotube/services/logger/logger.dart'; +import 'package:web_socket_channel/web_socket_channel.dart'; + +extension _WebsocketSinkExts on WebSocketSink { + void addEvent(WebSocketEvent event) { + add(event.toJson()); + } +} + +class ServerConnectRoutes { + final Ref ref; + final StreamController _connectClientStreamController; + final List subscriptions; + ServerConnectRoutes(this.ref) + : _connectClientStreamController = StreamController.broadcast(), + subscriptions = [] { + ref.onDispose(() { + _connectClientStreamController.close(); + for (final subscription in subscriptions) { + subscription.cancel(); + } + }); + } + + AudioPlayerNotifier get audioPlayerNotifier => + ref.read(audioPlayerProvider.notifier); + PlaybackHistoryActions get historyNotifier => + ref.read(playbackHistoryActionsProvider); + Stream get connectClientStream => + _connectClientStreamController.stream; + + FutureOr websocket(Request req) { + return webSocketHandler( + ( + WebSocketChannel channel, + String? protocol, + ) async { + final context = + (req.context["shelf.io.connection_info"] as HttpConnectionInfo?); + final origin = "${context?.remoteAddress.host}:${context?.remotePort}"; + _connectClientStreamController.add(origin); + + ref.listen( + audioPlayerProvider, + (previous, next) { + channel.sink.addEvent(WebSocketQueueEvent(next)); + }, + fireImmediately: true, + ); + + // because audioPlayer events doesn't fireImmediately + channel.sink.addEvent(WebSocketPlayingEvent(audioPlayer.isPlaying)); + channel.sink.addEvent( + WebSocketPositionEvent(audioPlayer.position), + ); + channel.sink.addEvent( + WebSocketDurationEvent(audioPlayer.duration), + ); + channel.sink.addEvent(WebSocketShuffleEvent(audioPlayer.isShuffled)); + channel.sink.addEvent(WebSocketLoopEvent(audioPlayer.loopMode)); + channel.sink.addEvent(WebSocketVolumeEvent(audioPlayer.volume)); + + subscriptions.addAll([ + audioPlayer.positionStream.listen( + (position) { + channel.sink.addEvent(WebSocketPositionEvent(position)); + }, + ), + audioPlayer.playingStream.listen( + (playing) { + channel.sink.addEvent(WebSocketPlayingEvent(playing)); + }, + ), + audioPlayer.durationStream.listen( + (duration) { + channel.sink.addEvent(WebSocketDurationEvent(duration)); + }, + ), + audioPlayer.shuffledStream.listen( + (shuffled) { + channel.sink.addEvent(WebSocketShuffleEvent(shuffled)); + }, + ), + audioPlayer.loopModeStream.listen( + (loopMode) { + channel.sink.addEvent(WebSocketLoopEvent(loopMode)); + }, + ), + audioPlayer.volumeStream.listen( + (volume) { + channel.sink.addEvent(WebSocketVolumeEvent(volume)); + }, + ), + channel.stream.listen( + (message) { + try { + final event = WebSocketEvent.fromJson( + jsonDecode(message), + (data) => data, + ); + + event.onLoad((event) async { + await audioPlayerNotifier.load( + event.data.tracks, + autoPlay: true, + initialIndex: event.data.initialIndex ?? 0, + ); + + if (event.data.collectionId == null) return; + audioPlayerNotifier.addCollection(event.data.collectionId!); + if (event.data.collection is AlbumSimple) { + historyNotifier + .addAlbums([event.data.collection as AlbumSimple]); + } else { + historyNotifier.addPlaylists( + [event.data.collection as PlaylistSimple]); + } + }); + + event.onPause((event) async { + await audioPlayer.pause(); + }); + + event.onResume((event) async { + await audioPlayer.resume(); + }); + + event.onStop((event) async { + await audioPlayer.stop(); + }); + + event.onNext((event) async { + await audioPlayer.skipToNext(); + }); + + event.onPrevious((event) async { + await audioPlayer.skipToPrevious(); + }); + + event.onJump((event) async { + await audioPlayer.jumpTo(event.data); + }); + + event.onSeek((event) async { + await audioPlayer.seek(event.data); + }); + + event.onShuffle((event) async { + await audioPlayer.setShuffle(event.data); + }); + + event.onLoop((event) async { + await audioPlayer.setLoopMode(event.data); + }); + + event.onAddTrack((event) async { + await audioPlayerNotifier.addTrack(event.data); + }); + + event.onRemoveTrack((event) async { + await audioPlayerNotifier.removeTrack(event.data); + }); + + event.onReorder((event) async { + await audioPlayerNotifier.moveTrack( + event.data.oldIndex, + event.data.newIndex, + ); + }); + + event.onVolume((event) async { + ref.read(volumeProvider.notifier).setVolume(event.data); + }); + } catch (e, stackTrace) { + AppLogger.reportError(e, stackTrace); + channel.sink.addEvent(WebSocketErrorEvent(e.toString())); + } + }, + onDone: () { + AppLogger.log.i('Connection closed'); + }, + ), + ]); + }, + )(req); + } +} + +final serverConnectRoutesProvider = Provider((ref) => ServerConnectRoutes(ref)); diff --git a/lib/provider/server/routes/playback.dart b/lib/provider/server/routes/playback.dart new file mode 100644 index 000000000..30322a6fc --- /dev/null +++ b/lib/provider/server/routes/playback.dart @@ -0,0 +1,74 @@ +import 'package:dio/dio.dart' hide Response; +import 'package:flutter/foundation.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:shelf/shelf.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/provider/audio_player/state.dart'; +import 'package:spotube/provider/server/active_sourced_track.dart'; +import 'package:spotube/provider/server/sourced_track.dart'; +import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +import 'package:spotube/services/audio_player/audio_player.dart'; +import 'package:spotube/services/logger/logger.dart'; + +class ServerPlaybackRoutes { + final Ref ref; + UserPreferences get userPreferences => ref.read(userPreferencesProvider); + AudioPlayerState get playlist => ref.read(audioPlayerProvider); + final Dio dio; + + ServerPlaybackRoutes(this.ref) : dio = Dio(); + + /// @get('/stream/') + Future getStreamTrackId(Request request, String trackId) async { + try { + final track = + playlist.tracks.firstWhere((element) => element.id == trackId); + + final activeSourcedTrack = ref.read(activeSourcedTrackProvider); + final sourcedTrack = activeSourcedTrack?.id == track.id + ? activeSourcedTrack + : await ref.read(sourcedTrackProvider(SpotubeMedia(track)).future); + + ref.read(activeSourcedTrackProvider.notifier).update(sourcedTrack); + + final res = await dio.get( + sourcedTrack!.url, + options: Options( + headers: { + ...request.headers, + "User-Agent": + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36", + "host": Uri.parse(sourcedTrack.url).host, + "Cache-Control": "max-age=0", + "Connection": "keep-alive", + }, + responseType: ResponseType.stream, + validateStatus: (status) => status! < 500, + ), + ); + + final audioStream = + (res.data?.stream as Stream?)?.asBroadcastStream(); + + audioStream!.listen( + (event) {}, + cancelOnError: true, + ); + + return Response( + res.statusCode!, + body: audioStream, + context: { + "shelf.io.buffer_output": false, + }, + headers: res.headers.map, + ); + } catch (e, stack) { + AppLogger.reportError(e, stack); + return Response.internalServerError(); + } + } +} + +final serverPlaybackRoutesProvider = + Provider((ref) => ServerPlaybackRoutes(ref)); diff --git a/lib/provider/server/server.dart b/lib/provider/server/server.dart index 009cc534f..131f1ea47 100644 --- a/lib/provider/server/server.dart +++ b/lib/provider/server/server.dart @@ -1,119 +1,34 @@ import 'dart:io'; import 'dart:math'; -import 'package:catcher_2/catcher_2.dart'; -import 'package:dio/dio.dart' hide Response; -import 'package:flutter/foundation.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:logger/logger.dart'; -import 'package:shelf/shelf.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:shelf/shelf_io.dart'; -import 'package:shelf_router/shelf_router.dart'; -import 'package:spotube/models/logger.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; -import 'package:spotube/provider/server/active_sourced_track.dart'; -import 'package:spotube/provider/server/sourced_track.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; - -class PlaybackServer { - final Ref ref; - UserPreferences get userPreferences => ref.read(userPreferencesProvider); - ProxyPlaylist get playlist => ref.read(proxyPlaylistProvider); - final Logger logger; - final Dio dio; - - final Router router; - - static final port = Random().nextInt(17000) + 1500; - - PlaybackServer(this.ref) - : logger = getLogger('PlaybackServer'), - dio = Dio(), - router = Router() { - router.get('/stream/', getStreamTrackId); - - const pipeline = Pipeline(); - - if (kDebugMode) { - pipeline.addMiddleware(logRequests()); - } - - serve(pipeline.addHandler(router.call), InternetAddress.loopbackIPv4, port) - .then((server) { - logger - .t('Playback server at http://${server.address.host}:${server.port}'); - - ref.onDispose(() { - dio.close(force: true); - server.close(); - }); +import 'package:spotube/provider/server/pipeline.dart'; +import 'package:spotube/provider/server/router.dart'; +import 'package:spotube/services/audio_player/audio_player.dart'; +import 'package:spotube/services/logger/logger.dart'; + +final serverProvider = FutureProvider( + (ref) async { + final pipeline = ref.watch(pipelineProvider); + final router = ref.watch(serverRouterProvider); + final port = Random().nextInt(17500) + 5000; + + SpotubeMedia.serverPort = port; + + final server = await serve( + pipeline.addHandler(router.call), + InternetAddress.anyIPv4, + port, + ); + + AppLogger.log + .t('Playback server at http://${server.address.host}:${server.port}'); + + ref.onDispose(() { + server.close(); }); - } - - /// @get('/stream/') - Future getStreamTrackId(Request request, String trackId) async { - try { - final track = - playlist.tracks.firstWhere((element) => element.id == trackId); - final activeSourcedTrack = ref.read(activeSourcedTrackProvider); - final sourcedTrack = activeSourcedTrack?.id == track.id - ? activeSourcedTrack - : await ref.read(sourcedTrackProvider(track).future); - - ref.read(activeSourcedTrackProvider.notifier).update(sourcedTrack); - - final res = await dio.get( - sourcedTrack!.url, - options: Options( - headers: { - ...request.headers, - "User-Agent": - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36", - "host": Uri.parse(sourcedTrack.url).host, - "Cache-Control": "max-age=0", - "Connection": "keep-alive", - }, - responseType: ResponseType.stream, - validateStatus: (status) => status! < 500, - ), - ); - - final audioStream = - (res.data?.stream as Stream?)?.asBroadcastStream(); - - // if (res.statusCode! > 300) { - // debugPrint( - // "[[Request]]\n" - // "URI: ${res.requestOptions.uri}\n" - // "Status: ${res.statusCode}\n" - // "Request Headers: ${res.requestOptions.headers}\n" - // "Response Body: ${res.data}\n" - // "Response Headers: ${res.headers.map}", - // ); - // } - - audioStream!.listen( - (event) {}, - cancelOnError: true, - ); - - return Response( - res.statusCode!, - body: audioStream, - context: { - "shelf.io.buffer_output": false, - }, - headers: res.headers.map, - ); - } catch (e, stack) { - Catcher2.reportCheckedError(e, stack); - return Response.internalServerError(); - } - } -} -final playbackServerProvider = Provider((ref) { - return PlaybackServer(ref); -}); + return (server: server, port: port); + }, +); diff --git a/lib/provider/server/sourced_track.dart b/lib/provider/server/sourced_track.dart index 82c7ddcd0..53a040232 100644 --- a/lib/provider/server/sourced_track.dart +++ b/lib/provider/server/sourced_track.dart @@ -1,21 +1,21 @@ import 'package:collection/collection.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotify/spotify.dart'; import 'package:spotube/models/local_track.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/services/audio_player/audio_player.dart'; import 'package:spotube/services/sourced_track/sourced_track.dart'; final sourcedTrackProvider = - FutureProvider.family((ref, track) async { + FutureProvider.family((ref, media) async { + final track = media?.track; if (track == null || track is LocalTrack) { return null; } ref.listen( - proxyPlaylistProvider, + audioPlayerProvider.select((value) => value.tracks), (old, next) { - if (next.tracks.isEmpty || - next.tracks.none((element) => element.id == track.id)) { + if (next.isEmpty || next.none((element) => element.id == track.id)) { ref.invalidateSelf(); } }, diff --git a/lib/provider/skip_segments/skip_segments.dart b/lib/provider/skip_segments/skip_segments.dart new file mode 100644 index 000000000..005797f45 --- /dev/null +++ b/lib/provider/skip_segments/skip_segments.dart @@ -0,0 +1,112 @@ +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; +import 'package:spotube/services/logger/logger.dart'; +import 'package:dio/dio.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/provider/server/active_sourced_track.dart'; +import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; + +import 'package:spotube/services/dio/dio.dart'; + +class SourcedSegments { + final String source; + final List segments; + + SourcedSegments({required this.source, required this.segments}); +} + +Future> getAndCacheSkipSegments( + String id, Ref ref) async { + final database = ref.read(databaseProvider); + try { + final cached = await (database.select(database.skipSegmentTable) + ..where((s) => s.trackId.equals(id))) + .get(); + + if (cached.isNotEmpty) { + return cached; + } + + final res = await globalDio.getUri( + Uri( + scheme: "https", + host: "sponsor.ajay.app", + path: "/api/skipSegments", + queryParameters: { + "videoID": id, + "category": [ + 'sponsor', + 'selfpromo', + 'interaction', + 'intro', + 'outro', + 'music_offtopic' + ], + "actionType": 'skip' + }, + ), + options: Options( + responseType: ResponseType.json, + validateStatus: (status) => (status ?? 0) < 500, + ), + ); + + if (res.data == "Not Found") { + return List.castFrom([]); + } + + final data = res.data as List; + final segments = data.map((obj) { + final start = obj["segment"].first.toInt(); + final end = obj["segment"].last.toInt(); + return SkipSegmentTableCompanion.insert( + trackId: id, + start: start, + end: end, + ); + }).toList(); + + await database.batch((b) { + b.insertAll(database.skipSegmentTable, segments); + }); + + return await (database.select(database.skipSegmentTable) + ..where((s) => s.trackId.equals(id))) + .get(); + } catch (e, stack) { + AppLogger.reportError(e, stack); + return List.castFrom([]); + } +} + +final segmentProvider = FutureProvider( + (ref) async { + final track = ref.watch(activeSourcedTrackProvider); + if (track == null) return null; + + final skipNonMusic = ref.watch( + userPreferencesProvider.select( + (s) { + final isPipedYTMusicMode = s.audioSource == AudioSource.piped && + s.searchMode == SearchMode.youtubeMusic; + + return s.skipNonMusic && !isPipedYTMusicMode; + }, + ), + ); + + if (!skipNonMusic) { + return SourcedSegments( + segments: [], + source: track.sourceInfo.id, + ); + } + + final segments = await getAndCacheSkipSegments(track.sourceInfo.id, ref); + + return SourcedSegments( + source: track.sourceInfo.id, + segments: segments, + ); + }, +); diff --git a/lib/provider/spotify/album/releases.dart b/lib/provider/spotify/album/releases.dart index cacddbdf5..43d2e4748 100644 --- a/lib/provider/spotify/album/releases.dart +++ b/lib/provider/spotify/album/releases.dart @@ -30,7 +30,7 @@ class AlbumReleasesNotifier @override fetch(int offset, int limit) async { - final market = ref.read(userPreferencesProvider).recommendationMarket; + final market = ref.read(userPreferencesProvider).market; final albums = await spotify.browse .newReleases(country: market) @@ -43,7 +43,7 @@ class AlbumReleasesNotifier build() async { ref.watch(spotifyProvider); ref.watch( - userPreferencesProvider.select((s) => s.recommendationMarket), + userPreferencesProvider.select((s) => s.market), ); ref.watch(allFollowedArtistsProvider); diff --git a/lib/provider/spotify/artist/albums.dart b/lib/provider/spotify/artist/albums.dart index 16bd87681..32aa38a6f 100644 --- a/lib/provider/spotify/artist/albums.dart +++ b/lib/provider/spotify/artist/albums.dart @@ -30,7 +30,7 @@ class ArtistAlbumsNotifier extends AutoDisposeFamilyPaginatedAsyncNotifier< @override fetch(arg, offset, limit) async { - final market = ref.read(userPreferencesProvider).recommendationMarket; + final market = ref.read(userPreferencesProvider).market; final albums = await spotify.artists .albums(arg, country: market) .getPage(limit, offset); @@ -44,7 +44,7 @@ class ArtistAlbumsNotifier extends AutoDisposeFamilyPaginatedAsyncNotifier< ref.watch(spotifyProvider); ref.watch( - userPreferencesProvider.select((s) => s.recommendationMarket), + userPreferencesProvider.select((s) => s.market), ); final albums = await fetch(arg, 0, 20); return ArtistAlbumsState( diff --git a/lib/provider/spotify/artist/top_tracks.dart b/lib/provider/spotify/artist/top_tracks.dart index fa40d6469..a2862c3d9 100644 --- a/lib/provider/spotify/artist/top_tracks.dart +++ b/lib/provider/spotify/artist/top_tracks.dart @@ -6,8 +6,7 @@ final artistTopTracksProvider = ref.cacheFor(); final spotify = ref.watch(spotifyProvider); - final market = ref - .watch(userPreferencesProvider.select((s) => s.recommendationMarket)); + final market = ref.watch(userPreferencesProvider.select((s) => s.market)); final tracks = await spotify.artists.topTracks(artistId, market); return tracks.toList(); diff --git a/lib/provider/spotify/category/categories.dart b/lib/provider/spotify/category/categories.dart index 7652215c8..6237b64c4 100644 --- a/lib/provider/spotify/category/categories.dart +++ b/lib/provider/spotify/category/categories.dart @@ -3,8 +3,7 @@ part of '../spotify.dart'; final categoriesProvider = FutureProvider( (ref) async { final spotify = ref.watch(spotifyProvider); - final market = ref - .watch(userPreferencesProvider.select((s) => s.recommendationMarket)); + final market = ref.watch(userPreferencesProvider.select((s) => s.market)); final locale = ref.watch(userPreferencesProvider.select((s) => s.locale)); final categories = await spotify.categories .list( diff --git a/lib/provider/spotify/category/playlists.dart b/lib/provider/spotify/category/playlists.dart index 979b7f319..18d4845f7 100644 --- a/lib/provider/spotify/category/playlists.dart +++ b/lib/provider/spotify/category/playlists.dart @@ -33,7 +33,7 @@ class CategoryPlaylistsNotifier extends AutoDisposeFamilyPaginatedAsyncNotifier< final preferences = ref.read(userPreferencesProvider); final playlists = await Pages( spotify, - "v1/browse/categories/$arg/playlists?country=${preferences.recommendationMarket.name}&locale=${preferences.locale}", + "v1/browse/categories/$arg/playlists?country=${preferences.market.name}&locale=${preferences.locale}", (json) => json == null ? null : PlaylistSimple.fromJson(json), 'playlists', (json) => PlaylistsFeatured.fromJson(json), @@ -48,7 +48,7 @@ class CategoryPlaylistsNotifier extends AutoDisposeFamilyPaginatedAsyncNotifier< ref.watch(spotifyProvider); ref.watch(userPreferencesProvider.select((s) => s.locale)); - ref.watch(userPreferencesProvider.select((s) => s.recommendationMarket)); + ref.watch(userPreferencesProvider.select((s) => s.market)); final playlists = await fetch(arg, 0, 8); diff --git a/lib/provider/spotify/lyrics/synced.dart b/lib/provider/spotify/lyrics/synced.dart index 6ce74ae79..085fccb7f 100644 --- a/lib/provider/spotify/lyrics/synced.dart +++ b/lib/provider/spotify/lyrics/synced.dart @@ -1,37 +1,37 @@ part of '../spotify.dart'; -class SyncedLyricsNotifier extends FamilyAsyncNotifier - with Persistence { - SyncedLyricsNotifier() { - load(); - } - +class SyncedLyricsNotifier extends FamilyAsyncNotifier { Track get _track => arg!; Future getSpotifyLyrics(String? token) async { - final res = await http.get( - Uri.parse( - "https://spclient.wg.spotify.com/color-lyrics/v2/track/${_track.id}?format=json&market=from_token", - ), + final res = await globalDio.getUri( + Uri.parse( + "https://spclient.wg.spotify.com/color-lyrics/v2/track/${_track.id}?format=json&market=from_token", + ), + options: Options( headers: { "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.0.0 Safari/537.36", "App-platform": "WebPlayer", "authorization": "Bearer $token" - }); + }, + responseType: ResponseType.json, + validateStatus: (status) => true, + ), + ); if (res.statusCode != 200) { return SubtitleSimple( lyrics: [], name: _track.name!, - uri: res.request!.url, + uri: res.realUri, rating: 0, provider: "Spotify", ); } - final linesRaw = Map.castFrom( - jsonDecode(res.body), - )["lyrics"]?["lines"] as List?; + final linesRaw = + Map.castFrom(res.data)["lyrics"] + ?["lines"] as List?; final lines = linesRaw?.map((line) { return LyricSlice( @@ -44,7 +44,7 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier return SubtitleSimple( lyrics: lines, name: _track.name!, - uri: res.request!.url, + uri: res.realUri, rating: 100, provider: "Spotify", ); @@ -55,7 +55,7 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier Future getLRCLibLyrics() async { final packageInfo = await PackageInfo.fromPlatform(); - final res = await http.get( + final res = await globalDio.getUri( Uri( scheme: "https", host: "lrclib.net", @@ -67,23 +67,26 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier "duration": _track.duration?.inSeconds.toString(), }, ), - headers: { - "User-Agent": - "Spotube v${packageInfo.version} (https://github.com/KRTirtho/spotube)" - }, + options: Options( + headers: { + "User-Agent": + "Spotube v${packageInfo.version} (https://github.com/KRTirtho/spotube)" + }, + responseType: ResponseType.json, + ), ); if (res.statusCode != 200) { return SubtitleSimple( lyrics: [], name: _track.name!, - uri: res.request!.url, + uri: res.realUri, rating: 0, provider: "LRCLib", ); } - final json = jsonDecode(res.body) as Map; + final json = res.data as Map; final syncedLyricsRaw = json["syncedLyrics"] as String?; final syncedLyrics = syncedLyricsRaw?.isNotEmpty == true @@ -97,7 +100,7 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier return SubtitleSimple( lyrics: syncedLyrics!, name: _track.name!, - uri: res.request!.url, + uri: res.realUri, rating: 100, provider: "LRCLib", ); @@ -111,7 +114,7 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier return SubtitleSimple( lyrics: plainLyrics, name: _track.name!, - uri: res.request!.url, + uri: res.realUri, rating: 0, provider: "LRCLib", ); @@ -120,14 +123,27 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier @override FutureOr build(track) async { try { + final database = ref.watch(databaseProvider); final spotify = ref.watch(spotifyProvider); + if (track == null) { throw "No track currently"; } + + final cachedLyrics = await (database.select(database.lyricsTable) + ..where((tbl) => tbl.trackId.equals(track.id!))) + .map((row) => row.data) + .getSingleOrNull(); + + SubtitleSimple? lyrics = cachedLyrics; + final token = await spotify.getCredentials(); - SubtitleSimple lyrics = await getSpotifyLyrics(token.accessToken); - if (lyrics.lyrics.isEmpty) { + if (lyrics == null || lyrics.lyrics.isEmpty) { + lyrics = await getSpotifyLyrics(token.accessToken); + } + + if (lyrics.lyrics.isEmpty || lyrics.lyrics.length <= 5) { lyrics = await getLRCLibLyrics(); } @@ -135,19 +151,22 @@ class SyncedLyricsNotifier extends FamilyAsyncNotifier throw Exception("Unable to find lyrics"); } + if (cachedLyrics == null || cachedLyrics.lyrics.isEmpty) { + await database.into(database.lyricsTable).insert( + LyricsTableCompanion.insert( + trackId: track.id!, + data: lyrics, + ), + mode: InsertMode.replace, + ); + } + return lyrics; } catch (e, stackTrace) { - Catcher2.reportCheckedError(e, stackTrace); + AppLogger.reportError(e, stackTrace); rethrow; } } - - @override - FutureOr fromJson(Map json) => - SubtitleSimple.fromJson(json.castKeyDeep()); - - @override - Map toJson(SubtitleSimple data) => data.toJson(); } final syncedLyricsDelayProvider = StateProvider((ref) => 0); diff --git a/lib/provider/spotify/playlist/favorite.dart b/lib/provider/spotify/playlist/favorite.dart index a0e051aa6..000001ade 100644 --- a/lib/provider/spotify/playlist/favorite.dart +++ b/lib/provider/spotify/playlist/favorite.dart @@ -51,6 +51,20 @@ class FavoritePlaylistsNotifier ); } + void updatePlaylist(PlaylistSimple playlist) { + if (state.value == null) return; + + if (state.value!.items.none((e) => e.id == playlist.id)) return; + + state = AsyncData( + state.value!.copyWith( + items: state.value!.items + .map((element) => element.id == playlist.id ? playlist : element) + .toList(), + ), + ); + } + Future addFavorite(PlaylistSimple playlist) async { await update((state) async { await spotify.playlists.followPlaylist(playlist.id!); diff --git a/lib/provider/spotify/playlist/generate.dart b/lib/provider/spotify/playlist/generate.dart index 15447b54f..0832003e9 100644 --- a/lib/provider/spotify/playlist/generate.dart +++ b/lib/provider/spotify/playlist/generate.dart @@ -5,7 +5,7 @@ final generatePlaylistProvider = FutureProvider.autoDispose (ref, input) async { final spotify = ref.watch(spotifyProvider); final market = ref.watch( - userPreferencesProvider.select((s) => s.recommendationMarket), + userPreferencesProvider.select((s) => s.market), ); final recommendation = await spotify.recommendations @@ -24,7 +24,7 @@ final generatePlaylistProvider = FutureProvider.autoDispose ?.cast(), ) .catchError((e, stackTrace) { - Catcher2.reportCheckedError(e, stackTrace); + AppLogger.reportError(e, stackTrace); return Recommendations(); }); diff --git a/lib/provider/spotify/playlist/liked.dart b/lib/provider/spotify/playlist/liked.dart index 52463d3de..27c3e2b65 100644 --- a/lib/provider/spotify/playlist/liked.dart +++ b/lib/provider/spotify/playlist/liked.dart @@ -1,10 +1,6 @@ part of '../spotify.dart'; -class LikedTracksNotifier extends AsyncNotifier> with Persistence { - LikedTracksNotifier() { - load(); - } - +class LikedTracksNotifier extends AsyncNotifier> { @override FutureOr> build() async { final spotify = ref.watch(spotifyProvider); @@ -29,18 +25,6 @@ class LikedTracksNotifier extends AsyncNotifier> with Persistence { } }); } - - @override - FutureOr> fromJson(Map json) { - return (json['tracks'] as List).map((e) => Track.fromJson(e)).toList(); - } - - @override - Map toJson(List data) { - return { - 'tracks': data.map((e) => e.toJson()).toList(), - }; - } } final likedTracksProvider = diff --git a/lib/provider/spotify/playlist/playlist.dart b/lib/provider/spotify/playlist/playlist.dart index fd420cd93..0eec3a87d 100644 --- a/lib/provider/spotify/playlist/playlist.dart +++ b/lib/provider/spotify/playlist/playlist.dart @@ -71,16 +71,32 @@ class PlaylistNotifier extends FamilyAsyncNotifier { state.id!, input.base64Image!, ); + + final playlist = await spotify.playlists.get(state.id!); + + ref.read(favoritePlaylistsProvider.notifier).updatePlaylist(playlist); + return playlist; } - return spotify.playlists.get(state.id!); - } catch (e) { + final playlist = Playlist.fromJson( + { + ...state.toJson(), + 'name': input.playlistName, + 'collaborative': input.collaborative, + 'description': input.description, + 'public': input.public, + }, + ); + + ref.read(favoritePlaylistsProvider.notifier).updatePlaylist(playlist); + + return playlist; + } catch (e, stack) { onError?.call(e); + AppLogger.reportError(e, stack); rethrow; } }); - - ref.invalidate(favoritePlaylistsProvider); } } diff --git a/lib/provider/spotify/search/search.dart b/lib/provider/spotify/search/search.dart index bd97f08b3..dc00d913e 100644 --- a/lib/provider/spotify/search/search.dart +++ b/lib/provider/spotify/search/search.dart @@ -42,7 +42,7 @@ class SearchNotifier extends AutoDisposeFamilyPaginatedAsyncNotifier extends AutoDisposeFamilyPaginatedAsyncNotifier value.recommendationMarket), + userPreferencesProvider.select((value) => value.market), ); final results = await fetch(arg, 0, 10); diff --git a/lib/provider/spotify/spotify.dart b/lib/provider/spotify/spotify.dart index 816420f65..5997a47a6 100644 --- a/lib/provider/spotify/spotify.dart +++ b/lib/provider/spotify/spotify.dart @@ -1,10 +1,14 @@ library spotify; import 'dart:async'; -import 'dart:convert'; -import 'package:catcher_2/catcher_2.dart'; +import 'package:drift/drift.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; +import 'package:spotube/provider/spotify/utils/json_cast.dart'; +import 'package:spotube/services/logger/logger.dart'; import 'package:collection/collection.dart'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:intl/intl.dart'; @@ -15,7 +19,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; // ignore: depend_on_referenced_packages, implementation_imports import 'package:riverpod/src/async_notifier.dart'; import 'package:spotube/extensions/album_simple.dart'; -import 'package:spotube/extensions/map.dart'; import 'package:spotube/extensions/track.dart'; import 'package:spotube/models/lyrics.dart'; import 'package:spotube/models/spotify/recommendation_seeds.dart'; @@ -23,9 +26,8 @@ import 'package:spotube/models/spotify_friends.dart'; import 'package:spotube/provider/custom_spotify_endpoint_provider.dart'; import 'package:spotube/provider/spotify_provider.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +import 'package:spotube/services/dio/dio.dart'; import 'package:spotube/services/wikipedia/wikipedia.dart'; -import 'package:spotube/utils/persisted_state_notifier.dart'; -import 'package:http/http.dart' as http; import 'package:wikipedia_api/wikipedia_api.dart'; diff --git a/lib/provider/spotify/utils/json_cast.dart b/lib/provider/spotify/utils/json_cast.dart new file mode 100644 index 000000000..307009714 --- /dev/null +++ b/lib/provider/spotify/utils/json_cast.dart @@ -0,0 +1,21 @@ +Map castNestedJson(Map map) { + return Map.castFrom( + map.map((key, value) { + if (value is Map) { + return MapEntry( + key, + castNestedJson(value), + ); + } else if (value is Iterable) { + return MapEntry( + key, + value.map((e) { + if (e is Map) return castNestedJson(e); + return e; + }).toList(), + ); + } + return MapEntry(key, value); + }), + ); +} diff --git a/lib/provider/spotify/utils/persistence.dart b/lib/provider/spotify/utils/persistence.dart index 14d3c9408..57f41dec0 100644 --- a/lib/provider/spotify/utils/persistence.dart +++ b/lib/provider/spotify/utils/persistence.dart @@ -16,7 +16,7 @@ mixin Persistence on BuildlessAsyncNotifier { (json is List && json.isNotEmpty)) { state = AsyncData( await fromJson( - PersistedStateNotifier.castNestedJson(json), + castNestedJson(json), ), ); } diff --git a/lib/provider/spotify/views/home.dart b/lib/provider/spotify/views/home.dart index 810d110dd..ad6a076ab 100644 --- a/lib/provider/spotify/views/home.dart +++ b/lib/provider/spotify/views/home.dart @@ -1,14 +1,14 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/custom_spotify_endpoint_provider.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; final homeViewProvider = FutureProvider((ref) async { final country = ref.watch( - userPreferencesProvider.select((s) => s.recommendationMarket), + userPreferencesProvider.select((s) => s.market), ); final spTCookie = ref.watch( - authenticationProvider.select((s) => s?.getCookie("sp_t")), + authenticationProvider.select((s) => s.asData?.value?.getCookie("sp_t")), ); if (spTCookie == null) return null; diff --git a/lib/provider/spotify/views/home_section.dart b/lib/provider/spotify/views/home_section.dart index 1078fa72d..5eb9183db 100644 --- a/lib/provider/spotify/views/home_section.dart +++ b/lib/provider/spotify/views/home_section.dart @@ -1,6 +1,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/models/spotify/home_feed.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/provider/custom_spotify_endpoint_provider.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; @@ -8,10 +8,10 @@ final homeSectionViewProvider = FutureProvider.family( (ref, sectionUri) async { final country = ref.watch( - userPreferencesProvider.select((s) => s.recommendationMarket), + userPreferencesProvider.select((s) => s.market), ); final spTCookie = ref.watch( - authenticationProvider.select((s) => s?.getCookie("sp_t")), + authenticationProvider.select((s) => s.asData?.value?.getCookie("sp_t")), ); if (spTCookie == null) return null; diff --git a/lib/provider/spotify/views/view.dart b/lib/provider/spotify/views/view.dart index f1af998bb..ff565febf 100644 --- a/lib/provider/spotify/views/view.dart +++ b/lib/provider/spotify/views/view.dart @@ -4,7 +4,7 @@ final viewProvider = FutureProvider.family, String>( (ref, viewName) async { final customSpotify = ref.watch(customSpotifyEndpointProvider); final market = ref.watch( - userPreferencesProvider.select((s) => s.recommendationMarket), + userPreferencesProvider.select((s) => s.market), ); final locale = ref.watch( userPreferencesProvider.select((s) => s.locale), diff --git a/lib/provider/spotify_provider.dart b/lib/provider/spotify_provider.dart index f8b6e0441..5824cce0a 100644 --- a/lib/provider/spotify_provider.dart +++ b/lib/provider/spotify_provider.dart @@ -2,14 +2,14 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/collections/env.dart'; -import 'package:spotube/provider/authentication_provider.dart'; +import 'package:spotube/provider/authentication/authentication.dart'; import 'package:spotube/utils/primitive_utils.dart'; final spotifyProvider = Provider((ref) { final authState = ref.watch(authenticationProvider); final anonCred = PrimitiveUtils.getRandomElement(Env.spotifySecrets); - if (authState == null) { + if (authState.asData?.value == null) { return SpotifyApi( SpotifyApiCredentials( anonCred["clientId"], @@ -18,5 +18,5 @@ final spotifyProvider = Provider((ref) { ); } - return SpotifyApi.withAccessToken(authState.accessToken); + return SpotifyApi.withAccessToken(authState.asData!.value!.accessToken.value); }); diff --git a/lib/provider/tray_manager/tray_manager.dart b/lib/provider/tray_manager/tray_manager.dart new file mode 100644 index 000000000..9cc4becc6 --- /dev/null +++ b/lib/provider/tray_manager/tray_manager.dart @@ -0,0 +1,79 @@ +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/provider/tray_manager/tray_menu.dart'; +import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; +import 'package:spotube/utils/platform.dart'; +import 'package:tray_manager/tray_manager.dart'; +import 'package:window_manager/window_manager.dart'; + +class SystemTrayManager with TrayListener { + final Ref ref; + final bool enabled; + + SystemTrayManager( + this.ref, { + required this.enabled, + }) { + initialize(); + } + + Future initialize() async { + if (!kIsDesktop) return; + + if (enabled) { + await trayManager.setIcon( + kIsWindows + ? 'assets/spotube-logo.ico' + : kIsFlatpak + ? 'com.github.KRTirtho.Spotube' + : 'assets/spotube-logo.png', + ); + trayManager.addListener(this); + } else { + await trayManager.destroy(); + } + } + + void dispose() { + trayManager.removeListener(this); + } + + @override + onTrayIconMouseDown() { + if (kIsWindows) { + windowManager.show(); + } else { + trayManager.popUpContextMenu(); + } + } + + @override + onTrayIconRightMouseDown() { + if (!kIsWindows) { + windowManager.show(); + } else { + trayManager.popUpContextMenu(); + } + } +} + +final trayManagerProvider = Provider( + (ref) { + final enabled = ref.watch( + userPreferencesProvider.select((s) => s.showSystemTrayIcon), + ); + + ref.listen(trayMenuProvider, (_, menu) { + if (!enabled || !kIsDesktop) return; + trayManager.setContextMenu(menu); + }); + + final manager = SystemTrayManager( + ref, + enabled: enabled, + ); + + ref.onDispose(manager.dispose); + + return manager; + }, +); diff --git a/lib/provider/tray_manager/tray_menu.dart b/lib/provider/tray_manager/tray_menu.dart new file mode 100644 index 000000000..42a3f948e --- /dev/null +++ b/lib/provider/tray_manager/tray_menu.dart @@ -0,0 +1,108 @@ +import 'dart:io'; + +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/services/audio_player/audio_player.dart'; +import 'package:media_kit/media_kit.dart' hide Track; +import 'package:tray_manager/tray_manager.dart'; +import 'package:window_manager/window_manager.dart'; + +final audioPlayerLoopMode = StreamProvider((ref) { + return audioPlayer.loopModeStream; +}); + +final audioPlayerShuffleMode = StreamProvider((ref) { + return audioPlayer.shuffledStream; +}); +final audioPlayerPlaying = StreamProvider((ref) { + return audioPlayer.playingStream; +}); + +final trayMenuProvider = Provider((ref) { + final playlistNotifier = ref.watch(audioPlayerProvider.notifier); + final isPlaybackPlaying = + ref.watch(audioPlayerProvider.select((s) => s.activeTrack != null)); + final isLoopOne = + ref.watch(audioPlayerLoopMode).asData?.value == PlaylistMode.single; + final isShuffled = ref.watch(audioPlayerShuffleMode).asData?.value ?? false; + final isPlaying = ref.watch(audioPlayerPlaying).asData?.value ?? false; + + return Menu( + items: [ + MenuItem( + label: "Show/Hide Window", + onClick: (menuItem) async { + if (await windowManager.isVisible()) { + await windowManager.hide(); + } else { + await windowManager.focus(); + await windowManager.show(); + } + }, + ), + MenuItem.separator(), + MenuItem( + label: isPlaying ? "Pause" : "Play", + disabled: !isPlaybackPlaying, + onClick: (menuItem) async { + if (audioPlayer.isPlaying) { + await audioPlayer.pause(); + } else { + await audioPlayer.resume(); + } + }, + ), + MenuItem( + label: "Next", + disabled: !isPlaybackPlaying, + onClick: (menuItem) { + audioPlayer.skipToNext(); + }, + ), + MenuItem( + label: "Previous", + disabled: !isPlaybackPlaying, + onClick: (menuItem) { + audioPlayer.skipToPrevious(); + }, + ), + MenuItem.submenu( + label: "Playback", + submenu: Menu( + items: [ + MenuItem( + label: "Repeat", + checked: isLoopOne, + onClick: (menuItem) { + audioPlayer.setLoopMode( + isLoopOne ? PlaylistMode.none : PlaylistMode.single, + ); + }, + ), + MenuItem( + label: "Shuffle", + checked: isShuffled, + onClick: (menuItem) { + audioPlayer.setShuffle(!isShuffled); + }, + ), + MenuItem.separator(), + MenuItem( + label: "Stop", + onClick: (menuItem) { + playlistNotifier.stop(); + }, + ), + ], + ), + ), + MenuItem.separator(), + MenuItem( + label: "Quit", + onClick: (menuItem) { + exit(0); + }, + ), + ], + ); +}); diff --git a/lib/provider/user_preferences/user_preferences_provider.dart b/lib/provider/user_preferences/user_preferences_provider.dart index a1e247b22..a421e7d09 100644 --- a/lib/provider/user_preferences/user_preferences_provider.dart +++ b/lib/provider/user_preferences/user_preferences_provider.dart @@ -1,177 +1,208 @@ -import 'dart:async'; - +import 'package:drift/drift.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/settings/color_scheme_picker_dialog.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/modules/settings/color_scheme_picker_dialog.dart'; +import 'package:spotube/provider/audio_player/audio_player_streams.dart'; +import 'package:spotube/provider/database/database.dart'; import 'package:spotube/provider/palette_provider.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; import 'package:spotube/services/sourced_track/enums.dart'; - -import 'package:spotube/utils/persisted_state_notifier.dart'; import 'package:spotube/utils/platform.dart'; -import 'package:path/path.dart' as path; +import 'package:window_manager/window_manager.dart'; + +typedef UserPreferences = PreferencesTableData; + +class UserPreferencesNotifier extends Notifier { + @override + build() { + final db = ref.watch(databaseProvider); + + (db.select(db.preferencesTable)..where((tbl) => tbl.id.equals(0))) + .getSingleOrNull() + .then((result) async { + if (result == null) { + await db.into(db.preferencesTable).insert( + PreferencesTableCompanion.insert( + id: const Value(0), + downloadLocation: Value(await _getDefaultDownloadDirectory()), + ), + ); + } + + state = await (db.select(db.preferencesTable) + ..where((tbl) => tbl.id.equals(0))) + .getSingle(); + + final subscription = (db.select(db.preferencesTable) + ..where((tbl) => tbl.id.equals(0))) + .watchSingle() + .listen((event) async { + state = event; + + if (kIsDesktop) { + await windowManager.setTitleBarStyle( + state.systemTitleBar ? TitleBarStyle.normal : TitleBarStyle.hidden, + ); + } + + await audioPlayer.setAudioNormalization(state.normalizeAudio); + }); + + ref.onDispose(() { + subscription.cancel(); + }); + }); + + return PreferencesTable.defaults(); + } + + Future _getDefaultDownloadDirectory() async { + if (kIsAndroid) return "/storage/emulated/0/Download/Spotube"; + + if (kIsMacOS) { + return join((await getLibraryDirectory()).path, "Caches"); + } + + return getDownloadsDirectory().then((dir) { + return join(dir!.path, "Spotube"); + }); + } -class UserPreferencesNotifier extends PersistedStateNotifier { - final Ref ref; + Future setData(PreferencesTableCompanion data) async { + final db = ref.read(databaseProvider); - UserPreferencesNotifier(this.ref) - : super(UserPreferences.withDefaults(), "preferences"); + final query = db.update(db.preferencesTable)..where((t) => t.id.equals(0)); - void reset() { - state = UserPreferences.withDefaults(); + await query.write(data); + } + + Future reset() async { + final db = ref.read(databaseProvider); + + final query = db.update(db.preferencesTable)..where((t) => t.id.equals(0)); + + await query.replace(PreferencesTableCompanion.insert()); } void setStreamMusicCodec(SourceCodecs codec) { - state = state.copyWith(streamMusicCodec: codec); + setData(PreferencesTableCompanion(streamMusicCodec: Value(codec))); } void setDownloadMusicCodec(SourceCodecs codec) { - state = state.copyWith(downloadMusicCodec: codec); + setData(PreferencesTableCompanion(downloadMusicCodec: Value(codec))); } void setThemeMode(ThemeMode mode) { - state = state.copyWith(themeMode: mode); + setData(PreferencesTableCompanion(themeMode: Value(mode))); } void setRecommendationMarket(Market country) { - state = state.copyWith(recommendationMarket: country); + setData(PreferencesTableCompanion(market: Value(country))); } void setAccentColorScheme(SpotubeColor color) { - state = state.copyWith(accentColorScheme: color); + setData(PreferencesTableCompanion(accentColorScheme: Value(color))); } void setAlbumColorSync(bool sync) { - state = state.copyWith(albumColorSync: sync); + setData(PreferencesTableCompanion(albumColorSync: Value(sync))); if (!sync) { ref.read(paletteProvider.notifier).state = null; } else { - ref.read(proxyPlaylistProvider.notifier).updatePalette(); + ref.read(audioPlayerStreamListenersProvider).updatePalette(); } } void setCheckUpdate(bool check) { - state = state.copyWith(checkUpdate: check); + setData(PreferencesTableCompanion(checkUpdate: Value(check))); } void setAudioQuality(SourceQualities quality) { - state = state.copyWith(audioQuality: quality); + setData(PreferencesTableCompanion(audioQuality: Value(quality))); } void setDownloadLocation(String downloadDir) { if (downloadDir.isEmpty) return; - state = state.copyWith(downloadLocation: downloadDir); + setData(PreferencesTableCompanion(downloadLocation: Value(downloadDir))); + } + + void setLocalLibraryLocation(List localLibraryDirs) { + //if (localLibraryDir.isEmpty) return; + setData( + PreferencesTableCompanion( + localLibraryLocation: Value(localLibraryDirs), + ), + ); } void setLayoutMode(LayoutMode mode) { - state = state.copyWith(layoutMode: mode); + setData(PreferencesTableCompanion(layoutMode: Value(mode))); } void setCloseBehavior(CloseBehavior behavior) { - state = state.copyWith(closeBehavior: behavior); + setData(PreferencesTableCompanion(closeBehavior: Value(behavior))); } void setShowSystemTrayIcon(bool show) { - state = state.copyWith(showSystemTrayIcon: show); + setData(PreferencesTableCompanion(showSystemTrayIcon: Value(show))); } void setLocale(Locale locale) { - state = state.copyWith(locale: locale); + setData(PreferencesTableCompanion(locale: Value(locale))); } void setPipedInstance(String instance) { - state = state.copyWith(pipedInstance: instance); + setData(PreferencesTableCompanion(pipedInstance: Value(instance))); } void setSearchMode(SearchMode mode) { - state = state.copyWith(searchMode: mode); + setData(PreferencesTableCompanion(searchMode: Value(mode))); } void setSkipNonMusic(bool skip) { - state = state.copyWith(skipNonMusic: skip); + setData(PreferencesTableCompanion(skipNonMusic: Value(skip))); } void setAudioSource(AudioSource type) { - state = state.copyWith(audioSource: type); + setData(PreferencesTableCompanion(audioSource: Value(type))); } void setSystemTitleBar(bool isSystemTitleBar) { - state = state.copyWith(systemTitleBar: isSystemTitleBar); - if (DesktopTools.platform.isDesktop) { - DesktopTools.window.setTitleBarStyle( - isSystemTitleBar ? TitleBarStyle.normal : TitleBarStyle.hidden, - ); - } + setData( + PreferencesTableCompanion( + systemTitleBar: Value(isSystemTitleBar), + ), + ); } void setDiscordPresence(bool discordPresence) { - state = state.copyWith(discordPresence: discordPresence); + setData(PreferencesTableCompanion(discordPresence: Value(discordPresence))); } void setAmoledDarkTheme(bool isAmoled) { - state = state.copyWith(amoledDarkTheme: isAmoled); + setData(PreferencesTableCompanion(amoledDarkTheme: Value(isAmoled))); } void setNormalizeAudio(bool normalize) { - state = state.copyWith(normalizeAudio: normalize); + setData(PreferencesTableCompanion(normalizeAudio: Value(normalize))); audioPlayer.setAudioNormalization(normalize); } void setEndlessPlayback(bool endless) { - state = state.copyWith(endlessPlayback: endless); + setData(PreferencesTableCompanion(endlessPlayback: Value(endless))); } void setEnableConnect(bool enable) { - state = state.copyWith(enableConnect: enable); - } - - Future _getDefaultDownloadDirectory() async { - if (kIsAndroid) return "/storage/emulated/0/Download/Spotube"; - - if (kIsMacOS) { - return path.join((await getLibraryDirectory()).path, "Caches"); - } - - return getDownloadsDirectory().then((dir) { - return path.join(dir!.path, "Spotube"); - }); - } - - @override - FutureOr onInit() async { - if (state.downloadLocation.isEmpty) { - state = state.copyWith( - downloadLocation: await _getDefaultDownloadDirectory(), - ); - } - - if (DesktopTools.platform.isDesktop) { - await DesktopTools.window.setTitleBarStyle( - state.systemTitleBar ? TitleBarStyle.normal : TitleBarStyle.hidden, - ); - } - - await audioPlayer.setAudioNormalization(state.normalizeAudio); - } - - @override - FutureOr fromJson(Map json) { - return UserPreferences.fromJson(json); - } - - @override - Map toJson() { - return state.toJson(); + setData(PreferencesTableCompanion(enableConnect: Value(enable))); } } final userPreferencesProvider = - StateNotifierProvider( - (ref) => UserPreferencesNotifier(ref), + NotifierProvider( + () => UserPreferencesNotifier(), ); diff --git a/lib/provider/user_preferences/user_preferences_state.dart b/lib/provider/user_preferences/user_preferences_state.dart deleted file mode 100644 index e35c73b5e..000000000 --- a/lib/provider/user_preferences/user_preferences_state.dart +++ /dev/null @@ -1,141 +0,0 @@ -import 'dart:convert'; - -import 'package:flutter/material.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:spotify/spotify.dart'; -import 'package:spotube/components/settings/color_scheme_picker_dialog.dart'; -import 'package:spotube/services/sourced_track/enums.dart'; - -part 'user_preferences_state.g.dart'; -part 'user_preferences_state.freezed.dart'; - -@JsonEnum() -enum LayoutMode { - compact, - extended, - adaptive, -} - -@JsonEnum() -enum CloseBehavior { - minimizeToTray, - close, -} - -@JsonEnum() -enum AudioSource { - youtube, - piped, - jiosaavn; - - String get label => name[0].toUpperCase() + name.substring(1); -} - -@JsonEnum() -enum MusicCodec { - m4a._("M4a (Best for downloaded music)"), - weba._("WebA (Best for streamed music)\nDoesn't support audio metadata"); - - final String label; - const MusicCodec._(this.label); -} - -@JsonEnum() -enum SearchMode { - youtube._("YouTube"), - youtubeMusic._("YouTube Music"); - - final String label; - - const SearchMode._(this.label); - - factory SearchMode.fromString(String key) { - return SearchMode.values.firstWhere((e) => e.name == key); - } -} - -@freezed -class UserPreferences with _$UserPreferences { - const factory UserPreferences({ - @Default(SourceQualities.high) SourceQualities audioQuality, - @Default(true) bool albumColorSync, - @Default(false) bool amoledDarkTheme, - @Default(true) bool checkUpdate, - @Default(false) bool normalizeAudio, - @Default(true) bool showSystemTrayIcon, - @Default(false) bool skipNonMusic, - @Default(false) bool systemTitleBar, - @Default(CloseBehavior.minimizeToTray) CloseBehavior closeBehavior, - @Default(SpotubeColor(0xFF2196F3, name: "Blue")) - @JsonKey( - fromJson: UserPreferences._accentColorSchemeFromJson, - toJson: UserPreferences._accentColorSchemeToJson, - readValue: UserPreferences._accentColorSchemeReadValue, - ) - SpotubeColor accentColorScheme, - @Default(LayoutMode.adaptive) LayoutMode layoutMode, - @Default(Locale("system", "system")) - @JsonKey( - fromJson: UserPreferences._localeFromJson, - toJson: UserPreferences._localeToJson, - readValue: UserPreferences._localeReadValue, - ) - Locale locale, - @Default(Market.US) Market recommendationMarket, - @Default(SearchMode.youtube) SearchMode searchMode, - @Default("") String downloadLocation, - @Default("https://pipedapi.kavin.rocks") String pipedInstance, - @Default(ThemeMode.system) ThemeMode themeMode, - @Default(AudioSource.youtube) AudioSource audioSource, - @Default(SourceCodecs.weba) SourceCodecs streamMusicCodec, - @Default(SourceCodecs.m4a) SourceCodecs downloadMusicCodec, - @Default(true) bool discordPresence, - @Default(true) bool endlessPlayback, - @Default(false) bool enableConnect, - }) = _UserPreferences; - factory UserPreferences.fromJson(Map json) => - _$UserPreferencesFromJson(json); - - factory UserPreferences.withDefaults() => UserPreferences.fromJson({}); - - static SpotubeColor _accentColorSchemeFromJson(Map json) { - return SpotubeColor.fromString(json["color"]); - } - - static Map? _accentColorSchemeReadValue( - Map json, String key) { - if (json[key] is String) { - return {"color": json[key]}; - } - - return json[key] as Map?; - } - - static Map _accentColorSchemeToJson(SpotubeColor color) { - return {"color": color.toString()}; - } - - static Locale _localeFromJson(Map json) { - return Locale(json["languageCode"], json["countryCode"]); - } - - static Map _localeToJson(Locale locale) { - return { - "languageCode": locale.languageCode, - "countryCode": locale.countryCode, - }; - } - - static Map? _localeReadValue( - Map json, String key) { - if (json[key] is String) { - final map = jsonDecode(json[key]); - return { - "languageCode": map["lc"], - "countryCode": map["cc"], - }; - } - - return json[key] as Map?; - } -} diff --git a/lib/provider/volume_provider.dart b/lib/provider/volume_provider.dart index 464b5e424..64bcfe1a0 100644 --- a/lib/provider/volume_provider.dart +++ b/lib/provider/volume_provider.dart @@ -2,31 +2,23 @@ import 'dart:async'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; -import 'package:spotube/utils/persisted_state_notifier.dart'; +import 'package:spotube/services/kv_store/kv_store.dart'; -class VolumeProvider extends PersistedStateNotifier { - VolumeProvider() : super(1, 'volume'); - - Future setVolume(double volume) async { - state = volume; - await audioPlayer.setVolume(volume); - } - - @override - FutureOr onInit() async { - await audioPlayer.setVolume(state); - } +class VolumeProvider extends Notifier { + VolumeProvider(); @override - FutureOr fromJson(Map json) { - return json['volume'] as double? ?? 0.0; + build() { + audioPlayer.setVolume(KVStoreService.volume); + return KVStoreService.volume; } - @override - Map toJson() { - return {'volume': state}; + Future setVolume(double volume) async { + state = volume; + await audioPlayer.setVolume(volume); + KVStoreService.setVolume(volume); } } final volumeProvider = - StateNotifierProvider((ref) => VolumeProvider()); + NotifierProvider(() => VolumeProvider()); diff --git a/lib/services/audio_player/audio_player.dart b/lib/services/audio_player/audio_player.dart index a81c6c958..4febecdf1 100644 --- a/lib/services/audio_player/audio_player.dart +++ b/lib/services/audio_player/audio_player.dart @@ -1,18 +1,18 @@ import 'dart:io'; -import 'package:catcher_2/catcher_2.dart'; +import 'package:media_kit/media_kit.dart' hide Track; +import 'package:spotube/services/logger/logger.dart'; import 'package:flutter/foundation.dart'; -import 'package:spotify/spotify.dart'; -import 'package:spotube/extensions/track.dart'; +import 'package:spotify/spotify.dart' hide Playlist; import 'package:spotube/models/local_track.dart'; -import 'package:spotube/provider/server/server.dart'; import 'package:spotube/services/audio_player/custom_player.dart'; import 'dart:async'; import 'package:media_kit/media_kit.dart' as mk; -import 'package:spotube/services/audio_player/loop_mode.dart'; import 'package:spotube/services/audio_player/playback_state.dart'; +import 'package:spotube/services/sourced_track/sourced_track.dart'; +import 'package:spotube/utils/platform.dart'; part 'audio_players_streams_mixin.dart'; part 'audio_player_impl.dart'; @@ -20,24 +20,63 @@ part 'audio_player_impl.dart'; class SpotubeMedia extends mk.Media { final Track track; + static int serverPort = 0; + SpotubeMedia( this.track, { - Map? extras, + Map? extras, super.httpHeaders, }) : super( track is LocalTrack ? track.path - : "http://${InternetAddress.loopbackIPv4.address}:${PlaybackServer.port}/stream/${track.id}", + : "http://${kIsWindows ? "localhost" : InternetAddress.anyIPv4.address}:$serverPort/stream/${track.id}", extras: { ...?extras, - "track": track.toJson(), + "track": switch (track) { + LocalTrack() => track.toJson(), + SourcedTrack() => track.toJson(), + _ => track.toJson(), + }, }, ); - factory SpotubeMedia.fromMedia(mk.Media media) { - final track = Track.fromJson(media.extras?["track"]); - return SpotubeMedia(track); + @override + String get uri { + return switch (track) { + /// [super.uri] must be used instead of [track.path] to prevent wrong + /// path format exceptions in Windows causing [extras] to be null + LocalTrack() => super.uri, + _ => + "http://${kIsWindows ? "localhost" : InternetAddress.anyIPv4.address}:" + "$serverPort/stream/${track.id}", + }; } + + factory SpotubeMedia.fromMedia(mk.Media media) { + final track = media.uri.startsWith("http") + ? Track.fromJson(media.extras?["track"]) + : LocalTrack.fromJson(media.extras?["track"]); + return SpotubeMedia( + track, + extras: media.extras, + httpHeaders: media.httpHeaders, + ); + } + + // @override + // operator ==(Object other) { + // if (other is! SpotubeMedia) return false; + + // final isLocal = track is LocalTrack && other.track is LocalTrack; + // return isLocal + // ? (other.track as LocalTrack).path == (track as LocalTrack).path + // : other.track.id == track.id; + // } + + // @override + // int get hashCode => track is LocalTrack + // ? (track as LocalTrack).path.hashCode + // : track.id.hashCode; } abstract class AudioPlayerInterface { @@ -51,7 +90,7 @@ abstract class AudioPlayerInterface { ), ) { _mkPlayer.stream.error.listen((event) { - Catcher2.reportCheckedError(event, StackTrace.current); + AppLogger.reportError(event, StackTrace.current); }); } @@ -60,15 +99,19 @@ abstract class AudioPlayerInterface { bool get mkSupportedPlatform => _mkSupportedPlatform; - Future get duration async { + Duration get duration { return _mkPlayer.state.duration; } - Future get position async { + Playlist get playlist { + return _mkPlayer.state.playlist; + } + + Duration get position { return _mkPlayer.state.position; } - Future get bufferedPosition async { + Duration get bufferedPosition { return _mkPlayer.state.buffer; } @@ -101,12 +144,12 @@ abstract class AudioPlayerInterface { return _mkPlayer.state.completed; } - Future get isShuffled async { + bool get isShuffled { return _mkPlayer.shuffled; } - PlaybackLoopMode get loopMode { - return PlaybackLoopMode.fromPlaylistMode(_mkPlayer.state.playlistMode); + PlaylistMode get loopMode { + return _mkPlayer.state.playlistMode; } /// Returns the current volume of the player, between 0 and 1 diff --git a/lib/services/audio_player/audio_player_impl.dart b/lib/services/audio_player/audio_player_impl.dart index 58868aed7..82c8c9067 100644 --- a/lib/services/audio_player/audio_player_impl.dart +++ b/lib/services/audio_player/audio_player_impl.dart @@ -65,7 +65,7 @@ class SpotubeAudioPlayer extends AudioPlayerInterface } String? get nextSource { - if (loopMode == PlaybackLoopMode.all && + if (loopMode == PlaylistMode.loop && _mkPlayer.state.playlist.index == _mkPlayer.state.playlist.medias.length - 1) { return sources.first; @@ -77,8 +77,7 @@ class SpotubeAudioPlayer extends AudioPlayerInterface } String? get previousSource { - if (loopMode == PlaybackLoopMode.all && - _mkPlayer.state.playlist.index == 0) { + if (loopMode == PlaylistMode.loop && _mkPlayer.state.playlist.index == 0) { return sources.last; } @@ -125,8 +124,8 @@ class SpotubeAudioPlayer extends AudioPlayerInterface await _mkPlayer.setShuffle(shuffle); } - Future setLoopMode(PlaybackLoopMode loop) async { - await _mkPlayer.setPlaylistMode(loop.toPlaylistMode()); + Future setLoopMode(PlaylistMode loop) async { + await _mkPlayer.setPlaylistMode(loop); } Future setAudioNormalization(bool normalize) async { diff --git a/lib/services/audio_player/audio_players_streams_mixin.dart b/lib/services/audio_player/audio_players_streams_mixin.dart index f6fe06302..324059107 100644 --- a/lib/services/audio_player/audio_players_streams_mixin.dart +++ b/lib/services/audio_player/audio_players_streams_mixin.dart @@ -45,12 +45,9 @@ mixin SpotubeAudioPlayersStreams on AudioPlayerInterface { Stream percentCompletedStream(double percent) { return positionStream .asyncMap( - (position) async => (await duration)?.inSeconds == 0 + (position) async => duration == Duration.zero ? 0 - : (position.inSeconds / - ((await duration)?.inSeconds ?? 100) * - 100) - .toInt(), + : (position.inSeconds / duration.inSeconds * 100).toInt(), ) .where((event) => event >= percent); } @@ -71,12 +68,12 @@ mixin SpotubeAudioPlayersStreams on AudioPlayerInterface { // } } - Stream get loopModeStream { + Stream get loopModeStream { // if (mkSupportedPlatform) { - return _mkPlayer.stream.playlistMode.map(PlaybackLoopMode.fromPlaylistMode); + return _mkPlayer.stream.playlistMode; // } else { // return _justAudio!.loopModeStream - // .map(PlaybackLoopMode.fromLoopMode) + // .map(PlaylistMode.fromLoopMode) // ; // } } @@ -149,5 +146,7 @@ mixin SpotubeAudioPlayersStreams on AudioPlayerInterface { Stream get errorStream => _mkPlayer.stream.error; - Stream get playlistStream => _mkPlayer.stream.playlist; + Stream get playlistStream => _mkPlayer.stream.playlist.map((s) { + return s; + }); } diff --git a/lib/services/audio_player/custom_player.dart b/lib/services/audio_player/custom_player.dart index 916a983f4..f0dc8f13c 100644 --- a/lib/services/audio_player/custom_player.dart +++ b/lib/services/audio_player/custom_player.dart @@ -1,12 +1,12 @@ import 'dart:async'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; -import 'package:catcher_2/catcher_2.dart'; +import 'package:spotube/services/logger/logger.dart'; import 'package:media_kit/media_kit.dart'; import 'package:flutter_broadcasts/flutter_broadcasts.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:audio_session/audio_session.dart'; // ignore: implementation_imports import 'package:spotube/services/audio_player/playback_state.dart'; +import 'package:spotube/utils/platform.dart'; /// MediaKit [Player] by default doesn't have a state stream. /// This class adds a state stream to the [Player] class. @@ -48,13 +48,13 @@ class CustomPlayer extends Player { } }), stream.error.listen((event) { - Catcher2.reportCheckedError('[MediaKitError] \n$event', null); + AppLogger.reportError('[MediaKitError] \n$event', StackTrace.current); }), ]; PackageInfo.fromPlatform().then((packageInfo) { _packageName = packageInfo.packageName; }); - if (DesktopTools.platform.isAndroid) { + if (kIsAndroid) { _androidAudioManager = AndroidAudioManager(); AudioSession.instance.then((s) async { _androidAudioSessionId = @@ -71,7 +71,7 @@ class CustomPlayer extends Player { } Future notifyAudioSessionUpdate(bool active) async { - if (DesktopTools.platform.isAndroid) { + if (kIsAndroid) { sendBroadcast( BroadcastMessage( name: active diff --git a/lib/services/audio_player/loop_mode.dart b/lib/services/audio_player/loop_mode.dart deleted file mode 100644 index 78da43bae..000000000 --- a/lib/services/audio_player/loop_mode.dart +++ /dev/null @@ -1,90 +0,0 @@ -import 'package:audio_service/audio_service.dart'; -import 'package:media_kit/media_kit.dart'; - -/// An unified loop mode for both [LoopMode] and [PlaylistMode] -enum PlaybackLoopMode { - all, - one, - none; - - // static PlaybackLoopMode fromLoopMode(LoopMode loopMode) { - // switch (loopMode) { - // case LoopMode.all: - // return PlaybackLoopMode.all; - // case LoopMode.one: - // return PlaybackLoopMode.one; - // case LoopMode.off: - // return PlaybackLoopMode.none; - // } - // } - - // LoopMode toLoopMode() { - // switch (this) { - // case PlaybackLoopMode.all: - // return LoopMode.all; - // case PlaybackLoopMode.one: - // return LoopMode.one; - // case PlaybackLoopMode.none: - // return LoopMode.off; - // } - // } - - static PlaybackLoopMode fromPlaylistMode(PlaylistMode mode) { - switch (mode) { - case PlaylistMode.single: - return PlaybackLoopMode.one; - case PlaylistMode.loop: - return PlaybackLoopMode.all; - case PlaylistMode.none: - return PlaybackLoopMode.none; - } - } - - PlaylistMode toPlaylistMode() { - switch (this) { - case PlaybackLoopMode.all: - return PlaylistMode.loop; - case PlaybackLoopMode.one: - return PlaylistMode.single; - case PlaybackLoopMode.none: - return PlaylistMode.none; - } - } - - static PlaybackLoopMode fromAudioServiceRepeatMode( - AudioServiceRepeatMode mode) { - switch (mode) { - case AudioServiceRepeatMode.all: - case AudioServiceRepeatMode.group: - return PlaybackLoopMode.all; - case AudioServiceRepeatMode.one: - return PlaybackLoopMode.one; - case AudioServiceRepeatMode.none: - return PlaybackLoopMode.none; - } - } - - AudioServiceRepeatMode toAudioServiceRepeatMode() { - switch (this) { - case PlaybackLoopMode.all: - return AudioServiceRepeatMode.all; - case PlaybackLoopMode.one: - return AudioServiceRepeatMode.one; - case PlaybackLoopMode.none: - return AudioServiceRepeatMode.none; - } - } - - static PlaybackLoopMode fromString(String? value) { - switch (value) { - case 'all': - return PlaybackLoopMode.all; - case 'one': - return PlaybackLoopMode.one; - case 'none': - return PlaybackLoopMode.none; - default: - return PlaybackLoopMode.none; - } - } -} diff --git a/lib/services/audio_services/audio_services.dart b/lib/services/audio_services/audio_services.dart index 338427aa1..d1820a007 100644 --- a/lib/services/audio_services/audio_services.dart +++ b/lib/services/audio_services/audio_services.dart @@ -1,44 +1,44 @@ import 'package:audio_service/audio_service.dart'; -import 'package:flutter_desktop_tools/flutter_desktop_tools.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/extensions/artist_simple.dart'; import 'package:spotube/extensions/image.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/services/audio_services/mobile_audio_service.dart'; import 'package:spotube/services/audio_services/windows_audio_service.dart'; import 'package:spotube/services/sourced_track/sourced_track.dart'; +import 'package:spotube/utils/platform.dart'; -class AudioServices { +class AudioServices with WidgetsBindingObserver { final MobileAudioService? mobile; final WindowsAudioService? smtc; - AudioServices(this.mobile, this.smtc); + AudioServices(this.mobile, this.smtc) { + WidgetsBinding.instance.addObserver(this); + } static Future create( Ref ref, - ProxyPlaylistNotifier playback, + AudioPlayerNotifier playback, ) async { - final mobile = DesktopTools.platform.isMobile || - DesktopTools.platform.isMacOS || - DesktopTools.platform.isLinux + final mobile = kIsMobile || kIsMacOS || kIsLinux ? await AudioService.init( builder: () => MobileAudioService(playback), - config: const AudioServiceConfig( - androidNotificationChannelId: 'com.krtirtho.Spotube', + config: AudioServiceConfig( + androidNotificationChannelId: + kIsLinux ? 'spotube' : 'com.krtirtho.Spotube', androidNotificationChannelName: 'Spotube', - androidNotificationOngoing: true, + androidNotificationOngoing: false, + androidNotificationIcon: "drawable/ic_launcher_monochrome", + androidStopForegroundOnPause: false, + androidNotificationChannelDescription: "Spotube Media Controls", ), ) : null; - final smtc = DesktopTools.platform.isWindows - ? WindowsAudioService(ref, playback) - : null; + final smtc = kIsWindows ? WindowsAudioService(ref, playback) : null; - return AudioServices( - mobile, - smtc, - ); + return AudioServices(mobile, smtc); } Future addTrack(Track track) async { @@ -68,7 +68,20 @@ class AudioServices { mobile?.session?.setActive(false); } + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + switch (state) { + case AppLifecycleState.detached: + deactivateSession(); + mobile?.stop(); + break; + default: + break; + } + } + void dispose() { smtc?.dispose(); + WidgetsBinding.instance.removeObserver(this); } } diff --git a/lib/services/audio_services/mobile_audio_service.dart b/lib/services/audio_services/mobile_audio_service.dart index 3bb884475..cdd16138e 100644 --- a/lib/services/audio_services/mobile_audio_service.dart +++ b/lib/services/audio_services/mobile_audio_service.dart @@ -2,19 +2,19 @@ import 'dart:async'; import 'package:audio_service/audio_service.dart'; import 'package:audio_session/audio_session.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; +import 'package:spotube/provider/audio_player/state.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; -import 'package:spotube/services/audio_player/loop_mode.dart'; +import 'package:media_kit/media_kit.dart' hide Track; class MobileAudioService extends BaseAudioHandler { AudioSession? session; - final ProxyPlaylistNotifier playlistNotifier; + final AudioPlayerNotifier audioPlayerNotifier; - // ignore: invalid_use_of_protected_member - ProxyPlaylist get playlist => playlistNotifier.state; + // ignore: invalid_use_of_protected_member, invalid_use_of_visible_for_testing_member + AudioPlayerState get playlist => audioPlayerNotifier.state; - MobileAudioService(this.playlistNotifier) { + MobileAudioService(this.audioPlayerNotifier) { AudioSession.instance.then((s) { session = s; session?.configure(const AudioSessionConfiguration.music()); @@ -91,36 +91,39 @@ class MobileAudioService extends BaseAudioHandler { @override Future setRepeatMode(AudioServiceRepeatMode repeatMode) async { super.setRepeatMode(repeatMode); - audioPlayer.setLoopMode( - PlaybackLoopMode.fromAudioServiceRepeatMode(repeatMode), - ); + audioPlayer.setLoopMode(switch (repeatMode) { + AudioServiceRepeatMode.all || + AudioServiceRepeatMode.group => + PlaylistMode.loop, + AudioServiceRepeatMode.one => PlaylistMode.single, + _ => PlaylistMode.none, + }); } @override Future stop() async { - await playlistNotifier.stop(); + await audioPlayerNotifier.stop(); } @override Future skipToNext() async { - await playlistNotifier.next(); + await audioPlayer.skipToNext(); await super.skipToNext(); } @override Future skipToPrevious() async { - await playlistNotifier.previous(); + await audioPlayer.skipToPrevious(); await super.skipToPrevious(); } @override Future onTaskRemoved() async { - await playlistNotifier.stop(); + await audioPlayerNotifier.stop(); return super.onTaskRemoved(); } Future _transformEvent() async { - final position = (await audioPlayer.position) ?? Duration.zero; return PlaybackState( controls: [ MediaControl.skipToPrevious, @@ -133,13 +136,17 @@ class MobileAudioService extends BaseAudioHandler { }, androidCompactActionIndices: const [0, 1, 2], playing: audioPlayer.isPlaying, - updatePosition: position, - bufferedPosition: await audioPlayer.bufferedPosition ?? Duration.zero, - shuffleMode: await audioPlayer.isShuffled == true + updatePosition: audioPlayer.position, + bufferedPosition: audioPlayer.bufferedPosition, + shuffleMode: audioPlayer.isShuffled == true ? AudioServiceShuffleMode.all : AudioServiceShuffleMode.none, - repeatMode: (audioPlayer.loopMode).toAudioServiceRepeatMode(), - processingState: playlist.isFetching == true + repeatMode: switch (audioPlayer.loopMode) { + PlaylistMode.loop => AudioServiceRepeatMode.all, + PlaylistMode.single => AudioServiceRepeatMode.one, + _ => AudioServiceRepeatMode.none, + }, + processingState: audioPlayer.isBuffering ? AudioProcessingState.loading : AudioProcessingState.ready, ); diff --git a/lib/services/audio_services/smtc_windows_web.dart b/lib/services/audio_services/smtc_windows_web.dart deleted file mode 100644 index 055d43be1..000000000 --- a/lib/services/audio_services/smtc_windows_web.dart +++ /dev/null @@ -1,276 +0,0 @@ -// ignore_for_file: constant_identifier_names - -class MusicMetadata { - final String? title; - final String? artist; - final String? album; - final String? albumArtist; - final String? thumbnail; - - const MusicMetadata({ - this.title, - this.artist, - this.album, - this.albumArtist, - this.thumbnail, - }); -} - -enum PlaybackStatus { - Closed, - Changing, - Stopped, - Playing, - Paused, -} - -enum PressedButton { - play, - pause, - next, - previous, - fastForward, - rewind, - stop, - record, - channelUp, - channelDown; - - static PressedButton fromString(String button) { - switch (button) { - case 'play': - return PressedButton.play; - case 'pause': - return PressedButton.pause; - case 'next': - return PressedButton.next; - case 'previous': - return PressedButton.previous; - case 'fast_forward': - return PressedButton.fastForward; - case 'rewind': - return PressedButton.rewind; - case 'stop': - return PressedButton.stop; - case 'record': - return PressedButton.record; - case 'channel_up': - return PressedButton.channelUp; - case 'channel_down': - return PressedButton.channelDown; - default: - throw Exception('Unknown button: $button'); - } - } -} - -class SMTCConfig { - final bool playEnabled; - final bool pauseEnabled; - final bool stopEnabled; - final bool nextEnabled; - final bool prevEnabled; - final bool fastForwardEnabled; - final bool rewindEnabled; - - const SMTCConfig({ - required this.playEnabled, - required this.pauseEnabled, - required this.stopEnabled, - required this.nextEnabled, - required this.prevEnabled, - required this.fastForwardEnabled, - required this.rewindEnabled, - }); -} - -enum RepeatMode { - none, - track, - list; - - static RepeatMode fromString(String value) { - switch (value) { - case 'none': - return none; - case 'track': - return track; - case 'list': - return list; - default: - throw Exception('Unknown repeat mode: $value'); - } - } - - String get asString => toString().split('.').last; -} - -class PlaybackTimeline { - final int startTimeMs; - final int endTimeMs; - final int positionMs; - final int? minSeekTimeMs; - final int? maxSeekTimeMs; - - const PlaybackTimeline({ - required this.startTimeMs, - required this.endTimeMs, - required this.positionMs, - this.minSeekTimeMs, - this.maxSeekTimeMs, - }); -} - -class SMTCWindows { - SMTCWindows({ - SMTCConfig? config, - PlaybackTimeline? timeline, - MusicMetadata? metadata, - PlaybackStatus? status, - bool? shuffleEnabled, - RepeatMode? repeatMode, - bool? enabled, - }); - - SMTCConfig get config => throw UnimplementedError(); - PlaybackTimeline get timeline => throw UnimplementedError(); - MusicMetadata get metadata => throw UnimplementedError(); - PlaybackStatus? get status => throw UnimplementedError(); - Stream get buttonPressStream => throw UnimplementedError(); - Stream get shuffleChangeStream => throw UnimplementedError(); - Stream get repeatModeChangeStream => throw UnimplementedError(); - - bool get isPlayEnabled => config.playEnabled; - bool get isPauseEnabled => config.pauseEnabled; - bool get isStopEnabled => config.stopEnabled; - bool get isNextEnabled => config.nextEnabled; - bool get isPrevEnabled => config.prevEnabled; - bool get isFastForwardEnabled => config.fastForwardEnabled; - bool get isRewindEnabled => config.rewindEnabled; - - bool get isShuffleEnabled => throw UnimplementedError(); - RepeatMode get repeatMode => throw UnimplementedError(); - bool get enabled => throw UnimplementedError(); - - Duration? get startTime => Duration(milliseconds: timeline.startTimeMs); - Duration? get endTime => Duration(milliseconds: timeline.endTimeMs); - Duration? get position => Duration(milliseconds: timeline.positionMs); - Duration? get minSeekTime => timeline.minSeekTimeMs == null - ? null - : Duration(milliseconds: timeline.minSeekTimeMs!); - Duration? get maxSeekTime => timeline.maxSeekTimeMs == null - ? null - : Duration(milliseconds: timeline.maxSeekTimeMs!); - - Future updateConfig(SMTCConfig config) { - throw UnimplementedError(); - } - - Future updateTimeline(PlaybackTimeline timeline) { - throw UnimplementedError(); - } - - Future updateMetadata(MusicMetadata metadata) { - throw UnimplementedError(); - } - - Future clearMetadata() { - throw UnimplementedError(); - } - - Future dispose() async { - throw UnimplementedError(); - } - - Future disableSmtc() { - throw UnimplementedError(); - } - - Future enableSmtc() { - throw UnimplementedError(); - } - - Future setPlaybackStatus(PlaybackStatus status) async { - throw UnimplementedError(); - } - - Future setIsPlayEnabled(bool enabled) { - throw UnimplementedError(); - } - - Future setIsPauseEnabled(bool enabled) { - throw UnimplementedError(); - } - - Future setIsStopEnabled(bool enabled) { - throw UnimplementedError(); - } - - Future setIsNextEnabled(bool enabled) { - throw UnimplementedError(); - } - - Future setIsPrevEnabled(bool enabled) { - throw UnimplementedError(); - } - - Future setIsFastForwardEnabled(bool enabled) { - throw UnimplementedError(); - } - - Future setIsRewindEnabled(bool enabled) { - throw UnimplementedError(); - } - - Future setTimeline(PlaybackTimeline timeline) { - return updateTimeline(timeline); - } - - Future setTitle(String title) { - throw UnimplementedError(); - } - - Future setArtist(String artist) { - throw UnimplementedError(); - } - - Future setAlbum(String album) { - throw UnimplementedError(); - } - - Future setAlbumArtist(String albumArtist) { - throw UnimplementedError(); - } - - Future setThumbnail(String thumbnail) { - throw UnimplementedError(); - } - - Future setPosition(Duration position) { - throw UnimplementedError(); - } - - Future setStartTime(Duration startTime) { - throw UnimplementedError(); - } - - Future setEndTime(Duration endTime) { - throw UnimplementedError(); - } - - Future setMaxSeekTime(Duration maxSeekTime) { - throw UnimplementedError(); - } - - Future setMinSeekTime(Duration minSeekTime) { - throw UnimplementedError(); - } - - Future setShuffleEnabled(bool enabled) { - throw UnimplementedError(); - } - - Future setRepeatMode(RepeatMode repeatMode) { - throw UnimplementedError(); - } -} diff --git a/lib/services/audio_services/windows_audio_service.dart b/lib/services/audio_services/windows_audio_service.dart index a3ee31e14..8edc50696 100644 --- a/lib/services/audio_services/windows_audio_service.dart +++ b/lib/services/audio_services/windows_audio_service.dart @@ -5,20 +5,20 @@ import 'package:smtc_windows/smtc_windows.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/extensions/artist_simple.dart'; import 'package:spotube/extensions/image.dart'; -import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart'; +import 'package:spotube/provider/audio_player/audio_player.dart'; import 'package:spotube/services/audio_player/audio_player.dart'; import 'package:spotube/services/audio_player/playback_state.dart'; class WindowsAudioService { final SMTCWindows smtc; final Ref ref; - final ProxyPlaylistNotifier playlistNotifier; + final AudioPlayerNotifier audioPlayerNotifier; final subscriptions = []; - WindowsAudioService(this.ref, this.playlistNotifier) + WindowsAudioService(this.ref, this.audioPlayerNotifier) : smtc = SMTCWindows(enabled: false) { - smtc.setPlaybackStatus(PlaybackStatus.Stopped); + smtc.setPlaybackStatus(PlaybackStatus.stopped); final buttonStream = smtc.buttonPressStream.listen((event) { switch (event) { case PressedButton.play: @@ -28,13 +28,13 @@ class WindowsAudioService { audioPlayer.pause(); break; case PressedButton.next: - playlistNotifier.next(); + audioPlayer.skipToNext(); break; case PressedButton.previous: - playlistNotifier.previous(); + audioPlayer.skipToPrevious(); break; case PressedButton.stop: - playlistNotifier.stop(); + audioPlayerNotifier.stop(); break; default: break; @@ -45,16 +45,16 @@ class WindowsAudioService { audioPlayer.playerStateStream.listen((state) async { switch (state) { case AudioPlaybackState.playing: - await smtc.setPlaybackStatus(PlaybackStatus.Playing); + await smtc.setPlaybackStatus(PlaybackStatus.playing); break; case AudioPlaybackState.paused: - await smtc.setPlaybackStatus(PlaybackStatus.Paused); + await smtc.setPlaybackStatus(PlaybackStatus.paused); break; case AudioPlaybackState.stopped: - await smtc.setPlaybackStatus(PlaybackStatus.Stopped); + await smtc.setPlaybackStatus(PlaybackStatus.stopped); break; case AudioPlaybackState.completed: - await smtc.setPlaybackStatus(PlaybackStatus.Changing); + await smtc.setPlaybackStatus(PlaybackStatus.changing); break; default: break; diff --git a/lib/services/cli/cli.dart b/lib/services/cli/cli.dart index 720216c70..985c0e723 100644 --- a/lib/services/cli/cli.dart +++ b/lib/services/cli/cli.dart @@ -5,7 +5,6 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:flutter/foundation.dart'; import 'package:package_info_plus/package_info_plus.dart'; -import 'package:spotube/models/logger.dart'; Future startCLI(List args) async { final parser = ArgParser(); @@ -15,13 +14,6 @@ Future startCLI(List args) async { abbr: 'v', help: 'Verbose mode', defaultsTo: !kReleaseMode, - callback: (verbose) { - if (verbose) { - logEnv['VERBOSE'] = 'true'; - logEnv['DEBUG'] = 'true'; - logEnv['ERROR'] = 'true'; - } - }, ); parser.addFlag( "version", diff --git a/lib/services/custom_spotify_endpoints/spotify_endpoints.dart b/lib/services/custom_spotify_endpoints/spotify_endpoints.dart index d8600366a..3b3583660 100644 --- a/lib/services/custom_spotify_endpoints/spotify_endpoints.dart +++ b/lib/services/custom_spotify_endpoints/spotify_endpoints.dart @@ -1,6 +1,6 @@ import 'dart:convert'; -import 'package:http/http.dart' as http; +import 'package:dio/dio.dart'; import 'package:spotify/spotify.dart'; import 'package:spotube/models/spotify/home_feed.dart'; import 'package:spotube/models/spotify_friends.dart'; @@ -9,9 +9,21 @@ import 'package:timezone/timezone.dart' as tz; class CustomSpotifyEndpoints { static const _baseUrl = 'https://api.spotify.com/v1'; final String accessToken; - final http.Client _client; - - CustomSpotifyEndpoints(this.accessToken) : _client = http.Client(); + final Dio _client; + + CustomSpotifyEndpoints(this.accessToken) + : _client = Dio( + BaseOptions( + baseUrl: _baseUrl, + responseType: ResponseType.json, + headers: { + "content-type": "application/json", + if (accessToken.isNotEmpty) + "authorization": "Bearer $accessToken", + "accept": "application/json", + }, + ), + ); // views API @@ -65,117 +77,43 @@ class CustomSpotifyEndpoints { if (country != null) 'country': country.name, }.entries.map((e) => '${e.key}=${e.value}').join('&'); - final res = await _client.get( + final res = await _client.getUri( Uri.parse('$_baseUrl/views/$view?$queryParams'), - headers: { - "content-type": "application/json", - "authorization": "Bearer $accessToken", - "accept": "application/json", - }, ); if (res.statusCode == 200) { - return jsonDecode(res.body); + return res.data; } else { throw Exception( '[CustomSpotifyEndpoints.getView]: Failed to get view' '\nStatus code: ${res.statusCode}' - '\nBody: ${res.body}', + '\nBody: ${res.data}', ); } } Future> listGenreSeeds() async { - final res = await _client.get( + final res = await _client.getUri( Uri.parse("$_baseUrl/recommendations/available-genre-seeds"), - headers: { - "content-type": "application/json", - if (accessToken.isNotEmpty) "authorization": "Bearer $accessToken", - "accept": "application/json", - }, ); if (res.statusCode == 200) { - final body = jsonDecode(res.body); + final body = res.data; return List.from(body["genres"] ?? []); } else { throw Exception( '[CustomSpotifyEndpoints.listGenreSeeds]: Failed to get genre seeds' '\nStatus code: ${res.statusCode}' - '\nBody: ${res.body}', + '\nBody: ${res.data}', ); } } - void _addList( - Map parameters, String key, Iterable paramList) { - if (paramList.isNotEmpty) { - parameters[key] = paramList.join(','); - } - } - - void _addTunableTrackMap( - Map parameters, Map? tunableTrackMap) { - if (tunableTrackMap != null) { - parameters.addAll(tunableTrackMap.map((k, v) => - MapEntry(k, v is int ? v.toString() : v.toStringAsFixed(2)))); - } - } - - Future> getRecommendations({ - Iterable? seedArtists, - Iterable? seedGenres, - Iterable? seedTracks, - int limit = 20, - Market? market, - Map? max, - Map? min, - Map? target, - }) async { - assert(limit >= 1 && limit <= 100, 'limit should be 1 <= limit <= 100'); - final seedsNum = (seedArtists?.length ?? 0) + - (seedGenres?.length ?? 0) + - (seedTracks?.length ?? 0); - assert( - seedsNum >= 1 && seedsNum <= 5, - 'Up to 5 seed values may be provided in any combination of seed_artists,' - ' seed_tracks and seed_genres.'); - final parameters = {'limit': limit.toString()}; - final _ = { - 'seed_artists': seedArtists, - 'seed_genres': seedGenres, - 'seed_tracks': seedTracks - }.forEach((key, list) => _addList(parameters, key, list!)); - if (market != null) parameters['market'] = market.name; - for (var map in [min, max, target]) { - _addTunableTrackMap(parameters, map); - } - final pathQuery = - "$_baseUrl/recommendations?${parameters.entries.map((e) => '${e.key}=${e.value}').join('&')}"; - final res = await _client.get( - Uri.parse(pathQuery), - headers: { - "content-type": "application/json", - if (accessToken.isNotEmpty) "authorization": "Bearer $accessToken", - "accept": "application/json", - }, - ); - final result = jsonDecode(res.body); - return List.castFrom( - result["tracks"].map((track) => Track.fromJson(track)).toList(), - ); - } - Future getFriendActivity() async { - final res = await _client.get( + final res = await _client.getUri( Uri.parse("https://guc-spclient.spotify.com/presence-view/v1/buddylist"), - headers: { - "content-type": "application/json", - "authorization": "Bearer $accessToken", - "accept": "application/json", - }, ); - return SpotifyFriends.fromJson(jsonDecode(res.body)); + return SpotifyFriends.fromJson(res.data); } Future getHomeFeed({ @@ -190,7 +128,7 @@ class CustomSpotifyEndpoints { 'origin': 'https://open.spotify.com', 'referer': 'https://open.spotify.com/' }; - final response = await http.get( + final response = await _client.getUri( Uri( scheme: "https", host: "api-partner.spotify.com", @@ -219,21 +157,11 @@ class CustomSpotifyEndpoints { ), }, ), - headers: headers, + options: Options(headers: headers), ); - if (response.statusCode >= 400) { - throw Exception( - "[RequestException] " - "Status: ${response.statusCode}\n" - "Body: ${response.body}", - ); - } - final data = SpotifyHomeFeed.fromJson( - transformHomeFeedJsonMap( - jsonDecode(response.body), - ), + transformHomeFeedJsonMap(response.data), ); return data; @@ -252,7 +180,7 @@ class CustomSpotifyEndpoints { 'origin': 'https://open.spotify.com', 'referer': 'https://open.spotify.com/' }; - final response = await http.get( + final response = await _client.getUri( Uri( scheme: "https", host: "api-partner.spotify.com", @@ -280,20 +208,12 @@ class CustomSpotifyEndpoints { ), }, ), - headers: headers, + options: Options(headers: headers), ); - if (response.statusCode >= 400) { - throw Exception( - "[RequestException] " - "Status: ${response.statusCode}\n" - "Body: ${response.body}", - ); - } - final data = SpotifyHomeFeedSection.fromJson( transformSectionItemJsonMap( - jsonDecode(response.body)["data"]["homeSections"]["sections"][0], + response.data["data"]["homeSections"]["sections"][0], ), ); diff --git a/lib/services/dio/dio.dart b/lib/services/dio/dio.dart new file mode 100644 index 000000000..cddf19795 --- /dev/null +++ b/lib/services/dio/dio.dart @@ -0,0 +1,3 @@ +import 'package:dio/dio.dart'; + +final globalDio = Dio(); diff --git a/lib/services/download_manager/chunked_download.dart b/lib/services/download_manager/chunked_download.dart index 9e5e0a989..80a3e78fb 100644 --- a/lib/services/download_manager/chunked_download.dart +++ b/lib/services/download_manager/chunked_download.dart @@ -2,9 +2,6 @@ import 'dart:async'; import 'dart:io'; import 'package:dio/dio.dart'; -import 'package:spotube/models/logger.dart'; - -final logger = getLogger("ChunkedDownload"); /// Downloading by spiting as file in chunks extension ChunkDownload on Dio { @@ -69,11 +66,7 @@ extension ChunkDownload on Dio { } await raf.close(); - logger.d("Downloaded file path: ${headFile.path}"); - headFile = await headFile.rename(savePath); - - logger.d("Renamed file path: ${headFile.path}"); } final firstResponse = await downloadChunk( diff --git a/lib/services/download_manager/download_manager.dart b/lib/services/download_manager/download_manager.dart index dbb96791c..d2072bd7e 100644 --- a/lib/services/download_manager/download_manager.dart +++ b/lib/services/download_manager/download_manager.dart @@ -1,18 +1,18 @@ import 'dart:async'; import 'dart:collection'; import 'dart:io'; -import 'package:catcher_2/catcher_2.dart'; import 'package:collection/collection.dart'; import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; import 'package:path/path.dart' as path; import 'package:path_provider/path_provider.dart'; -import 'package:spotube/models/logger.dart'; + import 'package:spotube/services/download_manager/chunked_download.dart'; import 'package:spotube/services/download_manager/download_request.dart'; import 'package:spotube/services/download_manager/download_status.dart'; import 'package:spotube/services/download_manager/download_task.dart'; +import 'package:spotube/services/logger/logger.dart'; import 'package:spotube/utils/primitive_utils.dart'; export './download_request.dart'; @@ -25,7 +25,6 @@ typedef DownloadStatusEvent = ({ }); class DownloadManager { - final logger = getLogger("DownloadManager"); final Map _cache = {}; final Queue _queue = Queue(); var dio = Dio(); @@ -77,9 +76,10 @@ class DownloadManager { } setStatus(task, DownloadStatus.downloading); - logger.d("[DownloadManager] $url"); final file = File(savePath.toString()); + await Directory(path.dirname(savePath)).create(recursive: true); + final tmpDirPath = await Directory( path.join( (await getTemporaryDirectory()).path, @@ -97,11 +97,8 @@ class DownloadManager { final partialFileExist = await partialFile.exists(); if (fileExist) { - logger.d("[DownloadManager] File Exists"); setStatus(task, DownloadStatus.completed); } else if (partialFileExist) { - logger.d("[DownloadManager] Partial File Exists"); - final partialFileLength = await partialFile.length(); final response = await dio.download( @@ -146,7 +143,7 @@ class DownloadManager { } } } catch (e, stackTrace) { - Catcher2.reportCheckedError(e, stackTrace); + AppLogger.reportError(e, stackTrace); var task = getDownload(url)!; if (task.status.value != DownloadStatus.canceled && @@ -223,7 +220,6 @@ class DownloadManager { } Future pauseDownload(String url) async { - logger.d("[DownloadManager] Pause Download"); var task = getDownload(url)!; setStatus(task, DownloadStatus.paused); task.request.cancelToken.cancel(); @@ -232,7 +228,6 @@ class DownloadManager { } Future cancelDownload(String url) async { - logger.d("[DownloadManager] Cancel Download"); var task = getDownload(url)!; setStatus(task, DownloadStatus.canceled); _queue.remove(task.request); @@ -240,7 +235,6 @@ class DownloadManager { } Future resumeDownload(String url) async { - logger.d("[DownloadManager] Resume Download"); var task = getDownload(url)!; setStatus(task, DownloadStatus.downloading); task.request.cancelToken = CancelToken(); @@ -403,7 +397,6 @@ class DownloadManager { while (_queue.isNotEmpty && runningTasks < maxConcurrentTasks) { runningTasks++; - logger.d('Concurrent workers: $runningTasks'); var currentRequest = _queue.removeFirst(); await download( diff --git a/lib/services/kv_store/encrypted_kv_store.dart b/lib/services/kv_store/encrypted_kv_store.dart new file mode 100644 index 000000000..4eca00070 --- /dev/null +++ b/lib/services/kv_store/encrypted_kv_store.dart @@ -0,0 +1,59 @@ +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; +import 'package:spotube/services/kv_store/kv_store.dart'; +import 'package:uuid/uuid.dart'; +import 'package:spotube/utils/platform.dart'; + +abstract class EncryptedKvStoreService { + static const _storage = FlutterSecureStorage( + aOptions: AndroidOptions( + encryptedSharedPreferences: true, + ), + ); + + static FlutterSecureStorage get storage => _storage; + + static String? _encryptionKeySync; + + static Future initialize() async { + _encryptionKeySync = await encryptionKey; + } + + static String get encryptionKeySync => _encryptionKeySync!; + + static bool get isUnsupportedPlatform => + kIsMacOS || kIsIOS || (kIsLinux && !kIsFlatpak); + + static Future get encryptionKey async { + if (isUnsupportedPlatform) { + return KVStoreService.encryptionKey; + } + try { + final value = await _storage.read(key: 'encryption'); + final key = const Uuid().v4(); + + if (value == null) { + await setEncryptionKey(key); + return key; + } + + return value; + } catch (e) { + return KVStoreService.encryptionKey; + } + } + + static Future setEncryptionKey(String key) async { + if (isUnsupportedPlatform) { + await KVStoreService.setEncryptionKey(key); + return; + } + + try { + await _storage.write(key: 'encryption', value: key); + } catch (e) { + await KVStoreService.setEncryptionKey(key); + } finally { + _encryptionKeySync = key; + } + } +} diff --git a/lib/services/kv_store/kv_store.dart b/lib/services/kv_store/kv_store.dart index f94ec4ee6..efe83abf8 100644 --- a/lib/services/kv_store/kv_store.dart +++ b/lib/services/kv_store/kv_store.dart @@ -1,4 +1,9 @@ +import 'dart:convert'; + +import 'package:encrypt/encrypt.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:spotube/services/wm_tools/wm_tools.dart'; +import 'package:uuid/uuid.dart'; abstract class KVStoreService { static SharedPreferences? _sharedPreferences; @@ -23,4 +28,63 @@ abstract class KVStoreService { static Future setRecentSearches(List value) async => await sharedPreferences.setStringList('recentSearches', value); + + static WindowSize? get windowSize { + final raw = sharedPreferences.getString('windowSize'); + + if (raw == null) { + return null; + } + return WindowSize.fromJson(jsonDecode(raw)); + } + + static Future setWindowSize(WindowSize value) async => + await sharedPreferences.setString( + 'windowSize', + jsonEncode( + value.toJson(), + ), + ); + + static String get encryptionKey { + final value = sharedPreferences.getString('encryption'); + + final key = const Uuid().v4(); + if (value == null) { + setEncryptionKey(key); + return key; + } + + return value; + } + + static Future setEncryptionKey(String key) async { + await sharedPreferences.setString('encryption', key); + } + + static IV get ivKey { + final iv = sharedPreferences.getString('iv'); + final value = IV.fromSecureRandom(8); + + if (iv == null) { + setIVKey(value); + + return value; + } + + return IV.fromBase64(iv); + } + + static Future setIVKey(IV iv) async { + await sharedPreferences.setString('iv', iv.base64); + } + + static double get volume => sharedPreferences.getDouble('volume') ?? 1.0; + static Future setVolume(double value) async => + await sharedPreferences.setDouble('volume', value); + + static bool get hasMigratedToDrift => + sharedPreferences.getBool('hasMigratedToDrift') ?? false; + static Future setHasMigratedToDrift(bool value) async => + await sharedPreferences.setBool('hasMigratedToDrift', value); } diff --git a/lib/services/logger/logger.dart b/lib/services/logger/logger.dart new file mode 100644 index 000000000..1df7b5aa0 --- /dev/null +++ b/lib/services/logger/logger.dart @@ -0,0 +1,124 @@ +import 'dart:async'; +import 'dart:io'; +import 'dart:isolate'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:logger/logger.dart'; +import 'package:path/path.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:spotube/utils/platform.dart'; + +class AppLogger { + static late final Logger log; + static late final File logFile; + + static initialize(bool verbose) { + log = Logger( + level: kDebugMode || (verbose && kReleaseMode) ? Level.all : Level.info, + ); + } + + static R? runZoned(R Function() body) { + return runZonedGuarded( + () { + WidgetsFlutterBinding.ensureInitialized(); + + FlutterError.onError = (details) { + reportError(details.exception, details.stack ?? StackTrace.current); + }; + + PlatformDispatcher.instance.onError = (error, stackTrace) { + reportError(error, stackTrace); + return true; + }; + + if (!kIsWeb) { + Isolate.current.addErrorListener( + RawReceivePort((pair) async { + final isolateError = pair as List; + reportError( + isolateError.first.toString(), + isolateError.last, + ); + }).sendPort, + ); + } + + getLogsPath().then((value) => logFile = value); + + return body(); + }, + (error, stackTrace) { + reportError(error, stackTrace); + }, + ); + } + + static Future getLogsPath() async { + String dir = (await getApplicationDocumentsDirectory()).path; + if (kIsAndroid) { + dir = (await getExternalStorageDirectory())?.path ?? ""; + } + + if (kIsMacOS) { + dir = join((await getLibraryDirectory()).path, "Logs"); + } + + if (kIsLinux) { + dir = join(_getXdgStateHome(), "spotube"); + } + + final file = File(join(dir, ".spotube_logs")); + if (!await file.exists()) { + await file.create(recursive: true); + } + return file; + } + + static Future reportError( + dynamic error, [ + StackTrace? stackTrace, + message = "", + ]) async { + log.e(message, error: error, stackTrace: stackTrace); + + if (kReleaseMode) { + await logFile.writeAsString( + "[${DateTime.now()}]---------------------\n" + "$error\n$stackTrace\n" + "----------------------------------------\n", + mode: FileMode.writeOnlyAppend, + ); + } + } + + static String _getXdgStateHome() { + // path_provider seems does not support XDG_STATE_HOME, + // which is the specification to store application logs on Linux. + // See https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html + // TODO: Use path_provider once it supports XDG_STATE_HOME + if (const bool.hasEnvironment("XDG_STATE_HOME")) { + String xdgStateHomeRaw = Platform.environment["XDG_STATE_HOME"] ?? ""; + if (xdgStateHomeRaw.isNotEmpty) { + return xdgStateHomeRaw; + } + } + return join(Platform.environment["HOME"] ?? "", ".local", "state"); + } +} + +class AppLoggerProviderObserver extends ProviderObserver { + const AppLoggerProviderObserver(); + + @override + void providerDidFail( + ProviderBase provider, + Object error, + StackTrace stackTrace, + ProviderContainer container, + ) { + AppLogger.reportError(error, stackTrace); + } +} diff --git a/lib/services/song_link/song_link.dart b/lib/services/song_link/song_link.dart index b02f60cbf..e3cffa521 100644 --- a/lib/services/song_link/song_link.dart +++ b/lib/services/song_link/song_link.dart @@ -2,7 +2,7 @@ library song_link; import 'dart:convert'; -import 'package:catcher_2/catcher_2.dart'; +import 'package:spotube/services/logger/logger.dart'; import 'package:dio/dio.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:html/parser.dart'; @@ -47,7 +47,7 @@ abstract class SongLinkService { return songLinks?.map((link) => SongLink.fromJson(link)).toList() ?? []; } catch (e, stackTrace) { - Catcher2.reportCheckedError(e, stackTrace); + AppLogger.reportError(e, stackTrace); return []; } } diff --git a/lib/services/song_link/song_link.freezed.dart b/lib/services/song_link/song_link.freezed.dart index a8230eebf..0a1af8a9b 100644 --- a/lib/services/song_link/song_link.freezed.dart +++ b/lib/services/song_link/song_link.freezed.dart @@ -12,7 +12,7 @@ part of 'song_link.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); SongLink _$SongLinkFromJson(Map json) { return _SongLink.fromJson(json); diff --git a/lib/services/song_link/song_link.g.dart b/lib/services/song_link/song_link.g.dart index 911849e3a..7658a74c8 100644 --- a/lib/services/song_link/song_link.g.dart +++ b/lib/services/song_link/song_link.g.dart @@ -6,8 +6,7 @@ part of 'song_link.dart'; // JsonSerializableGenerator // ************************************************************************** -_$SongLinkImpl _$$SongLinkImplFromJson(Map json) => - _$SongLinkImpl( +_$SongLinkImpl _$$SongLinkImplFromJson(Map json) => _$SongLinkImpl( displayName: json['displayName'] as String, linkId: json['linkId'] as String, platform: json['platform'] as String, diff --git a/lib/services/sourced_track/models/source_info.g.dart b/lib/services/sourced_track/models/source_info.g.dart index 1ec9f75f7..5fe136cee 100644 --- a/lib/services/sourced_track/models/source_info.g.dart +++ b/lib/services/sourced_track/models/source_info.g.dart @@ -6,7 +6,7 @@ part of 'source_info.dart'; // JsonSerializableGenerator // ************************************************************************** -SourceInfo _$SourceInfoFromJson(Map json) => SourceInfo( +SourceInfo _$SourceInfoFromJson(Map json) => SourceInfo( id: json['id'] as String, title: json['title'] as String, artist: json['artist'] as String, diff --git a/lib/services/sourced_track/models/source_map.g.dart b/lib/services/sourced_track/models/source_map.g.dart index e1085aa81..a581cc672 100644 --- a/lib/services/sourced_track/models/source_map.g.dart +++ b/lib/services/sourced_track/models/source_map.g.dart @@ -6,8 +6,7 @@ part of 'source_map.dart'; // JsonSerializableGenerator // ************************************************************************** -SourceQualityMap _$SourceQualityMapFromJson(Map json) => - SourceQualityMap( +SourceQualityMap _$SourceQualityMapFromJson(Map json) => SourceQualityMap( high: json['high'] as String, medium: json['medium'] as String, low: json['low'] as String, @@ -20,16 +19,18 @@ Map _$SourceQualityMapToJson(SourceQualityMap instance) => 'low': instance.low, }; -SourceMap _$SourceMapFromJson(Map json) => SourceMap( +SourceMap _$SourceMapFromJson(Map json) => SourceMap( weba: json['weba'] == null ? null - : SourceQualityMap.fromJson(json['weba'] as Map), + : SourceQualityMap.fromJson( + Map.from(json['weba'] as Map)), m4a: json['m4a'] == null ? null - : SourceQualityMap.fromJson(json['m4a'] as Map), + : SourceQualityMap.fromJson( + Map.from(json['m4a'] as Map)), ); Map _$SourceMapToJson(SourceMap instance) => { - 'weba': instance.weba, - 'm4a': instance.m4a, + 'weba': instance.weba?.toJson(), + 'm4a': instance.m4a?.toJson(), }; diff --git a/lib/services/sourced_track/models/video_info.dart b/lib/services/sourced_track/models/video_info.dart index 031a8943b..58dd02808 100644 --- a/lib/services/sourced_track/models/video_info.dart +++ b/lib/services/sourced_track/models/video_info.dart @@ -1,5 +1,6 @@ import 'package:piped_client/piped_client.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; +import 'package:spotube/models/database/database.dart'; + import 'package:youtube_explode_dart/youtube_explode_dart.dart'; class YoutubeVideoInfo { diff --git a/lib/services/sourced_track/sourced_track.dart b/lib/services/sourced_track/sourced_track.dart index a5e094ed5..977b980be 100644 --- a/lib/services/sourced_track/sourced_track.dart +++ b/lib/services/sourced_track/sourced_track.dart @@ -5,8 +5,9 @@ import 'package:collection/collection.dart'; import 'package:dio/dio.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:spotify/spotify.dart'; +import 'package:spotube/models/database/database.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; + import 'package:spotube/services/sourced_track/enums.dart'; import 'package:spotube/services/sourced_track/exceptions.dart'; import 'package:spotube/services/sourced_track/models/source_info.dart'; @@ -135,16 +136,10 @@ abstract class SourcedTrack extends Track { return await PipedSourcedTrack.fetchFromTrack(track: track, ref: ref); } catch (e) { if (e is DioException || e is ClientException || e is SocketException) { - if (preferences.audioSource == AudioSource.jiosaavn) { - return await JioSaavnSourcedTrack.fetchFromTrack( - track: track, - ref: ref, - weakMatch: true, - ); - } return await JioSaavnSourcedTrack.fetchFromTrack( track: track, ref: ref, + weakMatch: preferences.audioSource == AudioSource.jiosaavn, ); } rethrow; diff --git a/lib/services/sourced_track/sources/jiosaavn.dart b/lib/services/sourced_track/sources/jiosaavn.dart index f731de6c1..1434e4f73 100644 --- a/lib/services/sourced_track/sources/jiosaavn.dart +++ b/lib/services/sourced_track/sources/jiosaavn.dart @@ -1,7 +1,9 @@ import 'package:collection/collection.dart'; +import 'package:drift/drift.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/models/source_match.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; import 'package:spotube/services/sourced_track/enums.dart'; import 'package:spotube/services/sourced_track/exceptions.dart'; import 'package:spotube/services/sourced_track/models/source_info.dart'; @@ -39,7 +41,15 @@ class JioSaavnSourcedTrack extends SourcedTrack { required Ref ref, bool weakMatch = false, }) async { - final cachedSource = await SourceMatch.box.get(track.id); + final database = ref.read(databaseProvider); + final cachedSource = await (database.select(database.sourceMatchTable) + ..where((s) => s.trackId.equals(track.id!)) + ..limit(1) + ..orderBy([ + (s) => + OrderingTerm(expression: s.createdAt, mode: OrderingMode.desc), + ])) + .getSingleOrNull(); if (cachedSource == null || cachedSource.sourceType != SourceType.jiosaavn) { @@ -50,15 +60,13 @@ class JioSaavnSourcedTrack extends SourcedTrack { throw TrackNotFoundError(track); } - await SourceMatch.box.put( - track.id!, - SourceMatch( - id: track.id!, - sourceType: SourceType.jiosaavn, - createdAt: DateTime.now(), - sourceId: siblings.first.info.id, - ), - ); + await database.into(database.sourceMatchTable).insert( + SourceMatchTableCompanion.insert( + trackId: track.id!, + sourceId: siblings.first.info.id, + sourceType: const Value(SourceType.jiosaavn), + ), + ); return JioSaavnSourcedTrack( ref: ref, @@ -206,15 +214,18 @@ class JioSaavnSourcedTrack extends SourcedTrack { final (:info, :source) = toSiblingType(item); - await SourceMatch.box.put( - id!, - SourceMatch( - id: id!, - sourceType: SourceType.jiosaavn, - createdAt: DateTime.now(), - sourceId: info.id, - ), - ); + final database = ref.read(databaseProvider); + await database.into(database.sourceMatchTable).insert( + SourceMatchTableCompanion.insert( + trackId: id!, + sourceId: info.id, + sourceType: const Value(SourceType.jiosaavn), + // Because we're sorting by createdAt in the query + // we have to update it to indicate priority + createdAt: Value(DateTime.now()), + ), + mode: InsertMode.replace, + ); return JioSaavnSourcedTrack( ref: ref, diff --git a/lib/services/sourced_track/sources/piped.dart b/lib/services/sourced_track/sources/piped.dart index 75f831256..d24f110f3 100644 --- a/lib/services/sourced_track/sources/piped.dart +++ b/lib/services/sourced_track/sources/piped.dart @@ -1,10 +1,12 @@ import 'package:collection/collection.dart'; +import 'package:drift/drift.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:piped_client/piped_client.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/models/source_match.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; import 'package:spotube/provider/user_preferences/user_preferences_provider.dart'; -import 'package:spotube/provider/user_preferences/user_preferences_state.dart'; + import 'package:spotube/services/sourced_track/enums.dart'; import 'package:spotube/services/sourced_track/exceptions.dart'; import 'package:spotube/services/sourced_track/models/source_info.dart'; @@ -48,7 +50,15 @@ class PipedSourcedTrack extends SourcedTrack { required Track track, required Ref ref, }) async { - final cachedSource = await SourceMatch.box.get(track.id); + final database = ref.read(databaseProvider); + final cachedSource = await (database.select(database.sourceMatchTable) + ..where((s) => s.trackId.equals(track.id!)) + ..limit(1) + ..orderBy([ + (s) => + OrderingTerm(expression: s.createdAt, mode: OrderingMode.desc), + ])) + .getSingleOrNull(); final preferences = ref.read(userPreferencesProvider); final pipedClient = ref.read(pipedProvider); @@ -58,17 +68,17 @@ class PipedSourcedTrack extends SourcedTrack { throw TrackNotFoundError(track); } - await SourceMatch.box.put( - track.id!, - SourceMatch( - id: track.id!, - sourceType: preferences.searchMode == SearchMode.youtube - ? SourceType.youtube - : SourceType.youtubeMusic, - createdAt: DateTime.now(), - sourceId: siblings.first.info.id, - ), - ); + await database.into(database.sourceMatchTable).insert( + SourceMatchTableCompanion.insert( + trackId: track.id!, + sourceId: siblings.first.info.id, + sourceType: Value( + preferences.searchMode == SearchMode.youtube + ? SourceType.youtube + : SourceType.youtubeMusic, + ), + ), + ); return PipedSourcedTrack( ref: ref, @@ -163,7 +173,7 @@ class PipedSourcedTrack extends SourcedTrack { final PipedSearchResult(items: searchResults) = await pipedClient.search( query, preference.searchMode == SearchMode.youtube - ? PipedFilter.videos + ? PipedFilter.video : PipedFilter.musicSongs, ); @@ -267,15 +277,18 @@ class PipedSourcedTrack extends SourcedTrack { final manifest = await pipedClient.streams(newSourceInfo.id); - await SourceMatch.box.put( - id!, - SourceMatch( - id: id!, - sourceType: SourceType.jiosaavn, - createdAt: DateTime.now(), - sourceId: newSourceInfo.id, - ), - ); + final database = ref.read(databaseProvider); + await database.into(database.sourceMatchTable).insert( + SourceMatchTableCompanion.insert( + trackId: id!, + sourceId: newSourceInfo.id, + sourceType: const Value(SourceType.youtube), + // Because we're sorting by createdAt in the query + // we have to update it to indicate priority + createdAt: Value(DateTime.now()), + ), + mode: InsertMode.replace, + ); return PipedSourcedTrack( ref: ref, diff --git a/lib/services/sourced_track/sources/youtube.dart b/lib/services/sourced_track/sources/youtube.dart index 3fc78f0b7..0b5ee71bb 100644 --- a/lib/services/sourced_track/sources/youtube.dart +++ b/lib/services/sourced_track/sources/youtube.dart @@ -1,8 +1,11 @@ import 'package:collection/collection.dart'; +import 'package:drift/drift.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:http/http.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/models/source_match.dart'; +import 'package:spotube/models/database/database.dart'; +import 'package:spotube/provider/database/database.dart'; +import 'package:spotube/services/logger/logger.dart'; import 'package:spotube/services/song_link/song_link.dart'; import 'package:spotube/services/sourced_track/enums.dart'; import 'package:spotube/services/sourced_track/exceptions.dart'; @@ -45,7 +48,16 @@ class YoutubeSourcedTrack extends SourcedTrack { required Track track, required Ref ref, }) async { - final cachedSource = await SourceMatch.box.get(track.id); + final database = ref.read(databaseProvider); + final cachedSource = await (database.select(database.sourceMatchTable) + ..where((s) => s.trackId.equals(track.id!)) + ..limit(1) + ..orderBy([ + (s) => + OrderingTerm(expression: s.createdAt, mode: OrderingMode.desc), + ])) + .get() + .then((s) => s.firstOrNull); if (cachedSource == null || cachedSource.sourceType != SourceType.youtube) { final siblings = await fetchSiblings(ref: ref, track: track); @@ -53,15 +65,13 @@ class YoutubeSourcedTrack extends SourcedTrack { throw TrackNotFoundError(track); } - await SourceMatch.box.put( - track.id!, - SourceMatch( - id: track.id!, - sourceType: SourceType.youtube, - createdAt: DateTime.now(), - sourceId: siblings.first.info.id, - ), - ); + await database.into(database.sourceMatchTable).insert( + SourceMatchTableCompanion.insert( + trackId: track.id!, + sourceId: siblings.first.info.id, + sourceType: const Value(SourceType.youtube), + ), + ); return YoutubeSourcedTrack( ref: ref, @@ -220,15 +230,23 @@ class YoutubeSourcedTrack extends SourcedTrack { final links = await SongLinkService.links(track.id!); final ytLink = links.firstWhereOrNull((link) => link.platform == "youtube"); - if (ytLink?.url != null) { - return [ - await toSiblingType( - 0, - YoutubeVideoInfo.fromVideo( - await youtubeClient.videos.get(ytLink!.url!), - ), - ) - ]; + if (ytLink?.url != null + // allows to fetch siblings more results for already sourced track + && + track is! SourcedTrack) { + try { + return [ + await toSiblingType( + 0, + YoutubeVideoInfo.fromVideo( + await youtubeClient.videos.get(ytLink!.url!), + ), + ) + ]; + } on VideoUnplayableException catch (e, stack) { + // Ignore this error and continue with the search + AppLogger.reportError(e, stack); + } } final query = SourcedTrack.getSearchTerm(track); @@ -274,15 +292,19 @@ class YoutubeSourcedTrack extends SourcedTrack { onTimeout: () => throw ClientException("Timeout"), ); - await SourceMatch.box.put( - id!, - SourceMatch( - id: id!, - sourceType: SourceType.jiosaavn, - createdAt: DateTime.now(), - sourceId: newSourceInfo.id, - ), - ); + final database = ref.read(databaseProvider); + + await database.into(database.sourceMatchTable).insert( + SourceMatchTableCompanion.insert( + trackId: id!, + sourceId: newSourceInfo.id, + sourceType: const Value(SourceType.youtube), + // Because we're sorting by createdAt in the query + // we have to update it to indicate priority + createdAt: Value(DateTime.now()), + ), + mode: InsertMode.replace, + ); return YoutubeSourcedTrack( ref: ref, diff --git a/lib/services/wm_tools/wm_tools.dart b/lib/services/wm_tools/wm_tools.dart new file mode 100644 index 000000000..920e09b57 --- /dev/null +++ b/lib/services/wm_tools/wm_tools.dart @@ -0,0 +1,89 @@ +import 'package:flutter/material.dart'; +import 'package:spotube/services/kv_store/kv_store.dart'; +import 'package:spotube/utils/platform.dart'; +import 'package:window_manager/window_manager.dart'; + +class WindowSize { + final double height; + final double width; + final bool maximized; + + WindowSize({ + required this.height, + required this.width, + required this.maximized, + }); + + factory WindowSize.fromJson(Map json) => WindowSize( + height: json["height"], + width: json["width"], + maximized: json["maximized"], + ); + + Map toJson() => { + "height": height, + "width": width, + "maximized": maximized, + }; +} + +class WindowManagerTools with WidgetsBindingObserver { + static WindowManagerTools? _instance; + static WindowManagerTools get instance => _instance!; + + WindowManagerTools._(); + + static Future initialize() async { + await windowManager.ensureInitialized(); + _instance = WindowManagerTools._(); + WidgetsBinding.instance.addObserver(instance); + + await windowManager.waitUntilReadyToShow( + const WindowOptions( + title: "Spotube", + backgroundColor: Colors.transparent, + minimumSize: Size(300, 700), + titleBarStyle: TitleBarStyle.hidden, + center: true, + ), + () async { + final savedSize = KVStoreService.windowSize; + await windowManager.setResizable(true); + if (savedSize?.maximized == true && + !(await windowManager.isMaximized())) { + await windowManager.maximize(); + } else if (savedSize != null) { + await windowManager.setSize(Size(savedSize.width, savedSize.height)); + } + + await windowManager.focus(); + await windowManager.show(); + }, + ); + } + + Size? _prevSize; + + @override + void didChangeMetrics() async { + super.didChangeMetrics(); + if (kIsMobile) return; + final size = await windowManager.getSize(); + final windowSameDimension = + _prevSize?.width == size.width && _prevSize?.height == size.height; + + if (windowSameDimension || _prevSize == null) { + _prevSize = size; + return; + } + final isMaximized = await windowManager.isMaximized(); + await KVStoreService.setWindowSize( + WindowSize( + height: size.height, + width: size.width, + maximized: isMaximized, + ), + ); + _prevSize = size; + } +} diff --git a/lib/themes/theme.dart b/lib/themes/theme.dart index 51e98269a..485e5af7b 100644 --- a/lib/themes/theme.dart +++ b/lib/themes/theme.dart @@ -4,7 +4,6 @@ ThemeData theme(Color seed, Brightness brightness, bool isAmoled) { final scheme = ColorScheme.fromSeed( seedColor: seed, shadow: Colors.black12, - background: isAmoled ? Colors.black : null, surface: isAmoled ? Colors.black : null, brightness: brightness, ); @@ -15,7 +14,12 @@ ThemeData theme(Color seed, Brightness brightness, bool isAmoled) { horizontalTitleGap: 5, iconColor: scheme.onSurface, ), - appBarTheme: const AppBarTheme(surfaceTintColor: Colors.transparent), + appBarTheme: const AppBarTheme( + surfaceTintColor: Colors.transparent, + scrolledUnderElevation: 0, + shadowColor: Colors.transparent, + elevation: 0, + ), inputDecorationTheme: InputDecorationTheme( border: OutlineInputBorder( borderRadius: BorderRadius.circular(15), @@ -25,7 +29,7 @@ ThemeData theme(Color seed, Brightness brightness, bool isAmoled) { navigationBarTheme: const NavigationBarThemeData( labelBehavior: NavigationDestinationLabelBehavior.alwaysHide, height: 50, - iconTheme: MaterialStatePropertyAll( + iconTheme: WidgetStatePropertyAll( IconThemeData(size: 18), ), ), @@ -43,6 +47,9 @@ ThemeData theme(Color seed, Brightness brightness, bool isAmoled) { shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), color: scheme.surface, elevation: 4, + labelTextStyle: WidgetStatePropertyAll( + TextStyle(color: scheme.onSurface), + ), ), snackBarTheme: SnackBarThemeData( behavior: SnackBarBehavior.floating, @@ -52,25 +59,25 @@ ThemeData theme(Color seed, Brightness brightness, bool isAmoled) { ), sliderTheme: SliderThemeData(overlayShape: SliderComponentShape.noOverlay), searchBarTheme: SearchBarThemeData( - textStyle: const MaterialStatePropertyAll(TextStyle(fontSize: 15)), + textStyle: const WidgetStatePropertyAll(TextStyle(fontSize: 15)), constraints: const BoxConstraints(maxWidth: double.infinity), - padding: const MaterialStatePropertyAll(EdgeInsets.all(8)), - backgroundColor: MaterialStatePropertyAll( + padding: const WidgetStatePropertyAll(EdgeInsets.all(8)), + backgroundColor: WidgetStatePropertyAll( Color.lerp( - scheme.surfaceVariant, + scheme.surfaceContainerHighest, scheme.surface, brightness == Brightness.light ? .9 : .7, ), ), - elevation: const MaterialStatePropertyAll(0), - shape: MaterialStatePropertyAll( + elevation: const WidgetStatePropertyAll(0), + shape: WidgetStatePropertyAll( RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), ), ), scrollbarTheme: const ScrollbarThemeData( - thickness: MaterialStatePropertyAll(14), + thickness: WidgetStatePropertyAll(14), ), checkboxTheme: CheckboxThemeData( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), diff --git a/lib/utils/duration.dart b/lib/utils/duration.dart index a2bb4d165..1869cea15 100644 --- a/lib/utils/duration.dart +++ b/lib/utils/duration.dart @@ -1,4 +1,4 @@ -import 'package:catcher_2/catcher_2.dart'; +import 'package:spotube/services/logger/logger.dart'; /// Parses duration string formatted by Duration.toString() to [Duration]. /// The string should be of form hours:minutes:seconds.microseconds @@ -51,7 +51,7 @@ Duration? tryParseDuration(String input) { try { return parseDuration(input); } catch (e, stack) { - Catcher2.reportCheckedError(e, stack); + AppLogger.reportError(e, stack); return null; } } diff --git a/lib/utils/migrations/adapters.dart b/lib/utils/migrations/adapters.dart new file mode 100644 index 000000000..f7f6350be --- /dev/null +++ b/lib/utils/migrations/adapters.dart @@ -0,0 +1,320 @@ +import 'package:hive/hive.dart'; +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:spotify/spotify.dart'; +import 'package:spotube/modules/settings/color_scheme_picker_dialog.dart'; +import 'package:spotube/services/sourced_track/enums.dart'; + +part 'adapters.g.dart'; +part 'adapters.freezed.dart'; + +@HiveType(typeId: 2) +class SkipSegment { + @HiveField(0) + final int start; + @HiveField(1) + final int end; + SkipSegment(this.start, this.end); + + static String version = 'v1'; + static final boxName = "oss.krtirtho.spotube.skip_segments.$version"; + static LazyBox get box => Hive.lazyBox(boxName); + + SkipSegment.fromJson(Map json) + : start = json['start'], + end = json['end']; + + Map toJson() => { + 'start': start, + 'end': end, + }; +} + +@JsonEnum() +@HiveType(typeId: 5) +enum SourceType { + @HiveField(0) + youtube._("YouTube"), + + @HiveField(1) + youtubeMusic._("YouTube Music"), + + @HiveField(2) + jiosaavn._("JioSaavn"); + + final String label; + + const SourceType._(this.label); +} + +@JsonSerializable() +@HiveType(typeId: 6) +class SourceMatch { + @HiveField(0) + String id; + + @HiveField(1) + String sourceId; + + @HiveField(2) + SourceType sourceType; + + @HiveField(3) + DateTime createdAt; + + SourceMatch({ + required this.id, + required this.sourceId, + required this.sourceType, + required this.createdAt, + }); + + factory SourceMatch.fromJson(Map json) => + _$SourceMatchFromJson(json); + + Map toJson() => _$SourceMatchToJson(this); + + static String version = 'v1'; + static final boxName = "oss.krtirtho.spotube.source_matches.$version"; + + static LazyBox get box => Hive.lazyBox(boxName); +} + +@JsonSerializable() +class AuthenticationCredentials { + String cookie; + String accessToken; + DateTime expiration; + + AuthenticationCredentials({ + required this.cookie, + required this.accessToken, + required this.expiration, + }); + + factory AuthenticationCredentials.fromJson(Map json) { + return AuthenticationCredentials( + cookie: json['cookie'] as String, + accessToken: json['accessToken'] as String, + expiration: DateTime.parse(json['expiration'] as String), + ); + } + + Map toJson() { + return { + 'cookie': cookie, + 'accessToken': accessToken, + 'expiration': expiration.toIso8601String(), + }; + } +} + +@JsonEnum() +enum LayoutMode { + compact, + extended, + adaptive, +} + +@JsonEnum() +enum CloseBehavior { + minimizeToTray, + close, +} + +@JsonEnum() +enum AudioSource { + youtube, + piped, + jiosaavn; + + String get label => name[0].toUpperCase() + name.substring(1); +} + +@JsonEnum() +enum MusicCodec { + m4a._("M4a (Best for downloaded music)"), + weba._("WebA (Best for streamed music)\nDoesn't support audio metadata"); + + final String label; + const MusicCodec._(this.label); +} + +@JsonEnum() +enum SearchMode { + youtube._("YouTube"), + youtubeMusic._("YouTube Music"); + + final String label; + + const SearchMode._(this.label); + + factory SearchMode.fromString(String key) { + return SearchMode.values.firstWhere((e) => e.name == key); + } +} + +@freezed +class UserPreferences with _$UserPreferences { + const factory UserPreferences({ + @Default(SourceQualities.high) SourceQualities audioQuality, + @Default(true) bool albumColorSync, + @Default(false) bool amoledDarkTheme, + @Default(true) bool checkUpdate, + @Default(false) bool normalizeAudio, + @Default(false) bool showSystemTrayIcon, + @Default(false) bool skipNonMusic, + @Default(false) bool systemTitleBar, + @Default(CloseBehavior.close) CloseBehavior closeBehavior, + @Default(SpotubeColor(0xFF2196F3, name: "Blue")) + @JsonKey( + fromJson: UserPreferences._accentColorSchemeFromJson, + toJson: UserPreferences._accentColorSchemeToJson, + readValue: UserPreferences._accentColorSchemeReadValue, + ) + SpotubeColor accentColorScheme, + @Default(LayoutMode.adaptive) LayoutMode layoutMode, + @Default(Locale("system", "system")) + @JsonKey( + fromJson: UserPreferences._localeFromJson, + toJson: UserPreferences._localeToJson, + readValue: UserPreferences._localeReadValue, + ) + Locale locale, + @Default(Market.US) Market recommendationMarket, + @Default(SearchMode.youtube) SearchMode searchMode, + @Default("") String downloadLocation, + @Default([]) List localLibraryLocation, + @Default("https://pipedapi.kavin.rocks") String pipedInstance, + @Default(ThemeMode.system) ThemeMode themeMode, + @Default(AudioSource.youtube) AudioSource audioSource, + @Default(SourceCodecs.weba) SourceCodecs streamMusicCodec, + @Default(SourceCodecs.m4a) SourceCodecs downloadMusicCodec, + @Default(true) bool discordPresence, + @Default(true) bool endlessPlayback, + @Default(false) bool enableConnect, + }) = _UserPreferences; + factory UserPreferences.fromJson(Map json) => + _$UserPreferencesFromJson(json); + + factory UserPreferences.withDefaults() => UserPreferences.fromJson({}); + + static SpotubeColor _accentColorSchemeFromJson(Map json) { + return SpotubeColor.fromString(json["color"]); + } + + static Map? _accentColorSchemeReadValue( + Map json, String key) { + if (json[key] is String) { + return {"color": json[key]}; + } + + return json[key] as Map?; + } + + static Map _accentColorSchemeToJson(SpotubeColor color) { + return {"color": color.toString()}; + } + + static Locale _localeFromJson(Map json) { + return Locale(json["languageCode"], json["countryCode"]); + } + + static Map _localeToJson(Locale locale) { + return { + "languageCode": locale.languageCode, + "countryCode": locale.countryCode, + }; + } + + static Map? _localeReadValue( + Map json, String key) { + if (json[key] is String) { + final map = jsonDecode(json[key]); + return { + "languageCode": map["lc"], + "countryCode": map["cc"], + }; + } + + return json[key] as Map?; + } +} + +enum BlacklistedType { + artist, + track; + + static BlacklistedType fromName(String name) => + BlacklistedType.values.firstWhere((e) => e.name == name); +} + +class BlacklistedElement { + final String id; + final String name; + final BlacklistedType type; + + BlacklistedElement.fromJson(Map json) + : id = json['id'], + name = json['name'], + type = BlacklistedType.fromName(json['type']); + + Map toJson() => {'id': id, 'type': type.name, 'name': name}; +} + +@freezed +class PlaybackHistoryItem with _$PlaybackHistoryItem { + factory PlaybackHistoryItem.playlist({ + required DateTime date, + required PlaylistSimple playlist, + }) = PlaybackHistoryPlaylist; + + factory PlaybackHistoryItem.album({ + required DateTime date, + required AlbumSimple album, + }) = PlaybackHistoryAlbum; + + factory PlaybackHistoryItem.track({ + required DateTime date, + required Track track, + }) = PlaybackHistoryTrack; + + factory PlaybackHistoryItem.fromJson(Map json) => + _$PlaybackHistoryItemFromJson(json); +} + +class PlaybackHistoryState { + final List items; + const PlaybackHistoryState({this.items = const []}); + + factory PlaybackHistoryState.fromJson(Map json) { + return PlaybackHistoryState( + items: json["items"] + ?.map( + (json) => PlaybackHistoryItem.fromJson(json), + ) + .toList() + .cast() ?? + [], + ); + } +} + +class ScrobblerState { + final String username; + final String passwordHash; + + ScrobblerState({ + required this.username, + required this.passwordHash, + }); + + factory ScrobblerState.fromJson(Map json) { + return ScrobblerState( + username: json["username"], + passwordHash: json["passwordHash"], + ); + } +} diff --git a/lib/provider/user_preferences/user_preferences_state.freezed.dart b/lib/utils/migrations/adapters.freezed.dart similarity index 55% rename from lib/provider/user_preferences/user_preferences_state.freezed.dart rename to lib/utils/migrations/adapters.freezed.dart index a5b076bb6..339ec0e5b 100644 --- a/lib/provider/user_preferences/user_preferences_state.freezed.dart +++ b/lib/utils/migrations/adapters.freezed.dart @@ -3,7 +3,7 @@ // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark -part of 'user_preferences_state.dart'; +part of 'adapters.dart'; // ************************************************************************** // FreezedGenerator @@ -12,7 +12,7 @@ part of 'user_preferences_state.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); UserPreferences _$UserPreferencesFromJson(Map json) { return _UserPreferences.fromJson(json); @@ -43,6 +43,7 @@ mixin _$UserPreferences { Market get recommendationMarket => throw _privateConstructorUsedError; SearchMode get searchMode => throw _privateConstructorUsedError; String get downloadLocation => throw _privateConstructorUsedError; + List get localLibraryLocation => throw _privateConstructorUsedError; String get pipedInstance => throw _privateConstructorUsedError; ThemeMode get themeMode => throw _privateConstructorUsedError; AudioSource get audioSource => throw _privateConstructorUsedError; @@ -88,6 +89,7 @@ abstract class $UserPreferencesCopyWith<$Res> { Market recommendationMarket, SearchMode searchMode, String downloadLocation, + List localLibraryLocation, String pipedInstance, ThemeMode themeMode, AudioSource audioSource, @@ -126,6 +128,7 @@ class _$UserPreferencesCopyWithImpl<$Res, $Val extends UserPreferences> Object? recommendationMarket = null, Object? searchMode = null, Object? downloadLocation = null, + Object? localLibraryLocation = null, Object? pipedInstance = null, Object? themeMode = null, Object? audioSource = null, @@ -196,6 +199,10 @@ class _$UserPreferencesCopyWithImpl<$Res, $Val extends UserPreferences> ? _value.downloadLocation : downloadLocation // ignore: cast_nullable_to_non_nullable as String, + localLibraryLocation: null == localLibraryLocation + ? _value.localLibraryLocation + : localLibraryLocation // ignore: cast_nullable_to_non_nullable + as List, pipedInstance: null == pipedInstance ? _value.pipedInstance : pipedInstance // ignore: cast_nullable_to_non_nullable @@ -264,6 +271,7 @@ abstract class _$$UserPreferencesImplCopyWith<$Res> Market recommendationMarket, SearchMode searchMode, String downloadLocation, + List localLibraryLocation, String pipedInstance, ThemeMode themeMode, AudioSource audioSource, @@ -300,6 +308,7 @@ class __$$UserPreferencesImplCopyWithImpl<$Res> Object? recommendationMarket = null, Object? searchMode = null, Object? downloadLocation = null, + Object? localLibraryLocation = null, Object? pipedInstance = null, Object? themeMode = null, Object? audioSource = null, @@ -370,6 +379,10 @@ class __$$UserPreferencesImplCopyWithImpl<$Res> ? _value.downloadLocation : downloadLocation // ignore: cast_nullable_to_non_nullable as String, + localLibraryLocation: null == localLibraryLocation + ? _value._localLibraryLocation + : localLibraryLocation // ignore: cast_nullable_to_non_nullable + as List, pipedInstance: null == pipedInstance ? _value.pipedInstance : pipedInstance // ignore: cast_nullable_to_non_nullable @@ -415,10 +428,10 @@ class _$UserPreferencesImpl implements _UserPreferences { this.amoledDarkTheme = false, this.checkUpdate = true, this.normalizeAudio = false, - this.showSystemTrayIcon = true, + this.showSystemTrayIcon = false, this.skipNonMusic = false, this.systemTitleBar = false, - this.closeBehavior = CloseBehavior.minimizeToTray, + this.closeBehavior = CloseBehavior.close, @JsonKey( fromJson: UserPreferences._accentColorSchemeFromJson, toJson: UserPreferences._accentColorSchemeToJson, @@ -433,6 +446,7 @@ class _$UserPreferencesImpl implements _UserPreferences { this.recommendationMarket = Market.US, this.searchMode = SearchMode.youtube, this.downloadLocation = "", + final List localLibraryLocation = const [], this.pipedInstance = "https://pipedapi.kavin.rocks", this.themeMode = ThemeMode.system, this.audioSource = AudioSource.youtube, @@ -440,7 +454,8 @@ class _$UserPreferencesImpl implements _UserPreferences { this.downloadMusicCodec = SourceCodecs.m4a, this.discordPresence = true, this.endlessPlayback = true, - this.enableConnect = false}); + this.enableConnect = false}) + : _localLibraryLocation = localLibraryLocation; factory _$UserPreferencesImpl.fromJson(Map json) => _$$UserPreferencesImplFromJson(json); @@ -496,6 +511,16 @@ class _$UserPreferencesImpl implements _UserPreferences { @override @JsonKey() final String downloadLocation; + final List _localLibraryLocation; + @override + @JsonKey() + List get localLibraryLocation { + if (_localLibraryLocation is EqualUnmodifiableListView) + return _localLibraryLocation; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_localLibraryLocation); + } + @override @JsonKey() final String pipedInstance; @@ -523,7 +548,7 @@ class _$UserPreferencesImpl implements _UserPreferences { @override String toString() { - return 'UserPreferences(audioQuality: $audioQuality, albumColorSync: $albumColorSync, amoledDarkTheme: $amoledDarkTheme, checkUpdate: $checkUpdate, normalizeAudio: $normalizeAudio, showSystemTrayIcon: $showSystemTrayIcon, skipNonMusic: $skipNonMusic, systemTitleBar: $systemTitleBar, closeBehavior: $closeBehavior, accentColorScheme: $accentColorScheme, layoutMode: $layoutMode, locale: $locale, recommendationMarket: $recommendationMarket, searchMode: $searchMode, downloadLocation: $downloadLocation, pipedInstance: $pipedInstance, themeMode: $themeMode, audioSource: $audioSource, streamMusicCodec: $streamMusicCodec, downloadMusicCodec: $downloadMusicCodec, discordPresence: $discordPresence, endlessPlayback: $endlessPlayback, enableConnect: $enableConnect)'; + return 'UserPreferences(audioQuality: $audioQuality, albumColorSync: $albumColorSync, amoledDarkTheme: $amoledDarkTheme, checkUpdate: $checkUpdate, normalizeAudio: $normalizeAudio, showSystemTrayIcon: $showSystemTrayIcon, skipNonMusic: $skipNonMusic, systemTitleBar: $systemTitleBar, closeBehavior: $closeBehavior, accentColorScheme: $accentColorScheme, layoutMode: $layoutMode, locale: $locale, recommendationMarket: $recommendationMarket, searchMode: $searchMode, downloadLocation: $downloadLocation, localLibraryLocation: $localLibraryLocation, pipedInstance: $pipedInstance, themeMode: $themeMode, audioSource: $audioSource, streamMusicCodec: $streamMusicCodec, downloadMusicCodec: $downloadMusicCodec, discordPresence: $discordPresence, endlessPlayback: $endlessPlayback, enableConnect: $enableConnect)'; } @override @@ -560,6 +585,8 @@ class _$UserPreferencesImpl implements _UserPreferences { other.searchMode == searchMode) && (identical(other.downloadLocation, downloadLocation) || other.downloadLocation == downloadLocation) && + const DeepCollectionEquality() + .equals(other._localLibraryLocation, _localLibraryLocation) && (identical(other.pipedInstance, pipedInstance) || other.pipedInstance == pipedInstance) && (identical(other.themeMode, themeMode) || @@ -597,6 +624,7 @@ class _$UserPreferencesImpl implements _UserPreferences { recommendationMarket, searchMode, downloadLocation, + const DeepCollectionEquality().hash(_localLibraryLocation), pipedInstance, themeMode, audioSource, @@ -647,6 +675,7 @@ abstract class _UserPreferences implements UserPreferences { final Market recommendationMarket, final SearchMode searchMode, final String downloadLocation, + final List localLibraryLocation, final String pipedInstance, final ThemeMode themeMode, final AudioSource audioSource, @@ -698,6 +727,8 @@ abstract class _UserPreferences implements UserPreferences { @override String get downloadLocation; @override + List get localLibraryLocation; + @override String get pipedInstance; @override ThemeMode get themeMode; @@ -718,3 +749,632 @@ abstract class _UserPreferences implements UserPreferences { _$$UserPreferencesImplCopyWith<_$UserPreferencesImpl> get copyWith => throw _privateConstructorUsedError; } + +PlaybackHistoryItem _$PlaybackHistoryItemFromJson(Map json) { + switch (json['runtimeType']) { + case 'playlist': + return PlaybackHistoryPlaylist.fromJson(json); + case 'album': + return PlaybackHistoryAlbum.fromJson(json); + case 'track': + return PlaybackHistoryTrack.fromJson(json); + + default: + throw CheckedFromJsonException(json, 'runtimeType', 'PlaybackHistoryItem', + 'Invalid union type "${json['runtimeType']}"!'); + } +} + +/// @nodoc +mixin _$PlaybackHistoryItem { + DateTime get date => throw _privateConstructorUsedError; + @optionalTypeArgs + TResult when({ + required TResult Function(DateTime date, PlaylistSimple playlist) playlist, + required TResult Function(DateTime date, AlbumSimple album) album, + required TResult Function(DateTime date, Track track) track, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime date, PlaylistSimple playlist)? playlist, + TResult? Function(DateTime date, AlbumSimple album)? album, + TResult? Function(DateTime date, Track track)? track, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime date, PlaylistSimple playlist)? playlist, + TResult Function(DateTime date, AlbumSimple album)? album, + TResult Function(DateTime date, Track track)? track, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult map({ + required TResult Function(PlaybackHistoryPlaylist value) playlist, + required TResult Function(PlaybackHistoryAlbum value) album, + required TResult Function(PlaybackHistoryTrack value) track, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PlaybackHistoryPlaylist value)? playlist, + TResult? Function(PlaybackHistoryAlbum value)? album, + TResult? Function(PlaybackHistoryTrack value)? track, + }) => + throw _privateConstructorUsedError; + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PlaybackHistoryPlaylist value)? playlist, + TResult Function(PlaybackHistoryAlbum value)? album, + TResult Function(PlaybackHistoryTrack value)? track, + required TResult orElse(), + }) => + throw _privateConstructorUsedError; + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $PlaybackHistoryItemCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PlaybackHistoryItemCopyWith<$Res> { + factory $PlaybackHistoryItemCopyWith( + PlaybackHistoryItem value, $Res Function(PlaybackHistoryItem) then) = + _$PlaybackHistoryItemCopyWithImpl<$Res, PlaybackHistoryItem>; + @useResult + $Res call({DateTime date}); +} + +/// @nodoc +class _$PlaybackHistoryItemCopyWithImpl<$Res, $Val extends PlaybackHistoryItem> + implements $PlaybackHistoryItemCopyWith<$Res> { + _$PlaybackHistoryItemCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = null, + }) { + return _then(_value.copyWith( + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$PlaybackHistoryPlaylistImplCopyWith<$Res> + implements $PlaybackHistoryItemCopyWith<$Res> { + factory _$$PlaybackHistoryPlaylistImplCopyWith( + _$PlaybackHistoryPlaylistImpl value, + $Res Function(_$PlaybackHistoryPlaylistImpl) then) = + __$$PlaybackHistoryPlaylistImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({DateTime date, PlaylistSimple playlist}); +} + +/// @nodoc +class __$$PlaybackHistoryPlaylistImplCopyWithImpl<$Res> + extends _$PlaybackHistoryItemCopyWithImpl<$Res, + _$PlaybackHistoryPlaylistImpl> + implements _$$PlaybackHistoryPlaylistImplCopyWith<$Res> { + __$$PlaybackHistoryPlaylistImplCopyWithImpl( + _$PlaybackHistoryPlaylistImpl _value, + $Res Function(_$PlaybackHistoryPlaylistImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = null, + Object? playlist = null, + }) { + return _then(_$PlaybackHistoryPlaylistImpl( + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime, + playlist: null == playlist + ? _value.playlist + : playlist // ignore: cast_nullable_to_non_nullable + as PlaylistSimple, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PlaybackHistoryPlaylistImpl implements PlaybackHistoryPlaylist { + _$PlaybackHistoryPlaylistImpl( + {required this.date, required this.playlist, final String? $type}) + : $type = $type ?? 'playlist'; + + factory _$PlaybackHistoryPlaylistImpl.fromJson(Map json) => + _$$PlaybackHistoryPlaylistImplFromJson(json); + + @override + final DateTime date; + @override + final PlaylistSimple playlist; + + @JsonKey(name: 'runtimeType') + final String $type; + + @override + String toString() { + return 'PlaybackHistoryItem.playlist(date: $date, playlist: $playlist)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlaybackHistoryPlaylistImpl && + (identical(other.date, date) || other.date == date) && + (identical(other.playlist, playlist) || + other.playlist == playlist)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, date, playlist); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$PlaybackHistoryPlaylistImplCopyWith<_$PlaybackHistoryPlaylistImpl> + get copyWith => __$$PlaybackHistoryPlaylistImplCopyWithImpl< + _$PlaybackHistoryPlaylistImpl>(this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(DateTime date, PlaylistSimple playlist) playlist, + required TResult Function(DateTime date, AlbumSimple album) album, + required TResult Function(DateTime date, Track track) track, + }) { + return playlist(date, this.playlist); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime date, PlaylistSimple playlist)? playlist, + TResult? Function(DateTime date, AlbumSimple album)? album, + TResult? Function(DateTime date, Track track)? track, + }) { + return playlist?.call(date, this.playlist); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime date, PlaylistSimple playlist)? playlist, + TResult Function(DateTime date, AlbumSimple album)? album, + TResult Function(DateTime date, Track track)? track, + required TResult orElse(), + }) { + if (playlist != null) { + return playlist(date, this.playlist); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(PlaybackHistoryPlaylist value) playlist, + required TResult Function(PlaybackHistoryAlbum value) album, + required TResult Function(PlaybackHistoryTrack value) track, + }) { + return playlist(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PlaybackHistoryPlaylist value)? playlist, + TResult? Function(PlaybackHistoryAlbum value)? album, + TResult? Function(PlaybackHistoryTrack value)? track, + }) { + return playlist?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PlaybackHistoryPlaylist value)? playlist, + TResult Function(PlaybackHistoryAlbum value)? album, + TResult Function(PlaybackHistoryTrack value)? track, + required TResult orElse(), + }) { + if (playlist != null) { + return playlist(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$PlaybackHistoryPlaylistImplToJson( + this, + ); + } +} + +abstract class PlaybackHistoryPlaylist implements PlaybackHistoryItem { + factory PlaybackHistoryPlaylist( + {required final DateTime date, + required final PlaylistSimple playlist}) = _$PlaybackHistoryPlaylistImpl; + + factory PlaybackHistoryPlaylist.fromJson(Map json) = + _$PlaybackHistoryPlaylistImpl.fromJson; + + @override + DateTime get date; + PlaylistSimple get playlist; + @override + @JsonKey(ignore: true) + _$$PlaybackHistoryPlaylistImplCopyWith<_$PlaybackHistoryPlaylistImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$PlaybackHistoryAlbumImplCopyWith<$Res> + implements $PlaybackHistoryItemCopyWith<$Res> { + factory _$$PlaybackHistoryAlbumImplCopyWith(_$PlaybackHistoryAlbumImpl value, + $Res Function(_$PlaybackHistoryAlbumImpl) then) = + __$$PlaybackHistoryAlbumImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({DateTime date, AlbumSimple album}); +} + +/// @nodoc +class __$$PlaybackHistoryAlbumImplCopyWithImpl<$Res> + extends _$PlaybackHistoryItemCopyWithImpl<$Res, _$PlaybackHistoryAlbumImpl> + implements _$$PlaybackHistoryAlbumImplCopyWith<$Res> { + __$$PlaybackHistoryAlbumImplCopyWithImpl(_$PlaybackHistoryAlbumImpl _value, + $Res Function(_$PlaybackHistoryAlbumImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = null, + Object? album = null, + }) { + return _then(_$PlaybackHistoryAlbumImpl( + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime, + album: null == album + ? _value.album + : album // ignore: cast_nullable_to_non_nullable + as AlbumSimple, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PlaybackHistoryAlbumImpl implements PlaybackHistoryAlbum { + _$PlaybackHistoryAlbumImpl( + {required this.date, required this.album, final String? $type}) + : $type = $type ?? 'album'; + + factory _$PlaybackHistoryAlbumImpl.fromJson(Map json) => + _$$PlaybackHistoryAlbumImplFromJson(json); + + @override + final DateTime date; + @override + final AlbumSimple album; + + @JsonKey(name: 'runtimeType') + final String $type; + + @override + String toString() { + return 'PlaybackHistoryItem.album(date: $date, album: $album)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlaybackHistoryAlbumImpl && + (identical(other.date, date) || other.date == date) && + (identical(other.album, album) || other.album == album)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, date, album); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$PlaybackHistoryAlbumImplCopyWith<_$PlaybackHistoryAlbumImpl> + get copyWith => + __$$PlaybackHistoryAlbumImplCopyWithImpl<_$PlaybackHistoryAlbumImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(DateTime date, PlaylistSimple playlist) playlist, + required TResult Function(DateTime date, AlbumSimple album) album, + required TResult Function(DateTime date, Track track) track, + }) { + return album(date, this.album); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime date, PlaylistSimple playlist)? playlist, + TResult? Function(DateTime date, AlbumSimple album)? album, + TResult? Function(DateTime date, Track track)? track, + }) { + return album?.call(date, this.album); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime date, PlaylistSimple playlist)? playlist, + TResult Function(DateTime date, AlbumSimple album)? album, + TResult Function(DateTime date, Track track)? track, + required TResult orElse(), + }) { + if (album != null) { + return album(date, this.album); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(PlaybackHistoryPlaylist value) playlist, + required TResult Function(PlaybackHistoryAlbum value) album, + required TResult Function(PlaybackHistoryTrack value) track, + }) { + return album(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PlaybackHistoryPlaylist value)? playlist, + TResult? Function(PlaybackHistoryAlbum value)? album, + TResult? Function(PlaybackHistoryTrack value)? track, + }) { + return album?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PlaybackHistoryPlaylist value)? playlist, + TResult Function(PlaybackHistoryAlbum value)? album, + TResult Function(PlaybackHistoryTrack value)? track, + required TResult orElse(), + }) { + if (album != null) { + return album(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$PlaybackHistoryAlbumImplToJson( + this, + ); + } +} + +abstract class PlaybackHistoryAlbum implements PlaybackHistoryItem { + factory PlaybackHistoryAlbum( + {required final DateTime date, + required final AlbumSimple album}) = _$PlaybackHistoryAlbumImpl; + + factory PlaybackHistoryAlbum.fromJson(Map json) = + _$PlaybackHistoryAlbumImpl.fromJson; + + @override + DateTime get date; + AlbumSimple get album; + @override + @JsonKey(ignore: true) + _$$PlaybackHistoryAlbumImplCopyWith<_$PlaybackHistoryAlbumImpl> + get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class _$$PlaybackHistoryTrackImplCopyWith<$Res> + implements $PlaybackHistoryItemCopyWith<$Res> { + factory _$$PlaybackHistoryTrackImplCopyWith(_$PlaybackHistoryTrackImpl value, + $Res Function(_$PlaybackHistoryTrackImpl) then) = + __$$PlaybackHistoryTrackImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({DateTime date, Track track}); +} + +/// @nodoc +class __$$PlaybackHistoryTrackImplCopyWithImpl<$Res> + extends _$PlaybackHistoryItemCopyWithImpl<$Res, _$PlaybackHistoryTrackImpl> + implements _$$PlaybackHistoryTrackImplCopyWith<$Res> { + __$$PlaybackHistoryTrackImplCopyWithImpl(_$PlaybackHistoryTrackImpl _value, + $Res Function(_$PlaybackHistoryTrackImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? date = null, + Object? track = null, + }) { + return _then(_$PlaybackHistoryTrackImpl( + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime, + track: null == track + ? _value.track + : track // ignore: cast_nullable_to_non_nullable + as Track, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$PlaybackHistoryTrackImpl implements PlaybackHistoryTrack { + _$PlaybackHistoryTrackImpl( + {required this.date, required this.track, final String? $type}) + : $type = $type ?? 'track'; + + factory _$PlaybackHistoryTrackImpl.fromJson(Map json) => + _$$PlaybackHistoryTrackImplFromJson(json); + + @override + final DateTime date; + @override + final Track track; + + @JsonKey(name: 'runtimeType') + final String $type; + + @override + String toString() { + return 'PlaybackHistoryItem.track(date: $date, track: $track)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PlaybackHistoryTrackImpl && + (identical(other.date, date) || other.date == date) && + (identical(other.track, track) || other.track == track)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, date, track); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$PlaybackHistoryTrackImplCopyWith<_$PlaybackHistoryTrackImpl> + get copyWith => + __$$PlaybackHistoryTrackImplCopyWithImpl<_$PlaybackHistoryTrackImpl>( + this, _$identity); + + @override + @optionalTypeArgs + TResult when({ + required TResult Function(DateTime date, PlaylistSimple playlist) playlist, + required TResult Function(DateTime date, AlbumSimple album) album, + required TResult Function(DateTime date, Track track) track, + }) { + return track(date, this.track); + } + + @override + @optionalTypeArgs + TResult? whenOrNull({ + TResult? Function(DateTime date, PlaylistSimple playlist)? playlist, + TResult? Function(DateTime date, AlbumSimple album)? album, + TResult? Function(DateTime date, Track track)? track, + }) { + return track?.call(date, this.track); + } + + @override + @optionalTypeArgs + TResult maybeWhen({ + TResult Function(DateTime date, PlaylistSimple playlist)? playlist, + TResult Function(DateTime date, AlbumSimple album)? album, + TResult Function(DateTime date, Track track)? track, + required TResult orElse(), + }) { + if (track != null) { + return track(date, this.track); + } + return orElse(); + } + + @override + @optionalTypeArgs + TResult map({ + required TResult Function(PlaybackHistoryPlaylist value) playlist, + required TResult Function(PlaybackHistoryAlbum value) album, + required TResult Function(PlaybackHistoryTrack value) track, + }) { + return track(this); + } + + @override + @optionalTypeArgs + TResult? mapOrNull({ + TResult? Function(PlaybackHistoryPlaylist value)? playlist, + TResult? Function(PlaybackHistoryAlbum value)? album, + TResult? Function(PlaybackHistoryTrack value)? track, + }) { + return track?.call(this); + } + + @override + @optionalTypeArgs + TResult maybeMap({ + TResult Function(PlaybackHistoryPlaylist value)? playlist, + TResult Function(PlaybackHistoryAlbum value)? album, + TResult Function(PlaybackHistoryTrack value)? track, + required TResult orElse(), + }) { + if (track != null) { + return track(this); + } + return orElse(); + } + + @override + Map toJson() { + return _$$PlaybackHistoryTrackImplToJson( + this, + ); + } +} + +abstract class PlaybackHistoryTrack implements PlaybackHistoryItem { + factory PlaybackHistoryTrack( + {required final DateTime date, + required final Track track}) = _$PlaybackHistoryTrackImpl; + + factory PlaybackHistoryTrack.fromJson(Map json) = + _$PlaybackHistoryTrackImpl.fromJson; + + @override + DateTime get date; + Track get track; + @override + @JsonKey(ignore: true) + _$$PlaybackHistoryTrackImplCopyWith<_$PlaybackHistoryTrackImpl> + get copyWith => throw _privateConstructorUsedError; +} diff --git a/lib/provider/user_preferences/user_preferences_state.g.dart b/lib/utils/migrations/adapters.g.dart similarity index 61% rename from lib/provider/user_preferences/user_preferences_state.g.dart rename to lib/utils/migrations/adapters.g.dart index 8bdd12cc6..ca95a8404 100644 --- a/lib/provider/user_preferences/user_preferences_state.g.dart +++ b/lib/utils/migrations/adapters.g.dart @@ -1,13 +1,176 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'user_preferences_state.dart'; +part of 'adapters.dart'; + +// ************************************************************************** +// TypeAdapterGenerator +// ************************************************************************** + +class SkipSegmentAdapter extends TypeAdapter { + @override + final int typeId = 2; + + @override + SkipSegment read(BinaryReader reader) { + final numOfFields = reader.readByte(); + final fields = { + for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), + }; + return SkipSegment( + fields[0] as int, + fields[1] as int, + ); + } + + @override + void write(BinaryWriter writer, SkipSegment obj) { + writer + ..writeByte(2) + ..writeByte(0) + ..write(obj.start) + ..writeByte(1) + ..write(obj.end); + } + + @override + int get hashCode => typeId.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is SkipSegmentAdapter && + runtimeType == other.runtimeType && + typeId == other.typeId; +} + +class SourceMatchAdapter extends TypeAdapter { + @override + final int typeId = 6; + + @override + SourceMatch read(BinaryReader reader) { + final numOfFields = reader.readByte(); + final fields = { + for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), + }; + return SourceMatch( + id: fields[0] as String, + sourceId: fields[1] as String, + sourceType: fields[2] as SourceType, + createdAt: fields[3] as DateTime, + ); + } + + @override + void write(BinaryWriter writer, SourceMatch obj) { + writer + ..writeByte(4) + ..writeByte(0) + ..write(obj.id) + ..writeByte(1) + ..write(obj.sourceId) + ..writeByte(2) + ..write(obj.sourceType) + ..writeByte(3) + ..write(obj.createdAt); + } + + @override + int get hashCode => typeId.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is SourceMatchAdapter && + runtimeType == other.runtimeType && + typeId == other.typeId; +} + +class SourceTypeAdapter extends TypeAdapter { + @override + final int typeId = 5; + + @override + SourceType read(BinaryReader reader) { + switch (reader.readByte()) { + case 0: + return SourceType.youtube; + case 1: + return SourceType.youtubeMusic; + case 2: + return SourceType.jiosaavn; + default: + return SourceType.youtube; + } + } + + @override + void write(BinaryWriter writer, SourceType obj) { + switch (obj) { + case SourceType.youtube: + writer.writeByte(0); + break; + case SourceType.youtubeMusic: + writer.writeByte(1); + break; + case SourceType.jiosaavn: + writer.writeByte(2); + break; + } + } + + @override + int get hashCode => typeId.hashCode; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is SourceTypeAdapter && + runtimeType == other.runtimeType && + typeId == other.typeId; +} // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -_$UserPreferencesImpl _$$UserPreferencesImplFromJson( - Map json) => +SourceMatch _$SourceMatchFromJson(Map json) => SourceMatch( + id: json['id'] as String, + sourceId: json['sourceId'] as String, + sourceType: $enumDecode(_$SourceTypeEnumMap, json['sourceType']), + createdAt: DateTime.parse(json['createdAt'] as String), + ); + +Map _$SourceMatchToJson(SourceMatch instance) => + { + 'id': instance.id, + 'sourceId': instance.sourceId, + 'sourceType': _$SourceTypeEnumMap[instance.sourceType]!, + 'createdAt': instance.createdAt.toIso8601String(), + }; + +const _$SourceTypeEnumMap = { + SourceType.youtube: 'youtube', + SourceType.youtubeMusic: 'youtubeMusic', + SourceType.jiosaavn: 'jiosaavn', +}; + +AuthenticationCredentials _$AuthenticationCredentialsFromJson(Map json) => + AuthenticationCredentials( + cookie: json['cookie'] as String, + accessToken: json['accessToken'] as String, + expiration: DateTime.parse(json['expiration'] as String), + ); + +Map _$AuthenticationCredentialsToJson( + AuthenticationCredentials instance) => + { + 'cookie': instance.cookie, + 'accessToken': instance.accessToken, + 'expiration': instance.expiration.toIso8601String(), + }; + +_$UserPreferencesImpl _$$UserPreferencesImplFromJson(Map json) => _$UserPreferencesImpl( audioQuality: $enumDecodeNullable(_$SourceQualitiesEnumMap, json['audioQuality']) ?? @@ -16,12 +179,12 @@ _$UserPreferencesImpl _$$UserPreferencesImplFromJson( amoledDarkTheme: json['amoledDarkTheme'] as bool? ?? false, checkUpdate: json['checkUpdate'] as bool? ?? true, normalizeAudio: json['normalizeAudio'] as bool? ?? false, - showSystemTrayIcon: json['showSystemTrayIcon'] as bool? ?? true, + showSystemTrayIcon: json['showSystemTrayIcon'] as bool? ?? false, skipNonMusic: json['skipNonMusic'] as bool? ?? false, systemTitleBar: json['systemTitleBar'] as bool? ?? false, closeBehavior: $enumDecodeNullable(_$CloseBehaviorEnumMap, json['closeBehavior']) ?? - CloseBehavior.minimizeToTray, + CloseBehavior.close, accentColorScheme: UserPreferences._accentColorSchemeReadValue( json, 'accentColorScheme') == null @@ -44,6 +207,10 @@ _$UserPreferencesImpl _$$UserPreferencesImplFromJson( $enumDecodeNullable(_$SearchModeEnumMap, json['searchMode']) ?? SearchMode.youtube, downloadLocation: json['downloadLocation'] as String? ?? "", + localLibraryLocation: (json['localLibraryLocation'] as List?) + ?.map((e) => e as String) + .toList() ?? + const [], pipedInstance: json['pipedInstance'] as String? ?? "https://pipedapi.kavin.rocks", themeMode: $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']) ?? @@ -81,6 +248,7 @@ Map _$$UserPreferencesImplToJson( 'recommendationMarket': _$MarketEnumMap[instance.recommendationMarket]!, 'searchMode': _$SearchModeEnumMap[instance.searchMode]!, 'downloadLocation': instance.downloadLocation, + 'localLibraryLocation': instance.localLibraryLocation, 'pipedInstance': instance.pipedInstance, 'themeMode': _$ThemeModeEnumMap[instance.themeMode]!, 'audioSource': _$AudioSourceEnumMap[instance.audioSource]!, @@ -382,3 +550,51 @@ const _$SourceCodecsEnumMap = { SourceCodecs.m4a: 'm4a', SourceCodecs.weba: 'weba', }; + +_$PlaybackHistoryPlaylistImpl _$$PlaybackHistoryPlaylistImplFromJson( + Map json) => + _$PlaybackHistoryPlaylistImpl( + date: DateTime.parse(json['date'] as String), + playlist: PlaylistSimple.fromJson( + Map.from(json['playlist'] as Map)), + $type: json['runtimeType'] as String?, + ); + +Map _$$PlaybackHistoryPlaylistImplToJson( + _$PlaybackHistoryPlaylistImpl instance) => + { + 'date': instance.date.toIso8601String(), + 'playlist': instance.playlist.toJson(), + 'runtimeType': instance.$type, + }; + +_$PlaybackHistoryAlbumImpl _$$PlaybackHistoryAlbumImplFromJson(Map json) => + _$PlaybackHistoryAlbumImpl( + date: DateTime.parse(json['date'] as String), + album: + AlbumSimple.fromJson(Map.from(json['album'] as Map)), + $type: json['runtimeType'] as String?, + ); + +Map _$$PlaybackHistoryAlbumImplToJson( + _$PlaybackHistoryAlbumImpl instance) => + { + 'date': instance.date.toIso8601String(), + 'album': instance.album.toJson(), + 'runtimeType': instance.$type, + }; + +_$PlaybackHistoryTrackImpl _$$PlaybackHistoryTrackImplFromJson(Map json) => + _$PlaybackHistoryTrackImpl( + date: DateTime.parse(json['date'] as String), + track: Track.fromJson(Map.from(json['track'] as Map)), + $type: json['runtimeType'] as String?, + ); + +Map _$$PlaybackHistoryTrackImplToJson( + _$PlaybackHistoryTrackImpl instance) => + { + 'date': instance.date.toIso8601String(), + 'track': instance.track.toJson(), + 'runtimeType': instance.$type, + }; diff --git a/lib/utils/persisted_state_notifier.dart b/lib/utils/migrations/cache_box.dart similarity index 52% rename from lib/utils/persisted_state_notifier.dart rename to lib/utils/migrations/cache_box.dart index 9416a340b..dfe1947bd 100644 --- a/lib/utils/persisted_state_notifier.dart +++ b/lib/utils/migrations/cache_box.dart @@ -1,61 +1,31 @@ -import 'dart:async'; import 'dart:convert'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:hive/hive.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'package:spotube/components/shared/dialogs/prompt_dialog.dart'; -import 'package:spotube/extensions/context.dart'; +import 'package:spotube/provider/spotify/utils/json_cast.dart'; +import 'package:spotube/services/kv_store/encrypted_kv_store.dart'; import 'package:spotube/utils/platform.dart'; import 'package:spotube/utils/primitive_utils.dart'; -const secureStorage = FlutterSecureStorage( - aOptions: AndroidOptions( - encryptedSharedPreferences: true, - ), -); - const kKeyBoxName = "spotube_box_name"; const kNoEncryptionWarningShownKey = "showedNoEncryptionWarning"; const kIsUsingEncryption = "isUsingEncryption"; String getBoxKey(String boxName) => "spotube_box_$boxName"; -abstract class PersistedStateNotifier extends StateNotifier { +class PersistenceCacheBox { + static late LazyBox _box; + static late LazyBox _encryptedBox; + final String cacheKey; final bool encrypted; - FutureOr onInit() {} + final T Function(Map) fromJson; - PersistedStateNotifier( - super.state, + PersistenceCacheBox( this.cacheKey, { + required this.fromJson, this.encrypted = false, - }) { - _load().then((_) => onInit()); - } - - static late LazyBox _box; - static late LazyBox _encryptedBox; - - static Future showNoEncryptionDialog(BuildContext context) async { - final localStorage = await SharedPreferences.getInstance(); - final wasShownAlready = - localStorage.getBool(kNoEncryptionWarningShownKey) == true; - - if (wasShownAlready || !context.mounted) { - return; - } - - await showPromptDialog( - context: context, - title: context.l10n.failed_to_encrypt, - message: context.l10n.encryption_failed_warning, - cancelText: null, - ); - await localStorage.setBool(kNoEncryptionWarningShownKey, true); - } + }); static Future read(String key) async { final localStorage = await SharedPreferences.getInstance(); @@ -65,7 +35,7 @@ abstract class PersistedStateNotifier extends StateNotifier { try { await localStorage.setBool(kIsUsingEncryption, true); - return await secureStorage.read(key: key); + return await EncryptedKvStoreService.storage.read(key: key); } catch (e) { await localStorage.setBool(kIsUsingEncryption, false); return localStorage.getString(key); @@ -81,7 +51,7 @@ abstract class PersistedStateNotifier extends StateNotifier { try { await localStorage.setBool(kIsUsingEncryption, true); - await secureStorage.write(key: key, value: value); + await EncryptedKvStoreService.storage.write(key: key, value: value); } catch (e) { await localStorage.setBool(kIsUsingEncryption, false); await localStorage.setString(key, value); @@ -116,49 +86,15 @@ abstract class PersistedStateNotifier extends StateNotifier { LazyBox get box => encrypted ? _encryptedBox : _box; - Future _load() async { + Future getData() async { final json = await box.get(cacheKey); if (json != null || (json is Map && json.entries.isNotEmpty) || (json is List && json.isNotEmpty)) { - state = await fromJson(castNestedJson(json)); + return fromJson(castNestedJson(json)); } - } - - static Map castNestedJson(Map map) { - return Map.castFrom( - map.map((key, value) { - if (value is Map) { - return MapEntry( - key, - castNestedJson(value), - ); - } else if (value is Iterable) { - return MapEntry( - key, - value.map((e) { - if (e is Map) return castNestedJson(e); - return e; - }).toList(), - ); - } - return MapEntry(key, value); - }), - ); - } - - void save() async { - await box.put(cacheKey, toJson()); - } - - FutureOr fromJson(Map json); - Map toJson(); - @override - set state(T value) { - if (state == value) return; - super.state = value; - save(); + return null; } } diff --git a/lib/utils/migrations/hive.dart b/lib/utils/migrations/hive.dart new file mode 100644 index 000000000..e57819314 --- /dev/null +++ b/lib/utils/migrations/hive.dart @@ -0,0 +1,319 @@ +import 'package:drift/drift.dart'; +import 'package:flutter/foundation.dart'; +import 'package:hive/hive.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:spotube/models/database/database.dart' + hide + SourceType, + AudioSource, + CloseBehavior, + MusicCodec, + LayoutMode, + SearchMode, + BlacklistedType; +import 'package:spotube/models/database/database.dart' as db; +import 'package:spotube/services/kv_store/kv_store.dart'; +import 'package:spotube/services/logger/logger.dart'; +import 'package:spotube/utils/migrations/adapters.dart'; +import 'package:spotube/utils/migrations/cache_box.dart'; + +late AppDatabase _database; + +Future getHiveCacheDir() async => + kIsWeb ? null : (await getApplicationSupportDirectory()).path; + +Future migrateAuthenticationInfo() async { + AppLogger.log.i("🔵 Migrating authentication info.."); + + final box = PersistenceCacheBox( + "authentication", + encrypted: true, + fromJson: (json) => AuthenticationCredentials.fromJson(json), + ); + + final credentials = await box.getData(); + + if (credentials == null) return; + + await _database.into(_database.authenticationTable).insert( + AuthenticationTableCompanion.insert( + accessToken: DecryptedText(credentials.accessToken), + cookie: DecryptedText(credentials.cookie), + expiration: credentials.expiration, + id: const Value(0), + ), + mode: InsertMode.insertOrReplace, + ); + + AppLogger.log.i("✅ Migrated authentication info"); +} + +Future migratePreferences() async { + AppLogger.log.i("🔵 Migrating preferences.."); + final box = PersistenceCacheBox( + "preferences", + fromJson: (json) => UserPreferences.fromJson(json), + ); + + final preferences = await box.getData(); + + if (preferences == null) return; + + await _database.into(_database.preferencesTable).insert( + PreferencesTableCompanion.insert( + id: const Value(0), + accentColorScheme: Value(preferences.accentColorScheme), + albumColorSync: Value(preferences.albumColorSync), + amoledDarkTheme: Value(preferences.amoledDarkTheme), + audioQuality: Value(preferences.audioQuality), + audioSource: Value( + switch (preferences.audioSource) { + AudioSource.youtube => db.AudioSource.youtube, + AudioSource.piped => db.AudioSource.piped, + AudioSource.jiosaavn => db.AudioSource.jiosaavn, + }, + ), + checkUpdate: Value(preferences.checkUpdate), + closeBehavior: Value( + switch (preferences.closeBehavior) { + CloseBehavior.minimizeToTray => db.CloseBehavior.minimizeToTray, + CloseBehavior.close => db.CloseBehavior.close, + }, + ), + discordPresence: Value(preferences.discordPresence), + downloadLocation: Value(preferences.downloadLocation), + downloadMusicCodec: Value(preferences.downloadMusicCodec), + enableConnect: Value(preferences.enableConnect), + endlessPlayback: Value(preferences.endlessPlayback), + layoutMode: Value( + switch (preferences.layoutMode) { + LayoutMode.adaptive => db.LayoutMode.adaptive, + LayoutMode.compact => db.LayoutMode.compact, + LayoutMode.extended => db.LayoutMode.extended, + }, + ), + localLibraryLocation: Value(preferences.localLibraryLocation), + locale: Value(preferences.locale), + market: Value(preferences.recommendationMarket), + normalizeAudio: Value(preferences.normalizeAudio), + pipedInstance: Value(preferences.pipedInstance), + searchMode: Value( + switch (preferences.searchMode) { + SearchMode.youtube => db.SearchMode.youtube, + SearchMode.youtubeMusic => db.SearchMode.youtubeMusic, + }, + ), + showSystemTrayIcon: Value(preferences.showSystemTrayIcon), + skipNonMusic: Value(preferences.skipNonMusic), + streamMusicCodec: Value(preferences.streamMusicCodec), + systemTitleBar: Value(preferences.systemTitleBar), + themeMode: Value(preferences.themeMode), + ), + mode: InsertMode.replace, + ); + + AppLogger.log.i("✅ Migrated preferences"); +} + +Future migrateSkipSegment() async { + AppLogger.log.i("🔵 Migrating skip segments.."); + Hive.registerAdapter(SkipSegmentAdapter()); + + final box = await Hive.openLazyBox( + SkipSegment.boxName, + path: await getHiveCacheDir(), + ); + + final skipSegments = await Future.wait( + box.keys.map( + (key) async => ( + id: key as String, + data: await box.get(key), + ), + ), + ); + + await _database.batch((batch) { + batch.insertAll( + _database.skipSegmentTable, + skipSegments + .where((element) => element.data != null) + .expand((element) => (element.data as List).map( + (segment) => SkipSegmentTableCompanion.insert( + trackId: element.id, + start: segment["start"], + end: segment["end"], + ), + )) + .toList(), + ); + }); + + AppLogger.log.i("✅ Migrated skip segments"); +} + +Future migrateSourceMatches() async { + AppLogger.log.i("🔵 Migrating source matches.."); + + Hive.registerAdapter(SourceMatchAdapter()); + Hive.registerAdapter(SourceTypeAdapter()); + + final box = await Hive.openBox( + SourceMatch.boxName, + path: await getHiveCacheDir(), + ); + + final sourceMatches = + box.keys.map((key) => (data: box.get(key), trackId: key)); + + await _database.batch((batch) { + batch.insertAll( + _database.sourceMatchTable, + sourceMatches + .where((element) => element.data != null) + .map( + (sourceMatch) => SourceMatchTableCompanion.insert( + sourceId: sourceMatch.data!.sourceId, + trackId: sourceMatch.trackId, + sourceType: Value( + switch (sourceMatch.data!.sourceType) { + SourceType.jiosaavn => db.SourceType.jiosaavn, + SourceType.youtube => db.SourceType.youtube, + SourceType.youtubeMusic => db.SourceType.youtubeMusic, + }, + ), + ), + ) + .toList(), + ); + }); + + AppLogger.log.i("✅ Migrated source matches"); +} + +Future migrateBlacklist() async { + AppLogger.log.i("🔵 Migrating blacklist.."); + + final box = PersistenceCacheBox>( + "blacklist", + fromJson: (json) => (json["blacklist"] as List) + .map((e) => BlacklistedElement.fromJson(e)) + .toSet(), + ); + + final data = await box.getData(); + + if (data == null) return; + + await _database.batch((batch) { + batch.insertAll( + _database.blacklistTable, + data.map( + (element) => BlacklistTableCompanion.insert( + name: element.name, + elementId: element.id, + elementType: switch (element.type) { + BlacklistedType.artist => db.BlacklistedType.artist, + BlacklistedType.track => db.BlacklistedType.track, + }, + ), + ), + ); + }); + + AppLogger.log.i("✅ Migrated blacklist"); +} + +Future migrateLastFmCredentials() async { + AppLogger.log.i("🔵 Migrating Last.fm credentials.."); + + final box = PersistenceCacheBox( + "scrobbler", + fromJson: (json) => ScrobblerState.fromJson(json), + encrypted: true, + ); + + final data = await box.getData(); + + if (data == null) return; + + await _database.into(_database.scrobblerTable).insert( + ScrobblerTableCompanion.insert( + id: const Value(0), + passwordHash: DecryptedText(data.passwordHash), + username: data.username, + ), + mode: InsertMode.replace, + ); + + AppLogger.log.i("✅ Migrated Last.fm credentials"); +} + +Future migratePlaybackHistory() async { + AppLogger.log.i("🔵 Migrating playback history.."); + + final box = PersistenceCacheBox( + "playback_history", + fromJson: (json) => PlaybackHistoryState.fromJson(json), + ); + + final data = await box.getData(); + + if (data == null) return; + + await _database.batch((batch) { + batch.insertAll( + _database.historyTable, + data.items.map( + (item) => switch (item) { + PlaybackHistoryAlbum() => HistoryTableCompanion.insert( + createdAt: Value(item.date), + itemId: item.album.id!, + data: item.album.toJson(), + type: db.HistoryEntryType.album, + ), + PlaybackHistoryPlaylist() => HistoryTableCompanion.insert( + createdAt: Value(item.date), + itemId: item.playlist.id!, + data: item.playlist.toJson(), + type: db.HistoryEntryType.playlist, + ), + PlaybackHistoryTrack() => HistoryTableCompanion.insert( + createdAt: Value(item.date), + itemId: item.track.id!, + data: item.track.toJson(), + type: db.HistoryEntryType.track, + ), + _ => throw Exception("Unknown history item type"), + }, + ), + ); + }); + + AppLogger.log.i("✅ Migrated playback history"); +} + +Future migrateFromHiveToDrift(AppDatabase database) async { + if (KVStoreService.hasMigratedToDrift) return; + + await PersistenceCacheBox.initializeBoxes( + path: await getHiveCacheDir(), + ); + + _database = database; + + await migrateAuthenticationInfo(); + await migratePreferences(); + + await migrateSkipSegment(); + await migrateSourceMatches(); + + await migrateBlacklist(); + await migratePlaybackHistory(); + + await migrateLastFmCredentials(); + + await KVStoreService.setHasMigratedToDrift(true); + + AppLogger.log.i("🚀 Migrated all data to Drift"); +} diff --git a/lib/utils/migrations/sandbox.dart b/lib/utils/migrations/sandbox.dart new file mode 100644 index 000000000..1ed5090ac --- /dev/null +++ b/lib/utils/migrations/sandbox.dart @@ -0,0 +1,58 @@ +import 'dart:io'; + +import 'package:path/path.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:spotube/services/logger/logger.dart'; +import 'package:spotube/utils/platform.dart'; + +/// Migrates sandbox files on macOS to non-sandbox directories +Future migrateMacOsFromSandboxToNoSandbox() async { + if (!kIsMacOS) return; + + try { + final sandboxApplicationSupportDir = Directory( + "/Users/${Platform.environment["USER"]}/Library/Containers/oss.krtirtho.spotube/Data/Library/Application Support/oss.krtirtho.spotube", + ); + + if (!await sandboxApplicationSupportDir.exists()) { + stdout.writeln("🔵 Sandbox directory not found, skipping migration"); + return; + } + + const fileExts = [".db", ".lock", ".hive"]; + + final supportDir = await getApplicationSupportDirectory() + ..create(recursive: true); + + final supportFiles = await supportDir.list().toList(); + final oldSupportFiles = await sandboxApplicationSupportDir.list().toList(); + + if (oldSupportFiles.isEmpty) { + stdout.writeln( + "🔵 No files found in sandboxed directory, skipping migration", + ); + return; + } else if (supportFiles.any( + (file) => file is File && fileExts.contains(extension(file.path)))) { + stdout.writeln( + "🔵 Non-sandbox directory is not empty, skipping migration", + ); + return; + } + + for (final oldSupportFile in oldSupportFiles) { + if (oldSupportFile is File && + fileExts.contains(extension(oldSupportFile.path))) { + final newPath = join(supportDir.path, basename(oldSupportFile.path)); + await oldSupportFile.copy(newPath); + } + } + + stdout.writeln("✅ Migrated sandboxed files to non-sandboxed directory"); + } catch (e, stack) { + stdout.writeln( + "❌ Error migrating sandboxed files to non-sandboxed directory", + ); + AppLogger.reportError(e, stack); + } +} diff --git a/lib/utils/persisted_change_notifier.dart b/lib/utils/persisted_change_notifier.dart deleted file mode 100644 index d48cb67a3..000000000 --- a/lib/utils/persisted_change_notifier.dart +++ /dev/null @@ -1,55 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/widgets.dart'; -import 'package:shared_preferences/shared_preferences.dart'; - -abstract class PersistedChangeNotifier extends ChangeNotifier { - late SharedPreferences _localStorage; - PersistedChangeNotifier() { - SharedPreferences.getInstance().then((value) => _localStorage = value).then( - (_) async { - final persistedMap = (await toMap()) - .entries - .toList() - .fold>({}, (acc, entry) { - if (entry.value != null) { - if (entry.value is bool) { - acc[entry.key] = _localStorage.getBool(entry.key); - } else if (entry.value is int) { - acc[entry.key] = _localStorage.getInt(entry.key); - } else if (entry.value is double) { - acc[entry.key] = _localStorage.getDouble(entry.key); - } else if (entry.value is String) { - acc[entry.key] = _localStorage.getString(entry.key); - } - } else { - acc[entry.key] = _localStorage.get(entry.key); - } - return acc; - }); - await loadFromLocal(persistedMap); - notifyListeners(); - }, - ); - } - - FutureOr loadFromLocal(Map map); - - FutureOr> toMap(); - - Future updatePersistence({bool clearNullEntries = false}) async { - for (final entry in (await toMap()).entries) { - if (entry.value is bool) { - await _localStorage.setBool(entry.key, entry.value); - } else if (entry.value is int) { - await _localStorage.setInt(entry.key, entry.value); - } else if (entry.value is double) { - await _localStorage.setDouble(entry.key, entry.value); - } else if (entry.value is String) { - await _localStorage.setString(entry.key, entry.value); - } else if (entry.value == null && clearNullEntries) { - _localStorage.remove(entry.key); - } - } - } -} diff --git a/lib/utils/service_utils.dart b/lib/utils/service_utils.dart index 88c528966..c00f07ab9 100644 --- a/lib/utils/service_utils.dart +++ b/lib/utils/service_utils.dart @@ -1,22 +1,29 @@ -import 'dart:convert'; - -import 'package:flutter/widgets.dart' hide Element; +import 'package:dio/dio.dart'; import 'package:go_router/go_router.dart'; -import 'package:html/dom.dart'; +import 'package:html/dom.dart' hide Text; import 'package:spotify/spotify.dart'; -import 'package:spotube/components/library/user_local_tracks.dart'; -import 'package:spotube/models/logger.dart'; -import 'package:http/http.dart' as http; +import 'package:spotube/modules/library/user_local_tracks.dart'; +import 'package:spotube/modules/root/update_dialog.dart'; + import 'package:spotube/models/lyrics.dart'; +import 'package:spotube/provider/database/database.dart'; +import 'package:spotube/services/dio/dio.dart'; import 'package:spotube/services/sourced_track/sourced_track.dart'; import 'package:spotube/utils/primitive_utils.dart'; import 'package:collection/collection.dart'; import 'package:html/parser.dart' as parser; -abstract class ServiceUtils { - static final logger = getLogger("ServiceUtils"); +import 'dart:async'; + +import 'package:flutter/material.dart' hide Element; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:package_info_plus/package_info_plus.dart'; +import 'package:spotube/collections/env.dart'; + +import 'package:version/version.dart'; +abstract class ServiceUtils { static final _englishMatcherRegex = RegExp( "^[a-zA-Z0-9\\s!\"#\$%&\\'()*+,-.\\/:;<=>?@\\[\\]^_`{|}~]*\$", ); @@ -60,9 +67,12 @@ abstract class ServiceUtils { } static Future extractLyrics(Uri url) async { - final response = await http.get(url); + final response = await globalDio.getUri( + url, + options: Options(responseType: ResponseType.plain), + ); - Document document = parser.parse(response.body); + Document document = parser.parse(response.data); String? lyrics = document.querySelector('div.lyrics')?.text.trim(); if (lyrics == null) { lyrics = ""; @@ -101,11 +111,14 @@ abstract class ServiceUtils { String reqUrl = "$searchUrl${Uri.encodeComponent(song)}"; Map headers = {"Authorization": 'Bearer $apiKey'}; - final response = await http.get( + final response = await globalDio.getUri( Uri.parse(authHeader ? reqUrl : "$reqUrl&access_token=$apiKey"), - headers: authHeader ? headers : null, + options: Options( + headers: authHeader ? headers : null, + responseType: ResponseType.json, + ), ); - Map data = jsonDecode(response.body)["response"]; + Map data = response.data["response"]; if (data["hits"]?.length == 0) return null; List results = data["hits"]?.map((val) { return { @@ -179,14 +192,15 @@ abstract class ServiceUtils { artists: artistNames, ); - logger.v("[Searching Subtitle] $query"); - final searchUri = Uri.parse("$baseUri/subtitles4songs.aspx").replace( queryParameters: {"q": query}, ); - final res = await http.get(searchUri); - final document = parser.parse(res.body); + final res = await globalDio.getUri( + searchUri, + options: Options(responseType: ResponseType.plain), + ); + final document = parser.parse(res.data); final results = document.querySelectorAll("#tablecontainer table tbody tr td a"); @@ -209,7 +223,6 @@ abstract class ServiceUtils { // not result was found at all if (rateSortedResults.first["points"] == 0) { - logger.e("[Subtitle not found] ${track.name}"); return Future.error("Subtitle lookup failed", StackTrace.current); } @@ -217,9 +230,11 @@ abstract class ServiceUtils { final subtitleUri = Uri.parse("$baseUri/${topResult.attributes["href"]}&type=lrc"); - logger.v("[Selected subtitle] ${topResult.text} | $subtitleUri"); - - final lrcDocument = parser.parse((await http.get(subtitleUri)).body); + final lrcDocument = parser.parse((await globalDio.getUri( + subtitleUri, + options: Options(responseType: ResponseType.plain), + )) + .data); final lrcList = lrcDocument .querySelector("#ctl00_ContentPlaceHolder1_lbllyrics") ?.innerHtml @@ -262,6 +277,22 @@ abstract class ServiceUtils { GoRouter.of(context).go(location, extra: extra); } + static void navigateNamed( + BuildContext context, + String name, { + Object? extra, + Map? pathParameters, + Map? queryParameters, + }) { + if (GoRouterState.of(context).matchedLocation == name) return; + GoRouter.of(context).goNamed( + name, + pathParameters: pathParameters ?? const {}, + queryParameters: queryParameters ?? const {}, + extra: extra, + ); + } + static void push(BuildContext context, String location, {Object? extra}) { final router = GoRouter.of(context); final routerState = GoRouterState.of(context); @@ -273,6 +304,36 @@ abstract class ServiceUtils { router.push(location, extra: extra); } + static void pushNamed( + BuildContext context, + String name, { + Object? extra, + Map pathParameters = const {}, + Map queryParameters = const {}, + }) { + final router = GoRouter.of(context); + final routerState = GoRouterState.of(context); + final routerStack = router.routerDelegate.currentConfiguration.matches + .map((e) => e.matchedLocation); + + final nameLocation = routerState.namedLocation( + name, + pathParameters: pathParameters, + queryParameters: queryParameters, + ); + + if (routerState.matchedLocation == nameLocation || + routerStack.contains(nameLocation)) { + return; + } + router.pushNamed( + name, + pathParameters: pathParameters, + queryParameters: queryParameters, + extra: extra, + ); + } + static DateTime parseSpotifyAlbumDate(AlbumSimple? album) { if (album == null || album.releaseDate == null) { return DateTime.parse("1975-01-01"); @@ -318,4 +379,74 @@ abstract class ServiceUtils { } }); } + + static Future checkForUpdates( + BuildContext context, + WidgetRef ref, + ) async { + if (!Env.enableUpdateChecker) return; + final database = ref.read(databaseProvider); + final checkUpdate = await (database.selectOnly(database.preferencesTable) + ..addColumns([database.preferencesTable.checkUpdate]) + ..where(database.preferencesTable.id.equals(0))) + .map((row) => row.read(database.preferencesTable.checkUpdate)) + .getSingleOrNull(); + + if (checkUpdate == false) return; + final packageInfo = await PackageInfo.fromPlatform(); + + if (Env.releaseChannel == ReleaseChannel.nightly) { + final value = await globalDio.getUri( + Uri.parse( + "https://api.github.com/repos/KRTirtho/spotube/actions/workflows/spotube-release-binary.yml/runs?status=success&per_page=1", + ), + options: Options( + responseType: ResponseType.json, + ), + ); + + final buildNum = value.data["workflow_runs"][0]["run_number"] as int; + + if (buildNum <= int.parse(packageInfo.buildNumber) || !context.mounted) { + return; + } + + await showDialog( + context: context, + barrierDismissible: true, + barrierColor: Colors.black26, + builder: (context) { + return RootAppUpdateDialog.nightly(nightlyBuildNum: buildNum); + }, + ); + } else { + final value = await globalDio.getUri( + Uri.parse( + "https://api.github.com/repos/KRTirtho/spotube/releases/latest", + ), + ); + final tagName = (value.data["tag_name"] as String).replaceAll("v", ""); + final currentVersion = packageInfo.version == "Unknown" + ? null + : Version.parse(packageInfo.version); + final latestVersion = + tagName == "nightly" ? null : Version.parse(tagName); + + if (currentVersion == null || + latestVersion == null || + (latestVersion.isPreRelease && !currentVersion.isPreRelease) || + (!latestVersion.isPreRelease && currentVersion.isPreRelease)) return; + + if (latestVersion <= currentVersion || !context.mounted) return; + + showDialog( + context: context, + barrierDismissible: true, + barrierColor: Colors.black26, + builder: (context) { + return RootAppUpdateDialog(version: latestVersion); + }, + ); + } + } } diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index c69c17c01..0f93d754d 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -6,23 +6,23 @@ #include "generated_plugin_registrant.h" -#include +#include #include #include #include #include #include #include +#include #include -#include +#include #include #include -#include void fl_register_plugins(FlPluginRegistry* registry) { - g_autoptr(FlPluginRegistrar) dart_discord_rpc_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "DartDiscordRpcPlugin"); - dart_discord_rpc_plugin_register_with_registrar(dart_discord_rpc_registrar); + g_autoptr(FlPluginRegistrar) desktop_webview_window_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopWebviewWindowPlugin"); + desktop_webview_window_plugin_register_with_registrar(desktop_webview_window_registrar); g_autoptr(FlPluginRegistrar) file_selector_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin"); file_selector_plugin_register_with_registrar(file_selector_linux_registrar); @@ -41,19 +41,19 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) screen_retriever_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); + g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin"); + sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar); g_autoptr(FlPluginRegistrar) system_theme_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "SystemThemePlugin"); system_theme_plugin_register_with_registrar(system_theme_registrar); - g_autoptr(FlPluginRegistrar) system_tray_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "SystemTrayPlugin"); - system_tray_plugin_register_with_registrar(system_tray_registrar); + g_autoptr(FlPluginRegistrar) tray_manager_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin"); + tray_manager_plugin_register_with_registrar(tray_manager_registrar); g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); g_autoptr(FlPluginRegistrar) window_manager_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); window_manager_plugin_register_with_registrar(window_manager_registrar); - g_autoptr(FlPluginRegistrar) window_size_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "WindowSizePlugin"); - window_size_plugin_register_with_registrar(window_size_registrar); } diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index a4487f4d0..ff6426968 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -3,21 +3,22 @@ # list(APPEND FLUTTER_PLUGIN_LIST - dart_discord_rpc + desktop_webview_window file_selector_linux flutter_secure_storage_linux gtk local_notifier media_kit_libs_linux screen_retriever + sqlite3_flutter_libs system_theme - system_tray + tray_manager url_launcher_linux window_manager - window_size ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + flutter_discord_rpc media_kit_native_event_loop metadata_god ) diff --git a/linux/my_application.cc b/linux/my_application.cc index d1ac5d124..0aa4d905b 100644 --- a/linux/my_application.cc +++ b/linux/my_application.cc @@ -23,7 +23,7 @@ static void my_application_activate(GApplication* application) { gtk_window_present(GTK_WINDOW(windows->data)); return; } - + GtkWindow* window = GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); @@ -55,10 +55,11 @@ static void my_application_activate(GApplication* application) { } gtk_window_set_default_size(window, 1280, 720); - gtk_widget_realize(GTK_WIDGET(window)); + gtk_widget_show(GTK_WIDGET(window)); g_autoptr(FlDartProject) project = fl_dart_project_new(); - fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + fl_dart_project_set_dart_entrypoint_arguments( + project, self->dart_entrypoint_arguments); FlView* view = fl_view_new(project); gtk_widget_show(GTK_WIDGET(view)); @@ -70,16 +71,18 @@ static void my_application_activate(GApplication* application) { } // Implements GApplication::local_command_line. -static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { +static gboolean my_application_local_command_line(GApplication* application, + gchar*** arguments, + int* exit_status) { MyApplication* self = MY_APPLICATION(application); // Strip out the first argument as it is the binary name. self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); g_autoptr(GError) error = nullptr; if (!g_application_register(application, nullptr, &error)) { - g_warning("Failed to register: %s", error->message); - *exit_status = 1; - return TRUE; + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; } g_application_activate(application); @@ -97,15 +100,31 @@ static void my_application_dispose(GObject* object) { static void my_application_class_init(MyApplicationClass* klass) { G_APPLICATION_CLASS(klass)->activate = my_application_activate; - G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_APPLICATION_CLASS(klass)->local_command_line = + my_application_local_command_line; G_OBJECT_CLASS(klass)->dispose = my_application_dispose; } static void my_application_init(MyApplication* self) {} -MyApplication* my_application_new() { - return MY_APPLICATION(g_object_new(my_application_get_type(), - "com.github.KRTirtho.Spotube", APPLICATION_ID, - "flags", G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_HANDLES_OPEN, - nullptr)); +bool is_flatpak(void) { + if (getenv("container") || getenv("FLATPAK_ID") || getenv("FLATPAK")) { + /* flatpak */ + return true; + } + return false; /* No container detected */ } + +MyApplication* my_application_new() { + // gchar based alternate MY_APPLICATION_ID + const char* my_application_id = APPLICATION_ID; + + if (is_flatpak()) { + my_application_id = "com.github.KRTirtho.Spotube"; + } + + return MY_APPLICATION(g_object_new( + my_application_get_type(), "application-id", my_application_id, "flags", + G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_HANDLES_OPEN, + nullptr)); +} \ No newline at end of file diff --git a/linux/packaging/deb/make_config.yaml b/linux/packaging/deb/make_config.yaml index 95777f567..a7bea1aa4 100644 --- a/linux/packaging/deb/make_config.yaml +++ b/linux/packaging/deb/make_config.yaml @@ -23,6 +23,8 @@ dependencies: - avahi-utils - libnss-mdns - mdns-scan + - libwebkit2gtk-4.1-0 | libwebkit2gtk-4.0-0 + - libsoup-3.0-0 | libsoup-2.4-0 essential: false icon: assets/spotube-logo.png diff --git a/linux/packaging/rpm/make_config.yaml b/linux/packaging/rpm/make_config.yaml index 12b4473e5..3d4a3b7ed 100644 --- a/linux/packaging/rpm/make_config.yaml +++ b/linux/packaging/rpm/make_config.yaml @@ -16,6 +16,8 @@ requires: - avahi - mdns-scan - nss-mdns + - webkit2gtk4.1 + - libsoup3 display_name: Spotube diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index a9f6650ff..ea94bf6dd 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -9,6 +9,7 @@ import app_links import audio_service import audio_session import bonsoir_darwin +import desktop_webview_window import device_info_plus import file_selector_macos import flutter_inappwebview_macos @@ -20,31 +21,32 @@ import path_provider_foundation import screen_retriever import shared_preferences_foundation import sqflite +import sqlite3_flutter_libs import system_theme -import system_tray +import tray_manager import url_launcher_macos import window_manager -import window_size func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin")) AudioServicePlugin.register(with: registry.registrar(forPlugin: "AudioServicePlugin")) AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin")) SwiftBonsoirPlugin.register(with: registry.registrar(forPlugin: "SwiftBonsoirPlugin")) + DesktopWebviewWindowPlugin.register(with: registry.registrar(forPlugin: "DesktopWebviewWindowPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin")) FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) LocalNotifierPlugin.register(with: registry.registrar(forPlugin: "LocalNotifierPlugin")) MediaKitLibsMacosAudioPlugin.register(with: registry.registrar(forPlugin: "MediaKitLibsMacosAudioPlugin")) - FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) + FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) + Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin")) SystemThemePlugin.register(with: registry.registrar(forPlugin: "SystemThemePlugin")) - SystemTrayPlugin.register(with: registry.registrar(forPlugin: "SystemTrayPlugin")) + TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) - WindowSizePlugin.register(with: registry.registrar(forPlugin: "WindowSizePlugin")) } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 317de385f..b3092d8cd 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -8,26 +8,28 @@ PODS: - bonsoir_darwin (0.0.1): - Flutter - FlutterMacOS + - desktop_webview_window (0.0.1): + - FlutterMacOS - device_info_plus (0.0.1): - FlutterMacOS - file_selector_macos (0.0.1): - FlutterMacOS + - flutter_discord_rpc (0.0.1): + - FlutterMacOS - flutter_inappwebview_macos (0.0.1): - FlutterMacOS - OrderedSet (~> 5.0) - flutter_secure_storage_macos (6.1.1): - FlutterMacOS - FlutterMacOS (1.0.0) - - FMDB (2.7.5): - - FMDB/standard (= 2.7.5) - - FMDB/standard (2.7.5) - local_notifier (0.1.0): - FlutterMacOS - media_kit_libs_macos_audio (1.0.4): - FlutterMacOS - media_kit_native_event_loop (1.0.0): - FlutterMacOS - - metadata_god (0.0.1) + - metadata_god (0.0.1): + - FlutterMacOS - OrderedSet (5.0.0) - package_info_plus (0.0.1): - FlutterMacOS @@ -39,27 +41,42 @@ PODS: - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS - - sqflite (0.0.2): + - sqflite (0.0.3): + - Flutter - FlutterMacOS - - FMDB (>= 2.7.5) + - "sqlite3 (3.46.0+1)": + - "sqlite3/common (= 3.46.0+1)" + - "sqlite3/common (3.46.0+1)" + - "sqlite3/fts5 (3.46.0+1)": + - sqlite3/common + - "sqlite3/perf-threadsafe (3.46.0+1)": + - sqlite3/common + - "sqlite3/rtree (3.46.0+1)": + - sqlite3/common + - sqlite3_flutter_libs (0.0.1): + - FlutterMacOS + - sqlite3 (~> 3.46.0) + - sqlite3/fts5 + - sqlite3/perf-threadsafe + - sqlite3/rtree - system_theme (0.0.1): - FlutterMacOS - - system_tray (0.0.1): + - tray_manager (0.0.1): - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS - window_manager (0.2.0): - FlutterMacOS - - window_size (0.0.2): - - FlutterMacOS DEPENDENCIES: - app_links (from `Flutter/ephemeral/.symlinks/plugins/app_links/macos`) - audio_service (from `Flutter/ephemeral/.symlinks/plugins/audio_service/macos`) - audio_session (from `Flutter/ephemeral/.symlinks/plugins/audio_session/macos`) - bonsoir_darwin (from `Flutter/ephemeral/.symlinks/plugins/bonsoir_darwin/darwin`) + - desktop_webview_window (from `Flutter/ephemeral/.symlinks/plugins/desktop_webview_window/macos`) - device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`) - file_selector_macos (from `Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos`) + - flutter_discord_rpc (from `Flutter/ephemeral/.symlinks/plugins/flutter_discord_rpc/macos`) - flutter_inappwebview_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_inappwebview_macos/macos`) - flutter_secure_storage_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos`) - FlutterMacOS (from `Flutter/ephemeral`) @@ -71,17 +88,17 @@ DEPENDENCIES: - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) - screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/macos`) + - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`) + - sqlite3_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos`) - system_theme (from `Flutter/ephemeral/.symlinks/plugins/system_theme/macos`) - - system_tray (from `Flutter/ephemeral/.symlinks/plugins/system_tray/macos`) + - tray_manager (from `Flutter/ephemeral/.symlinks/plugins/tray_manager/macos`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) - - window_size (from `Flutter/ephemeral/.symlinks/plugins/window_size/macos`) SPEC REPOS: trunk: - - FMDB - OrderedSet + - sqlite3 EXTERNAL SOURCES: app_links: @@ -92,10 +109,14 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/audio_session/macos bonsoir_darwin: :path: Flutter/ephemeral/.symlinks/plugins/bonsoir_darwin/darwin + desktop_webview_window: + :path: Flutter/ephemeral/.symlinks/plugins/desktop_webview_window/macos device_info_plus: :path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos file_selector_macos: :path: Flutter/ephemeral/.symlinks/plugins/file_selector_macos/macos + flutter_discord_rpc: + :path: Flutter/ephemeral/.symlinks/plugins/flutter_discord_rpc/macos flutter_inappwebview_macos: :path: Flutter/ephemeral/.symlinks/plugins/flutter_inappwebview_macos/macos flutter_secure_storage_macos: @@ -119,44 +140,46 @@ EXTERNAL SOURCES: shared_preferences_foundation: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin sqflite: - :path: Flutter/ephemeral/.symlinks/plugins/sqflite/macos + :path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin + sqlite3_flutter_libs: + :path: Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos system_theme: :path: Flutter/ephemeral/.symlinks/plugins/system_theme/macos - system_tray: - :path: Flutter/ephemeral/.symlinks/plugins/system_tray/macos + tray_manager: + :path: Flutter/ephemeral/.symlinks/plugins/tray_manager/macos url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos window_manager: :path: Flutter/ephemeral/.symlinks/plugins/window_manager/macos - window_size: - :path: Flutter/ephemeral/.symlinks/plugins/window_size/macos SPEC CHECKSUMS: - app_links: 4481ed4d71f384b0c3ae5016f4633aa73d32ff67 + app_links: 10e0a0ab602ffaf34d142cd4862f29d34b303b2a audio_service: b88ff778e0e3915efd4cd1a5ad6f0beef0c950a9 audio_session: dea1f41890dbf1718f04a56f1d6150fd50039b72 bonsoir_darwin: e3b8526c42ca46a885142df84229131dfabea842 - device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f + desktop_webview_window: 89bb3d691f4c80314a10be312f4cd35db93a9d5a + device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720 file_selector_macos: 468fb6b81fac7c0e88d71317f3eec34c3b008ff9 + flutter_discord_rpc: 67a7c10ea24d9d3bf35d01af643f48fbcfa7c24f flutter_inappwebview_macos: 9600c9df9fdb346aaa8933812009f8d94304203d flutter_secure_storage_macos: d56e2d218c1130b262bef8b4a7d64f88d7f9c9ea FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 - FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a local_notifier: e9506bc66fc70311e8bc7291fb70f743c081e4ff media_kit_libs_macos_audio: 3871782a4f3f84c77f04d7666c87800a781c24da media_kit_native_event_loop: 7321675377cb9ae8596a29bddf3a3d2b5e8792c5 - metadata_god: eceae399d0020475069a5cebc35943ce8562b5d7 + metadata_god: 829f61208b44ac1173e7cd32ab740d8776be5435 OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c - package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce - path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 + package_info_plus: fa739dd842b393193c5ca93c26798dff6e3d0e0c + path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38 - shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 - sqflite: a5789cceda41d54d23f31d6de539d65bb14100ea + shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 + sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec + sqlite3: 292c3e1bfe89f64e51ea7fc7dab9182a017c8630 + sqlite3_flutter_libs: 1be4459672f8168ded2d8667599b8e3ca5e72b83 system_theme: c7b9f6659a5caa26c9bc2284da096781e9a6fcbc - system_tray: e53c972838c69589ff2e77d6d3abfd71332f9e5d + tray_manager: 9064e219c56d75c476e46b9a21182087930baf90 url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 - window_size: 339dafa0b27a95a62a843042038fa6c3c48de195 PODFILE CHECKSUM: 0d3963a09fc94f580682bd88480486da345dc3f0 diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements index f05277de8..6e73fa3ca 100644 --- a/macos/Runner/DebugProfile.entitlements +++ b/macos/Runner/DebugProfile.entitlements @@ -1,18 +1,18 @@ - - com.apple.security.app-sandbox - - com.apple.security.assets.music.read-write - - com.apple.security.files.downloads.read-write - - com.apple.security.files.user-selected.read-write - - com.apple.security.network.client - - com.apple.security.network.server - - - + + com.apple.security.app-sandbox + + com.apple.security.assets.music.read-write + + com.apple.security.files.downloads.read-write + + com.apple.security.files.user-selected.read-write + + com.apple.security.network.client + + com.apple.security.network.server + + + \ No newline at end of file diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements index f05277de8..6e73fa3ca 100644 --- a/macos/Runner/Release.entitlements +++ b/macos/Runner/Release.entitlements @@ -1,18 +1,18 @@ - - com.apple.security.app-sandbox - - com.apple.security.assets.music.read-write - - com.apple.security.files.downloads.read-write - - com.apple.security.files.user-selected.read-write - - com.apple.security.network.client - - com.apple.security.network.server - - - + + com.apple.security.app-sandbox + + com.apple.security.assets.music.read-write + + com.apple.security.files.downloads.read-write + + com.apple.security.files.user-selected.read-write + + com.apple.security.network.client + + com.apple.security.network.server + + + \ No newline at end of file diff --git a/macos/Runner/RunnerDebug.entitlements b/macos/Runner/RunnerDebug.entitlements index f05277de8..6e73fa3ca 100644 --- a/macos/Runner/RunnerDebug.entitlements +++ b/macos/Runner/RunnerDebug.entitlements @@ -1,18 +1,18 @@ - - com.apple.security.app-sandbox - - com.apple.security.assets.music.read-write - - com.apple.security.files.downloads.read-write - - com.apple.security.files.user-selected.read-write - - com.apple.security.network.client - - com.apple.security.network.server - - - + + com.apple.security.app-sandbox + + com.apple.security.assets.music.read-write + + com.apple.security.files.downloads.read-write + + com.apple.security.files.user-selected.read-write + + com.apple.security.network.client + + com.apple.security.network.server + + + \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 8d19f604c..6f0f3e73f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,26 +5,26 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" url: "https://pub.dev" source: hosted - version: "61.0.0" + version: "67.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" url: "https://pub.dev" source: hosted - version: "5.13.0" + version: "6.4.1" analyzer_plugin: dependency: transitive description: name: analyzer_plugin - sha256: c1d5f167683de03d5ab6c3b53fc9aeefc5d59476e7810ba7bbddff50c6f4392d + sha256: "9661b30b13a685efaee9f02e5d01ed9f2b423bd889d28a304d02d704aee69161" url: "https://pub.dev" source: hosted - version: "0.11.2" + version: "0.11.3" ansicolor: dependency: transitive description: @@ -37,90 +37,34 @@ packages: dependency: "direct main" description: name: app_links - sha256: "4e392b5eba997df356ca6021f28431ce1cfeb16758699553a94b13add874a3bb" + sha256: "42dc15aecf2618ace4ffb74a2e58a50e45cd1b9f2c17c8f0cafe4c297f08c815" url: "https://pub.dev" source: hosted - version: "3.5.0" - app_package_maker: - dependency: transitive - description: - name: app_package_maker - sha256: "0dc1949e09a60ec2d0b79b43c5237734e6d03f7a022919bdfe1b4789f4c3bfb0" - url: "https://pub.dev" - source: hosted - version: "0.0.9" - app_package_maker_aab: - dependency: transitive - description: - name: app_package_maker_aab - sha256: "44810e77dff3b3b54011270b01a42876e838766d6e85c98f9a33bfe61db51651" - url: "https://pub.dev" - source: hosted - version: "0.0.9" - app_package_maker_apk: - dependency: transitive - description: - name: app_package_maker_apk - sha256: "974e639cda26c2e18fffaba18f88797523731f5b5457056b25e92243c9191f61" - url: "https://pub.dev" - source: hosted - version: "0.0.9" - app_package_maker_deb: - dependency: transitive - description: - name: app_package_maker_deb - sha256: dcd4047cb67648e53afd61079a8baa3c8ea383668f068e3ce8da841f3728eb29 - url: "https://pub.dev" - source: hosted - version: "0.0.9" - app_package_maker_dmg: - dependency: transitive - description: - name: app_package_maker_dmg - sha256: e0410a51304f3fff3e3850696c8e56f53f71c990e097f1c325126ebe90d242c4 - url: "https://pub.dev" - source: hosted - version: "0.0.9" - app_package_maker_exe: - dependency: transitive - description: - name: app_package_maker_exe - sha256: "07e3899a3ae12e8b6cd80efc7281ccca6c9050d2810e0fdc0e7e614cf4bd8a02" - url: "https://pub.dev" - source: hosted - version: "0.0.9" - app_package_maker_ipa: - dependency: transitive - description: - name: app_package_maker_ipa - sha256: "1a11498506ba975d02a4715650701981a382a2161c81481911517b50b378cd65" - url: "https://pub.dev" - source: hosted - version: "0.0.9" - app_package_maker_zip: - dependency: transitive - description: - name: app_package_maker_zip - sha256: cef07a47c589036a4762fdc9e61b9022f0a2a2a9f69538109a0a952a7e668306 - url: "https://pub.dev" - source: hosted - version: "0.0.9" + version: "4.0.1" archive: dependency: transitive description: name: archive - sha256: ca12e6c9ac022f33fd89128e7007fb5e97ab6e814d4fa05dd8d4f2db1e3c69cb + sha256: ecf4273855368121b1caed0d10d4513c7241dfc813f7d3c8933b36622ae9b265 url: "https://pub.dev" source: hosted - version: "3.4.5" + version: "3.5.1" args: dependency: "direct main" description: name: args - sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.5.0" + asn1lib: + dependency: transitive + description: + name: asn1lib + sha256: "58082b3f0dca697204dbab0ef9ff208bfaea7767ea771076af9a343488428dda" + url: "https://pub.dev" + source: hosted + version: "1.5.3" async: dependency: "direct main" description: @@ -133,18 +77,18 @@ packages: dependency: "direct main" description: name: audio_service - sha256: a4d989f1225ea9621898d60f23236dcbfc04876fa316086c23c5c4af075dbac4 + sha256: "4547c312a94f9cb2c48b60823fb190767cbd63454a83c73049384d5d3cba4650" url: "https://pub.dev" source: hosted - version: "0.18.12" + version: "0.18.13" audio_service_mpris: dependency: "direct main" description: name: audio_service_mpris - sha256: "31be5de2db0c71b217157afce1974ac6d0ad329bd91deb1f19ad094d29340d8e" + sha256: b16db3584a4b2464c0bfd575c1a21765723d257931222f8adfcb0511f940d352 url: "https://pub.dev" source: hosted - version: "0.1.0" + version: "0.1.5" audio_service_platform_interface: dependency: transitive description: @@ -157,18 +101,18 @@ packages: dependency: transitive description: name: audio_service_web - sha256: "523e64ddc914c714d53eec2da85bba1074f08cf26c786d4efb322de510815ea7" + sha256: "9d7d5ae5f98a5727f2580fad73062f2484f400eef6cef42919413268e62a363e" url: "https://pub.dev" source: hosted - version: "0.1.1" + version: "0.1.2" audio_session: dependency: "direct main" description: name: audio_session - sha256: "6fdf255ed3af86535c96452c33ecff1245990bb25a605bfb1958661ccc3d467f" + sha256: a49af9981eec5d7cd73b37bacb6ee73f8143a6a9f9bd5b6021e6c346b9b6cf4e url: "https://pub.dev" source: hosted - version: "0.1.18" + version: "0.1.19" auto_size_text: dependency: "direct main" description: @@ -181,50 +125,50 @@ packages: dependency: "direct main" description: name: bonsoir - sha256: "9703ca3ce201c7ab6cd278ae5a530a125959687f59c2b97822f88a8db5bef106" + sha256: b7697a954c772a6ddc68d52b3e4768947cc98613127f7720a05b14ed1e59d68b url: "https://pub.dev" source: hosted - version: "5.1.9" + version: "5.1.10" bonsoir_android: dependency: transitive description: name: bonsoir_android - sha256: "19583ae34a5e5743fa2c16619e4ec699b35ae5e6cece59b99b1cf21c1b4ed618" + sha256: a72d83a78780c1f238e3178d0585e5604fbd9f2503206293737cdfab899ce8d0 url: "https://pub.dev" source: hosted - version: "5.1.4" + version: "5.1.5" bonsoir_darwin: dependency: transitive description: name: bonsoir_darwin - sha256: "985c4c38b4cbfa57ed5870e724a7e17aa080ee7f49d03b43e6d08781511505c6" + sha256: "2d25c70f0d09260be1c2ab583b80dd89cbbfd59997579dadf789c5af00c7b2e4" url: "https://pub.dev" source: hosted - version: "5.1.2" + version: "5.1.3" bonsoir_linux: dependency: transitive description: name: bonsoir_linux - sha256: "65554b20bc169c68c311eb31fab46ccdd8ee3d3dd89a2d57c338f4cbf6ceb00d" + sha256: f2639aded6e15943a9822de98a663a1056f37cbfd0a74d72c9eaa941965945c2 url: "https://pub.dev" source: hosted - version: "5.1.2" + version: "5.1.3" bonsoir_platform_interface: dependency: transitive description: name: bonsoir_platform_interface - sha256: "4ee898bec0b5a63f04f82b06da9896ae8475f32a33b6fa395bea56399daeb9f0" + sha256: "08bb8b35d0198168b3bce87dbc718e4e510336cff1d97e43762e030c01636d45" url: "https://pub.dev" source: hosted - version: "5.1.2" + version: "5.1.3" bonsoir_windows: dependency: transitive description: name: bonsoir_windows - sha256: abbc90b73ac39e823b0c127da43b91d8906dcc530fc0cec4e169cf0d8c4404b1 + sha256: d4a0ca479d4f3679487a61f3174fb9fe1651e323c778b02dfa630490366be65d url: "https://pub.dev" source: hosted - version: "5.1.4" + version: "5.1.5" boolean_selector: dependency: transitive description: @@ -261,18 +205,18 @@ packages: dependency: transitive description: name: build_daemon - sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65" + sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1" url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "4.0.1" build_resolvers: dependency: transitive description: name: build_resolvers - sha256: d912852cce27c9e80a93603db721c267716894462e7033165178b91138587972 + sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.4.2" build_runner: dependency: "direct dev" description: @@ -285,10 +229,10 @@ packages: dependency: transitive description: name: build_runner_core - sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41" + sha256: "4ae8ffe5ac758da294ecf1802f2aff01558d8b1b00616aa7538ea9a8a5d50799" url: "https://pub.dev" source: hosted - version: "7.2.10" + version: "7.3.0" built_collection: dependency: transitive description: @@ -301,18 +245,18 @@ packages: dependency: transitive description: name: built_value - sha256: ff627b645b28fb8bdb69e645f910c2458fd6b65f6585c3a53e0626024897dedf + sha256: c7913a9737ee4007efedaffc968c049fd0f3d0e49109e778edc10de9426005cb url: "https://pub.dev" source: hosted - version: "8.6.2" + version: "8.9.2" buttons_tabbar: dependency: "direct main" description: name: buttons_tabbar - sha256: "781128180f3e76cf93c093183f10395c664983dbee20bc4da2025be70085c2da" + sha256: "3f0969c26574ef15c0c9ff1dee42c3c4b0d3563d2c8607804372490fb8b76896" url: "https://pub.dev" source: hosted - version: "1.3.7+1" + version: "1.3.8" cached_network_image: dependency: "direct main" description: @@ -337,14 +281,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" - catcher_2: - dependency: "direct main" - description: - name: catcher_2 - sha256: "73e251057b1b59442d58b5109d26401cfed850df21da44b028338d4f85f69105" - url: "https://pub.dev" - source: hosted - version: "1.0.0" change_case: dependency: transitive description: @@ -361,6 +297,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + charcode: + dependency: transitive + description: + name: charcode + sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + url: "https://pub.dev" + source: hosted + version: "1.3.1" checked_yaml: dependency: transitive description: @@ -381,10 +325,10 @@ packages: dependency: transitive description: name: cli_util - sha256: b8db3080e59b2503ca9e7922c3df2072cf13992354d5e944074ffa836fba43b7 + sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19 url: "https://pub.dev" source: hosted - version: "0.4.0" + version: "0.4.1" clock: dependency: transitive description: @@ -397,10 +341,10 @@ packages: dependency: transitive description: name: code_builder - sha256: "315a598c7fbe77f22de1c9da7cfd6fd21816312f16ffa124453b4fc679e540f1" + sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37 url: "https://pub.dev" source: hosted - version: "4.6.0" + version: "4.10.0" collection: dependency: "direct main" description: @@ -429,12 +373,12 @@ packages: dependency: transitive description: name: cross_file - sha256: fd832b5384d0d6da4f6df60b854d33accaaeb63aa9e10e736a87381f08dee2cb + sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32" url: "https://pub.dev" source: hosted - version: "0.3.3+5" + version: "0.3.4+1" crypto: - dependency: "direct main" + dependency: "direct dev" description: name: crypto sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab @@ -449,14 +393,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" - cupertino_icons: - dependency: "direct main" - description: - name: cupertino_icons - sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d - url: "https://pub.dev" - source: hosted - version: "1.0.6" curved_navigation_bar: dependency: "direct main" description: @@ -469,26 +405,26 @@ packages: dependency: "direct dev" description: name: custom_lint - sha256: "22bd87a362f433ba6aae127a7bac2838645270737f3721b180916d7c5946cb5d" + sha256: "7c0aec12df22f9082146c354692056677f1e70bc43471644d1fdb36c6fdda799" url: "https://pub.dev" source: hosted - version: "0.5.11" + version: "0.6.4" custom_lint_builder: dependency: transitive description: name: custom_lint_builder - sha256: "0d48e002438950f9582e574ef806b2bea5719d8d14c0f9f754fbad729bcf3b19" + sha256: d7dc41e709dde223806660268678be7993559e523eb3164e2a1425fd6f7615a9 url: "https://pub.dev" source: hosted - version: "0.5.14" + version: "0.6.4" custom_lint_core: dependency: transitive description: name: custom_lint_core - sha256: "2952837953022de610dacb464f045594854ced6506ac7f76af28d4a6490e189b" + sha256: a85e8f78f4c52f6c63cdaf8c872eb573db0231dcdf3c3a5906d493c1f8bc20e6 url: "https://pub.dev" source: hosted - version: "0.5.14" + version: "0.6.3" dart_des: dependency: transitive description: @@ -497,23 +433,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.2" - dart_discord_rpc: - dependency: "direct main" + dart_mappable: + dependency: transitive description: - path: "." - ref: HEAD - resolved-ref: "4d05017838ebeadcdb832e1893fabad1506fddba" - url: "https://github.com/Tommypop2/dart_discord_rpc.git" - source: git - version: "0.0.3" + name: dart_mappable + sha256: "47269caf2060533c29b823ff7fa9706502355ffcb61e7f2a374e3a0fb2f2c3f0" + url: "https://pub.dev" + source: hosted + version: "4.2.2" dart_style: dependency: transitive description: name: dart_style - sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55" + sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.3.6" dartx: dependency: transitive description: @@ -530,22 +465,23 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.10" - device_frame: - dependency: transitive + desktop_webview_window: + dependency: "direct main" description: - name: device_frame - sha256: afe76182aec178d171953d9b4a50a43c57c7cf3c77d8b09a48bf30c8fa04dd9d - url: "https://pub.dev" - source: hosted - version: "1.1.0" + path: "packages/desktop_webview_window" + ref: "feat/cookies" + resolved-ref: f20e433d4a948515b35089d40069f7dd9bced9e4 + url: "https://github.com/KRTirtho/flutter-plugins.git" + source: git + version: "0.2.4" device_info_plus: dependency: "direct main" description: name: device_info_plus - sha256: "77f757b789ff68e4eaf9c56d1752309bd9f7ad557cb105b938a7f8eb89e59110" + sha256: eead12d1a1ed83d8283ab4c2f3fca23ac4082f29f25f29dff0f758f57d06ec91 url: "https://pub.dev" source: hosted - version: "9.1.2" + version: "10.1.0" device_info_plus_platform_interface: dependency: transitive description: @@ -554,30 +490,22 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" - device_preview: - dependency: "direct main" - description: - name: device_preview - sha256: "2f097bf31b929e15e6756dbe0ec1bcb63952ab9ed51c25dc5a2c722d2b21fdaf" - url: "https://pub.dev" - source: hosted - version: "1.1.0" dio: dependency: "direct main" description: name: dio - sha256: "49af28382aefc53562459104f64d16b9dfd1e8ef68c862d5af436cc8356ce5a8" + sha256: "11e40df547d418cc0c4900a9318b26304e665da6fa4755399a9ff9efd09034b5" url: "https://pub.dev" source: hosted - version: "5.4.1" + version: "5.4.3+1" disable_battery_optimization: dependency: "direct main" description: name: disable_battery_optimization - sha256: b3441975ab2a3ab0c19ed78e909a88d245ce689d43d17f9b23582b1ed41c047b + sha256: "6b2ba802f984af141faf1b6b5fb956d5ef01f9cd555597c35b9cc335a03185ba" url: "https://pub.dev" source: hosted - version: "1.1.0+1" + version: "1.1.1" dots_indicator: dependency: transitive description: @@ -595,6 +523,22 @@ packages: url: "https://github.com/thielepaul/flutter-draggable-scrollbar.git" source: git version: "0.1.0" + drift: + dependency: "direct main" + description: + name: drift + sha256: "6acedc562ffeed308049f78fb1906abad3d65714580b6745441ee6d50ec564cd" + url: "https://pub.dev" + source: hosted + version: "2.18.0" + drift_dev: + dependency: "direct dev" + description: + name: drift_dev + sha256: d9b020736ea85fff1568699ce18b89fabb3f0f042e8a7a05e84a3ec20d39acde + url: "https://pub.dev" + source: hosted + version: "2.18.0" duration: dependency: "direct main" description: @@ -603,22 +547,38 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.13" + encrypt: + dependency: "direct main" + description: + name: encrypt + sha256: "62d9aa4670cc2a8798bab89b39fc71b6dfbacf615de6cf5001fb39f7e4a996a2" + url: "https://pub.dev" + source: hosted + version: "5.0.3" envied: dependency: "direct main" description: name: envied - sha256: "60d3f5606c7b35bc6ef493e650d916b34351d8af2e58b7ac45881ba59dfcf039" + sha256: bbff9c76120e4dc5e2e36a46690cf0a26feb65e7765633f4e8d916bcd173a450 url: "https://pub.dev" source: hosted - version: "0.3.0+3" + version: "0.5.4+1" envied_generator: dependency: "direct dev" description: name: envied_generator - sha256: dfdbe5dc52863e54c036a4c4042afbdf1bd528cb4c1e638ecba26228ba72e9e5 + sha256: "517b70de08d13dcd40e97b4e5347e216a0b1c75c99e704f3c85c0474a392d14a" url: "https://pub.dev" source: hosted - version: "0.3.0+3" + version: "0.5.4+1" + equatable: + dependency: transitive + description: + name: equatable + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" + source: hosted + version: "2.0.5" fake_async: dependency: transitive description: @@ -631,10 +591,10 @@ packages: dependency: transitive description: name: ffi - sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.2" file: dependency: transitive description: @@ -647,34 +607,34 @@ packages: dependency: "direct main" description: name: file_picker - sha256: "4e42aacde3b993c5947467ab640882c56947d9d27342a5b6f2895b23956954a6" + sha256: d1d0ac3966b36dc3e66eeefb40280c17feb87fa2099c6e22e6a1fc959327bd03 url: "https://pub.dev" source: hosted - version: "6.1.1" + version: "8.0.0+1" file_selector: dependency: "direct main" description: name: file_selector - sha256: "84eaf3e034d647859167d1f01cfe7b6352488f34c1b4932635012b202014c25b" + sha256: "5019692b593455127794d5718304ff1ae15447dea286cdda9f0db2a796a1b828" url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.0.3" file_selector_android: dependency: transitive description: name: file_selector_android - sha256: d41e165d6f798ca941d536e5dc93494d50e78c571c28ad60cfe0b0fefeb9f1e7 + sha256: "1cd66575f063b689e041aec836905ba7be18d76c9f0634d0d75daec825f67095" url: "https://pub.dev" source: hosted - version: "0.5.0+3" + version: "0.5.0+7" file_selector_ios: dependency: transitive description: name: file_selector_ios - sha256: b3fbdda64aa2e335df6e111f6b0f1bb968402ed81d2dd1fa4274267999aa32c2 + sha256: "0a1196a9c5795858aa315332da2fb5c4bcfdcb312d8a4e27651f765b87904431" url: "https://pub.dev" source: hosted - version: "0.5.1+6" + version: "0.5.1+9" file_selector_linux: dependency: transitive description: @@ -687,26 +647,26 @@ packages: dependency: transitive description: name: file_selector_macos - sha256: "182c3f8350cee659f7b115e956047ee3dc672a96665883a545e81581b9a82c72" + sha256: b15c3da8bd4908b9918111fa486903f5808e388b8d1c559949f584725a6594d6 url: "https://pub.dev" source: hosted - version: "0.9.3+2" + version: "0.9.3+3" file_selector_platform_interface: dependency: transitive description: name: file_selector_platform_interface - sha256: "0aa47a725c346825a2bd396343ce63ac00bda6eff2fbc43eabe99737dede8262" + sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "2.6.2" file_selector_web: dependency: transitive description: name: file_selector_web - sha256: dc6622c4d66cb1bee623ddcc029036603c6cc45c85e4a775bb06008d61c809c1 + sha256: "619e431b224711a3869e30dbd7d516f5f5a4f04b265013a50912f39e1abc88c8" url: "https://pub.dev" source: hosted - version: "0.9.2+1" + version: "0.9.4+1" file_selector_windows: dependency: transitive description: @@ -727,31 +687,15 @@ packages: dependency: "direct main" description: name: fluentui_system_icons - sha256: "7637cab80bd8d1ba762144cd85df79a7318c12ed5a66d166a9e4acbf24a4c412" + sha256: "1c860f10a0e74c5788ff8a650ae6074d9a544463ae269714f1044b32df52b978" url: "https://pub.dev" source: hosted - version: "1.1.214" + version: "1.1.234" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" - flutter_app_builder: - dependency: transitive - description: - name: flutter_app_builder - sha256: "9e5527919f62424f0fafaa3e8dfda8469caf63e465862e9866a0d60a37c00fcf" - url: "https://pub.dev" - source: hosted - version: "0.0.9" - flutter_app_packager: - dependency: transitive - description: - name: flutter_app_packager - sha256: b5bfb7113b49710c004c5f1ab6f08ac121418540d49e14825dd75e99810fa695 - url: "https://pub.dev" - source: hosted - version: "0.0.9" flutter_broadcasts: dependency: "direct main" description: @@ -768,15 +712,15 @@ packages: url: "https://pub.dev" source: hosted version: "3.3.1" - flutter_desktop_tools: + flutter_discord_rpc: dependency: "direct main" description: - path: "." - ref: "1f0bec3283626dcbd8ee2f54e238d096d8dea50e" - resolved-ref: "1f0bec3283626dcbd8ee2f54e238d096d8dea50e" - url: "https://github.com/KRTirtho/flutter_desktop_tools.git" + path: "packages/flutter_discord_rpc" + ref: cargokit + resolved-ref: "331636d8e378e3ac9ad30a4b0d3eed17d5a85fe9" + url: "https://github.com/KRTirtho/frb_plugins.git" source: git - version: "0.0.1" + version: "0.1.0+1" flutter_displaymode: dependency: "direct main" description: @@ -785,14 +729,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.0" - flutter_distributor: - dependency: "direct dev" - description: - name: flutter_distributor - sha256: "50d56df265e97396427ec42cc02374b72d08c71b3442d662b97fc089bd1705ea" - url: "https://pub.dev" - source: hosted - version: "0.0.2" flutter_driver: dependency: transitive description: flutter @@ -890,10 +826,10 @@ packages: dependency: transitive description: name: flutter_keyboard_visibility - sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb" + sha256: "98664be7be0e3ffca00de50f7f6a287ab62c763fc8c762e0a21584584a3ff4f8" url: "https://pub.dev" source: hosted - version: "5.4.1" + version: "6.0.0" flutter_keyboard_visibility_linux: dependency: transitive description: @@ -946,55 +882,47 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7 + sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.2" flutter_localizations: dependency: "direct main" description: flutter source: sdk version: "0.0.0" - flutter_mailer: - dependency: transitive - description: - name: flutter_mailer - sha256: a935e9caa842877e8ed56109afb75b86e6488edbcd4696a5ac02b327a48fcd8a - url: "https://pub.dev" - source: hosted - version: "2.1.1" flutter_native_splash: dependency: "direct main" description: name: flutter_native_splash - sha256: "558f10070f03ee71f850a78f7136ab239a67636a294a44a06b6b7345178edb1e" + sha256: edf39bcf4d74aca1eb2c1e43c3e445fd9f494013df7f0da752fefe72020eedc0 url: "https://pub.dev" source: hosted - version: "2.3.10" + version: "2.4.0" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: f185ac890306b5779ecbd611f52502d8d4d63d27703ef73161ca0407e815f02c + sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f" url: "https://pub.dev" source: hosted - version: "2.0.16" + version: "2.0.19" flutter_riverpod: dependency: "direct main" description: name: flutter_riverpod - sha256: "4bce556b7ecbfea26109638d5237684538d4abc509d253e6c5c4c5733b360098" + sha256: "0f1974eff5bbe774bf1d870e406fc6f29e3d6f1c46bd9c58e7172ff68a785d7d" url: "https://pub.dev" source: hosted - version: "2.4.10" + version: "2.5.1" flutter_rust_bridge: dependency: transitive description: name: flutter_rust_bridge - sha256: e12415c3bce49bcbc3fed383f0ea41ad7d828f6cf0eccba0588ffa5a812fe522 + sha256: fac14d2dd67eeba29a20e5d99fac0d4d9fcd552cdf6bf4f8945f7679c6b07b1d url: "https://pub.dev" source: hosted - version: "1.82.1" + version: "2.1.0" flutter_secure_storage: dependency: "direct main" description: @@ -1047,10 +975,10 @@ packages: dependency: "direct main" description: name: flutter_sharing_intent - sha256: "6eb896e6523b735e8230eeb206fd3b9f220f11ce879c2400a90b443147036ff9" + sha256: "785ffc391822641457f930eb477c91c2f598a888f50b8fbb40d481ee01c7e719" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" flutter_svg: dependency: "direct main" description: @@ -1069,14 +997,6 @@ packages: description: flutter source: sdk version: "0.0.0" - fluttertoast: - dependency: transitive - description: - name: fluttertoast - sha256: "474f7d506230897a3cd28c965ec21c5328ae5605fc9c400cd330e9e9d6ac175c" - url: "https://pub.dev" - source: hosted - version: "8.2.2" form_validator: dependency: "direct main" description: @@ -1089,10 +1009,10 @@ packages: dependency: "direct dev" description: name: freezed - sha256: "6c5031daae12c7072b3a87eff98983076434b4889ef2a44384d0cae3f82372ba" + sha256: a434911f643466d78462625df76fd9eb13e57348ff43fe1f77bbe909522c67a1 url: "https://pub.dev" source: hosted - version: "2.4.6" + version: "2.5.2" freezed_annotation: dependency: "direct main" description: @@ -1105,10 +1025,10 @@ packages: dependency: transitive description: name: frontend_server_client - sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 url: "https://pub.dev" source: hosted - version: "3.2.0" + version: "4.0.0" fuchsia_remote_debug_protocol: dependency: transitive description: flutter @@ -1150,10 +1070,10 @@ packages: dependency: "direct main" description: name: google_fonts - sha256: f0b8d115a13ecf827013ec9fc883390ccc0e87a96ed5347a3114cac177ef18e8 + sha256: b1ac0fe2832c9cc95e5e88b57d627c5e68c223b9657f4b96e1487aa9098c7b82 url: "https://pub.dev" source: hosted - version: "6.1.0" + version: "6.2.1" graphs: dependency: transitive description: @@ -1206,10 +1126,10 @@ packages: dependency: "direct main" description: name: hooks_riverpod - sha256: "758b07eba336e3cbacbd81dba481f2228a14102083fdde07045e8514e8054c49" + sha256: "45b2030a18bcd6dbd680c2c91bc3b33e3fe7c323e3acb5ecec93a613e2fbaa8a" url: "https://pub.dev" source: hosted - version: "2.4.10" + version: "2.5.1" hotreloader: dependency: transitive description: @@ -1270,42 +1190,42 @@ packages: dependency: transitive description: name: image - sha256: "028f61960d56f26414eb616b48b04eb37d700cbe477b7fb09bf1d7ce57fd9271" + sha256: "4c68bfd5ae83e700b5204c1e74451e7bf3cf750e6843c6e158289cf56bda018e" url: "https://pub.dev" source: hosted - version: "4.1.3" + version: "4.1.7" image_picker: dependency: "direct main" description: name: image_picker - sha256: "7d7f2768df2a8b0a3cefa5ef4f84636121987d403130e70b17ef7e2cf650ba84" + sha256: fe9ee64ccb8d599a5dfb0e21cc6652232c610bcf667af4e79b9eb175cc30a7a5 url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.1.0" image_picker_android: dependency: transitive description: name: image_picker_android - sha256: "47da2161c2e9f8f8a9cbbd89d466d174333fbdd769aeed848912e0b16d9cb369" + sha256: "8e75431a62b7feb4fd55cb4a5c6f0ac4564460ec5dc09f9c4a0d50a5ce7c4cb9" url: "https://pub.dev" source: hosted - version: "0.8.8" + version: "0.8.10" image_picker_for_web: dependency: transitive description: name: image_picker_for_web - sha256: "50bc9ae6a77eea3a8b11af5eb6c661eeb858fdd2f734c2a4fd17086922347ef7" + sha256: "5d6eb13048cd47b60dbf1a5495424dea226c5faf3950e20bf8120a58efb5b5f3" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.0.4" image_picker_ios: dependency: transitive description: name: image_picker_ios - sha256: c5538cacefacac733c724be7484377923b476216ad1ead35a0d2eadcdc0fc497 + sha256: f4a6f62be96d6fd268f32a6bf8ef444cd8e3fff64d16923c6e6fe55e0c84a761 url: "https://pub.dev" source: hosted - version: "0.8.8+2" + version: "0.8.10" image_picker_linux: dependency: transitive description: @@ -1326,10 +1246,10 @@ packages: dependency: transitive description: name: image_picker_platform_interface - sha256: ed9b00e63977c93b0d2d2b343685bed9c324534ba5abafbb3dfbd6a780b1b514 + sha256: "9ec26d410ff46f483c5519c29c02ef0e02e13a543f882b152d4bfd2f06802f80" url: "https://pub.dev" source: hosted - version: "2.9.1" + version: "2.10.0" image_picker_windows: dependency: transitive description: @@ -1347,20 +1267,20 @@ packages: dependency: "direct main" description: name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf url: "https://pub.dev" source: hosted - version: "0.18.1" + version: "0.19.0" introduction_screen: dependency: "direct main" description: name: introduction_screen - sha256: ef5a5479a8e06a84b9a7eff16c698b9b82f70cd1b6203b264bc3686f9bfb77e2 + sha256: "325f26e86fa3c3e86e6ab2bbc1fda860c9e6eae5ff29166fc2a3cab8f710d5b5" url: "https://pub.dev" source: hosted - version: "3.1.11" + version: "3.1.14" io: - dependency: transitive + dependency: "direct dev" description: name: io sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" @@ -1403,26 +1323,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.4" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.3" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" lints: dependency: transitive description: @@ -1432,21 +1352,21 @@ packages: source: hosted version: "3.0.0" local_notifier: - dependency: transitive + dependency: "direct main" description: name: local_notifier - sha256: cc855aa6362c8840e3d3b35b1c3b058a3a8becdb2b03d5a9aa3f3a1e861f0a03 + sha256: f6cfc933c6fbc961f4e52b5c880f68e41b2d3cd29aad557cc654fd211093a025 url: "https://pub.dev" source: hosted - version: "0.1.5" + version: "0.1.6" logger: dependency: "direct main" description: name: logger - sha256: ba3bc83117b2b49bdd723c0ea7848e8285a0fbc597ba09203b20d329d020c24a + sha256: "8c94b8c219e7e50194efc8771cd0e9f10807d8d3e219af473d89b06cc2ee4e04" url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.2.0" logging: dependency: transitive description: @@ -1463,14 +1383,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.2" - mailer: - dependency: transitive - description: - name: mailer - sha256: "57f6dd1496699999a7bfd0aa6be0645384f477f4823e16d4321c40a434346382" - url: "https://pub.dev" - source: hosted - version: "6.0.1" matcher: dependency: transitive description: @@ -1491,26 +1403,26 @@ packages: dependency: "direct main" description: name: media_kit - sha256: "92c7f59e075d74471b31e703f81ccc1d7102739ebcce945b30a6417fa2f751d5" + sha256: "3289062540e3b8b9746e5c50d95bd78a9289826b7227e253dff806d002b9e67a" url: "https://pub.dev" source: hosted - version: "1.1.7" + version: "1.1.10+1" media_kit_libs_android_audio: dependency: transitive description: name: media_kit_libs_android_audio - sha256: "1d9ba8814e58a12ae69014884abf96893d38e444abfb806ff38896dfe089dd15" + sha256: "3d2df5c09d3f3ff7c55b53bf955e46712f76483e77562a5a017439a3ea85ce88" url: "https://pub.dev" source: hosted - version: "1.3.5" + version: "1.3.6" media_kit_libs_audio: dependency: "direct main" description: name: media_kit_libs_audio - sha256: "9ccf9019edc220b8d0bfa1f53a91aa2cf2506ac860b4d5774c9d6bbdd49796ca" + sha256: f3f91df69848005363b3ae0ef7971a90edbd80a9365195684ef26c9a6ac8833f url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.4" media_kit_libs_ios_audio: dependency: transitive description: @@ -1551,38 +1463,39 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" + menu_base: + dependency: transitive + description: + name: menu_base + sha256: "820368014a171bd1241030278e6c2617354f492f5c703d7b7d4570a6b8b84405" + url: "https://pub.dev" + source: hosted + version: "0.1.1" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.12.0" metadata_god: dependency: "direct main" description: - name: metadata_god - sha256: cf13931c39eba0b9443d16e8940afdabee125bf08945f18d4c0d02bcae2a3317 - url: "https://pub.dev" - source: hosted - version: "0.5.2+1" + path: "packages/metadata_god" + ref: cargokit + resolved-ref: "331636d8e378e3ac9ad30a4b0d3eed17d5a85fe9" + url: "https://github.com/KRTirtho/frb_plugins.git" + source: git + version: "0.5.3" mime: dependency: "direct main" description: name: mime - sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" url: "https://pub.dev" source: hosted - version: "1.0.4" - nested: - dependency: transitive - description: - name: nested - sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" - url: "https://pub.dev" - source: hosted - version: "1.0.0" + version: "1.0.5" oauth2: dependency: transitive description: @@ -1611,10 +1524,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: "6ff267fcd9d48cb61c8df74a82680e8b82e940231bb5f68356672fde0397334a" + sha256: cb44f49b6e690fa766f023d5b22cac6b9affe741dd792b6ac7ad4fabe0d7b097 url: "https://pub.dev" source: hosted - version: "4.1.0" + version: "6.0.0" package_info_plus_platform_interface: dependency: transitive description: @@ -1659,26 +1572,26 @@ packages: dependency: "direct main" description: name: path_provider - sha256: a1aa8aaa2542a6bc57e381f132af822420216c80d4781f7aa085ca3229208aaa + sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.3" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: "6b8b19bd80da4f11ce91b2d1fb931f3006911477cec227cce23d3253d80df3f1" + sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.2.4" path_provider_foundation: dependency: transitive description: name: path_provider_foundation - sha256: "19314d595120f82aca0ba62787d58dde2cc6b5df7d2f0daf72489e38d1b57f2d" + sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f" url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.3.2" path_provider_linux: dependency: transitive description: @@ -1691,10 +1604,10 @@ packages: dependency: transitive description: name: path_provider_platform_interface - sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c" + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" path_provider_windows: dependency: transitive description: @@ -1707,42 +1620,50 @@ packages: dependency: "direct main" description: name: permission_handler - sha256: "284a66179cabdf942f838543e10413246f06424d960c92ba95c84439154fcac8" + sha256: "18bf33f7fefbd812f37e72091a15575e72d5318854877e0e4035a24ac1113ecb" url: "https://pub.dev" source: hosted - version: "11.0.1" + version: "11.3.1" permission_handler_android: dependency: transitive description: name: permission_handler_android - sha256: ace7d15a3d1a4a0b91c041d01e5405df221edb9de9116525efc773c74e6fc790 + sha256: "1acac6bae58144b442f11e66621c062aead9c99841093c38f5bcdcc24c1c3474" url: "https://pub.dev" source: hosted - version: "11.0.5" + version: "12.0.5" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - sha256: "99e220bce3f8877c78e4ace901082fb29fa1b4ebde529ad0932d8d664b34f3f5" + sha256: e9ad66020b89ff1b63908f247c2c6f931c6e62699b756ef8b3c4569350cd8662 + url: "https://pub.dev" + source: hosted + version: "9.4.4" + permission_handler_html: + dependency: transitive + description: + name: permission_handler_html + sha256: "54bf176b90f6eddd4ece307e2c06cf977fb3973719c35a93b85cc7093eb6070d" url: "https://pub.dev" source: hosted - version: "9.1.4" + version: "0.1.1" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - sha256: f2343e9fa9c22ae4fd92d4732755bfe452214e7189afcc097380950cf567b4b2 + sha256: "48d4fcf201a1dad93ee869ab0d4101d084f49136ec82a8a06ed9cfeacab9fd20" url: "https://pub.dev" source: hosted - version: "3.11.5" + version: "4.2.1" permission_handler_windows: dependency: transitive description: name: permission_handler_windows - sha256: cc074aace208760f1eee6aa4fae766b45d947df85bc831cde77009cdb4720098 + sha256: "1a790728016f79a41216d88672dbc5df30e686e811ad4e698bfc51f76ad91f1e" url: "https://pub.dev" source: hosted - version: "0.1.3" + version: "0.2.1" petitparser: dependency: transitive description: @@ -1754,11 +1675,10 @@ packages: piped_client: dependency: "direct main" description: - path: "." - ref: HEAD - resolved-ref: "64631732eefe3d93889756dc2e4ff5c8523ed763" - url: "https://github.com/KRTirtho/piped_client.git" - source: git + name: piped_client + sha256: "87b04b2ebf4e008cfbb0ac85e9920ab3741f5aa697be2dd44919658a3297a4bc" + url: "https://pub.dev" + source: hosted version: "0.1.1" platform: dependency: transitive @@ -1772,18 +1692,18 @@ packages: dependency: transitive description: name: plugin_platform_interface - sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" url: "https://pub.dev" source: hosted - version: "2.1.6" + version: "2.1.8" pointycastle: dependency: transitive description: name: pointycastle - sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c" + sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe" url: "https://pub.dev" source: hosted - version: "3.7.3" + version: "3.9.1" pool: dependency: transitive description: @@ -1808,22 +1728,22 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.2" - provider: - dependency: transitive + process_run: + dependency: "direct dev" description: - name: provider - sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f + name: process_run + sha256: "8d9c6198b98fbbfb511edd42e7364e24d85c163e47398919871b952dc86a423e" url: "https://pub.dev" source: hosted - version: "6.0.5" + version: "0.14.2" pub_api_client: - dependency: "direct main" + dependency: "direct dev" description: name: pub_api_client - sha256: d456816ef5142906a22dc56e37be6bef6cb0276f0a26c11d1f7d277868202e71 + sha256: cc3d2c93df3823553de6a3e7d3ac09a3f43f8c271af4f43c2795266090ac9625 url: "https://pub.dev" source: hosted - version: "2.6.0" + version: "2.7.0" pub_semver: dependency: transitive description: @@ -1841,21 +1761,13 @@ packages: source: hosted version: "2.3.0" pubspec_parse: - dependency: "direct main" + dependency: "direct dev" description: name: pubspec_parse - sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 - url: "https://pub.dev" - source: hosted - version: "1.2.3" - puppeteer: - dependency: transitive - description: - name: puppeteer - sha256: eedeaae6ec5d2e54f9ae22ab4d6b3dda2e8791c356cc783046d06c287ffe11d8 + sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8 url: "https://pub.dev" source: hosted - version: "3.6.0" + version: "1.3.0" quiver: dependency: transitive description: @@ -1864,30 +1776,46 @@ packages: url: "https://pub.dev" source: hosted version: "3.2.1" - riverpod: + recase: dependency: transitive + description: + name: recase + sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 + url: "https://pub.dev" + source: hosted + version: "4.1.0" + retry: + dependency: "direct main" + description: + name: retry + sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc" + url: "https://pub.dev" + source: hosted + version: "3.1.2" + riverpod: + dependency: "direct main" description: name: riverpod - sha256: "548e2192eb7aeb826eb89387f814edb76594f3363e2c0bb99dd733d795ba3589" + sha256: f21b32ffd26a36555e501b04f4a5dca43ed59e16343f1a30c13632b2351dfa4d url: "https://pub.dev" source: hosted - version: "2.5.0" + version: "2.5.1" riverpod_analyzer_utils: dependency: transitive description: name: riverpod_analyzer_utils - sha256: d72d7096964baf288b55619fe48100001fc4564ab7923ed0a7f5c7650e03c0d6 + sha256: "8b71f03fc47ae27d13769496a1746332df4cec43918aeba9aff1e232783a780f" url: "https://pub.dev" source: hosted - version: "0.3.4" + version: "0.5.1" riverpod_lint: dependency: "direct dev" description: name: riverpod_lint - sha256: "70198738c3047ae4f6517ef1a2011a8514a980a52576c7f629a3a08810319a02" + sha256: "3c67c14ccd16f0c9d53e35ef70d06cd9d072e2fb14557326886bbde903b230a5" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.3.10" rxdart: dependency: transitive description: @@ -1929,38 +1857,30 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.1" - sentry: - dependency: transitive - description: - name: sentry - sha256: "39c23342fc96105da449914f7774139a17a0ca8a4e70d9ad5200171f7e47d6ba" - url: "https://pub.dev" - source: hosted - version: "7.9.0" shared_preferences: dependency: "direct main" description: name: shared_preferences - sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02" + sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180 url: "https://pub.dev" source: hosted - version: "2.2.2" + version: "2.2.3" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: "8568a389334b6e83415b6aae55378e158fbc2314e074983362d20c562780fb06" + sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2" url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.2.2" shared_preferences_foundation: dependency: transitive description: name: shared_preferences_foundation - sha256: "7bf53a9f2d007329ee6f3df7268fd498f8373602f943c975598bbb34649b62a7" + sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c" url: "https://pub.dev" source: hosted - version: "2.3.4" + version: "2.3.5" shared_preferences_linux: dependency: transitive description: @@ -1973,18 +1893,18 @@ packages: dependency: transitive description: name: shared_preferences_platform_interface - sha256: d4ec5fc9ebb2f2e056c617112aa75dcf92fc2e4faaf2ae999caa297473f75d8a + sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b" url: "https://pub.dev" source: hosted - version: "2.3.1" + version: "2.3.2" shared_preferences_web: dependency: transitive description: name: shared_preferences_web - sha256: d762709c2bbe80626ecc819143013cc820fa49ca5e363620ee20a8b15a3e3daf + sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a" url: "https://pub.dev" source: hosted - version: "2.2.1" + version: "2.3.0" shared_preferences_windows: dependency: transitive description: @@ -2009,14 +1929,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.4" - shelf_static: - dependency: transitive - description: - name: shelf_static - sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e - url: "https://pub.dev" - source: hosted - version: "1.1.2" shelf_web_socket: dependency: "direct main" description: @@ -2025,38 +1937,38 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.4" + shortid: + dependency: transitive + description: + name: shortid + sha256: d0b40e3dbb50497dad107e19c54ca7de0d1a274eb9b4404991e443dadb9ebedb + url: "https://pub.dev" + source: hosted + version: "0.1.2" sidebarx: dependency: "direct main" description: name: sidebarx - sha256: "7042d64844b8e64ca5c17e70d89b49df35b54a26c015b90000da9741eab70bc0" + sha256: abe39d6db237fb8e25c600e8039ffab80fa7fe71acab03e9c378c31f912d2766 url: "https://pub.dev" source: hosted - version: "0.16.3" + version: "0.17.1" simple_icons: dependency: "direct main" description: name: simple_icons - sha256: "8aa6832dc7a263a3213e40ecbf1328a392308c809d534a3b860693625890483b" + sha256: "30067d70a9d72923fbc80e142e17fa46085dfa970e66bc4bede3be4819d05901" url: "https://pub.dev" source: hosted - version: "7.10.0" - skeleton_text: - dependency: "direct main" - description: - name: skeleton_text - sha256: bacd536bf0664efe1cae53bcbd78c3d4040a120f300f69dc85d83f358471cc6c - url: "https://pub.dev" - source: hosted - version: "3.0.1" + version: "10.1.3" skeletonizer: dependency: "direct main" description: name: skeletonizer - sha256: ff4c36e826efd5288d7a84e7619a6e9be8185d3064cecf101a9133762f3b401b + sha256: "9a3ae2f4ee4349bdbed3292d04586a1315a44745d2c454684f82f0c46dbeabf9" url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "1.1.1" sky_engine: dependency: transitive description: flutter @@ -2073,19 +1985,20 @@ packages: smtc_windows: dependency: "direct main" description: - name: smtc_windows - sha256: aba2bad5ddfaf595496db04df3d9fdb54fb128fc1f39c8f024945a67455388fe - url: "https://pub.dev" - source: hosted - version: "0.1.1" + path: "packages/smtc_windows" + ref: cargokit + resolved-ref: "331636d8e378e3ac9ad30a4b0d3eed17d5a85fe9" + url: "https://github.com/KRTirtho/frb_plugins.git" + source: git + version: "0.1.3" source_gen: dependency: transitive description: name: source_gen - sha256: fc0da689e5302edb6177fdd964efcb7f58912f43c28c2047a808f5bfff643d16 + sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832" url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.5.0" source_helper: dependency: transitive description: @@ -2106,26 +2019,58 @@ packages: dependency: "direct main" description: name: spotify - sha256: "2308a84511c18ec1e72515a57e28abb1467389549d571c460732b4538c2e34de" + sha256: "705f09a457a893973451c15f4072670ac4783d67e42c35c080c55a48dee3a01f" url: "https://pub.dev" source: hosted - version: "0.13.3" + version: "0.13.7" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" sqflite: dependency: transitive description: name: sqflite - sha256: "591f1602816e9c31377d5f008c2d9ef7b8aca8941c3f89cc5fd9d84da0c38a9a" + sha256: "5ce2e1a15e822c3b4bfb5400455775e421da7098eed8adc8f26298ada7c9308c" url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "2.3.3" sqflite_common: dependency: transitive description: name: sqflite_common - sha256: "1b92f368f44b0dee2425bb861cfa17b6f6cf3961f762ff6f941d20b33355660a" + sha256: "3da423ce7baf868be70e2c0976c28a1bb2f73644268b7ffa7d2e08eab71f16a4" url: "https://pub.dev" source: hosted - version: "2.5.0" + version: "2.5.4" + sqlite3: + dependency: "direct main" + description: + name: sqlite3 + sha256: b384f598b813b347c5a7e5ffad82cbaff1bec3d1561af267041e66f6f0899295 + url: "https://pub.dev" + source: hosted + version: "2.4.3" + sqlite3_flutter_libs: + dependency: "direct main" + description: + name: sqlite3_flutter_libs + sha256: "9f89a7e7dc36eac2035808427eba1c3fbd79e59c3a22093d8dace6d36b1fe89e" + url: "https://pub.dev" + source: hosted + version: "0.5.23" + sqlparser: + dependency: transitive + description: + name: sqlparser + sha256: ade9a67fd70d0369329ed3373208de7ebd8662470e8c396fc8d0d60f9acdfc9f + url: "https://pub.dev" + source: hosted + version: "0.36.0" stack_trace: dependency: transitive description: @@ -2138,10 +2083,10 @@ packages: dependency: transitive description: name: state_notifier - sha256: "8fe42610f179b843b12371e40db58c9444f8757f8b69d181c97e50787caed289" + sha256: b8677376aa54f2d7c58280d5a007f9e8774f1968d1fb1c096adcb4792fba29bb url: "https://pub.dev" source: hosted - version: "0.7.2+1" + version: "1.0.0" stream_channel: dependency: transitive description: @@ -2186,10 +2131,10 @@ packages: dependency: transitive description: name: synchronized - sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60" + sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.0+1" system_theme: dependency: "direct main" description: @@ -2206,14 +2151,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.0.2" - system_tray: - dependency: "direct overridden" - description: - name: system_tray - sha256: "087edb877f22f286d82d42f330fa640138c192e98aa9d20c2b83aa4e406bb432" - url: "https://pub.dev" - source: hosted - version: "2.0.2" term_glyph: dependency: transitive description: @@ -2226,18 +2163,18 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.0" time: dependency: transitive description: name: time - sha256: "83427e11d9072e038364a5e4da559e85869b227cf699a541be0da74f14140124" + sha256: ad8e018a6c9db36cb917a031853a1aae49467a93e0d464683e029537d848c221 url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" timezone: dependency: "direct main" description: @@ -2262,14 +2199,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" - tuple: + tray_manager: + dependency: "direct main" + description: + name: tray_manager + sha256: e0ac9a88b2700f366b8629b97e8663b6ef450a2f169560a685dc167bfe9c9c29 + url: "https://pub.dev" + source: hosted + version: "0.2.2" + type_plus: dependency: transitive description: - name: tuple - sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151 + name: type_plus + sha256: d5d1019471f0d38b91603adb9b5fd4ce7ab903c879d2fbf1a3f80a630a03fcc9 url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.1.1" typed_data: dependency: transitive description: @@ -2314,74 +2259,74 @@ packages: dependency: "direct main" description: name: url_launcher - sha256: "47e208a6711459d813ba18af120d9663c20bdf6985d6ad39fe165d2538378d27" + sha256: "6ce1e04375be4eed30548f10a315826fd933c1e493206eab82eed01f438c8d2e" url: "https://pub.dev" source: hosted - version: "6.1.14" + version: "6.2.6" url_launcher_android: dependency: transitive description: name: url_launcher_android - sha256: b04af59516ab45762b2ca6da40fa830d72d0f6045cd97744450b73493fa76330 + sha256: "360a6ed2027f18b73c8d98e159dda67a61b7f2e0f6ec26e86c3ada33b0621775" url: "https://pub.dev" source: hosted - version: "6.1.0" + version: "6.3.1" url_launcher_ios: dependency: transitive description: name: url_launcher_ios - sha256: "7c65021d5dee51813d652357bc65b8dd4a6177082a9966bc8ba6ee477baa795f" + sha256: "9149d493b075ed740901f3ee844a38a00b33116c7c5c10d7fb27df8987fb51d5" url: "https://pub.dev" source: hosted - version: "6.1.5" + version: "6.2.5" url_launcher_linux: dependency: transitive description: name: url_launcher_linux - sha256: b651aad005e0cb06a01dbd84b428a301916dc75f0e7ea6165f80057fee2d8e8e + sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811 url: "https://pub.dev" source: hosted - version: "3.0.6" + version: "3.1.1" url_launcher_macos: dependency: transitive description: name: url_launcher_macos - sha256: b55486791f666e62e0e8ff825e58a023fd6b1f71c49926483f1128d3bbd8fe88 + sha256: b7244901ea3cf489c5335bdacda07264a6e960b1c1b1a9f91e4bc371d9e68234 url: "https://pub.dev" source: hosted - version: "3.0.7" + version: "3.1.0" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface - sha256: "95465b39f83bfe95fcb9d174829d6476216f2d548b79c38ab2506e0458787618" + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.3.2" url_launcher_web: dependency: transitive description: name: url_launcher_web - sha256: "2942294a500b4fa0b918685aff406773ba0a4cd34b7f42198742a94083020ce5" + sha256: "8d9e750d8c9338601e709cd0885f95825086bd8b642547f26bda435aade95d8a" url: "https://pub.dev" source: hosted - version: "2.0.20" + version: "2.3.1" url_launcher_windows: dependency: transitive description: name: url_launcher_windows - sha256: "95fef3129dc7cfaba2bc3d5ba2e16063bb561fc6d78e63eee16162bc70029069" + sha256: ecf9725510600aa2bb6d7ddabe16357691b6d2805f66216a97d1b881e21beff7 url: "https://pub.dev" source: hosted - version: "3.0.8" + version: "3.1.1" uuid: dependency: "direct main" description: name: uuid - sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" + sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8" url: "https://pub.dev" source: hosted - version: "3.0.7" + version: "4.4.0" vector_math: dependency: transitive description: @@ -2418,10 +2363,10 @@ packages: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.1" watcher: dependency: transitive description: @@ -2434,18 +2379,18 @@ packages: dependency: transitive description: name: web - sha256: "1d9158c616048c38f712a6646e317a3426da10e884447626167240d45209cbad" + sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.5.1" web_socket_channel: dependency: "direct main" description: name: web_socket_channel - sha256: "1d8e795e2a8b3730c41b8a98a2dff2e0fb57ae6f0764a1c46ec5915387d257b2" + sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42" url: "https://pub.dev" source: hosted - version: "2.4.4" + version: "2.4.5" webdriver: dependency: transitive description: @@ -2466,45 +2411,36 @@ packages: dependency: transitive description: name: win32 - sha256: "9e82a402b7f3d518fb9c02d0e9ae45952df31b9bf34d77baf19da2de03fc2aaa" + sha256: "0a989dc7ca2bb51eac91e8fd00851297cfffd641aa7538b165c62637ca0eaa4a" url: "https://pub.dev" source: hosted - version: "5.0.7" + version: "5.4.0" win32_registry: dependency: "direct main" description: name: win32_registry - sha256: "41fd8a189940d8696b1b810efb9abcf60827b6cbfab90b0c43e8439e3a39d85a" + sha256: "10589e0d7f4e053f2c61023a31c9ce01146656a70b7b7f0828c0b46d7da2a9bb" url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "1.1.3" window_manager: dependency: "direct main" description: name: window_manager - sha256: "6ee795be9124f90660ea9d05e581a466de19e1c89ee74fc4bf528f60c8600edd" + sha256: "8699323b30da4cdbe2aa2e7c9de567a6abd8a97d9a5c850a3c86dcd0b34bbfbf" url: "https://pub.dev" source: hosted - version: "0.3.6" - window_size: - dependency: "direct main" - description: - path: "plugins/window_size" - ref: a738913c8ce2c9f47515382d40827e794a334274 - resolved-ref: a738913c8ce2c9f47515382d40827e794a334274 - url: "https://github.com/google/flutter-desktop-embedding.git" - source: git - version: "0.1.0" + version: "0.3.9" xdg_directories: dependency: transitive description: name: xdg_directories - sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2" + sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d url: "https://pub.dev" source: hosted - version: "1.0.3" + version: "1.0.4" xml: - dependency: transitive + dependency: "direct dev" description: name: xml sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 @@ -2523,10 +2459,10 @@ packages: dependency: "direct main" description: name: youtube_explode_dart - sha256: "98fd11b51adbbca76cbdb17f560168f1d7a9835cecceea965f49eb1e5eed155c" + sha256: "26c9671d638f3396a1bfb2666f586988ee7b0ba3469e478b22a4c1a168bcf6ee" url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.2.1" sdks: - dart: ">=3.3.0 <4.0.0" - flutter: ">=3.16.0" + dart: ">=3.4.0 <4.0.0" + flutter: ">=3.19.2" diff --git a/pubspec.yaml b/pubspec.yaml index 3f4c22af3..77aa3f5ba 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Open source Spotify client that doesn't require Premium nor uses El publish_to: "none" -version: 3.6.0+30 +version: 3.8.0+33 homepage: https://spotube.krtirtho.dev repository: https://github.com/KRTirtho/spotube @@ -13,96 +13,93 @@ environment: flutter: ">=3.10.0" dependencies: - args: ^2.3.2 + args: ^2.5.0 async: ^2.9.0 - audio_service: ^0.18.9 - audio_session: ^0.1.18 + audio_service: ^0.18.13 + audio_service_mpris: ^0.1.5 + audio_session: ^0.1.19 auto_size_text: ^3.0.0 - buttons_tabbar: ^1.3.6 + buttons_tabbar: ^1.3.8 cached_network_image: ^3.3.1 - catcher_2: 1.0.0 collection: ^1.15.0 - cupertino_icons: ^1.0.5 curved_navigation_bar: ^1.0.3 dbus: ^0.7.8 - device_info_plus: ^9.1.2 - device_preview: ^1.1.0 - dio: ^5.4.1 - disable_battery_optimization: ^1.1.0+1 + desktop_webview_window: + git: + url: https://github.com/KRTirtho/flutter-plugins.git + ref: feat/cookies + path: packages/desktop_webview_window + device_info_plus: ^10.1.0 + dio: ^5.4.3+1 + disable_battery_optimization: ^1.1.1 duration: ^3.0.12 - envied: ^0.3.0 - file_selector: ^1.0.1 - fluentui_system_icons: ^1.1.189 + envied: ^0.5.4+1 + file_picker: ^8.0.0+1 + file_selector: ^1.0.3 + fluentui_system_icons: ^1.1.234 flutter: sdk: flutter flutter_cache_manager: ^3.3.0 - flutter_desktop_tools: - git: - url: https://github.com/KRTirtho/flutter_desktop_tools.git - ref: 1f0bec3283626dcbd8ee2f54e238d096d8dea50e flutter_displaymode: ^0.6.0 flutter_feather_icons: ^2.0.0+1 flutter_hooks: ^0.20.5 flutter_inappwebview: ^6.0.0 flutter_localizations: sdk: flutter - flutter_native_splash: ^2.3.10 - flutter_riverpod: ^2.4.10 + flutter_native_splash: ^2.4.0 + flutter_riverpod: ^2.5.1 flutter_secure_storage: ^9.0.0 flutter_svg: ^1.1.6 form_validator: ^2.1.1 fuzzywuzzy: ^1.1.6 go_router: 12.1.3 # Stuck on this https://github.com/flutter/flutter/issues/140869 - google_fonts: ^6.1.0 + google_fonts: ^6.2.1 hive: ^2.2.3 hive_flutter: ^1.1.0 - hooks_riverpod: ^2.4.3 + hooks_riverpod: ^2.5.1 html: ^0.15.1 - http: ^1.2.0 - image_picker: ^1.0.4 - intl: ^0.18.0 - introduction_screen: ^3.0.2 + image_picker: ^1.1.0 + intl: any + introduction_screen: ^3.1.14 json_annotation: ^4.8.1 logger: ^2.0.2 - media_kit: ^1.1.3 - media_kit_libs_audio: ^1.0.3 - metadata_god: ^0.5.2+1 + media_kit: ^1.1.10+1 + media_kit_libs_audio: ^1.0.4 + metadata_god: + git: + url: https://github.com/KRTirtho/frb_plugins.git + path: packages/metadata_god + ref: cargokit mime: ^1.0.2 - package_info_plus: ^4.1.0 + package_info_plus: ^6.0.0 palette_generator: ^0.3.3 - path: ^1.8.0 - path_provider: ^2.0.8 - permission_handler: ^11.0.1 - piped_client: - git: - url: https://github.com/KRTirtho/piped_client.git + path: ^1.9.0 + path_provider: ^2.1.3 + permission_handler: ^11.3.1 + piped_client: ^0.1.1 popover: ^0.3.0 scrobblenaut: git: url: https://github.com/KRTirtho/scrobblenaut.git ref: dart-3-support scroll_to_index: ^3.0.1 - sidebarx: ^0.16.3 - shared_preferences: ^2.2.2 - skeleton_text: ^3.0.1 - smtc_windows: ^0.1.1 + sidebarx: ^0.17.1 + shared_preferences: ^2.2.3 + smtc_windows: + git: + url: https://github.com/KRTirtho/frb_plugins.git + path: packages/smtc_windows + ref: cargokit stroke_text: ^0.0.2 system_theme: ^2.1.0 titlebar_buttons: ^1.0.0 - url_launcher: ^6.1.7 - uuid: ^3.0.7 + url_launcher: ^6.2.6 + uuid: ^4.4.0 version: ^3.0.2 visibility_detector: ^0.4.0+2 - window_manager: ^0.3.1 - window_size: - git: - url: https://github.com/google/flutter-desktop-embedding.git - ref: a738913c8ce2c9f47515382d40827e794a334274 - path: plugins/window_size - youtube_explode_dart: ^2.0.1 - simple_icons: ^7.10.0 - audio_service_mpris: ^0.1.0 - file_picker: ^6.0.0 + window_manager: ^0.3.9 + youtube_explode_dart: ^2.2.1 + simple_icons: ^10.1.3 jiosaavn: ^0.1.0 draggable_scrollbar: git: @@ -111,33 +108,41 @@ dependencies: very_good_infinite_list: ^0.7.1 gap: ^3.0.1 sliver_tools: ^0.2.12 - dart_discord_rpc: + flutter_discord_rpc: git: - url: https://github.com/Tommypop2/dart_discord_rpc.git + url: https://github.com/KRTirtho/frb_plugins.git + path: packages/flutter_discord_rpc + ref: cargokit html_unescape: ^2.0.0 wikipedia_api: ^0.1.0 - skeletonizer: ^0.8.0 - app_links: ^3.5.0 - win32_registry: ^1.1.2 + skeletonizer: ^1.1.1 + app_links: ^4.0.1 + win32_registry: ^1.1.3 flutter_sharing_intent: ^1.1.0 flutter_broadcasts: ^0.4.0 freezed_annotation: ^2.4.1 - spotify: ^0.13.3 - bonsoir: ^5.1.9 + spotify: ^0.13.7 + bonsoir: ^5.1.10 shelf: ^1.4.1 shelf_router: ^1.1.4 shelf_web_socket: ^1.0.4 - web_socket_channel: ^2.4.4 + web_socket_channel: ^2.4.5 lrc: ^1.0.2 - pub_api_client: ^2.4.0 - pubspec_parse: ^1.2.2 timezone: ^0.9.2 - crypto: ^3.0.3 + local_notifier: ^0.1.6 + tray_manager: ^0.2.2 + http: ^1.2.1 + riverpod: ^2.5.1 + drift: ^2.18.0 + sqlite3_flutter_libs: ^0.5.23 + sqlite3: ^2.4.3 + encrypt: ^5.0.3 + retry: ^3.1.2 dev_dependencies: build_runner: ^2.4.9 - envied_generator: ^0.3.0+3 - flutter_distributor: ^0.0.2 + crypto: ^3.0.3 + envied_generator: ^0.5.4+1 flutter_gen_runner: ^5.4.0 flutter_launcher_icons: ^0.13.1 flutter_lints: ^3.0.1 @@ -147,12 +152,18 @@ dev_dependencies: sdk: flutter hive_generator: ^2.0.0 json_serializable: ^6.6.2 - freezed: ^2.4.6 - custom_lint: ^0.5.11 - riverpod_lint: ^2.1.1 + freezed: ^2.5.2 + custom_lint: ^0.6.4 + riverpod_lint: ^2.3.10 + process_run: ^0.14.2 + pubspec_parse: ^1.3.0 + pub_api_client: ^2.7.0 + xml: ^6.5.0 + io: ^1.0.4 + drift_dev: ^2.18.0 dependency_overrides: - system_tray: 2.0.2 + uuid: ^4.4.0 flutter: generate: true diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index 6e1e3cb37..0c638eb75 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -1,13 +1,16 @@ +# Project-level configuration. cmake_minimum_required(VERSION 3.14) project(spotube LANGUAGES CXX) +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. set(BINARY_NAME "spotube") -cmake_policy(SET CMP0063 NEW) +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) -set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") - -# Configure build options. +# Define build configuration option. get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" @@ -20,7 +23,7 @@ else() "Debug" "Profile" "Release") endif() endif() - +# Define settings for the Profile build mode. set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") @@ -30,6 +33,10 @@ set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") add_definitions(-DUNICODE -D_UNICODE) # Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") @@ -38,14 +45,14 @@ function(APPLY_STANDARD_SETTINGS TARGET) target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") - # Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) -# Application build +# Application build; see runner/CMakeLists.txt. add_subdirectory("runner") + # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) @@ -80,6 +87,12 @@ if(PLUGIN_BUNDLED_LIBRARIES) COMPONENT Runtime) endif() +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") +install(DIRECTORY "${NATIVE_ASSETS_DIR}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index d8a9db298..f2d60e211 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -8,26 +8,26 @@ #include #include -#include +#include #include #include #include #include #include #include +#include #include -#include +#include #include #include -#include void RegisterPlugins(flutter::PluginRegistry* registry) { AppLinksPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("AppLinksPluginCApi")); BonsoirWindowsPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("BonsoirWindowsPluginCApi")); - DartDiscordRpcPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("DartDiscordRpcPlugin")); + DesktopWebviewWindowPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("DesktopWebviewWindowPlugin")); FileSelectorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorWindows")); FlutterSecureStorageWindowsPluginRegisterWithRegistrar( @@ -40,14 +40,14 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); ScreenRetrieverPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); + Sqlite3FlutterLibsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin")); SystemThemePluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("SystemThemePlugin")); - SystemTrayPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("SystemTrayPlugin")); + TrayManagerPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("TrayManagerPlugin")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); WindowManagerPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("WindowManagerPlugin")); - WindowSizePluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("WindowSizePlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 902927444..bea4d8017 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -5,21 +5,22 @@ list(APPEND FLUTTER_PLUGIN_LIST app_links bonsoir_windows - dart_discord_rpc + desktop_webview_window file_selector_windows flutter_secure_storage_windows local_notifier media_kit_libs_windows_audio permission_handler_windows screen_retriever + sqlite3_flutter_libs system_theme - system_tray + tray_manager url_launcher_windows window_manager - window_size ) list(APPEND FLUTTER_FFI_PLUGIN_LIST + flutter_discord_rpc media_kit_native_event_loop metadata_god smtc_windows diff --git a/windows/packaging/exe/inno_setup.iss b/windows/packaging/exe/inno_setup.iss index 64acc2b3c..dbb8082b6 100644 --- a/windows/packaging/exe/inno_setup.iss +++ b/windows/packaging/exe/inno_setup.iss @@ -12,7 +12,7 @@ AppPublisher={{PUBLISHER_NAME}} AppPublisherURL={{PUBLISHER_URL}} AppSupportURL={{PUBLISHER_URL}} AppUpdatesURL={{PUBLISHER_URL}} -DefaultDirName={{INSTALL_DIR_NAME}} +DefaultDirName={autopf}\{{DISPLAY_NAME}} DisableProgramGroupPage=yes OutputDir=. OutputBaseFilename={{OUTPUT_BASE_FILENAME}} diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc index e8fccc8a6..c77ce0c64 100644 --- a/windows/runner/Runner.rc +++ b/windows/runner/Runner.rc @@ -60,14 +60,14 @@ IDI_APP_ICON ICON "resources\\app_icon.ico" // Version // -#ifdef FLUTTER_BUILD_NUMBER -#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD #else -#define VERSION_AS_NUMBER 1,0,0 +#define VERSION_AS_NUMBER %{{SPOTUBE_VERSION_AS_NUMBER}}% #endif -#ifdef FLUTTER_BUILD_NAME -#define VERSION_AS_STRING #FLUTTER_BUILD_NAME +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION #else #define VERSION_AS_STRING "%{{SPOTUBE_VERSION}}%" #endif @@ -93,7 +93,7 @@ BEGIN VALUE "FileDescription", "Spotube" "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" VALUE "InternalName", "spotube" "\0" - VALUE "LegalCopyright", "Copyright (C) 2022 oss.krtirtho. All rights reserved." "\0" + VALUE "LegalCopyright", "Copyright (C) 2024 oss.krtirtho. All rights reserved." "\0" VALUE "OriginalFilename", "spotube.exe" "\0" VALUE "ProductName", "spotube" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0" diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp index b938ff495..d86a2421c 100644 --- a/windows/runner/main.cpp +++ b/windows/runner/main.cpp @@ -19,14 +19,13 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, flutter::DartProject project(L"data"); - std::vector command_line_arguments = - GetCommandLineArguments(); + std::vector command_line_arguments = GetCommandLineArguments(); project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); FlutterWindow window(project); Win32Window::Point origin(10, 10); - Win32Window::Size size(1280, 720); + Win32Window::Size size(1200, 800); if (!window.CreateAndShow(L"spotube", origin, size)) { return EXIT_FAILURE; }