diff --git a/.forgejo/workflows/bump-libmpv.yml b/.forgejo/workflows/bump-libmpv.yml new file mode 100644 index 0000000..71a3865 --- /dev/null +++ b/.forgejo/workflows/bump-libmpv.yml @@ -0,0 +1,24 @@ +name: "Bump the Windows build's libmpv" + +on: + schedule: + - cron: "0 6 * * 1" + workflow_dispatch: + +jobs: + bump-libmpv: + runs-on: ["small", "debian-13-x86_64"] + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Lix GHA Installer Action + uses: samueldr/lix-gha-installer-action@v2026-02-22 + with: + extra_nix_config: experimental-features = nix-command flakes flake-self-attrs + + - name: Open a PR if there's a newer libmpv build + env: + TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: nix run .#bump-libmpv diff --git a/.forgejo/workflows/e2e.yml b/.forgejo/workflows/e2e.yml new file mode 100644 index 0000000..14d96d2 --- /dev/null +++ b/.forgejo/workflows/e2e.yml @@ -0,0 +1,28 @@ +name: "End-to-end tests" + +on: + schedule: + - cron: "0 6 * * 1" + pull_request: + workflow_dispatch: + +jobs: + e2e: + runs-on: ["large-mem", "debian-13-x86_64"] + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + submodules: recursive + + - name: Lix GHA Installer Action + uses: samueldr/lix-gha-installer-action@v2026-02-22 + with: + extra_nix_config: experimental-features = nix-command flakes flake-self-attrs + + - name: Generate code + run: nix develop --command bash -c "flutter pub get && dart scripts/generate.dart && flutter pub run build_runner build" + + - name: Run end-to-end tests + run: nix run .#e2e-headless diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index cf64422..5cb03be 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -15,6 +15,7 @@ jobs: uses: actions/checkout@v6 with: submodules: recursive + fetch-depth: 0 - name: Lix GHA Installer Action uses: samueldr/lix-gha-installer-action@v2026-02-22 @@ -26,8 +27,30 @@ jobs: env: KEYSTORE_CONTENT: ${{ secrets.KEYSTORE_CONTENT }} + # The NDK's path ends up in the native libraries' build IDs, so put it where F-Droid has it. + # It's copied rather than linked, as clang finds its headers from its resolved location. + - name: Set up Android SDK + run: | + ndk=$(nix develop --command printenv ANDROID_NDK_HOME) + sudo mkdir -p /opt/android-sdk/ndk + sudo chown -R "$USER" /opt/android-sdk + for entry in "${ndk%/ndk/*}"/*; do + [[ $entry == */ndk ]] || ln -s "$entry" /opt/android-sdk/ + done + cp -rL "$ndk" /opt/android-sdk/ndk/ + - name: Build app - run: nix develop --command bash -c "flutter pub get && dart scripts/generate.dart && flutter pub run build_runner build && flutter build apk --target-platform android-arm64 --split-per-abi --dart-define=GIT_COMMIT=${{ github.sha }}" + run: | + export PUB_CACHE=$PWD/.pub-cache + export GOTOOLCHAIN=go$(sed -n -E 's/^toolchain go([0-9.]+)$/\1/p' gomuks/go.mod) + nix develop --command bash -c ' + set -e + export ANDROID_HOME=/opt/android-sdk ANDROID_SDK_ROOT=/opt/android-sdk ANDROID_NDK_HOME=/opt/android-sdk/ndk/${ANDROID_NDK_HOME##*/} + flutter pub get --enforce-lockfile + bash scripts/build_avif_native.sh + dart scripts/generate.dart + flutter pub run build_runner build + flutter build apk --target-platform android-arm64 --split-per-abi --dart-define=GIT_COMMIT=$GITHUB_SHA' env: KEYSTORE_PATH: ../../keystore.jks KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 28344ea..662cff6 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: 3.47.4 + flutter-version-file: pubspec.yaml - name: Set up Go uses: actions/setup-go@v6 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index b56f16f..5437318 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: 3.47.4 + flutter-version-file: pubspec.yaml - name: Set up Go uses: actions/setup-go@v6 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index db339b9..79032d5 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: 3.47.4 + flutter-version-file: pubspec.yaml - name: Set up Go uses: actions/setup-go@v6 @@ -36,7 +36,7 @@ jobs: - name: Go build run: | cd gomuks/pkg/ffi - go build -tags goolm,sqlite_fts5 -o ../../../libgomuks.dll -buildmode=c-shared + go build -tags sqlite_fts5 -o ../../../libgomuks.dll -buildmode=c-shared - name: Build with Flutter run: | @@ -45,6 +45,17 @@ jobs: flutter pub run build_runner build flutter build windows --dart-define=GIT_COMMIT=${{ github.sha }} + # better_player plays videos with libmpv, but doesn't bundle it + - name: Download libmpv + shell: powershell + run: | + $archive = "$env:RUNNER_TEMP\mpv.7z" + Invoke-WebRequest "https://github.com/shinchiro/mpv-winbuild-cmake/releases/download/20261111/mpv-dev-x86_64-20261111-git-bcde6b93cc.7z" -OutFile $archive + if ((Get-FileHash $archive -Algorithm SHA256).Hash -ne "273c079b11ea5575822f972756f4c9a71149a5c10130353abeb8586738938452") { + throw "libmpv checksum mismatch" + } + 7z e $archive libmpv-2.dll -obuild/windows/x64/runner/Release + - name: Copy MinGW runtime DLLs shell: msys2 {0} run: | diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index fa4a0a1..0f73f6a 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -12,6 +12,16 @@ You can run the following command to update the Gomuks submodule: git submodule update --remote ``` +## Releasing + +To make a release, run the following command with the new version, either `X.Y.Z` or a pre-release like `X.Y.Z-alpha1`: + +```sh +scripts/release.sh 1.2.0 +``` + +This sets the version in `pubspec.yaml` (along with the Android version code), the Windows installer, the AppStream metainfo and the README, then commits and tags it. Push it with the command it prints, then attach the artifacts from the tag's CI run to the release. + ## Code Style See [Effective Dart: Style](https://dart.dev/effective-dart/style) for general rules. There are some extra rules detailed below: diff --git a/README.md b/README.md index 5d3090f..4fd61e4 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ A simple and user-friendly Matrix client made with Flutter and a Gomuks backend. ## Screenshots -| Dark Mode | Light Mode | -| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------: | -| ![Screenshot of Nexus Client in dark mode, showing users talking, with a sidebar showing rooms and spaces, and another sidebar showing members](./assets/screenshotDark.png) | ![The same screenshot as above, but in light mode](./assets/screenshotLight.png) | +| Dark Mode | Light Mode | +| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------: | +| ![Screenshot of Nexus Client in dark mode, showing users talking, with a sidebar showing rooms and spaces, and another sidebar showing members](./assets/screenshots/desktop-dark.png) | ![The same screenshot as above, but in light mode](./assets/screenshots/desktop-light.png) | ## Try it out @@ -49,7 +49,7 @@ nexus = { This tracks the latest commit on `main`. To stay on a release instead, pin the input to its tag: ```nix -url = "git+https://git.federated.nexus/Nexus/nexus?ref=refs/tags/v1.0.1"; +url = "git+https://git.federated.nexus/Nexus/nexus?ref=refs/tags/v1.1.3"; ``` Then import the module and enable it in your NixOS configuration: @@ -75,7 +75,7 @@ This installs Nexus system-wide. With `enableNotifications`, it also installs KU #### Linux - On NixOS: Either use direnv and `direnv allow`, or `nix develop` -- On other distros: Install Flutter, Go, Git, Libclang, Libass, MPV, and Glibc. Do not use any Snap packages, they cause various compilation issues. +- On other distros: Install Flutter, Go, Git, Libclang, MPV, GStreamer (with its base, good and libav plugins), and Glibc. Do not use any Snap packages, they cause various compilation issues. #### Windows @@ -83,12 +83,11 @@ You will need: - Flutter - Git -- Libass -- MPV - Go - Visual Studio 2022 (Desktop development with C++) - [MSYS2/MinGW-w64 GCC](https://www.msys2.org/) (for CGO) - [LLVM/Clang + libclang](https://clang.llvm.org/get_started.html) (for `ffigen`) +- `libmpv-2.dll`, for playing videos, next to `nexus.exe` (CI uses a build from [mpv-winbuild-cmake](https://github.com/shinchiro/mpv-winbuild-cmake/releases)) On Windows, make sure these are available in your shell `PATH`: @@ -157,3 +156,6 @@ Join the [Nexus Client Matrix room](https://matrix.to/#/#nexus:federated.nexus) Thank you Hylke Bons (https://planetpeanut.studio) for making the amazing icon for Nexus! Thank you Tulir Asokan for making [Gomuks](https://github.com/gomuks/gomuks), and helping us integrate it into Nexus! +Thank you [Feline Build Services](https://felinebuildservices.org/) for providing CI for the Nexus Forgejo repo! + +The Nexus icon, including its source files in `assets/` and the platform app icons generated from them, is © Hylke Bons. The screenshots are © Henry Hiles. Both are licensed under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 9c0d96c..35d2638 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -16,7 +16,7 @@ if (keystorePropertiesFile.exists()) { android { namespace = "nexus.federated.nexus" - compileSdk = 36 + compileSdk = 37 ndkVersion = flutter.ndkVersion compileOptions { @@ -57,9 +57,14 @@ android { } } + dependenciesInfo { + includeInApk = false + } + buildTypes { release { - signingConfig = signingConfigs.getByName("release") + // Unsigned without a keystore, e.g. for F-Droid, which signs it itself + signingConfig = signingConfigs.getByName("release").takeIf { it.storeFile != null } } debug { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 7378547..7638ad6 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,7 +1,13 @@ - + - - + + + @@ -20,7 +26,7 @@ (FLUTTER_VIEW_ID) ?: return - view.post { view.rootWindowInsets?.let(view::onApplyWindowInsets) } + view.post { view.requestApplyInsets() } } } diff --git a/android/gradle.properties b/android/gradle.properties index 1551eb0..440f99f 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -5,3 +5,5 @@ android.enableJetifier=true android.builtInKotlin=false # This newDsl flag was added automatically by Flutter migrator android.newDsl=false +# Leaves proprietary Google Play services out of the location plugin +location.playServices=false diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index b59bc94..f07087d 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -23,4 +23,16 @@ plugins { id("org.jetbrains.kotlin.android") version "2.4.10" apply false } -include(":app") \ No newline at end of file +include(":app") + +// Flutter's plugin loader includes dev dependency plugins like integration_test as projects even in +// release builds (where they're never linked in). integration_test lives in the Flutter SDK, which +// is read-only under Nix, and Gradle 9+ refuses to configure a project whose directory isn't writable. +findProject(":integration_test")?.let { project -> + if (!project.projectDir.canWrite()) { + val copy = file("../build/integration_test_android") + copy.deleteRecursively() + project.projectDir.copyRecursively(copy) + project.projectDir = copy + } +} \ No newline at end of file diff --git a/assets/bundled/federated_nexus.svg b/assets/bundled/federated_nexus.svg new file mode 100644 index 0000000..0effd9a --- /dev/null +++ b/assets/bundled/federated_nexus.svg @@ -0,0 +1,150 @@ + + + + diff --git a/assets/bundled/matrix.svg b/assets/bundled/matrix.svg new file mode 100644 index 0000000..bfe705e --- /dev/null +++ b/assets/bundled/matrix.svg @@ -0,0 +1,11 @@ + + + + + diff --git a/assets/screenshotDark.png b/assets/screenshotDark.png deleted file mode 100644 index 48be6e5..0000000 Binary files a/assets/screenshotDark.png and /dev/null differ diff --git a/assets/screenshotLight.png b/assets/screenshotLight.png deleted file mode 100644 index 5aae7a0..0000000 Binary files a/assets/screenshotLight.png and /dev/null differ diff --git a/assets/screenshots/desktop-dark.png b/assets/screenshots/desktop-dark.png new file mode 100644 index 0000000..e9753bd Binary files /dev/null and b/assets/screenshots/desktop-dark.png differ diff --git a/assets/screenshots/desktop-light.png b/assets/screenshots/desktop-light.png new file mode 100644 index 0000000..2d5c876 Binary files /dev/null and b/assets/screenshots/desktop-light.png differ diff --git a/fastlane/metadata/android/en-US/full_description.txt b/fastlane/metadata/android/en-US/full_description.txt new file mode 100644 index 0000000..e310d29 --- /dev/null +++ b/fastlane/metadata/android/en-US/full_description.txt @@ -0,0 +1,10 @@ +

Nexus is a simple and user-friendly client for Matrix, the open and decentralized chat network. It's made with Flutter, with gomuks handling the Matrix side.

+ +

Features include:

+
    +
  • Spaces, threads, replies and reactions
  • +
  • End-to-end encryption, with verification and recovery keys
  • +
  • Polls, location sharing, and custom emoji and sticker packs
  • +
  • Multiple accounts
  • +
  • Notifications through UnifiedPush, or Firebase Cloud Messaging
  • +
diff --git a/fastlane/metadata/android/en-US/images/icon.png b/fastlane/metadata/android/en-US/images/icon.png new file mode 100644 index 0000000..6b1b81c Binary files /dev/null and b/fastlane/metadata/android/en-US/images/icon.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png new file mode 100644 index 0000000..c6688a0 Binary files /dev/null and b/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png new file mode 100644 index 0000000..1d4ff07 Binary files /dev/null and b/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png new file mode 100644 index 0000000..f969bf1 Binary files /dev/null and b/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png new file mode 100644 index 0000000..82915b6 Binary files /dev/null and b/fastlane/metadata/android/en-US/images/phoneScreenshots/4.png differ diff --git a/fastlane/metadata/android/en-US/short_description.txt b/fastlane/metadata/android/en-US/short_description.txt new file mode 100644 index 0000000..570387a --- /dev/null +++ b/fastlane/metadata/android/en-US/short_description.txt @@ -0,0 +1 @@ +A simple and user-friendly Matrix client diff --git a/fastlane/metadata/android/en-US/title.txt b/fastlane/metadata/android/en-US/title.txt new file mode 100644 index 0000000..755a6d7 --- /dev/null +++ b/fastlane/metadata/android/en-US/title.txt @@ -0,0 +1 @@ +Nexus diff --git a/flake.lock b/flake.lock index db5f957..b6443af 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,102 @@ { "nodes": { + "advisory-db": { + "flake": false, + "locked": { + "lastModified": 1793979272, + "narHash": "sha256-oUcBtPbtS7PlEMuSrgTAN4wv49cXYbwKbQqhH2pah5w=", + "owner": "rustsec", + "repo": "advisory-db", + "rev": "309392b18f6b17022f82c701f300433126901068", + "type": "github" + }, + "original": { + "owner": "rustsec", + "repo": "advisory-db", + "type": "github" + } + }, + "continuwuity": { + "inputs": { + "advisory-db": "advisory-db", + "crane": "crane", + "fenix": "fenix", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs" + ], + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1794436491, + "narHash": "sha256-1Gbe5ys68lljaWtwn8Z4RhkUnWDfw8AaHQJDKVzzmVA=", + "ref": "ea3beb628a3cab6fbc4142b725c9edb043846eb6", + "rev": "ea3beb628a3cab6fbc4142b725c9edb043846eb6", + "revCount": 8146, + "type": "git", + "url": "https://forgejo.ellis.link/Continuwuation/Continuwuity" + }, + "original": { + "ref": "ea3beb628a3cab6fbc4142b725c9edb043846eb6", + "type": "git", + "url": "https://forgejo.ellis.link/Continuwuation/Continuwuity" + } + }, + "crane": { + "locked": { + "lastModified": 1793836618, + "narHash": "sha256-TREenflwEjxOSq292FYwbc3kEm7TDRtXCZRNWEdjBmg=", + "owner": "ipetkov", + "repo": "crane", + "rev": "79fd63528501446749c09f08cad486a58c7d173e", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "continuwuity", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1794142885, + "narHash": "sha256-xWFSr7q8IerDAVRk4W7/CgTmi05hMy2qjZ0z3VYpOVk=", + "owner": "nix-community", + "repo": "fenix", + "rev": "f7d416b5073152c7f2e4de1a28d1a4330dd30a26", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "edolstra", + "ref": "master", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -18,6 +115,24 @@ "type": "github" } }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1793576659, + "narHash": "sha256-V1h85lUaJBQoHFrB2vpXZOE0Ju1MYSnIpsehoVZYlDo=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "ea2630b7470978622c7689a1ff75d2b389175399", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -39,7 +154,9 @@ "nix2flatpak": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1791751882, @@ -57,15 +174,15 @@ }, "nixpkgs": { "locked": { - "lastModified": 1773389992, - "narHash": "sha256-wvfdLLWJ2I9oEpDd9PfMA8osfIZicoQ5MT1jIwNs9Tk=", - "owner": "NixOS", + "lastModified": 1793540411, + "narHash": "sha256-fiPJ88izTVucjeo2EQ3jk4aWmLg03I1D4vxnX2QjEgE=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "c06b4ae3d6599a672a6210b7021d699c351eebda", + "rev": "0bb2eedc20e4739f29e8045034f2828ad7054f8f", "type": "github" }, "original": { - "owner": "NixOS", + "owner": "nixos", "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" @@ -86,27 +203,44 @@ "type": "github" } }, - "nixpkgs_2": { + "nixpkgs-lib_2": { "locked": { - "lastModified": 1793540411, - "narHash": "sha256-fiPJ88izTVucjeo2EQ3jk4aWmLg03I1D4vxnX2QjEgE=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "0bb2eedc20e4739f29e8045034f2828ad7054f8f", + "lastModified": 1793504054, + "narHash": "sha256-ThkfL3D/FhCiZFc9+3BtxwuMmpuK+/bGtXCSo1+yVew=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "7851ba61fd862b277cb6a9cef37394bc18bb94e4", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", + "owner": "nix-community", + "repo": "nixpkgs.lib", "type": "github" } }, "root": { "inputs": { - "flake-parts": "flake-parts", + "continuwuity": "continuwuity", + "flake-parts": "flake-parts_2", "nix2flatpak": "nix2flatpak", - "nixpkgs": "nixpkgs_2" + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1794096810, + "narHash": "sha256-dWC+YtMX+cwH3e9ndiFB77ijTsKtO5I2OxfcvUY4j3k=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "03ae6be57aa063bb373f69eead3b8e15168a45d2", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" } }, "systems": { @@ -123,6 +257,27 @@ "repo": "default", "type": "github" } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "continuwuity", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1791885023, + "narHash": "sha256-C3alQ2MEt0zVrUSho5NUDo3jmhbff72++bfwoqT9Omo=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "0d6d739a833ba9a9c93034862e4a7b061a062a1c", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index e4cae8a..2ee3373 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,15 @@ self.submodules = true; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; - nix2flatpak.url = "github:neobrain/nix2flatpak"; + nix2flatpak = { + url = "github:neobrain/nix2flatpak"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + # TEMPORARY: the e2e tests against Continuwuity from the forge, till there's a new full release in nixpkgs + continuwuity = { + url = "git+https://forgejo.ellis.link/Continuwuation/Continuwuity?ref=ea3beb628a3cab6fbc4142b725c9edb043846eb6"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = diff --git a/gomuks b/gomuks index 46ab9e9..2a76e97 160000 --- a/gomuks +++ b/gomuks @@ -1 +1 @@ -Subproject commit 46ab9e9afa54c12f585cbbf559c395b9c2dcb545 +Subproject commit 2a76e97eb3e955ec14775ce4027ed446865ed7fa diff --git a/hook/build.dart b/hook/build.dart index 8726642..2181e8a 100644 --- a/hook/build.dart +++ b/hook/build.dart @@ -64,10 +64,14 @@ Future main(List args) => build(args, (input, output) async { final targetNdkApi = codeConfig.android.targetNdkApi; + // Treats empty variables as unset, since e.g. F-Droid sets ANDROID_NDK_HOME to "" without an NDK + String? env(String name) => switch (Platform.environment[name]) { + "" => null, + final value => value, + }; + Future findNdkFromSdk() async { - final androidHome = - Platform.environment["ANDROID_HOME"] ?? - Platform.environment["ANDROID_SDK_ROOT"]; + final androidHome = env("ANDROID_HOME") ?? env("ANDROID_SDK_ROOT"); if (androidHome == null) return null; final ndkDir = Directory(join(androidHome, "ndk")); @@ -78,9 +82,9 @@ Future main(List args) => build(args, (input, output) async { } final ndkHome = - Platform.environment["ANDROID_NDK_HOME"] ?? - Platform.environment["ANDROID_NDK_ROOT"] ?? - Platform.environment["NDK_HOME"] ?? + env("ANDROID_NDK_HOME") ?? + env("ANDROID_NDK_ROOT") ?? + env("NDK_HOME") ?? await findNdkFromSdk(); if (ndkHome == null) { @@ -91,8 +95,7 @@ Future main(List args) => build(args, (input, output) async { // TODO: Someone please give me a way to detect host architecture so I can change this final hostTag = - Platform.environment["ANDROID_HOST_TAG"] ?? - "${Platform.operatingSystem}-x86_64"; + env("ANDROID_HOST_TAG") ?? "${Platform.operatingSystem}-x86_64"; final ccTriple = switch (targetArch) { Architecture.arm64 => "aarch64-linux-android", Architecture.arm => "armv7a-linux-androideabi", @@ -120,7 +123,6 @@ Future main(List args) => build(args, (input, output) async { final tags = [ "sqlite_fts5", - "goolm", // goheif/dav1d is not supported on Android or iOS, would need to be fixed upstream "noheic", ].join(","); diff --git a/integration_test/helpers/fakes.dart b/integration_test/helpers/fakes.dart new file mode 100644 index 0000000..050eb99 --- /dev/null +++ b/integration_test/helpers/fakes.dart @@ -0,0 +1,47 @@ +import "dart:async"; + +import "package:app_links_platform_interface/app_links_platform_interface.dart"; +import "package:url_launcher_platform_interface/link.dart"; +import "package:url_launcher_platform_interface/url_launcher_platform_interface.dart"; + +/// Delivers links to the app as if the OS had opened them. +class FakeAppLinks extends AppLinksPlatform { + final _links = StreamController.broadcast(); + + void open(Uri uri) => _links.add(uri); + + @override + Future getInitialLink() async => null; + + @override + Future getInitialLinkString() async => null; + + @override + Future getLatestLink() async => null; + + @override + Future getLatestLinkString() async => null; + + @override + Stream get uriLinkStream => _links.stream; + + @override + Stream get stringLinkStream => + _links.stream.map((uri) => uri.toString()); +} + +/// Hands launched URLs to [onLaunch] instead of opening a browser. +class FakeUrlLauncher(final void Function(Uri url) onLaunch) + extends UrlLauncherPlatform { + @override + LinkDelegate? get linkDelegate => null; + + @override + Future canLaunch(String url) async => true; + + @override + Future launchUrl(String url, LaunchOptions options) async { + onLaunch(.parse(url)); + return true; + } +} diff --git a/integration_test/helpers/matrix_user.dart b/integration_test/helpers/matrix_user.dart new file mode 100644 index 0000000..bd2692c --- /dev/null +++ b/integration_test/helpers/matrix_user.dart @@ -0,0 +1,174 @@ +import "dart:convert"; + +import "package:fast_immutable_collections/fast_immutable_collections.dart"; +import "package:http/http.dart" as http; + +const homeserver = String.fromEnvironment("NEXUS_E2E_HOMESERVER"); + +/// A user acting over the client-server API directly, as a control for the +/// tests: it doesn't go through gomuks or any other Nexus code, so it sets +/// things up and checks the server's side independently of what's being +/// tested. That includes Nexus' models, so the JSON it sends is written out +/// here rather than built the way Nexus builds it. +class const MatrixUser(final String userId, final String accessToken) { + static Future login(String username, String password) async { + final json = await request( + "POST", + "/_matrix/client/v3/login", + body: { + "type": "m.login.password", + "identifier": {"type": "m.id.user", "user": username}, + "password": password, + }, + ); + return MatrixUser(json["user_id"], json["access_token"]); + } + + static Future> request( + String method, + String path, { + String? accessToken, + Object? body, + }) async { + final httpRequest = + http.Request(method, Uri.parse(homeserver).resolve(path)) + ..headers.addAll({ + "Content-Type": "application/json", + if (accessToken != null) "Authorization": "Bearer $accessToken", + }); + if (method != "GET") httpRequest.body = jsonEncode(body ?? {}); + final response = await http.Response.fromStream(await httpRequest.send()); + + if (response.statusCode == 429) { + final retryAfter = jsonDecode(response.body)["retry_after_ms"] ?? 1000; + await Future.delayed(.new(milliseconds: retryAfter)); + return request(method, path, accessToken: accessToken, body: body); + } + if (response.statusCode >= 300) { + throw StateError( + "$method $path failed with ${response.statusCode}: ${response.body}", + ); + } + return jsonDecode(response.body); + } + + Future createRoom(String name) async => (await request( + "POST", + "/_matrix/client/v3/createRoom", + accessToken: accessToken, + body: {"name": name, "preset": "private_chat"}, + ))["room_id"]; + + Future invite(String roomId, String userId) => request( + "POST", + "/_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/invite", + accessToken: accessToken, + body: {"user_id": userId}, + ); + + Future join(String roomId) => request( + "POST", + "/_matrix/client/v3/join/${Uri.encodeComponent(roomId)}", + accessToken: accessToken, + ); + + Future logout() => + request("POST", "/_matrix/client/v3/logout", accessToken: accessToken); + + Future sendEvent( + String roomId, + String type, + Map content, + ) async => (await request( + "PUT", + "/_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/send/$type/" + "${DateTime.now().microsecondsSinceEpoch}", + accessToken: accessToken, + body: content, + ))["event_id"]; + + /// Sends a text message. With [threadRoot] it's a reply in that thread, and + /// otherwise with [replyTo] it's a reply to that event. + Future send( + String roomId, + String body, { + String? threadRoot, + String? replyTo, + }) => sendEvent(roomId, "m.room.message", { + "msgtype": "m.text", + "body": body, + "m.relates_to": ?switch ((threadRoot, replyTo)) { + (final threadRoot?, _) => { + "rel_type": "m.thread", + "event_id": threadRoot, + "is_falling_back": true, + "m.in_reply_to": {"event_id": threadRoot}, + }, + (null, final replyTo?) => { + "m.in_reply_to": {"event_id": replyTo}, + }, + (null, null) => null, + }, + }); + + /// Sends [rootBody], then [replies] in a thread from it, oldest first. + Future<({String rootId, IList replyIds})> sendThread( + String roomId, + String rootBody, + IList replies, + ) async { + final rootId = await send(roomId, rootBody); + // One at a time, so they're in order (oops earlier tests weren't reproducable) + final replyIds = await Stream.fromIterable(replies) + .asyncMap((body) => send(roomId, body, threadRoot: rootId)) + .toList(); + return (rootId: rootId, replyIds: replyIds.toIList()); + } + + /// Edits the text message [eventId] to say [body]. + Future edit(String roomId, String eventId, String body) => + sendEvent(roomId, "m.room.message", { + "msgtype": "m.text", + "body": "* $body", + "m.new_content": {"msgtype": "m.text", "body": body}, + "m.relates_to": {"rel_type": "m.replace", "event_id": eventId}, + }); + + Future redact(String roomId, String eventId) => request( + "PUT", + "/_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/redact/" + "${Uri.encodeComponent(eventId)}/${DateTime.now().microsecondsSinceEpoch}", + accessToken: accessToken, + ); + + /// The bodies of the replies in the thread from [threadRoot], oldest first. + Future> threadReplies(String roomId, String threadRoot) async { + final json = await request( + "GET", + "/_matrix/client/v1/rooms/${Uri.encodeComponent(roomId)}/relations/" + "${Uri.encodeComponent(threadRoot)}/m.thread?dir=f&limit=100", + accessToken: accessToken, + ); + return (json["chunk"] as List) + .map((event) => event["content"]["body"] as String) + .toIList(); + } + + Future> threadRepliesIncluding( + String roomId, + String threadRoot, + String body, { + int attempts = 20, + }) async { + final replies = await threadReplies(roomId, threadRoot); + if (replies.contains(body) || attempts <= 1) return replies; + + await Future.delayed(const .new(milliseconds: 500)); + return threadRepliesIncluding( + roomId, + threadRoot, + body, + attempts: attempts - 1, + ); + } +} diff --git a/integration_test/helpers/oauth.dart b/integration_test/helpers/oauth.dart new file mode 100644 index 0000000..be652d7 --- /dev/null +++ b/integration_test/helpers/oauth.dart @@ -0,0 +1,68 @@ +import "package:http/http.dart" as http; + +import "fakes.dart"; + +/// Fake platforms that do the browser's part of OAuth on Continuwuity, logging +/// in as [username], then hand the redirect back to Nexus. +class OAuthFakes(final String username, final String password) { + final links = FakeAppLinks(); + late final launcher = FakeUrlLauncher(onLaunch); + + Future onLaunch(Uri url) async { + if (!url.queryParameters.containsKey("code_challenge")) return; + + final redirect = await authorize(url); + // Nexus listens for the redirect after the launch returns + await Future.delayed(const .new(milliseconds: 500)); + links.open(redirect); + } + + /// Logs in on [authorizationUrl], then confirms the grant, returning the URI + /// Continuwuity redirects back to the app with. + Future authorize(Uri authorizationUrl) async { + final client = http.Client(); + String? cookie; + + Future followRedirect( + String method, + Uri url, [ + Map? form, + ]) async { + final request = http.Request(method, url) + ..followRedirects = false + ..headers.addAll({ + // Continuwuity only accepts its forms from top-level navigations + "Sec-Fetch-Site": "same-origin", + "Sec-Fetch-Mode": "navigate", + "Sec-Fetch-Dest": "document", + "Cookie": ?cookie, + }); + if (form != null) request.bodyFields = form; + + final response = await http.Response.fromStream( + await client.send(request), + ); + if (response.headers["set-cookie"] case final setCookie?) { + cookie = setCookie.split(";").first; + } + + return switch ((response.statusCode, response.headers["location"])) { + (302 || 303 || 307, final location?) => url.resolve(location), + (final status, _) => throw StateError( + "Expected $method $url to redirect, got $status: ${response.body}", + ), + }; + } + + try { + final loginUrl = await followRedirect("GET", authorizationUrl); + final grantUrl = await followRedirect("POST", loginUrl, { + "identifier": username, + "password": password, + }); + return await followRedirect("POST", grantUrl, {"stage": "confirm"}); + } finally { + client.close(); + } + } +} diff --git a/integration_test/helpers/pump_until.dart b/integration_test/helpers/pump_until.dart new file mode 100644 index 0000000..95c4944 --- /dev/null +++ b/integration_test/helpers/pump_until.dart @@ -0,0 +1,70 @@ +import "package:fast_immutable_collections/fast_immutable_collections.dart"; +import "package:flutter_test/flutter_test.dart"; +import "package:material_ui/material_ui.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; + +// Custom because `patrol_finder` gives me jQuery vibes, and that's Not GoodTM +extension PumpUntil on WidgetTester { + /// Pumps until [finder] finds something, failing if it doesn't within 30 + /// seconds, or if the app shows an error. + Future pumpUntil(Finder finder) async { + const timeout = Duration(seconds: 30); + + String textsIn(Finder finder) => + widgetList( + find.descendant( + of: finder, + matching: find.byWidgetPredicate( + (widget) => widget is Text || widget is SelectableText, + ), + ), + ) + .map( + (widget) => switch (widget) { + Text(:final data) || SelectableText(:final data) => data, + _ => null, + }, + ) + .nonNulls + .join("\n"); + + final stopwatch = Stopwatch()..start(); + while (stopwatch.elapsed < timeout) { + await pump(const .new(milliseconds: 100)); + + if (finder.evaluate().isNotEmpty) return; + + final errorDialog = find.byType(ErrorDialog); + if (errorDialog.evaluate().isNotEmpty) { + fail( + "The app showed an error while waiting for $finder:\n" + "${textsIn(errorDialog)}", + ); + } + } + + final snackBar = find.byType(SnackBar); + final shown = find + .byType(RichText) + .hitTestable() + .evaluate() + .map((element) => (element.widget as RichText).text.toPlainText()) + .where((text) => text.trim().isNotEmpty) + .toIList() + .removeDuplicates() + .join(" | "); + fail( + "Timed out after $timeout waiting for $finder" + "${snackBar.evaluate().isEmpty ? "" : "\nSnack bar: ${textsIn(snackBar)}"}" + "\nShown: $shown", + ); + } + + /// Taps [finder] once it can be tapped, like after animating in. + Future tapWhenShown(Finder finder) async { + final tappable = finder.hitTestable(); + await pumpUntil(tappable); + await tap(tappable.first); + await pump(); + } +} diff --git a/integration_test/helpers/test_app.dart b/integration_test/helpers/test_app.dart new file mode 100644 index 0000000..27e3027 --- /dev/null +++ b/integration_test/helpers/test_app.dart @@ -0,0 +1,113 @@ +import "package:app_links_platform_interface/app_links_platform_interface.dart"; +import "package:flutter_test/flutter_test.dart"; +import "package:material_ui/material_ui.dart"; +import "package:nexus/controllers/active_account.dart"; +import "package:nexus/main.dart" as nexus; +import "package:nexus/widgets/account_scope.dart"; +import "package:nexus/widgets/pages/chat.dart"; +import "package:nexus/widgets/pages/select_server.dart"; +import "package:nexus/widgets/pages/verify.dart"; +import "package:nexus/widgets/room_chat/room_chat.dart"; +import "package:url_launcher_platform_interface/url_launcher_platform_interface.dart"; + +import "matrix_user.dart"; +import "oauth.dart"; +import "pump_until.dart"; + +/// Nexus, run as the account [username], which is set up through the UI the +/// first time it's opened. +class TestApp(final String username, final String password) { + late final fakes = OAuthFakes(username, password); + + void setUp() { + nexus.isInBackground = false; + AppLinksPlatform.instance = fakes.links; + UrlLauncherPlatform.instance = fakes.launcher; + + // A tap that misses would otherwise only warn + WidgetController.hitTestWarningShouldBeFatal = true; + } + + Future join(MatrixUser inviter, String roomId) async { + final user = await MatrixUser.login(username, password); + await inviter.invite(roomId, user.userId); + await user.join(roomId); + await user.logout(); + } + + /// Starts Nexus like [open], then opens [roomName]. + Future openRoom(WidgetTester tester, String roomName) async { + await open(tester); + await selectRoom(tester, roomName); + } + + /// Taps [roomName] in the room list, opening the drawer it's in first when + /// the window is narrow enough for the mobile layout. + Future selectRoom(WidgetTester tester, String roomName) async { + // Shown once the first sync is done, as is the drawer button on mobile + await tester.pumpUntil(find.byType(RoomChat)); + + final drawerButton = find + .byTooltip(const DefaultMaterialLocalizations().openAppDrawerTooltip) + .hitTestable(); + if (drawerButton.evaluate().isNotEmpty) await tester.tap(drawerButton); + await tester.tapWhenShown(find.text(roomName)); + } + + /// Starts Nexus, logged in and verified, logging in and setting up + /// encryption through the UI first if it isn't. + Future open(WidgetTester tester) async { + await tester.pumpWidget( + AccountScope( + initialAccountId: await ActiveAccountController.stored(), + retry: (_, _) => null, + child: nexus.App(), + ), + ); + + await tester.pumpUntil( + find.byWidgetPredicate( + (widget) => + widget is SelectServerPage || + widget is VerifyPage || + widget is ChatPage, + ), + ); + if (find.byType(SelectServerPage).evaluate().isNotEmpty) { + await logIn(tester); + } + if (find.byType(VerifyPage).evaluate().isNotEmpty) { + await setUpEncryption(tester); + } + await tester.pumpUntil(find.byType(ChatPage)); + } + + Future logIn(WidgetTester tester) async { + final homeserverField = find.widgetWithText(TextField, "Homeserver URL"); + await tester.pumpUntil(homeserverField); + await tester.enterText(homeserverField, homeserver); + await tester.testTextInput.receiveAction(.done); + + // Discovery only uses HTTPS, which the test homeserver doesn't serve, so + // Nexus offers to log in with the URL as typed + await tester.tapWhenShown(find.text("Attempt log in anyways")); + + // Nexus opens the authorization page, which fakes authorizes + await tester.pumpUntil( + find.byWidgetPredicate( + (widget) => widget is VerifyPage || widget is ChatPage, + ), + ); + } + + /// Sets up encryption from the verify page, for an account without it. + Future setUpEncryption(WidgetTester tester) async { + await tester.pumpUntil(find.text("Set Up Encryption")); + await tester.tapWhenShown(find.widgetWithText(TextButton, "Set Up")); + + await tester.tapWhenShown(find.text("I've saved my recovery key")); + await tester.tapWhenShown(find.widgetWithText(TextButton, "Set Up")); + + await tester.tapWhenShown(find.widgetWithText(TextButton, "Done")); + } +} diff --git a/integration_test/helpers/threads.dart b/integration_test/helpers/threads.dart new file mode 100644 index 0000000..d2eee0d --- /dev/null +++ b/integration_test/helpers/threads.dart @@ -0,0 +1,34 @@ +import "package:flutter_test/flutter_test.dart"; +import "package:material_ui/material_ui.dart"; + +import "pump_until.dart"; + +extension MessageFinders on CommonFinders { + Finder message(String body) => textContaining(body, findRichText: true); +} + +extension RelativeFinders on Finder { + Finder inside(Type type) => + find.descendant(of: find.byType(type), matching: this); + + /// The [InkWell] ancestor around what this finds + Finder get inkWell => find.ancestor(of: this, matching: find.byType(InkWell)); +} + +extension ReplyCounts on WidgetTester { + /// Waits for a reply count in widgets of [type], then checks it, so a wrong + /// count fails straight away with what was shown. + Future expectReplyCount(Type type, int expected) async { + final repliesLabel = RegExp(r"^(\d+) repl(?:y|ies)$"); + final labels = find.textContaining(repliesLabel).inside(type); + await pumpUntil(labels); + + final shown = widgetList(labels) + .map((label) => label.data) + .nonNulls + .map(repliesLabel.firstMatch) + .nonNulls + .map((match) => int.parse(match[1]!)); + expect(shown, everyElement(expected), reason: "Reply count in $type"); + } +} diff --git a/integration_test/links_test.dart b/integration_test/links_test.dart new file mode 100644 index 0000000..4137fff --- /dev/null +++ b/integration_test/links_test.dart @@ -0,0 +1,56 @@ +import "package:flutter_test/flutter_test.dart"; +import "package:integration_test/integration_test.dart"; +import "package:nexus/widgets/room_chat/room_chat.dart"; +import "package:nexus/widgets/rooms/room_summary_sheet.dart"; +import "package:nexus/widgets/users/user_bottom_sheet.dart"; + +import "helpers/matrix_user.dart"; +import "helpers/test_app.dart"; +import "helpers/pump_until.dart"; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + final app = TestApp("dave", "davepass"); + setUpAll(app.setUp); + final run = DateTime.now().millisecondsSinceEpoch; + Future bob() => MatrixUser.login("bob", "bobpass"); + + Future openLink(WidgetTester tester, String link) async { + await app.open(tester); + app.fakes.links.open(.parse(link)); + } + + group("a link opened by the OS", () { + testWidgets("to a user opens their popover", (tester) async { + await openLink(tester, "matrix:u/bob:localhost"); + + await tester.pumpUntil(find.byType(UserBottomSheet)); + }); + + testWidgets("to a joined room opens it", (tester) async { + final inviter = await bob(); + final roomId = await inviter.createRoom("Linked $run"); + // Joined before Nexus starts, so the room is there once it syncs + await app.join(inviter, roomId); + + await openLink(tester, "matrix:roomid/${roomId.substring(1)}"); + + await tester.pumpUntil( + find.byWidgetPredicate( + (widget) => widget is RoomChat && widget.roomId == roomId, + ), + ); + }); + + testWidgets("to a room that isn't joined shows its summary", ( + tester, + ) async { + final roomId = await (await bob()).createRoom("Unjoined $run"); + + await openLink(tester, "matrix:roomid/${roomId.substring(1)}"); + + await tester.pumpUntil(find.byType(RoomSummarySheet)); + }); + }); +} diff --git a/integration_test/long_thread_test.dart b/integration_test/long_thread_test.dart new file mode 100644 index 0000000..49e450a --- /dev/null +++ b/integration_test/long_thread_test.dart @@ -0,0 +1,115 @@ +import "package:fast_immutable_collections/fast_immutable_collections.dart"; +import "package:flutter_test/flutter_test.dart"; +import "package:integration_test/integration_test.dart"; +import "package:material_ui/material_ui.dart"; +import "package:nexus/widgets/room_chat/room_chat.dart"; +import "package:nexus/widgets/threads/thread_drawer.dart"; +import "package:nexus/widgets/threads/threads_drawer.dart"; + +import "helpers/matrix_user.dart"; +import "helpers/test_app.dart"; +import "helpers/pump_until.dart"; +import "helpers/threads.dart"; + +/// A thread longer than gomuks' initial sync, which gets the latest 100 +/// events, so its start only reaches Nexus through `/relations`. That needs +/// an account whose first sync is after the thread exists, so it's not the one +/// other tests use. +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + final app = TestApp("carol", "carolpass"); + setUpAll(app.setUp); + final run = DateTime.now().millisecondsSinceEpoch; + final roomName = "Long thread $run"; + final rootBody = "Long thread root $run"; + const replyCount = 120; + // Among the first replies, which aren't synced + const jumpedTo = 10; + // Padded, so no reply's text contains another's (oops those failures were confusing when I didn't do that) + String reply(int number) => "Long reply ${number.toString().padLeft(3, "0")}"; + + setUpAll(() async { + final bob = await MatrixUser.login("bob", "bobpass"); + final roomId = await bob.createRoom(roomName); + await app.join(bob, roomId); + + final thread = await bob.sendThread( + roomId, + rootBody, + Iterable.generate(replyCount, (index) => reply(index + 1)).toIList(), + ); + // In the room's timeline, so there's something to jump from, to a reply + // with others on both sides that aren't synced either + await bob.send( + roomId, + "Quoting an old reply", + replyTo: thread.replyIds[jumpedTo - 1], + ); + }); + + /// Drags the open thread by [offset] until [finder] is shown in it, loading + /// more replies as it goes, for up to 30 seconds. + Future scrollThread( + WidgetTester tester, + Finder finder, + Offset offset, + ) => tester.dragUntilVisible( + finder.inside(ThreadDrawer), + find.byType(CustomScrollView).inside(ThreadDrawer).first, + offset, + maxIteration: 60, + duration: const .new(milliseconds: 500), + ); + + Future openThreadsDrawer(WidgetTester tester) async { + await app.openRoom(tester, roomName); + await tester.tapWhenShown(find.byTooltip("Open threads")); + await tester.pumpUntil(find.message(rootBody).inside(ThreadsDrawer)); + } + + testWidgets("lists the thread with all of its replies", (tester) async { + await openThreadsDrawer(tester); + + await tester.expectReplyCount(ThreadsDrawer, replyCount); + }); + + // Before the whole thread is loaded by scrolling through it below + testWidgets("jumps to a reply in the thread that isn't loaded", ( + tester, + ) async { + await app.openRoom(tester, roomName); + + // The quote of the reply is fetched on its own, then tapped + await tester.tapWhenShown( + find.message(reply(jumpedTo)).inside(RoomChat).inkWell, + ); + + // The thread opens around the reply, with replies on both sides + await tester.pumpUntil( + find.message(reply(jumpedTo)).inside(ThreadDrawer).hitTestable(), + ); + await tester.pumpUntil( + find.message(reply(jumpedTo - 1)).inside(ThreadDrawer), + ); + await tester.pumpUntil( + find.message(reply(jumpedTo + 1)).inside(ThreadDrawer), + ); + + await scrollThread(tester, find.message(reply(60)), const .new(0, -400)); + }); + + testWidgets("loads older replies back to the root", (tester) async { + await openThreadsDrawer(tester); + await tester.tapWhenShown( + find.message(rootBody).inside(ThreadsDrawer).inkWell, + ); + await tester.pumpUntil( + find.message(reply(replyCount)).inside(ThreadDrawer), + ); + + // Dragging down scrolls up the reversed timeline, to older replies + await scrollThread(tester, find.message(rootBody), const .new(0, 400)); + expect(find.message(reply(1)).inside(ThreadDrawer), findsWidgets); + }); +} diff --git a/integration_test/screenshots/avatars/SOURCES.md b/integration_test/screenshots/avatars/SOURCES.md new file mode 100644 index 0000000..e6094db --- /dev/null +++ b/integration_test/screenshots/avatars/SOURCES.md @@ -0,0 +1,22 @@ +# Screenshot avatars + +Avatars for the people, rooms and spaces in the screenshots, cropped from photos on Wikimedia Commons and Public Domain Pictures that are in the public domain or CC0, so they need no attribution. + +| File | License | Source | +| ---------------------- | ------------- | -------------------------------------------------------------------------------------------------------- | +| pumpkin.webp | Public domain | https://commons.wikimedia.org/wiki/File:Cucurbita_2011_G1.jpg | +| orange.webp | Public domain | https://commons.wikimedia.org/wiki/File:Orange-fruit-2.jpg | +| log-1.webp | CC0 | https://commons.wikimedia.org/wiki/File:Tabby_cat_with_blue_eyes-3336579.jpg (tinted green) | +| strudel.webp | CC0 | https://commons.wikimedia.org/wiki/File:Strudel-de-maca-2.png | +| opal.webp | Public domain | https://commons.wikimedia.org/wiki/File:Opal_6.jpg | +| cinnamon.webp | CC0 | https://commons.wikimedia.org/wiki/File:Cassia_bark_(2).jpg | +| green-tea.webp | CC0 | https://www.publicdomainpictures.net/en/view-image.php?image=165622&picture=hot-green-tea-with-heart-art | +| development.webp | CC0 | https://commons.wikimedia.org/wiki/File:Code_on_computer_monitor_(Unsplash).jpg | +| fediverse.webp | Public domain | https://commons.wikimedia.org/wiki/File:Blackeyegalaxy.jpg | +| flutter-devs.webp | CC0 | https://commons.wikimedia.org/wiki/File:Anna%27s_Hummingbird_Feeding.jpg | +| linux-mobile.webp | CC0 | https://commons.wikimedia.org/wiki/File:Gentoo_penguin_with_a_feather_in_its_beak.jpg | +| matrix-community.webp | Public domain | https://commons.wikimedia.org/wiki/File:Earth_at_Night,_Asia_(8270740728).jpg | +| off-topic.webp | CC0 | https://commons.wikimedia.org/wiki/File:Coffee_cup_surrounded_by_coffee_beans.jpg | +| open-source-games.webp | Public domain | https://commons.wikimedia.org/wiki/File:LodgeNet-Nintendo-N64-Controller.jpg | +| rust.webp | CC0 | https://commons.wikimedia.org/wiki/File:Carcinus_maenas_146434844.jpg | +| self-hosting.webp | CC0 | https://commons.wikimedia.org/wiki/File:Legrand_S.A._server_rack.jpg | diff --git a/integration_test/screenshots/avatars/cinnamon.webp b/integration_test/screenshots/avatars/cinnamon.webp new file mode 100644 index 0000000..8520f24 Binary files /dev/null and b/integration_test/screenshots/avatars/cinnamon.webp differ diff --git a/integration_test/screenshots/avatars/development.webp b/integration_test/screenshots/avatars/development.webp new file mode 100644 index 0000000..21a47b1 Binary files /dev/null and b/integration_test/screenshots/avatars/development.webp differ diff --git a/integration_test/screenshots/avatars/fediverse.webp b/integration_test/screenshots/avatars/fediverse.webp new file mode 100644 index 0000000..8952d99 Binary files /dev/null and b/integration_test/screenshots/avatars/fediverse.webp differ diff --git a/integration_test/screenshots/avatars/flutter-devs.webp b/integration_test/screenshots/avatars/flutter-devs.webp new file mode 100644 index 0000000..79634a2 Binary files /dev/null and b/integration_test/screenshots/avatars/flutter-devs.webp differ diff --git a/integration_test/screenshots/avatars/green-tea.webp b/integration_test/screenshots/avatars/green-tea.webp new file mode 100644 index 0000000..d58801c Binary files /dev/null and b/integration_test/screenshots/avatars/green-tea.webp differ diff --git a/integration_test/screenshots/avatars/linux-mobile.webp b/integration_test/screenshots/avatars/linux-mobile.webp new file mode 100644 index 0000000..8a525bd Binary files /dev/null and b/integration_test/screenshots/avatars/linux-mobile.webp differ diff --git a/integration_test/screenshots/avatars/log-1.webp b/integration_test/screenshots/avatars/log-1.webp new file mode 100644 index 0000000..e954d0c Binary files /dev/null and b/integration_test/screenshots/avatars/log-1.webp differ diff --git a/integration_test/screenshots/avatars/matrix-community.webp b/integration_test/screenshots/avatars/matrix-community.webp new file mode 100644 index 0000000..2e58828 Binary files /dev/null and b/integration_test/screenshots/avatars/matrix-community.webp differ diff --git a/integration_test/screenshots/avatars/off-topic.webp b/integration_test/screenshots/avatars/off-topic.webp new file mode 100644 index 0000000..ea9ec17 Binary files /dev/null and b/integration_test/screenshots/avatars/off-topic.webp differ diff --git a/integration_test/screenshots/avatars/opal.webp b/integration_test/screenshots/avatars/opal.webp new file mode 100644 index 0000000..807223f Binary files /dev/null and b/integration_test/screenshots/avatars/opal.webp differ diff --git a/integration_test/screenshots/avatars/open-source-games.webp b/integration_test/screenshots/avatars/open-source-games.webp new file mode 100644 index 0000000..3b92ac7 Binary files /dev/null and b/integration_test/screenshots/avatars/open-source-games.webp differ diff --git a/integration_test/screenshots/avatars/orange.webp b/integration_test/screenshots/avatars/orange.webp new file mode 100644 index 0000000..1f9c199 Binary files /dev/null and b/integration_test/screenshots/avatars/orange.webp differ diff --git a/integration_test/screenshots/avatars/pumpkin.webp b/integration_test/screenshots/avatars/pumpkin.webp new file mode 100644 index 0000000..d300ec9 Binary files /dev/null and b/integration_test/screenshots/avatars/pumpkin.webp differ diff --git a/integration_test/screenshots/avatars/quadradical.webp b/integration_test/screenshots/avatars/quadradical.webp new file mode 100644 index 0000000..79e26c1 Binary files /dev/null and b/integration_test/screenshots/avatars/quadradical.webp differ diff --git a/integration_test/screenshots/avatars/rust.webp b/integration_test/screenshots/avatars/rust.webp new file mode 100644 index 0000000..5089187 Binary files /dev/null and b/integration_test/screenshots/avatars/rust.webp differ diff --git a/integration_test/screenshots/avatars/self-hosting.webp b/integration_test/screenshots/avatars/self-hosting.webp new file mode 100644 index 0000000..30535e9 Binary files /dev/null and b/integration_test/screenshots/avatars/self-hosting.webp differ diff --git a/integration_test/screenshots/avatars/strudel.webp b/integration_test/screenshots/avatars/strudel.webp new file mode 100644 index 0000000..e69e842 Binary files /dev/null and b/integration_test/screenshots/avatars/strudel.webp differ diff --git a/integration_test/screenshots/screenshot_data.dart b/integration_test/screenshots/screenshot_data.dart new file mode 100644 index 0000000..fbabe4b --- /dev/null +++ b/integration_test/screenshots/screenshot_data.dart @@ -0,0 +1,365 @@ +import "dart:convert"; + +import "package:collection/collection.dart"; +import "package:fast_immutable_collections/fast_immutable_collections.dart"; +import "package:nexus/models/client_state.dart"; +import "package:nexus/models/room.dart"; +import "package:nexus/models/space_edge.dart"; + +/// What the screenshots show: the Nexus space, with its room mid-conversation. +/// Rooms are written as gomuks reports them. +class ScreenshotData(final DateTime now) { + static const me = "@quadradical:federated.nexus"; + static const bot = "@nexusbot:federated.nexus"; + static const alice = "@alice:example.org"; + static const pumpkin = "@pumpkin:example.org"; + static const strudel = "@strudel:example.org"; + static const opal = "@opal:example.org"; + static const greenTea = "@greentea:example.org"; + + static const nexusSpace = "!nexus-space:federated.nexus"; + static const nexusRoom = "!nexus-client:federated.nexus"; + + /// Nexus' own avatar, the app icon. Every other `mxc://screenshots/` is + /// a file in avatars/, see avatars/SOURCES.md. + static const nexusAvatar = "mxc://screenshots/nexus"; + static const myAvatar = "mxc://screenshots/quadradical.webp"; + static const issueUrl = "https://git.federated.nexus/Nexus/nexus/issues/174"; + static const commitUrl = + "https://git.federated.nexus/Nexus/nexus/commit/41f5225420"; + + static const topic = + "A simple and user-friendly Matrix client made with Flutter and a Gomuks backend."; + + /// The users shown, with their power level in the Nexus room. Those without + /// an avatar get Nexus' fallback. Everyone but QuadRadical and NexusBot is + /// made up, on example.org so as not to be anyone real. + static const users = IListConst([ + (id: me, name: "QuadRadical", powerLevel: 100, avatar: myAvatar), + (id: alice, name: "Alice", powerLevel: 100, avatar: null), + (id: bot, name: "NexusBot", powerLevel: 50, avatar: nexusAvatar), + ( + id: pumpkin, + name: "Pumpkin", + powerLevel: 0, + avatar: "mxc://screenshots/pumpkin.webp", + ), + ( + id: strudel, + name: "Strudel", + powerLevel: 0, + avatar: "mxc://screenshots/strudel.webp", + ), + ( + id: opal, + name: "Opal", + powerLevel: 0, + avatar: "mxc://screenshots/opal.webp", + ), + ( + id: "@orange:example.org", + name: "Orange", + powerLevel: 0, + avatar: "mxc://screenshots/orange.webp", + ), + ( + id: "@log1:example.org", + name: "log(1)", + powerLevel: 0, + avatar: "mxc://screenshots/log-1.webp", + ), + ( + id: greenTea, + name: "Green Tea", + powerLevel: 0, + avatar: "mxc://screenshots/green-tea.webp", + ), + ( + id: "@cinnamon:example.org", + name: "Cinnamon", + powerLevel: 0, + avatar: "mxc://screenshots/cinnamon.webp", + ), + ]); + + /// The Nexus space's other rooms + static const otherRooms = IListConst([ + (name: "Off-topic", unread: 3), + (name: "Development", unread: 0), + ]); + + /// Spaces shown in the rail besides Nexus, so it doesn't look empty + static const otherSpaces = IListConst([ + "Matrix Community", + "Flutter Devs", + "Linux Mobile", + "Rust", + "Open Source Games", + "Fediverse", + "Self-Hosting", + ]); + + static const clientState = ClientState( + isInitialized: true, + isLoggedIn: true, + isVerified: true, + userId: me, + deviceId: "SCREENSHOTS", + homeserverUrl: "https://federated.nexus", + ); + + static final IList topLevelSpaces = .new([ + nexusSpace, + ...otherSpaces.map(_roomId), + ]); + + static final IMap> spaceEdges = .new({ + nexusSpace: .new( + [ + nexusRoom, + ...otherRooms.map((room) => _roomId(room.name)), + ].map((id) => .new(childId: id)), + ), + }); + + /// The rooms, with the Nexus room's state already fetched so it isn't + /// requested + late final IMap rooms = { + nexusSpace: _room(nexusSpace, "Nexus Client", topic: topic), + nexusRoom: _room( + nexusRoom, + "Nexus Client", + topic: topic, + lastEvent: timeline.last, + extra: { + "timeline": timeline + .map( + (event) => { + "timeline_rowid": event["rowid"], + "event_rowid": event["rowid"], + }, + ) + .toList(), + "events": [...nexusState, ...timeline], + "state": _stateIndex(nexusState), + "receipts": { + timeline.last["event_id"]: [ + _receipt(strudel, timeline.last), + _receipt(greenTea, timeline.last), + ], + timeline[timeline.length - 2]["event_id"]: [ + _receipt(opal, timeline[timeline.length - 2]), + ], + }, + "has_more": false, + }, + ).copyWith(hasFetchedState: true, hasFetchedMembers: true), + for (final room in otherRooms) + _roomId(room.name): _room( + _roomId(room.name), + room.name, + avatar: _avatarOfRoom(room.name), + unread: room.unread, + ), + for (final space in otherSpaces) + _roomId(space): _room( + _roomId(space), + space, + avatar: _avatarOfRoom(space), + ), + }.lock; + + /// The Nexus room's state: who's in it, and their power levels + late final List> nexusState = [ + _event(me, "m.room.power_levels", { + "users": Map.fromEntries( + users.map((user) => .new(user.id, user.powerLevel)), + ), + "users_default": 0, + "events_default": 0, + "state_default": 50, + }, key: ""), + ...users.map( + (user) => _event(user.id, "m.room.member", { + "membership": "join", + "displayname": user.name, + "avatar_url": ?user.avatar, + }, key: user.id), + ), + ]; + + late final List> timeline = [ + _message( + alice, + 35, + "the screenshots in the readme are pretty out of date btw", + ), + _message( + me, + 32, + "Should I:\n" + "1. just take screenshots on a few devices, and redo them whenever the " + "UI changes\n" + "or\n" + "2. overengineer a test that makes them automatically, in a fake room\n" + "I think the answer is 2 :p", + html: + "Should I:" + "
  1. just take screenshots on a few devices, and redo them " + "whenever the UI changes
" + "or" + '
  1. overengineer a test that makes them ' + "automatically, in a fake room
" + "I think the answer is 2 :p", + reactions: {"2️⃣": 3}, + ), + _message(pumpkin, 30, "2, obviously"), + // Linked only in the HTML, so the body has no link to preview + _message( + bot, + 29, + "[Nexus/nexus] Issue opened: #174 Automatic scripts to make screenshots " + "for different pages and viewports by Henry-Hiles", + html: + '[Nexus/nexus] Issue opened: #174 Automatic ' + "scripts to make screenshots for different pages and viewports " + "by Henry-Hiles", + ), + _message( + bot, + 7, + "[Nexus/nexus] Henry-Hiles pushed 1 commit to main: $commitUrl: " + "update screenshots - Henry-Hiles", + html: + "[Nexus/nexus] Henry-Hiles pushed 1 commit to main:
" + '41f5225: update screenshots - Henry-Hiles', + reactions: {"🚀": 3}, + ), + _message( + pumpkin, + 5, + "they're generated now?? let's gooo", + reactions: {"🎉": 2, "❤️": 1}, + ), + ]; + + /// The link preview shown under NexusBot's message + static const urlPreview = { + "og:title": "update screenshots · 41f5225420", + "og:description": + "nexus - A simple and user-friendly Matrix client made with Flutter " + "and a Gomuks backend.", + }; + + int _rowId = 0; + + /// An event in the Nexus room + Map _event( + String sender, + String type, + Map content, { + String? key, + int minutesAgo = 60, + Map reactions = const {}, + }) { + final rowId = ++_rowId; + return { + "rowid": rowId, + "timeline_rowid": rowId, + "room_id": nexusRoom, + "event_id": "\$screenshots-$rowId", + "sender": sender, + "type": type, + "state_key": ?key, + "timestamp": now + .subtract(.new(minutes: minutesAgo)) + .millisecondsSinceEpoch, + "content": content, + "reactions": reactions, + }; + } + + Map _message( + String sender, + int minutesAgo, + String body, { + String? html, + Map reactions = const {}, + }) => _event( + sender, + "m.room.message", + { + "msgtype": sender == bot ? "m.notice" : "m.text", + "body": body, + if (html != null) ...{ + "format": "org.matrix.custom.html", + "formatted_body": html, + }, + }, + minutesAgo: minutesAgo, + reactions: reactions, + ); + + Map _receipt(String userId, Map event) => { + "user_id": userId, + "event_id": event["event_id"], + "room_id": nexusRoom, + "timestamp": event["timestamp"], + }; + + /// A room, with [extra] JSON besides its metadata + Room _room( + String id, + String name, { + String avatar = nexusAvatar, + String? topic, + int unread = 0, + Map? lastEvent, + Map extra = const {}, + }) => .fromJson( + // Round-tripped, so the JSON has the types gomuks' decoded JSON would + jsonDecode( + jsonEncode({ + "meta": { + "room_id": id, + "name": name, + "avatar": avatar, + "topic": ?topic, + "has_member_list": true, + "preview_event_rowid": lastEvent?["rowid"] ?? 0, + "sorting_timestamp": + lastEvent?["timestamp"] ?? + now.subtract(const .new(hours: 1)).millisecondsSinceEpoch, + "unread_highlights": 0, + "unread_notifications": 0, + "unread_messages": unread, + }, + ...extra, + }), + ), + ); + + static Map> _stateIndex( + List> state, + ) => state + .groupListsBy((event) => event["type"] as String) + .map( + (type, events) => .new( + type, + Map.fromEntries( + events.map( + (event) => + .new(event["state_key"] as String, event["rowid"] as int), + ), + ), + ), + ); + + static String _avatarOfRoom(String name) => + "mxc://screenshots/${_slug(name)}.webp"; + + static String _slug(String name) => + name.toLowerCase().replaceAll(RegExp("[^a-z]+"), "-"); + + static String _roomId(String name) => "!${_slug(name)}:federated.nexus"; +} diff --git a/integration_test/screenshots/screenshot_fakes.dart b/integration_test/screenshots/screenshot_fakes.dart new file mode 100644 index 0000000..23ef76f --- /dev/null +++ b/integration_test/screenshots/screenshot_fakes.dart @@ -0,0 +1,62 @@ +import "dart:io"; +import "dart:ui" as ui; + +import "package:flutter/rendering.dart"; +import "package:flutter_test/flutter_test.dart"; +import "package:nexus/controllers/client.dart"; + +import "screenshot_data.dart"; + +/// Answers the commands the screenshotted screens send to gomuks, so the +/// screenshots don't need gomuks or a homeserver. +class FakeClientController() extends ClientController { + this : super(null); + + @override + Future build() async => 0; + + @override + Future sendCommand( + String command, [ + Map request = const {}, + ]) async => switch (command) { + "get_url_preview" => ScreenshotData.urlPreview, + "download_media" => {"path": _mediaPath(request["mxc"])}, + "get_related_events" => [], + "mark_read" || "set_typing" => null, + _ => throw UnimplementedError("The screenshots can't answer $command"), + }; + + /// The file for [mxc], from avatars/ beside this file + static String _mediaPath(String mxc) { + final file = File(switch (mxc) { + ScreenshotData.nexusAvatar => "assets/mobile.png", + _ => + "integration_test/screenshots/avatars/" + "${Uri.parse(mxc).pathSegments.last}", + }); + if (!file.existsSync()) throw StateError("No screenshot media for $mxc"); + return file.absolute.path; + } +} + +extension Screenshot on WidgetTester { + /// Saves what the app currently shows to [path], as a PNG. + Future screenshot(String path) async { + // Lets images finish decoding and animations settle + for (var frame = 0; frame < 20; frame++) { + await runAsync(() => .delayed(const .new(milliseconds: 50))); + await pump(const .new(milliseconds: 50)); + } + + final renderView = binding.renderViews.single; + final layer = renderView.debugLayer! as OffsetLayer; + final bytes = await runAsync(() async { + final image = await layer.toImage(Offset.zero & view.physicalSize); + return image.toByteData(format: ui.ImageByteFormat.png); + }); + + await File(path).create(recursive: true); + await File(path).writeAsBytes(bytes!.buffer.asUint8List()); + } +} diff --git a/integration_test/screenshots/screenshots_test.dart b/integration_test/screenshots/screenshots_test.dart new file mode 100644 index 0000000..29ed0bd --- /dev/null +++ b/integration_test/screenshots/screenshots_test.dart @@ -0,0 +1,142 @@ +import "dart:convert"; + +import "package:flutter_test/flutter_test.dart"; +import "package:integration_test/integration_test.dart"; +import "package:material_ui/material_ui.dart"; +import "package:nexus/controllers/client.dart"; +import "package:nexus/controllers/client_state.dart"; +import "package:nexus/controllers/gomuks_listener.dart"; +import "package:nexus/controllers/init_complete.dart"; +import "package:nexus/controllers/key.dart"; +import "package:nexus/controllers/member_list_opened.dart"; +import "package:nexus/controllers/rooms.dart"; +import "package:nexus/controllers/settings.dart"; +import "package:nexus/controllers/space_edges.dart"; +import "package:nexus/controllers/top_level_spaces.dart"; +import "package:nexus/main.dart" as nexus; +import "package:nexus/models/account.dart"; +import "package:nexus/widgets/account_scope.dart"; +import "package:shared_preferences_platform_interface/in_memory_shared_preferences_async.dart"; +import "package:shared_preferences_platform_interface/shared_preferences_async_platform_interface.dart"; + +import "../helpers/pump_until.dart"; +import "screenshot_data.dart"; +import "screenshot_fakes.dart"; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + // Where the screenshots are saved, set by `nix run .#screenshots` + const outputDirectory = String.fromEnvironment( + "SCREENSHOTS_DIR", + defaultValue: "build/screenshots", + ); + const accountId = "screenshots"; + + final data = ScreenshotData(.now()); + + setUpAll(() => nexus.isInBackground = false); + + /// Opens Nexus at the Nexus room, as a [size] window at [pixelRatio], + /// pretending to be a phone if [mobile]. + Future open( + WidgetTester tester, { + required ThemeMode theme, + required Size size, + required double pixelRatio, + required bool mobile, + }) async { + tester.view.physicalSize = size; + tester.view.devicePixelRatio = pixelRatio; + addTearDown(tester.view.reset); + + SharedPreferencesAsyncPlatform.instance = + InMemorySharedPreferencesAsync.withData({ + KeyController.accountsKey: json.encode([ + Account( + id: accountId, + userId: ScreenshotData.me, + displayName: "QuadRadical", + avatar: .parse(ScreenshotData.myAvatar), + ), + ]), + KeyController.activeAccountKey: accountId, + MemberListOpenedController.key: true, + "$accountId/${KeyController.spaceKey}": ScreenshotData.nexusSpace, + "$accountId/${KeyController.roomKey}": ScreenshotData.nexusRoom, + }); + + await tester.pumpWidget( + AccountScope( + initialAccountId: accountId, + retry: (_, _) => null, + overrides: [ + ClientController.provider.overrideWith(FakeClientController.new), + // Never starts gomuks; the state below is what it would sync + GomuksListenerController.provider.overrideWithBuild((_, _) {}), + ClientStateController.provider.overrideWithBuild( + (_, _) => ScreenshotData.clientState, + ), + InitCompleteController.provider.overrideWithBuild((_, _) => true), + RoomsController.provider.overrideWithBuild((_, _) => data.rooms), + TopLevelSpacesController.provider.overrideWithBuild( + (_, _) => ScreenshotData.topLevelSpaces, + ), + SpaceEdgesController.provider.overrideWithBuild( + (_, _) => ScreenshotData.spaceEdges, + ), + SettingsController.provider.overrideWithBuild( + (_, _) => .new( + theme: theme, + useDynamicTheming: false, + linuxMobileMode: mobile, + ), + ), + ], + child: nexus.App(), + ), + ); + + await tester.pumpUntil(find.text("they're generated now?? let's gooo")); + + // Focused on desktop, which would show a cursor + FocusManager.instance.primaryFocus?.unfocus(); + } + + for (final theme in [ThemeMode.dark, ThemeMode.light]) { + testWidgets("desktop, ${theme.name}", (tester) async { + await open( + tester, + theme: theme, + size: const .new(1920, 1080), + pixelRatio: 1, + mobile: false, + ); + + await tester.pumpUntil(find.text("Strudel")); + + await tester.screenshot("$outputDirectory/desktop-${theme.name}.png"); + }); + + testWidgets("phone, ${theme.name}", (tester) async { + await open( + tester, + theme: theme, + size: const .new(1080, 2340), + pixelRatio: 3, + mobile: true, + ); + + await tester.screenshot("$outputDirectory/phone-chat-${theme.name}.png"); + + await tester.tap( + find.byTooltip( + const DefaultMaterialLocalizations().openAppDrawerTooltip, + ), + ); + await tester.pumpUntil(find.text("Off-topic")); + + await tester.screenshot("$outputDirectory/phone-rooms-${theme.name}.png"); + }); + } +} diff --git a/integration_test/threads_test.dart b/integration_test/threads_test.dart new file mode 100644 index 0000000..8105f1b --- /dev/null +++ b/integration_test/threads_test.dart @@ -0,0 +1,258 @@ +import "package:flutter_test/flutter_test.dart"; +import "package:integration_test/integration_test.dart"; +import "package:material_ui/material_ui.dart"; +import "package:nexus/widgets/composer/composer.dart"; +import "package:nexus/widgets/room_chat/room_chat.dart"; +import "package:nexus/widgets/threads/thread_drawer.dart"; +import "package:nexus/widgets/threads/thread_summary.dart"; +import "package:nexus/widgets/threads/threads_drawer.dart"; + +import "helpers/matrix_user.dart"; +import "helpers/test_app.dart"; +import "helpers/pump_until.dart"; +import "helpers/threads.dart"; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + final app = TestApp("alice", "alicepass"); + setUpAll(app.setUp); + final run = DateTime.now().millisecondsSinceEpoch; + late MatrixUser bob; + + setUpAll(() async => bob = await MatrixUser.login("bob", "bobpass")); + + /// Opens [roomName], waiting for the thread from [rootBody] in its timeline. + Future openRoom( + WidgetTester tester, + String roomName, + String rootBody, + ) async { + await app.openRoom(tester, roomName); + await tester.pumpUntil( + find.message(rootBody).inside(RoomChat).hitTestable(), + ); + } + + /// Opens the thread from the room's summary, waiting for [reply] in it. + Future openThread(WidgetTester tester, String reply) async { + await tester.tapWhenShown(find.byType(ThreadSummary)); + await tester.pumpUntil(find.message(reply).inside(ThreadDrawer)); + } + + group("a thread", () { + final roomName = "Threads $run"; + final rootBody = "Thread root $run"; + const firstReply = "First reply"; + const secondReply = "Second reply"; + + late String roomId; + late String rootId; + + setUpAll(() async { + roomId = await bob.createRoom(roomName); + // Joined before Nexus logs in, so the room is there once it does + await app.join(bob, roomId); + + rootId = (await bob.sendThread( + roomId, + rootBody, + .new([firstReply, secondReply]), + )).rootId; + }); + + Future replyCount() async => + (await bob.threadReplies(roomId, rootId)).length; + + testWidgets("logs in with OAuth and sets up encryption", (tester) async { + await app.open(tester); + + await app.selectRoom(tester, roomName); + }); + + testWidgets("summarises the thread under its root", (tester) async { + await openRoom(tester, roomName, rootBody); + + await tester.expectReplyCount(ThreadSummary, 2); + expect(find.message(secondReply).inside(ThreadSummary), findsWidgets); + // Replies are in the thread, not the room's timeline + expect(find.message(firstReply), findsNothing); + }); + + testWidgets("lists the thread in the threads drawer", (tester) async { + await openRoom(tester, roomName, rootBody); + await tester.tapWhenShown(find.byTooltip("Open threads")); + + await tester.pumpUntil(find.message(rootBody).inside(ThreadsDrawer)); + await tester.expectReplyCount(ThreadsDrawer, 2); + expect(find.text("Last active:").inside(ThreadsDrawer), findsOneWidget); + }); + + testWidgets("opens the thread from the threads drawer", (tester) async { + await openRoom(tester, roomName, rootBody); + await tester.tapWhenShown(find.byTooltip("Open threads")); + await tester.tapWhenShown( + find.message(rootBody).inside(ThreadsDrawer).inkWell, + ); + + await tester.pumpUntil(find.message(secondReply).inside(ThreadDrawer)); + }); + + testWidgets("shows the root and its replies, oldest first", (tester) async { + await openRoom(tester, roomName, rootBody); + await openThread(tester, secondReply); + + final root = find.message(rootBody).inside(ThreadDrawer).first; + final first = find.message(firstReply).inside(ThreadDrawer).first; + final second = find.message(secondReply).inside(ThreadDrawer).first; + expect(root, findsOneWidget); + expect(first, findsOneWidget); + expect( + tester.getTopLeft(root).dy, + lessThan(tester.getTopLeft(first).dy), + reason: "The root should be above the replies", + ); + expect( + tester.getTopLeft(first).dy, + lessThan(tester.getTopLeft(second).dy), + reason: "Older replies should be above newer ones", + ); + }); + + testWidgets("sends replies to the thread", (tester) async { + final body = "Reply from Nexus $run"; + final before = await replyCount(); + await openRoom(tester, roomName, rootBody); + await openThread(tester, secondReply); + + final composer = find + .widgetWithText(TextField, "Your message here...") + .inside(ThreadDrawer); + await tester.pumpUntil(composer); + await tester.enterText(composer, body); + await tester.tapWhenShown( + find.byTooltip("Send message").inside(ThreadDrawer), + ); + await tester.pumpUntil(find.message(body).inside(ThreadDrawer)); + + // It's in the thread for other clients too + final replies = await bob.threadRepliesIncluding(roomId, rootId, body); + expect(replies.last, body); + + // Shown as the latest reply once the summary has caught up + await tester.pumpUntil(find.message(body).inside(ThreadSummary)); + await tester.expectReplyCount(ThreadSummary, before + 1); + expect( + find.text(body).inside(Composer), + findsNothing, + reason: "The composer should be cleared once sent", + ); + }); + + testWidgets("shows replies from others as they arrive", (tester) async { + final body = "Live reply $run"; + await openRoom(tester, roomName, rootBody); + await openThread(tester, secondReply); + + final before = await replyCount(); + await bob.send(roomId, body, threadRoot: rootId); + + await tester.pumpUntil(find.message(body).inside(ThreadDrawer)); + await tester.pumpUntil(find.message(body).inside(ThreadSummary)); + await tester.expectReplyCount(ThreadSummary, before + 1); + }); + }); + + group("redactions", () { + final roomName = "Redactions $run"; + final rootBody = "Redaction root $run"; + const keptReply = "Kept reply"; + const redactedReply = "Redacted reply"; + + late String roomId; + late String rootId; + late String redactedId; + + setUpAll(() async { + roomId = await bob.createRoom(roomName); + await app.join(bob, roomId); + + final thread = await bob.sendThread( + roomId, + rootBody, + .new([keptReply, redactedReply]), + ); + rootId = thread.rootId; + redactedId = thread.replyIds.last; + }); + + testWidgets("drops a redacted reply from its thread", (tester) async { + await openRoom(tester, roomName, rootBody); + await tester.expectReplyCount(ThreadSummary, 2); + + await bob.redact(roomId, redactedId); + + // The reply before it becomes the latest + await tester.pumpUntil(find.message(keptReply).inside(ThreadSummary)); + await tester.expectReplyCount(ThreadSummary, 1); + + await openThread(tester, keptReply); + expect(find.message(redactedReply).inside(ThreadDrawer), findsNothing); + }); + + testWidgets("still opens the thread of a redacted root", (tester) async { + await bob.redact(roomId, rootId); + await app.openRoom(tester, roomName); + await tester.tapWhenShown(find.byTooltip("Open threads")); + + // The root's preview is redacted, so the card is found by its count + await tester.tapWhenShown( + find.text("1 reply").inside(ThreadsDrawer).inkWell, + ); + + final root = find.text("Redacted event").inside(ThreadDrawer); + final reply = find.message(keptReply).inside(ThreadDrawer); + await tester.pumpUntil(root); + await tester.pumpUntil(reply); + expect( + tester.getTopLeft(root.first).dy, + lessThan(tester.getTopLeft(reply.first).dy), + reason: "The redacted root should still be above the replies", + ); + }); + }); + + group("edits", () { + final roomName = "Edits $run"; + final rootBody = "Edit root $run"; + const originalReply = "Reply before editing"; + const editedReply = "Reply after editing"; + + late String roomId; + late String replyId; + + setUpAll(() async { + roomId = await bob.createRoom(roomName); + await app.join(bob, roomId); + + final thread = await bob.sendThread( + roomId, + rootBody, + .new([originalReply]), + ); + replyId = thread.replyIds.single; + }); + + testWidgets("shows an edited reply's new text", (tester) async { + await openRoom(tester, roomName, rootBody); + await tester.pumpUntil(find.message(originalReply).inside(ThreadSummary)); + + await bob.edit(roomId, replyId, editedReply); + + await tester.pumpUntil(find.message(editedReply).inside(ThreadSummary)); + await openThread(tester, editedReply); + expect(find.message(originalReply).inside(ThreadDrawer), findsNothing); + expect(find.text("(edited)").inside(ThreadDrawer), findsOneWidget); + }); + }); +} diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig index ec97fc6..592ceee 100644 --- a/ios/Flutter/Debug.xcconfig +++ b/ios/Flutter/Debug.xcconfig @@ -1,2 +1 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig index c4855bf..592ceee 100644 --- a/ios/Flutter/Release.xcconfig +++ b/ios/Flutter/Release.xcconfig @@ -1,2 +1 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/ios/Podfile b/ios/Podfile deleted file mode 100644 index 620e46e..0000000 --- a/ios/Podfile +++ /dev/null @@ -1,43 +0,0 @@ -# Uncomment this line to define a global platform for your project -# platform :ios, '13.0' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_ios_podfile_setup - -target 'Runner' do - use_frameworks! - - flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) - target 'RunnerTests' do - inherit! :search_paths - end -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_ios_build_settings(target) - end -end diff --git a/ios/Podfile.lock b/ios/Podfile.lock deleted file mode 100644 index b29d5cb..0000000 --- a/ios/Podfile.lock +++ /dev/null @@ -1,28 +0,0 @@ -PODS: - - Flutter (1.0.0) - - media_kit_libs_ios_video (1.0.4): - - Flutter - - media_kit_video (0.0.1): - - Flutter - -DEPENDENCIES: - - Flutter (from `Flutter`) - - media_kit_libs_ios_video (from `.symlinks/plugins/media_kit_libs_ios_video/ios`) - - media_kit_video (from `.symlinks/plugins/media_kit_video/ios`) - -EXTERNAL SOURCES: - Flutter: - :path: Flutter - media_kit_libs_ios_video: - :path: ".symlinks/plugins/media_kit_libs_ios_video/ios" - media_kit_video: - :path: ".symlinks/plugins/media_kit_video/ios" - -SPEC CHECKSUMS: - Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 - media_kit_libs_ios_video: 5a18affdb97d1f5d466dc79988b13eff6c5e2854 - media_kit_video: 1746e198cb697d1ffb734b1d05ec429d1fcd1474 - -PODFILE CHECKSUM: 3c63482e143d1b91d2d2560aee9fb04ecc74ac7e - -COCOAPODS: 1.17.0 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 065d08b..1612bb0 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -8,13 +8,11 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 2ADFEE6C745FFB2100CC9AFD /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8156A45F510382D558AED93A /* Pods_RunnerTests.framework */; }; 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 7884E8682EC3CC0700C636F2 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */; }; 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; - 88D55A5F1C7625122EBEE29D /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 82F9A3759658343C81A0EA4C /* Pods_Runner.framework */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; @@ -46,19 +44,14 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 22DE4310DAFBE211CDF700B1 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 363A89F6FA09BCCBDED440CE /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 63516CF65A79A5DDDE64B0D1 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7884E8672EC3CC0400C636F2 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; - 8156A45F510382D558AED93A /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 82F9A3759658343C81A0EA4C /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -66,9 +59,6 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - AEB96D8976BD46D6860C7041 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; - B8B599FDB72E4713FB7B5A44 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; - FE5E4162842555A83F8A7FD7 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -76,7 +66,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 2ADFEE6C745FFB2100CC9AFD /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -85,27 +74,12 @@ buildActionMask = 2147483647; files = ( 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */, - 88D55A5F1C7625122EBEE29D /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 1CFFAE23B502BCCEB2B191A3 /* Pods */ = { - isa = PBXGroup; - children = ( - AEB96D8976BD46D6860C7041 /* Pods-Runner.debug.xcconfig */, - 363A89F6FA09BCCBDED440CE /* Pods-Runner.release.xcconfig */, - 22DE4310DAFBE211CDF700B1 /* Pods-Runner.profile.xcconfig */, - B8B599FDB72E4713FB7B5A44 /* Pods-RunnerTests.debug.xcconfig */, - FE5E4162842555A83F8A7FD7 /* Pods-RunnerTests.release.xcconfig */, - 63516CF65A79A5DDDE64B0D1 /* Pods-RunnerTests.profile.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; 331C8082294A63A400263BE5 /* RunnerTests */ = { isa = PBXGroup; children = ( @@ -114,15 +88,6 @@ path = RunnerTests; sourceTree = ""; }; - 594EB1F65336CF9C7958F6FA /* Frameworks */ = { - isa = PBXGroup; - children = ( - 82F9A3759658343C81A0EA4C /* Pods_Runner.framework */, - 8156A45F510382D558AED93A /* Pods_RunnerTests.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -142,8 +107,6 @@ 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, 331C8082294A63A400263BE5 /* RunnerTests */, - 1CFFAE23B502BCCEB2B191A3 /* Pods */, - 594EB1F65336CF9C7958F6FA /* Frameworks */, ); sourceTree = ""; }; @@ -179,7 +142,6 @@ isa = PBXNativeTarget; buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( - EE82EC529EB6C0F1FA480659 /* [CP] Check Pods Manifest.lock */, 331C807D294A63A400263BE5 /* Sources */, 331C807F294A63A400263BE5 /* Resources */, 8C0A36760DA8B873D8F6DDCE /* Frameworks */, @@ -198,14 +160,12 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 0830C6758DA3ECA81FB12386 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 1D165FDFB9D0D939B041966D /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -283,45 +243,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 0830C6758DA3ECA81FB12386 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - 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; - }; - 1D165FDFB9D0D939B041966D /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; alwaysOutOfDate = 1; @@ -353,28 +274,6 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - EE82EC529EB6C0F1FA480659 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - 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; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -502,7 +401,6 @@ }; 331C8088294A63A400263BE5 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = B8B599FDB72E4713FB7B5A44 /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -520,7 +418,6 @@ }; 331C8089294A63A400263BE5 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FE5E4162842555A83F8A7FD7 /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; @@ -536,7 +433,6 @@ }; 331C808A294A63A400263BE5 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 63516CF65A79A5DDDE64B0D1 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CODE_SIGN_STYLE = Automatic; diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata index 21a3cc1..1d526a1 100644 --- a/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,7 +4,4 @@ - - diff --git a/lib/controllers/account_data.dart b/lib/controllers/account_data.dart index 7d6e449..62997b5 100644 --- a/lib/controllers/account_data.dart +++ b/lib/controllers/account_data.dart @@ -8,6 +8,7 @@ import "package:nexus/controllers/client.dart"; import "package:nexus/models/account_data.dart"; import "package:nexus/models/push_rules.dart"; import "package:nexus/models/requests/update_push_rule.dart"; +import "package:nexus/models/room_notification_level.dart"; import "package:nexus/models/sync_data.dart"; class AccountDataController extends Notifier { @@ -98,6 +99,27 @@ class AccountDataController extends Notifier { (rules) => rules.find(kind, ruleId) == null, ); + /// Replaces the push rules for the room with [roomId] with those [level] + /// needs, deleting them first so disabled ones don't stay disabled. + Future setRoomNotificationLevel( + String roomId, + RoomNotificationLevel level, + ) async { + final rules = state.pushRules.global; + if (RoomNotificationLevel.of(rules, roomId) == level) return; + + return _updatePushRules( + .new([ + ...[PushRuleKind.override, PushRuleKind.room] + .where((kind) => rules.find(kind, roomId) != null) + .map((kind) => .new(kind: kind, ruleId: roomId, action: .delete)), + if (level.ruleFor(roomId) case (:final kind, :final rule)) + .new(kind: kind, ruleId: roomId, action: .put, newContent: rule), + ]), + (rules) => RoomNotificationLevel.of(rules, roomId) == level, + ); + } + /// Sends [requests] in order, then waits until [arrived] is true for the /// synced push rules. Future _updatePushRules( diff --git a/lib/controllers/author.dart b/lib/controllers/author.dart index f9c9167..0b783f0 100644 --- a/lib/controllers/author.dart +++ b/lib/controllers/author.dart @@ -2,27 +2,30 @@ import "dart:async"; import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:nexus/controllers/user.dart"; +import "package:nexus/models/configs/author.dart"; import "package:nexus/models/content/membership.dart"; -import "package:nexus/models/event.dart"; -class AuthorController(final Event event) +class AuthorController(final AuthorConfig config) extends AsyncNotifier { @override Future build() async { final member = await ref.watch( - UserController.provider(.new(roomId: event.roomId, userId: event.sender)) - .future, + UserController.provider( + .new(roomId: config.roomId, userId: config.userId), + ).future, ); return .new( status: member.status, - avatarUrl: event.pmp?.avatarUrl ?? member.avatarUrl, - displayName: event.pmp?.displayName ?? member.displayName, + avatarUrl: config.avatarUrl ?? member.avatarUrl, + displayName: config.displayName ?? member.displayName, ); } static final provider = - AsyncNotifierProvider.family( - AuthorController.new, - ); + AsyncNotifierProvider.family< + AuthorController, + MembershipContent, + AuthorConfig + >(AuthorController.new); } diff --git a/lib/controllers/banned_warning_dismissed.dart b/lib/controllers/banned_warning_dismissed.dart new file mode 100644 index 0000000..b080d38 --- /dev/null +++ b/lib/controllers/banned_warning_dismissed.dart @@ -0,0 +1,20 @@ +import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:nexus/controllers/shared_prefs.dart"; + +class BannedWarningDismissedController extends AsyncNotifier { + static const String key = "bannedWarningDismissed"; + + @override + Future build() async => + await ref.watch(SharedPrefsController.provider).getBool(key) ?? false; + + Future set(bool value) async { + state = .data(value); + await ref.read(SharedPrefsController.provider).setBool(key, value); + } + + static final provider = + AsyncNotifierProvider( + BannedWarningDismissedController.new, + ); +} diff --git a/lib/controllers/client.dart b/lib/controllers/client.dart index e6afa3b..3a1ac6c 100644 --- a/lib/controllers/client.dart +++ b/lib/controllers/client.dart @@ -221,7 +221,10 @@ class ClientController(final String? accountId) extends AsyncNotifier { : .fromJson(response["notification"]); } - Future _sendCommand( + /// Sends [command] to gomuks, returning its decoded response. Overridable so + /// that tests can answer commands without gomuks. + @protected + Future sendCommand( String command, [ Map data = const {}, ]) => callGomuksMethod(data, (handle, data, callback) { @@ -238,18 +241,18 @@ class ClientController(final String? accountId) extends AsyncNotifier { }); Future redactEvent(RedactEventRequest report) => - _sendCommand("redact_event", report.toJson()); + sendCommand("redact_event", report.toJson()); /// Null for gomuks' own commands that don't reply. Future sendMessage(SendMessageRequest request) async => - switch (await _sendCommand("send_message", request.toJson())) { + switch (await sendCommand("send_message", request.toJson())) { final Map json => .fromJson(json), _ => null, }; /// The MSC4391 definitions of gomuks' own commands. Future> getCommandDefinitions() async => - switch (await _sendCommand("get_command_definitions")) { + switch (await sendCommand("get_command_definitions")) { final List definitions => .new( definitions.whereType>().map( BotCommandDescriptionContent.fromJson, @@ -259,27 +262,27 @@ class ClientController(final String? accountId) extends AsyncNotifier { }; Future sendEvent(SendEventRequest request) async => - Event.fromJson(await _sendCommand("send_event", request.toJson())); + Event.fromJson(await sendCommand("send_event", request.toJson())); Future setState(SetStateRequest request) async => - await _sendCommand("set_state", request.toJson()); + await sendCommand("set_state", request.toJson()); - Future pauseSync() => _sendCommand("pause_sync"); - Future resumeSync() => _sendCommand("resume_sync"); + Future pauseSync() => sendCommand("pause_sync"); + Future resumeSync() => sendCommand("resume_sync"); Future verify(String recoveryKey) => - _sendCommand("verify", {"recovery_key": recoveryKey}); + sendCommand("verify", {"recovery_key": recoveryKey}); Future generateRecoveryKey(String passphrase) async => .fromJson( - await _sendCommand("generate_recovery_key", {"passphrase": passphrase}), + await sendCommand("generate_recovery_key", {"passphrase": passphrase}), ); Future resetEncryption(RecoveryKey key) => - _sendCommand("reset_encryption", key.toJson()); + sendCommand("reset_encryption", key.toJson()); Future getCrossSigningResetUrl(Uri homeserver) async { const action = "org.matrix.cross_signing_reset"; - final oauth = (await _sendCommand("get_login_flows", { + final oauth = (await sendCommand("get_login_flows", { "homeserver_url": homeserver.toString(), }))["oauth"]; @@ -297,33 +300,33 @@ class ClientController(final String? accountId) extends AsyncNotifier { } Future joinRoom(JoinRoomRequest request) async => - (await _sendCommand("join_room", request.toJson()))["room_id"]; + (await sendCommand("join_room", request.toJson()))["room_id"]; Future knockRoom(JoinRoomRequest request) async => - (await _sendCommand("knock_room", request.toJson()))["room_id"]; + (await sendCommand("knock_room", request.toJson()))["room_id"]; Future createRoom(CreateRoomRequest request) async => - (await _sendCommand("create_room", request.toJson()))["room_id"]; + (await sendCommand("create_room", request.toJson()))["room_id"]; Future getSpaceHierarchy( GetSpaceHierarchyRequest request, ) async => - .fromJson(await _sendCommand("get_space_hierarchy", request.toJson())); + .fromJson(await sendCommand("get_space_hierarchy", request.toJson())); Future getRoomDirectory( GetRoomDirectoryRequest request, ) async => - .fromJson(await _sendCommand("get_room_directory", request.toJson())); + .fromJson(await sendCommand("get_room_directory", request.toJson())); Future getRoomSummary(JoinRoomRequest request) async => - .fromJson(await _sendCommand("get_room_summary", request.toJson())); + .fromJson(await sendCommand("get_room_summary", request.toJson())); Future leaveRoom(String roomId) => - _sendCommand("leave_room", {"room_id": roomId}); + sendCommand("leave_room", {"room_id": roomId}); Future> getRoomState(GetRoomStateRequest request) async { Future getState(GetRoomStateRequest request) async => - (await _sendCommand("get_room_state", request.toJson())) as List?; + (await sendCommand("get_room_state", request.toJson())) as List?; final response = await getState(request); return .new( @@ -336,7 +339,7 @@ class ClientController(final String? accountId) extends AsyncNotifier { Future> getSpecificRoomState( GetSpecificRoomStateRequest request, ) async => .new( - ((await _sendCommand("get_specific_room_state", request.toJson())) + ((await sendCommand("get_specific_room_state", request.toJson())) as List? ?? []) .map((event) => .fromJson(event)), @@ -346,48 +349,48 @@ class ClientController(final String? accountId) extends AsyncNotifier { GetRelatedEventsRequest request, ) async { final response = - (await _sendCommand("get_related_events", request.toJson())) as List?; + (await sendCommand("get_related_events", request.toJson())) as List?; return .new(response?.map((event) => .fromJson(event))); } Future getMentions(GetMentionsRequest request) async => - .fromJson(await _sendCommand("get_mentions", request.toJson())); + .fromJson(await sendCommand("get_mentions", request.toJson())); Future getEvent(GetEventRequest request) async { - final json = await _sendCommand("get_event", request.toJson()); + final json = await sendCommand("get_event", request.toJson()); return json == null ? null : .fromJson(json); } Future getUrlPreview(Uri url) async => - .fromJson(await _sendCommand("get_url_preview", {"url": url.toString()})); + .fromJson(await sendCommand("get_url_preview", {"url": url.toString()})); Future paginate(PaginateRequest request) async => - .fromJson(await _sendCommand("paginate", request.toJson())); + .fromJson(await sendCommand("paginate", request.toJson())); Future getThreads(GetThreadsRequest request) async => - .fromJson(await _sendCommand("get_threads", request.toJson())); + .fromJson(await sendCommand("get_threads", request.toJson())); Future paginateManual(PaginateManualRequest request) async => - .fromJson(await _sendCommand("paginate_manual", request.toJson())); + .fromJson(await sendCommand("paginate_manual", request.toJson())); Future searchLocal(SearchRequest request) async => - .fromJson(await _sendCommand("search_local", request.toJson())); + .fromJson(await sendCommand("search_local", request.toJson())); Future searchServer(SearchRequest request) async => - .fromJson(await _sendCommand("search_server", request.toJson())); + .fromJson(await sendCommand("search_server", request.toJson())); Future getEventContext(GetEventContextRequest request) async => - .fromJson(await _sendCommand("get_event_context", request.toJson())); + .fromJson(await sendCommand("get_event_context", request.toJson())); Future getProfile(String userId) async { try { - return .fromJson(await _sendCommand("get_profile", {"user_id": userId})); + return .fromJson(await sendCommand("get_profile", {"user_id": userId})); } catch (_) { return .new(profile: .new(id: userId)); } } - Future setProfileField(String field, Object? value) => _sendCommand( + Future setProfileField(String field, Object? value) => sendCommand( "set_profile_field", { "field": field, @@ -397,28 +400,28 @@ class ClientController(final String? accountId) extends AsyncNotifier { ); Future reportEvent(ReportRequest request) => - _sendCommand("report_event", request.toJson()); + sendCommand("report_event", request.toJson()); Future setMembership(SetMembershipRequest request) => - _sendCommand("set_membership", request.toJson()); + sendCommand("set_membership", request.toJson()); Future setAccountData(SetAccountDataRequest request) => - _sendCommand("set_account_data", request.toJson()); + sendCommand("set_account_data", request.toJson()); Future updatePushRule(UpdatePushRuleRequest request) => - _sendCommand("update_push_rule", request.toJson()); + sendCommand("update_push_rule", request.toJson()); Future registerPusher(RegisterPusherRequest request) => - _sendCommand("register_homeserver_push", request.toJson()); + sendCommand("register_homeserver_push", request.toJson()); Future deregisterPusher(DeregisterPusherRequest request) => - _sendCommand("register_homeserver_push", { + sendCommand("register_homeserver_push", { ...request.toJson(), "kind": null, }); Future uploadMedia(UploadMediaRequest request) async => - .fromJson(await _sendCommand("upload_media", request.toJson())); + .fromJson(await sendCommand("upload_media", request.toJson())); Future downloadMedia(DownloadMediaRequest request) async { if (accountId == null && @@ -427,13 +430,13 @@ class ClientController(final String? accountId) extends AsyncNotifier { } return .new( - (await _sendCommand("download_media", request.toJson()))["path"], + (await sendCommand("download_media", request.toJson()))["path"], ); } - Future logout() => _sendCommand("logout"); + Future logout() => sendCommand("logout"); - Future setTyping(String roomId, Duration timeout) => _sendCommand( + Future setTyping(String roomId, Duration timeout) => sendCommand( "set_typing", {"room_id": roomId, "timeout": timeout.inMilliseconds}, ); @@ -462,7 +465,7 @@ class ClientController(final String? accountId) extends AsyncNotifier { ref.read(SettingsController.provider).value?.readReceipts == .showAndSend; - await _sendCommand("mark_read", { + await sendCommand("mark_read", { "room_id": room.metadata!.id, "receipt_type": sendPublic ? "m.read" : "m.read.private", "event_id": event.eventId, @@ -471,44 +474,44 @@ class ClientController(final String? accountId) extends AsyncNotifier { } Future registerClient(OAuthRegisterClientRequest request) async => - (await _sendCommand( + (await sendCommand( "oauth_register_client", request.toJson(), ))["client_id"]; Future getAuthUrl(OAuthGetAuthUrl request) async => .fromJson( - await _sendCommand("oauth_get_authorization_url", request.toJson()), + await sendCommand("oauth_get_authorization_url", request.toJson()), ); Future exchangeToken(OAuthExchangeTokenRequest request) async => - await _sendCommand("oauth_exchange_token", request.toJson()); + await sendCommand("oauth_exchange_token", request.toJson()); Future> getMutualRooms(String userId) async => IList( - ((await _sendCommand("get_mutual_rooms", {"user_id": userId}))["joined"] + ((await sendCommand("get_mutual_rooms", {"user_id": userId}))["joined"] as List?) ?.cast(), ); Future> getLocalAliases(String roomId) async => IList( - ((await _sendCommand("get_local_aliases", {"room_id": roomId}))["aliases"] + ((await sendCommand("get_local_aliases", {"room_id": roomId}))["aliases"] as List?) ?.cast(), ); Future createAlias(String roomId, String alias) => - _sendCommand("create_alias", {"room_id": roomId, "alias": alias}); + sendCommand("create_alias", {"room_id": roomId, "alias": alias}); Future deleteAlias(String alias) => - _sendCommand("delete_alias", {"alias": alias}); + sendCommand("delete_alias", {"alias": alias}); Future getRoomPublished(String roomId) async => - (await _sendCommand("get_room_visibility", { + (await sendCommand("get_room_visibility", { "room_id": roomId, }))["visibility"] == "public"; - Future setRoomPublished(String roomId, bool published) => _sendCommand( + Future setRoomPublished(String roomId, bool published) => sendCommand( "publish_room", {"room_id": roomId, "visibility": published ? "public" : "private"}, ); @@ -517,7 +520,7 @@ class ClientController(final String? accountId) extends AsyncNotifier { String roomId, String version, { ISet additionalCreators = const .empty(), - }) async => (await _sendCommand("upgrade_room", { + }) async => (await sendCommand("upgrade_room", { "room_id": roomId, "new_version": version, if (additionalCreators.isNotEmpty) @@ -527,7 +530,7 @@ class ClientController(final String? accountId) extends AsyncNotifier { /// The room [alias] points to, or null if it doesn't exist. Future resolveAlias(String alias) async { try { - return (await _sendCommand("resolve_alias", {"alias": alias}))["room_id"]; + return (await sendCommand("resolve_alias", {"alias": alias}))["room_id"]; } on GomuksException catch (error) { if (error.statusCode == 404) return null; rethrow; @@ -535,14 +538,14 @@ class ClientController(final String? accountId) extends AsyncNotifier { } Future getSpecVersions() async => - .fromJson(await _sendCommand("get_versions")); + .fromJson(await sendCommand("get_versions")); Future getCapabilities() async => - .fromJson((await _sendCommand("get_capabilities"))["capabilities"]); + .fromJson((await sendCommand("get_capabilities"))["capabilities"]); Future discoverHomeserver(Uri homeserver) async { try { - final response = await _sendCommand("discover_homeserver", { + final response = await sendCommand("discover_homeserver", { "user_id": "@fake-user:${homeserver.authority}", }); return Uri.parse(response["m.homeserver"]?["base_url"]); diff --git a/lib/controllers/clock.dart b/lib/controllers/clock.dart new file mode 100644 index 0000000..f9fe690 --- /dev/null +++ b/lib/controllers/clock.dart @@ -0,0 +1,20 @@ +import "dart:async"; + +import "package:flutter_riverpod/flutter_riverpod.dart"; + +class ClockController extends Notifier { + @override + DateTime build() { + final timer = Timer.periodic( + const .new(seconds: 30), + (_) => state = .now(), + ); + ref.onDispose(timer.cancel); + return .now(); + } + + static final provider = + NotifierProvider.autoDispose( + ClockController.new, + ); +} diff --git a/lib/controllers/emoji_shortcodes.dart b/lib/controllers/emoji_shortcodes.dart new file mode 100644 index 0000000..a24ebb1 --- /dev/null +++ b/lib/controllers/emoji_shortcodes.dart @@ -0,0 +1,31 @@ +import "package:collection/collection.dart"; +import "package:fast_immutable_collections/fast_immutable_collections.dart"; +import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:material_emoji_picker/material_emoji_picker.dart"; + +/// Maps each unicode emoji, without variation selectors, to its shortcode. +class EmojiShortcodesController extends Notifier> { + static final _variationSelectors = RegExp("[\uFE0E\uFE0F]"); + + static String normalize(String emoji) => + emoji.replaceAll(_variationSelectors, ""); + + @override + IMap build() => .fromEntries( + ref + .watch(EmojiController.provider) + .requireValue + .map((category) => category.emojis) + .flattened + .where((emoji) => emoji.aliases.isNotEmpty) + .map( + (emoji) => + MapEntry(normalize(emoji.value), ":${emoji.aliases.first}:"), + ), + ); + + static final provider = + NotifierProvider>( + EmojiShortcodesController.new, + ); +} diff --git a/lib/controllers/reactions.dart b/lib/controllers/reactions.dart index 0c30128..662661c 100644 --- a/lib/controllers/reactions.dart +++ b/lib/controllers/reactions.dart @@ -1,14 +1,18 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:nexus/controllers/client.dart"; +import "package:nexus/controllers/emoji_shortcodes.dart"; import "package:nexus/controllers/rooms.dart"; import "package:nexus/models/configs/event.dart"; import "package:nexus/models/content/reaction.dart"; +import "package:nexus/models/reaction_group.dart"; class ReactionsController(final EventConfig config) - extends AsyncNotifier>> { + extends AsyncNotifier> { @override - Future>> build() async { + Future> build() async { + final unicodeShortcodes = ref.watch(EmojiShortcodesController.provider); + final eventInfo = ref.watch( RoomsController.provider.select((value) { final event = value[config.roomId]?.events[config.eventRowId]; @@ -30,12 +34,25 @@ class ReactionsController(final EventConfig config) return reactionEvents ?.where((event) => event.redactedBy == null) - .fold>>(.new(), (acc, event) { - if (event.content case ReactionContent(:final key?)) { + .fold>(.new(), (acc, event) { + if (event.content case ReactionContent( + :final key?, + :final shortcode, + )) { return acc.update( key, - (list) => list.add(event.sender), - ifAbsent: () => .new([event.sender]), + (group) => group.copyWith( + senders: group.senders.add(event.sender), + shortcode: group.shortcode ?? shortcode, + ), + ifAbsent: () => .new( + senders: .new([event.sender]), + shortcode: + shortcode ?? + unicodeShortcodes[EmojiShortcodesController.normalize( + key, + )], + ), ); } @@ -47,7 +64,7 @@ class ReactionsController(final EventConfig config) static final provider = AsyncNotifierProvider.family< ReactionsController, - IMap>, + IMap, EventConfig >(ReactionsController.new); } diff --git a/lib/controllers/room_chat.dart b/lib/controllers/room_chat.dart index 773f30d..2a53a0d 100644 --- a/lib/controllers/room_chat.dart +++ b/lib/controllers/room_chat.dart @@ -295,6 +295,7 @@ class RoomChatController(final ChatParams info) : null, ), ); + if (!ref.mounted) return; if (response.events.isEmpty) { state = .data(chat); @@ -333,6 +334,7 @@ class RoomChatController(final ChatParams info) : chat!.historicalData!.start, ), ); + if (!ref.mounted) return; ref .read(RoomsController.provider.notifier) @@ -345,6 +347,7 @@ class RoomChatController(final ChatParams info) final rootRowId = direction == .backward ? await threadRootBefore(paginationResponse) : null; + if (!ref.mounted) return; final eventRowIds = [ ?rootRowId, ...(direction == .forward @@ -383,6 +386,7 @@ class RoomChatController(final ChatParams info) ); } } catch (_) { + if (!ref.mounted) return; state = .data(chat); rethrow; } diff --git a/lib/controllers/room_settings_sections.dart b/lib/controllers/room_settings_sections.dart index bf7159a..bababee 100644 --- a/lib/controllers/room_settings_sections.dart +++ b/lib/controllers/room_settings_sections.dart @@ -36,9 +36,9 @@ import "package:nexus/models/join_rule.dart"; import "package:nexus/models/power_level_permission.dart"; import "package:nexus/models/setting.dart"; import "package:nexus/models/settings_category.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/divider_text.dart"; -import "package:nexus/widgets/image_pack_avatar.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/common/divider_text.dart"; +import "package:nexus/widgets/avatars/image_pack_avatar.dart"; import "package:nexus/widgets/settings/add_users_power_level_sheet.dart"; import "package:nexus/widgets/settings/aliases_sheet.dart"; import "package:nexus/widgets/settings/allowed_rooms_sheet.dart"; diff --git a/lib/controllers/settings_sections.dart b/lib/controllers/settings_sections.dart index 35c7f94..999fea6 100644 --- a/lib/controllers/settings_sections.dart +++ b/lib/controllers/settings_sections.dart @@ -35,15 +35,15 @@ import "package:nexus/models/settings.dart"; import "package:nexus/models/settings_category.dart"; import "package:nexus/models/show_and_send.dart"; import "package:nexus/main.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/divider_text.dart"; -import "package:nexus/widgets/image_pack_avatar.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/common/divider_text.dart"; +import "package:nexus/widgets/avatars/image_pack_avatar.dart"; import "package:nexus/widgets/settings/block_user_field.dart"; import "package:nexus/widgets/settings/dialog_list_tile.dart"; import "package:nexus/widgets/settings/enable_image_packs_sheet.dart"; import "package:nexus/widgets/settings/keyword_field.dart"; -import "package:nexus/widgets/user_bottom_sheet.dart"; -import "package:nexus/widgets/reset_encryption_sheet.dart"; +import "package:nexus/widgets/users/user_bottom_sheet.dart"; +import "package:nexus/widgets/encryption/reset_encryption_sheet.dart"; class SettingsSectionsController extends AsyncNotifier>> { diff --git a/lib/helpers/current_location_helper.dart b/lib/helpers/current_location_helper.dart index dbdb9e8..06f22d8 100644 --- a/lib/helpers/current_location_helper.dart +++ b/lib/helpers/current_location_helper.dart @@ -2,7 +2,7 @@ import "dart:async"; import "dart:io"; import "package:flutter_riverpod/flutter_riverpod.dart"; -import "package:geolocator/geolocator.dart"; +import "package:location/location.dart"; import "package:latlong2/latlong.dart"; import "package:nexus/controllers/portal.dart"; import "package:nexus/models/location_exception.dart"; @@ -13,7 +13,7 @@ class CurrentLocationHelper(final Ref ref) { /// The user's location and its accuracy in meters, or null if [askPermission] /// is off and they haven't allowed it. Future<(LatLng, double?)?> get({required bool askPermission}) async { - // geolocator talks to GeoClue directly, which Flatpak's sandbox blocks, so + // location talks to GeoClue directly, which Flatpak's sandbox blocks, so // Linux uses the location portal, which also asks the user for permission if (Platform.isLinux) { // The portal can't say whether it's allowed without asking @@ -40,40 +40,36 @@ class CurrentLocationHelper(final Ref ref) { } } - if (!await Geolocator.isLocationServiceEnabled()) { + final location = Location.instance; + if (!await location.serviceEnabled()) { if (!askPermission) return null; throw LocationException.servicesOff; } - var permission = await Geolocator.checkPermission(); + var permission = await location.hasPermission(); if (permission == .denied && askPermission) { - permission = await Geolocator.requestPermission(); + permission = await location.requestPermission(); } if (permission == .denied || permission == .deniedForever) { if (!askPermission) return null; throw LocationException.denied; } - Position? position; + LocationData? data; try { - position = await Geolocator.getCurrentPosition( - locationSettings: Platform.isAndroid - // Play services' location can hang without Google, like on microG, - // so this uses Android's own, as other apps do - ? AndroidSettings(forceLocationManager: true, timeLimit: _timeLimit) - : const LocationSettings(timeLimit: _timeLimit), - ); + data = await location.getLocation().timeout(_timeLimit); } on TimeoutException { // A fix can take long indoors, but another app may have a recent one - position = await Geolocator.getLastKnownPosition( - forceAndroidLocationManager: true, + data = await location.getLastKnownLocation().onError( + (_, _) => throw LocationException.failed, ); } catch (_) { throw LocationException.failed; } - if (position == null) throw LocationException.timedOut; - return (LatLng(position.latitude, position.longitude), position.accuracy); + if (data == null) throw LocationException.timedOut; + + return (LatLng(data.latitude, data.longitude), data.accuracy); } static final provider = Provider( diff --git a/lib/helpers/extensions/better_when.dart b/lib/helpers/extensions/better_when.dart index e054d02..459d139 100644 --- a/lib/helpers/extensions/better_when.dart +++ b/lib/helpers/extensions/better_when.dart @@ -1,7 +1,7 @@ import "package:flutter/widgets.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/widgets/loading.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/widgets/common/loading.dart"; extension BetterWhen on AsyncValue { Widget betterWhen({ diff --git a/lib/helpers/extensions/build_event_options.dart b/lib/helpers/extensions/build_event_options.dart index aff4ba0..a6ecc06 100644 --- a/lib/helpers/extensions/build_event_options.dart +++ b/lib/helpers/extensions/build_event_options.dart @@ -15,8 +15,8 @@ import "package:nexus/helpers/extensions/event_id_is_fake.dart"; import "package:nexus/models/content/message.dart"; import "package:nexus/models/event.dart"; import "package:nexus/models/relation_type.dart"; -import "package:nexus/widgets/emoji_picker.dart"; -import "package:nexus/widgets/mxc_emoji.dart"; +import "package:nexus/widgets/emoji/emoji_picker.dart"; +import "package:nexus/widgets/emoji/mxc_emoji.dart"; import "package:nexus/main.dart"; extension BuildEventOptions on Event { diff --git a/lib/helpers/extensions/image_pack_emoji.dart b/lib/helpers/extensions/image_pack_emoji.dart index 2b04cf1..fe480d5 100644 --- a/lib/helpers/extensions/image_pack_emoji.dart +++ b/lib/helpers/extensions/image_pack_emoji.dart @@ -2,7 +2,7 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:material_emoji_picker/material_emoji_picker.dart"; import "package:nexus/models/content/image_pack.dart"; import "package:nexus/models/image_pack.dart"; -import "package:nexus/widgets/mxc_emoji.dart"; +import "package:nexus/widgets/emoji/mxc_emoji.dart"; extension ImagePackEmoji on ImagePack { EmojiCategory? get emojiCategory => _category(emoticons); diff --git a/lib/helpers/extensions/open_link_info.dart b/lib/helpers/extensions/open_link_info.dart index e15e9b0..60947bb 100644 --- a/lib/helpers/extensions/open_link_info.dart +++ b/lib/helpers/extensions/open_link_info.dart @@ -7,7 +7,7 @@ import "package:nexus/helpers/extensions/focus_room.dart"; import "package:nexus/helpers/extensions/get_link_info.dart"; import "package:nexus/helpers/extensions/show_user_popover.dart"; import "package:nexus/models/room_summary.dart"; -import "package:nexus/widgets/room_summary_sheet.dart"; +import "package:nexus/widgets/rooms/room_summary_sheet.dart"; extension OpenLinkInfo on WidgetRef { Future openLinkInfo( diff --git a/lib/helpers/extensions/room_destinations.dart b/lib/helpers/extensions/room_destinations.dart index 3628d05..3d0323b 100644 --- a/lib/helpers/extensions/room_destinations.dart +++ b/lib/helpers/extensions/room_destinations.dart @@ -2,7 +2,7 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:material_ui/material_ui.dart"; import "package:navigation_rail_m3e/navigation_rail_m3e.dart"; import "package:nexus/models/room.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; extension RoomDestination on Room { NavigationRailM3EDestination toDestination({ diff --git a/lib/helpers/extensions/scheme_to_theme.dart b/lib/helpers/extensions/scheme_to_theme.dart index 97d239d..73ce176 100644 --- a/lib/helpers/extensions/scheme_to_theme.dart +++ b/lib/helpers/extensions/scheme_to_theme.dart @@ -20,6 +20,8 @@ extension SchemeToTheme on ColorScheme { shape: RoundedRectangleBorder(borderRadius: .circular(16)), color: surfaceContainerHigh, ), + // So ink at the edges of a sheet doesn't spill past its rounded corners + bottomSheetTheme: .new(clipBehavior: .antiAlias), appBarTheme: AppBarTheme( titleSpacing: 0, backgroundColor: surfaceContainerLow, diff --git a/lib/helpers/extensions/show_image_viewer.dart b/lib/helpers/extensions/show_image_viewer.dart new file mode 100644 index 0000000..9be95b8 --- /dev/null +++ b/lib/helpers/extensions/show_image_viewer.dart @@ -0,0 +1,83 @@ +import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:m3e_buttons/m3e_buttons.dart"; +import "package:material_ui/material_ui.dart"; +import "package:nexus/helpers/extensions/save_attachment.dart"; +import "package:nexus/helpers/extensions/size_to_string.dart"; +import "package:nexus/helpers/mxc_image.dart"; +import "package:nexus/models/requests/download_media.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; + +extension ShowImageViewer on BuildContext { + /// Shows the image from [request] fullscreen, zoomable. + /// + /// If [downloadFilename] is set, a download button is shown, suggesting it. + void showImageViewer( + WidgetRef ref, + DownloadMediaRequest request, { + String? downloadFilename, + int? size, + }) => showDialog( + context: this, + builder: (context) => SafeArea( + child: Stack( + children: [ + Positioned.fill( + child: GestureDetector( + onTap: Navigator.of(context).pop, + child: InteractiveViewer( + maxScale: 10, + child: Image( + errorBuilder: (_, error, stackTrace) => ErrorDialog( + "Loading failed for ${request.mxc}\nError: $error", + stackTrace, + ), + image: MxcImage(ref, request), + ), + ), + ), + ), + if (size != null) + Align( + alignment: .topLeft, + child: Padding( + padding: .all(32), + child: Card( + margin: .zero, + child: Padding( + padding: .symmetric(horizontal: 12, vertical: 8), + child: Text(size.sizeAsString), + ), + ), + ), + ), + Align( + alignment: .topRight, + child: Padding( + padding: .all(32), + child: Row( + mainAxisSize: .min, + spacing: 8, + children: [ + if (downloadFilename != null) + M3EButton( + onPressed: () => context.saveAttachment( + ref, + request.mxc, + encrypted: request.encrypted, + filename: downloadFilename, + ), + child: Icon(Icons.download), + ), + M3EButton( + onPressed: Navigator.of(context).pop, + child: Icon(Icons.close), + ), + ], + ), + ), + ), + ], + ), + ), + ); +} diff --git a/lib/helpers/extensions/show_user_popover.dart b/lib/helpers/extensions/show_user_popover.dart index af3e00e..e7018c0 100644 --- a/lib/helpers/extensions/show_user_popover.dart +++ b/lib/helpers/extensions/show_user_popover.dart @@ -1,6 +1,6 @@ import "package:material_ui/material_ui.dart"; import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; -import "package:nexus/widgets/user_bottom_sheet.dart"; +import "package:nexus/widgets/users/user_bottom_sheet.dart"; extension ShowUserPopover on BuildContext { void showUserPopover(String userId, {String? roomId, Rect? anchor}) => diff --git a/lib/helpers/hooks/chat_scroll.dart b/lib/helpers/hooks/chat_scroll.dart index 47f3e40..77d688a 100644 --- a/lib/helpers/hooks/chat_scroll.dart +++ b/lib/helpers/hooks/chat_scroll.dart @@ -14,6 +14,7 @@ final class ChatScroll({ required final IList liveRows, required final GlobalKey centerKey, required final ScrollController scrollController, + required final bool atBottom, required final int? highlightedEvent, @@ -109,6 +110,13 @@ final class ChatScroll({ final lastRowId = controllerData.value?.timeline.lastOrNull; final previousLastRowId = useRef(null); + void updateAtBottom() { + if (!hookContext.mounted || !scrollController.hasClients) return; + + final isAtBottom = scrollController.position.extentBefore <= 0; + if (isAtBottom != atBottom.value) atBottom.value = isAtBottom; + } + useEffect(() { final previous = previousLastRowId.value; previousLastRowId.value = lastRowId; @@ -123,6 +131,10 @@ final class ChatScroll({ anchorId.value = lastRowId; scrollController.position.correctPixels(0); + + // Other callbacks this frame still see the new event below the old + // anchor, so they think it isn't at the bottom until the next frame + WidgetsBinding.instance.addPostFrameCallback((_) => updateAtBottom()); }); return null; @@ -136,9 +148,7 @@ final class ChatScroll({ if (!scrollController.hasClients) return; final position = scrollController.position; - - final isAtBottom = position.extentBefore <= 0; - if (isAtBottom != atBottom.value) atBottom.value = isAtBottom; + updateAtBottom(); // contextualEvent updates immediately when jumping, but // controllerData is only for the historical timeline once it loads @@ -152,6 +162,8 @@ final class ChatScroll({ await paginate(.forward); } + if (!hookContext.mounted || !scrollController.hasClients) return; + if (!isHistorical && position.extentBefore <= 0) await markRead(); if (controllerData.isLoading == false && @@ -208,7 +220,7 @@ final class ChatScroll({ liveRows: split.live, centerKey: centerKey, scrollController: scrollController, - atBottom: atBottom.value, + atBottom: atBottom.value && contextualEvent.value == null, highlightedEvent: highlightedEvent.value, keyFor: keyFor, jumpToEvent: (int rowId) async { diff --git a/lib/helpers/launch_helper.dart b/lib/helpers/launch_helper.dart index 89c7015..82f1806 100644 --- a/lib/helpers/launch_helper.dart +++ b/lib/helpers/launch_helper.dart @@ -1,17 +1,30 @@ import "package:flutter/services.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:material_ui/material_ui.dart"; +import "package:nexus/helpers/extensions/show_error_snack_bar.dart"; +import "package:nexus/main.dart"; import "package:url_launcher/url_launcher.dart" as ul; class LaunchHelper(Ref ref) { Future launchUrl(Uri url, {bool useWebview = false}) async { - try { - return await ul.launchUrl( - url, - mode: useWebview ? .inAppBrowserView : .externalApplication, + final launched = await ul + .launchUrl( + url, + mode: useWebview ? .inAppBrowserView : .externalApplication, + ) + .catchError((_) => false, test: (error) => error is PlatformException); + + if (navigatorKey.currentContext case final context? + when !launched && context.mounted) { + ScaffoldMessenger.of(context).showErrorSnackBar( + "Couldn't open $url. Is there a browser installed?", + action: ( + label: "Copy link", + onPressed: () => Clipboard.setData(.new(text: url.toString())), + ), ); - } on PlatformException catch (_) { - return false; } + return launched; } static final provider = Provider(LaunchHelper.new); diff --git a/lib/helpers/mxc_image.dart b/lib/helpers/mxc_image.dart index 4013397..d82d485 100644 --- a/lib/helpers/mxc_image.dart +++ b/lib/helpers/mxc_image.dart @@ -1,6 +1,7 @@ import "dart:async"; import "dart:io"; import "dart:isolate"; +import "dart:typed_data"; import "dart:ui" as ui; import "package:avif_native/avif_native.dart"; @@ -20,20 +21,28 @@ class MxcImage(final WidgetRef ref, final DownloadMediaRequest request) MultiFrameImageStreamCompleter(codec: _loadAsync(decode), scale: 1.0); Future _loadAsync(ImageDecoderCallback decode) async { - final file = await ref - .read(ClientController.provider.notifier) - .downloadMedia(request); - final bytes = await File(file.path).readAsBytes(); + try { + final file = await ref + .read(ClientController.provider.notifier) + .downloadMedia(request); + final bytes = await File(file.path).readAsBytes(); - // Flutter can't decode AVIF on Linux/Windows (or older Android/iOS), so we do it ourselves - if (String.fromCharCodes(bytes.skip(4).take(8)) - case "ftypavif" || "ftypavis") { - return AvifCodec(await Isolate.run(() => decodeAvif(bytes))); + // Flutter can't decode AVIF on Linux/Windows (or older Android/iOS), so we do it ourselves + if (String.fromCharCodes(bytes.skip(4).take(8)) + case "ftypavif" || "ftypavis") { + return AvifCodec(await _decodeAvifInIsolate(bytes)); + } + + return await decode(await .fromUint8List(bytes)); + } catch (_) { + scheduleMicrotask(() => PaintingBinding.instance.imageCache.evict(this)); + rethrow; } - - return decode(await .fromUint8List(bytes)); } + static Future _decodeAvifInIsolate(Uint8List bytes) => + Isolate.run(() => decodeAvif(bytes)); + @override bool operator ==(Object other) => other is MxcImage && other.request == request; diff --git a/lib/main.dart b/lib/main.dart index 6234b0c..299e95a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,7 +4,6 @@ import "package:dynamic_color/dynamic_color.dart"; import "package:flutter/foundation.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:material_emoji_picker/material_emoji_picker.dart"; -import "package:media_kit/media_kit.dart"; import "package:nexus/controllers/active_account.dart"; import "package:nexus/controllers/client.dart"; import "package:nexus/controllers/client_state.dart"; @@ -22,9 +21,9 @@ import "package:nexus/widgets/pages/select_server.dart"; import "package:nexus/widgets/pages/settings.dart"; import "package:nexus/widgets/pages/verify.dart"; import "package:nexus/widgets/account_scope.dart"; -import "package:nexus/widgets/appbar.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/widgets/loading.dart"; +import "package:nexus/widgets/common/appbar.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/widgets/common/loading.dart"; import "package:window_manager/window_manager.dart"; import "package:material_ui/material_ui.dart"; @@ -46,7 +45,11 @@ New Value: ${newValue is AsyncData ? newValue.value : newValue} } void showError(Object error, [StackTrace? stackTrace]) { - if (error.toString().contains("'_nextFrame != null': is not true.")) { + // Harmless Flutter race in animated images (the assert in debug, a null check in release) + if (error.toString().contains("'_nextFrame != null': is not true.") || + stackTrace.toString().contains( + "MultiFrameImageStreamCompleter._handleAppFrame", + )) { return; } @@ -65,7 +68,6 @@ void showError(Object error, [StackTrace? stackTrace]) { void main(List args) async { WidgetsFlutterBinding.ensureInitialized(); - MediaKit.ensureInitialized(); LicenseRegistry.addLicense(() => .fromIterable(fontLicenses)); diff --git a/lib/models/configs/author.dart b/lib/models/configs/author.dart new file mode 100644 index 0000000..a3a15e9 --- /dev/null +++ b/lib/models/configs/author.dart @@ -0,0 +1,19 @@ +import "package:freezed_annotation/freezed_annotation.dart"; +import "package:nexus/models/event.dart"; + +part "author.freezed.dart"; + +@freezed +class const AuthorConfig({ + required final String roomId, + required final String userId, + final Uri? avatarUrl, + final String? displayName, +}) with _$AuthorConfig { + factory AuthorConfig.fromEvent(Event event) => .new( + roomId: event.roomId, + userId: event.sender, + avatarUrl: event.pmp?.avatarUrl, + displayName: event.pmp?.displayName, + ); +} diff --git a/lib/models/homeserver.dart b/lib/models/homeserver.dart index 5504941..ca1a271 100644 --- a/lib/models/homeserver.dart +++ b/lib/models/homeserver.dart @@ -1,4 +1,5 @@ import "package:freezed_annotation/freezed_annotation.dart"; +import "package:material_ui/material_ui.dart"; part "homeserver.freezed.dart"; @@ -7,5 +8,5 @@ class const Homeserver({ required final String name, required final String description, required final Uri url, - required final String iconUrl, + required final Widget icon, }) with _$Homeserver; diff --git a/lib/models/push_rules.dart b/lib/models/push_rules.dart index a23d12b..88fb050 100644 --- a/lib/models/push_rules.dart +++ b/lib/models/push_rules.dart @@ -15,18 +15,20 @@ class const PushRules({final PushRuleset global = const .new()}) _$PushRulesFromJson(json); } -/// Push rules by kind, apart from room and sender rules, which Nexus doesn't -/// use. The first rule that matches decides what happens. +/// Push rules by kind, apart from sender rules, which Nexus doesn't use. The +/// first rule that matches decides what happens. @Freezed(toJson: false, fromJson: false) @JsonSerializable() class const PushRuleset({ final IList override = const .empty(), final IList content = const .empty(), + final IList room = const .empty(), final IList underride = const .empty(), }) with _$PushRuleset { IList ofKind(PushRuleKind kind) => switch (kind) { .override => override, .content => content, + .room => room, .underride => underride, }; @@ -46,7 +48,7 @@ class const PushRuleset({ _$PushRulesetFromJson(json); } -enum PushRuleKind { override, content, underride } +enum PushRuleKind { override, content, room, underride } @Freezed(toJson: false, fromJson: false) @JsonSerializable() @@ -60,6 +62,9 @@ class const PushRule({ /// What content rules match in messages' bodies. final String? pattern, + + /// What override and underride rules match. + final IList conditions = const .empty(), }) with _$PushRule { Map toJson() => _$PushRuleToJson(this); @@ -67,6 +72,24 @@ class const PushRule({ _$PushRuleFromJson(json); } +/// Only the fields of event_match conditions are kept. +@Freezed(toJson: false, fromJson: false) +@JsonSerializable() +class const PushCondition({ + required final String kind, + final String? key, + final String? pattern, +}) with _$PushCondition { + /// Matches events in the room with [roomId]. + factory PushCondition.inRoom(String roomId) => + .new(kind: "event_match", key: "room_id", pattern: roomId); + + Map toJson() => _$PushConditionToJson(this); + + factory PushCondition.fromJson(Map json) => + _$PushConditionFromJson(json); +} + /// What happens when a push rule matches. Actions Nexus doesn't support are /// dropped, so they're replaced when these are changed. @Freezed(toJson: false, fromJson: false) diff --git a/lib/models/reaction_group.dart b/lib/models/reaction_group.dart new file mode 100644 index 0000000..b3ea32c --- /dev/null +++ b/lib/models/reaction_group.dart @@ -0,0 +1,10 @@ +import "package:fast_immutable_collections/fast_immutable_collections.dart"; +import "package:freezed_annotation/freezed_annotation.dart"; + +part "reaction_group.freezed.dart"; + +@Freezed(toJson: false, fromJson: false) +class const ReactionGroup({ + required final IList senders, + final String? shortcode, +}) with _$ReactionGroup; diff --git a/lib/models/room_notification_level.dart b/lib/models/room_notification_level.dart new file mode 100644 index 0000000..36a5029 --- /dev/null +++ b/lib/models/room_notification_level.dart @@ -0,0 +1,49 @@ +import "package:material_ui/material_ui.dart"; +import "package:nexus/models/push_rules.dart"; + +enum RoomNotificationLevel( + final String title, + final String description, + final IconData icon, +) { + global( + "Default", + "Follows your global notification rules.", + Icons.notifications, + ), + allMessages( + "All Messages", + "Every message notifies you.", + Icons.notifications_active, + ), + mentionsAndKeywords( + "Mentions & Keywords", + "Only messages that mention you or contain your keywords notify you.", + Icons.alternate_email, + ), + mute("Mute", "Nothing in this room notifies you.", Icons.notifications_off); + + static RoomNotificationLevel of(PushRuleset ruleset, String roomId) => + switch ((ruleset.find(.override, roomId), ruleset.find(.room, roomId))) { + (PushRule(enabled: true, actions: PushActions(notify: false)), _) => + .mute, + (_, PushRule(enabled: true, actions: PushActions(notify: true))) => + .allMessages, + (_, PushRule(enabled: true)) => .mentionsAndKeywords, + _ => .global, + }; + + ({PushRuleKind kind, PushRule rule})? ruleFor(String roomId) => + switch (this) { + .global => null, + .allMessages => ( + kind: .room, + rule: .new(ruleId: roomId, actions: .notifyWithSound), + ), + .mentionsAndKeywords => (kind: .room, rule: .new(ruleId: roomId)), + .mute => ( + kind: .override, + rule: .new(ruleId: roomId, conditions: .new([.inRoom(roomId)])), + ), + }; +} diff --git a/lib/widgets/account_scope.dart b/lib/widgets/account_scope.dart index 3f89b4b..ff8db09 100644 --- a/lib/widgets/account_scope.dart +++ b/lib/widgets/account_scope.dart @@ -1,5 +1,6 @@ import "package:flutter_hooks/flutter_hooks.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:flutter_riverpod/misc.dart"; import "package:material_ui/material_ui.dart"; import "package:nexus/controllers/active_account.dart"; import "package:nexus/controllers/notification_request.dart"; @@ -11,6 +12,9 @@ class const AccountScope({ required final Widget child, final List? observers, final Duration? Function(int retryCount, Object error)? retry, + + /// Applied to each account's scope, after its own, e.g. for test fakes + final List overrides = const [], super.key, }) extends HookWidget { @override @@ -34,6 +38,7 @@ class const AccountScope({ NotificationRequestController.provider.overrideWithBuild( (_, _) => active.value.notificationRowId, ), + ...overrides, ], child: child, ); diff --git a/lib/widgets/avatar_or_hash.dart b/lib/widgets/avatars/avatar_or_hash.dart similarity index 79% rename from lib/widgets/avatar_or_hash.dart rename to lib/widgets/avatars/avatar_or_hash.dart index bdaf657..bb14c78 100644 --- a/lib/widgets/avatar_or_hash.dart +++ b/lib/widgets/avatars/avatar_or_hash.dart @@ -12,9 +12,18 @@ final class const AvatarOrHash( }) extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { + final color = ColorHash(title).color; final box = ColoredBox( - color: ColorHash(title).color, - child: Center(child: Icon(Icons.person, size: dimension / 2)), + color: color, + child: Center( + child: Icon( + Icons.person, + size: dimension / 2, + color: ThemeData.estimateBrightnessForColor(color) == .dark + ? Colors.white + : Colors.black, + ), + ), ); return SizedBox( diff --git a/lib/widgets/avatar_ring.dart b/lib/widgets/avatars/avatar_ring.dart similarity index 100% rename from lib/widgets/avatar_ring.dart rename to lib/widgets/avatars/avatar_ring.dart diff --git a/lib/widgets/editable_avatar.dart b/lib/widgets/avatars/editable_avatar.dart similarity index 100% rename from lib/widgets/editable_avatar.dart rename to lib/widgets/avatars/editable_avatar.dart diff --git a/lib/widgets/image_pack_avatar.dart b/lib/widgets/avatars/image_pack_avatar.dart similarity index 86% rename from lib/widgets/image_pack_avatar.dart rename to lib/widgets/avatars/image_pack_avatar.dart index aaebca2..42504ae 100644 --- a/lib/widgets/image_pack_avatar.dart +++ b/lib/widgets/avatars/image_pack_avatar.dart @@ -1,5 +1,5 @@ import "package:material_ui/material_ui.dart"; -import "package:nexus/widgets/mxc_emoji.dart"; +import "package:nexus/widgets/emoji/mxc_emoji.dart"; class const ImagePackAvatar(final Uri? icon, {super.key}) extends StatelessWidget { diff --git a/lib/widgets/account_switcher.dart b/lib/widgets/common/account_switcher.dart similarity index 98% rename from lib/widgets/account_switcher.dart rename to lib/widgets/common/account_switcher.dart index 6c9c93b..3d0f996 100644 --- a/lib/widgets/account_switcher.dart +++ b/lib/widgets/common/account_switcher.dart @@ -7,7 +7,7 @@ import "package:nexus/controllers/active_account.dart"; import "package:nexus/helpers/extensions/log_out.dart"; import "package:nexus/main.dart"; import "package:nexus/models/account.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; /// Switches between, adds and logs out of accounts. With [onlyWithOthers], it's /// hidden when there's only one account. diff --git a/lib/widgets/appbar.dart b/lib/widgets/common/appbar.dart similarity index 100% rename from lib/widgets/appbar.dart rename to lib/widgets/common/appbar.dart diff --git a/lib/widgets/bouncing_dots.dart b/lib/widgets/common/bouncing_dots.dart similarity index 100% rename from lib/widgets/bouncing_dots.dart rename to lib/widgets/common/bouncing_dots.dart diff --git a/lib/widgets/count_badge.dart b/lib/widgets/common/count_badge.dart similarity index 100% rename from lib/widgets/count_badge.dart rename to lib/widgets/common/count_badge.dart diff --git a/lib/widgets/divider_text.dart b/lib/widgets/common/divider_text.dart similarity index 82% rename from lib/widgets/divider_text.dart rename to lib/widgets/common/divider_text.dart index c44ae11..2c623ba 100644 --- a/lib/widgets/divider_text.dart +++ b/lib/widgets/common/divider_text.dart @@ -1,5 +1,5 @@ import "package:material_ui/material_ui.dart"; -import "package:nexus/widgets/divider_widget.dart"; +import "package:nexus/widgets/common/divider_widget.dart"; final class const DividerText(final String text, {super.key}) extends StatelessWidget { diff --git a/lib/widgets/divider_widget.dart b/lib/widgets/common/divider_widget.dart similarity index 100% rename from lib/widgets/divider_widget.dart rename to lib/widgets/common/divider_widget.dart diff --git a/lib/widgets/error_dialog.dart b/lib/widgets/common/error_dialog.dart similarity index 100% rename from lib/widgets/error_dialog.dart rename to lib/widgets/common/error_dialog.dart diff --git a/lib/widgets/common/expandable_image.dart b/lib/widgets/common/expandable_image.dart new file mode 100644 index 0000000..34a1f76 --- /dev/null +++ b/lib/widgets/common/expandable_image.dart @@ -0,0 +1,28 @@ +import "package:material_ui/material_ui.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; +import "package:nexus/helpers/extensions/show_image_viewer.dart"; +import "package:nexus/models/requests/download_media.dart"; + +final class const ExpandableImage( + final DownloadMediaRequest? request, { + required final Widget child, + + /// If set, a download button is shown, suggesting this filename + final String? downloadFilename, + final int? size, + super.key, +}) extends ConsumerWidget { + @override + Widget build(BuildContext context, WidgetRef ref) => InkWell( + onTap: switch (request) { + final request? => () => context.showImageViewer( + ref, + request, + downloadFilename: downloadFilename, + size: size, + ), + null => null, + }, + child: child, + ); +} diff --git a/lib/widgets/highlight_wrapper.dart b/lib/widgets/common/highlight_wrapper.dart similarity index 100% rename from lib/widgets/highlight_wrapper.dart rename to lib/widgets/common/highlight_wrapper.dart diff --git a/lib/widgets/linkified_text.dart b/lib/widgets/common/linkified_text.dart similarity index 100% rename from lib/widgets/linkified_text.dart rename to lib/widgets/common/linkified_text.dart diff --git a/lib/widgets/loading.dart b/lib/widgets/common/loading.dart similarity index 100% rename from lib/widgets/loading.dart rename to lib/widgets/common/loading.dart diff --git a/lib/widgets/m3e_rail_theme.dart b/lib/widgets/common/m3e_rail_theme.dart similarity index 100% rename from lib/widgets/m3e_rail_theme.dart rename to lib/widgets/common/m3e_rail_theme.dart diff --git a/lib/widgets/sync_status_banner.dart b/lib/widgets/common/sync_status_banner.dart similarity index 93% rename from lib/widgets/sync_status_banner.dart rename to lib/widgets/common/sync_status_banner.dart index 10aec7e..0eccff3 100644 --- a/lib/widgets/sync_status_banner.dart +++ b/lib/widgets/common/sync_status_banner.dart @@ -1,7 +1,8 @@ import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:material_ui/material_ui.dart"; +import "package:nexus/controllers/clock.dart"; import "package:nexus/controllers/sync_status.dart"; -import "package:nexus/widgets/error_dialog.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; import "package:timeago/timeago.dart"; class const SyncStatusBanner({super.key}) extends ConsumerWidget { @@ -38,7 +39,7 @@ class const SyncStatusBanner({super.key}) extends ConsumerWidget { ?status.error, if (status.errorCount > 0) "Failed attempts: ${status.errorCount}.", if (status.lastSync case final lastSync?) - "Last synced ${format(lastSync)}.", + "Last synced ${format(lastSync, clock: ref.watch(ClockController.provider))}.", ]; return AnimatedSize( diff --git a/lib/widgets/timestamp.dart b/lib/widgets/common/timestamp.dart similarity index 58% rename from lib/widgets/timestamp.dart rename to lib/widgets/common/timestamp.dart index bc9db74..2f7a2fc 100644 --- a/lib/widgets/timestamp.dart +++ b/lib/widgets/common/timestamp.dart @@ -1,13 +1,15 @@ +import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:material_ui/material_ui.dart"; +import "package:nexus/controllers/clock.dart"; import "package:timeago/timeago.dart"; class const Timestamp(final DateTime timestamp, {super.key}) - extends StatelessWidget { + extends ConsumerWidget { @override - Widget build(BuildContext context) => Tooltip( + Widget build(BuildContext context, WidgetRef ref) => Tooltip( message: timestamp.toString(), child: Text( - format(timestamp), + format(timestamp, clock: ref.watch(ClockController.provider)), maxLines: 1, overflow: .ellipsis, style: Theme.of(context).textTheme.labelSmall diff --git a/lib/widgets/composer/bot_command_panel.dart b/lib/widgets/composer/bot_command_panel.dart index 8a06754..bc6c05a 100644 --- a/lib/widgets/composer/bot_command_panel.dart +++ b/lib/widgets/composer/bot_command_panel.dart @@ -9,7 +9,7 @@ import "package:nexus/controllers/bot_command_draft.dart"; import "package:nexus/models/bot_argument_suggestion.dart"; import "package:nexus/models/bot_command.dart"; import "package:nexus/models/text_command.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; class const BotCommandPanel( final ComposerParams composer, { diff --git a/lib/widgets/composer/composer.dart b/lib/widgets/composer/composer.dart index 1b70ec3..3b722e0 100644 --- a/lib/widgets/composer/composer.dart +++ b/lib/widgets/composer/composer.dart @@ -17,7 +17,7 @@ import "package:nexus/models/composer_params.dart"; import "package:nexus/models/text_command.dart"; import "package:nexus/widgets/composer/bot_command_form.dart"; import "package:nexus/widgets/composer/bot_command_panel.dart"; -import "package:nexus/widgets/emoji_picker.dart"; +import "package:nexus/widgets/emoji/emoji_picker.dart"; import "package:material_ui/material_ui.dart"; import "package:flutter/services.dart"; import "package:flutter_hooks/flutter_hooks.dart"; @@ -33,12 +33,14 @@ import "package:nexus/controllers/power_level.dart"; import "package:nexus/controllers/image_packs.dart"; import "package:nexus/models/content/image_pack.dart"; import "package:nexus/models/content/message.dart"; +import "package:nexus/widgets/renderers/message_media.dart"; +import "package:nexus/helpers/extensions/is_media.dart"; import "package:nexus/models/content/poll_start.dart"; import "package:nexus/models/image_pack.dart"; -import "package:nexus/widgets/mxc_emoji.dart"; -import "package:nexus/widgets/sticker_picker.dart"; -import "package:nexus/widgets/create_poll_sheet.dart"; -import "package:nexus/widgets/location_picker_sheet.dart"; +import "package:nexus/widgets/emoji/mxc_emoji.dart"; +import "package:nexus/widgets/emoji/sticker_picker.dart"; +import "package:nexus/widgets/composer/create_poll_sheet.dart"; +import "package:nexus/widgets/location/location_picker_sheet.dart"; import "package:nexus/models/location.dart"; import "package:nexus/widgets/composer/overlays/tagger_overlay.dart"; import "package:nexus/widgets/composer/paste_files_action.dart"; @@ -482,19 +484,47 @@ class const Composer( if (attachment != null) Card( margin: .only(bottom: 8), - child: ListTile( - leading: attachment.$2 == null - ? SizedBox( + child: Column( + children: [ + ListTile( + leading: switch (attachment.$2) { + null => SizedBox( width: 16, height: 16, child: CircularProgressIndicator(), - ) - : Icon(Icons.file_copy), - title: Text(attachment.$1), - trailing: IconButton( - onPressed: () => ref.invalidate(attachmentProvider), - icon: Icon(Icons.close), - ), + ), + ImageMessageContent() => Icon(Icons.image), + VideoMessageContent() => Icon(Icons.movie), + AudioMessageContent() => Icon(Icons.audiotrack), + _ => Icon(Icons.file_copy), + }, + title: Text(attachment.$1), + trailing: IconButton( + onPressed: () => ref.invalidate(attachmentProvider), + icon: Icon(Icons.close), + ), + ), + AnimatedSize( + duration: Durations.short4, + alignment: .topCenter, + child: switch (attachment.$2) { + final content? + when content is! FileMessageContent && + content.isMedia => + Padding( + padding: EdgeInsets.all(12).copyWith(top: 0), + child: Align( + alignment: .centerLeft, + child: ConstrainedBox( + constraints: .loose(.square(300)), + child: MessageMedia(content), + ), + ), + ), + _ => SizedBox(width: .infinity), + }, + ), + ], ), ), AnimatedSize( @@ -804,6 +834,21 @@ class const Composer( controller.addTag(id: id, name: name); node?.requestFocus(); }, + insertText: (text) { + final end = + controller.selection.baseOffset; + controller + ..dismissOverlay() + ..value = controller.value.replaced( + .new( + start: + end - query.value.length - 1, + end: end, + ), + "$text ", + ); + node?.requestFocus(); + }, ), controller: controller, onSearch: (newQuery, newTriggerCharacter) { diff --git a/lib/widgets/create_poll_sheet.dart b/lib/widgets/composer/create_poll_sheet.dart similarity index 100% rename from lib/widgets/create_poll_sheet.dart rename to lib/widgets/composer/create_poll_sheet.dart diff --git a/lib/widgets/composer/overlays/emoji_overlay.dart b/lib/widgets/composer/overlays/emoji_overlay.dart index bb4b88f..6f9c15f 100644 --- a/lib/widgets/composer/overlays/emoji_overlay.dart +++ b/lib/widgets/composer/overlays/emoji_overlay.dart @@ -12,6 +12,7 @@ class const EmojiOverlay( required final String roomId, required final void Function({required String id, required String name}) addTag, + required final void Function(String text) insertText, super.key, }) extends ConsumerWidget { @override @@ -38,19 +39,19 @@ class const EmojiOverlay( ), title: Text(emoji.aliases.first), subtitle: Text(emoji.description), - onTap: () => addTag( - id: emoji.value.startsWith("mxc://") - ? ImagePack.emojiMarkdown( + onTap: () => emoji.value.startsWith("mxc://") + ? addTag( + id: ImagePack.emojiMarkdown( emoji.aliases.first, emoji.value, description: switch (emoji.data) { PackImage(:final body) => body, _ => null, }, - ) - : emoji.value, - name: emoji.aliases.first, - ), + ), + name: emoji.aliases.first, + ) + : insertText(emoji.value), ), ) .toList(), diff --git a/lib/widgets/composer/overlays/room_overlay.dart b/lib/widgets/composer/overlays/room_overlay.dart index f4778a8..c95db16 100644 --- a/lib/widgets/composer/overlays/room_overlay.dart +++ b/lib/widgets/composer/overlays/room_overlay.dart @@ -3,7 +3,7 @@ import "package:material_ui/material_ui.dart"; import "package:nexus/controllers/rooms.dart"; import "package:nexus/controllers/via.dart"; import "package:nexus/helpers/extensions/weighted_search.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; class const RoomOverlay( final String query, { diff --git a/lib/widgets/composer/overlays/tagger_overlay.dart b/lib/widgets/composer/overlays/tagger_overlay.dart index 7d973dc..e32a328 100644 --- a/lib/widgets/composer/overlays/tagger_overlay.dart +++ b/lib/widgets/composer/overlays/tagger_overlay.dart @@ -3,13 +3,14 @@ import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:nexus/widgets/composer/overlays/room_overlay.dart"; import "package:nexus/widgets/composer/overlays/user_overlay.dart"; import "package:nexus/widgets/composer/overlays/emoji_overlay.dart"; -import "package:nexus/widgets/loading.dart"; +import "package:nexus/widgets/common/loading.dart"; class const TaggerOverlay( final String query, { required final String roomId, required final void Function({required String id, required String name}) addTag, + required final void Function(String text) insertText, required final String? triggerCharacter, super.key, }) extends ConsumerWidget { @@ -27,7 +28,12 @@ class const TaggerOverlay( child: switch (triggerCharacter) { "@" => UserOverlay(query, roomId: roomId, addTag: addTag), "#" => RoomOverlay(query, addTag: addTag), - ":" => EmojiOverlay(query, roomId: roomId, addTag: addTag), + ":" => EmojiOverlay( + query, + roomId: roomId, + addTag: addTag, + insertText: insertText, + ), _ => Loading(), }, diff --git a/lib/widgets/composer/overlays/user_overlay.dart b/lib/widgets/composer/overlays/user_overlay.dart index e6f122b..845fb3a 100644 --- a/lib/widgets/composer/overlays/user_overlay.dart +++ b/lib/widgets/composer/overlays/user_overlay.dart @@ -5,7 +5,7 @@ import "package:nexus/helpers/extensions/better_when.dart"; import "package:nexus/helpers/extensions/get_localpart.dart"; import "package:nexus/helpers/extensions/weighted_search.dart"; import "package:nexus/models/content/membership.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; class const UserOverlay( final String query, { @@ -41,7 +41,7 @@ class const UserOverlay( title: Text(displayName ?? member.stateKey!.localpart), subtitle: Text(member.stateKey!), onTap: () => addTag( - id: "[@$displayName](matrix:u/${member.stateKey!.substring(1)})", + id: "[@${displayName ?? member.stateKey!.localpart}](matrix:u/${member.stateKey!.substring(1)})", name: member.stateKey!.localpart, ), ), diff --git a/lib/widgets/composer/relation_preview.dart b/lib/widgets/composer/relation_preview.dart index 5af01ee..f319d74 100644 --- a/lib/widgets/composer/relation_preview.dart +++ b/lib/widgets/composer/relation_preview.dart @@ -2,7 +2,7 @@ import "package:material_ui/material_ui.dart"; import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:nexus/models/event.dart"; import "package:nexus/models/relation_type.dart"; -import "package:nexus/widgets/event_preview.dart"; +import "package:nexus/widgets/renderers/event_preview.dart"; class const RelationPreview( final Event? relatedEvent, { diff --git a/lib/widgets/composer/typing_indicator.dart b/lib/widgets/composer/typing_indicator.dart index 9624937..9cacb9c 100644 --- a/lib/widgets/composer/typing_indicator.dart +++ b/lib/widgets/composer/typing_indicator.dart @@ -5,8 +5,8 @@ import "package:nexus/controllers/room_typing.dart"; import "package:nexus/controllers/user.dart"; import "package:nexus/helpers/extensions/get_localpart.dart"; import "package:nexus/helpers/hooks/tap_recognizer.dart"; -import "package:nexus/widgets/bouncing_dots.dart"; -import "package:nexus/widgets/user_span.dart"; +import "package:nexus/widgets/common/bouncing_dots.dart"; +import "package:nexus/widgets/users/user_span.dart"; class const TypingIndicator(final String roomId, {super.key}) extends HookConsumerWidget { diff --git a/lib/widgets/emoji_picker.dart b/lib/widgets/emoji/emoji_picker.dart similarity index 100% rename from lib/widgets/emoji_picker.dart rename to lib/widgets/emoji/emoji_picker.dart diff --git a/lib/widgets/mxc_emoji.dart b/lib/widgets/emoji/mxc_emoji.dart similarity index 100% rename from lib/widgets/mxc_emoji.dart rename to lib/widgets/emoji/mxc_emoji.dart diff --git a/lib/widgets/sticker_picker.dart b/lib/widgets/emoji/sticker_picker.dart similarity index 100% rename from lib/widgets/sticker_picker.dart rename to lib/widgets/emoji/sticker_picker.dart diff --git a/lib/widgets/recovery_key_sheet.dart b/lib/widgets/encryption/recovery_key_sheet.dart similarity index 100% rename from lib/widgets/recovery_key_sheet.dart rename to lib/widgets/encryption/recovery_key_sheet.dart diff --git a/lib/widgets/reset_encryption_sheet.dart b/lib/widgets/encryption/reset_encryption_sheet.dart similarity index 99% rename from lib/widgets/reset_encryption_sheet.dart rename to lib/widgets/encryption/reset_encryption_sheet.dart index c223b37..40b0074 100644 --- a/lib/widgets/reset_encryption_sheet.dart +++ b/lib/widgets/encryption/reset_encryption_sheet.dart @@ -6,7 +6,7 @@ import "package:nexus/controllers/client.dart"; import "package:nexus/controllers/client_state.dart"; import "package:nexus/main.dart"; import "package:nexus/models/client_state.dart"; -import "package:nexus/widgets/recovery_key_sheet.dart"; +import "package:nexus/widgets/encryption/recovery_key_sheet.dart"; class const ResetEncryptionSheet({ /// Whether this is shown as a page rather than in a sheet, in which case it diff --git a/lib/widgets/expandable_image.dart b/lib/widgets/expandable_image.dart deleted file mode 100644 index f10221e..0000000 --- a/lib/widgets/expandable_image.dart +++ /dev/null @@ -1,73 +0,0 @@ -import "package:material_ui/material_ui.dart"; -import "package:hooks_riverpod/hooks_riverpod.dart"; -import "package:m3e_buttons/m3e_buttons.dart"; -import "package:nexus/helpers/extensions/save_attachment.dart"; -import "package:nexus/helpers/mxc_image.dart"; -import "package:nexus/models/requests/download_media.dart"; -import "package:nexus/widgets/error_dialog.dart"; - -final class const ExpandableImage( - final DownloadMediaRequest? request, { - required final Widget child, - - /// If set, a download button is shown, suggesting this filename - final String? downloadFilename, - super.key, -}) extends ConsumerWidget { - @override - Widget build(BuildContext context, WidgetRef ref) => InkWell( - onTap: request == null - ? null - : () => showDialog( - context: context, - builder: (_) => SafeArea( - child: Stack( - children: [ - Positioned.fill( - child: GestureDetector( - onTap: Navigator.of(context).pop, - child: InteractiveViewer( - maxScale: 10, - child: Image( - errorBuilder: (_, error, stackTrace) => ErrorDialog( - "Loading failed for ${request?.mxc}\nError: $error", - stackTrace, - ), - image: MxcImage(ref, request!), - ), - ), - ), - ), - Align( - alignment: .topRight, - child: Padding( - padding: .all(32), - child: Row( - mainAxisSize: .min, - spacing: 8, - children: [ - if (downloadFilename != null) - M3EButton( - onPressed: () => context.saveAttachment( - ref, - request!.mxc, - encrypted: request!.encrypted, - filename: downloadFilename, - ), - child: Icon(Icons.download), - ), - M3EButton( - onPressed: Navigator.of(context).pop, - child: Icon(Icons.close), - ), - ], - ), - ), - ), - ], - ), - ), - ), - child: child, - ); -} diff --git a/lib/widgets/html/html.dart b/lib/widgets/html/html.dart index d717a8a..9236e9a 100644 --- a/lib/widgets/html/html.dart +++ b/lib/widgets/html/html.dart @@ -6,7 +6,7 @@ import "package:html/dom.dart" as dom; import "package:nexus/helpers/extensions/get_link_info.dart"; import "package:nexus/helpers/launch_helper.dart"; import "package:nexus/helpers/mxc_image.dart"; -import "package:nexus/widgets/expandable_image.dart"; +import "package:nexus/widgets/common/expandable_image.dart"; import "package:nexus/widgets/html/mention_chip.dart"; import "package:nexus/widgets/html/spoiler_text.dart"; import "package:nexus/widgets/html/code_block.dart"; diff --git a/lib/widgets/lazy_loading/message_avatar.dart b/lib/widgets/lazy_loading/message_avatar.dart index 0279eca..80a1101 100644 --- a/lib/widgets/lazy_loading/message_avatar.dart +++ b/lib/widgets/lazy_loading/message_avatar.dart @@ -4,7 +4,7 @@ import "package:nexus/controllers/author.dart"; import "package:nexus/helpers/extensions/get_localpart.dart"; import "package:nexus/helpers/extensions/show_user_popover.dart"; import "package:nexus/models/event.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; class const MessageAvatar( final Event event, { @@ -13,7 +13,7 @@ class const MessageAvatar( }) extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) => - switch (ref.watch(AuthorController.provider(event))) { + switch (ref.watch(AuthorController.provider(.fromEvent(event)))) { AsyncData(:final value) || AsyncLoading(:final value?) => InkWell( onTap: () => context.showUserPopover(event.sender, roomId: event.roomId), diff --git a/lib/widgets/lazy_loading/message_displayname.dart b/lib/widgets/lazy_loading/message_displayname.dart index d7c91bd..0f68ac5 100644 --- a/lib/widgets/lazy_loading/message_displayname.dart +++ b/lib/widgets/lazy_loading/message_displayname.dart @@ -18,7 +18,7 @@ class const MessageDisplayname( Widget build(BuildContext context, WidgetRef ref) { final color = ref.displaynameColor(event.roomId, event.sender); - return switch (ref.watch(AuthorController.provider(event))) { + return switch (ref.watch(AuthorController.provider(.fromEvent(event)))) { AsyncData(:final MembershipContent? value) || AsyncLoading(:final value) || AsyncError(:final value) => InkWell( diff --git a/lib/widgets/location_map.dart b/lib/widgets/location/location_map.dart similarity index 100% rename from lib/widgets/location_map.dart rename to lib/widgets/location/location_map.dart diff --git a/lib/widgets/location_message.dart b/lib/widgets/location/location_message.dart similarity index 94% rename from lib/widgets/location_message.dart rename to lib/widgets/location/location_message.dart index 2f22b9d..661b7dd 100644 --- a/lib/widgets/location_message.dart +++ b/lib/widgets/location/location_message.dart @@ -2,8 +2,8 @@ import "package:material_ui/material_ui.dart"; import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; import "package:nexus/models/content/message.dart"; import "package:nexus/models/location.dart"; -import "package:nexus/widgets/location_map.dart"; -import "package:nexus/widgets/location_viewer_sheet.dart"; +import "package:nexus/widgets/location/location_map.dart"; +import "package:nexus/widgets/location/location_viewer_sheet.dart"; class const LocationMessage(final LocationMessageContent content, {super.key}) extends StatelessWidget { diff --git a/lib/widgets/location_picker_sheet.dart b/lib/widgets/location/location_picker_sheet.dart similarity index 98% rename from lib/widgets/location_picker_sheet.dart rename to lib/widgets/location/location_picker_sheet.dart index 10b77ae..4fb61bf 100644 --- a/lib/widgets/location_picker_sheet.dart +++ b/lib/widgets/location/location_picker_sheet.dart @@ -7,7 +7,7 @@ import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; import "package:nexus/helpers/current_location_helper.dart"; import "package:nexus/models/content/message.dart"; import "package:nexus/models/location.dart"; -import "package:nexus/widgets/location_map.dart"; +import "package:nexus/widgets/location/location_map.dart"; /// Chooses a location to share, either the user's own or a pin dropped on the /// map. diff --git a/lib/widgets/location_viewer_sheet.dart b/lib/widgets/location/location_viewer_sheet.dart similarity index 95% rename from lib/widgets/location_viewer_sheet.dart rename to lib/widgets/location/location_viewer_sheet.dart index 48965bc..ca74ab0 100644 --- a/lib/widgets/location_viewer_sheet.dart +++ b/lib/widgets/location/location_viewer_sheet.dart @@ -4,7 +4,7 @@ import "package:material_ui/material_ui.dart"; import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; import "package:nexus/helpers/launch_helper.dart"; import "package:nexus/models/location.dart"; -import "package:nexus/widgets/location_map.dart"; +import "package:nexus/widgets/location/location_map.dart"; class const LocationViewerSheet( final LatLng point, { diff --git a/lib/widgets/pages/chat.dart b/lib/widgets/pages/chat.dart index 4e5ca8f..c5d704f 100644 --- a/lib/widgets/pages/chat.dart +++ b/lib/widgets/pages/chat.dart @@ -8,11 +8,11 @@ import "package:nexus/helpers/extensions/open_link_info.dart"; import "package:nexus/main.dart"; import "package:nexus/controllers/selected_room.dart"; import "package:nexus/controllers/notification_request.dart"; -import "package:nexus/widgets/appbar.dart"; -import "package:nexus/widgets/sidebar.dart"; -import "package:nexus/widgets/sync_status_banner.dart"; +import "package:nexus/widgets/common/appbar.dart"; +import "package:nexus/widgets/sidebar/sidebar.dart"; +import "package:nexus/widgets/common/sync_status_banner.dart"; import "package:nexus/widgets/room_chat/room_chat.dart"; -import "package:nexus/widgets/loading.dart"; +import "package:nexus/widgets/common/loading.dart"; class const ChatPage({super.key}) extends HookConsumerWidget { @override @@ -45,10 +45,10 @@ class const ChatPage({super.key}) extends HookConsumerWidget { WidgetsBinding.instance.addPostFrameCallback((_) { ref.read(LinkRequestController.provider.notifier).consume(); navigatorKey.currentState?.popUntil((route) => route.isFirst); - final navigatorContext = navigatorKey.currentContext; - if (navigatorContext == null) return; + final scaffoldContext = scaffoldKey.currentContext; + if (scaffoldContext == null) return; - ref.openLinkInfo(navigatorContext, linkRequest).onError(showError); + ref.openLinkInfo(scaffoldContext, linkRequest).onError(showError); }); return null; }, [linkRequest, initComplete]); diff --git a/lib/widgets/pages/explore.dart b/lib/widgets/pages/explore.dart index bc8ab2d..3cd77ea 100644 --- a/lib/widgets/pages/explore.dart +++ b/lib/widgets/pages/explore.dart @@ -14,14 +14,14 @@ import "package:nexus/controllers/settings.dart"; import "package:nexus/helpers/extensions/get_localpart.dart"; import "package:nexus/main.dart"; import "package:nexus/helpers/extensions/room_summary_display.dart"; -import "package:nexus/widgets/add_directory_server_sheet.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/room_summary_sheet.dart"; -import "package:nexus/widgets/divider_text.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/widgets/loading.dart"; -import "package:nexus/widgets/m3e_rail_theme.dart"; -import "package:nexus/widgets/room_directory_card.dart"; +import "package:nexus/widgets/rooms/add_directory_server_sheet.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/rooms/room_summary_sheet.dart"; +import "package:nexus/widgets/common/divider_text.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/widgets/common/loading.dart"; +import "package:nexus/widgets/common/m3e_rail_theme.dart"; +import "package:nexus/widgets/rooms/room_directory_card.dart"; class const ExplorePage({super.key}) extends HookConsumerWidget { @override diff --git a/lib/widgets/pages/select_server.dart b/lib/widgets/pages/select_server.dart index 1e20f32..a3102e6 100644 --- a/lib/widgets/pages/select_server.dart +++ b/lib/widgets/pages/select_server.dart @@ -13,9 +13,9 @@ import "package:nexus/models/gomuks_exception.dart"; import "package:nexus/models/homeserver.dart"; import "package:nexus/models/oauth_auth_code_response.dart"; import "package:nexus/widgets/pages/settings.dart"; -import "package:nexus/widgets/account_switcher.dart"; -import "package:nexus/widgets/appbar.dart"; -import "package:nexus/widgets/divider_text.dart"; +import "package:nexus/widgets/common/account_switcher.dart"; +import "package:nexus/widgets/common/appbar.dart"; +import "package:nexus/widgets/common/divider_text.dart"; class const SelectServerPage({super.key}) extends HookConsumerWidget { @override @@ -48,7 +48,7 @@ class const SelectServerPage({super.key}) extends HookConsumerWidget { Future tryLogin(Uri url) async { final OAuthAuthCodeResponse codeResponse; try { - codeResponse = await ref.watch( + codeResponse = await ref.read( AuthUrlController.provider(url).future, ); } on GomuksException catch (error) { @@ -190,31 +190,34 @@ class const SelectServerPage({super.key}) extends HookConsumerWidget { name: "Matrix.org", description: "The Matrix.org Foundation offers the matrix.org homeserver as an easy entry point for anyone wanting to try out Matrix.", url: .https("matrix.org"), - iconUrl: - "https://raw.githubusercontent.com/element-hq/logos/refs/heads/master/matrix/matrix-favicon${Theme.brightnessOf(context) == Brightness.dark ? "-white" : ""}.png", + icon: SvgPicture.asset( + "assets/bundled/matrix.svg", + colorFilter: .mode(theme.colorScheme.onSurface, .srcIn), + ), ), .new( name: "Federated Nexus", description: "Federated Nexus is a community resource hosting multiple FOSS (especially federated) services, including Matrix and Forgejo. By the same developers who made Nexus client.", url: .https("federated.nexus"), - iconUrl: "https://federated.nexus/images/icon.png", + icon: SvgPicture.asset( + "assets/bundled/federated_nexus.svg", + ), ), // TODO: Add back unredacted when they have MAS, find where new favicon is // .new( // name: "Unredacted", // description: "Unredacted is a 501(c)(3) non-profit organization that builds Internet infrastructure and services to help people evade censorship and protect their right to privacy.", // url: .https("unredacted.org", "services/si/matrix"), - // iconUrl: "https://unredacted.org/favicon.ico", + // icon: Image.network("https://unredacted.org/favicon.ico"), // ), ].map( (homeserver) => Card( child: ListTile( enabled: !isLoading.value, title: Text(homeserver.name), - leading: Image.network( - homeserver.iconUrl, - errorBuilder: (_, _, _) => SizedBox.shrink(), - height: 32, + leading: SizedBox.square( + dimension: 32, + child: homeserver.icon, ), subtitle: Text(homeserver.description), onTap: isLoading.value diff --git a/lib/widgets/pages/settings_category.dart b/lib/widgets/pages/settings_category.dart index 69513b8..0efa68e 100644 --- a/lib/widgets/pages/settings_category.dart +++ b/lib/widgets/pages/settings_category.dart @@ -8,7 +8,7 @@ import "package:hooks_riverpod/misc.dart"; import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:nexus/models/settings_category.dart"; import "package:nexus/helpers/extensions/better_when.dart"; -import "package:nexus/widgets/highlight_wrapper.dart"; +import "package:nexus/widgets/common/highlight_wrapper.dart"; import "package:super_sliver_list/super_sliver_list.dart"; class const SettingsCategoryPage( diff --git a/lib/widgets/pages/verify.dart b/lib/widgets/pages/verify.dart index 6cf935d..aa342cd 100644 --- a/lib/widgets/pages/verify.dart +++ b/lib/widgets/pages/verify.dart @@ -5,12 +5,12 @@ import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; import "package:nexus/controllers/client.dart"; import "package:nexus/controllers/client_state.dart"; import "package:nexus/models/client_state.dart"; -import "package:nexus/widgets/loading.dart"; +import "package:nexus/widgets/common/loading.dart"; import "package:nexus/widgets/pages/settings.dart"; -import "package:nexus/widgets/account_switcher.dart"; -import "package:nexus/widgets/appbar.dart"; +import "package:nexus/widgets/common/account_switcher.dart"; +import "package:nexus/widgets/common/appbar.dart"; import "package:nexus/helpers/required_validator_helper.dart"; -import "package:nexus/widgets/reset_encryption_sheet.dart"; +import "package:nexus/widgets/encryption/reset_encryption_sheet.dart"; class const VerifyPage({super.key}) extends HookConsumerWidget { @override diff --git a/lib/widgets/players/audio.dart b/lib/widgets/players/audio.dart index 3e254b0..f29955b 100644 --- a/lib/widgets/players/audio.dart +++ b/lib/widgets/players/audio.dart @@ -1,9 +1,9 @@ import "dart:async"; +import "package:audioplayers/audioplayers.dart" as audioplayers; import "package:material_ui/material_ui.dart"; import "package:flutter_hooks/flutter_hooks.dart"; import "package:hooks_riverpod/hooks_riverpod.dart"; -import "package:media_kit/media_kit.dart"; import "package:nexus/controllers/client.dart"; import "package:nexus/helpers/extensions/save_attachment.dart"; import "package:nexus/models/info/audio.dart"; @@ -18,10 +18,9 @@ class const AudioPlayer( }) extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final player = useMemoized( - () => Player(configuration: .new(bufferSize: 128 * 1024 * 1024)), - ); + final player = useMemoized(audioplayers.AudioPlayer.new); final loaded = useState(false); + final unsupported = useState(false); useEffect(() { scheduleMicrotask(() async { @@ -29,37 +28,84 @@ class const AudioPlayer( .read(ClientController.provider.notifier) .downloadMedia(.new(mxc: uri, encrypted: encrypted)); if (!context.mounted) return; - await player.open(Media(audio.path), play: false); + // Keeps the audio loaded after it finishes, so it can be replayed + await player.setReleaseMode(.stop); + try { + // AVFoundation needs the format, since gomuks caches files without an extension + await player.setSource( + audioplayers.DeviceFileSource(audio.path, mimeType: info?.mimeType), + ); + } on Exception catch (_) { + // The platform can't play this format, like Ogg on Apple platforms or MIDI on Linux + if (context.mounted) unsupported.value = true; + return; + } if (context.mounted) loaded.value = true; }); return player.dispose; }, []); - return SizedBox( - height: 60, - child: Card( - color: Theme.of(context).colorScheme.surfaceContainer, - child: Padding( - padding: .symmetric(horizontal: 8), - child: PlayerControls( - player, - loading: !loaded.value, - actions: .new([ - SizedBox(width: 4), - IconButton( - onPressed: () => context.saveAttachment( - ref, - uri, - encrypted: encrypted, - filename: filename, - ), - tooltip: "Download", - icon: Icon(Icons.download), + final state = + useStream( + player.onPlayerStateChanged, + initialData: player.state, + ).data ?? + player.state; + final position = + useStream(player.onPositionChanged, initialData: Duration.zero).data ?? + Duration.zero; + final duration = + useStream(player.onDurationChanged, initialData: Duration.zero).data ?? + Duration.zero; + final playing = state == .playing; + + final downloadButton = IconButton( + onPressed: () => context.saveAttachment( + ref, + uri, + encrypted: encrypted, + filename: filename, + ), + tooltip: "Download", + icon: Icon(Icons.download), + ); + + return Card( + color: Theme.of(context).colorScheme.surfaceContainerHigh, + child: Padding( + padding: .symmetric(horizontal: 8), + child: unsupported.value + ? Row( + children: [ + Padding( + padding: .all(12), + child: Icon( + Icons.music_off, + color: Theme.of(context).colorScheme.error, + ), + ), + Expanded( + child: Text( + "Can't play this audio format", + style: Theme.of(context).textTheme.bodySmall?.copyWith( + color: Theme.of(context).colorScheme.error, + ), + ), + ), + downloadButton, + ], + ) + : PlayerControls( + playing: playing, + position: position, + duration: duration, + onPlayPause: playing ? player.pause : player.resume, + onSeek: player.seek, + loading: !loaded.value, + size: info?.size, + actions: .new([SizedBox(width: 4), downloadButton]), ), - ]), - ), - ), ), ); } diff --git a/lib/widgets/players/player_controls.dart b/lib/widgets/players/player_controls.dart index 6226260..53a8c5b 100644 --- a/lib/widgets/players/player_controls.dart +++ b/lib/widgets/players/player_controls.dart @@ -1,37 +1,25 @@ import "dart:math"; import "package:fast_immutable_collections/fast_immutable_collections.dart"; -import "package:flutter_hooks/flutter_hooks.dart"; import "package:material_ui/material_ui.dart"; -import "package:media_kit/media_kit.dart"; +import "package:nexus/helpers/extensions/size_to_string.dart"; -/// Play/pause, position and seeking controls for a media_kit [Player]. -class const PlayerControls( - final Player player, { +/// Play/pause, position and seeking controls, for any player. +class const PlayerControls({ + required final bool playing, + required final Duration position, + required final Duration duration, + required final VoidCallback onPlayPause, + required final ValueChanged onSeek, final bool loading = false, + final bool buffering = false, final Color? color, + final int? size, final IList actions = const .empty(), super.key, -}) extends HookWidget { +}) extends StatelessWidget { @override Widget build(BuildContext context) { - final playing = useStream( - player.stream.playing, - initialData: player.state.playing, - ).requireData; - final buffering = useStream( - player.stream.buffering, - initialData: player.state.buffering, - ).requireData; - final position = useStream( - player.stream.position, - initialData: player.state.position, - ).requireData; - final duration = useStream( - player.stream.duration, - initialData: player.state.duration, - ).requireData; - String format(Duration duration) { final minutes = duration.inMinutes .remainder(60) @@ -45,6 +33,8 @@ class const PlayerControls( return "$minutes:$seconds"; } + final sizeSuffix = size == null ? "" : " (${size!.sizeAsString})"; + final textStyle = Theme.of(context).textTheme.bodySmall ?.copyWith(color: color); final max = duration.inMilliseconds <= 0 @@ -57,19 +47,19 @@ class const PlayerControls( child: CircularProgressIndicator(padding: .all(12), color: color), ) : IconButton( - onPressed: player.playOrPause, + onPressed: onPlayPause, color: color, tooltip: playing ? "Pause" : "Play", icon: Icon(playing ? Icons.pause_circle : Icons.play_circle), ); - Slider slider({EdgeInsetsGeometry? padding}) => Slider( + Slider slider({EdgeInsetsGeometry? padding}) => .new( padding: padding, max: max, value: min(position.inMilliseconds.toDouble(), max), onChanged: loading ? null - : (value) => player.seek(.new(milliseconds: value.toInt())), + : (value) => onSeek(.new(milliseconds: value.toInt())), ); return LayoutBuilder( @@ -77,13 +67,14 @@ class const PlayerControls( ? Column( mainAxisSize: .min, children: [ - slider(padding: const .symmetric(horizontal: 12)), + SizedBox(height: 12), + slider(padding: const .symmetric(horizontal: 16)), Row( children: [ playButton, Expanded( child: Text( - "${format(position)} / ${format(duration)}", + "${format(position)} / ${format(duration)}$sizeSuffix", style: textStyle, maxLines: 1, overflow: .ellipsis, @@ -94,15 +85,17 @@ class const PlayerControls( ), ], ) - : Row( - children: [ - playButton, - SizedBox(width: 8), - Text(format(position), style: textStyle), - Expanded(child: slider()), - Text(format(duration), style: textStyle), - ...actions, - ], + : IntrinsicHeight( + child: Row( + children: [ + playButton, + SizedBox(width: 8), + Text(format(position), style: textStyle), + Expanded(child: slider()), + Text("${format(duration)}$sizeSuffix", style: textStyle), + ...actions, + ], + ), ), ); } diff --git a/lib/widgets/players/video.dart b/lib/widgets/players/video.dart index ef56024..053041a 100644 --- a/lib/widgets/players/video.dart +++ b/lib/widgets/players/video.dart @@ -1,13 +1,14 @@ import "dart:async"; +import "package:better_player/better_player.dart"; import "package:material_ui/material_ui.dart"; import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:nexus/controllers/client.dart"; import "package:nexus/helpers/extensions/save_attachment.dart"; +import "package:mime/mime.dart"; import "package:nexus/models/info/video.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; import "package:flutter_hooks/flutter_hooks.dart"; -import "package:media_kit/media_kit.dart"; -import "package:media_kit_video/media_kit_video.dart"; import "package:nexus/widgets/players/player_controls.dart"; class const VideoPlayer( @@ -19,51 +20,91 @@ class const VideoPlayer( }) extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final player = useMemoized( - () => Player(configuration: .new(bufferSize: 128 * 1024 * 1024)), - ); - final controller = useMemoized(() => VideoController(player)); - final loaded = useState(false); - - useEffect(() { - scheduleMicrotask(() async { - final video = await ref - .read(ClientController.provider.notifier) - .downloadMedia(.new(mxc: uri, encrypted: encrypted)); - if (!context.mounted) return; - await player.open(Media(video.path), play: false); - if (context.mounted) loaded.value = true; - }); - - return player.dispose; - }, []); - final aspectRatio = switch (info) { VideoInfo(:final width?, :final height?) when width > 0 && height > 0 => width / height, _ => 16 / 9, }; - return ConstrainedBox( - constraints: const .new(maxHeight: 300), - child: AspectRatio( - aspectRatio: aspectRatio, - child: ClipRRect( - borderRadius: .circular(12), - child: Video( - controller: controller, - controls: (_) => - // Until media_kit moves to material_ui, this Material is needed. - Material( + final loaded = useState(false); + final controller = useMemoized( + () => BetterPlayerController( + PlayerConfiguration( + aspectRatio: aspectRatio, + fit: .contain, + controlsConfiguration: PlayerControlsConfiguration( + playerTheme: .custom, + customControlsBuilder: (controller, _) => HookBuilder( + builder: (context) { + final isLoaded = useValueListenable(loaded); + final value = useState(controller.videoPlayerValue); + useEffect(() { + void listener() => value.value = controller.videoPlayerValue; + controller.addVideoListener(listener); + return () => controller.removeVideoListener(listener); + }, [controller]); + + final playing = value.value?.isPlaying ?? false; + final ready = isLoaded && (value.value?.initialized ?? false); + final error = value.value?.errorDescription; + + // better_player doesn't use material_ui, so this Material is needed. + return Material( type: .transparency, child: Stack( children: [ Positioned.fill( child: GestureDetector( behavior: .opaque, - onTap: loaded.value ? player.playOrPause : null, + onTap: ready + ? playing + ? controller.pause + : controller.play + : null, ), ), + if (error != null) + Positioned.fill( + child: ColoredBox( + color: Colors.black54, + child: Center( + child: Column( + mainAxisSize: .min, + children: [ + Padding( + padding: .all(12), + child: Icon( + Icons.videocam_off, + color: Theme.of(context) + .colorScheme + .error, + ), + ), + Flexible( + child: Text( + "Can't play this video", + style: Theme.of(context) + .textTheme + .bodySmall + ?.copyWith( + color: Theme.of(context) + .colorScheme + .error, + ), + ), + ), + TextButton( + onPressed: () => showDialog( + context: context, + builder: (_) => ErrorDialog(error, null), + ), + child: Text("Show Error"), + ), + ], + ), + ), + ), + ), Positioned( top: 4, right: 4, @@ -82,55 +123,94 @@ class const VideoPlayer( icon: Icon(Icons.download), ), ), - Positioned( - left: 0, - right: 0, - bottom: 0, - child: DecoratedBox( - decoration: const BoxDecoration( - gradient: LinearGradient( - begin: .bottomCenter, - end: .topCenter, - colors: [Colors.black54, Colors.transparent], + if (error == null) + Positioned( + left: 0, + right: 0, + bottom: 0, + child: DecoratedBox( + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: .bottomCenter, + end: .topCenter, + colors: [Colors.black54, Colors.transparent], + ), ), - ), - child: Padding( - padding: const .only(left: 4, right: 4, top: 16), - child: PlayerControls( - player, - loading: !loaded.value, - color: Colors.white, - actions: .new([ - Builder( - builder: (context) { - final fullscreen = isFullscreen(context); - - return IconButton( - onPressed: () => - toggleFullscreen(context), - color: Colors.white, - tooltip: fullscreen - ? "Exit fullscreen" - : "Fullscreen", - icon: Icon( - fullscreen - ? Icons.fullscreen_exit - : Icons.fullscreen, - ), - ); - }, - ), - ]), + child: Padding( + padding: const .only(left: 4, right: 4, top: 16), + child: PlayerControls( + playing: playing, + buffering: value.value?.isBuffering ?? false, + position: value.value?.position ?? .zero, + duration: value.value?.duration ?? .zero, + onPlayPause: playing + ? controller.pause + : controller.play, + onSeek: controller.seekTo, + loading: !ready, + size: info?.size, + color: Colors.white, + actions: .new([ + IconButton( + onPressed: controller.toggleFullScreen, + color: Colors.white, + tooltip: controller.isFullScreen + ? "Exit fullscreen" + : "Fullscreen", + icon: Icon( + controller.isFullScreen + ? Icons.fullscreen_exit + : Icons.fullscreen, + ), + ), + ]), + ), ), ), ), - ), ], ), - ), + ); + }, + ), ), ), ), ); + + useEffect(() { + scheduleMicrotask(() async { + final video = await ref + .read(ClientController.provider.notifier) + .downloadMedia(.new(mxc: uri, encrypted: encrypted)); + if (!context.mounted) return; + await controller.setupDataSource( + .file( + video.path, + videoExtension: switch (info?.mimeType) { + final mimeType? => extensionFromMime(mimeType), + null => null, + }, + ), + ); + // better_player's mpv backend (Linux and Windows) starts playing as + // soon as it loads a file, despite autoPlay being off + await controller.pause(); + if (context.mounted) loaded.value = true; + }); + + return null; + }, []); + + return ConstrainedBox( + constraints: const .new(maxHeight: 300), + child: AspectRatio( + aspectRatio: aspectRatio, + child: ClipRRect( + borderRadius: .circular(12), + child: BetterPlayer(controller: controller), + ), + ), + ); } } diff --git a/lib/widgets/reaction_row.dart b/lib/widgets/reaction_row.dart deleted file mode 100644 index 288ebd6..0000000 --- a/lib/widgets/reaction_row.dart +++ /dev/null @@ -1,113 +0,0 @@ -import "package:material_ui/material_ui.dart"; -import "package:flutter_hooks/flutter_hooks.dart"; -import "package:flutter_riverpod/flutter_riverpod.dart"; -import "package:nexus/controllers/client_state.dart"; -import "package:nexus/controllers/reactions.dart"; -import "package:nexus/controllers/room_chat.dart"; -import "package:nexus/helpers/mxc_image.dart"; -import "package:nexus/models/event.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/main.dart"; -import "package:fast_immutable_collections/fast_immutable_collections.dart"; - -class const ReactionRow(final Event event, {super.key}) extends ConsumerWidget { - @override - Widget build(BuildContext context, WidgetRef ref) { - final clientState = ref.watch(ClientStateController.provider); - - return Padding( - padding: .only(top: 4), - child: switch (ref.watch( - ReactionsController.provider( - .new(roomId: event.roomId, eventRowId: event.rowId), - ), - )) { - AsyncData(value: final IMap>? reactors) || - AsyncLoading(value: final reactors) => Wrap( - spacing: 4, - runSpacing: 4, - children: event.reactions - .where((_, value) => value != 0) - .mapTo( - (reaction, count) => HookBuilder( - builder: (context) { - final enabled = useState(true); - - final selected = - reactors?[reaction]?.contains(clientState!.userId) ?? - false; - return Tooltip( - message: reactors?[reaction]?.join(", ") ?? "", - child: ChoiceChip( - showCheckmark: false, - selected: selected, - label: Row( - mainAxisSize: .min, - spacing: 8, - children: [ - Flexible( - child: reaction.startsWith("mxc://") - ? Image( - height: 20, - image: MxcImage( - ref, - .new(mxc: Uri.parse(reaction)), - ), - errorBuilder: (context, _, _) => Icon( - Icons.broken_image, - color: Theme.of(context) - .colorScheme - .error, - ), - ) - : Text(reaction, overflow: .ellipsis), - ), - Text(count.toString(), overflow: .ellipsis), - ], - ), - onSelected: enabled.value - ? (value) async { - enabled.value = false; - try { - final controller = ref.watch( - RoomChatController.provider(( - roomId: event.roomId, - contextualEvent: null, - threadRoot: null, - )).notifier, - ); - - if (selected) { - await controller - .removeReaction( - reaction, - event, - clientState!.userId!, - ) - .onError(showError); - } else { - await controller - .sendReaction(reaction, event) - .onError(showError); - } - } finally { - enabled.value = true; - } - } - : null, - ), - ); - }, - ), - ) - .toList(), - ), - - AsyncError(:final error, :final stackTrace) => ErrorDialog( - error, - stackTrace, - ), - }, - ); - } -} diff --git a/lib/widgets/reactions/reaction_key.dart b/lib/widgets/reactions/reaction_key.dart new file mode 100644 index 0000000..ca00602 --- /dev/null +++ b/lib/widgets/reactions/reaction_key.dart @@ -0,0 +1,25 @@ +import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:material_ui/material_ui.dart"; +import "package:nexus/helpers/mxc_image.dart"; + +/// A reaction's key, either an emoji or a custom (mxc) image. +class const ReactionKey( + final String reaction, { + required final double height, + final TextStyle? style, + super.key, +}) extends ConsumerWidget { + @override + Widget build(BuildContext context, WidgetRef ref) => + reaction.startsWith("mxc://") + ? Image( + height: height, + image: MxcImage(ref, .new(mxc: Uri.parse(reaction))), + errorBuilder: (context, _, _) => Icon( + Icons.broken_image, + size: height, + color: Theme.of(context).colorScheme.error, + ), + ) + : Text(reaction, style: style, overflow: .ellipsis); +} diff --git a/lib/widgets/reactions/reaction_row.dart b/lib/widgets/reactions/reaction_row.dart new file mode 100644 index 0000000..c8bae95 --- /dev/null +++ b/lib/widgets/reactions/reaction_row.dart @@ -0,0 +1,120 @@ +import "package:flutter/gestures.dart"; +import "package:material_ui/material_ui.dart"; +import "package:flutter_hooks/flutter_hooks.dart"; +import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:nexus/controllers/client_state.dart"; +import "package:nexus/controllers/reactions.dart"; +import "package:nexus/controllers/room_chat.dart"; +import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; +import "package:nexus/models/event.dart"; +import "package:nexus/models/reaction_group.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/widgets/reactions/reaction_key.dart"; +import "package:nexus/widgets/reactions/reactions_popover.dart"; +import "package:nexus/main.dart"; +import "package:fast_immutable_collections/fast_immutable_collections.dart"; + +class const ReactionRow(final Event event, {super.key}) extends ConsumerWidget { + @override + Widget build(BuildContext context, WidgetRef ref) { + final clientState = ref.watch(ClientStateController.provider); + + return Padding( + padding: .only(top: 4), + child: switch (ref.watch( + ReactionsController.provider( + .new(roomId: event.roomId, eventRowId: event.rowId), + ), + )) { + AsyncData(value: final IMap? reactors) || + AsyncLoading(value: final reactors) => Wrap( + spacing: 4, + runSpacing: 4, + children: event.reactions + .where((_, value) => value != 0) + .mapTo( + (reaction, count) => HookBuilder( + builder: (context) { + final enabled = useState(true); + + final selected = + reactors?[reaction]?.senders.contains( + clientState!.userId, + ) ?? + false; + void showReactions(PositionedGestureDetails details) => + context.showAdaptivePopover( + (_) => ReactionsPopover( + event, + initialReaction: reaction, + ), + anchor: context.globalRectAt(details.globalPosition), + ); + + return GestureDetector( + onSecondaryTapUp: showReactions, + onLongPressStart: showReactions, + child: Tooltip( + // Long press opens the reactions popover instead + triggerMode: .manual, + message: reactors?[reaction]?.shortcode ?? reaction, + child: ChoiceChip( + showCheckmark: false, + selected: selected, + label: Row( + mainAxisSize: .min, + spacing: 8, + children: [ + Flexible( + child: ReactionKey(reaction, height: 20), + ), + Text(count.toString(), overflow: .ellipsis), + ], + ), + onSelected: enabled.value + ? (value) async { + enabled.value = false; + try { + final controller = ref.watch( + RoomChatController.provider(( + roomId: event.roomId, + contextualEvent: null, + threadRoot: null, + )).notifier, + ); + + if (selected) { + await controller + .removeReaction( + reaction, + event, + clientState!.userId!, + ) + .onError(showError); + } else { + await controller + .sendReaction(reaction, event) + .onError(showError); + } + } finally { + enabled.value = true; + } + } + : null, + ), + ), + ); + }, + ), + ) + .toList(), + ), + + AsyncError(:final error, :final stackTrace) => ErrorDialog( + error, + stackTrace, + ), + }, + ); + } +} diff --git a/lib/widgets/reactions/reactions_popover.dart b/lib/widgets/reactions/reactions_popover.dart new file mode 100644 index 0000000..44c455b --- /dev/null +++ b/lib/widgets/reactions/reactions_popover.dart @@ -0,0 +1,144 @@ +import "dart:math"; + +import "package:fast_immutable_collections/fast_immutable_collections.dart"; +import "package:flutter_hooks/flutter_hooks.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; +import "package:material_ui/material_ui.dart"; +import "package:nexus/controllers/reactions.dart"; +import "package:nexus/controllers/user.dart"; +import "package:nexus/helpers/extensions/better_when.dart"; +import "package:nexus/helpers/extensions/get_localpart.dart"; +import "package:nexus/helpers/extensions/show_user_popover.dart"; +import "package:nexus/models/event.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/helpers/extensions/show_image_viewer.dart"; +import "package:nexus/widgets/reactions/reaction_key.dart"; + +/// Every reaction to an event in tabs, each listing who reacted with it. +class const ReactionsPopover( + final Event event, { + final String? initialReaction, + super.key, +}) extends HookConsumerWidget { + @override + Widget build(BuildContext context, WidgetRef ref) { + final reactions = ref.watch( + ReactionsController.provider( + .new(roomId: event.roomId, eventRowId: event.rowId), + ), + ); + // Ordered like the reaction row on the timeline + final order = event.reactions.keys.toIList(); + final keys = + reactions.value?.keys.toIList().sortOrdered( + (a, b) => order.indexOf(a).compareTo(order.indexOf(b)), + ) ?? + const .empty(); + + final vsync = useSingleTickerProvider(keys: [keys.length]); + final tabController = useMemoized( + () => TabController( + length: keys.length, + initialIndex: keys + .indexOf(initialReaction ?? "") + .clamp(0, max(0, keys.length - 1)), + vsync: vsync, + ), + [keys.length], + ); + useEffect(() => tabController.dispose, [tabController]); + useListenable(tabController); + + return reactions.betterWhen( + skipLoadingOnReload: true, + data: (reactions) { + if (keys.isEmpty) return SizedBox.shrink(); + + final reaction = keys[tabController.index]; + + return Column( + mainAxisSize: .min, + crossAxisAlignment: .stretch, + children: [ + TabBar( + controller: tabController, + isScrollable: true, + tabAlignment: .start, + tabs: keys.map((reaction) { + void expand() => context.showImageViewer( + ref, + .new(mxc: Uri.parse(reaction)), + downloadFilename: reaction.split("/").last, + ); + final isImage = reaction.startsWith("mxc://"); + + return GestureDetector( + onSecondaryTap: isImage ? expand : null, + onLongPress: isImage ? expand : null, + child: Tab( + child: Row( + mainAxisSize: .min, + spacing: 8, + children: [ + ReactionKey(reaction, height: 20), + Text(reactions[reaction]!.senders.length.toString()), + ], + ), + ), + ); + }).toList(), + ), + Flexible( + child: AnimatedSize( + duration: Durations.medium2, + curve: Curves.easeInOutCubicEmphasized, + alignment: .topCenter, + child: SingleChildScrollView( + key: ValueKey(reaction), + padding: .symmetric(vertical: 8), + child: Column( + crossAxisAlignment: .stretch, + children: reactions[reaction]!.senders + .map( + (userId) => Consumer( + builder: (context, ref, _) { + final member = ref + .watch( + UserController.provider( + .new( + roomId: event.roomId, + userId: userId, + ), + ), + ) + .value; + final name = + member?.displayName ?? userId.localpart; + + return ListTile( + leading: AvatarOrHash( + member?.avatarUrl, + name, + dimension: 40, + ), + title: Text(name, overflow: .ellipsis), + subtitle: Text(userId, overflow: .ellipsis), + onTap: () => context.showUserPopover( + userId, + roomId: event.roomId, + ), + ); + }, + ), + ) + .toList(), + ), + ), + ), + ), + ], + ); + }, + ); + } +} diff --git a/lib/widgets/read_receipts_row.dart b/lib/widgets/read_receipts/read_receipts_row.dart similarity index 96% rename from lib/widgets/read_receipts_row.dart rename to lib/widgets/read_receipts/read_receipts_row.dart index fb20e3d..156d3f8 100644 --- a/lib/widgets/read_receipts_row.dart +++ b/lib/widgets/read_receipts/read_receipts_row.dart @@ -8,9 +8,9 @@ import "package:nexus/controllers/room_chat.dart"; import "package:nexus/controllers/user.dart"; import "package:nexus/helpers/extensions/get_localpart.dart"; import "package:nexus/helpers/extensions/show_user_popover.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/avatar_ring.dart"; -import "package:nexus/widgets/read_receipts_sheet.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_ring.dart"; +import "package:nexus/widgets/read_receipts/read_receipts_sheet.dart"; class const ReadReceiptsRow( final String eventId, { diff --git a/lib/widgets/read_receipts_sheet.dart b/lib/widgets/read_receipts/read_receipts_sheet.dart similarity index 96% rename from lib/widgets/read_receipts_sheet.dart rename to lib/widgets/read_receipts/read_receipts_sheet.dart index 135e3fb..3021102 100644 --- a/lib/widgets/read_receipts_sheet.dart +++ b/lib/widgets/read_receipts/read_receipts_sheet.dart @@ -6,7 +6,7 @@ import "package:nexus/controllers/room_chat.dart"; import "package:nexus/controllers/user.dart"; import "package:nexus/helpers/extensions/get_localpart.dart"; import "package:nexus/helpers/extensions/show_user_popover.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; /// Everyone who has read up to an event, kept up to date while open. class const ReadReceiptsSheet( diff --git a/lib/widgets/renderers/change_line.dart b/lib/widgets/renderers/diffs/change_line.dart similarity index 100% rename from lib/widgets/renderers/change_line.dart rename to lib/widgets/renderers/diffs/change_line.dart diff --git a/lib/widgets/renderers/join_rules_diff.dart b/lib/widgets/renderers/diffs/join_rules_diff.dart similarity index 97% rename from lib/widgets/renderers/join_rules_diff.dart rename to lib/widgets/renderers/diffs/join_rules_diff.dart index 6d41c0b..1698aa0 100644 --- a/lib/widgets/renderers/join_rules_diff.dart +++ b/lib/widgets/renderers/diffs/join_rules_diff.dart @@ -5,7 +5,7 @@ import "package:nexus/controllers/rooms.dart"; import "package:nexus/helpers/extensions/join_rule_name.dart"; import "package:nexus/helpers/extensions/success_scheme.dart"; import "package:nexus/models/content/join_rules.dart"; -import "package:nexus/widgets/renderers/change_line.dart"; +import "package:nexus/widgets/renderers/diffs/change_line.dart"; /// The join rule a join rules event changed to, and for restricted rooms, the /// rooms whose members it let join, or stopped letting join. diff --git a/lib/widgets/renderers/pinned_events_diff.dart b/lib/widgets/renderers/diffs/pinned_events_diff.dart similarity index 100% rename from lib/widgets/renderers/pinned_events_diff.dart rename to lib/widgets/renderers/diffs/pinned_events_diff.dart diff --git a/lib/widgets/renderers/power_levels_diff.dart b/lib/widgets/renderers/diffs/power_levels_diff.dart similarity index 100% rename from lib/widgets/renderers/power_levels_diff.dart rename to lib/widgets/renderers/diffs/power_levels_diff.dart diff --git a/lib/widgets/renderers/server_acl_diff.dart b/lib/widgets/renderers/diffs/server_acl_diff.dart similarity index 97% rename from lib/widgets/renderers/server_acl_diff.dart rename to lib/widgets/renderers/diffs/server_acl_diff.dart index e232614..9364c04 100644 --- a/lib/widgets/renderers/server_acl_diff.dart +++ b/lib/widgets/renderers/diffs/server_acl_diff.dart @@ -2,7 +2,7 @@ import "package:fast_immutable_collections/fast_immutable_collections.dart"; import "package:material_ui/material_ui.dart"; import "package:nexus/helpers/extensions/success_scheme.dart"; import "package:nexus/models/content/server_acl.dart"; -import "package:nexus/widgets/renderers/change_line.dart"; +import "package:nexus/widgets/renderers/diffs/change_line.dart"; /// The servers newly denied (in red) and allowed (in green) by a server ACL /// event, and those no longer denied or allowed, struck through. diff --git a/lib/widgets/renderers/event.dart b/lib/widgets/renderers/event.dart index deff7f7..228abf6 100644 --- a/lib/widgets/renderers/event.dart +++ b/lib/widgets/renderers/event.dart @@ -32,21 +32,21 @@ import "package:nexus/models/content/server_acl.dart"; import "package:nexus/models/content/tombstone.dart"; import "package:nexus/models/content/topic.dart"; import "package:nexus/models/event.dart"; -import "package:nexus/widgets/error_dialog.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; import "package:nexus/widgets/renderers/message.dart"; -import "package:nexus/widgets/reaction_row.dart"; -import "package:nexus/widgets/read_receipts_row.dart"; +import "package:nexus/widgets/reactions/reaction_row.dart"; +import "package:nexus/widgets/read_receipts/read_receipts_row.dart"; import "package:nexus/widgets/renderers/membership.dart"; -import "package:nexus/widgets/renderers/change_line.dart"; +import "package:nexus/widgets/renderers/diffs/change_line.dart"; import "package:nexus/widgets/renderers/generic_event.dart"; -import "package:nexus/widgets/renderers/join_rules_diff.dart"; -import "package:nexus/widgets/renderers/power_levels_diff.dart"; -import "package:nexus/widgets/renderers/pinned_events_diff.dart"; -import "package:nexus/widgets/renderers/server_acl_diff.dart"; -import "package:nexus/widgets/swipe_to_reply.dart"; -import "package:nexus/widgets/thread_summary.dart"; -import "package:nexus/widgets/timestamp.dart"; -import "package:nexus/widgets/user_span.dart"; +import "package:nexus/widgets/renderers/diffs/join_rules_diff.dart"; +import "package:nexus/widgets/renderers/diffs/power_levels_diff.dart"; +import "package:nexus/widgets/renderers/diffs/pinned_events_diff.dart"; +import "package:nexus/widgets/renderers/diffs/server_acl_diff.dart"; +import "package:nexus/widgets/renderers/swipe_to_reply.dart"; +import "package:nexus/widgets/threads/thread_summary.dart"; +import "package:nexus/widgets/common/timestamp.dart"; +import "package:nexus/widgets/users/user_span.dart"; class const EventRenderer( final int eventRowId, { @@ -525,10 +525,12 @@ class const EventRenderer( child: Row( spacing: 4, children: [ - Text( - event.sendError!, - style: theme.textTheme.labelSmall?.copyWith( - color: theme.colorScheme.error, + Flexible( + child: Text( + event.sendError!, + style: theme.textTheme.labelSmall?.copyWith( + color: theme.colorScheme.error, + ), ), ), InkWell( diff --git a/lib/widgets/event_preview.dart b/lib/widgets/renderers/event_preview.dart similarity index 100% rename from lib/widgets/event_preview.dart rename to lib/widgets/renderers/event_preview.dart diff --git a/lib/widgets/file_card.dart b/lib/widgets/renderers/file_card.dart similarity index 100% rename from lib/widgets/file_card.dart rename to lib/widgets/renderers/file_card.dart diff --git a/lib/widgets/renderers/membership.dart b/lib/widgets/renderers/membership.dart index 17f8128..125ea64 100644 --- a/lib/widgets/renderers/membership.dart +++ b/lib/widgets/renderers/membership.dart @@ -6,7 +6,7 @@ import "package:nexus/helpers/hooks/tap_recognizer.dart"; import "package:nexus/models/content/membership.dart"; import "package:nexus/models/event.dart"; import "package:nexus/widgets/renderers/generic_event.dart"; -import "package:nexus/widgets/user_span.dart"; +import "package:nexus/widgets/users/user_span.dart"; class const MembershipRenderer( final Event event, { diff --git a/lib/widgets/renderers/message.dart b/lib/widgets/renderers/message.dart index 4e6a45a..655fc0d 100644 --- a/lib/widgets/renderers/message.dart +++ b/lib/widgets/renderers/message.dart @@ -12,22 +12,21 @@ import "package:nexus/models/location.dart"; import "package:nexus/models/content/poll_start.dart"; import "package:nexus/models/content/sticker.dart"; import "package:nexus/models/event.dart"; -import "package:nexus/widgets/file_card.dart"; import "package:nexus/widgets/html/html.dart"; import "package:nexus/widgets/lazy_loading/message_avatar.dart"; import "package:nexus/widgets/lazy_loading/message_displayname.dart"; -import "package:nexus/widgets/linkified_text.dart"; -import "package:nexus/widgets/location_message.dart"; -import "package:nexus/widgets/loading.dart"; -import "package:nexus/widgets/message_image.dart"; -import "package:nexus/widgets/reaction_row.dart"; -import "package:nexus/widgets/timestamp.dart"; -import "package:nexus/widgets/url_preview.dart"; -import "package:nexus/widgets/event_preview.dart"; -import "package:nexus/widgets/players/video.dart"; -import "package:nexus/widgets/players/audio.dart"; +import "package:nexus/widgets/common/linkified_text.dart"; +import "package:nexus/widgets/location/location_message.dart"; +import "package:nexus/widgets/common/loading.dart"; +import "package:nexus/widgets/renderers/message_image.dart"; +import "package:nexus/widgets/reactions/reaction_row.dart"; +import "package:nexus/widgets/common/timestamp.dart"; +import "package:nexus/widgets/renderers/url_preview.dart"; +import "package:nexus/widgets/renderers/event_preview.dart"; +import "package:nexus/widgets/renderers/message_media.dart"; +import "package:nexus/helpers/extensions/is_media.dart"; import "package:nexus/widgets/renderers/poll.dart"; -import "package:nexus/widgets/thread_summary.dart"; +import "package:nexus/widgets/threads/thread_summary.dart"; class const MessageRenderer( final Event event, { @@ -125,63 +124,10 @@ class const MessageRenderer( ), if (!textOnly) ...[ - if (event.content - case ImageMessageContent(:final url) || - FileMessageContent(:final url) || - VideoMessageContent(:final url) || - AudioMessageContent(:final url)) + if (content.isMedia) ConstrainedBox( constraints: .loose(.square(500)), - child: switch (event.content) { - VideoMessageContent( - :final info, - :final file, - :final filename, - :final body, - ) => - VideoPlayer( - url, - info, - encrypted: file != null, - filename: filename ?? body, - ), - AudioMessageContent( - :final info, - :final file, - :final filename, - :final body, - ) => - AudioPlayer( - url, - info, - encrypted: file != null, - filename: filename ?? body, - ), - FileMessageContent( - :final info, - :final filename, - :final file, - ) => - FileCard( - url, - info, - filename: filename, - encrypted: file != null, - ), - ImageMessageContent( - :final info, - :final file, - :final filename, - :final body, - ) => - MessageImage( - url, - info: info, - encrypted: file != null, - filename: filename ?? body, - ), - _ => SizedBox.shrink(), - }, + child: MessageMedia(content), ), if (event.lastEditRowId != 0) @@ -197,12 +143,18 @@ class const MessageRenderer( UnknownMessageContent(:final body) => body == null ? Text("This message is redacted", style: errorStyle) - : Wrap( - spacing: 8, - children: [ - Text("Unknown message type:", style: errorStyle), - Text(body), - ], + : Text.rich( + TextSpan( + children: [ + TextSpan( + text: "Unknown message type: ", + style: errorStyle, + ), + TextSpan(text: body), + ], + ), + maxLines: maxLines, + overflow: maxLines == null ? null : .ellipsis, ), }, _ => throw Exception("This is impossible"), diff --git a/lib/widgets/message_image.dart b/lib/widgets/renderers/message_image.dart similarity index 93% rename from lib/widgets/message_image.dart rename to lib/widgets/renderers/message_image.dart index 70aedd9..a8c44e3 100644 --- a/lib/widgets/message_image.dart +++ b/lib/widgets/renderers/message_image.dart @@ -4,8 +4,8 @@ import "package:flutter_riverpod/flutter_riverpod.dart"; import "package:nexus/helpers/mxc_image.dart"; import "package:nexus/models/info/image.dart" as i; import "package:nexus/models/requests/download_media.dart"; -import "package:nexus/widgets/expandable_image.dart"; -import "package:nexus/widgets/loading.dart"; +import "package:nexus/widgets/common/expandable_image.dart"; +import "package:nexus/widgets/common/loading.dart"; final class const MessageImage( final Uri url, { @@ -20,6 +20,7 @@ final class const MessageImage( return ExpandableImage( request, downloadFilename: filename, + size: info?.size, child: ClipRRect( borderRadius: .all(.circular(8)), child: AspectRatio( diff --git a/lib/widgets/renderers/message_media.dart b/lib/widgets/renderers/message_media.dart new file mode 100644 index 0000000..1f7e6b9 --- /dev/null +++ b/lib/widgets/renderers/message_media.dart @@ -0,0 +1,55 @@ +import "package:material_ui/material_ui.dart"; +import "package:nexus/models/content/message.dart"; +import "package:nexus/widgets/players/audio.dart"; +import "package:nexus/widgets/players/video.dart"; +import "package:nexus/widgets/renderers/file_card.dart"; +import "package:nexus/widgets/renderers/message_image.dart"; + +final class const MessageMedia(final MessageContent content, {super.key}) + extends StatelessWidget { + @override + Widget build(BuildContext context) => switch (content) { + VideoMessageContent( + :final url, + :final info, + :final file, + :final filename, + :final body, + ) => + VideoPlayer( + url, + info, + encrypted: file != null, + filename: filename ?? body, + ), + AudioMessageContent( + :final url, + :final info, + :final file, + :final filename, + :final body, + ) => + AudioPlayer( + url, + info, + encrypted: file != null, + filename: filename ?? body, + ), + FileMessageContent(:final url, :final info, :final filename, :final file) => + FileCard(url, info, filename: filename, encrypted: file != null), + ImageMessageContent( + :final url, + :final info, + :final file, + :final filename, + :final body, + ) => + MessageImage( + url, + info: info, + encrypted: file != null, + filename: filename ?? body, + ), + _ => SizedBox.shrink(), + }; +} diff --git a/lib/widgets/renderers/poll.dart b/lib/widgets/renderers/poll.dart index d3a8cb0..1f738b5 100644 --- a/lib/widgets/renderers/poll.dart +++ b/lib/widgets/renderers/poll.dart @@ -15,7 +15,7 @@ import "package:nexus/helpers/extensions/event_id_is_fake.dart"; import "package:nexus/main.dart"; import "package:nexus/models/content/poll_start.dart"; import "package:nexus/models/event.dart"; -import "package:nexus/widgets/poll_option.dart"; +import "package:nexus/widgets/renderers/poll_option.dart"; class const PollRenderer(final Event event, final PollStart poll, {super.key}) extends HookConsumerWidget { diff --git a/lib/widgets/poll_option.dart b/lib/widgets/renderers/poll_option.dart similarity index 100% rename from lib/widgets/poll_option.dart rename to lib/widgets/renderers/poll_option.dart diff --git a/lib/widgets/swipe_to_reply.dart b/lib/widgets/renderers/swipe_to_reply.dart similarity index 100% rename from lib/widgets/swipe_to_reply.dart rename to lib/widgets/renderers/swipe_to_reply.dart diff --git a/lib/widgets/url_preview.dart b/lib/widgets/renderers/url_preview.dart similarity index 100% rename from lib/widgets/url_preview.dart rename to lib/widgets/renderers/url_preview.dart diff --git a/lib/widgets/room_chat/banned_warning_dialog.dart b/lib/widgets/room_chat/banned_warning_dialog.dart new file mode 100644 index 0000000..5beeaae --- /dev/null +++ b/lib/widgets/room_chat/banned_warning_dialog.dart @@ -0,0 +1,21 @@ +import "package:material_ui/material_ui.dart"; + +class const BannedWarningDialog({super.key}) extends StatelessWidget { + @override + Widget build(BuildContext context) => AlertDialog( + title: Text("View Banned Members?"), + content: Text( + "Banned members may have offensive or abusive display names and avatars.", + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(context).pop(false), + child: Text("Cancel"), + ), + TextButton( + onPressed: () => Navigator.of(context).pop(true), + child: Text("Continue and don't show again"), + ), + ], + ); +} diff --git a/lib/widgets/room_chat/chat_body.dart b/lib/widgets/room_chat/chat_body.dart index 239ae4b..3b5f752 100644 --- a/lib/widgets/room_chat/chat_body.dart +++ b/lib/widgets/room_chat/chat_body.dart @@ -13,10 +13,10 @@ import "package:nexus/main.dart"; import "package:nexus/models/event.dart"; import "package:nexus/widgets/composer/composer.dart"; import "package:nexus/widgets/composer/typing_indicator.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/widgets/loading.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/widgets/common/loading.dart"; import "package:nexus/widgets/room_chat/chat_timeline.dart"; -import "package:nexus/widgets/tombstone_banner.dart"; +import "package:nexus/widgets/room_chat/tombstone_banner.dart"; final class const ChatBody({ required final ChatParams chat, diff --git a/lib/widgets/room_chat/chat_timeline.dart b/lib/widgets/room_chat/chat_timeline.dart index 40cc2e6..d6aaef7 100644 --- a/lib/widgets/room_chat/chat_timeline.dart +++ b/lib/widgets/room_chat/chat_timeline.dart @@ -4,7 +4,7 @@ import "package:nexus/controllers/room_chat.dart"; import "package:nexus/helpers/hooks/chat_scroll.dart"; import "package:nexus/models/event.dart"; import "package:nexus/widgets/renderers/event.dart"; -import "package:nexus/widgets/highlight_wrapper.dart"; +import "package:nexus/widgets/common/highlight_wrapper.dart"; import "package:super_sliver_list/super_sliver_list.dart"; class const ChatTimeline({ @@ -25,16 +25,20 @@ class const ChatTimeline({ int? previousEventRowId, { required Key key, }) => HighlightWrapper( - EventRenderer( - eventRowId, - previousEventRowId: previousEventRowId, - roomId: chat.roomId, - jumpToEvent: jumpToEvent, - onOpenThread: onOpenThread, - getEventOptions: getEventOptions, - onSwipe: onSwipe == null ? null : () => onSwipe!(eventRowId), - readReceiptsChat: chat, - threadRoot: chat.threadRoot, + // To work around an AWFUL SuperSliverList bug + ConstrainedBox( + constraints: const BoxConstraints(minHeight: 0.01), + child: EventRenderer( + eventRowId, + previousEventRowId: previousEventRowId, + roomId: chat.roomId, + jumpToEvent: jumpToEvent, + onOpenThread: onOpenThread, + getEventOptions: getEventOptions, + onSwipe: onSwipe == null ? null : () => onSwipe!(eventRowId), + readReceiptsChat: chat, + threadRoot: chat.threadRoot, + ), ), key: key, isHighlighted: scroll.highlightedEvent == eventRowId, diff --git a/lib/widgets/member_list.dart b/lib/widgets/room_chat/member_list.dart similarity index 86% rename from lib/widgets/member_list.dart rename to lib/widgets/room_chat/member_list.dart index 02cc0c6..a967075 100644 --- a/lib/widgets/member_list.dart +++ b/lib/widgets/room_chat/member_list.dart @@ -4,6 +4,7 @@ import "package:flutter_hooks/flutter_hooks.dart"; import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:m3e_buttons/m3e_buttons.dart"; import "package:m3e_card_list/m3e_card_list.dart"; +import "package:nexus/controllers/banned_warning_dismissed.dart"; import "package:nexus/controllers/members_by_status.dart"; import "package:nexus/controllers/members_grouped.dart"; import "package:nexus/helpers/extensions/get_localpart.dart"; @@ -11,10 +12,11 @@ import "package:nexus/helpers/extensions/show_user_popover.dart"; import "package:nexus/helpers/extensions/displayname_color.dart"; import "package:nexus/models/content/membership.dart"; import "package:nexus/models/membership_status.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/divider_text.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/widgets/loading.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/common/divider_text.dart"; +import "package:nexus/widgets/room_chat/banned_warning_dialog.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/widgets/common/loading.dart"; class const MemberList(final String roomId, {super.key}) extends HookConsumerWidget { @@ -40,8 +42,26 @@ class const MemberList(final String roomId, {super.key}) padding: .all(8), child: M3EToggleButtonGroup( selectedIndex: statusIndex.value, - onSelectedIndexChanged: (index) => - statusIndex.value = index ?? statusIndex.value, + onSelectedIndexChanged: (index) async { + if (index == null) return; + if (options.values.toIList()[index] == .ban && + !await ref.read( + BannedWarningDismissedController.provider.future, + )) { + if (!context.mounted) return; + final confirmed = await showDialog( + context: context, + builder: (_) => BannedWarningDialog(), + ); + if (confirmed != true) return; + await ref + .read( + BannedWarningDismissedController.provider.notifier, + ) + .set(true); + } + statusIndex.value = index; + }, actions: options .mapTo( (name, value) => M3EToggleButtonGroupAction( diff --git a/lib/widgets/pinned_events_drawer.dart b/lib/widgets/room_chat/pinned_events_drawer.dart similarity index 96% rename from lib/widgets/pinned_events_drawer.dart rename to lib/widgets/room_chat/pinned_events_drawer.dart index cff6ad6..1e0ab6a 100644 --- a/lib/widgets/pinned_events_drawer.dart +++ b/lib/widgets/room_chat/pinned_events_drawer.dart @@ -4,8 +4,8 @@ import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:nexus/controllers/pinned_events.dart"; import "package:nexus/helpers/hooks/chat_scroll.dart"; import "package:nexus/models/event.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/widgets/loading.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/widgets/common/loading.dart"; import "package:nexus/widgets/renderers/event.dart"; final class const PinnedEventsDrawer( diff --git a/lib/widgets/room_appbar.dart b/lib/widgets/room_chat/room_appbar.dart similarity index 87% rename from lib/widgets/room_appbar.dart rename to lib/widgets/room_chat/room_appbar.dart index 83a3278..14b9df5 100644 --- a/lib/widgets/room_appbar.dart +++ b/lib/widgets/room_chat/room_appbar.dart @@ -2,13 +2,13 @@ import "package:material_ui/material_ui.dart"; import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; import "package:nexus/controllers/rooms.dart"; -import "package:nexus/widgets/appbar.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/count_badge.dart"; -import "package:nexus/widgets/room_menu_button.dart"; -import "package:nexus/widgets/room_summary_sheet.dart"; -import "package:nexus/widgets/room_title.dart"; -import "package:nexus/widgets/sidebar.dart"; +import "package:nexus/widgets/common/appbar.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/common/count_badge.dart"; +import "package:nexus/widgets/rooms/room_menu_button.dart"; +import "package:nexus/widgets/rooms/room_summary_sheet.dart"; +import "package:nexus/widgets/rooms/room_title.dart"; +import "package:nexus/widgets/sidebar/sidebar.dart"; final class const RoomAppbar({ required final String? roomId, diff --git a/lib/widgets/room_chat/room_chat.dart b/lib/widgets/room_chat/room_chat.dart index 0062450..8a29c38 100644 --- a/lib/widgets/room_chat/room_chat.dart +++ b/lib/widgets/room_chat/room_chat.dart @@ -10,16 +10,17 @@ import "package:nexus/controllers/room_chat.dart"; import "package:nexus/helpers/hooks/chat_composer.dart"; import "package:nexus/helpers/hooks/chat_scroll.dart"; import "package:nexus/models/event.dart"; -import "package:nexus/widgets/pinned_events_drawer.dart"; -import "package:nexus/widgets/member_list.dart"; -import "package:nexus/widgets/room_appbar.dart"; -import "package:nexus/widgets/search_drawer.dart"; -import "package:nexus/widgets/sync_status_banner.dart"; -import "package:nexus/widgets/thread_drawer.dart"; -import "package:nexus/widgets/threads_drawer.dart"; +import "package:nexus/widgets/room_chat/pinned_events_drawer.dart"; +import "package:nexus/widgets/room_chat/member_list.dart"; +import "package:nexus/widgets/room_chat/room_appbar.dart"; +import "package:nexus/widgets/room_chat/search_drawer.dart"; +import "package:nexus/widgets/common/sync_status_banner.dart"; +import "package:nexus/widgets/threads/thread_drawer.dart"; +import "package:nexus/widgets/threads/threads_drawer.dart"; import "package:nexus/widgets/room_chat/chat_body.dart"; import "package:nexus/helpers/extensions/build_event_options.dart"; import "package:nexus/controllers/jump_request.dart"; +import "package:nexus/main.dart"; final class const RoomChat({ required final String? roomId, @@ -202,10 +203,14 @@ final class const RoomChat({ isDesktop: isDesktop, onOpenDrawer: Scaffold.of(context).openDrawer, onOpenMemberList: (thisContext) { + if (!showMembersByDefault) { + return Scaffold.of(thisContext).openEndDrawer(); + } + ref .read(MemberListOpenedController.provider.notifier) - .set(!memberListOpened); - Scaffold.of(thisContext).openEndDrawer(); + .set(!memberListOpened) + .onError(showError); }, onOpenPinnedMessagesList: Scaffold.of(middleContext) .openEndDrawer, diff --git a/lib/widgets/search_drawer.dart b/lib/widgets/room_chat/search_drawer.dart similarity index 98% rename from lib/widgets/search_drawer.dart rename to lib/widgets/room_chat/search_drawer.dart index 03418df..2905789 100644 --- a/lib/widgets/search_drawer.dart +++ b/lib/widgets/room_chat/search_drawer.dart @@ -6,8 +6,8 @@ import "package:nexus/controllers/event_search.dart"; import "package:nexus/helpers/hooks/chat_scroll.dart"; import "package:nexus/main.dart"; import "package:nexus/models/event.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/widgets/loading.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/widgets/common/loading.dart"; import "package:nexus/widgets/renderers/event.dart"; final class const SearchDrawer( diff --git a/lib/widgets/tombstone_banner.dart b/lib/widgets/room_chat/tombstone_banner.dart similarity index 100% rename from lib/widgets/tombstone_banner.dart rename to lib/widgets/room_chat/tombstone_banner.dart diff --git a/lib/widgets/room_list.dart b/lib/widgets/room_list.dart deleted file mode 100644 index bdbf9cd..0000000 --- a/lib/widgets/room_list.dart +++ /dev/null @@ -1,328 +0,0 @@ -import "dart:math"; - -import "package:fast_immutable_collections/fast_immutable_collections.dart"; -import "package:hooks_riverpod/hooks_riverpod.dart"; -import "package:material_ui/material_ui.dart"; -import "package:navigation_rail_m3e/navigation_rail_m3e.dart"; -import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; -import "package:nexus/helpers/extensions/get_all_child_rooms.dart"; -import "package:nexus/helpers/extensions/room_destinations.dart"; -import "package:nexus/widgets/account_switcher.dart"; -import "package:nexus/models/nav_page.dart"; -import "package:nexus/widgets/appbar.dart"; -import "package:nexus/widgets/room_title.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/create_room_sheet.dart"; -import "package:nexus/widgets/start_dm_sheet.dart"; -import "package:nexus/widgets/divider_widget.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/widgets/pages/explore.dart"; -import "package:nexus/widgets/pages/settings.dart"; -import "package:nexus/widgets/join_sheet.dart"; -import "package:nexus/widgets/m3e_rail_theme.dart"; -import "package:nexus/widgets/room_summary_sheet.dart"; -import "package:nexus/widgets/room_menu_button.dart"; -import "package:nexus/widgets/space_hierarchy_sheet.dart"; -import "package:nexus/controllers/key.dart"; -import "package:nexus/controllers/selected_room.dart"; -import "package:nexus/controllers/selected_space.dart"; -import "package:nexus/controllers/rooms.dart"; -import "package:nexus/controllers/spaces.dart"; - -class const RoomList({super.key}) extends ConsumerWidget implements NavPage { - @override - String get title => "Rooms"; - - @override - IconData get icon => Icons.list; - - @override - int? badgeCount(WidgetRef ref) { - final (notifications, hasUnread) = ref.watch( - RoomsController.provider.select( - (rooms) => rooms.values.fold( - (0, false), - (total, room) => ( - total.$1 + (room.metadata?.unreadNotifications ?? 0), - total.$2 || (room.metadata?.unreadMessages ?? 0) > 0, - ), - ), - ), - ); - - return notifications > 0 - ? notifications - : hasUnread - ? 0 - : null; - } - - @override - Widget build(BuildContext context, WidgetRef ref) { - final spacesAsync = ref.watch(SpacesController.provider); - if (spacesAsync.value == null) { - return switch (spacesAsync) { - AsyncError(:final error, :final stackTrace) => ErrorDialog( - error, - stackTrace, - ), - _ => const Center(child: CircularProgressIndicator()), - }; - } - - return const Row( - children: [ - SpacesRail(), - Expanded(child: RoomsPane()), - ], - ); - } -} - -class const SpacesRail({super.key}) extends ConsumerWidget { - @override - Widget build(BuildContext context, WidgetRef ref) { - final spaces = ref.watch( - SpacesController.provider.select((async) => async.requireValue), - ); - final selectedSpaceId = ref.watch( - KeyController.provider(KeyController.spaceKey) - .select((async) => async.requireValue), - ); - - return M3ERailTheme( - extensions: [ - NavigationRailM3ETheme(itemCollapsedHeight: 48, itemVerticalGap: 0), - ], - builder: (context) => Container( - color: NavigationRailTokensAdapter(context).containerColor, - padding: .only(top: 16), - child: NavigationRailM3E( - type: .alwaysCollapse, - labelBehavior: .alwaysHide, - scrollable: true, - onDestinationSelected: (value) { - ref - .read(KeyController.provider(KeyController.spaceKey).notifier) - .set(spaces[value].id); - ref - .read(KeyController.provider(KeyController.roomKey).notifier) - .set(spaces[value].children.firstOrNull?.metadata?.id); - }, - sections: [ - .new( - destinations: spaces.map((space) { - final notifications = space.allChildRooms.fold( - 0, - (sum, room) => - sum + (room.metadata?.unreadNotifications ?? 0), - ); - - return NavigationRailM3EDestination( - badgeCount: notifications > 0 - ? notifications - : space.allChildRooms.any( - (room) => room.metadata?.unreadMessages != 0, - ) - ? 0 - : null, - short: true, - icon: AvatarOrHash( - dimension: 28, - space.room?.metadata?.avatar, - fallback: space.icon == null ? null : Icon(space.icon), - space.title, - ), - label: space.title, - ); - }).toList(), - ), - ], - selectedIndex: max( - 0, - spaces.indexWhere((space) => space.id == selectedSpaceId), - ), - trailingAtBottom: true, - trailing: Padding( - padding: .only(top: 8), - child: Column( - children: [ - AdaptiveMenuButton( - tooltip: "Add a room", - itemBuilder: (_) => [ - PopupMenuItem( - onTap: () => - context.showAdaptiveSheet((_) => JoinSheet(ref)), - child: const ListTile( - title: Text("Join an existing room (or space)"), - leading: Icon(Icons.numbers), - ), - ), - PopupMenuItem( - onTap: () => context.showAdaptiveSheet( - (_) => const CreateRoomSheet(), - ), - child: const ListTile( - title: Text("Create a new room (or space)"), - leading: Icon(Icons.add), - ), - ), - PopupMenuItem( - onTap: () => context.showAdaptiveSheet( - (_) => const StartDmSheet(), - ), - child: const ListTile( - title: Text("Start a direct message"), - leading: Icon(Icons.person_add), - ), - ), - ], - icon: const Icon(Icons.add), - ), - const AccountSwitcher(), - IconButton( - tooltip: "Explore other rooms", - onPressed: () => Navigator.of(context).push( - MaterialPageRoute(builder: (_) => const ExplorePage()), - ), - icon: const Icon(Icons.explore), - ), - IconButton( - tooltip: "Open settings", - onPressed: () => showDialog( - context: context, - builder: (_) => SettingsPage(), - ), - icon: const Icon(Icons.settings), - ), - ], - ), - ), - ), - ), - ); - } -} - -class const RoomsPane({super.key}) extends ConsumerWidget { - @override - Widget build(BuildContext context, WidgetRef ref) { - final selectedRoomId = ref.watch(SelectedRoomController.provider); - final selectedSpace = ref.watch(SelectedSpaceController.provider)!; - final isDm = selectedSpace.id == "dms"; - final spaceMetadata = selectedSpace.room?.metadata; - // In the order the rail shows them, with the space's own timeline first - final destinationIds = IList([?spaceMetadata?.id]) - .addAll(selectedSpace.allChildRooms.map((room) => room.metadata?.id)); - - return Scaffold( - backgroundColor: Colors.transparent, - appBar: Appbar( - // Home and DMs aren't real spaces, so they don't have a summary. - onTap: spaceMetadata == null - ? null - : () => context.showAdaptiveSheet( - (_) => RoomSummarySheet(.fromMetadata(spaceMetadata)), - ), - windowControls: false, - leading: AvatarOrHash( - spaceMetadata?.avatar, - fallback: selectedSpace.icon == null - ? null - : Icon(selectedSpace.icon), - selectedSpace.title, - ), - title: RoomTitle(selectedSpace.title, topic: spaceMetadata?.topic), - backgroundColor: Colors.transparent, - actions: .new([ - RoomMenuButton( - selectedSpace.room, - children: selectedSpace.allChildRooms, - ), - ]), - ), - body: M3ERailTheme( - extensions: [ - NavigationRailM3ETheme( - itemExpandedHeight: 48, - iconLabelGap: 16, - sectionHeaderSpacingTop: 0, - ), - ], - builder: (context) => Padding( - padding: const .only(top: 4), - child: NavigationRailM3E( - fab: selectedSpace.room == null - ? null - : .new( - icon: const Icon(Icons.explore), - label: "Browse space", - tooltip: "Browse and join rooms in this space", - onPressed: () => context.showAdaptiveSheet( - (_) => SpaceHierarchySheet(selectedSpace.id), - ), - ), - expandedWidth: double.infinity, - scrollable: true, - background: Colors.transparent, - type: .alwaysExpand, - selectedIndex: max(0, destinationIds.indexOf(selectedRoomId)), - sections: [ - if (selectedSpace.room case final room? - when spaceMetadata != null) - .new( - destinations: [ - room.toDestination( - isDm: isDm, - label: "Space timeline", - icon: const Icon(Icons.forum), - ), - ], - ), - .new( - header: selectedSpace.room == null - ? null - : const DividerWidget(Text("Rooms")), - destinations: selectedSpace.children.toDestinations(isDm: isDm), - ), - ...selectedSpace.subSpaces.map( - (subSpace) => NavigationRailM3ESection( - header: DividerWidget( - Row( - mainAxisSize: .min, - spacing: 8, - children: [ - if (subSpace.room.metadata?.avatar != null) - AvatarOrHash( - subSpace.room.metadata?.avatar, - subSpace.room.metadata?.name ?? "Unnamed Room", - dimension: 16, - ), - Flexible( - child: Text( - subSpace.room.metadata?.name ?? "Unnamed Space", - maxLines: 1, - overflow: .ellipsis, - ), - ), - ], - ), - ), - destinations: subSpace.children.toDestinations(isDm: isDm), - ), - ), - ], - onDestinationSelected: (value) { - ref - .read(KeyController.provider(KeyController.roomKey).notifier) - .set(destinationIds[value]); - if (Navigator.of(context).canPop()) { - Navigator.of(context).pop(); - } - }, - ), - ), - ), - ); - } -} diff --git a/lib/widgets/add_directory_server_sheet.dart b/lib/widgets/rooms/add_directory_server_sheet.dart similarity index 100% rename from lib/widgets/add_directory_server_sheet.dart rename to lib/widgets/rooms/add_directory_server_sheet.dart diff --git a/lib/widgets/add_space_rooms_sheet.dart b/lib/widgets/rooms/add_space_rooms_sheet.dart similarity index 99% rename from lib/widgets/add_space_rooms_sheet.dart rename to lib/widgets/rooms/add_space_rooms_sheet.dart index b6d8767..e78ba7a 100644 --- a/lib/widgets/add_space_rooms_sheet.dart +++ b/lib/widgets/rooms/add_space_rooms_sheet.dart @@ -14,7 +14,7 @@ import "package:nexus/helpers/extensions/with_progress_snackbar.dart"; import "package:nexus/main.dart"; import "package:nexus/models/content/content.dart"; import "package:nexus/models/content/space_child.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; import "package:nexus/widgets/settings/search_chooser.dart"; /// Chooses rooms to add to the space [spaceId], then adds them. diff --git a/lib/widgets/create_room_sheet.dart b/lib/widgets/rooms/create_room_sheet.dart similarity index 100% rename from lib/widgets/create_room_sheet.dart rename to lib/widgets/rooms/create_room_sheet.dart diff --git a/lib/widgets/join_sheet.dart b/lib/widgets/rooms/join_sheet.dart similarity index 96% rename from lib/widgets/join_sheet.dart rename to lib/widgets/rooms/join_sheet.dart index 8977814..e9ee719 100644 --- a/lib/widgets/join_sheet.dart +++ b/lib/widgets/rooms/join_sheet.dart @@ -4,7 +4,7 @@ import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; import "package:nexus/controllers/room_summary.dart"; import "package:nexus/helpers/extensions/get_link_info.dart"; -import "package:nexus/widgets/room_summary_sheet.dart"; +import "package:nexus/widgets/rooms/room_summary_sheet.dart"; class const JoinSheet(final WidgetRef ref, {super.key}) extends HookWidget { @override diff --git a/lib/widgets/knock_sheet.dart b/lib/widgets/rooms/knock_sheet.dart similarity index 100% rename from lib/widgets/knock_sheet.dart rename to lib/widgets/rooms/knock_sheet.dart diff --git a/lib/widgets/room_directory_card.dart b/lib/widgets/rooms/room_directory_card.dart similarity index 96% rename from lib/widgets/room_directory_card.dart rename to lib/widgets/rooms/room_directory_card.dart index e8d8bfc..10cc071 100644 --- a/lib/widgets/room_directory_card.dart +++ b/lib/widgets/rooms/room_directory_card.dart @@ -8,9 +8,9 @@ import "package:nexus/helpers/extensions/focus_room.dart"; import "package:nexus/helpers/extensions/join_room.dart"; import "package:nexus/helpers/extensions/room_summary_display.dart"; import "package:nexus/models/room_summary.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/knock_sheet.dart"; -import "package:nexus/widgets/room_summary_sheet.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/rooms/knock_sheet.dart"; +import "package:nexus/widgets/rooms/room_summary_sheet.dart"; class const RoomDirectoryCard( final RoomSummary summary, { diff --git a/lib/widgets/room_menu_button.dart b/lib/widgets/rooms/room_menu_button.dart similarity index 78% rename from lib/widgets/room_menu_button.dart rename to lib/widgets/rooms/room_menu_button.dart index 2f3f156..22d94f9 100644 --- a/lib/widgets/room_menu_button.dart +++ b/lib/widgets/rooms/room_menu_button.dart @@ -5,7 +5,9 @@ import "package:nexus/helpers/extensions/get_localpart.dart"; import "package:nexus/helpers/extensions/show_leave_room_sheet.dart"; import "package:flutter/services.dart"; import "package:flutter_riverpod/flutter_riverpod.dart"; +import "package:nexus/controllers/account_data.dart"; import "package:nexus/controllers/client.dart"; +import "package:nexus/models/room_notification_level.dart"; import "package:nexus/controllers/room_settings_sections.dart"; import "package:nexus/widgets/settings/settings_layout.dart"; import "package:nexus/controllers/via.dart"; @@ -44,6 +46,44 @@ final class const RoomMenuButton( ), ), if (room != null) ...[ + PopupMenuItem( + onTap: () async { + final roomId = room!.metadata!.id; + final accountData = ref.read( + AccountDataController.provider.notifier, + ); + final current = RoomNotificationLevel.of( + ref.read(AccountDataController.provider).pushRules.global, + roomId, + ); + + final level = await context.showAdaptiveMenu( + RoomNotificationLevel.values + .map( + (level) => PopupMenuItem( + value: level, + child: ListTile( + selected: level == current, + leading: Icon(level.icon), + title: Text(level.title), + subtitle: Text(level.description), + trailing: level == current ? Icon(Icons.check) : null, + ), + ), + ) + .toList(), + ); + if (level == null) return; + await accountData + .setRoomNotificationLevel(roomId, level) + .onError(showError); + }, + child: ListTile( + leading: Icon(Icons.notifications), + title: Text("Notifications"), + trailing: Icon(Icons.expand_more), + ), + ), PopupMenuItem( onTap: () async { final vias = ref.read(ViaController.provider(room!)).viaQuery; diff --git a/lib/widgets/room_summary_sheet.dart b/lib/widgets/rooms/room_summary_sheet.dart similarity index 89% rename from lib/widgets/room_summary_sheet.dart rename to lib/widgets/rooms/room_summary_sheet.dart index 373c833..2195101 100644 --- a/lib/widgets/room_summary_sheet.dart +++ b/lib/widgets/rooms/room_summary_sheet.dart @@ -9,10 +9,10 @@ import "package:nexus/helpers/extensions/get_localpart.dart"; import "package:nexus/helpers/extensions/join_room.dart"; import "package:nexus/helpers/extensions/room_summary_display.dart"; import "package:nexus/main.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/expandable_image.dart"; -import "package:nexus/widgets/knock_sheet.dart"; -import "package:nexus/widgets/linkified_text.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/common/expandable_image.dart"; +import "package:nexus/widgets/rooms/knock_sheet.dart"; +import "package:nexus/widgets/common/linkified_text.dart"; import "package:nexus/models/room_summary.dart"; class const RoomSummarySheet( @@ -155,27 +155,32 @@ class const RoomSummarySheet( title: const Text("Invite reason"), subtitle: SelectableText(reason), ), - // Invite state never includes the member count - if (summary.joinedMembers != null || !isInvite) + + if (summary.joinedMembers != null) ListTile( title: Text( "${summary.joinedMembers ?? "Unknown number of"} members", ), leading: Icon(Icons.people), ), + + if (summary.canonicalAlias case final canonicalAlias?) + ListTile( + title: Text("Canonical Alias"), + subtitle: SelectableText(canonicalAlias), + leading: Icon(Icons.numbers), + ), + ListTile( - title: Text( - summary.canonicalAlias == null ? "Room ID" : "Canonical Alias", - ), - subtitle: SelectableText( - summary.canonicalAlias ?? summary.roomId, - ), - leading: Icon(Icons.numbers), + title: Text("Room ID"), + subtitle: SelectableText(summary.roomId), + leading: Icon(Icons.badge), ), - if (summary.topic != null) + + if (summary.topic case final topic?) ListTile( title: Text("Topic"), - subtitle: LinkifiedText(summary.topic!, roomId: summary.roomId), + subtitle: LinkifiedText(topic, roomId: summary.roomId), leading: Icon(Icons.info), ), if (isKnocking) diff --git a/lib/widgets/room_title.dart b/lib/widgets/rooms/room_title.dart similarity index 100% rename from lib/widgets/room_title.dart rename to lib/widgets/rooms/room_title.dart diff --git a/lib/widgets/space_hierarchy_sheet.dart b/lib/widgets/rooms/space_hierarchy_sheet.dart similarity index 97% rename from lib/widgets/space_hierarchy_sheet.dart rename to lib/widgets/rooms/space_hierarchy_sheet.dart index 613c13c..65fb5da 100644 --- a/lib/widgets/space_hierarchy_sheet.dart +++ b/lib/widgets/rooms/space_hierarchy_sheet.dart @@ -17,12 +17,12 @@ import "package:nexus/main.dart"; import "package:nexus/models/content/content.dart"; import "package:nexus/models/content/create.dart"; import "package:nexus/models/space_hierarchy.dart"; -import "package:nexus/widgets/add_space_rooms_sheet.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/expandable_image.dart"; -import "package:nexus/widgets/knock_sheet.dart"; -import "package:nexus/widgets/loading.dart"; -import "package:nexus/widgets/room_summary_sheet.dart"; +import "package:nexus/widgets/rooms/add_space_rooms_sheet.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/common/expandable_image.dart"; +import "package:nexus/widgets/rooms/knock_sheet.dart"; +import "package:nexus/widgets/common/loading.dart"; +import "package:nexus/widgets/rooms/room_summary_sheet.dart"; class const SpaceHierarchySheet(final String spaceId, {super.key}) extends ConsumerWidget { diff --git a/lib/widgets/settings/allowed_rooms_sheet.dart b/lib/widgets/settings/allowed_rooms_sheet.dart index 8123c51..63aac8b 100644 --- a/lib/widgets/settings/allowed_rooms_sheet.dart +++ b/lib/widgets/settings/allowed_rooms_sheet.dart @@ -7,7 +7,7 @@ import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; import "package:nexus/controllers/client.dart"; import "package:nexus/controllers/rooms.dart"; import "package:nexus/main.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; import "package:nexus/widgets/settings/search_chooser.dart"; /// Chooses the rooms whose members can join [roomId] without an invite. diff --git a/lib/widgets/settings/enable_image_packs_sheet.dart b/lib/widgets/settings/enable_image_packs_sheet.dart index 9bc952f..427f7d8 100644 --- a/lib/widgets/settings/enable_image_packs_sheet.dart +++ b/lib/widgets/settings/enable_image_packs_sheet.dart @@ -8,8 +8,8 @@ import "package:nexus/controllers/room_image_packs.dart"; import "package:nexus/controllers/rooms.dart"; import "package:nexus/helpers/extensions/better_when.dart"; import "package:nexus/models/account_data.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/image_pack_avatar.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/image_pack_avatar.dart"; /// Chooses a room, then which of its image packs to use in every room. class const EnableImagePacksSheet({ diff --git a/lib/widgets/settings/image_pack_sheet.dart b/lib/widgets/settings/image_pack_sheet.dart index 2dd394e..d18d3f6 100644 --- a/lib/widgets/settings/image_pack_sheet.dart +++ b/lib/widgets/settings/image_pack_sheet.dart @@ -9,8 +9,8 @@ import "package:nexus/helpers/hooks/saving.dart"; import "package:nexus/main.dart"; import "package:nexus/models/content/image_pack.dart"; import "package:nexus/models/content/message.dart"; -import "package:nexus/widgets/image_pack_avatar.dart"; -import "package:nexus/widgets/mxc_emoji.dart"; +import "package:nexus/widgets/avatars/image_pack_avatar.dart"; +import "package:nexus/widgets/emoji/mxc_emoji.dart"; import "package:nexus/widgets/settings/image_usage_chips.dart"; import "package:nexus/widgets/settings/pack_image_sheet.dart"; diff --git a/lib/widgets/settings/member_chooser.dart b/lib/widgets/settings/member_chooser.dart index 18ed2e2..fbaaa8e 100644 --- a/lib/widgets/settings/member_chooser.dart +++ b/lib/widgets/settings/member_chooser.dart @@ -6,7 +6,7 @@ import "package:material_ui/material_ui.dart"; import "package:nexus/controllers/members.dart"; import "package:nexus/helpers/extensions/get_localpart.dart"; import "package:nexus/models/content/membership.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; import "package:nexus/widgets/settings/search_chooser.dart"; /// The [chosen] users, above a field searching [roomId]'s members, or taking a user ID, to choose more. diff --git a/lib/widgets/settings/pack_image_sheet.dart b/lib/widgets/settings/pack_image_sheet.dart index da17f38..89ed4f7 100644 --- a/lib/widgets/settings/pack_image_sheet.dart +++ b/lib/widgets/settings/pack_image_sheet.dart @@ -3,7 +3,7 @@ import "package:flutter_hooks/flutter_hooks.dart"; import "package:material_ui/material_ui.dart"; import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; import "package:nexus/models/content/image_pack.dart"; -import "package:nexus/widgets/mxc_emoji.dart"; +import "package:nexus/widgets/emoji/mxc_emoji.dart"; import "package:nexus/widgets/settings/image_usage_chips.dart"; /// Edits an image in a pack, or only shows it if [onSave] is null. diff --git a/lib/widgets/settings/settings_layout.dart b/lib/widgets/settings/settings_layout.dart index 9741dcb..de20137 100644 --- a/lib/widgets/settings/settings_layout.dart +++ b/lib/widgets/settings/settings_layout.dart @@ -10,9 +10,9 @@ import "package:nexus/helpers/extensions/better_when.dart"; import "package:nexus/helpers/extensions/weighted_search.dart"; import "package:nexus/models/settings_category.dart"; import "package:nexus/widgets/pages/settings_category.dart"; -import "package:nexus/widgets/divider_text.dart"; -import "package:nexus/widgets/highlight_wrapper.dart"; -import "package:nexus/widgets/m3e_rail_theme.dart"; +import "package:nexus/widgets/common/divider_text.dart"; +import "package:nexus/widgets/common/highlight_wrapper.dart"; +import "package:nexus/widgets/common/m3e_rail_theme.dart"; import "package:super_sliver_list/super_sliver_list.dart"; /// A settings screen split into categories: a list of them that opens each diff --git a/lib/widgets/sidebar/invite_card.dart b/lib/widgets/sidebar/invite_card.dart new file mode 100644 index 0000000..239d3c1 --- /dev/null +++ b/lib/widgets/sidebar/invite_card.dart @@ -0,0 +1,52 @@ +import "package:hooks_riverpod/hooks_riverpod.dart"; +import "package:material_ui/material_ui.dart"; +import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; +import "package:nexus/controllers/invites.dart"; +import "package:nexus/helpers/extensions/get_localpart.dart"; +import "package:nexus/helpers/extensions/room_summary_display.dart"; +import "package:nexus/models/room_summary.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/rooms/room_summary_sheet.dart"; + +class const InviteCard(final RoomSummary invite, {super.key}) + extends ConsumerWidget { + @override + Widget build(BuildContext context, WidgetRef ref) { + final responding = ref + .watch(InvitesController.respondMutation(invite.roomId)) + .isPending; + final name = invite.name ?? invite.canonicalAlias ?? invite.roomId; + final inviterName = + invite.inviterProfile?.displayName ?? invite.invitedBy?.localpart; + + return Card( + clipBehavior: .antiAlias, + child: ListTile( + onTap: responding + ? null + : () => context.showAdaptiveSheet((_) => RoomSummarySheet(invite)), + trailing: responding + ? const SizedBox.square( + dimension: 24, + child: CircularProgressIndicator(), + ) + : null, + leading: AvatarOrHash( + invite.avatarUrl, + name, + dimension: 40, + fallback: invite.isDirect ? null : Icon(invite.icon), + ), + title: Text(name, maxLines: 1, overflow: .ellipsis), + subtitle: Text( + [ + if (inviterName != null) + "${invite.isDirect ? "Direct message from" : "Invited by"} $inviterName", + ].join("\n"), + maxLines: 2, + overflow: .ellipsis, + ), + ), + ); + } +} diff --git a/lib/widgets/invites_list.dart b/lib/widgets/sidebar/invites_list.dart similarity index 63% rename from lib/widgets/invites_list.dart rename to lib/widgets/sidebar/invites_list.dart index 68d8b3b..18fb5f0 100644 --- a/lib/widgets/invites_list.dart +++ b/lib/widgets/sidebar/invites_list.dart @@ -1,14 +1,10 @@ +import "package:nexus/widgets/sidebar/invite_card.dart"; import "package:hooks_riverpod/hooks_riverpod.dart"; import "package:material_ui/material_ui.dart"; import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; import "package:nexus/controllers/invites.dart"; -import "package:nexus/helpers/extensions/get_localpart.dart"; -import "package:nexus/helpers/extensions/room_summary_display.dart"; import "package:nexus/main.dart"; import "package:nexus/models/nav_page.dart"; -import "package:nexus/models/room_summary.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; -import "package:nexus/widgets/room_summary_sheet.dart"; class const InvitesList({super.key}) extends ConsumerWidget implements NavPage { @override @@ -92,46 +88,3 @@ class const InvitesList({super.key}) extends ConsumerWidget implements NavPage { ); } } - -class const InviteCard(final RoomSummary invite, {super.key}) - extends ConsumerWidget { - @override - Widget build(BuildContext context, WidgetRef ref) { - final responding = ref - .watch(InvitesController.respondMutation(invite.roomId)) - .isPending; - final name = invite.name ?? invite.canonicalAlias ?? invite.roomId; - final inviterName = - invite.inviterProfile?.displayName ?? invite.invitedBy?.localpart; - - return Card( - clipBehavior: .antiAlias, - child: ListTile( - onTap: responding - ? null - : () => context.showAdaptiveSheet((_) => RoomSummarySheet(invite)), - trailing: responding - ? const SizedBox.square( - dimension: 24, - child: CircularProgressIndicator(), - ) - : null, - leading: AvatarOrHash( - invite.avatarUrl, - name, - dimension: 40, - fallback: invite.isDirect ? null : Icon(invite.icon), - ), - title: Text(name, maxLines: 1, overflow: .ellipsis), - subtitle: Text( - [ - if (inviterName != null) - "${invite.isDirect ? "Direct message from" : "Invited by"} $inviterName", - ].join("\n"), - maxLines: 2, - overflow: .ellipsis, - ), - ), - ); - } -} diff --git a/lib/widgets/notifications_list.dart b/lib/widgets/sidebar/notifications_list.dart similarity index 97% rename from lib/widgets/notifications_list.dart rename to lib/widgets/sidebar/notifications_list.dart index 23ff676..f52f944 100644 --- a/lib/widgets/notifications_list.dart +++ b/lib/widgets/sidebar/notifications_list.dart @@ -9,9 +9,9 @@ import "package:nexus/controllers/notifications.dart"; import "package:nexus/helpers/extensions/focus_room.dart"; import "package:nexus/models/event.dart"; import "package:nexus/models/nav_page.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/widgets/highlight_wrapper.dart"; -import "package:nexus/widgets/loading.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/widgets/common/highlight_wrapper.dart"; +import "package:nexus/widgets/common/loading.dart"; import "package:nexus/widgets/renderers/event.dart"; import "package:super_sliver_list/super_sliver_list.dart"; diff --git a/lib/widgets/sidebar/room_list.dart b/lib/widgets/sidebar/room_list.dart new file mode 100644 index 0000000..0e94cdb --- /dev/null +++ b/lib/widgets/sidebar/room_list.dart @@ -0,0 +1,59 @@ +import "package:nexus/widgets/sidebar/spaces_rail.dart"; +import "package:nexus/widgets/sidebar/rooms_pane.dart"; + +import "package:hooks_riverpod/hooks_riverpod.dart"; +import "package:material_ui/material_ui.dart"; +import "package:nexus/models/nav_page.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/controllers/rooms.dart"; +import "package:nexus/controllers/spaces.dart"; + +class const RoomList({super.key}) extends ConsumerWidget implements NavPage { + @override + String get title => "Rooms"; + + @override + IconData get icon => Icons.list; + + @override + int? badgeCount(WidgetRef ref) { + final (notifications, hasUnread) = ref.watch( + RoomsController.provider.select( + (rooms) => rooms.values.fold( + (0, false), + (total, room) => ( + total.$1 + (room.metadata?.unreadNotifications ?? 0), + total.$2 || (room.metadata?.unreadMessages ?? 0) > 0, + ), + ), + ), + ); + + return notifications > 0 + ? notifications + : hasUnread + ? 0 + : null; + } + + @override + Widget build(BuildContext context, WidgetRef ref) { + final spacesAsync = ref.watch(SpacesController.provider); + if (spacesAsync.value == null) { + return switch (spacesAsync) { + AsyncError(:final error, :final stackTrace) => ErrorDialog( + error, + stackTrace, + ), + _ => const Center(child: CircularProgressIndicator()), + }; + } + + return const Row( + children: [ + SpacesRail(), + Expanded(child: RoomsPane()), + ], + ); + } +} diff --git a/lib/widgets/sidebar/rooms_pane.dart b/lib/widgets/sidebar/rooms_pane.dart new file mode 100644 index 0000000..aabebbb --- /dev/null +++ b/lib/widgets/sidebar/rooms_pane.dart @@ -0,0 +1,143 @@ +import "dart:math"; + +import "package:fast_immutable_collections/fast_immutable_collections.dart"; +import "package:hooks_riverpod/hooks_riverpod.dart"; +import "package:material_ui/material_ui.dart"; +import "package:navigation_rail_m3e/navigation_rail_m3e.dart"; +import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; +import "package:nexus/helpers/extensions/get_all_child_rooms.dart"; +import "package:nexus/helpers/extensions/room_destinations.dart"; +import "package:nexus/widgets/common/appbar.dart"; +import "package:nexus/widgets/rooms/room_title.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/common/divider_widget.dart"; +import "package:nexus/widgets/common/m3e_rail_theme.dart"; +import "package:nexus/widgets/rooms/room_summary_sheet.dart"; +import "package:nexus/widgets/rooms/room_menu_button.dart"; +import "package:nexus/widgets/rooms/space_hierarchy_sheet.dart"; +import "package:nexus/controllers/key.dart"; +import "package:nexus/controllers/selected_room.dart"; +import "package:nexus/controllers/selected_space.dart"; + +class const RoomsPane({super.key}) extends ConsumerWidget { + @override + Widget build(BuildContext context, WidgetRef ref) { + final selectedRoomId = ref.watch(SelectedRoomController.provider); + final selectedSpace = ref.watch(SelectedSpaceController.provider)!; + final isDm = selectedSpace.id == "dms"; + final spaceMetadata = selectedSpace.room?.metadata; + // In the order the rail shows them, with the space's own timeline first + final destinationIds = IList([?spaceMetadata?.id]) + .addAll(selectedSpace.allChildRooms.map((room) => room.metadata?.id)); + + return Scaffold( + backgroundColor: Colors.transparent, + appBar: Appbar( + // Home and DMs aren't real spaces, so they don't have a summary. + onTap: spaceMetadata == null + ? null + : () => context.showAdaptiveSheet( + (_) => RoomSummarySheet(.fromMetadata(spaceMetadata)), + ), + windowControls: false, + leading: AvatarOrHash( + spaceMetadata?.avatar, + fallback: selectedSpace.icon == null + ? null + : Icon(selectedSpace.icon), + selectedSpace.title, + ), + title: RoomTitle(selectedSpace.title, topic: spaceMetadata?.topic), + backgroundColor: Colors.transparent, + actions: .new([ + RoomMenuButton( + selectedSpace.room, + children: selectedSpace.allChildRooms, + ), + ]), + ), + body: M3ERailTheme( + extensions: [ + NavigationRailM3ETheme( + itemExpandedHeight: 48, + iconLabelGap: 16, + sectionHeaderSpacingTop: 0, + ), + ], + builder: (context) => Padding( + padding: const .only(top: 4), + child: NavigationRailM3E( + fab: selectedSpace.room == null + ? null + : .new( + icon: const Icon(Icons.explore), + label: "Browse space", + tooltip: "Browse and join rooms in this space", + onPressed: () => context.showAdaptiveSheet( + (_) => SpaceHierarchySheet(selectedSpace.id), + ), + ), + expandedWidth: double.infinity, + scrollable: true, + background: Colors.transparent, + type: .alwaysExpand, + selectedIndex: max(0, destinationIds.indexOf(selectedRoomId)), + sections: [ + if (selectedSpace.room case final room? + when spaceMetadata != null) + .new( + destinations: [ + room.toDestination( + isDm: isDm, + label: "Space timeline", + icon: const Icon(Icons.forum), + ), + ], + ), + .new( + header: selectedSpace.room == null + ? null + : const DividerWidget(Text("Rooms")), + destinations: selectedSpace.children.toDestinations(isDm: isDm), + ), + ...selectedSpace.subSpaces.map( + (subSpace) => NavigationRailM3ESection( + header: DividerWidget( + Row( + mainAxisSize: .min, + spacing: 8, + children: [ + if (subSpace.room.metadata?.avatar != null) + AvatarOrHash( + subSpace.room.metadata?.avatar, + subSpace.room.metadata?.name ?? "Unnamed Room", + dimension: 16, + ), + Flexible( + child: Text( + subSpace.room.metadata?.name ?? "Unnamed Space", + maxLines: 1, + overflow: .ellipsis, + ), + ), + ], + ), + ), + destinations: subSpace.children.toDestinations(isDm: isDm), + ), + ), + ], + onDestinationSelected: (value) { + ref + .read(KeyController.provider(KeyController.roomKey).notifier) + .set(destinationIds[value]); + if (Navigator.of(context).canPop()) { + Navigator.of(context).pop(); + } + }, + ), + ), + ), + ); + } +} diff --git a/lib/widgets/sidebar.dart b/lib/widgets/sidebar/sidebar.dart similarity index 88% rename from lib/widgets/sidebar.dart rename to lib/widgets/sidebar/sidebar.dart index 3ed8daa..d8f98cb 100644 --- a/lib/widgets/sidebar.dart +++ b/lib/widgets/sidebar/sidebar.dart @@ -4,10 +4,10 @@ import "package:material_ui/material_ui.dart"; import "package:nexus/controllers/sidebar_page.dart"; import "package:nexus/models/nav_page.dart"; import "package:nexus/models/sidebar_page.dart"; -import "package:nexus/widgets/count_badge.dart"; -import "package:nexus/widgets/invites_list.dart"; -import "package:nexus/widgets/notifications_list.dart"; -import "package:nexus/widgets/room_list.dart"; +import "package:nexus/widgets/common/count_badge.dart"; +import "package:nexus/widgets/sidebar/invites_list.dart"; +import "package:nexus/widgets/sidebar/notifications_list.dart"; +import "package:nexus/widgets/sidebar/room_list.dart"; class const Sidebar({super.key}) extends ConsumerWidget { static NavPage pageFor(SidebarPage page) => switch (page) { diff --git a/lib/widgets/sidebar/spaces_rail.dart b/lib/widgets/sidebar/spaces_rail.dart new file mode 100644 index 0000000..d84a40a --- /dev/null +++ b/lib/widgets/sidebar/spaces_rail.dart @@ -0,0 +1,142 @@ +import "dart:math"; + +import "package:hooks_riverpod/hooks_riverpod.dart"; +import "package:material_ui/material_ui.dart"; +import "package:navigation_rail_m3e/navigation_rail_m3e.dart"; +import "package:material_adaptive_sheets/material_adaptive_sheets.dart"; +import "package:nexus/helpers/extensions/get_all_child_rooms.dart"; +import "package:nexus/widgets/common/account_switcher.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; +import "package:nexus/widgets/rooms/create_room_sheet.dart"; +import "package:nexus/widgets/users/start_dm_sheet.dart"; +import "package:nexus/widgets/pages/explore.dart"; +import "package:nexus/widgets/pages/settings.dart"; +import "package:nexus/widgets/rooms/join_sheet.dart"; +import "package:nexus/widgets/common/m3e_rail_theme.dart"; +import "package:nexus/controllers/key.dart"; +import "package:nexus/controllers/spaces.dart"; + +class const SpacesRail({super.key}) extends ConsumerWidget { + @override + Widget build(BuildContext context, WidgetRef ref) { + final spaces = ref.watch( + SpacesController.provider.select((async) => async.requireValue), + ); + final selectedSpaceId = ref.watch( + KeyController.provider(KeyController.spaceKey) + .select((async) => async.requireValue), + ); + + return M3ERailTheme( + extensions: [ + NavigationRailM3ETheme(itemCollapsedHeight: 48, itemVerticalGap: 0), + ], + builder: (context) => Container( + color: NavigationRailTokensAdapter(context).containerColor, + padding: .only(top: 16), + child: NavigationRailM3E( + type: .alwaysCollapse, + labelBehavior: .alwaysHide, + scrollable: true, + onDestinationSelected: (value) { + ref + .read(KeyController.provider(KeyController.spaceKey).notifier) + .set(spaces[value].id); + ref + .read(KeyController.provider(KeyController.roomKey).notifier) + .set(spaces[value].children.firstOrNull?.metadata?.id); + }, + sections: [ + .new( + destinations: spaces.map((space) { + final notifications = space.allChildRooms.fold( + 0, + (sum, room) => + sum + (room.metadata?.unreadNotifications ?? 0), + ); + + return NavigationRailM3EDestination( + badgeCount: notifications > 0 + ? notifications + : space.allChildRooms.any( + (room) => room.metadata?.unreadMessages != 0, + ) + ? 0 + : null, + short: true, + icon: AvatarOrHash( + dimension: 28, + space.room?.metadata?.avatar, + fallback: space.icon == null ? null : Icon(space.icon), + space.title, + ), + label: space.title, + ); + }).toList(), + ), + ], + selectedIndex: max( + 0, + spaces.indexWhere((space) => space.id == selectedSpaceId), + ), + trailingAtBottom: true, + trailing: Padding( + padding: .only(top: 8), + child: Column( + children: [ + AdaptiveMenuButton( + tooltip: "Add a room", + itemBuilder: (_) => [ + PopupMenuItem( + onTap: () => + context.showAdaptiveSheet((_) => JoinSheet(ref)), + child: const ListTile( + title: Text("Join an existing room (or space)"), + leading: Icon(Icons.numbers), + ), + ), + PopupMenuItem( + onTap: () => context.showAdaptiveSheet( + (_) => const CreateRoomSheet(), + ), + child: const ListTile( + title: Text("Create a new room (or space)"), + leading: Icon(Icons.add), + ), + ), + PopupMenuItem( + onTap: () => context.showAdaptiveSheet( + (_) => const StartDmSheet(), + ), + child: const ListTile( + title: Text("Start a direct message"), + leading: Icon(Icons.person_add), + ), + ), + ], + icon: const Icon(Icons.add), + ), + const AccountSwitcher(), + IconButton( + tooltip: "Explore other rooms", + onPressed: () => Navigator.of(context).push( + MaterialPageRoute(builder: (_) => const ExplorePage()), + ), + icon: const Icon(Icons.explore), + ), + IconButton( + tooltip: "Open settings", + onPressed: () => showDialog( + context: context, + builder: (_) => SettingsPage(), + ), + icon: const Icon(Icons.settings), + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/widgets/thread_drawer.dart b/lib/widgets/threads/thread_drawer.dart similarity index 100% rename from lib/widgets/thread_drawer.dart rename to lib/widgets/threads/thread_drawer.dart diff --git a/lib/widgets/thread_summary.dart b/lib/widgets/threads/thread_summary.dart similarity index 100% rename from lib/widgets/thread_summary.dart rename to lib/widgets/threads/thread_summary.dart diff --git a/lib/widgets/threads_drawer.dart b/lib/widgets/threads/threads_drawer.dart similarity index 96% rename from lib/widgets/threads_drawer.dart rename to lib/widgets/threads/threads_drawer.dart index a2ff127..e7931da 100644 --- a/lib/widgets/threads_drawer.dart +++ b/lib/widgets/threads/threads_drawer.dart @@ -4,10 +4,10 @@ import "package:nexus/controllers/thread_list.dart"; import "package:nexus/controllers/rooms.dart"; import "package:nexus/helpers/extensions/thread_events.dart"; import "package:nexus/main.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/widgets/loading.dart"; -import "package:nexus/widgets/event_preview.dart"; -import "package:nexus/widgets/timestamp.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/widgets/common/loading.dart"; +import "package:nexus/widgets/renderers/event_preview.dart"; +import "package:nexus/widgets/common/timestamp.dart"; final class const ThreadsDrawer( final String roomId, { diff --git a/lib/widgets/mutual_rooms_sheet.dart b/lib/widgets/users/mutual_rooms_sheet.dart similarity index 97% rename from lib/widgets/mutual_rooms_sheet.dart rename to lib/widgets/users/mutual_rooms_sheet.dart index 4c47577..16066b0 100644 --- a/lib/widgets/mutual_rooms_sheet.dart +++ b/lib/widgets/users/mutual_rooms_sheet.dart @@ -7,7 +7,7 @@ import "package:nexus/controllers/rooms.dart"; import "package:nexus/controllers/sidebar_page.dart"; import "package:nexus/helpers/extensions/better_when.dart"; import "package:nexus/helpers/extensions/focus_room.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; /// The rooms the user shares with [userId]. class const MutualRoomsSheet(final String userId, {super.key}) diff --git a/lib/widgets/start_dm_sheet.dart b/lib/widgets/users/start_dm_sheet.dart similarity index 100% rename from lib/widgets/start_dm_sheet.dart rename to lib/widgets/users/start_dm_sheet.dart diff --git a/lib/widgets/timezone_field.dart b/lib/widgets/users/timezone_field.dart similarity index 100% rename from lib/widgets/timezone_field.dart rename to lib/widgets/users/timezone_field.dart diff --git a/lib/widgets/user_bottom_sheet.dart b/lib/widgets/users/user_bottom_sheet.dart similarity index 97% rename from lib/widgets/user_bottom_sheet.dart rename to lib/widgets/users/user_bottom_sheet.dart index 373ed52..12e0e24 100644 --- a/lib/widgets/user_bottom_sheet.dart +++ b/lib/widgets/users/user_bottom_sheet.dart @@ -19,19 +19,19 @@ import "package:nexus/helpers/extensions/create_room.dart"; import "package:nexus/helpers/extensions/success_scheme.dart"; import "package:nexus/helpers/extensions/with_progress_snackbar.dart"; import "package:nexus/helpers/extensions/get_localpart.dart"; -import "package:nexus/widgets/error_dialog.dart"; -import "package:nexus/widgets/loading.dart"; -import "package:nexus/widgets/mutual_rooms_sheet.dart"; +import "package:nexus/widgets/common/error_dialog.dart"; +import "package:nexus/widgets/common/loading.dart"; +import "package:nexus/widgets/users/mutual_rooms_sheet.dart"; import "package:nexus/models/content/membership.dart"; import "package:nexus/models/membership_action.dart"; import "package:nexus/models/profile_response.dart"; -import "package:nexus/widgets/avatar_or_hash.dart"; +import "package:nexus/widgets/avatars/avatar_or_hash.dart"; import "package:nexus/main.dart"; -import "package:nexus/widgets/editable_avatar.dart"; -import "package:nexus/widgets/expandable_image.dart"; +import "package:nexus/widgets/avatars/editable_avatar.dart"; +import "package:nexus/widgets/common/expandable_image.dart"; import "package:nexus/widgets/settings/inline_text_field.dart"; -import "package:nexus/widgets/start_dm_sheet.dart"; -import "package:nexus/widgets/timezone_field.dart"; +import "package:nexus/widgets/users/start_dm_sheet.dart"; +import "package:nexus/widgets/users/timezone_field.dart"; final class const UserBottomSheet( final String userId, { diff --git a/lib/widgets/user_span.dart b/lib/widgets/users/user_span.dart similarity index 65% rename from lib/widgets/user_span.dart rename to lib/widgets/users/user_span.dart index c131a82..d8a305c 100644 --- a/lib/widgets/user_span.dart +++ b/lib/widgets/users/user_span.dart @@ -10,28 +10,32 @@ import "package:nexus/models/event.dart"; /// A user's [name] in text, opening their popover when tapped. Unlike a widget /// in text, it wraps and ellipsizes with the rest of it. -class UserSpan extends TextSpan { - UserSpan( - BuildContext context, - String name, { - required String userId, - required TapGestureRecognizer recognizer, - String? roomId, - super.style, - super.children, - }) : super( - text: name, - recognizer: recognizer - ..onTapUp = (details) { - if (!context.mounted) return; - context.showUserPopover( - userId, - roomId: roomId, - anchor: context.globalRectAt(details.globalPosition), - ); - }, - ); +// Can't be const, since it sets the recognizer's onTapUp +// ignore: prefer_const_constructors_in_immutables +class UserSpan( + BuildContext context, + String name, { + required String userId, + required TapGestureRecognizer recognizer, + String? roomId, + super.style, + super.children, +}) extends TextSpan { + this + : super( + text: name, + recognizer: recognizer + ..onTapUp = (details) { + if (!context.mounted) return; + + context.showUserPopover( + userId, + roomId: roomId, + anchor: context.globalRectAt(details.globalPosition), + ); + }, + ); factory UserSpan.sender( BuildContext context, @@ -43,7 +47,7 @@ class UserSpan extends TextSpan { return UserSpan( context, - ref.watch(AuthorController.provider(event)).value?.displayName ?? + ref.watch(AuthorController.provider(.fromEvent(event))).value?.displayName ?? event.sender.localpart, userId: event.sender, roomId: event.roomId, diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 077376d..955bc02 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,10 +7,11 @@ #include "generated_plugin_registrant.h" #include +#include +#include #include #include -#include -#include +#include #include #include @@ -18,18 +19,21 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) app_links_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "AppLinksPluginLinux"); app_links_plugin_linux_register_with_registrar(app_links_linux_registrar); + g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin"); + audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar); + g_autoptr(FlPluginRegistrar) better_player_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "BetterPlayerLinuxPlugin"); + better_player_linux_plugin_register_with_registrar(better_player_linux_registrar); g_autoptr(FlPluginRegistrar) dynamic_color_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "DynamicColorPlugin"); dynamic_color_plugin_register_with_registrar(dynamic_color_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); - g_autoptr(FlPluginRegistrar) media_kit_libs_linux_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "MediaKitLibsLinuxPlugin"); - media_kit_libs_linux_plugin_register_with_registrar(media_kit_libs_linux_registrar); - g_autoptr(FlPluginRegistrar) media_kit_video_registrar = - fl_plugin_registry_get_registrar_for_plugin(registry, "MediaKitVideoPlugin"); - media_kit_video_plugin_register_with_registrar(media_kit_video_registrar); + g_autoptr(FlPluginRegistrar) location_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "LocationPlugin"); + location_plugin_register_with_registrar(location_registrar); g_autoptr(FlPluginRegistrar) pasteboard_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "PasteboardPlugin"); pasteboard_plugin_register_with_registrar(pasteboard_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 89cfca2..c41bfb1 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,10 +4,11 @@ list(APPEND FLUTTER_PLUGIN_LIST app_links_linux + audioplayers_linux + better_player_linux dynamic_color file_selector_linux - media_kit_libs_linux - media_kit_video + location pasteboard url_launcher_linux ) diff --git a/linux/nexus.federated.nexus.metainfo.xml b/linux/nexus.federated.nexus.metainfo.xml new file mode 100644 index 0000000..53c738c --- /dev/null +++ b/linux/nexus.federated.nexus.metainfo.xml @@ -0,0 +1,78 @@ + + + nexus.federated.nexus + CC0-1.0 + GPL-3.0-only + + Nexus + A simple and user-friendly Matrix client + + QuadRadical + + + +

+ Nexus is a simple and user-friendly client for Matrix, the open and + decentralized chat network. It's made with Flutter, with gomuks handling + the Matrix side. +

+

Features include:

+
    +
  • Spaces, threads, replies and reactions
  • +
  • End-to-end encryption, with verification and recovery keys
  • +
  • Polls, location sharing, and custom emoji and sticker packs
  • +
  • Multiple accounts
  • +
  • Notifications through UnifiedPush
  • +
  • Layouts for phones and desktops, including Linux phones
  • +
+
+ + nexus.federated.nexus.desktop + + https://git.federated.nexus/Nexus/nexus + https://git.federated.nexus/Nexus/nexus/issues + https://git.federated.nexus/Nexus/nexus + + + + + Chatting in a room, with its members + https://git.federated.nexus/Nexus/nexus/raw/branch/main/assets/screenshots/desktop-light.png + + + The same, in dark mode + https://git.federated.nexus/Nexus/nexus/raw/branch/main/assets/screenshots/desktop-dark.png + + + Chatting on a phone + https://git.federated.nexus/Nexus/nexus/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png + + + Spaces and rooms on a phone + https://git.federated.nexus/Nexus/nexus/raw/branch/main/fastlane/metadata/android/en-US/images/phoneScreenshots/3.png + + + + + 360 + + + keyboard + pointing + touch + + + + intense + intense + + + + + + + + + + +
diff --git a/linux/nix/build_env.nix b/linux/nix/build_env.nix new file mode 100644 index 0000000..8883959 --- /dev/null +++ b/linux/nix/build_env.nix @@ -0,0 +1,64 @@ +{ pkgs, lib }: +# What building Nexus needs, shared by the dev shell and the e2e tests +{ + packages = + with pkgs; + [ + stdenv.cc + # webcrypto's build hook runs CMake with the Unix Makefiles generator + gnumake + go + git + ffmpeg-headless + + libGL + (flutter.override { + # audioplayers plays audio through GStreamer + extraPkgConfigPackages = [ + gst_all_1.gstreamer + gst_all_1.gst-plugins-base + ]; + }) + ] + ++ lib.optionals pkgs.stdenv.isLinux [ + wayland + (callPackage ./pkg/hook_pkg_config.nix { }) + ]; + + env = lib.optionalAttrs pkgs.stdenv.isLinux { + # nativeapi includes XInput2.h and GTK's Wayland headers, which need these, but xi.pc and gdk-3.0.pc + # only list them privately, so its hook's pkg-config doesn't return them. Hooks only get NIX_ variables. + "NIX_CFLAGS_COMPILE_${pkgs.stdenv.cc.suffixSalt}" = + lib.concatMapStringsSep " " (pkg: "-isystem ${lib.getDev pkg}/include") + ( + with pkgs; + [ + libxext + libxfixes + wayland + ] + ); + # better_player loads libmpv at runtime to play videos + LD_LIBRARY_PATH = "./build/native_assets/linux:${ + lib.makeLibraryPath [ + pkgs.zlib + pkgs.mpv-unwrapped + ] + }"; + # audioplayers links GStreamer by name only, without its library directory + LIBRARY_PATH = lib.makeLibraryPath [ + pkgs.gst_all_1.gstreamer + pkgs.gst_all_1.gst-plugins-base + pkgs.glib + ]; + GST_PLUGIN_SYSTEM_PATH_1_0 = lib.makeSearchPathOutput "lib" "lib/gstreamer-1.0" ( + with pkgs.gst_all_1; + [ + gstreamer + gst-plugins-base + gst-plugins-good + gst-libav + ] + ); + }; +} diff --git a/linux/nix/bump_libmpv.sh b/linux/nix/bump_libmpv.sh new file mode 100644 index 0000000..02a74f1 --- /dev/null +++ b/linux/nix/bump_libmpv.sh @@ -0,0 +1,60 @@ +# shellcheck shell=bash + +# Opens a PR bumping the libmpv build that the Windows CI downloads, if +# mpv-winbuild-cmake has published a newer one. Run it from the repo root, with +# TOKEN set to a Forgejo token that can push branches and open PRs. + +# Checked first, so that nothing is pushed if the PR can't be opened +: "${TOKEN:?needs a Forgejo token}" +: "${GITHUB_SERVER_URL:?is set by Forgejo Actions}" +: "${GITHUB_REPOSITORY:?is set by Forgejo Actions}" +: "${GITHUB_REF_NAME:?is set by Forgejo Actions}" + +workflow=.github/workflows/windows.yml +current_url=$(grep -oE 'https://github\.com/shinchiro/mpv-winbuild-cmake/releases/download/[^"]+\.7z' "$workflow") +current_hash=$(grep -oE -- '-ne "[0-9a-f]{64}"' "$workflow" | grep -oE '[0-9a-f]{64}') + +release=$(curl -fsSL https://api.github.com/repos/shinchiro/mpv-winbuild-cmake/releases/latest) +tag=$(jq -r .tag_name <<<"$release") +url=$(jq -r '.assets[] | select(.name | test("^mpv-dev-x86_64-[0-9]{8}-git-[0-9a-f]+\\.7z$")) | .browser_download_url' <<<"$release") + +if [ -z "$url" ]; then + echo "Release $tag has no x86_64 libmpv archive" >&2 + exit 1 +fi +if [ "$url" = "$current_url" ]; then + echo "libmpv is up to date ($tag)" + exit 0 +fi + +branch="bump-libmpv-$tag" +if git ls-remote --exit-code --heads origin "$branch" >/dev/null; then + echo "$branch already exists, so its PR should already be open" + exit 0 +fi + +archive=$(mktemp) +curl -fsSL "$url" -o "$archive" +hash=$(sha256sum "$archive" | cut -d " " -f 1) +rm "$archive" + +sed -i "s|$current_url|$url|; s|$current_hash|$hash|" "$workflow" + +git config user.name "Forgejo Actions" +git config user.email "forgejo-actions@noreply.git.federated.nexus" +git switch -c "$branch" +git commit -am "bump libmpv to $tag" +git push origin "$branch" + +curl -fsS -X POST "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/pulls" \ + -H "Authorization: token $TOKEN" \ + -H "Content-Type: application/json" \ + -d "$(jq -n \ + --arg head "$branch" \ + --arg base "$GITHUB_REF_NAME" \ + --arg title "Bump libmpv to $tag" \ + --arg body "Updates the libmpv build that the Windows CI bundles to [$tag](https://github.com/shinchiro/mpv-winbuild-cmake/releases/tag/$tag)." \ + '{head: $head, base: $base, title: $title, body: $body}')" \ + >/dev/null + +echo "Opened a PR bumping libmpv to $tag" diff --git a/linux/nix/default.nix b/linux/nix/default.nix index 3c0a301..8f09dbc 100644 --- a/linux/nix/default.nix +++ b/linux/nix/default.nix @@ -30,7 +30,14 @@ appName = "Nexus"; developer = "QuadRadical"; appId = "nexus.federated.nexus"; - package = default; + # The runtime's GStreamer gets loaded instead of ours, and it can't + # load our plugins, so keep wrapGAppsHook from pointing it at them + package = default.overrideAttrs (old: { + postInstall = '' + unset GST_PLUGIN_SYSTEM_PATH_1_0 + '' + + old.postInstall; + }); runtime = "org.gnome.Platform/51"; permissions = { share = [ "network" ]; @@ -54,6 +61,94 @@ }; devShells.default = pkgs.callPackage ./devshell.nix { }; + + apps = + let + buildEnv = import ./build_env.nix { inherit pkgs lib; }; + testEnv = buildEnv.env // { + DBUS_SESSION_CONFIG = "${pkgs.dbus}/share/dbus-1/session.conf"; + }; + e2e = pkgs.writeShellApplication { + name = "nexus-e2e"; + runtimeInputs = + buildEnv.packages + ++ (with pkgs; [ + # TEMPORARY: matrix-continuwuity, once the local fixes are released + (inputs.continuwuity.packages.${system}.default.overrideAttrs { doCheck = false; }) + curl + dbus + ]); + runtimeEnv = testEnv; + text = builtins.readFile ./e2e.sh; + }; + screenshots = pkgs.writeShellApplication { + name = "nexus-screenshots"; + runtimeInputs = + buildEnv.packages + ++ (with pkgs; [ + dbus + oxipng + pngquant + ]); + runtimeEnv = testEnv; + text = builtins.readFile ./screenshots.sh; + }; + + headless = + program: + lib.getExe ( + pkgs.writeShellApplication { + name = "${lib.getName program}-headless"; + runtimeInputs = [ pkgs.cage ]; + runtimeEnv = { + WLR_BACKENDS = "headless"; + __EGL_VENDOR_LIBRARY_FILENAMES = "${pkgs.mesa}/share/glvnd/egl_vendor.d/50_mesa.json"; + }; + text = '' + unset DISPLAY WAYLAND_DISPLAY + # Wayland needs one, which CI may not have + XDG_RUNTIME_DIR="''${XDG_RUNTIME_DIR:-$(mktemp -d)}" + export XDG_RUNTIME_DIR + + exec cage -- ${lib.getExe program} "$@" + ''; + } + ); + in + { + e2e = { + type = "app"; + program = lib.getExe e2e; + }; + + bump-libmpv = { + type = "app"; + program = lib.getExe ( + pkgs.writeShellApplication { + name = "nexus-bump-libmpv"; + runtimeInputs = with pkgs; [ + coreutils + curl + git + gnugrep + gnused + jq + ]; + text = builtins.readFile ./bump_libmpv.sh; + } + ); + }; + + e2e-headless = { + type = "app"; + program = headless e2e; + }; + + screenshots = { + type = "app"; + program = headless screenshots; + }; + }; }; flake.nixosModules.default = import ./module.nix self; diff --git a/linux/nix/devshell.nix b/linux/nix/devshell.nix index f4bf1c6..1f02b67 100644 --- a/linux/nix/devshell.nix +++ b/linux/nix/devshell.nix @@ -1,5 +1,6 @@ { pkgs, lib }: let + ndkVersion = "28.2.13676358"; android = pkgs.androidenv.composeAndroidPackages { toolsVersion = "26.1.1"; platformToolsVersion = "37.0.1"; @@ -12,49 +13,40 @@ let "34" "35" "36" + "37.0" ]; abiVersions = [ "armeabi-v7a" "arm64-v8a" ]; includeNDK = true; - ndkVersions = [ "28.2.13676358" ]; + ndkVersions = [ ndkVersion ]; }; + buildEnv = import ./build_env.nix { inherit pkgs lib; }; in pkgs.mkShell { packages = - with pkgs; - [ - go - git + buildEnv.packages + ++ [ android.platform-tools ] + # For scripts/build_avif_native.sh + ++ (with pkgs; [ + cmake + jq + meson + ninja + python3 + ]); - libGL - (flutter.override { - extraPkgConfigPackages = [ - mpv-unwrapped - libass - ]; - }) - android.platform-tools - ] - ++ lib.optionals pkgs.stdenv.isLinux [ - wayland - # nativeapi includes XInput2.h, which needs these, but xi.pc only lists them privately - libxext - libxfixes - (callPackage ./pkg/hook_pkg_config.nix { }) - ]; + env = + rec { + LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.libclang ]; - env = rec { - LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.libclang ]; + ANDROID_HOME = "${android.androidsdk}/libexec/android-sdk"; + ANDROID_SDK_ROOT = ANDROID_HOME; + ANDROID_NDK_HOME = "${ANDROID_HOME}/ndk/${ndkVersion}"; + JAVA_HOME = pkgs.jdk21; - ANDROID_HOME = "${android.androidsdk}/libexec/android-sdk"; - ANDROID_SDK_ROOT = ANDROID_HOME; - JAVA_HOME = pkgs.jdk21; - - GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_HOME}/build-tools/36.0.0/aapt2"; - } - // lib.optionalAttrs pkgs.stdenv.isLinux { - LD_LIBRARY_PATH = "./build/native_assets/linux:${lib.makeLibraryPath [ pkgs.zlib ]}"; - }; + GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${ANDROID_HOME}/build-tools/36.0.0/aapt2"; + } + // buildEnv.env; } diff --git a/linux/nix/e2e.sh b/linux/nix/e2e.sh new file mode 100755 index 0000000..6a7a426 --- /dev/null +++ b/linux/nix/e2e.sh @@ -0,0 +1,85 @@ +# shellcheck shell=bash + +files=() +flutter_args=() +for arg in "$@"; do + if [[ "$arg" == *.dart ]]; then files+=("$arg"); else flutter_args+=("$arg"); fi +done +if [[ ${#files[@]} -eq 0 ]]; then files=(integration_test/*_test.dart); fi + +homeserver="http://localhost:8448" + +if curl -s -o /dev/null "$homeserver"; then + echo "Something is already using port 8448, like another e2e run." >&2 + exit 1 +fi + +work="$(mktemp -d)" +# shellcheck disable=SC2329 # Run by the trap +cleanup() { + [[ -n "${server_pid:-}" ]] && kill "$server_pid" 2>/dev/null && wait "$server_pid" 2>/dev/null + rm -rf "$work" +} +trap cleanup EXIT + +mkdir -p "$work/db" +cat > "$work/continuwuity.toml" < "$work/continuwuity.log" 2>&1 & +server_pid=$! + +all_can_log_in() { + for user in "${users[@]}"; do + curl -sf -XPOST "$homeserver/_matrix/client/v3/login" \ + -d "{\"type\":\"m.login.password\",\"identifier\":{\"type\":\"m.id.user\",\"user\":\"$user\"},\"password\":\"${user}pass\"}" \ + > /dev/null || return 1 + done +} + +# Wait until login succeeds, otherwise you might try to log in before the account is created +attempts=60 +until all_can_log_in; do + kill -0 "$server_pid" 2>/dev/null || { cat "$work/continuwuity.log"; exit 1; } + (( --attempts )) || { echo "Test users weren't created" >&2; exit 1; } + sleep 0.5 +done + +GOCACHE="$(go env GOCACHE)" +export GOCACHE + +# shellcheck disable=SC2329 +run_flutter_test() { + export DBUS_SESSION_BUS_ADDRESS="${DBUS_SESSION_BUS_ADDRESS%%;*}" + flutter test "$@" -d linux +} +export -f run_flutter_test + +status=0 +for file in "${files[@]}"; do + name="$(basename "$file" .dart)" + mkdir -p "$work/$name/data" "$work/$name/cache" + + XDG_DATA_HOME="$work/$name/data" XDG_CACHE_HOME="$work/$name/cache" \ + dbus-run-session --config-file="$DBUS_SESSION_CONFIG" -- \ + bash -c 'run_flutter_test "$@"' -- "$file" \ + --dart-define="NEXUS_E2E_HOMESERVER=$homeserver" "${flutter_args[@]}" || + status=$? +done +exit "$status" \ No newline at end of file diff --git a/linux/nix/pkg/avif_native.nix b/linux/nix/pkg/avif_native.nix index 59a5b96..64dcb81 100644 --- a/linux/nix/pkg/avif_native.nix +++ b/linux/nix/pkg/avif_native.nix @@ -1,24 +1,11 @@ # avif_native's build hook downloads its prebuilt library, which the sandbox -# can't do, so bundle it and point the manifest at the local copy instead +# can't do, so build it from source against nixpkgs' libavif, and point the +# manifest at it { stdenv, - fetchurl, + libavif, jq, }: -let - artifacts = { - x86_64-linux = { - arch = "x64"; - sha256 = "fa36210bc95b70abd14c20fd626204f57d0ef947297e9ff8ee66855c01e2c17f"; - }; - aarch64-linux = { - arch = "arm64"; - sha256 = "163487e98b5eee0676be0dc8d3f60b5e0e5b67191a8a0a2abb5c8fad14a3a506"; - }; - }; - inherit (artifacts.${stdenv.hostPlatform.system}) arch sha256; - key = "linux-${arch}-decode-dav1d"; -in { version, src, ... }: stdenv.mkDerivation { pname = "avif_native"; @@ -26,24 +13,23 @@ stdenv.mkDerivation { inherit (src) passthru; nativeBuildInputs = [ jq ]; + buildInputs = [ libavif ]; - library = fetchurl { - url = "https://github.com/Zhangw1998/avif_native/releases/download/native-v0.2.0/${key}-libavif_native.so.gz"; - inherit sha256; - }; + buildPhase = '' + $CC -shared -fPIC src/avif_shim.c -lavif -o native/libavif_native.so + ''; - # The hook checksums the library, so it must stay byte-identical + # The hook checksums the library, so it mustn't change after it's hashed dontFixup = true; + # Nexus only decodes, with dav1d, see hooks.user_defines in pubspec.yaml installPhase = '' - runHook preInstall - cp -r . $out - chmod -R u+w $out - gunzip -c $library > $out/native/libavif_native.so - jq '.artifacts["${key}"].path = "libavif_native.so"' \ - native/manifest.json > $out/native/manifest.json - - runHook postInstall + jq --arg hash "$(sha256sum native/libavif_native.so | cut -d " " -f 1)" \ + '.artifacts |= with_entries( + if .key | test("^linux-.*-decode-dav1d$") + then .value += { path: "libavif_native.so", librarySha256: $hash } + else . end + )' native/manifest.json > $out/native/manifest.json ''; } diff --git a/linux/nix/pkg/default.nix b/linux/nix/pkg/default.nix index 1248cc2..0bd7728 100644 --- a/linux/nix/pkg/default.nix +++ b/linux/nix/pkg/default.nix @@ -2,7 +2,8 @@ lib, callPackage, mpv-unwrapped, - libass, + gst_all_1, + ffmpeg-headless, libxext, libxfixes, libclang, @@ -39,8 +40,12 @@ flutter.buildFlutterApplication { nativeBuildInputs = [ (callPackage ./hook_pkg_config.nix { }) ]; buildInputs = [ - mpv-unwrapped - libass + # audioplayers plays audio through GStreamer, and wrapGAppsHook adds + # these plugins to the wrapper's GST_PLUGIN_SYSTEM_PATH_1_0 + gst_all_1.gstreamer + gst_all_1.gst-plugins-base + gst_all_1.gst-plugins-good + gst_all_1.gst-libav # nativeapi includes XInput2.h, which needs these, but xi.pc only lists them privately libxext libxfixes @@ -54,27 +59,34 @@ flutter.buildFlutterApplication { gitHashes = { linkify = "sha256-TpMD6+0zyY6i9l+6d8ErnVufmepCv362rCtnbOht/z4="; + location = "sha256-RL+l46pBhv75xP7ASJuazyYoi9vI35TSYAV11mkjAwY="; fab_m3e = "sha256-5V9m6yY0jimx2gh7lQHYg4HDKQ4Wrl0ATmBhw5DkQMI="; fluttertagger = "sha256-tHUNU2+fBPkq5UK5YRi3SWs1zF2PIPz6RgSbwignU/I="; m3e_design = "sha256-5V9m6yY0jimx2gh7lQHYg4HDKQ4Wrl0ATmBhw5DkQMI="; native_toolchain_cmake = "sha256-/drnHZebmTnsCnHgC1xmlAe+U4PSrjw5Sm9axicuTrY="; navigation_rail_m3e = "sha256-5V9m6yY0jimx2gh7lQHYg4HDKQ4Wrl0ATmBhw5DkQMI="; + pasteboard = "sha256-J3yray5n7XwVXMcOsvQ5+OvADEK2lPMeYniGg+yR704="; unifiedpush_linux = "sha256-KQKyBPL2ORK9O89C4K3RHGve/lvFaU1vIjSDnj6+bj4="; unifiedpush_platform_interface = "sha256-KQKyBPL2ORK9O89C4K3RHGve/lvFaU1vIjSDnj6+bj4="; - webcrypto = "sha256-HW0NukbddwOYd9iVUFA3L8iy1qggnyOBgcbMj0MTYss="; xdg_desktop_portal = "sha256-8GgiXHGv+wy6hJgj/rZxbymMitNVmdDLAnedZm9STSc="; }; postInstall = '' install -D assets/bundled/icon.svg $out/share/icons/hicolor/scalable/apps/nexus.svg install -Dm755 linux/*.desktop -t $out/share/applications + install -Dm644 linux/*.metainfo.xml -t $out/share/metainfo install -Dm644 linux/*.service -t $out/share/dbus-1/services + # better_player loads libmpv at runtime to play videos + # gomuks uses ffmpeg and ffprobe for video thumbnails and metadata wrapProgram $out/bin/nexus \ - --suffix LD_LIBRARY_PATH : $out/app/nexus/lib + --suffix LD_LIBRARY_PATH : $out/app/nexus/lib \ + --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ mpv-unwrapped ]} \ + --prefix PATH : ${lib.makeBinPath [ ffmpeg-headless ]} ''; meta = { description = "A simple and user-friendly Matrix client"; + license = lib.licenses.gpl3Only; mainProgram = "nexus"; platforms = lib.platforms.unix; diff --git a/linux/nix/pkg/gomuks.nix b/linux/nix/pkg/gomuks.nix index d277191..dc9f9ac 100644 --- a/linux/nix/pkg/gomuks.nix +++ b/linux/nix/pkg/gomuks.nix @@ -17,12 +17,12 @@ buildGoModule ( src = "${src}/gomuks"; - vendorHash = "sha256-VCPYI/7VQVi7qA7kTcnervlZAdAD9z5R/o6yikqW+z4="; + vendorHash = "sha256-MJu9qN1NhUkjF3MAz+ejVMY9dxg8yxMBqCCHzPh9RHc="; buildPhase = '' runHook preBuild - go build -buildmode=c-shared -o ${filename} -tags goolm,noheic,sqlite_fts5 ./pkg/ffi + go build -buildmode=c-shared -o ${filename} -tags noheic,sqlite_fts5 ./pkg/ffi runHook postBuild ''; diff --git a/linux/nix/screenshots.sh b/linux/nix/screenshots.sh new file mode 100644 index 0000000..f3dced6 --- /dev/null +++ b/linux/nix/screenshots.sh @@ -0,0 +1,30 @@ +# shellcheck shell=bash + +# Regenerates the README, AppStream and Fastlane screenshots, from +# integration_test/screenshots. Run it from the repo root. + +work="$(mktemp -d)" +# shellcheck disable=SC2329 # Run by the trap +cleanup() { rm -rf "$work"; } +trap cleanup EXIT + +GOCACHE="$(go env GOCACHE)" +export GOCACHE + +XDG_DATA_HOME="$work/data" XDG_CACHE_HOME="$work/cache" \ + dbus-run-session --config-file="$DBUS_SESSION_CONFIG" -- \ + flutter test integration_test/screenshots/screenshots_test.dart -d linux \ + --dart-define="SCREENSHOTS_DIR=$work/out" "$@" + +for shot in "$work"/out/*.png; do + pngquant --quality 65-95 --speed 1 --strip --force --ext .png "$shot" + oxipng --quiet --opt 4 --strip safe "$shot" +done + +install -Dm644 "$work"/out/desktop-*.png -t assets/screenshots + +phone=fastlane/metadata/android/en-US/images/phoneScreenshots +install -Dm644 "$work/out/phone-chat-light.png" "$phone/1.png" +install -Dm644 "$work/out/phone-chat-dark.png" "$phone/2.png" +install -Dm644 "$work/out/phone-rooms-light.png" "$phone/3.png" +install -Dm644 "$work/out/phone-rooms-dark.png" "$phone/4.png" diff --git a/linux/runner/my_application.cc b/linux/runner/my_application.cc index f5795d0..defa773 100644 --- a/linux/runner/my_application.cc +++ b/linux/runner/my_application.cc @@ -1,5 +1,6 @@ #include "my_application.h" +#include #include #include @@ -301,6 +302,9 @@ static void my_application_startup( G_APPLICATION_CLASS( my_application_parent_class) ->startup(application); + + // mpv hates normal locales + setlocale(LC_NUMERIC, "C"); } static void my_application_shutdown( diff --git a/macos/Flutter/Flutter-Debug.xcconfig b/macos/Flutter/Flutter-Debug.xcconfig index 4b81f9b..c2efd0b 100644 --- a/macos/Flutter/Flutter-Debug.xcconfig +++ b/macos/Flutter/Flutter-Debug.xcconfig @@ -1,2 +1 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/Flutter-Release.xcconfig b/macos/Flutter/Flutter-Release.xcconfig index 5caa9d1..c2efd0b 100644 --- a/macos/Flutter/Flutter-Release.xcconfig +++ b/macos/Flutter/Flutter-Release.xcconfig @@ -1,2 +1 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 88181b0..662a521 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,12 +6,12 @@ import FlutterMacOS import Foundation import app_links +import audioplayers_darwin +import better_player_macos import dynamic_color import file_selector_macos import flutter_local_notifications -import geolocator_apple -import media_kit_libs_macos_video -import media_kit_video +import location import package_info_plus import pasteboard import shared_preferences_foundation @@ -20,12 +20,12 @@ import wakelock_plus func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin")) + AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin")) + BetterPlayerPlugin.register(with: registry.registrar(forPlugin: "BetterPlayerPlugin")) DynamicColorPlugin.register(with: registry.registrar(forPlugin: "DynamicColorPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) - GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin")) - MediaKitLibsMacosVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitLibsMacosVideoPlugin")) - MediaKitVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitVideoPlugin")) + LocationPlugin.register(with: registry.registrar(forPlugin: "LocationPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) diff --git a/macos/Podfile b/macos/Podfile deleted file mode 100644 index 65543e2..0000000 --- a/macos/Podfile +++ /dev/null @@ -1,42 +0,0 @@ -platform :osx, '13.0' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_macos_podfile_setup - -target 'Runner' do - use_frameworks! - - flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) - target 'RunnerTests' do - inherit! :search_paths - end -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_macos_build_settings(target) - end -end diff --git a/macos/Podfile.lock b/macos/Podfile.lock deleted file mode 100644 index 08cb773..0000000 --- a/macos/Podfile.lock +++ /dev/null @@ -1,28 +0,0 @@ -PODS: - - FlutterMacOS (1.0.0) - - media_kit_libs_macos_video (1.0.4): - - FlutterMacOS - - media_kit_video (0.0.1): - - FlutterMacOS - -DEPENDENCIES: - - FlutterMacOS (from `Flutter/ephemeral`) - - media_kit_libs_macos_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos`) - - media_kit_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos`) - -EXTERNAL SOURCES: - FlutterMacOS: - :path: Flutter/ephemeral - media_kit_libs_macos_video: - :path: Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos - media_kit_video: - :path: Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos - -SPEC CHECKSUMS: - FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1 - media_kit_libs_macos_video: 85a23e549b5f480e72cae3e5634b5514bc692f65 - media_kit_video: fa6564e3799a0a28bff39442334817088b7ca758 - -PODFILE CHECKSUM: 54d867c82ac51cbd61b565781b9fada492027009 - -COCOAPODS: 1.17.0 diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index fa18d44..cc638f9 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -27,9 +27,7 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 34AEA7295333B7F48CD3BE4C /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D76F30AE9CCFCA04C354BD4C /* Pods_RunnerTests.framework */; }; 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; - BAF79690465DBAC1A1E19D28 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 70FD05041ACDA7E801BB9823 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -63,7 +61,6 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 18EDDEF1FB58EC56ABDA1BEB /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; @@ -80,16 +77,9 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; - 5099E6191AE87E21D356D9C8 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; - 6D9F8F8BBED102075ECF1DF9 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; - 70FD05041ACDA7E801BB9823 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; - 8F5ECEC7BF9DD35CB3E7196E /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; - 9DDE815F827B87E2C55DF94C /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - CBD1D9203BEE9731F981EEF8 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - D76F30AE9CCFCA04C354BD4C /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -97,7 +87,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 34AEA7295333B7F48CD3BE4C /* Pods_RunnerTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -106,7 +95,6 @@ buildActionMask = 2147483647; files = ( 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */, - BAF79690465DBAC1A1E19D28 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -139,8 +127,6 @@ 33CEB47122A05771004F2AC0 /* Flutter */, 331C80D6294CF71000263BE5 /* RunnerTests */, 33CC10EE2044A3C60003C045 /* Products */, - D73912EC22F37F3D000D13A0 /* Frameworks */, - FC780AF47288088B9004ACE2 /* Pods */, ); sourceTree = ""; }; @@ -189,29 +175,6 @@ path = Runner; sourceTree = ""; }; - D73912EC22F37F3D000D13A0 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 70FD05041ACDA7E801BB9823 /* Pods_Runner.framework */, - D76F30AE9CCFCA04C354BD4C /* Pods_RunnerTests.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - FC780AF47288088B9004ACE2 /* Pods */ = { - isa = PBXGroup; - children = ( - 6D9F8F8BBED102075ECF1DF9 /* Pods-Runner.debug.xcconfig */, - 9DDE815F827B87E2C55DF94C /* Pods-Runner.release.xcconfig */, - CBD1D9203BEE9731F981EEF8 /* Pods-Runner.profile.xcconfig */, - 18EDDEF1FB58EC56ABDA1BEB /* Pods-RunnerTests.debug.xcconfig */, - 8F5ECEC7BF9DD35CB3E7196E /* Pods-RunnerTests.release.xcconfig */, - 5099E6191AE87E21D356D9C8 /* Pods-RunnerTests.profile.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -219,7 +182,6 @@ isa = PBXNativeTarget; buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; buildPhases = ( - C413A8A75594D2165C9D56BD /* [CP] Check Pods Manifest.lock */, 331C80D1294CF70F00263BE5 /* Sources */, 331C80D2294CF70F00263BE5 /* Frameworks */, 331C80D3294CF70F00263BE5 /* Resources */, @@ -238,13 +200,11 @@ isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 446C82D5FE82BD05F78EDA6A /* [CP] Check Pods Manifest.lock */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, - C4D158541D7059C07D3CA9B3 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -371,67 +331,6 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; - 446C82D5FE82BD05F78EDA6A /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - 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; - }; - C413A8A75594D2165C9D56BD /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - 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; - }; - C4D158541D7059C07D3CA9B3 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -483,7 +382,6 @@ /* Begin XCBuildConfiguration section */ 331C80DB294CF71000263BE5 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 18EDDEF1FB58EC56ABDA1BEB /* Pods-RunnerTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; @@ -498,7 +396,6 @@ }; 331C80DC294CF71000263BE5 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 8F5ECEC7BF9DD35CB3E7196E /* Pods-RunnerTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; @@ -513,7 +410,6 @@ }; 331C80DD294CF71000263BE5 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5099E6191AE87E21D356D9C8 /* Pods-RunnerTests.profile.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; CURRENT_PROJECT_VERSION = 1; diff --git a/macos/Runner.xcworkspace/contents.xcworkspacedata b/macos/Runner.xcworkspace/contents.xcworkspacedata index 21a3cc1..1d526a1 100644 --- a/macos/Runner.xcworkspace/contents.xcworkspacedata +++ b/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -4,7 +4,4 @@ - - diff --git a/pubspec.lock b/pubspec.lock index 9ea2664..d5b2431 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -53,12 +53,12 @@ packages: dependency: transitive description: name: app_links_linux - sha256: "9ccb5802085a1e57bb07b6256fd1d61a78c7ec104944d4965e62938b4fefd9cb" + sha256: "734aa57a2f65d1b35c3643384ccfbe668730157a08479bfa488e10a9da847853" url: "https://pub.dev" source: hosted - version: "1.0.4" + version: "1.0.5" app_links_platform_interface: - dependency: transitive + dependency: "direct dev" description: name: app_links_platform_interface sha256: "7546f09a6e93f4a2df2fe2bd40a5c6c64310ac461b036d82b43033be7a59f809" @@ -77,10 +77,10 @@ packages: dependency: transitive description: name: archive - sha256: de5ac590b8155e4e676088d714bd41ea620449a6adc0f7950c5073874b287ddb + sha256: "2fda90592c0afd219c5e285618a98da835cd10df38372666093d25dfe457a2d0" url: "https://pub.dev" source: hosted - version: "4.6.0" + version: "4.7.1" args: dependency: transitive description: @@ -97,6 +97,62 @@ packages: url: "https://pub.dev" source: hosted version: "2.13.1" + audioplayers: + dependency: "direct main" + description: + name: audioplayers + sha256: "2ba4bb2944baacbdd5372ff8254a8e7feb8c10d7739545e392f5605a8f618745" + url: "https://pub.dev" + source: hosted + version: "6.8.1" + audioplayers_android: + dependency: transitive + description: + name: audioplayers_android + sha256: f5ff5b15620fbab8cb0849e9636c48e2b96c3f0f71723bbbe2ad3c761b205f05 + url: "https://pub.dev" + source: hosted + version: "5.3.0" + audioplayers_darwin: + dependency: transitive + description: + name: audioplayers_darwin + sha256: "1ca553add991384ecf421b9569da850f3ab2472ffb83f6970b0416365abc51be" + url: "https://pub.dev" + source: hosted + version: "6.5.0" + audioplayers_linux: + dependency: transitive + description: + name: audioplayers_linux + sha256: "15178b726b7cdee5364d0463c8d445630c4e0fb7d26612b73c767e7d25de9417" + url: "https://pub.dev" + source: hosted + version: "4.3.0" + audioplayers_platform_interface: + dependency: transitive + description: + name: audioplayers_platform_interface + sha256: "765f6f0e6dca55cb471c9483fc77700564b3484d19198aca4ebb5147c6c85acb" + url: "https://pub.dev" + source: hosted + version: "7.2.0" + audioplayers_web: + dependency: transitive + description: + name: audioplayers_web + sha256: ae1e0103c865a03e273f6d13d97b93f5595eac09915729cd5e37ef96e2857319 + url: "https://pub.dev" + source: hosted + version: "5.3.0" + audioplayers_windows: + dependency: transitive + description: + name: audioplayers_windows + sha256: a70ae82bba2dfcb6eb03dd4815d737a2d46d33ea5a96a03f535cfcaac490e413 + url: "https://pub.dev" + source: hosted + version: "4.4.1" avif_native: dependency: "direct main" description: @@ -105,6 +161,70 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.0" + better_player: + dependency: "direct main" + description: + name: better_player + sha256: f9b928eec81622f33457a5019a02c79d102dffe54b432baa43bb3400d31439e1 + url: "https://pub.dev" + source: hosted + version: "1.38.0" + better_player_android: + dependency: transitive + description: + name: better_player_android + sha256: "2c7df9bfb1e7fa69c86d3bb91a1825bba30292968307724fa51869bc3a0bb75d" + url: "https://pub.dev" + source: hosted + version: "1.13.2" + better_player_ios: + dependency: transitive + description: + name: better_player_ios + sha256: "4b9c08690374aa84b15ba88ab5d6b695cda618fb895b445a6a4186c220599c84" + url: "https://pub.dev" + source: hosted + version: "1.15.0" + better_player_linux: + dependency: transitive + description: + name: better_player_linux + sha256: "97d9eb16a587df4d714c1906ef2c49b825c1483e7d4c9050d63e696e26998f6e" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + better_player_macos: + dependency: transitive + description: + name: better_player_macos + sha256: "90f6fc0e354b034043850661a7c4e39ac34261ff7cc21c2895ea7bded126d15c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + better_player_platform_interface: + dependency: transitive + description: + name: better_player_platform_interface + sha256: e5218199dd12ffe6f43c01d5cdeecad0b53125926f8da8c3f4b90136d8b55ec1 + url: "https://pub.dev" + source: hosted + version: "1.8.0" + better_player_web: + dependency: transitive + description: + name: better_player_web + sha256: d7b365221f7724f22d3fef7840e45af2493a784e2429a30e980f807bcb7c9539 + url: "https://pub.dev" + source: hosted + version: "1.6.1" + better_player_windows: + dependency: transitive + description: + name: better_player_windows + sha256: eddc817dce6af08e74de456ad711ffd987a641c45f73998cbe9ccbf6ab5ebf22 + url: "https://pub.dev" + source: hosted + version: "1.5.1" boolean_selector: dependency: transitive description: @@ -213,18 +333,18 @@ packages: dependency: transitive description: name: cnativeapi - sha256: "3c9e30d513cdc8ecb116f3017308f2480828c766e45aa00083c3d15d621e5d57" + sha256: c43703998995e132b0656d2b8a95ed2bedc6b22ccee2c827bcdc075e0330e319 url: "https://pub.dev" source: hosted - version: "0.5.8" + version: "0.5.10" code_assets: dependency: "direct main" description: name: code_assets - sha256: "828110d598123b5ea96c00c9f3c72105bf79f8ee36c20a39b26209ade421ec57" + sha256: "1ef22a0be3af9370bd9481ac76db114db92bfe75d5ca2b2d7bc911764478a4d9" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.2.0" collection: dependency: "direct main" description: @@ -273,6 +393,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.2" + cupertino_icons: + dependency: transitive + description: + name: cupertino_icons + sha256: b7cc2390aac296c083bea762859413eb1cf5b630c70e0c7e4d831018f762a8b2 + url: "https://pub.dev" + source: hosted + version: "2.0.0" cupertino_ui: dependency: transitive description: @@ -471,22 +599,27 @@ packages: url: "https://pub.dev" source: hosted version: "0.9.1" + flutter_driver: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" flutter_file_dialog: dependency: "direct main" description: name: flutter_file_dialog - sha256: "5d270d69b6a5fdf45bdb88ebcf590e073dd89dfb45526ac83a64524ba57303b5" + sha256: "3765fca2a6babe983730a3105e9d652d852fe463c44bb7713344f11bec40d393" url: "https://pub.dev" source: hosted - version: "3.3.3" + version: "3.3.6" flutter_hooks: dependency: "direct main" description: name: flutter_hooks - sha256: "8ae1f090e5f4ef5cfa6670ce1ab5dddadd33f3533a7f9ba19d9f958aa2a89f42" + sha256: b4f6eb8f13fc92523023a47d4a2e541b17827535334941f9a974f10da0797a7e url: "https://pub.dev" source: hosted - version: "0.21.3+1" + version: "0.21.4" flutter_launcher_icons: dependency: "direct dev" description: @@ -507,42 +640,42 @@ packages: dependency: "direct main" description: name: flutter_local_notifications - sha256: fd5fc8966a8b34337ac182dc394f3506139b69d8138d4e9e174a13d6468adcd4 + sha256: "7d37d69ded3028af4f22531a0097a3baa478a384dff2e23e873707c93df3b704" url: "https://pub.dev" source: hosted - version: "22.3.3" + version: "23.0.3" flutter_local_notifications_linux: dependency: transitive description: name: flutter_local_notifications_linux - sha256: "3b89a4bf095fa5f8a99beeabf982c5bd506c3ad25e7b9e61da945e994dc5b615" + sha256: bcbcf3c15e33b6866805092308f5f6ef27e1191874f6a92ef59213a0812a79a2 url: "https://pub.dev" source: hosted - version: "8.0.2" + version: "9.0.0" flutter_local_notifications_platform_interface: dependency: transitive description: name: flutter_local_notifications_platform_interface - sha256: "43c3761d916c9bd3d5c7ebbc44d82f4990329840c0c5d62ad5260cc1b5d399bd" + sha256: "4a49db4ce3d633ebc85c85b5fa959572600ec10bd097419c454579444308a0a0" url: "https://pub.dev" source: hosted - version: "12.2.0" + version: "13.0.0" flutter_local_notifications_web: dependency: transitive description: name: flutter_local_notifications_web - sha256: "516afaf97a2d1e67a036c6617321b00d205d72f7a67b6eccf936cd565f985878" + sha256: ef117694fbfcd82308ab0e324cfc9282fa50c192e24ec54a58173ae327ebc544 url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "2.0.0" flutter_local_notifications_windows: dependency: transitive description: name: flutter_local_notifications_windows - sha256: "6f43bdd03b171b7a90f22647506fea33e2bb12294b7c7c7a3d690e960a382945" + sha256: "8e80ac29433c71e267493b397457e3a8430c5c1d9c76bb58a6971c016cdba3d7" url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "4.0.1" flutter_localizations: dependency: "direct main" description: flutter @@ -568,20 +701,20 @@ packages: dependency: "direct main" description: name: flutter_riverpod - sha256: "2b7f9d2a3c730ac1a98221b420cef966b990fca7ab546ede324642ca57a533e3" + sha256: "2ae1a93a868ae5f2d5358f521a4bfae0da7a3bfe77a60515ab5c28953b50557f" url: "https://pub.dev" source: hosted - version: "3.4.3" + version: "3.5.0" flutter_svg: dependency: "direct main" description: name: flutter_svg - sha256: "100c19dcc4ff60083e95a44a6f44f3a1bb887d353c5d86f6a9b688aa3cb46236" + sha256: "4565a66f0a968f2e1ab4197854686990258aadab9572eb80a7655053a01dc302" url: "https://pub.dev" source: hosted - version: "2.3.2" + version: "2.5.0" flutter_test: - dependency: transitive + dependency: "direct dev" description: flutter source: sdk version: "0.0.0" @@ -623,70 +756,11 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.0" - geoclue: + fuchsia_remote_debug_protocol: dependency: transitive - description: - name: geoclue - sha256: c2a998c77474fc57aa00c6baa2928e58f4b267649057a1c76738656e9dbd2a7f - url: "https://pub.dev" - source: hosted - version: "0.1.1" - geolocator: - dependency: "direct main" - description: - name: geolocator - sha256: "2b3bc0f7320d5a5fa02f8209ffcf1aaa7c2cabb7b2bedbc0cfeb5ff2778b8b09" - url: "https://pub.dev" - source: hosted - version: "14.1.2" - geolocator_android: - dependency: transitive - description: - name: geolocator_android - sha256: e67583809a1fab5f4a2255902978e2bc095ace9451fde0d9624e54facd0a5c22 - url: "https://pub.dev" - source: hosted - version: "5.2.1" - geolocator_apple: - dependency: transitive - description: - name: geolocator_apple - sha256: a1e177f3081089724f2095856aeb96eb8d7d1c59e425aed8dd4de7aa2c11ab66 - url: "https://pub.dev" - source: hosted - version: "2.4.3" - geolocator_linux: - dependency: transitive - description: - name: geolocator_linux - sha256: "3da7420f11c3496511a5bd3c18fd67b88e5659f12e46b7ce00a788f6996e850a" - url: "https://pub.dev" - source: hosted - version: "0.2.6" - geolocator_platform_interface: - dependency: transitive - description: - name: geolocator_platform_interface - sha256: e012af6b7e2674e7500237ab11e44ac9119e87fd0105e7bb55cde1750e8e5d80 - url: "https://pub.dev" - source: hosted - version: "4.4.1" - geolocator_web: - dependency: transitive - description: - name: geolocator_web - sha256: "19e485a0f8d6a88abcf9c53cba3a4105e14b7435ed8ac1c108c067b938fe8429" - url: "https://pub.dev" - source: hosted - version: "4.1.4" - geolocator_windows: - dependency: transitive - description: - name: geolocator_windows - sha256: "175435404d20278ffd220de83c2ca293b73db95eafbdc8131fe8609be1421eb6" - url: "https://pub.dev" - source: hosted - version: "0.2.5" + description: flutter + source: sdk + version: "0.0.0" glob: dependency: transitive description: @@ -703,14 +777,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.2" - gsettings: - dependency: transitive - description: - name: gsettings - sha256: "1b0ce661f5436d2db1e51f3c4295a49849f03d304003a7ba177d01e3a858249c" - url: "https://pub.dev" - source: hosted - version: "0.2.8" hooks: dependency: "direct main" description: @@ -723,10 +789,10 @@ packages: dependency: "direct main" description: name: hooks_riverpod - sha256: d58e1e14aa112ca9c56d54effb7d0d717b2d3f96dad3cdd1fce16f8740450700 + sha256: bfafc8ca13e33e191fd3c3c2e920eed08918ef669e0b4df253b401fa78f82f47 url: "https://pub.dev" source: hosted - version: "3.4.3" + version: "3.5.0" html: dependency: "direct main" description: @@ -771,10 +837,10 @@ packages: dependency: transitive description: name: image - sha256: "89ed75b2f8231fe676808c5564f9590d728024ded7ac782a7ed8474f1c95b72a" + sha256: bc13f61f0f5cb77936e78ae5dae3800f442718dac5d2bc4654f03c239230ed0c url: "https://pub.dev" source: hosted - version: "4.12.0" + version: "4.13.1" image_picker: dependency: "direct main" description: @@ -803,10 +869,10 @@ packages: dependency: transitive description: name: image_picker_ios - sha256: b8f508306db2bf71141aba2de4ec13456338bf01e13f034bd2594f341a5f8eb2 + sha256: a4aeafbe049ad99882059f186862de6fd5296c708c5805277f6f684165268af1 url: "https://pub.dev" source: hosted - version: "0.8.13+14" + version: "0.8.13+16" image_picker_linux: dependency: transitive description: @@ -839,6 +905,11 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.2" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" intl: dependency: "direct main" description: @@ -859,10 +930,18 @@ packages: dependency: transitive description: name: jni - sha256: d8df6dab6847855512fe44dd9032b0bbe34dda7bf7597e41d30750879779813f + sha256: "19764f78f6b9e0d40f6395b04649d1046eb57f5ccf05afce50cc63e5a82777b0" url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.2.1" + jni_flutter: + dependency: transitive + description: + name: jni_flutter + sha256: "586594ad345b403bda8a794b0b8a9e34298238b86c2a7d7f15160b092fe9ef3d" + url: "https://pub.dev" + source: hosted + version: "1.1.0" jni_util: dependency: transitive description: @@ -944,6 +1023,31 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" + location: + dependency: "direct main" + description: + path: "packages/location" + ref: "feat/optional-play-services" + resolved-ref: "1a2602a9f7b07906a1191730d5435f4b695547d3" + url: "https://github.com/Henry-Hiles/flutterlocation" + source: git + version: "10.2.0" + location_platform_interface: + dependency: transitive + description: + name: location_platform_interface + sha256: a47b6d790eeb7308147293aedec0efb3b62d9f1b10899679be04f91cff664821 + url: "https://pub.dev" + source: hosted + version: "7.1.0" + location_web: + dependency: transitive + description: + name: location_web + sha256: da3812c65ca683c6180790838f551de10122a4887ffbd569360c9cb2d85859b7 + url: "https://pub.dev" + source: hosted + version: "7.0.1" logging: dependency: transitive description: @@ -1013,10 +1117,10 @@ packages: dependency: "direct main" description: name: material_ui - sha256: feb289df1e5f9ed9522f9fe3d909432a7f7bc76943f16abad09f80a16cd25196 + sha256: a6b19012df437a356cbc01f8ea22a105e07194c47c9a6009da0032a0ce35c4ab url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.11.1" measure_size: dependency: "direct main" description: @@ -1025,70 +1129,6 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.2" - media_kit: - dependency: "direct main" - description: - name: media_kit - sha256: ae9e79597500c7ad6083a3c7b7b7544ddabfceacce7ae5c9709b0ec16a5d6643 - url: "https://pub.dev" - source: hosted - version: "1.2.6" - media_kit_libs_android_video: - dependency: transitive - description: - name: media_kit_libs_android_video - sha256: "3f6274e5ab2de512c286a25c327288601ee445ed8ac319e0ef0b66148bd8f76c" - url: "https://pub.dev" - source: hosted - version: "1.3.8" - media_kit_libs_ios_video: - dependency: transitive - description: - name: media_kit_libs_ios_video - sha256: b5382994eb37a4564c368386c154ad70ba0cc78dacdd3fb0cd9f30db6d837991 - url: "https://pub.dev" - source: hosted - version: "1.1.4" - media_kit_libs_linux: - dependency: transitive - description: - name: media_kit_libs_linux - sha256: "2b473399a49ec94452c4d4ae51cfc0f6585074398d74216092bf3d54aac37ecf" - url: "https://pub.dev" - source: hosted - version: "1.2.1" - media_kit_libs_macos_video: - dependency: transitive - description: - name: media_kit_libs_macos_video - sha256: f26aa1452b665df288e360393758f84b911f70ffb3878032e1aabba23aa1032d - url: "https://pub.dev" - source: hosted - version: "1.1.4" - media_kit_libs_video: - dependency: "direct main" - description: - name: media_kit_libs_video - sha256: "2b235b5dac79c6020e01eef5022c6cc85fedc0df1738aadc6ea489daa12a92a9" - url: "https://pub.dev" - source: hosted - version: "1.0.7" - media_kit_libs_windows_video: - dependency: transitive - description: - name: media_kit_libs_windows_video - sha256: dff76da2778729ab650229e6b4ec6ec111eb5151431002cbd7ea304ff1f112ab - url: "https://pub.dev" - source: hosted - version: "1.0.11" - media_kit_video: - dependency: "direct main" - description: - name: media_kit_video - sha256: afaa509e7b7e0bf247557a3a740cde903a52c34ace9810f94500e127bd7b043d - url: "https://pub.dev" - source: hosted - version: "2.0.1" meta: dependency: transitive description: @@ -1133,10 +1173,10 @@ packages: dependency: transitive description: name: native_toolchain_c - sha256: "90eaad8059ebc2004a63810a4696ea9acdb02473e47ed3b6b3bafb100ac77e31" + sha256: "120b6fc66acd8a5ddeaeb1e59b78836bb3ec9919bd9d9dfb1e2401985710c2c0" url: "https://pub.dev" source: hosted - version: "0.19.5" + version: "0.19.6" native_toolchain_cmake: dependency: "direct overridden" description: @@ -1150,18 +1190,18 @@ packages: dependency: transitive description: name: nativeapi - sha256: "87b0912bde3c9b7e0649c5e12047baf2bf179d3844a9b984313e897872120267" + sha256: "118045bb549cb6fabad472a3a22a537e7310bbf20097350f5027808b4a5853ce" url: "https://pub.dev" source: hosted - version: "0.5.8" + version: "0.5.10" nativeapi_flutter: dependency: transitive description: name: nativeapi_flutter - sha256: b62a42b8a86538119ba67b8eab8328eb89d69ac4a2142d623d08ac163faa9cd8 + sha256: "357a405c69212f5157da1bd3be183a53c2b841d0de0eb51f4a3947913712aec4" url: "https://pub.dev" source: hosted - version: "0.5.8" + version: "0.5.10" navigation_rail_m3e: dependency: "direct main" description: @@ -1175,10 +1215,10 @@ packages: dependency: transitive description: name: objective_c - sha256: "5c80c2ad6e2c0397de5db38c6d653e69616a3397e13aa7633bf39eb668f2041b" + sha256: c965d264fd4b0b4dd402dce9d049b70656bf98d3ca108b9bc55d2544ceadbe5e url: "https://pub.dev" source: hosted - version: "9.6.2" + version: "9.6.4" package_config: dependency: transitive description: @@ -1206,11 +1246,12 @@ packages: pasteboard: dependency: "direct main" description: - name: pasteboard - sha256: e0535da36124e6f2ca9d17424102ce5de34e72acc39f05a1d942b974b48e5eea - url: "https://pub.dev" - source: hosted - version: "0.6.0" + path: "packages/pasteboard" + ref: HEAD + resolved-ref: e79a0ecc741b80575f38465c02eba9c553e12479 + url: "https://github.com/Henry-Hiles/flutter-plugins" + source: git + version: "0.6.1" path: dependency: "direct main" description: @@ -1239,10 +1280,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: "149441ca6e4f38193b2e004c0ca6376a3d11f51fa5a77552d8bd4d2b0c0912ba" + sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd" url: "https://pub.dev" source: hosted - version: "2.2.23" + version: "2.3.1" path_provider_foundation: dependency: transitive description: @@ -1367,34 +1408,26 @@ packages: dependency: transitive description: name: riverpod - sha256: "484dfc873ea4c4f4240e5635444fa066f87b07862b7279ebd004a2b71fba4b7a" + sha256: "24cbce92e87088cae0dd06caac3876c0b3abfd084901e7a93a3254d6daf4937d" url: "https://pub.dev" source: hosted - version: "3.4.3" + version: "3.5.0" riverpod_analyzer_utils: dependency: transitive description: name: riverpod_analyzer_utils - sha256: bb13cb3985815840cc103eda1027158358c5fdc00f308fc6f76574d0594107af + sha256: a9ac757dd927b8b52ee4d3c5f8b7ecba523e140a8df916a88d5d54fef5bff72f url: "https://pub.dev" source: hosted - version: "1.0.0-dev.12" + version: "1.0.0" riverpod_lint: dependency: "direct dev" description: name: riverpod_lint - sha256: "215cb3cd54a97e09bc3512535fa4e8bedd3bf2a06dc2ae015ac8e0050fc71bd1" + sha256: "948ad74ce14bac286be014483891fb65a5584a353b0f77dd7d493a8f7880cd41" url: "https://pub.dev" source: hosted - version: "3.1.9" - safe_local_storage: - dependency: transitive - description: - name: safe_local_storage - sha256: "76288b689a3e1fddccb377177feed85d73fdfc64c9c3c52991e2d9aba35c4857" - url: "https://pub.dev" - source: hosted - version: "2.0.7" + version: "3.2.0" shared_preferences: dependency: "direct main" description: @@ -1407,18 +1440,18 @@ packages: dependency: transitive description: name: shared_preferences_android - sha256: "33b38b07d9ac7d16aff0426c61418752fd3e7a8c7dc8be786c875d6ce673b002" + sha256: "137dedccacb394b8f470d6c9b435ffc3d33faaa6ce2949c4f54a61007d64396d" url: "https://pub.dev" source: hosted - version: "2.5.4" + version: "2.5.5" shared_preferences_foundation: dependency: transitive description: name: shared_preferences_foundation - sha256: "4e396ac6f8751ab7d2d6e27f22f32c8350b07006028d534f5221503382f1fa69" + sha256: "89435cb71ecb1ad1bf29ef73a381f871a06f433d4182b7e2ba7243b02b2c544b" url: "https://pub.dev" source: hosted - version: "2.6.1" + version: "2.6.2" shared_preferences_linux: dependency: transitive description: @@ -1428,7 +1461,7 @@ packages: source: hosted version: "2.4.1" shared_preferences_platform_interface: - dependency: transitive + dependency: "direct dev" description: name: shared_preferences_platform_interface sha256: "649dc798a33931919ea356c4305c2d1f81619ea6e92244070b520187b5140ef9" @@ -1552,14 +1585,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.1" + sync_http: + dependency: transitive + description: + name: sync_http + sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" + url: "https://pub.dev" + source: hosted + version: "0.3.1" synchronized: dependency: transitive description: name: synchronized - sha256: b3d516dbd3757ff2a458735e4f6cbac9ff261f576f6e87bcb17feabb39e657c5 + sha256: a77637ebe1460f3b48cac89a790d2eb634f0a8593cab0d3f340c6db174ba9b94 url: "https://pub.dev" source: hosted - version: "3.5.0" + version: "3.6.1+1" term_glyph: dependency: transitive description: @@ -1658,22 +1699,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" - universal_platform: - dependency: transitive - description: - name: universal_platform - sha256: "64e16458a0ea9b99260ceb5467a214c1f298d647c659af1bff6d3bf82536b1ec" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - uri_parser: - dependency: transitive - description: - name: uri_parser - sha256: "051c62e5f693de98ca9f130ee707f8916e2266945565926be3ff20659f7853ce" - url: "https://pub.dev" - source: hosted - version: "3.0.2" url_launcher: dependency: "direct main" description: @@ -1686,10 +1711,10 @@ packages: dependency: transitive description: name: url_launcher_android - sha256: "611e87fb320b70d1dd721dc46af89c98aceccea9b31fde49e084591414e0c610" + sha256: b8073b1e5173d63afe1a18985a75896d72f759d3bc1817eb1ae8d26e8527cceb url: "https://pub.dev" source: hosted - version: "6.3.33" + version: "6.3.35" url_launcher_ios: dependency: transitive description: @@ -1715,7 +1740,7 @@ packages: source: hosted version: "3.2.6" url_launcher_platform_interface: - dependency: transitive + dependency: "direct dev" description: name: url_launcher_platform_interface sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" @@ -1750,18 +1775,18 @@ packages: dependency: transitive description: name: vector_graphics - sha256: "82885f6ac633044e7a4e4d8d745724a67aa0dc50af5d8a81ec29379f63c29035" + sha256: "06081e4f2d8f17c306aa58989520694b463ad411bc7c7b93e76afa3e41ca17ac" url: "https://pub.dev" source: hosted - version: "1.2.6" + version: "1.3.1" vector_graphics_codec: dependency: transitive description: name: vector_graphics_codec - sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146" + sha256: "023f3afd1b08d040406e7ccc324f5173c04762a59e374f29d04cef00a4940742" url: "https://pub.dev" source: hosted - version: "1.1.13" + version: "1.2.0" vector_graphics_compiler: dependency: transitive description: @@ -1778,6 +1803,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.4" + visibility_detector: + dependency: transitive + description: + name: visibility_detector + sha256: dd5cc11e13494f432d15939c3aa8ae76844c42b723398643ce9addb88a5ed420 + url: "https://pub.dev" + source: hosted + version: "0.4.0+2" vm_service: dependency: transitive description: @@ -1837,12 +1870,19 @@ packages: webcrypto: dependency: "direct overridden" description: - path: "." - ref: "fix/apple-x86_64-fiat-asm-upstream" - resolved-ref: e50fcce3d0c30627b11ffc74eb964b1073d42620 - url: "https://github.com/DavidClaudeAI/webcrypto.dart" - source: git - version: "0.6.2-wip" + name: webcrypto + sha256: bdfa2b11696f2bac02834649d9e07d24a5154e527feec21ed1bdf81b31f982df + url: "https://pub.dev" + source: hosted + version: "0.6.2" + webdriver: + dependency: transitive + description: + name: webdriver + sha256: "28b82ec894fed45dd71c23ba62d1af973ed97dd59a4f5790a4d38b0b13e5657e" + url: "https://pub.dev" + source: hosted + version: "3.2.0" webpush_encryption: dependency: transitive description: @@ -1917,5 +1957,5 @@ packages: source: hosted version: "2.2.4" sdks: - dart: ">=3.13.3 <4.0.0" - flutter: ">=3.47.0" + dart: "3.13.3" + flutter: "3.47.4" diff --git a/pubspec.yaml b/pubspec.yaml index a1dbdf5..dd21cb7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: nexus description: "A simple and user-friendly Matrix client" -version: 1.1.0-alpha1 +version: 1.1.3+101030999 publish_to: none flutter: @@ -16,15 +16,13 @@ flutter: uses-material-design: true environment: - sdk: ^3.13.3 + sdk: 3.13.3 + flutter: 3.47.4 dependency_overrides: dynamic_color: 2.1.0 - code_assets: 2.1.0 # webcrypto requires ^1.0.0, but works with 2.x - webcrypto: - git: - url: https://github.com/DavidClaudeAI/webcrypto.dart - ref: fix/apple-x86_64-fiat-asm-upstream # Uses build hooks and fixes macOS x86_64 + code_assets: 2.2.0 # webcrypto requires ^1.0.0, but works with 2.x + webcrypto: 0.6.2 native_toolchain_cmake: git: url: https://github.com/rainyl/native_toolchain_cmake # Fixes native aarch64 linux builds, unreleased @@ -46,6 +44,10 @@ dependency_overrides: url: https://codeberg.org/Henry-Hiles/flutter-connector ref: quad/nexus path: unifiedpush_platform_interface + pasteboard: + git: + url: https://github.com/Henry-Hiles/flutter-plugins # FileTransfer portal support on Linux, unreleased + path: packages/pasteboard linkify: git: url: https://github.com/appelladev/linkify @@ -56,8 +58,8 @@ dependencies: sdk: flutter flutter_localizations: sdk: flutter - flutter_riverpod: 3.4.3 - hooks_riverpod: 3.4.3 + flutter_riverpod: 3.5.0 + hooks_riverpod: 3.5.0 intl: 0.20.3 fast_immutable_collections: 11.2.1 path_provider: 2.1.6 @@ -70,16 +72,16 @@ dependencies: window_manager: 0.6.0 color_hash: 1.0.1 flutter_widget_from_html_core: 0.18.0-beta.1 - flutter_svg: 2.3.2 + flutter_svg: 2.5.0 json_annotation: 4.12.0 shared_preferences: 2.5.6 fluttertagger: git: url: https://github.com/Henry-Hiles/fluttertagger # Fixes the last tag search being dropped from formattedText - flutter_hooks: 0.21.3+1 + flutter_hooks: 0.21.4 ffi: 2.2.0 hooks: 2.2.0 - code_assets: 2.1.0 + code_assets: 2.2.0 ffigen: 23.0.0 timeago: 3.7.1 http: 1.6.0 @@ -87,9 +89,6 @@ dependencies: html: 0.15.7 flutter_blurhash: 0.9.1 super_sliver_list: 0.4.1 - media_kit: 1.2.6 - media_kit_video: 2.0.1 - media_kit_libs_video: 1.0.7 measure_size: 5.0.2 m3e_buttons: 1.0.4 m3e_design: 0.2.1 @@ -102,11 +101,11 @@ dependencies: package_info_plus: 10.2.2 app_links: 7.2.2 file_selector: 1.1.0 - material_ui: 1.9.0 + material_ui: 1.11.1 multi_state_switch: 1.1.0 unifiedpush: 6.2.0 unifiedpush_storage_shared_preferences: 1.0.0 - flutter_local_notifications: 22.3.3 + flutter_local_notifications: 23.0.3 timezone: 0.11.2 material_emoji_picker: 2.0.1+1 material_adaptive_sheets: 1.0.0 @@ -115,17 +114,30 @@ dependencies: url: https://github.com/Henry-Hiles/xdg_desktop_portal.dart ref: quad/nexus pasteboard: 0.6.0 - flutter_file_dialog: 3.3.3 + flutter_file_dialog: 3.3.6 mime: 2.1.0 avif_native: 0.2.0 flutter_map: 8.3.2 latlong2: 0.10.1 - geolocator: 14.1.2 + location: + git: + url: https://github.com/Henry-Hiles/flutterlocation # Adds an option to leave out proprietary Google Play services, unreleased + ref: feat/optional-play-services + path: packages/location + better_player: 1.38.0 + audioplayers: 6.8.1 dev_dependencies: + flutter_test: + sdk: flutter + integration_test: + sdk: flutter + app_links_platform_interface: 2.0.4 + url_launcher_platform_interface: 2.3.2 + shared_preferences_platform_interface: 2.4.2 build_runner: 2.17.1 flutter_lints: 6.0.0 freezed: 4.0.3 - riverpod_lint: 3.1.9 + riverpod_lint: 3.2.0 flutter_launcher_icons: 0.14.4 json_serializable: 6.15.2 diff --git a/scripts/build_avif_native.sh b/scripts/build_avif_native.sh new file mode 100644 index 0000000..e94f87c --- /dev/null +++ b/scripts/build_avif_native.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euo pipefail + +cd "${PUB_CACHE:-$HOME/.pub-cache}"/hosted/pub.dev/avif_native-* + +bash tool/native/build_unix.sh android-arm64 decode-dav1d + +library=dist/android-arm64/decode-dav1d/libavif_native.so +jq --arg path "../$library" --arg hash "$(sha256sum "$library" | cut -d " " -f 1)" \ + '.artifacts["android-arm64-decode-dav1d"] |= {path: $path, librarySha256: $hash, fileName}' \ + native/manifest.json > manifest.json +mv manifest.json native/manifest.json diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..01e2683 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +version=${1:?usage: $0 , e.g. 1.2.0 or 1.2.0-beta1} +[[ $version =~ ^([0-9]+)\.([0-9]{1,2})\.([0-9]{1,2})(-[a-z]+([0-9]{1,3}))?$ ]] || + { echo "invalid version: $version" >&2; exit 1; } +prerelease=${BASH_REMATCH[5]:-} + +code=$((10#${BASH_REMATCH[1]} * 100000000 + 10#${BASH_REMATCH[2]} * 1000000 + 10#${BASH_REMATCH[3]} * 10000 + 10#${prerelease:-999})) + +cd "$(dirname "$0")/.." +git diff --quiet HEAD || { echo "commit or stash your changes first" >&2; exit 1; } +! git rev-parse -q --verify "refs/tags/v$version" > /dev/null || { echo "v$version already exists" >&2; exit 1; } + +sed -i "s/^version: .*/version: $version+$code/" pubspec.yaml +sed -i "s/^AppVersion=.*/AppVersion=$version/" windows/installer.iss +if [[ $prerelease ]]; then + release="" +else + release="" + sed -i "s|refs/tags/v[^\"]*\"|refs/tags/v$version\"|" README.md +fi +sed -i "s|^\( *\)|&\n\1 $release|" linux/nexus.federated.nexus.metainfo.xml + +git commit -qam "prepare v$version" +git tag "v$version" +echo "Tagged v$version ($code). Push with: git push origin HEAD v$version" diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8df32b4..b63c950 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,27 +7,27 @@ #include "generated_plugin_registrant.h" #include +#include +#include #include #include -#include -#include -#include +#include #include #include void RegisterPlugins(flutter::PluginRegistry* registry) { AppLinksPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("AppLinksPluginCApi")); + AudioplayersWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); + BetterPlayerWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("BetterPlayerWindowsPlugin")); DynamicColorPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("DynamicColorPluginCApi")); FileSelectorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorWindows")); - GeolocatorWindowsRegisterWithRegistrar( - registry->GetRegistrarForPlugin("GeolocatorWindows")); - MediaKitLibsWindowsVideoPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("MediaKitLibsWindowsVideoPluginCApi")); - MediaKitVideoPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("MediaKitVideoPluginCApi")); + LocationPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("LocationPlugin")); PasteboardPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PasteboardPlugin")); UrlLauncherWindowsRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 3435f5e..b6e3eef 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,11 +4,11 @@ list(APPEND FLUTTER_PLUGIN_LIST app_links + audioplayers_windows + better_player_windows dynamic_color file_selector_windows - geolocator_windows - media_kit_libs_windows_video - media_kit_video + location pasteboard url_launcher_windows ) diff --git a/windows/installer.iss b/windows/installer.iss index 65f1ce5..e1a08c0 100644 --- a/windows/installer.iss +++ b/windows/installer.iss @@ -1,6 +1,6 @@ [Setup] AppName=Nexus -AppVersion=1.0.0 +AppVersion=1.1.3 DefaultDirName={pf}\Nexus DefaultGroupName=Nexus OutputDir=dist