Compare commits

..

No commits in common. "stable" and "v6.3.0-beta.7" have entirely different histories.

528 changed files with 15295 additions and 26704 deletions

View file

@ -1,47 +0,0 @@
name: "Prebuilt steps for build"
description: "Reusable steps for multiple jobs"
inputs:
java_ver:
required: true
description: "Java version to install"
ghc_ver:
required: true
description: "GHC version to install"
github_ref:
required: true
description: "Git reference"
os:
required: true
description: "Target OS"
cache_path:
required: false
default: "~/.cabal/store"
description: "Cache path"
cabal_ver:
required: false
default: 3.10.1.0
description: "GHC version to install"
runs:
using: "composite"
steps:
- name: Setup Haskell
uses: simplex-chat/setup-haskell-action@v2
with:
ghc-version: ${{ inputs.ghc_ver }}
cabal-version: ${{ inputs.cabal_ver }}
- name: Setup Java
if: startsWith(inputs.github_ref, 'refs/tags/v')
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: ${{ inputs.java_ver }}
cache: 'gradle'
- name: Restore cached build
uses: actions/cache@v4
with:
path: |
${{ inputs.cache_path }}
dist-newstyle
key: ${{ inputs.os }}-ghc${{ inputs.ghc_ver }}-${{ hashFiles('cabal.project', 'simplex-chat.cabal') }}

View file

@ -1,39 +0,0 @@
name: "Upload binary and update hash"
description: "Reusable steps for multiple jobs"
inputs:
bin_path:
required: true
description: "Path to binary to upload"
bin_name:
required: true
description: "Name of uploaded binary"
bin_hash:
required: true
description: "Message with SHA to include in release"
github_ref:
required: true
description: "Github reference"
github_token:
required: true
description: "Github token"
runs:
using: "composite"
steps:
- name: Upload file with specific name
if: startsWith(inputs.github_ref, 'refs/tags/v')
uses: simplex-chat/upload-release-action@v2
with:
repo_token: ${{ inputs.github_token }}
file: ${{ inputs.bin_path }}
asset_name: ${{ inputs.bin_name }}
tag: ${{ inputs.github_ref }}
- name: Add hash to release notes
if: startsWith(inputs.github_ref, 'refs/tags/v')
uses: simplex-chat/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
with:
append_body: true
body: |
${{ inputs.bin_hash }}

View file

@ -1,44 +0,0 @@
name: 'Set Swap Space'
description: 'Add moar swap'
branding:
icon: 'crop'
color: 'orange'
inputs:
swap-size-gb:
description: 'Swap space to create, in Gigabytes.'
required: false
default: '10'
runs:
using: "composite"
steps:
- name: Swap space report before modification
shell: bash
run: |
echo "Memory and swap:"
free -h
echo
swapon --show
echo
- name: Set Swap
shell: bash
run: |
export SWAP_FILE=$(swapon --show=NAME | tail -n 1)
echo "Swap file: $SWAP_FILE"
if [ -z "$SWAP_FILE" ]; then
SWAP_FILE=/opt/swapfile
else
sudo swapoff $SWAP_FILE
sudo rm $SWAP_FILE
fi
sudo fallocate -l ${{ inputs.swap-size-gb }}G $SWAP_FILE
sudo chmod 600 $SWAP_FILE
sudo mkswap $SWAP_FILE
sudo swapon $SWAP_FILE
- name: Swap space report after modification
shell: bash
run: |
echo "Memory and swap:"
free -h
echo
swapon --show
echo

View file

@ -22,58 +22,17 @@ on:
- "README.md" - "README.md"
- "PRIVACY.md" - "PRIVACY.md"
# This workflow uses custom actions (prepare-build and prepare-release) defined in:
#
# .github/actions/
# ├── prepare-build
# │ └── action.yml
# └── prepare-release
# └── action.yml
# Important!
# Do not use always(), it makes build unskippable.
# See: https://github.com/actions/runner/issues/1846#issuecomment-1246102753
jobs: jobs:
prepare-release:
# ============================= if: startsWith(github.ref, 'refs/tags/v')
# Global variables
# =============================
# That is the only and less hacky way to setup global variables
# to use in strategy matrix (env:/YAML anchors doesn't work).
# See: https://github.com/orgs/community/discussions/56787#discussioncomment-6041789
# https://github.com/actions/runner/issues/1182
# https://stackoverflow.com/a/77549656
variables:
runs-on: ubuntu-latest
outputs:
GHC_VER: 9.6.3
JAVA_VER: 17
steps:
- name: Dummy job when we have just simple variables
if: false
run: echo
# =============================
# Create release
# =============================
# Create release, but only if it's triggered by tag push.
# On pull requests/commits push, this job will always complete.
maybe-release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Clone project - name: Clone project
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Build changelog - name: Build changelog
id: build_changelog id: build_changelog
if: startsWith(github.ref, 'refs/tags/v') uses: mikepenz/release-changelog-builder-action@v4
uses: simplex-chat/release-changelog-builder-action@v5
with: with:
configuration: .github/changelog_conf.json configuration: .github/changelog_conf.json
failOnError: true failOnError: true
@ -83,8 +42,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release - name: Create release
if: startsWith(github.ref, 'refs/tags/v') uses: softprops/action-gh-release@v1
uses: simplex-chat/action-gh-release@v2
with: with:
body: ${{ steps.build_changelog.outputs.changelog }} body: ${{ steps.build_changelog.outputs.changelog }}
prerelease: true prerelease: true
@ -94,295 +52,183 @@ jobs:
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ========================= build:
# Linux Build name: build-${{ matrix.os }}-${{ matrix.ghc }}
# ========================= if: always()
needs: prepare-release
build-linux: runs-on: ${{ matrix.os }}
name: "ubuntu-${{ matrix.os }} (CLI,Desktop), GHC: ${{ matrix.ghc }}"
needs: [maybe-release, variables]
runs-on: ubuntu-${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- os: 22.04 - os: ubuntu-20.04
ghc: "8.10.7" ghc: "8.10.7"
should_run: ${{ !(github.ref == 'refs/heads/stable' || startsWith(github.ref, 'refs/tags/v')) }} cache_path: ~/.cabal/store
- os: 22.04 - os: ubuntu-20.04
ghc: ${{ needs.variables.outputs.GHC_VER }} ghc: "9.6.3"
cli_asset_name: simplex-chat-ubuntu-22_04-x86-64 cache_path: ~/.cabal/store
asset_name: simplex-chat-ubuntu-20_04-x86-64
desktop_asset_name: simplex-desktop-ubuntu-20_04-x86_64.deb
- os: ubuntu-22.04
ghc: "9.6.3"
cache_path: ~/.cabal/store
asset_name: simplex-chat-ubuntu-22_04-x86-64
desktop_asset_name: simplex-desktop-ubuntu-22_04-x86_64.deb desktop_asset_name: simplex-desktop-ubuntu-22_04-x86_64.deb
should_run: true - os: macos-latest
- os: 24.04 ghc: "9.6.3"
ghc: ${{ needs.variables.outputs.GHC_VER }} cache_path: ~/.cabal/store
cli_asset_name: simplex-chat-ubuntu-24_04-x86-64 asset_name: simplex-chat-macos-aarch64
desktop_asset_name: simplex-desktop-ubuntu-24_04-x86_64.deb desktop_asset_name: simplex-desktop-macos-aarch64.dmg
should_run: true - os: macos-13
ghc: "9.6.3"
cache_path: ~/.cabal/store
asset_name: simplex-chat-macos-x86-64
desktop_asset_name: simplex-desktop-macos-x86_64.dmg
- os: windows-latest
ghc: "9.6.3"
cache_path: C:/cabal
asset_name: simplex-chat-windows-x86-64
desktop_asset_name: simplex-desktop-windows-x86_64.msi
steps: steps:
- name: Checkout Code - name: Skip unreliable ghc 8.10.7 build on stable branch
if: matrix.should_run == true if: matrix.ghc == '8.10.7' && github.ref == 'refs/heads/stable'
run: exit 0
- name: Configure pagefile (Windows)
if: matrix.os == 'windows-latest'
uses: al-cheb/configure-pagefile-action@v1.3
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "C:"
- name: Clone project
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Setup swap - name: Setup Haskell
if: matrix.ghc == '8.10.7' && matrix.should_run == true uses: haskell-actions/setup@v2
uses: ./.github/actions/swap
with: with:
swap-size-gb: 30 ghc-version: ${{ matrix.ghc }}
cabal-version: "3.10.1.0"
# Otherwise we run out of disk space with Docker build
- name: Free disk space
if: matrix.should_run == true
shell: bash
run: ./scripts/ci/linux_util_free_space.sh
- name: Restore cached build - name: Restore cached build
if: matrix.should_run == true id: restore_cache
uses: actions/cache@v4 uses: actions/cache/restore@v3
with: with:
path: | path: |
~/.cabal/store ${{ matrix.cache_path }}
dist-newstyle dist-newstyle
key: ubuntu-${{ matrix.os }}-ghc${{ matrix.ghc }}-${{ hashFiles('cabal.project', 'simplex-chat.cabal') }} key: ${{ matrix.os }}-ghc${{ matrix.ghc }}-${{ hashFiles('cabal.project', 'simplex-chat.cabal') }}
- name: Set up Docker Buildx # / Unix
if: matrix.should_run == true
uses: simplex-chat/docker-setup-buildx-action@v3
- name: Build and cache Docker image - name: Unix prepare cabal.project.local for Mac
if: matrix.should_run == true if: matrix.os == 'macos-latest'
uses: simplex-chat/docker-build-push-action@v6
with:
context: .
load: true
file: Dockerfile.build
tags: build/${{ matrix.os }}:latest
build-args: |
TAG=${{ matrix.os }}
GHC=${{ matrix.ghc }}
# Docker needs these flags for AppImage build:
# --device /dev/fuse
# --cap-add SYS_ADMIN
# --security-opt apparmor:unconfined
- name: Start container
if: matrix.should_run == true
shell: bash shell: bash
run: | run: |
docker run -t -d \ echo "ignore-project: False" >> cabal.project.local
--device /dev/fuse \ echo "package simplexmq" >> cabal.project.local
--cap-add SYS_ADMIN \ echo " extra-include-dirs: /opt/homebrew/opt/openssl@3.0/include" >> cabal.project.local
--security-opt apparmor:unconfined \ echo " extra-lib-dirs: /opt/homebrew/opt/openssl@3.0/lib" >> cabal.project.local
--name builder \ echo "" >> cabal.project.local
-v ~/.cabal:/root/.cabal \ echo "package direct-sqlcipher" >> cabal.project.local
-v /home/runner/work/_temp:/home/runner/work/_temp \ echo " extra-include-dirs: /opt/homebrew/opt/openssl@3.0/include" >> cabal.project.local
-v ${{ github.workspace }}:/project \ echo " extra-lib-dirs: /opt/homebrew/opt/openssl@3.0/lib" >> cabal.project.local
build/${{ matrix.os }}:latest echo " flags: +openssl" >> cabal.project.local
- name: Prepare cabal.project.local - name: Unix prepare cabal.project.local for Mac
if: matrix.should_run == true if: matrix.os == 'macos-13'
shell: bash
run: |
echo "ignore-project: False" >> cabal.project.local
echo "package simplexmq" >> cabal.project.local
echo " extra-include-dirs: /usr/local/opt/openssl@3.0/include" >> cabal.project.local
echo " extra-lib-dirs: /usr/local/opt/openssl@3.0/lib" >> cabal.project.local
echo "" >> cabal.project.local
echo "package direct-sqlcipher" >> cabal.project.local
echo " extra-include-dirs: /usr/local/opt/openssl@3.0/include" >> cabal.project.local
echo " extra-lib-dirs: /usr/local/opt/openssl@3.0/lib" >> cabal.project.local
echo " flags: +openssl" >> cabal.project.local
- name: Install AppImage dependencies
if: startsWith(github.ref, 'refs/tags/v') && matrix.asset_name && matrix.os == 'ubuntu-20.04'
run: sudo apt install -y desktop-file-utils
- name: Install openssl for Mac
if: matrix.os == 'macos-latest' || matrix.os == 'macos-13'
run: brew install openssl@3.0
- name: Unix prepare cabal.project.local for Ubuntu
if: matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04'
shell: bash shell: bash
run: | run: |
echo "ignore-project: False" >> cabal.project.local echo "ignore-project: False" >> cabal.project.local
echo "package direct-sqlcipher" >> cabal.project.local echo "package direct-sqlcipher" >> cabal.project.local
echo " flags: +openssl" >> cabal.project.local echo " flags: +openssl" >> cabal.project.local
# chmod/git commands are used to workaround permission issues when cache is restored - name: Unix build CLI
- name: Build CLI id: unix_cli_build
if: matrix.should_run == true if: matrix.os != 'windows-latest'
shell: docker exec -t builder sh -eu {0}
run: |
chmod -R 777 dist-newstyle ~/.cabal && git config --global --add safe.directory '*'
cabal clean
cabal update
cabal build -j --enable-tests
mkdir -p /out
for i in simplex-chat simplex-chat-test; do
bin=$(find /project/dist-newstyle -name "$i" -type f -executable)
chmod +x "$bin"
mv "$bin" /out/
done
strip /out/simplex-chat
- name: Copy tests from container
if: matrix.should_run == true
shell: bash shell: bash
run: | run: |
docker cp builder:/out/simplex-chat-test . cabal build --enable-tests
path=$(cabal list-bin simplex-chat)
- name: Copy CLI from container and prepare it
id: linux_cli_prepare
if: startsWith(github.ref, 'refs/tags/v') && matrix.should_run == true
shell: bash
run: |
docker cp builder:/out/simplex-chat ./${{ matrix.cli_asset_name }}
path="${{ github.workspace }}/${{ matrix.cli_asset_name }}"
echo "bin_path=$path" >> $GITHUB_OUTPUT echo "bin_path=$path" >> $GITHUB_OUTPUT
echo "bin_hash=$(echo SHA2-256\(${{ matrix.cli_asset_name }}\)= $(openssl sha256 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT echo "bin_hash=$(echo SHA2-512\(${{ matrix.asset_name }}\)= $(openssl sha512 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT
- name: Upload CLI - name: Unix upload CLI binary to release
if: startsWith(github.ref, 'refs/tags/v') && matrix.should_run == true if: startsWith(github.ref, 'refs/tags/v') && matrix.asset_name && matrix.os != 'windows-latest'
uses: ./.github/actions/prepare-release uses: svenstaro/upload-release-action@v2
with: with:
bin_path: ${{ steps.linux_cli_prepare.outputs.bin_path }} repo_token: ${{ secrets.GITHUB_TOKEN }}
bin_name: ${{ matrix.cli_asset_name }} file: ${{ steps.unix_cli_build.outputs.bin_path }}
bin_hash: ${{ steps.linux_cli_prepare.outputs.bin_hash }} asset_name: ${{ matrix.asset_name }}
github_ref: ${{ github.ref }} tag: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Desktop - name: Unix update CLI binary hash
if: startsWith(github.ref, 'refs/tags/v') && matrix.should_run == true if: startsWith(github.ref, 'refs/tags/v') && matrix.asset_name && matrix.os != 'windows-latest'
shell: docker exec -t builder sh -eu {0} uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
append_body: true
body: |
${{ steps.unix_cli_build.outputs.bin_hash }}
- name: Setup Java
if: startsWith(github.ref, 'refs/tags/v') && matrix.asset_name
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
cache: 'gradle'
- name: Linux build desktop
id: linux_desktop_build
if: startsWith(github.ref, 'refs/tags/v') && matrix.asset_name && (matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04')
shell: bash
run: | run: |
scripts/desktop/build-lib-linux.sh scripts/desktop/build-lib-linux.sh
cd apps/multiplatform cd apps/multiplatform
./gradlew packageDeb ./gradlew packageDeb
path=$(echo $PWD/release/main/deb/simplex_*_amd64.deb)
- name: Prepare Desktop
id: linux_desktop_build
if: startsWith(github.ref, 'refs/tags/v') && matrix.should_run == true
shell: bash
run: |
path=$(echo ${{ github.workspace }}/apps/multiplatform/release/main/deb/simplex_*_amd64.deb )
echo "package_path=$path" >> $GITHUB_OUTPUT echo "package_path=$path" >> $GITHUB_OUTPUT
echo "package_hash=$(echo SHA2-256\(${{ matrix.desktop_asset_name }}\)= $(openssl sha256 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT echo "package_hash=$(echo SHA2-512\(${{ matrix.desktop_asset_name }}\)= $(openssl sha512 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT
- name: Upload Desktop - name: Linux make AppImage
uses: ./.github/actions/prepare-release id: linux_appimage_build
if: startsWith(github.ref, 'refs/tags/v') && matrix.should_run == true if: startsWith(github.ref, 'refs/tags/v') && matrix.asset_name && matrix.os == 'ubuntu-20.04'
with: shell: bash
bin_path: ${{ steps.linux_desktop_build.outputs.package_path }}
bin_name: ${{ matrix.desktop_asset_name }}
bin_hash: ${{ steps.linux_desktop_build.outputs.package_hash }}
github_ref: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build AppImage
if: startsWith(github.ref, 'refs/tags/v') && matrix.os == '22.04' && matrix.should_run == true
shell: docker exec -t builder sh -eu {0}
run: | run: |
scripts/desktop/make-appimage-linux.sh scripts/desktop/make-appimage-linux.sh
path=$(echo $PWD/apps/multiplatform/release/main/*imple*.AppImage)
- name: Prepare AppImage
id: linux_appimage_build
if: startsWith(github.ref, 'refs/tags/v') && matrix.os == '22.04' && matrix.should_run == true
shell: bash
run: |
path=$(echo ${{ github.workspace }}/apps/multiplatform/release/main/*imple*.AppImage)
echo "appimage_path=$path" >> $GITHUB_OUTPUT echo "appimage_path=$path" >> $GITHUB_OUTPUT
echo "appimage_hash=$(echo SHA2-256\(simplex-desktop-x86_64.AppImage\)= $(openssl sha256 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT echo "appimage_hash=$(echo SHA2-512\(simplex-desktop-x86_64.AppImage\)= $(openssl sha512 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT
- name: Upload AppImage - name: Mac build desktop
if: startsWith(github.ref, 'refs/tags/v') && matrix.os == '22.04' && matrix.should_run == true
uses: ./.github/actions/prepare-release
with:
bin_path: ${{ steps.linux_appimage_build.outputs.appimage_path }}
bin_name: "simplex-desktop-x86_64.AppImage"
bin_hash: ${{ steps.linux_appimage_build.outputs.appimage_hash }}
github_ref: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Fix permissions for cache
if: matrix.should_run == true
shell: bash
run: |
sudo chmod -R 777 dist-newstyle ~/.cabal
sudo chown -R $(id -u):$(id -g) dist-newstyle ~/.cabal
- name: Run tests
if: matrix.should_run == true
timeout-minutes: 120
shell: bash
run: |
i=1
attempts=1
${{ (github.ref == 'refs/heads/stable' || startsWith(github.ref, 'refs/tags/v')) }} && attempts=3
while [ "$i" -le "$attempts" ]; do
if ./simplex-chat-test; then
break
else
echo "Attempt $i failed, retrying..."
i=$((i + 1))
sleep 1
fi
done
if [ "$i" -gt "$attempts" ]; then
echo "All "$attempts" attempts failed."
exit 1
fi
# =========================
# MacOS Build
# =========================
build-macos:
name: "${{ matrix.os }} (CLI,Desktop), GHC: ${{ matrix.ghc }}"
needs: [maybe-release, variables]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
ghc: ${{ needs.variables.outputs.GHC_VER }}
cli_asset_name: simplex-chat-macos-aarch64
desktop_asset_name: simplex-desktop-macos-aarch64.dmg
openssl_dir: "/opt/homebrew/opt"
- os: macos-13
ghc: ${{ needs.variables.outputs.GHC_VER }}
cli_asset_name: simplex-chat-macos-x86-64
desktop_asset_name: simplex-desktop-macos-x86_64.dmg
openssl_dir: "/usr/local/opt"
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Prepare build
uses: ./.github/actions/prepare-build
with:
java_ver: ${{ needs.variables.outputs.JAVA_VER }}
ghc_ver: ${{ matrix.ghc }}
os: ${{ matrix.os }}
github_ref: ${{ github.ref }}
- name: Install OpenSSL
run: brew install openssl@3.0
- name: Prepare cabal.project.local
shell: bash
run: |
echo "ignore-project: False" >> cabal.project.local
echo "package simplexmq" >> cabal.project.local
echo " extra-include-dirs: ${{ matrix.opnessl_dir }}/openssl@3.0/include" >> cabal.project.local
echo " extra-lib-dirs: ${{ matrix.openssl_dir}}/openssl@3.0/lib" >> cabal.project.local
echo "" >> cabal.project.local
echo "package direct-sqlcipher" >> cabal.project.local
echo " extra-include-dirs: ${{ matrix.openssl_dir }}/openssl@3.0/include" >> cabal.project.local
echo " extra-lib-dirs: ${{ matrix.openssl_dir }}/openssl@3.0/lib" >> cabal.project.local
echo " flags: +openssl" >> cabal.project.local
- name: Build CLI
id: mac_cli_build
shell: bash
run: |
cabal build -j --enable-tests
path=$(cabal list-bin simplex-chat)
echo "bin_path=$path" >> $GITHUB_OUTPUT
echo "bin_hash=$(echo SHA2-256\(${{ matrix.cli_asset_name }}\)= $(openssl sha256 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT
- name: Upload CLI
if: startsWith(github.ref, 'refs/tags/v')
uses: ./.github/actions/prepare-release
with:
bin_path: ${{ steps.mac_cli_build.outputs.bin_path }}
bin_name: ${{ matrix.cli_asset_name }}
bin_hash: ${{ steps.mac_cli_build.outputs.bin_hash }}
github_ref: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Desktop
id: mac_desktop_build id: mac_desktop_build
if: startsWith(github.ref, 'refs/tags/v') if: startsWith(github.ref, 'refs/tags/v') && (matrix.os == 'macos-latest' || matrix.os == 'macos-13')
shell: bash shell: bash
env: env:
APPLE_SIMPLEX_SIGNING_KEYCHAIN: ${{ secrets.APPLE_SIMPLEX_SIGNING_KEYCHAIN }} APPLE_SIMPLEX_SIGNING_KEYCHAIN: ${{ secrets.APPLE_SIMPLEX_SIGNING_KEYCHAIN }}
@ -392,77 +238,88 @@ jobs:
scripts/ci/build-desktop-mac.sh scripts/ci/build-desktop-mac.sh
path=$(echo $PWD/apps/multiplatform/release/main/dmg/SimpleX-*.dmg) path=$(echo $PWD/apps/multiplatform/release/main/dmg/SimpleX-*.dmg)
echo "package_path=$path" >> $GITHUB_OUTPUT echo "package_path=$path" >> $GITHUB_OUTPUT
echo "package_hash=$(echo SHA2-256\(${{ matrix.desktop_asset_name }}\)= $(openssl sha256 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT echo "package_hash=$(echo SHA2-512\(${{ matrix.desktop_asset_name }}\)= $(openssl sha512 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT
- name: Upload Desktop - name: Linux upload desktop package to release
if: startsWith(github.ref, 'refs/tags/v') if: startsWith(github.ref, 'refs/tags/v') && matrix.asset_name && (matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04')
uses: ./.github/actions/prepare-release uses: svenstaro/upload-release-action@v2
with: with:
bin_path: ${{ steps.mac_desktop_build.outputs.package_path }} repo_token: ${{ secrets.GITHUB_TOKEN }}
bin_name: ${{ matrix.desktop_asset_name }} file: ${{ steps.linux_desktop_build.outputs.package_path }}
bin_hash: ${{ steps.mac_desktop_build.outputs.package_hash }} asset_name: ${{ matrix.desktop_asset_name }}
github_ref: ${{ github.ref }} tag: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests - name: Linux update desktop package hash
timeout-minutes: 120 if: startsWith(github.ref, 'refs/tags/v') && matrix.asset_name && (matrix.os == 'ubuntu-20.04' || matrix.os == 'ubuntu-22.04')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
append_body: true
body: |
${{ steps.linux_desktop_build.outputs.package_hash }}
- name: Linux upload AppImage to release
if: startsWith(github.ref, 'refs/tags/v') && matrix.asset_name && matrix.os == 'ubuntu-20.04'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.linux_appimage_build.outputs.appimage_path }}
asset_name: simplex-desktop-x86_64.AppImage
tag: ${{ github.ref }}
- name: Linux update AppImage hash
if: startsWith(github.ref, 'refs/tags/v') && matrix.asset_name && matrix.os == 'ubuntu-20.04'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
append_body: true
body: |
${{ steps.linux_appimage_build.outputs.appimage_hash }}
- name: Mac upload desktop package to release
if: startsWith(github.ref, 'refs/tags/v') && (matrix.os == 'macos-latest' || matrix.os == 'macos-13')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ steps.mac_desktop_build.outputs.package_path }}
asset_name: ${{ matrix.desktop_asset_name }}
tag: ${{ github.ref }}
- name: Mac update desktop package hash
if: startsWith(github.ref, 'refs/tags/v') && (matrix.os == 'macos-latest' || matrix.os == 'macos-13')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
append_body: true
body: |
${{ steps.mac_desktop_build.outputs.package_hash }}
- name: Cache unix build
uses: actions/cache/save@v3
if: matrix.os != 'windows-latest'
with:
path: |
${{ matrix.cache_path }}
dist-newstyle
key: ${{ steps.restore_cache.outputs.cache-primary-key }}
- name: Unix test
if: matrix.os != 'windows-latest'
timeout-minutes: 40
shell: bash shell: bash
run: | run: cabal test --test-show-details=direct
i=1
attempts=1
${{ (github.ref == 'refs/heads/stable' || startsWith(github.ref, 'refs/tags/v')) }} && attempts=3
while [ "$i" -le "$attempts" ]; do
if cabal test --test-show-details=direct; then
break
else
echo "Attempt $i failed, retrying..."
i=$((i + 1))
sleep 1
fi
done
if [ "$i" -gt "$attempts" ]; then
echo "All "$attempts" attempts failed."
exit 1
fi
# ========================= # Unix /
# Windows Build
# =========================
build-windows: # / Windows
name: "${{ matrix.os }} (CLI,Desktop), GHC: ${{ matrix.ghc }}" # rm -rf dist-newstyle/src/direct-sq* is here because of the bug in cabal's dependency which prevents second build from finishing
needs: [maybe-release, variables]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
ghc: ${{ needs.variables.outputs.GHC_VER }}
cli_asset_name: simplex-chat-windows-x86-64
desktop_asset_name: simplex-desktop-windows-x86_64.msi
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Prepare build
uses: ./.github/actions/prepare-build
with:
java_ver: ${{ needs.variables.outputs.JAVA_VER }}
ghc_ver: ${{ matrix.ghc }}
os: ${{ matrix.os }}
cache_path: "C:/cabal"
github_ref: ${{ github.ref }}
- name: Configure pagefile (Windows)
uses: simplex-chat/configure-pagefile-action@v1.4
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "C:"
- name: 'Setup MSYS2' - name: 'Setup MSYS2'
uses: simplex-chat/setup-msys2@v2 if: matrix.os == 'windows-latest'
uses: msys2/setup-msys2@v2
with: with:
msystem: ucrt64 msystem: ucrt64
update: true update: true
@ -474,9 +331,10 @@ jobs:
toolchain:p toolchain:p
cmake:p cmake:p
# rm -rf dist-newstyle/src/direct-sq* is here because of the bug in cabal's dependency which prevents second build from finishing
- name: Build CLI - name: Windows build
id: windows_cli_build id: windows_build
if: matrix.os == 'windows-latest'
shell: msys2 {0} shell: msys2 {0}
run: | run: |
export PATH=$PATH:/c/ghcup/bin:$(echo /c/tools/ghc-*/bin || echo) export PATH=$PATH:/c/ghcup/bin:$(echo /c/tools/ghc-*/bin || echo)
@ -491,42 +349,70 @@ jobs:
rm -rf dist-newstyle/src/direct-sq* rm -rf dist-newstyle/src/direct-sq*
sed -i "s/, unix /--, unix /" simplex-chat.cabal sed -i "s/, unix /--, unix /" simplex-chat.cabal
cabal build -j --enable-tests cabal build --enable-tests
rm -rf dist-newstyle/src/direct-sq* rm -rf dist-newstyle/src/direct-sq*
path=$(cabal list-bin simplex-chat | tail -n 1) path=$(cabal list-bin simplex-chat | tail -n 1)
echo "bin_path=$path" >> $GITHUB_OUTPUT echo "bin_path=$path" >> $GITHUB_OUTPUT
echo "bin_hash=$(echo SHA2-256\(${{ matrix.cli_asset_name }}\)= $(openssl sha256 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT echo "bin_hash=$(echo SHA2-512\(${{ matrix.asset_name }}\)= $(openssl sha512 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT
- name: Upload CLI - name: Windows upload CLI binary to release
if: startsWith(github.ref, 'refs/tags/v') if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'windows-latest'
uses: ./.github/actions/prepare-release uses: svenstaro/upload-release-action@v2
with: with:
bin_path: ${{ steps.windows_cli_build.outputs.bin_path }} repo_token: ${{ secrets.GITHUB_TOKEN }}
bin_name: ${{ matrix.cli_asset_name }} file: ${{ steps.windows_build.outputs.bin_path }}
bin_hash: ${{ steps.windows_cli_build.outputs.bin_hash }} asset_name: ${{ matrix.asset_name }}
github_ref: ${{ github.ref }} tag: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Desktop - name: Windows update CLI binary hash
if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'windows-latest'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
append_body: true
body: |
${{ steps.windows_build.outputs.bin_hash }}
- name: Windows build desktop
id: windows_desktop_build id: windows_desktop_build
if: startsWith(github.ref, 'refs/tags/v') if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'windows-latest'
shell: msys2 {0} shell: msys2 {0}
run: | run: |
export PATH=$PATH:/c/ghcup/bin:$(echo /c/tools/ghc-*/bin || echo) export PATH=$PATH:/c/ghcup/bin:$(echo /c/tools/ghc-*/bin || echo)
scripts/desktop/build-lib-windows.sh scripts/desktop/build-lib-windows.sh
cd apps/multiplatform cd apps/multiplatform
./gradlew packageMsi ./gradlew packageMsi
rm -rf dist-newstyle/src/direct-sq*
path=$(echo $PWD/release/main/msi/*imple*.msi | sed 's#/\([a-z]\)#\1:#' | sed 's#/#\\#g') path=$(echo $PWD/release/main/msi/*imple*.msi | sed 's#/\([a-z]\)#\1:#' | sed 's#/#\\#g')
echo "package_path=$path" >> $GITHUB_OUTPUT echo "package_path=$path" >> $GITHUB_OUTPUT
echo "package_hash=$(echo SHA2-256\(${{ matrix.desktop_asset_name }}\)= $(openssl sha256 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT echo "package_hash=$(echo SHA2-512\(${{ matrix.desktop_asset_name }}\)= $(openssl sha512 $path | cut -d' ' -f 2))" >> $GITHUB_OUTPUT
- name: Upload Desktop - name: Windows upload desktop package to release
if: startsWith(github.ref, 'refs/tags/v') if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'windows-latest'
uses: ./.github/actions/prepare-release uses: svenstaro/upload-release-action@v2
with: with:
bin_path: ${{ steps.windows_desktop_build.outputs.package_path }} repo_token: ${{ secrets.GITHUB_TOKEN }}
bin_name: ${{ matrix.desktop_asset_name }} file: ${{ steps.windows_desktop_build.outputs.package_path }}
bin_hash: ${{ steps.windows_desktop_build.outputs.package_hash }} asset_name: ${{ matrix.desktop_asset_name }}
github_ref: ${{ github.ref }} tag: ${{ github.ref }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Windows update desktop package hash
if: startsWith(github.ref, 'refs/tags/v') && matrix.os == 'windows-latest'
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
append_body: true
body: |
${{ steps.windows_desktop_build.outputs.package_hash }}
- name: Cache windows build
uses: actions/cache/save@v3
if: matrix.os == 'windows-latest'
with:
path: |
${{ matrix.cache_path }}
dist-newstyle
key: ${{ steps.restore_cache.outputs.cache-primary-key }}
# Windows /

View file

@ -1,45 +0,0 @@
name: Reproduce latest release
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * *' # every day at 02:00 night
jobs:
reproduce:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get latest release
shell: bash
run: |
curl --proto '=https' \
--tlsv1.2 \
-sSf -L \
'https://api.github.com/repos/simplex-chat/simplex-chat/releases/latest' \
2>/dev/null | \
grep -i "tag_name" | \
awk -F \" '{print "TAG="$4}' >> $GITHUB_ENV
- name: Execute reproduce script
run: |
${GITHUB_WORKSPACE}/scripts/reproduce-builds.sh "$TAG"
- name: Check if build has been reproduced
env:
url: ${{ secrets.STATUS_SIMPLEX_WEBHOOK_URL }}
user: ${{ secrets.STATUS_SIMPLEX_WEBHOOK_USER }}
pass: ${{ secrets.STATUS_SIMPLEX_WEBHOOK_PASS }}
run: |
if [ -f "${GITHUB_WORKSPACE}/$TAG/_sha256sums" ]; then
exit 0
else
curl --proto '=https' --tlsv1.2 -sSf \
-u "${user}:${pass}" \
-H 'Content-Type: application/json' \
-d '{"title": "👾 GitHub: Runner", "description": "⛔️ '"$TAG"' did not reproduce."}' \
"$url"
exit 1
fi

View file

@ -33,7 +33,7 @@ jobs:
./website/web.sh ./website/web.sh
- name: Deploy - name: Deploy
uses: simplex-chat/actions-gh-pages@v3 uses: peaceiris/actions-gh-pages@v3
with: with:
publish_dir: ./website/_site publish_dir: ./website/_site
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}

View file

@ -29,7 +29,7 @@ RUN cp ./scripts/cabal.project.local.linux ./cabal.project.local
# Compile simplex-chat # Compile simplex-chat
RUN cabal update RUN cabal update
RUN cabal build exe:simplex-chat --constraint 'simplexmq +client_library' --constraint 'simplex-chat +client_library' RUN cabal build exe:simplex-chat --constraint 'simplexmq +client_library'
# Strip the binary from debug symbols to reduce size # Strip the binary from debug symbols to reduce size
RUN bin=$(find /project/dist-newstyle -name "simplex-chat" -type f -executable) && \ RUN bin=$(find /project/dist-newstyle -name "simplex-chat" -type f -executable) && \

View file

@ -1,92 +0,0 @@
# syntax=docker/dockerfile:1.7.0-labs
ARG TAG=24.04
FROM ubuntu:${TAG} AS build
### Build stage
ARG GHC=9.6.3
ARG CABAL=3.10.1.0
ARG JAVA=17
ENV TZ=Etc/UTC \
DEBIAN_FRONTEND=noninteractive
# Install curl, git and and simplex-chat dependencies
RUN apt-get update && \
apt-get install -y curl \
libpq-dev \
git \
sqlite3 \
libsqlite3-dev \
build-essential \
libgmp3-dev \
zlib1g-dev \
llvm \
cmake \
llvm-dev \
libnuma-dev \
libssl-dev \
desktop-file-utils \
patchelf \
ca-certificates \
zip \
wget \
fuse3 \
file \
appstream \
gpg \
unzip &&\
ln -s /bin/fusermount /bin/fusermount3 || :
# Install Java Coretto
# Required, because official Java in Ubuntu
# depends on libjpeg.so.8 and liblcms2.so.2 which are NOT copied into final
# /usr/lib/runtime/lib directory and I do not have time to figure out gradle.kotlin
# to fix this :(
RUN curl --proto '=https' --tlsv1.2 -sSf 'https://apt.corretto.aws/corretto.key' | gpg --dearmor -o /usr/share/keyrings/corretto-keyring.gpg &&\
echo "deb [signed-by=/usr/share/keyrings/corretto-keyring.gpg] https://apt.corretto.aws stable main" > /etc/apt/sources.list.d/corretto.list &&\
apt update &&\
apt install -y java-${JAVA}-amazon-corretto-jdk
# Specify bootstrap Haskell versions
ENV BOOTSTRAP_HASKELL_GHC_VERSION=${GHC}
ENV BOOTSTRAP_HASKELL_CABAL_VERSION=${CABAL}
# Do not install Stack
ENV BOOTSTRAP_HASKELL_INSTALL_NO_STACK=true
ENV BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=true
# Install ghcup
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh
# Adjust PATH
ENV PATH="/root/.cabal/bin:/root/.ghcup/bin:$PATH"
# Set both as default
RUN ghcup set ghc "${GHC}" && \
ghcup set cabal "${CABAL}"
#=====================
# Install Android SDK
#=====================
ARG SDK_VERSION=13114758
ENV SDK_VERSION=$SDK_VERSION \
ANDROID_HOME=/root
RUN curl -L -o tools.zip "https://dl.google.com/android/repository/commandlinetools-linux-${SDK_VERSION}_latest.zip" && \
unzip tools.zip && rm tools.zip && \
mv cmdline-tools tools && mkdir "$ANDROID_HOME/cmdline-tools" && mv tools "$ANDROID_HOME/cmdline-tools/" && \
ln -s "$ANDROID_HOME/cmdline-tools/tools" "$ANDROID_HOME/cmdline-tools/latest"
ENV PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/cmdline-tools/tools/bin"
# https://askubuntu.com/questions/885658/android-sdk-repositories-cfg-could-not-be-loaded
RUN mkdir -p ~/.android ~/.gradle && \
touch ~/.android/repositories.cfg && \
echo 'org.gradle.console=plain' > ~/.gradle/gradle.properties &&\
yes | sdkmanager --licenses >/dev/null
ENV PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools
WORKDIR /project

View file

@ -10,7 +10,7 @@
# SimpleX - the first messaging platform that has no user identifiers of any kind - 100% private by design! # SimpleX - the first messaging platform that has no user identifiers of any kind - 100% private by design!
[<img src="./images/trail-of-bits.jpg" height="80">](http://simplex.chat/blog/20221108-simplex-chat-v4.2-security-audit-new-website.html) &nbsp;&nbsp;&nbsp; [<img src="./images/privacy-guides.jpg" height="64">](https://www.privacyguides.org/en/real-time-communication/#simplex-chat) &nbsp;&nbsp;&nbsp; [<img src="./images/whonix-logo.jpg" height="64">](https://www.whonix.org/wiki/Chat#Recommendation) &nbsp;&nbsp;&nbsp; [<img src="./images/kuketz-blog.jpg" height="64">](https://www.kuketz-blog.de/simplex-eindruecke-vom-messenger-ohne-identifier/) [<img src="./images/trail-of-bits.jpg" height="100">](http://simplex.chat/blog/20221108-simplex-chat-v4.2-security-audit-new-website.html) &nbsp;&nbsp;&nbsp; [<img src="./images/privacy-guides.jpg" height="80">](https://www.privacyguides.org/en/real-time-communication/#simplex-chat) &nbsp;&nbsp;&nbsp; [<img src="./images/kuketz-blog.jpg" height="80">](https://www.kuketz-blog.de/simplex-eindruecke-vom-messenger-ohne-identifier/)
## Welcome to SimpleX Chat! ## Welcome to SimpleX Chat!
@ -72,7 +72,7 @@ You must:
Messages not following these rules will be deleted, the right to send messages may be revoked, and the access to the new members to the group may be temporarily restricted, to prevent re-joining under a different name - our imperfect group moderation does not have a better solution at the moment. Messages not following these rules will be deleted, the right to send messages may be revoked, and the access to the new members to the group may be temporarily restricted, to prevent re-joining under a different name - our imperfect group moderation does not have a better solution at the moment.
You can join an English-speaking users group if you want to ask any questions: [#SimpleX users group](https://simplex.chat/contact#/?v=2-7&smp=smp%3A%2F%2Fhpq7_4gGJiilmz5Rf-CswuU5kZGkm_zOIooSw6yALRg%3D%40smp5.simplex.im%2FiBkJE72asZX1NUZaYFIeKRVk6oVjb-iv%23%2F%3Fv%3D1-3%26dh%3DMCowBQYDK2VuAyEAinqu3j74AMjODLoIRR487ZW6ysip_dlpD6Zxk18SPFY%253D%26srv%3Djjbyvoemxysm7qxap7m5d5m35jzv5qq6gnlv7s4rsn7tdwwmuqciwpid.onion&data=%7B%22groupLinkId%22%3A%223wAFGCLygQHR5AwynZOHlQ%3D%3D%22%7D) You can join an English-speaking users group if you want to ask any questions: [#SimpleX users group](https://simplex.chat/contact#/?v=2-4&smp=smp%3A%2F%2FPQUV2eL0t7OStZOoAsPEV2QYWt4-xilbakvGUGOItUo%3D%40smp6.simplex.im%2Fos8FftfoV8zjb2T89fUEjJtF7y64p5av%23%2F%3Fv%3D1-2%26dh%3DMCowBQYDK2VuAyEAQqMgh0fw2lPhjn3PDIEfAKA_E0-gf8Hr8zzhYnDivRs%253D%26srv%3Dbylepyau3ty4czmn77q4fglvperknl4bi2eb2fdy2bh4jxtf32kf73yd.onion&data=%7B%22type%22%3A%22group%22%2C%22groupLinkId%22%3A%22lBPiveK2mjfUH43SN77R0w%3D%3D%22%7D)
There is also a group [#simplex-devs](https://simplex.chat/contact#/?v=1-4&smp=smp%3A%2F%2FPQUV2eL0t7OStZOoAsPEV2QYWt4-xilbakvGUGOItUo%3D%40smp6.simplex.im%2FvYCRjIflKNMGYlfTkuHe4B40qSlQ0439%23%2F%3Fv%3D1-2%26dh%3DMCowBQYDK2VuAyEAHNdcqNbzXZhyMoSBjT2R0-Eb1EPaLyUg3KZjn-kmM1w%253D%26srv%3Dbylepyau3ty4czmn77q4fglvperknl4bi2eb2fdy2bh4jxtf32kf73yd.onion&data=%7B%22type%22%3A%22group%22%2C%22groupLinkId%22%3A%22PD20tcXjw7IpkkMCfR6HLA%3D%3D%22%7D) for developers who build on SimpleX platform: There is also a group [#simplex-devs](https://simplex.chat/contact#/?v=1-4&smp=smp%3A%2F%2FPQUV2eL0t7OStZOoAsPEV2QYWt4-xilbakvGUGOItUo%3D%40smp6.simplex.im%2FvYCRjIflKNMGYlfTkuHe4B40qSlQ0439%23%2F%3Fv%3D1-2%26dh%3DMCowBQYDK2VuAyEAHNdcqNbzXZhyMoSBjT2R0-Eb1EPaLyUg3KZjn-kmM1w%253D%26srv%3Dbylepyau3ty4czmn77q4fglvperknl4bi2eb2fdy2bh4jxtf32kf73yd.onion&data=%7B%22type%22%3A%22group%22%2C%22groupLinkId%22%3A%22PD20tcXjw7IpkkMCfR6HLA%3D%3D%22%7D) for developers who build on SimpleX platform:
@ -110,15 +110,6 @@ After you connect, you can [verify connection security code](./blog/20230103-sim
Read about the app features and settings in the new [User guide](./docs/guide/README.md). Read about the app features and settings in the new [User guide](./docs/guide/README.md).
## Contribute
We would love to have you join the development! You can help us with:
- [share the color theme](./docs/THEMES.md) you use in Android app!
- writing a tutorial or recipes about hosting servers, chat bot automations, etc.
- contributing to SimpleX Chat knowledge-base.
- developing features - please connect to us via chat so we can help you get started.
## Help translating SimpleX Chat ## Help translating SimpleX Chat
Thanks to our users and [Weblate](https://hosted.weblate.org/engage/simplex-chat/), SimpleX Chat apps, website and documents are translated to many other languages. Thanks to our users and [Weblate](https://hosted.weblate.org/engage/simplex-chat/), SimpleX Chat apps, website and documents are translated to many other languages.
@ -150,6 +141,15 @@ Join our translators to help SimpleX grow!
Languages in progress: Arabic, Japanese, Korean, Portuguese and [others](https://hosted.weblate.org/projects/simplex-chat/#languages). We will be adding more languages as some of the already added are completed please suggest new languages, review the [translation guide](./docs/TRANSLATIONS.md) and get in touch with us! Languages in progress: Arabic, Japanese, Korean, Portuguese and [others](https://hosted.weblate.org/projects/simplex-chat/#languages). We will be adding more languages as some of the already added are completed please suggest new languages, review the [translation guide](./docs/TRANSLATIONS.md) and get in touch with us!
## Contribute
We would love to have you join the development! You can help us with:
- [share the color theme](./docs/THEMES.md) you use in Android app!
- writing a tutorial or recipes about hosting servers, chat bot automations, etc.
- contributing to SimpleX Chat knowledge-base.
- developing features - please connect to us via chat so we can help you get started.
## Please support us with your donations ## Please support us with your donations
Huge thank you to everybody who donated to SimpleX Chat! Huge thank you to everybody who donated to SimpleX Chat!
@ -169,7 +169,6 @@ It is possible to donate via:
- ETH: 0xD9ee7Db0AD0dc1Dfa7eD53290199ED06beA04692 - ETH: 0xD9ee7Db0AD0dc1Dfa7eD53290199ED06beA04692
- USDT (Ethereum): 0xD9ee7Db0AD0dc1Dfa7eD53290199ED06beA04692 - USDT (Ethereum): 0xD9ee7Db0AD0dc1Dfa7eD53290199ED06beA04692
- ZEC: t1fwjQW5gpFhDqXNhxqDWyF9j9WeKvVS5Jg - ZEC: t1fwjQW5gpFhDqXNhxqDWyF9j9WeKvVS5Jg
- ZEC shielded: u16rnvkflumf5uw9frngc2lymvmzgdr2mmc9unyu0l44unwfmdcpfm0axujd2w34ct3ye709azxsqge45705lpvvqu264ltzvfay55ygyq
- DOGE: D99pV4n9TrPxBPCkQGx4w4SMSa6QjRBxPf - DOGE: D99pV4n9TrPxBPCkQGx4w4SMSa6QjRBxPf
- SOL: 7JCf5m3TiHmYKZVr6jCu1KeZVtb9Y1jRMQDU69p5ARnu - SOL: 7JCf5m3TiHmYKZVr6jCu1KeZVtb9Y1jRMQDU69p5ARnu
- please ask if you want to donate any other coins. - please ask if you want to donate any other coins.
@ -235,10 +234,6 @@ You can use SimpleX with your own servers and still communicate with people usin
Recent and important updates: Recent and important updates:
[Mar 8, 2025. SimpleX Chat v6.3: new user experience and safety in public groups](./blog/20250308-simplex-chat-v6-3-new-user-experience-safety-in-public-groups.md)
[Jan 14, 2025. SimpleX network: large groups and privacy-preserving content moderation](./blog/20250114-simplex-network-large-groups-privacy-preserving-content-moderation.md)
[Dec 10, 2024. SimpleX network: preset servers operated by Flux, business chats and more with v6.2 of the apps](./20241210-simplex-network-v6-2-servers-by-flux-business-chats.md) [Dec 10, 2024. SimpleX network: preset servers operated by Flux, business chats and more with v6.2 of the apps](./20241210-simplex-network-v6-2-servers-by-flux-business-chats.md)
[Oct 14, 2024. SimpleX network: security review of protocols design by Trail of Bits, v6.1 released with better calls and user experience.](./blog/20241014-simplex-network-v6-1-security-review-better-calls-user-experience.md) [Oct 14, 2024. SimpleX network: security review of protocols design by Trail of Bits, v6.1 released with better calls and user experience.](./blog/20241014-simplex-network-v6-1-security-review-better-calls-user-experience.md)
@ -310,13 +305,12 @@ What is already implemented:
15. Manual messaging queue rotations to move conversation to another SMP relay. 15. Manual messaging queue rotations to move conversation to another SMP relay.
16. Sending end-to-end encrypted files using [XFTP protocol](https://simplex.chat/blog/20230301-simplex-file-transfer-protocol.html). 16. Sending end-to-end encrypted files using [XFTP protocol](https://simplex.chat/blog/20230301-simplex-file-transfer-protocol.html).
17. Local files encryption. 17. Local files encryption.
18. [Reproducible server builds](./docs/SERVER.md#reproduce-builds).
We plan to add: We plan to add:
1. Automatic message queue rotation and redundancy. Currently the queues created between two users are used until the queue is manually changed by the user or contact is deleted. We are planning to add automatic queue rotation to make these identifiers temporary and rotate based on some schedule TBC (e.g., every X messages, or every X hours/days). 1. Automatic message queue rotation and redundancy. Currently the queues created between two users are used until the queue is manually changed by the user or contact is deleted. We are planning to add automatic queue rotation to make these identifiers temporary and rotate based on some schedule TBC (e.g., every X messages, or every X hours/days).
2. Message "mixing" - adding latency to message delivery, to protect against traffic correlation by message time. 2. Message "mixing" - adding latency to message delivery, to protect against traffic correlation by message time.
3. Reproducible clients builds this is a complex problem, but we are aiming to have it in 2025 at least partially. 3. Reproducible builds this is the limitation of the development stack, but we will be investing into solving this problem. Users can still build all applications and services from the source code.
4. Recipients' XFTP relays to reduce traffic and conceal IP addresses from the relays chosen, and potentially controlled, by another party. 4. Recipients' XFTP relays to reduce traffic and conceal IP addresses from the relays chosen, and potentially controlled, by another party.
## For developers ## For developers

View file

@ -54,7 +54,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {
try await apiVerifyToken(token: token, nonce: nonce, code: verification) try await apiVerifyToken(token: token, nonce: nonce, code: verification)
m.tokenStatus = .active m.tokenStatus = .active
} catch { } catch {
if let cr = error as? ChatError, case .errorAgent(.NTF(.AUTH)) = cr { if let cr = error as? ChatResponse, case .chatCmdError(_, .errorAgent(.NTF(.AUTH))) = cr {
m.tokenStatus = .expired m.tokenStatus = .expired
} }
logger.error("AppDelegate: didReceiveRemoteNotification: apiVerifyToken or apiIntervalNofication error: \(responseError(error))") logger.error("AppDelegate: didReceiveRemoteNotification: apiVerifyToken or apiIntervalNofication error: \(responseError(error))")

View file

@ -1,23 +0,0 @@
{
"images" : [
{
"filename" : "vertical_logo_x1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "vertical_logo_x2.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "vertical_logo_x3.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

View file

@ -11,10 +11,12 @@ import SimpleXChat
private enum NoticesSheet: Identifiable { private enum NoticesSheet: Identifiable {
case whatsNew(updatedConditions: Bool) case whatsNew(updatedConditions: Bool)
case updatedConditions
var id: String { var id: String {
switch self { switch self {
case .whatsNew: return "whatsNew" case .whatsNew: return "whatsNew"
case .updatedConditions: return "updatedConditions"
} }
} }
} }
@ -74,7 +76,7 @@ struct ContentView: View {
} }
} }
func allViews() -> some View { @ViewBuilder func allViews() -> some View {
ZStack { ZStack {
let showCallArea = chatModel.activeCall != nil && chatModel.activeCall?.callState != .waitCapabilities && chatModel.activeCall?.callState != .invitationAccepted let showCallArea = chatModel.activeCall != nil && chatModel.activeCall?.callState != .waitCapabilities && chatModel.activeCall?.callState != .invitationAccepted
// contentView() has to be in a single branch, so that enabling authentication doesn't trigger re-rendering and close settings. // contentView() has to be in a single branch, so that enabling authentication doesn't trigger re-rendering and close settings.
@ -209,7 +211,7 @@ struct ContentView: View {
} }
} }
private func activeCallInteractiveArea(_ call: Call) -> some View { @ViewBuilder private func activeCallInteractiveArea(_ call: Call) -> some View {
HStack { HStack {
Text(call.contact.displayName).font(.body).foregroundColor(.white) Text(call.contact.displayName).font(.body).foregroundColor(.white)
Spacer() Spacer()
@ -276,8 +278,10 @@ struct ContentView: View {
let showWhatsNew = shouldShowWhatsNew() let showWhatsNew = shouldShowWhatsNew()
let showUpdatedConditions = chatModel.conditions.conditionsAction?.showNotice ?? false let showUpdatedConditions = chatModel.conditions.conditionsAction?.showNotice ?? false
noticesShown = showWhatsNew || showUpdatedConditions noticesShown = showWhatsNew || showUpdatedConditions
if showWhatsNew || showUpdatedConditions { if showWhatsNew {
noticesSheetItem = .whatsNew(updatedConditions: showUpdatedConditions) noticesSheetItem = .whatsNew(updatedConditions: showUpdatedConditions)
} else if showUpdatedConditions {
noticesSheetItem = .updatedConditions
} }
} }
} }
@ -296,6 +300,14 @@ struct ContentView: View {
.if(updatedConditions) { v in .if(updatedConditions) { v in
v.task { await setConditionsNotified_() } v.task { await setConditionsNotified_() }
} }
case .updatedConditions:
UsageConditionsView(
currUserServers: Binding.constant([]),
userServers: Binding.constant([]),
updated: true
)
.modifier(ThemedBackground(grouped: true))
.task { await setConditionsNotified_() }
} }
} }
if chatModel.setDeliveryReceipts { if chatModel.setDeliveryReceipts {
@ -443,12 +455,12 @@ struct ContentView: View {
} }
func connectViaUrl() { func connectViaUrl() {
let m = ChatModel.shared dismissAllSheets() {
if let url = m.appOpenUrl { let m = ChatModel.shared
m.appOpenUrl = nil if let url = m.appOpenUrl {
dismissAllSheets() { m.appOpenUrl = nil
var path = url.path var path = url.path
if (path == "/contact" || path == "/invitation" || path == "/a" || path == "/c" || path == "/g" || path == "/i") { if (path == "/contact" || path == "/invitation") {
path.removeFirst() path.removeFirst()
let link = url.absoluteString.replacingOccurrences(of: "///\(path)", with: "/\(path)") let link = url.absoluteString.replacingOccurrences(of: "///\(path)", with: "/\(path)")
planAndConnect( planAndConnect(

File diff suppressed because it is too large Load diff

View file

@ -30,18 +30,9 @@ actor TerminalItems {
} }
} }
func addCommand<R: ChatAPIResult>(_ start: Date, _ cmd: ChatCommand, _ res: APIResult<R>) async { func addCommand(_ start: Date, _ cmd: ChatCommand, _ resp: ChatResponse) async {
await add(.cmd(start, cmd)) await add(.cmd(start, cmd))
await addResult(res) await add(.resp(.now, resp))
}
func addResult<R: ChatAPIResult>(_ res: APIResult<R>) async {
let item: TerminalItem = switch res {
case let .result(r): .res(.now, r)
case let .error(e): .err(.now, e)
case let .invalid(type, json): .bad(.now, type, json)
}
await add(item)
} }
} }
@ -63,7 +54,9 @@ class ItemsModel: ObservableObject {
willSet { publisher.send() } willSet { publisher.send() }
} }
// set listener here that will be notified on every add/delete of a chat item
let chatState = ActiveChatState() let chatState = ActiveChatState()
var chatItemsChangesListener: RecalculatePositions = RecalculatePositions()
// Publishes directly to `objectWillChange` publisher, // Publishes directly to `objectWillChange` publisher,
// this will cause reversedChatItems to be rendered without throttling // this will cause reversedChatItems to be rendered without throttling
@ -73,10 +66,6 @@ class ItemsModel: ObservableObject {
private var navigationTimeoutTask: Task<Void, Never>? = nil private var navigationTimeoutTask: Task<Void, Never>? = nil
private var loadChatTask: Task<Void, Never>? = nil private var loadChatTask: Task<Void, Never>? = nil
var lastItemsLoaded: Bool {
chatState.splits.isEmpty || chatState.splits.first != reversedChatItems.first?.id
}
init() { init() {
publisher publisher
.throttle(for: 0.2, scheduler: DispatchQueue.main, latest: true) .throttle(for: 0.2, scheduler: DispatchQueue.main, latest: true)
@ -580,7 +569,7 @@ final class ChatModel: ObservableObject {
ci.meta.itemStatus = status ci.meta.itemStatus = status
} }
im.reversedChatItems.insert(ci, at: hasLiveDummy ? 1 : 0) im.reversedChatItems.insert(ci, at: hasLiveDummy ? 1 : 0)
im.chatState.itemAdded((ci.id, ci.isRcvNew), hasLiveDummy ? 1 : 0) im.chatItemsChangesListener.added((ci.id, ci.isRcvNew), hasLiveDummy ? 1 : 0)
im.itemAdded = true im.itemAdded = true
ChatItemDummyModel.shared.sendUpdate() ChatItemDummyModel.shared.sendUpdate()
return true return true
@ -628,52 +617,13 @@ final class ChatModel: ObservableObject {
if let i = getChatItemIndex(cItem) { if let i = getChatItemIndex(cItem) {
withAnimation { withAnimation {
let item = im.reversedChatItems.remove(at: i) let item = im.reversedChatItems.remove(at: i)
im.chatState.itemsRemoved([(item.id, i, item.isRcvNew)], im.reversedChatItems.reversed()) im.chatItemsChangesListener.removed([(item.id, i, item.isRcvNew)], im.reversedChatItems.reversed())
} }
} }
} }
VoiceItemState.stopVoiceInChatView(cInfo, cItem) VoiceItemState.stopVoiceInChatView(cInfo, cItem)
} }
func removeMemberItems(_ removedMember: GroupMember, byMember: GroupMember, _ groupInfo: GroupInfo) {
// this should not happen, only another member can "remove" user, user can only "leave" (another event).
if byMember.groupMemberId == groupInfo.membership.groupMemberId {
logger.debug("exiting removeMemberItems")
return
}
if chatId == groupInfo.id {
for i in 0..<im.reversedChatItems.count {
if let updatedItem = removedUpdatedItem(im.reversedChatItems[i]) {
_updateChatItem(at: i, with: updatedItem)
}
}
} else if let chat = getChat(groupInfo.id),
chat.chatItems.count > 0,
let updatedItem = removedUpdatedItem(chat.chatItems[0]) {
chat.chatItems = [updatedItem]
}
func removedUpdatedItem(_ item: ChatItem) -> ChatItem? {
let newContent: CIContent
if case .groupSnd = item.chatDir, removedMember.groupMemberId == groupInfo.membership.groupMemberId {
newContent = .sndModerated
} else if case let .groupRcv(groupMember) = item.chatDir, groupMember.groupMemberId == removedMember.groupMemberId {
newContent = .rcvModerated
} else {
return nil
}
var updatedItem = item
updatedItem.meta.itemDeleted = .moderated(deletedTs: Date.now, byGroupMember: byMember)
if groupInfo.fullGroupPreferences.fullDelete.on {
updatedItem.content = newContent
}
if item.isActiveReport {
decreaseGroupReportsCounter(groupInfo.id)
}
return updatedItem
}
}
func nextChatItemData<T>(_ chatItemId: Int64, previous: Bool, map: @escaping (ChatItem) -> T?) -> T? { func nextChatItemData<T>(_ chatItemId: Int64, previous: Bool, map: @escaping (ChatItem) -> T?) -> T? {
guard var i = im.reversedChatItems.firstIndex(where: { $0.id == chatItemId }) else { return nil } guard var i = im.reversedChatItems.firstIndex(where: { $0.id == chatItemId }) else { return nil }
if previous { if previous {
@ -716,7 +666,7 @@ final class ChatModel: ObservableObject {
let cItem = ChatItem.liveDummy(chatInfo.chatType) let cItem = ChatItem.liveDummy(chatInfo.chatType)
withAnimation { withAnimation {
im.reversedChatItems.insert(cItem, at: 0) im.reversedChatItems.insert(cItem, at: 0)
im.chatState.itemAdded((cItem.id, cItem.isRcvNew), 0) im.chatItemsChangesListener.added((cItem.id, cItem.isRcvNew), 0)
im.itemAdded = true im.itemAdded = true
} }
return cItem return cItem
@ -750,7 +700,7 @@ final class ChatModel: ObservableObject {
markChatItemRead_(i) markChatItemRead_(i)
i += 1 i += 1
} }
im.chatState.itemsRead(nil, im.reversedChatItems.reversed()) im.chatItemsChangesListener.read(nil, im.reversedChatItems.reversed())
} }
} }
func markChatUnread(_ cInfo: ChatInfo, unreadChat: Bool = true) { func markChatUnread(_ cInfo: ChatInfo, unreadChat: Bool = true) {
@ -774,7 +724,7 @@ final class ChatModel: ObservableObject {
if chatId == cInfo.id { if chatId == cInfo.id {
chatItemStatuses = [:] chatItemStatuses = [:]
im.reversedChatItems = [] im.reversedChatItems = []
im.chatState.clear() im.chatItemsChangesListener.cleared()
} }
} }
@ -792,7 +742,7 @@ final class ChatModel: ObservableObject {
} }
i += 1 i += 1
} }
im.chatState.itemsRead(unreadItemIds, im.reversedChatItems.reversed()) im.chatItemsChangesListener.read(unreadItemIds, im.reversedChatItems.reversed())
} }
self.unreadCollector.changeUnreadCounter(cInfo.id, by: -itemIds.count, unreadMentions: -mentionsRead) self.unreadCollector.changeUnreadCounter(cInfo.id, by: -itemIds.count, unreadMentions: -mentionsRead)
} }
@ -1152,6 +1102,27 @@ final class Chat: ObservableObject, Identifiable, ChatLike {
) )
} }
var userCanSend: Bool {
switch chatInfo {
case .direct: return true
case let .group(groupInfo):
let m = groupInfo.membership
return m.memberActive && m.memberRole >= .member
case .local:
return true
default: return false
}
}
var userIsObserver: Bool {
switch chatInfo {
case let .group(groupInfo):
let m = groupInfo.membership
return m.memberActive && m.memberRole == .observer
default: return false
}
}
var unreadTag: Bool { var unreadTag: Bool {
switch chatInfo.chatSettings?.enableNtfs { switch chatInfo.chatSettings?.enableNtfs {
case .all: chatStats.unreadChat || chatStats.unreadCount > 0 case .all: chatStats.unreadChat || chatStats.unreadCount > 0

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,6 @@ struct SimpleXApp: App {
@Environment(\.scenePhase) var scenePhase @Environment(\.scenePhase) var scenePhase
@State private var enteredBackgroundAuthenticated: TimeInterval? = nil @State private var enteredBackgroundAuthenticated: TimeInterval? = nil
@State private var appOpenUrlLater: URL?
init() { init() {
DispatchQueue.global(qos: .background).sync { DispatchQueue.global(qos: .background).sync {
@ -43,11 +42,7 @@ struct SimpleXApp: App {
.environmentObject(AppTheme.shared) .environmentObject(AppTheme.shared)
.onOpenURL { url in .onOpenURL { url in
logger.debug("ContentView.onOpenURL: \(url)") logger.debug("ContentView.onOpenURL: \(url)")
if AppChatState.shared.value == .active { chatModel.appOpenUrl = url
chatModel.appOpenUrl = url
} else {
appOpenUrlLater = url
}
} }
.onAppear() { .onAppear() {
// Present screen for continue migration if it wasn't finished yet // Present screen for continue migration if it wasn't finished yet
@ -98,16 +93,7 @@ struct SimpleXApp: App {
if !chatModel.showCallView && !CallController.shared.hasActiveCalls() { if !chatModel.showCallView && !CallController.shared.hasActiveCalls() {
await updateCallInvitations() await updateCallInvitations()
} }
if let url = appOpenUrlLater {
await MainActor.run {
appOpenUrlLater = nil
chatModel.appOpenUrl = url
}
}
} }
} else if let url = appOpenUrlLater {
appOpenUrlLater = nil
chatModel.appOpenUrl = url
} }
} }
} }

View file

@ -243,7 +243,7 @@ struct ActiveCallView: View {
ChatReceiver.shared.messagesChannel = nil ChatReceiver.shared.messagesChannel = nil
return return
} }
if case let .result(.chatItemsStatusesUpdated(_, chatItems)) = msg, if case let .chatItemsStatusesUpdated(_, chatItems) = msg,
chatItems.contains(where: { ci in chatItems.contains(where: { ci in
ci.chatInfo.id == call.contact.id && ci.chatInfo.id == call.contact.id &&
ci.chatItem.content.isSndCall && ci.chatItem.content.isSndCall &&
@ -361,7 +361,7 @@ struct ActiveCallOverlay: View {
HStack { HStack {
Text(call.encryptionStatus) Text(call.encryptionStatus)
if let connInfo = call.connectionInfo { if let connInfo = call.connectionInfo {
Text(verbatim: "(") + Text(connInfo.text) + Text(verbatim: ")") Text("(") + Text(connInfo.text) + Text(")")
} }
} }
} }
@ -390,7 +390,7 @@ struct ActiveCallOverlay: View {
HStack { HStack {
Text(call.encryptionStatus) Text(call.encryptionStatus)
if let connInfo = call.connectionInfo { if let connInfo = call.connectionInfo {
Text(verbatim: "(") + Text(connInfo.text) + Text(verbatim: ")") Text("(") + Text(connInfo.text) + Text(")")
} }
} }
} }
@ -467,7 +467,7 @@ struct ActiveCallOverlay: View {
.disabled(call.initialCallType == .audio && client.activeCall?.peerHasOldVersion == true) .disabled(call.initialCallType == .audio && client.activeCall?.peerHasOldVersion == true)
} }
private func flipCameraButton() -> some View { @ViewBuilder private func flipCameraButton() -> some View {
controlButton(call, "arrow.triangle.2.circlepath", padding: 12) { controlButton(call, "arrow.triangle.2.circlepath", padding: 12) {
Task { Task {
if await WebRTCClient.isAuthorized(for: .video) { if await WebRTCClient.isAuthorized(for: .video) {
@ -477,11 +477,11 @@ struct ActiveCallOverlay: View {
} }
} }
private func controlButton(_ call: Call, _ imageName: String, padding: CGFloat, _ perform: @escaping () -> Void) -> some View { @ViewBuilder private func controlButton(_ call: Call, _ imageName: String, padding: CGFloat, _ perform: @escaping () -> Void) -> some View {
callButton(imageName, call.peerMediaSources.hasVideo ? Color.black.opacity(0.2) : Color.white.opacity(0.2), padding: padding, perform) callButton(imageName, call.peerMediaSources.hasVideo ? Color.black.opacity(0.2) : Color.white.opacity(0.2), padding: padding, perform)
} }
private func audioDevicePickerButton() -> some View { @ViewBuilder private func audioDevicePickerButton() -> some View {
AudioDevicePicker() AudioDevicePicker()
.opacity(0.8) .opacity(0.8)
.scaleEffect(2) .scaleEffect(2)

View file

@ -7,7 +7,7 @@
// //
import SwiftUI import SwiftUI
@preconcurrency import SimpleXChat import SimpleXChat
func infoRow(_ title: LocalizedStringKey, _ value: String) -> some View { func infoRow(_ title: LocalizedStringKey, _ value: String) -> some View {
HStack { HStack {

View file

@ -50,7 +50,7 @@ struct CICallItemView: View {
Image(systemName: "phone.connection").foregroundColor(.green) Image(systemName: "phone.connection").foregroundColor(.green)
} }
private func endedCallIcon(_ sent: Bool) -> some View { @ViewBuilder private func endedCallIcon(_ sent: Bool) -> some View {
HStack { HStack {
Image(systemName: "phone.down") Image(systemName: "phone.down")
Text(durationText(duration)).foregroundColor(theme.colors.secondary) Text(durationText(duration)).foregroundColor(theme.colors.secondary)
@ -60,16 +60,16 @@ struct CICallItemView: View {
@ViewBuilder private func acceptCallButton() -> some View { @ViewBuilder private func acceptCallButton() -> some View {
if case let .direct(contact) = chat.chatInfo { if case let .direct(contact) = chat.chatInfo {
Label("Answer call", systemImage: "phone.arrow.down.left") Button {
.foregroundColor(theme.colors.primary) if let invitation = m.callInvitations[contact.id] {
.simultaneousGesture(TapGesture().onEnded { CallController.shared.answerCall(invitation: invitation)
if let invitation = m.callInvitations[contact.id] { logger.debug("acceptCallButton call answered")
CallController.shared.answerCall(invitation: invitation) } else {
logger.debug("acceptCallButton call answered") AlertManager.shared.showAlertMsg(title: "Call already ended!")
} else { }
AlertManager.shared.showAlertMsg(title: "Call already ended!") } label: {
} Label("Answer call", systemImage: "phone.arrow.down.left")
}) }
} else { } else {
Image(systemName: "phone.arrow.down.left").foregroundColor(theme.colors.secondary) Image(systemName: "phone.arrow.down.left").foregroundColor(theme.colors.secondary)
} }

View file

@ -26,9 +26,9 @@ struct CIFeaturePreferenceView: View {
allowed != .no && ct.allowsFeature(feature) && !ct.userAllowsFeature(feature) { allowed != .no && ct.allowsFeature(feature) && !ct.userAllowsFeature(feature) {
let setParam = feature == .timedMessages && ct.mergedPreferences.timedMessages.userPreference.preference.ttl == nil let setParam = feature == .timedMessages && ct.mergedPreferences.timedMessages.userPreference.preference.ttl == nil
featurePreferenceView(acceptText: setParam ? "Set 1 day" : "Accept") featurePreferenceView(acceptText: setParam ? "Set 1 day" : "Accept")
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
allowFeatureToContact(ct, feature, param: setParam ? 86400 : nil) allowFeatureToContact(ct, feature, param: setParam ? 86400 : nil)
}) }
} else { } else {
featurePreferenceView() featurePreferenceView()
} }

View file

@ -19,42 +19,42 @@ struct CIFileView: View {
var body: some View { var body: some View {
if smallViewSize != nil { if smallViewSize != nil {
fileIndicator() fileIndicator()
.simultaneousGesture(TapGesture().onEnded(fileAction)) .onTapGesture(perform: fileAction)
} else { } else {
let metaReserve = edited let metaReserve = edited
? " " ? " "
: " " : " "
HStack(alignment: .bottom, spacing: 6) { Button(action: fileAction) {
fileIndicator() HStack(alignment: .bottom, spacing: 6) {
.padding(.top, 5) fileIndicator()
.padding(.bottom, 3) .padding(.top, 5)
if let file = file { .padding(.bottom, 3)
let prettyFileSize = ByteCountFormatter.string(fromByteCount: file.fileSize, countStyle: .binary) if let file = file {
VStack(alignment: .leading, spacing: 2) { let prettyFileSize = ByteCountFormatter.string(fromByteCount: file.fileSize, countStyle: .binary)
Text(file.fileName) VStack(alignment: .leading, spacing: 2) {
.lineLimit(1) Text(file.fileName)
.multilineTextAlignment(.leading) .lineLimit(1)
.foregroundColor(theme.colors.onBackground) .multilineTextAlignment(.leading)
Text(prettyFileSize + metaReserve) .foregroundColor(theme.colors.onBackground)
.font(.caption) Text(prettyFileSize + metaReserve)
.lineLimit(1) .font(.caption)
.multilineTextAlignment(.leading) .lineLimit(1)
.foregroundColor(theme.colors.secondary) .multilineTextAlignment(.leading)
.foregroundColor(theme.colors.secondary)
}
} else {
Text(metaReserve)
} }
} else {
Text(metaReserve)
} }
.padding(.top, 4)
.padding(.bottom, 6)
.padding(.leading, 10)
.padding(.trailing, 12)
} }
.padding(.top, 4)
.padding(.bottom, 6)
.padding(.leading, 10)
.padding(.trailing, 12)
.simultaneousGesture(TapGesture().onEnded(fileAction))
.disabled(!itemInteractive) .disabled(!itemInteractive)
} }
} }
@inline(__always)
private var itemInteractive: Bool { private var itemInteractive: Bool {
if let file = file { if let file = file {
switch (file.fileStatus) { switch (file.fileStatus) {

View file

@ -84,12 +84,12 @@ struct CIGroupInvitationView: View {
} }
if action { if action {
v.simultaneousGesture(TapGesture().onEnded { v.onTapGesture {
inProgress = true inProgress = true
joinGroup(groupInvitation.groupId) { joinGroup(groupInvitation.groupId) {
await MainActor.run { inProgress = false } await MainActor.run { inProgress = false }
} }
}) }
.disabled(inProgress) .disabled(inProgress)
} else { } else {
v v

View file

@ -31,9 +31,7 @@ struct CIImageView: View {
.if(!smallView) { view in .if(!smallView) { view in
view.modifier(PrivacyBlur(blurred: $blurred)) view.modifier(PrivacyBlur(blurred: $blurred))
} }
.if(!blurred) { v in .onTapGesture { showFullScreenImage = true }
v.simultaneousGesture(TapGesture().onEnded { showFullScreenImage = true })
}
.onChange(of: m.activeCallViewIsCollapsed) { _ in .onChange(of: m.activeCallViewIsCollapsed) { _ in
showFullScreenImage = false showFullScreenImage = false
} }
@ -45,7 +43,7 @@ struct CIImageView: View {
imageView(preview).modifier(PrivacyBlur(blurred: $blurred)) imageView(preview).modifier(PrivacyBlur(blurred: $blurred))
} }
} }
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
if let file = file { if let file = file {
switch file.fileStatus { switch file.fileStatus {
case .rcvInvitation, .rcvAborted: case .rcvInvitation, .rcvAborted:
@ -82,7 +80,7 @@ struct CIImageView: View {
default: () default: ()
} }
} }
}) }
} }
} }
.onDisappear { .onDisappear {

View file

@ -7,11 +7,10 @@
// //
import SwiftUI import SwiftUI
import SimpleXChat
struct CIInvalidJSONView: View { struct CIInvalidJSONView: View {
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
var json: Data? var json: String
@State private var showJSON = false @State private var showJSON = false
var body: some View { var body: some View {
@ -24,16 +23,16 @@ struct CIInvalidJSONView: View {
.padding(.vertical, 6) .padding(.vertical, 6)
.background(Color(uiColor: .tertiarySystemGroupedBackground)) .background(Color(uiColor: .tertiarySystemGroupedBackground))
.textSelection(.disabled) .textSelection(.disabled)
.simultaneousGesture(TapGesture().onEnded { showJSON = true }) .onTapGesture { showJSON = true }
.appSheet(isPresented: $showJSON) { .appSheet(isPresented: $showJSON) {
invalidJSONView(dataToString(json)) invalidJSONView(json)
} }
} }
} }
func invalidJSONView(_ json: String) -> some View { func invalidJSONView(_ json: String) -> some View {
VStack(alignment: .leading, spacing: 16) { VStack(alignment: .leading, spacing: 16) {
Button { // this is used in the sheet, Button works here Button {
showShareSheet(items: [json]) showShareSheet(items: [json])
} label: { } label: {
Image(systemName: "square.and.arrow.up") Image(systemName: "square.and.arrow.up")
@ -50,6 +49,6 @@ func invalidJSONView(_ json: String) -> some View {
struct CIInvalidJSONView_Previews: PreviewProvider { struct CIInvalidJSONView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
CIInvalidJSONView(json: "{}".data(using: .utf8)!) CIInvalidJSONView(json: "{}")
} }
} }

View file

@ -21,15 +21,15 @@ struct CILinkView: View {
.resizable() .resizable()
.scaledToFit() .scaledToFit()
.modifier(PrivacyBlur(blurred: $blurred)) .modifier(PrivacyBlur(blurred: $blurred))
.if(!blurred) { v in
v.simultaneousGesture(TapGesture().onEnded {
openBrowserAlert(uri: linkPreview.uri)
})
}
} }
VStack(alignment: .leading, spacing: 6) { VStack(alignment: .leading, spacing: 6) {
Text(linkPreview.title) Text(linkPreview.title)
.lineLimit(3) .lineLimit(3)
// if linkPreview.description != "" {
// Text(linkPreview.description)
// .font(.subheadline)
// .lineLimit(12)
// }
Text(linkPreview.uri.absoluteString) Text(linkPreview.uri.absoluteString)
.font(.caption) .font(.caption)
.lineLimit(1) .lineLimit(1)
@ -37,32 +37,10 @@ struct CILinkView: View {
} }
.padding(.horizontal, 12) .padding(.horizontal, 12)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
.simultaneousGesture(TapGesture().onEnded {
openBrowserAlert(uri: linkPreview.uri)
})
} }
} }
} }
func openBrowserAlert(uri: URL) {
showAlert(
NSLocalizedString("Open link?", comment: "alert title"),
message: uri.absoluteString,
actions: {[
UIAlertAction(
title: NSLocalizedString("Cancel", comment: "alert action"),
style: .default,
handler: { _ in }
),
UIAlertAction(
title: NSLocalizedString("Open", comment: "alert action"),
style: .default,
handler: { _ in UIApplication.shared.open(uri) }
)
]}
)
}
struct LargeLinkPreview_Previews: PreviewProvider { struct LargeLinkPreview_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
let preview = LinkPreview( let preview = LinkPreview(

View file

@ -20,11 +20,12 @@ struct CIMemberCreatedContactView: View {
case let .groupRcv(groupMember): case let .groupRcv(groupMember):
if let contactId = groupMember.memberContactId { if let contactId = groupMember.memberContactId {
memberCreatedContactView(openText: "Open") memberCreatedContactView(openText: "Open")
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
ItemsModel.shared.loadOpenChat("@\(contactId)") { dismissAllSheets(animated: true)
dismissAllSheets(animated: true) DispatchQueue.main.async {
ItemsModel.shared.loadOpenChat("@\(contactId)")
} }
}) }
} else { } else {
memberCreatedContactView() memberCreatedContactView()
} }

View file

@ -15,7 +15,7 @@ struct CIMetaView: View {
@Environment(\.showTimestamp) var showTimestamp: Bool @Environment(\.showTimestamp) var showTimestamp: Bool
var chatItem: ChatItem var chatItem: ChatItem
var metaColor: Color var metaColor: Color
var paleMetaColor = Color(uiColor: .tertiaryLabel) var paleMetaColor = Color(UIColor.tertiaryLabel)
var showStatus = true var showStatus = true
var showEdited = true var showEdited = true
var invertedMaterial = false var invertedMaterial = false
@ -152,13 +152,11 @@ func ciMetaText(
return r.font(.caption) return r.font(.caption)
} }
@inline(__always)
private func statusIconText(_ icon: String, _ color: Color?) -> Text { private func statusIconText(_ icon: String, _ color: Color?) -> Text {
colored(Text(Image(systemName: icon)), color) colored(Text(Image(systemName: icon)), color)
} }
// Applying `foregroundColor(nil)` breaks `.invertedForegroundStyle` modifier // Applying `foregroundColor(nil)` breaks `.invertedForegroundStyle` modifier
@inline(__always)
private func colored(_ t: Text, _ color: Color?) -> Text { private func colored(_ t: Text, _ color: Color?) -> Text {
if let color { if let color {
t.foregroundColor(color) t.foregroundColor(color)

View file

@ -68,7 +68,7 @@ struct CIRcvDecryptionError: View {
} }
} }
private func viewBody() -> some View { @ViewBuilder private func viewBody() -> some View {
Group { Group {
if case let .direct(contact) = chat.chatInfo, if case let .direct(contact) = chat.chatInfo,
let contactStats = contact.activeConn?.connectionStats { let contactStats = contact.activeConn?.connectionStats {
@ -133,7 +133,7 @@ struct CIRcvDecryptionError: View {
CIMetaView(chat: chat, chatItem: chatItem, metaColor: theme.colors.secondary) CIMetaView(chat: chat, chatItem: chatItem, metaColor: theme.colors.secondary)
.padding(.horizontal, 12) .padding(.horizontal, 12)
} }
.simultaneousGesture(TapGesture().onEnded(onClick)) .onTapGesture(perform: { onClick() })
.padding(.vertical, 6) .padding(.vertical, 6)
.textSelection(.disabled) .textSelection(.disabled)
} }
@ -151,7 +151,7 @@ struct CIRcvDecryptionError: View {
CIMetaView(chat: chat, chatItem: chatItem, metaColor: theme.colors.secondary) CIMetaView(chat: chat, chatItem: chatItem, metaColor: theme.colors.secondary)
.padding(.horizontal, 12) .padding(.horizontal, 12)
} }
.simultaneousGesture(TapGesture().onEnded(onClick)) .onTapGesture(perform: { onClick() })
.padding(.vertical, 6) .padding(.vertical, 6)
.textSelection(.disabled) .textSelection(.disabled)
} }
@ -161,13 +161,13 @@ struct CIRcvDecryptionError: View {
let why = Text(decryptErrorReason) let why = Text(decryptErrorReason)
switch msgDecryptError { switch msgDecryptError {
case .ratchetHeader: case .ratchetHeader:
message = Text("\(msgCount) messages failed to decrypt.") + textNewLine + why message = Text("\(msgCount) messages failed to decrypt.") + Text("\n") + why
case .tooManySkipped: case .tooManySkipped:
message = Text("\(msgCount) messages skipped.") + textNewLine + why message = Text("\(msgCount) messages skipped.") + Text("\n") + why
case .ratchetEarlier: case .ratchetEarlier:
message = Text("\(msgCount) messages failed to decrypt.") + textNewLine + why message = Text("\(msgCount) messages failed to decrypt.") + Text("\n") + why
case .other: case .other:
message = Text("\(msgCount) messages failed to decrypt.") + textNewLine + why message = Text("\(msgCount) messages failed to decrypt.") + Text("\n") + why
case .ratchetSync: case .ratchetSync:
message = Text("Encryption re-negotiation failed.") message = Text("Encryption re-negotiation failed.")
} }

View file

@ -47,57 +47,57 @@ struct CIVideoView: View {
let file = chatItem.file let file = chatItem.file
ZStack(alignment: smallView ? .topLeading : .center) { ZStack(alignment: smallView ? .topLeading : .center) {
ZStack(alignment: .topLeading) { ZStack(alignment: .topLeading) {
if let file, let preview { if let file = file, let preview = preview, let decrypted = urlDecrypted, smallView {
if let urlDecrypted { smallVideoView(decrypted, file, preview)
if smallView { } else if let file = file, let preview = preview, let player = player, let decrypted = urlDecrypted {
smallVideoView(urlDecrypted, file, preview) videoView(player, decrypted, file, preview, duration)
} else if let player { } else if let file = file, let defaultPreview = preview, file.loaded && urlDecrypted == nil, smallView {
videoView(player, urlDecrypted, file, preview, duration) smallVideoViewEncrypted(file, defaultPreview)
} } else if let file = file, let defaultPreview = preview, file.loaded && urlDecrypted == nil {
} else if file.loaded { videoViewEncrypted(file, defaultPreview, duration)
if smallView { } else if let preview, let file {
smallVideoViewEncrypted(file, preview) Group { if smallView { smallViewImageView(preview, file) } else { imageView(preview) } }
} else { .onTapGesture {
videoViewEncrypted(file, preview, duration) switch file.fileStatus {
} case .rcvInvitation, .rcvAborted:
} else { receiveFileIfValidSize(file: file, receiveFile: receiveFile)
Group { if smallView { smallViewImageView(preview, file) } else { imageView(preview) } } case .rcvAccepted:
.simultaneousGesture(TapGesture().onEnded { switch file.fileProtocol {
switch file.fileStatus { case .xftp:
case .rcvInvitation, .rcvAborted: AlertManager.shared.showAlertMsg(
receiveFileIfValidSize(file: file, receiveFile: receiveFile) title: "Waiting for video",
case .rcvAccepted: message: "Video will be received when your contact completes uploading it."
switch file.fileProtocol { )
case .xftp: case .smp:
AlertManager.shared.showAlertMsg( AlertManager.shared.showAlertMsg(
title: "Waiting for video", title: "Waiting for video",
message: "Video will be received when your contact completes uploading it." message: "Video will be received when your contact is online, please wait or check later!"
) )
case .smp: case .local: ()
AlertManager.shared.showAlertMsg(
title: "Waiting for video",
message: "Video will be received when your contact is online, please wait or check later!"
)
case .local: ()
}
case .rcvTransfer: () // ?
case .rcvComplete: () // ?
case .rcvCancelled: () // TODO
default: ()
} }
}) case .rcvTransfer: () // ?
} case .rcvComplete: () // ?
case .rcvCancelled: () // TODO
default: ()
}
}
} }
if !smallView { if !smallView {
durationProgress() durationProgress()
} }
} }
if !blurred, let file, showDownloadButton(file.fileStatus) { if !blurred, let file, showDownloadButton(file.fileStatus) {
if !smallView || !file.showStatusIconInSmallView { if !smallView {
Button {
receiveFileIfValidSize(file: file, receiveFile: receiveFile)
} label: {
playPauseIcon("play.fill")
}
} else if !file.showStatusIconInSmallView {
playPauseIcon("play.fill") playPauseIcon("play.fill")
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
receiveFileIfValidSize(file: file, receiveFile: receiveFile) receiveFileIfValidSize(file: file, receiveFile: receiveFile)
}) }
} }
} }
} }
@ -151,26 +151,27 @@ struct CIVideoView: View {
ZStack(alignment: .center) { ZStack(alignment: .center) {
let canBePlayed = !chatItem.chatDir.sent || file.fileStatus == CIFileStatus.sndComplete || (file.fileStatus == .sndStored && file.fileProtocol == .local) let canBePlayed = !chatItem.chatDir.sent || file.fileStatus == CIFileStatus.sndComplete || (file.fileStatus == .sndStored && file.fileProtocol == .local)
imageView(defaultPreview) imageView(defaultPreview)
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
decrypt(file: file) { decrypt(file: file) {
showFullScreenPlayer = urlDecrypted != nil showFullScreenPlayer = urlDecrypted != nil
} }
}) }
.onChange(of: m.activeCallViewIsCollapsed) { _ in .onChange(of: m.activeCallViewIsCollapsed) { _ in
showFullScreenPlayer = false showFullScreenPlayer = false
} }
if !blurred { if !blurred {
if !decryptionInProgress { if !decryptionInProgress {
playPauseIcon(canBePlayed ? "play.fill" : "play.slash") Button {
.simultaneousGesture(TapGesture().onEnded { decrypt(file: file) {
decrypt(file: file) { if urlDecrypted != nil {
if urlDecrypted != nil { videoPlaying = true
videoPlaying = true player?.play()
player?.play()
}
} }
}) }
.disabled(!canBePlayed) } label: {
playPauseIcon(canBePlayed ? "play.fill" : "play.slash")
}
.disabled(!canBePlayed)
} else { } else {
videoDecryptionProgress() videoDecryptionProgress()
} }
@ -193,30 +194,29 @@ struct CIVideoView: View {
} }
} }
.modifier(PrivacyBlur(enabled: !videoPlaying, blurred: $blurred)) .modifier(PrivacyBlur(enabled: !videoPlaying, blurred: $blurred))
.if(!blurred) { v in .onTapGesture {
v.simultaneousGesture(TapGesture().onEnded { switch player.timeControlStatus {
switch player.timeControlStatus { case .playing:
case .playing: player.pause()
player.pause() videoPlaying = false
videoPlaying = false case .paused:
case .paused: if canBePlayed {
if canBePlayed { showFullScreenPlayer = true
showFullScreenPlayer = true
}
default: ()
} }
}) default: ()
}
} }
.onChange(of: m.activeCallViewIsCollapsed) { _ in .onChange(of: m.activeCallViewIsCollapsed) { _ in
showFullScreenPlayer = false showFullScreenPlayer = false
} }
if !videoPlaying && !blurred { if !videoPlaying && !blurred {
playPauseIcon(canBePlayed ? "play.fill" : "play.slash") Button {
.simultaneousGesture(TapGesture().onEnded { m.stopPreviousRecPlay = url
m.stopPreviousRecPlay = url player.play()
player.play() } label: {
}) playPauseIcon(canBePlayed ? "play.fill" : "play.slash")
.disabled(!canBePlayed) }
.disabled(!canBePlayed)
} }
} }
fileStatusIcon() fileStatusIcon()
@ -235,7 +235,7 @@ struct CIVideoView: View {
return ZStack(alignment: .topLeading) { return ZStack(alignment: .topLeading) {
let canBePlayed = !chatItem.chatDir.sent || file.fileStatus == CIFileStatus.sndComplete || (file.fileStatus == .sndStored && file.fileProtocol == .local) let canBePlayed = !chatItem.chatDir.sent || file.fileStatus == CIFileStatus.sndComplete || (file.fileStatus == .sndStored && file.fileProtocol == .local)
smallViewImageView(preview, file) smallViewImageView(preview, file)
.onTapGesture { // this is shown in chat list, where onTapGesture works .onTapGesture {
decrypt(file: file) { decrypt(file: file) {
showFullScreenPlayer = urlDecrypted != nil showFullScreenPlayer = urlDecrypted != nil
} }
@ -256,7 +256,7 @@ struct CIVideoView: View {
private func smallVideoView(_ url: URL, _ file: CIFile, _ preview: UIImage) -> some View { private func smallVideoView(_ url: URL, _ file: CIFile, _ preview: UIImage) -> some View {
return ZStack(alignment: .topLeading) { return ZStack(alignment: .topLeading) {
smallViewImageView(preview, file) smallViewImageView(preview, file)
.onTapGesture { // this is shown in chat list, where onTapGesture works .onTapGesture {
showFullScreenPlayer = true showFullScreenPlayer = true
} }
.onChange(of: m.activeCallViewIsCollapsed) { _ in .onChange(of: m.activeCallViewIsCollapsed) { _ in
@ -354,14 +354,14 @@ struct CIVideoView: View {
case .sndCancelled: fileIcon("xmark", 10, 13) case .sndCancelled: fileIcon("xmark", 10, 13)
case let .sndError(sndFileError): case let .sndError(sndFileError):
fileIcon("xmark", 10, 13) fileIcon("xmark", 10, 13)
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
showFileErrorAlert(sndFileError) showFileErrorAlert(sndFileError)
}) }
case let .sndWarning(sndFileError): case let .sndWarning(sndFileError):
fileIcon("exclamationmark.triangle.fill", 10, 13) fileIcon("exclamationmark.triangle.fill", 10, 13)
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
showFileErrorAlert(sndFileError, temporary: true) showFileErrorAlert(sndFileError, temporary: true)
}) }
case .rcvInvitation: fileIcon("arrow.down", 10, 13) case .rcvInvitation: fileIcon("arrow.down", 10, 13)
case .rcvAccepted: fileIcon("ellipsis", 14, 11) case .rcvAccepted: fileIcon("ellipsis", 14, 11)
case let .rcvTransfer(rcvProgress, rcvTotal): case let .rcvTransfer(rcvProgress, rcvTotal):
@ -375,14 +375,14 @@ struct CIVideoView: View {
case .rcvCancelled: fileIcon("xmark", 10, 13) case .rcvCancelled: fileIcon("xmark", 10, 13)
case let .rcvError(rcvFileError): case let .rcvError(rcvFileError):
fileIcon("xmark", 10, 13) fileIcon("xmark", 10, 13)
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
showFileErrorAlert(rcvFileError) showFileErrorAlert(rcvFileError)
}) }
case let .rcvWarning(rcvFileError): case let .rcvWarning(rcvFileError):
fileIcon("exclamationmark.triangle.fill", 10, 13) fileIcon("exclamationmark.triangle.fill", 10, 13)
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
showFileErrorAlert(rcvFileError, temporary: true) showFileErrorAlert(rcvFileError, temporary: true)
}) }
case .invalid: fileIcon("questionmark", 10, 13) case .invalid: fileIcon("questionmark", 10, 13)
} }
} }
@ -429,7 +429,7 @@ struct CIVideoView: View {
Color.black.edgesIgnoringSafeArea(.all) Color.black.edgesIgnoringSafeArea(.all)
VideoPlayer(player: fullPlayer) VideoPlayer(player: fullPlayer)
.overlay(alignment: .topLeading, content: { .overlay(alignment: .topLeading, content: {
Button(action: { showFullScreenPlayer = false }, // this is used in full screen player, Button works here Button(action: { showFullScreenPlayer = false },
label: { label: {
Image(systemName: "multiply") Image(systemName: "multiply")
.resizable() .resizable()

View file

@ -168,14 +168,14 @@ struct VoiceMessagePlayer: View {
case .sndCancelled: playbackButton() case .sndCancelled: playbackButton()
case let .sndError(sndFileError): case let .sndError(sndFileError):
fileStatusIcon("multiply", 14) fileStatusIcon("multiply", 14)
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
showFileErrorAlert(sndFileError) showFileErrorAlert(sndFileError)
}) }
case let .sndWarning(sndFileError): case let .sndWarning(sndFileError):
fileStatusIcon("exclamationmark.triangle.fill", 16) fileStatusIcon("exclamationmark.triangle.fill", 16)
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
showFileErrorAlert(sndFileError, temporary: true) showFileErrorAlert(sndFileError, temporary: true)
}) }
case .rcvInvitation: downloadButton(recordingFile, "play.fill") case .rcvInvitation: downloadButton(recordingFile, "play.fill")
case .rcvAccepted: loadingIcon() case .rcvAccepted: loadingIcon()
case .rcvTransfer: loadingIcon() case .rcvTransfer: loadingIcon()
@ -184,14 +184,14 @@ struct VoiceMessagePlayer: View {
case .rcvCancelled: playPauseIcon("play.fill", Color(uiColor: .tertiaryLabel)) case .rcvCancelled: playPauseIcon("play.fill", Color(uiColor: .tertiaryLabel))
case let .rcvError(rcvFileError): case let .rcvError(rcvFileError):
fileStatusIcon("multiply", 14) fileStatusIcon("multiply", 14)
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
showFileErrorAlert(rcvFileError) showFileErrorAlert(rcvFileError)
}) }
case let .rcvWarning(rcvFileError): case let .rcvWarning(rcvFileError):
fileStatusIcon("exclamationmark.triangle.fill", 16) fileStatusIcon("exclamationmark.triangle.fill", 16)
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
showFileErrorAlert(rcvFileError, temporary: true) showFileErrorAlert(rcvFileError, temporary: true)
}) }
case .invalid: playPauseIcon("play.fill", Color(uiColor: .tertiaryLabel)) case .invalid: playPauseIcon("play.fill", Color(uiColor: .tertiaryLabel))
} }
} else { } else {
@ -255,29 +255,59 @@ struct VoiceMessagePlayer: View {
} }
} }
private func playbackButton() -> some View { @ViewBuilder private func playbackButton() -> some View {
let icon = switch playbackState { if sizeMultiplier != 1 {
case .noPlayback: "play.fill" switch playbackState {
case .playing: "pause.fill" case .noPlayback:
case .paused: "play.fill" playPauseIcon("play.fill", theme.colors.primary)
} .onTapGesture {
return playPauseIcon(icon, theme.colors.primary) if let recordingSource = getLoadedFileSource(recordingFile) {
.simultaneousGesture(TapGesture().onEnded { _ in startPlayback(recordingSource)
switch playbackState { }
case .noPlayback: }
case .playing:
playPauseIcon("pause.fill", theme.colors.primary)
.onTapGesture {
audioPlayer?.pause()
playbackState = .paused
notifyStateChange()
}
case .paused:
playPauseIcon("play.fill", theme.colors.primary)
.onTapGesture {
audioPlayer?.play()
playbackState = .playing
notifyStateChange()
}
}
} else {
switch playbackState {
case .noPlayback:
Button {
if let recordingSource = getLoadedFileSource(recordingFile) { if let recordingSource = getLoadedFileSource(recordingFile) {
startPlayback(recordingSource) startPlayback(recordingSource)
} }
case .playing: } label: {
playPauseIcon("play.fill", theme.colors.primary)
}
case .playing:
Button {
audioPlayer?.pause() audioPlayer?.pause()
playbackState = .paused playbackState = .paused
notifyStateChange() notifyStateChange()
case .paused: } label: {
playPauseIcon("pause.fill", theme.colors.primary)
}
case .paused:
Button {
audioPlayer?.play() audioPlayer?.play()
playbackState = .playing playbackState = .playing
notifyStateChange() notifyStateChange()
} label: {
playPauseIcon("play.fill", theme.colors.primary)
} }
}) }
}
} }
private func playPauseIcon(_ image: String, _ color: Color/* = .accentColor*/) -> some View { private func playPauseIcon(_ image: String, _ color: Color/* = .accentColor*/) -> some View {
@ -299,14 +329,28 @@ struct VoiceMessagePlayer: View {
} }
private func downloadButton(_ recordingFile: CIFile, _ icon: String) -> some View { private func downloadButton(_ recordingFile: CIFile, _ icon: String) -> some View {
playPauseIcon(icon, theme.colors.primary) Group {
.simultaneousGesture(TapGesture().onEnded { if sizeMultiplier != 1 {
Task { playPauseIcon(icon, theme.colors.primary)
if let user = chatModel.currentUser { .onTapGesture {
await receiveFile(user: user, fileId: recordingFile.fileId) Task {
if let user = chatModel.currentUser {
await receiveFile(user: user, fileId: recordingFile.fileId)
}
}
} }
} else {
Button {
Task {
if let user = chatModel.currentUser {
await receiveFile(user: user, fileId: recordingFile.fileId)
}
}
} label: {
playPauseIcon(icon, theme.colors.primary)
} }
}) }
}
} }
func notifyStateChange() { func notifyStateChange() {
@ -386,7 +430,6 @@ struct VoiceMessagePlayer: View {
} }
} }
@inline(__always)
func voiceMessageSizeBasedOnSquareSize(_ squareSize: CGFloat) -> CGFloat { func voiceMessageSizeBasedOnSquareSize(_ squareSize: CGFloat) -> CGFloat {
let squareToCircleRatio = 0.935 let squareToCircleRatio = 0.935
return squareSize + squareSize * (1 - squareToCircleRatio) return squareSize + squareSize * (1 - squareToCircleRatio)
@ -403,12 +446,10 @@ class VoiceItemState {
self.playbackTime = playbackTime self.playbackTime = playbackTime
} }
@inline(__always)
static func id(_ chat: Chat, _ chatItem: ChatItem) -> String { static func id(_ chat: Chat, _ chatItem: ChatItem) -> String {
"\(chat.id) \(chatItem.id)" "\(chat.id) \(chatItem.id)"
} }
@inline(__always)
static func id(_ chatInfo: ChatInfo, _ chatItem: ChatItem) -> String { static func id(_ chatInfo: ChatInfo, _ chatItem: ChatItem) -> String {
"\(chatInfo.id) \(chatItem.id)" "\(chatInfo.id) \(chatItem.id)"
} }

View file

@ -23,6 +23,8 @@ struct FramedItemView: View {
@State private var useWhiteMetaColor: Bool = false @State private var useWhiteMetaColor: Bool = false
@State var showFullScreenImage = false @State var showFullScreenImage = false
@Binding var allowMenu: Bool @Binding var allowMenu: Bool
@State private var showSecrets = false
@State private var showQuoteSecrets = false
@State private var showFullscreenGallery: Bool = false @State private var showFullscreenGallery: Bool = false
var body: some View { var body: some View {
@ -55,7 +57,7 @@ struct FramedItemView: View {
if let qi = chatItem.quotedItem { if let qi = chatItem.quotedItem {
ciQuoteView(qi) ciQuoteView(qi)
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
if let ci = ItemsModel.shared.reversedChatItems.first(where: { $0.id == qi.itemId }) { if let ci = ItemsModel.shared.reversedChatItems.first(where: { $0.id == qi.itemId }) {
withAnimation { withAnimation {
scrollToItemId(ci.id) scrollToItemId(ci.id)
@ -65,7 +67,7 @@ struct FramedItemView: View {
} else { } else {
showQuotedItemDoesNotExistAlert() showQuotedItemDoesNotExistAlert()
} }
}) }
} else if let itemForwarded = chatItem.meta.itemForwarded { } else if let itemForwarded = chatItem.meta.itemForwarded {
framedItemHeader(icon: "arrowshape.turn.up.forward", caption: Text(itemForwarded.text(chat.chatInfo.chatType)).italic(), pad: true) framedItemHeader(icon: "arrowshape.turn.up.forward", caption: Text(itemForwarded.text(chat.chatInfo.chatType)).italic(), pad: true)
} }
@ -87,19 +89,19 @@ struct FramedItemView: View {
.overlay(DetermineWidth()) .overlay(DetermineWidth())
.accessibilityLabel("") .accessibilityLabel("")
} }
} }
.background { chatItemFrameColorMaybeImageOrVideo(chatItem, theme).modifier(ChatTailPadding()) } .background { chatItemFrameColorMaybeImageOrVideo(chatItem, theme).modifier(ChatTailPadding()) }
.onPreferenceChange(DetermineWidth.Key.self) { msgWidth = $0 } .onPreferenceChange(DetermineWidth.Key.self) { msgWidth = $0 }
if let (title, text) = chatItem.meta.itemStatus.statusInfo { if let (title, text) = chatItem.meta.itemStatus.statusInfo {
v.simultaneousGesture(TapGesture().onEnded { v.onTapGesture {
AlertManager.shared.showAlert( AlertManager.shared.showAlert(
Alert( Alert(
title: Text(title), title: Text(title),
message: Text(text) message: Text(text)
) )
) )
}) }
} else { } else {
v v
} }
@ -157,7 +159,7 @@ struct FramedItemView: View {
case let .file(text): case let .file(text):
ciFileView(chatItem, text) ciFileView(chatItem, text)
case let .report(text, reason): case let .report(text, reason):
ciMsgContentView(chatItem, txtPrefix: reason.attrString) ciMsgContentView(chatItem, Text(text.isEmpty ? reason.text : "\(reason.text): ").italic().foregroundColor(.red))
case let .link(_, preview): case let .link(_, preview):
CILinkView(linkPreview: preview) CILinkView(linkPreview: preview)
ciMsgContentView(chatItem) ciMsgContentView(chatItem)
@ -201,7 +203,6 @@ struct FramedItemView: View {
} }
@ViewBuilder private func ciQuoteView(_ qi: CIQuote) -> some View { @ViewBuilder private func ciQuoteView(_ qi: CIQuote) -> some View {
let backgroundColor = chatItemFrameContextColor(chatItem, theme)
let v = ZStack(alignment: .topTrailing) { let v = ZStack(alignment: .topTrailing) {
switch (qi.content) { switch (qi.content) {
case let .image(_, image): case let .image(_, image):
@ -243,8 +244,7 @@ struct FramedItemView: View {
// if enable this always, size of the framed voice message item will be incorrect after end of playback // if enable this always, size of the framed voice message item will be incorrect after end of playback
.overlay { if case .voice = chatItem.content.msgContent {} else { DetermineWidth() } } .overlay { if case .voice = chatItem.content.msgContent {} else { DetermineWidth() } }
.frame(minWidth: msgWidth, alignment: .leading) .frame(minWidth: msgWidth, alignment: .leading)
.background(backgroundColor) .background(chatItemFrameContextColor(chatItem, theme))
.environment(\.containerBackground, UIColor(backgroundColor))
if let mediaWidth = maxMediaWidth(), mediaWidth < maxWidth { if let mediaWidth = maxMediaWidth(), mediaWidth < maxWidth {
v.frame(maxWidth: mediaWidth, alignment: .leading) v.frame(maxWidth: mediaWidth, alignment: .leading)
} else { } else {
@ -270,12 +270,14 @@ struct FramedItemView: View {
.padding(.top, 6) .padding(.top, 6)
.padding(.horizontal, 12) .padding(.horizontal, 12)
} }
@inline(__always)
private func ciQuotedMsgTextView(_ qi: CIQuote, lines: Int) -> some View { private func ciQuotedMsgTextView(_ qi: CIQuote, lines: Int) -> some View {
MsgContentView(chat: chat, text: qi.text, formattedText: qi.formattedText, textStyle: .subheadline) toggleSecrets(qi.formattedText, $showQuoteSecrets,
.lineLimit(lines) MsgContentView(chat: chat, text: qi.text, formattedText: qi.formattedText, showSecrets: showQuoteSecrets)
.padding(.bottom, 6) .lineLimit(lines)
.font(.subheadline)
.padding(.bottom, 6)
)
} }
private func ciQuoteIconView(_ image: String) -> some View { private func ciQuoteIconView(_ image: String) -> some View {
@ -295,22 +297,21 @@ struct FramedItemView: View {
} }
} }
@ViewBuilder private func ciMsgContentView(_ ci: ChatItem, txtPrefix: NSAttributedString? = nil) -> some View { @ViewBuilder private func ciMsgContentView(_ ci: ChatItem, _ txtPrefix: Text? = nil) -> some View {
let text = ci.meta.isLive ? ci.content.msgContent?.text ?? ci.text : ci.text let text = ci.meta.isLive ? ci.content.msgContent?.text ?? ci.text : ci.text
let rtl = isRightToLeft(text) let rtl = isRightToLeft(text)
let ft = text == "" ? [] : ci.formattedText let ft = text == "" ? [] : ci.formattedText
let v = MsgContentView( let v = toggleSecrets(ft, $showSecrets, MsgContentView(
chat: chat, chat: chat,
text: text, text: text,
formattedText: ft, formattedText: ft,
textStyle: .body,
meta: ci.meta, meta: ci.meta,
mentions: ci.mentions, mentions: ci.mentions,
userMemberId: chat.chatInfo.groupInfo?.membership.memberId, userMemberId: chat.chatInfo.groupInfo?.membership.memberId,
rightToLeft: rtl, rightToLeft: rtl,
showSecrets: showSecrets,
prefix: txtPrefix prefix: txtPrefix
) ))
.environment(\.containerBackground, UIColor(chatItemFrameColor(ci, theme)))
.multilineTextAlignment(rtl ? .trailing : .leading) .multilineTextAlignment(rtl ? .trailing : .leading)
.padding(.vertical, 6) .padding(.vertical, 6)
.padding(.horizontal, 12) .padding(.horizontal, 12)
@ -350,6 +351,14 @@ struct FramedItemView: View {
} }
} }
@ViewBuilder func toggleSecrets<V: View>(_ ft: [FormattedText]?, _ showSecrets: Binding<Bool>, _ v: V) -> some View {
if let ft = ft, ft.contains(where: { $0.isSecret }) {
v.onTapGesture { showSecrets.wrappedValue.toggle() }
} else {
v
}
}
func isRightToLeft(_ s: String) -> Bool { func isRightToLeft(_ s: String) -> Bool {
if let lang = CFStringTokenizerCopyBestStringLanguage(s as CFString, CFRange(location: 0, length: min(s.count, 80))) { if let lang = CFStringTokenizerCopyBestStringLanguage(s as CFString, CFRange(location: 0, length: min(s.count, 80))) {
return NSLocale.characterDirection(forLanguage: lang as String) == .rightToLeft return NSLocale.characterDirection(forLanguage: lang as String) == .rightToLeft

View file

@ -126,7 +126,7 @@ struct FullScreenMediaView: View {
.scaledToFit() .scaledToFit()
} }
} }
.onTapGesture { showView = false } // this is used in full screen view, onTapGesture works .onTapGesture { showView = false }
} }
private func videoView( _ player: AVPlayer, _ url: URL) -> some View { private func videoView( _ player: AVPlayer, _ url: URL) -> some View {

View file

@ -31,8 +31,8 @@ struct IntegrityErrorItemView: View {
case .msgBadHash: case .msgBadHash:
AlertManager.shared.showAlert(Alert( AlertManager.shared.showAlert(Alert(
title: Text("Bad message hash"), title: Text("Bad message hash"),
message: Text("The hash of the previous message is different.") + textNewLine + message: Text("The hash of the previous message is different.") + Text("\n") +
Text(decryptErrorReason) + textNewLine + Text(decryptErrorReason) + Text("\n") +
Text("Please report it to the developers.") Text("Please report it to the developers.")
)) ))
case .msgBadId: msgBadIdAlert() case .msgBadId: msgBadIdAlert()
@ -47,7 +47,7 @@ struct IntegrityErrorItemView: View {
message: Text(""" message: Text("""
The ID of the next message is incorrect (less or equal to the previous). The ID of the next message is incorrect (less or equal to the previous).
It can happen because of some bug or when the connection is compromised. It can happen because of some bug or when the connection is compromised.
""") + textNewLine + """) + Text("\n") +
Text("Please report it to the developers.") Text("Please report it to the developers.")
)) ))
} }
@ -71,7 +71,7 @@ struct CIMsgError: View {
.padding(.vertical, 6) .padding(.vertical, 6)
.background { chatItemFrameColor(chatItem, theme).modifier(ChatTailPadding()) } .background { chatItemFrameColor(chatItem, theme).modifier(ChatTailPadding()) }
.textSelection(.disabled) .textSelection(.disabled)
.simultaneousGesture(TapGesture().onEnded(onTap)) .onTapGesture(perform: onTap)
} }
} }

View file

@ -11,74 +11,53 @@ import SimpleXChat
let uiLinkColor = UIColor(red: 0, green: 0.533, blue: 1, alpha: 1) let uiLinkColor = UIColor(red: 0, green: 0.533, blue: 1, alpha: 1)
private func typing(_ theme: AppTheme, _ descr: UIFontDescriptor, _ ws: [UIFont.Weight]) -> NSMutableAttributedString { private let noTyping = Text(verbatim: " ")
let res = NSMutableAttributedString()
for w in ws { private let typingIndicators: [Text] = [
res.append(NSAttributedString(string: ".", attributes: [ (typing(.black) + typing() + typing()),
.font: UIFont.monospacedSystemFont(ofSize: descr.pointSize, weight: w), (typing(.bold) + typing(.black) + typing()),
.kern: -2 as NSNumber, (typing() + typing(.bold) + typing(.black)),
.foregroundColor: UIColor(theme.colors.secondary) (typing() + typing() + typing(.bold))
])) ]
}
return res private func typing(_ w: Font.Weight = .light) -> Text {
Text(".").fontWeight(w)
} }
struct MsgContentView: View { struct MsgContentView: View {
@ObservedObject var chat: Chat @ObservedObject var chat: Chat
@Environment(\.showTimestamp) var showTimestamp: Bool @Environment(\.showTimestamp) var showTimestamp: Bool
@Environment(\.containerBackground) var containerBackground: UIColor
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
var text: String var text: String
var formattedText: [FormattedText]? = nil var formattedText: [FormattedText]? = nil
var textStyle: UIFont.TextStyle
var sender: String? = nil var sender: String? = nil
var meta: CIMeta? = nil var meta: CIMeta? = nil
var mentions: [String: CIMention]? = nil var mentions: [String: CIMention]? = nil
var userMemberId: String? = nil var userMemberId: String? = nil
var rightToLeft = false var rightToLeft = false
var prefix: NSAttributedString? = nil var showSecrets: Bool
@State private var showSecrets: Set<Int> = [] var prefix: Text? = nil
@State private var typingIdx = 0 @State private var typingIdx = 0
@State private var timer: Timer? @State private var timer: Timer?
@State private var typingIndicators: [NSAttributedString] = []
@State private var noTyping = NSAttributedString(string: " ")
@State private var phase: CGFloat = 0
@AppStorage(DEFAULT_SHOW_SENT_VIA_RPOXY) private var showSentViaProxy = false @AppStorage(DEFAULT_SHOW_SENT_VIA_RPOXY) private var showSentViaProxy = false
var body: some View { var body: some View {
let v = msgContentView()
if meta?.isLive == true { if meta?.isLive == true {
v.onAppear { msgContentView()
let descr = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body) .onAppear { switchTyping() }
noTyping = NSAttributedString(string: " ", attributes: [
.font: UIFont.monospacedSystemFont(ofSize: descr.pointSize, weight: .regular),
.kern: -2 as NSNumber,
.foregroundColor: UIColor(theme.colors.secondary)
])
switchTyping()
}
.onDisappear(perform: stopTyping) .onDisappear(perform: stopTyping)
.onChange(of: meta?.isLive, perform: switchTyping) .onChange(of: meta?.isLive, perform: switchTyping)
.onChange(of: meta?.recent, perform: switchTyping) .onChange(of: meta?.recent, perform: switchTyping)
} else { } else {
v msgContentView()
} }
} }
private func switchTyping(_: Bool? = nil) { private func switchTyping(_: Bool? = nil) {
if let meta = meta, meta.isLive && meta.recent { if let meta = meta, meta.isLive && meta.recent {
if typingIndicators.isEmpty {
let descr = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .body)
typingIndicators = [
typing(theme, descr, [.black, .light, .light]),
typing(theme, descr, [.bold, .black, .light]),
typing(theme, descr, [.light, .bold, .black]),
typing(theme, descr, [.light, .light, .bold])
]
}
timer = timer ?? Timer.scheduledTimer(withTimeInterval: 0.25, repeats: true) { _ in timer = timer ?? Timer.scheduledTimer(withTimeInterval: 0.25, repeats: true) { _ in
typingIdx = typingIdx + 1 typingIdx = (typingIdx + 1) % typingIndicators.count
} }
} else { } else {
stopTyping() stopTyping()
@ -88,276 +67,119 @@ struct MsgContentView: View {
private func stopTyping() { private func stopTyping() {
timer?.invalidate() timer?.invalidate()
timer = nil timer = nil
typingIdx = 0
} }
@inline(__always) private func msgContentView() -> Text {
private func msgContentView() -> some View { var v = messageText(text, formattedText, sender, mentions: mentions, userMemberId: userMemberId, showSecrets: showSecrets, secondaryColor: theme.colors.secondary, prefix: prefix)
let r = messageText(text, formattedText, textStyle: textStyle, sender: sender, mentions: mentions, userMemberId: userMemberId, showSecrets: showSecrets, backgroundColor: containerBackground, prefix: prefix)
let s = r.string
let t: Text
if let mt = meta { if let mt = meta {
if mt.isLive { if mt.isLive {
s.append(typingIndicator(mt.recent)) v = v + typingIndicator(mt.recent)
} }
t = Text(AttributedString(s)) + reserveSpaceForMeta(mt) v = v + reserveSpaceForMeta(mt)
} else {
t = Text(AttributedString(s))
} }
return msgTextResultView(r, t, showSecrets: $showSecrets) return v
} }
@inline(__always) private func typingIndicator(_ recent: Bool) -> Text {
private func typingIndicator(_ recent: Bool) -> NSAttributedString { return (recent ? typingIndicators[typingIdx] : noTyping)
recent && !typingIndicators.isEmpty .font(.body.monospaced())
? typingIndicators[typingIdx % 4] .kerning(-2)
: noTyping .foregroundColor(theme.colors.secondary)
} }
@inline(__always)
private func reserveSpaceForMeta(_ mt: CIMeta) -> Text { private func reserveSpaceForMeta(_ mt: CIMeta) -> Text {
(rightToLeft ? textNewLine : Text(verbatim: " ")) + ciMetaText(mt, chatTTL: chat.chatInfo.timedMessagesTTL, encrypted: nil, colorMode: .transparent, showViaProxy: showSentViaProxy, showTimesamp: showTimestamp) (rightToLeft ? Text("\n") : Text(verbatim: " ")) + ciMetaText(mt, chatTTL: chat.chatInfo.timedMessagesTTL, encrypted: nil, colorMode: .transparent, showViaProxy: showSentViaProxy, showTimesamp: showTimestamp)
} }
} }
func msgTextResultView(_ r: MsgTextResult, _ t: Text, showSecrets: Binding<Set<Int>>? = nil) -> some View { func messageText(_ text: String, _ formattedText: [FormattedText]?, _ sender: String?, icon: String? = nil, preview: Bool = false, mentions: [String: CIMention]?, userMemberId: String?, showSecrets: Bool, secondaryColor: Color, prefix: Text? = nil) -> Text {
t.if(r.hasSecrets, transform: hiddenSecretsView) let s = text
.if(r.handleTaps) { $0.overlay(handleTextTaps(r.string, showSecrets: showSecrets)) } var res: Text
}
if let ft = formattedText, ft.count > 0 && ft.count <= 200 {
@inline(__always) res = formatText(ft[0], preview, showSecret: showSecrets, mentions: mentions, userMemberId: userMemberId)
private func handleTextTaps(_ s: NSAttributedString, showSecrets: Binding<Set<Int>>? = nil) -> some View { var i = 1
return GeometryReader { g in while i < ft.count {
Rectangle() res = res + formatText(ft[i], preview, showSecret: showSecrets, mentions: mentions, userMemberId: userMemberId)
.fill(Color.clear) i = i + 1
.contentShape(Rectangle())
.simultaneousGesture(DragGesture(minimumDistance: 0).onEnded { event in
let t = event.translation
if t.width * t.width + t.height * t.height > 100 { return }
let framesetter = CTFramesetterCreateWithAttributedString(s as CFAttributedString)
let path = CGPath(rect: CGRect(origin: .zero, size: g.size), transform: nil)
let frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, s.length), path, nil)
let point = CGPoint(x: event.location.x, y: g.size.height - event.location.y) // Flip y for UIKit
var index: CFIndex?
if let lines = CTFrameGetLines(frame) as? [CTLine] {
var origins = [CGPoint](repeating: .zero, count: lines.count)
CTFrameGetLineOrigins(frame, CFRangeMake(0, 0), &origins)
for i in 0 ..< lines.count {
let bounds = CTLineGetBoundsWithOptions(lines[i], .useOpticalBounds)
if bounds.offsetBy(dx: origins[i].x, dy: origins[i].y).contains(point) {
index = CTLineGetStringIndexForPosition(lines[i], point)
break
}
}
}
if let index, let (url, browser) = attributedStringLink(s, for: index) {
if browser {
openBrowserAlert(uri: url)
} else {
UIApplication.shared.open(url)
}
}
})
}
func attributedStringLink(_ s: NSAttributedString, for index: CFIndex) -> (URL, Bool)? {
var linkURL: URL?
var browser: Bool = false
s.enumerateAttributes(in: NSRange(location: 0, length: s.length)) { attrs, range, stop in
if index >= range.location && index < range.location + range.length {
if let url = attrs[linkAttrKey] as? NSURL {
linkURL = url.absoluteURL
browser = attrs[webLinkAttrKey] != nil
} else if let showSecrets, let i = attrs[secretAttrKey] as? Int {
if showSecrets.wrappedValue.contains(i) {
showSecrets.wrappedValue.remove(i)
} else {
showSecrets.wrappedValue.insert(i)
}
}
stop.pointee = true
}
}
return if let linkURL { (linkURL, browser) } else { nil }
}
}
func hiddenSecretsView<V: View>(_ v: V) -> some View {
v.overlay(
GeometryReader { g in
let size = (g.size.width + g.size.height) / 1.4142
Image("vertical_logo")
.resizable(resizingMode: .tile)
.frame(width: size, height: size)
.rotationEffect(.degrees(45), anchor: .center)
.position(x: g.size.width / 2, y: g.size.height / 2)
.clipped()
.saturation(0.65)
.opacity(0.35)
}
.mask(v)
)
}
private let linkAttrKey = NSAttributedString.Key("chat.simplex.app.link")
private let webLinkAttrKey = NSAttributedString.Key("chat.simplex.app.webLink")
private let secretAttrKey = NSAttributedString.Key("chat.simplex.app.secret")
typealias MsgTextResult = (string: NSMutableAttributedString, hasSecrets: Bool, handleTaps: Bool)
func messageText(
_ text: String,
_ formattedText: [FormattedText]?,
textStyle: UIFont.TextStyle = .body,
sender: String?,
preview: Bool = false,
mentions: [String: CIMention]?,
userMemberId: String?,
showSecrets: Set<Int>?,
backgroundColor: UIColor,
prefix: NSAttributedString? = nil
) -> MsgTextResult {
let res = NSMutableAttributedString()
let descr = UIFontDescriptor.preferredFontDescriptor(withTextStyle: textStyle)
let font = UIFont.preferredFont(forTextStyle: textStyle)
let plain: [NSAttributedString.Key: Any] = [
.font: font,
.foregroundColor: UIColor.label
]
let secretColor = backgroundColor.withAlphaComponent(1)
var link: [NSAttributedString.Key: Any]?
var hasSecrets = false
var handleTaps = false
if let sender {
if preview {
res.append(NSAttributedString(string: sender + ": ", attributes: plain))
} else {
var attrs = plain
attrs[.font] = UIFont(descriptor: descr.addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: UIFont.Weight.medium]]), size: descr.pointSize)
res.append(NSAttributedString(string: sender, attributes: attrs))
res.append(NSAttributedString(string: ": ", attributes: plain))
}
}
if let prefix {
res.append(prefix)
}
if let fts = formattedText, fts.count > 0 {
var bold: UIFont?
var italic: UIFont?
var snippet: UIFont?
var mention: UIFont?
var secretIdx: Int = 0
for ft in fts {
var t = ft.text
var attrs = plain
switch (ft.format) {
case .bold:
bold = bold ?? UIFont(descriptor: descr.addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: UIFont.Weight.bold]]), size: descr.pointSize)
attrs[.font] = bold
case .italic:
italic = italic ?? UIFont(descriptor: descr.withSymbolicTraits(.traitItalic) ?? descr, size: descr.pointSize)
attrs[.font] = italic
case .strikeThrough:
attrs[.strikethroughStyle] = NSUnderlineStyle.single.rawValue
case .snippet:
snippet = snippet ?? UIFont.monospacedSystemFont(ofSize: descr.pointSize, weight: .regular)
attrs[.font] = snippet
case .secret:
if let showSecrets {
if !showSecrets.contains(secretIdx) {
attrs[.foregroundColor] = UIColor.clear
attrs[.backgroundColor] = secretColor
}
attrs[secretAttrKey] = secretIdx
secretIdx += 1
handleTaps = true
} else {
attrs[.foregroundColor] = UIColor.clear
attrs[.backgroundColor] = secretColor
}
hasSecrets = true
case let .colored(color):
if let c = color.uiColor {
attrs[.foregroundColor] = UIColor(c)
}
case .uri:
attrs = linkAttrs()
if !preview {
let s = t.lowercased()
let link = s.hasPrefix("http://") || s.hasPrefix("https://")
? t
: "https://" + t
attrs[linkAttrKey] = NSURL(string: link)
attrs[webLinkAttrKey] = true
handleTaps = true
}
case let .simplexLink(linkType, simplexUri, smpHosts):
attrs = linkAttrs()
if !preview {
attrs[linkAttrKey] = NSURL(string: simplexUri)
handleTaps = true
}
if case .description = privacySimplexLinkModeDefault.get() {
t = simplexLinkText(linkType, smpHosts)
}
case let .mention(memberName):
if let m = mentions?[memberName] {
mention = mention ?? UIFont(descriptor: descr.addingAttributes([.traits: [UIFontDescriptor.TraitKey.weight: UIFont.Weight.semibold]]), size: descr.pointSize)
attrs[.font] = mention
if let ref = m.memberRef {
let name: String = if let alias = ref.localAlias, alias != "" {
"\(alias) (\(ref.displayName))"
} else {
ref.displayName
}
if m.memberId == userMemberId {
attrs[.foregroundColor] = UIColor.tintColor
}
t = mentionText(name)
} else {
t = mentionText(memberName)
}
}
case .email:
attrs = linkAttrs()
if !preview {
attrs[linkAttrKey] = NSURL(string: "mailto:" + ft.text)
handleTaps = true
}
case .phone:
attrs = linkAttrs()
if !preview {
attrs[linkAttrKey] = NSURL(string: "tel:" + t.replacingOccurrences(of: " ", with: ""))
handleTaps = true
}
case .none: ()
}
res.append(NSAttributedString(string: t, attributes: attrs))
} }
} else { } else {
res.append(NSMutableAttributedString(string: text, attributes: plain)) res = Text(s)
}
if let i = icon {
res = Text(Image(systemName: i)).foregroundColor(secondaryColor) + textSpace + res
} }
return (string: res, hasSecrets: hasSecrets, handleTaps: handleTaps) if let p = prefix {
res = p + res
}
func linkAttrs() -> [NSAttributedString.Key: Any] { if let s = sender {
link = link ?? [ let t = Text(s)
.font: font, return (preview ? t : t.fontWeight(.medium)) + Text(": ") + res
.foregroundColor: uiLinkColor, } else {
.underlineStyle: NSUnderlineStyle.single.rawValue return res
]
return link!
} }
} }
@inline(__always) private func formatText(_ ft: FormattedText, _ preview: Bool, showSecret: Bool, mentions: [String: CIMention]?, userMemberId: String?) -> Text {
private func mentionText(_ name: String) -> String { let t = ft.text
name.contains(" @") ? "@'\(name)'" : "@\(name)" if let f = ft.format {
switch (f) {
case .bold: return Text(t).bold()
case .italic: return Text(t).italic()
case .strikeThrough: return Text(t).strikethrough()
case .snippet: return Text(t).font(.body.monospaced())
case .secret: return
showSecret
? Text(t)
: Text(AttributedString(t, attributes: AttributeContainer([
.foregroundColor: UIColor.clear as Any,
.backgroundColor: UIColor.secondarySystemFill as Any
])))
case let .colored(color): return Text(t).foregroundColor(color.uiColor)
case .uri: return linkText(t, t, preview, prefix: "")
case let .simplexLink(linkType, simplexUri, smpHosts):
switch privacySimplexLinkModeDefault.get() {
case .description: return linkText(simplexLinkText(linkType, smpHosts), simplexUri, preview, prefix: "")
case .full: return linkText(t, simplexUri, preview, prefix: "")
case .browser: return linkText(t, simplexUri, preview, prefix: "")
}
case let .mention(memberName):
if let m = mentions?[memberName] {
if let ref = m.memberRef {
let name: String = if let alias = ref.localAlias, alias != "" {
"\(alias) (\(ref.displayName))"
} else {
ref.displayName
}
let tName = mentionText(name)
return m.memberId == userMemberId ? tName.foregroundColor(.accentColor) : tName
} else {
return mentionText(memberName)
}
}
return Text(t)
case .email: return linkText(t, t, preview, prefix: "mailto:")
case .phone: return linkText(t, t.replacingOccurrences(of: " ", with: ""), preview, prefix: "tel:")
}
} else {
return Text(t)
}
}
private func mentionText(_ name: String) -> Text {
Text(name.contains(" @") ? "@'\(name)'" : "@\(name)").fontWeight(.semibold)
}
private func linkText(_ s: String, _ link: String, _ preview: Bool, prefix: String, color: Color = Color(uiColor: uiLinkColor), uiColor: UIColor = uiLinkColor) -> Text {
preview
? Text(s).foregroundColor(color).underline(color: color)
: Text(AttributedString(s, attributes: AttributeContainer([
.link: NSURL(string: prefix + link) as Any,
.foregroundColor: uiColor as Any
]))).underline()
} }
func simplexLinkText(_ linkType: SimplexLinkType, _ smpHosts: [String]) -> String { func simplexLinkText(_ linkType: SimplexLinkType, _ smpHosts: [String]) -> String {
@ -371,9 +193,9 @@ struct MsgContentView_Previews: PreviewProvider {
chat: Chat.sampleData, chat: Chat.sampleData,
text: chatItem.text, text: chatItem.text,
formattedText: chatItem.formattedText, formattedText: chatItem.formattedText,
textStyle: .body,
sender: chatItem.memberDisplayName, sender: chatItem.memberDisplayName,
meta: chatItem.meta meta: chatItem.meta,
showSecrets: false
) )
.environmentObject(Chat.sampleData) .environmentObject(Chat.sampleData)
} }

View file

@ -41,7 +41,7 @@ struct ChatItemForwardingView: View {
.alert(item: $alert) { $0.alert } .alert(item: $alert) { $0.alert }
} }
private func forwardListView() -> some View { @ViewBuilder private func forwardListView() -> some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
if !chatsToForwardTo.isEmpty { if !chatsToForwardTo.isEmpty {
List { List {

View file

@ -131,9 +131,9 @@ struct ChatItemInfoView: View {
} }
} }
private func details() -> some View { @ViewBuilder private func details() -> some View {
let meta = ci.meta let meta = ci.meta
return VStack(alignment: .leading, spacing: 16) { VStack(alignment: .leading, spacing: 16) {
Text(title) Text(title)
.font(.largeTitle) .font(.largeTitle)
.bold() .bold()
@ -197,7 +197,7 @@ struct ChatItemInfoView: View {
} }
} }
private func historyTab() -> some View { @ViewBuilder private func historyTab() -> some View {
GeometryReader { g in GeometryReader { g in
let maxWidth = (g.size.width - 32) * 0.84 let maxWidth = (g.size.width - 32) * 0.84
ScrollView { ScrollView {
@ -227,13 +227,12 @@ struct ChatItemInfoView: View {
} }
} }
private func itemVersionView(_ itemVersion: ChatItemVersion, _ maxWidth: CGFloat, current: Bool) -> some View { @ViewBuilder private func itemVersionView(_ itemVersion: ChatItemVersion, _ maxWidth: CGFloat, current: Bool) -> some View {
let backgroundColor = chatItemFrameColor(ci, theme) VStack(alignment: .leading, spacing: 4) {
return VStack(alignment: .leading, spacing: 4) { textBubble(itemVersion.msgContent.text, itemVersion.formattedText, nil)
textBubble(itemVersion.msgContent.text, itemVersion.formattedText, nil, backgroundColor: UIColor(backgroundColor))
.padding(.horizontal, 12) .padding(.horizontal, 12)
.padding(.vertical, 6) .padding(.vertical, 6)
.background(backgroundColor) .background(chatItemFrameColor(ci, theme))
.modifier(ChatItemClipped()) .modifier(ChatItemClipped())
.contextMenu { .contextMenu {
if itemVersion.msgContent.text != "" { if itemVersion.msgContent.text != "" {
@ -258,9 +257,9 @@ struct ChatItemInfoView: View {
.frame(maxWidth: maxWidth, alignment: .leading) .frame(maxWidth: maxWidth, alignment: .leading)
} }
@ViewBuilder private func textBubble(_ text: String, _ formattedText: [FormattedText]?, _ sender: String? = nil, backgroundColor: UIColor) -> some View { @ViewBuilder private func textBubble(_ text: String, _ formattedText: [FormattedText]?, _ sender: String? = nil) -> some View {
if text != "" { if text != "" {
TextBubble(text: text, formattedText: formattedText, sender: sender, mentions: ci.mentions, userMemberId: userMemberId, backgroundColor: backgroundColor) TextBubble(text: text, formattedText: formattedText, sender: sender, mentions: ci.mentions, userMemberId: userMemberId)
} else { } else {
Text("no text") Text("no text")
.italic() .italic()
@ -275,16 +274,14 @@ struct ChatItemInfoView: View {
var sender: String? = nil var sender: String? = nil
var mentions: [String: CIMention]? var mentions: [String: CIMention]?
var userMemberId: String? var userMemberId: String?
var backgroundColor: UIColor @State private var showSecrets = false
@State private var showSecrets: Set<Int> = []
var body: some View { var body: some View {
let r = messageText(text, formattedText, sender: sender, mentions: mentions, userMemberId: userMemberId, showSecrets: showSecrets, backgroundColor: backgroundColor) toggleSecrets(formattedText, $showSecrets, messageText(text, formattedText, sender, mentions: mentions, userMemberId: userMemberId, showSecrets: showSecrets, secondaryColor: theme.colors.secondary))
return msgTextResultView(r, Text(AttributedString(r.string)), showSecrets: $showSecrets)
} }
} }
private func quoteTab(_ qi: CIQuote) -> some View { @ViewBuilder private func quoteTab(_ qi: CIQuote) -> some View {
GeometryReader { g in GeometryReader { g in
let maxWidth = (g.size.width - 32) * 0.84 let maxWidth = (g.size.width - 32) * 0.84
ScrollView { ScrollView {
@ -302,10 +299,9 @@ struct ChatItemInfoView: View {
} }
} }
private func quotedMsgView(_ qi: CIQuote, _ maxWidth: CGFloat) -> some View { @ViewBuilder private func quotedMsgView(_ qi: CIQuote, _ maxWidth: CGFloat) -> some View {
let backgroundColor = quotedMsgFrameColor(qi, theme) VStack(alignment: .leading, spacing: 4) {
return VStack(alignment: .leading, spacing: 4) { textBubble(qi.text, qi.formattedText, qi.getSender(nil))
textBubble(qi.text, qi.formattedText, qi.getSender(nil), backgroundColor: UIColor(backgroundColor))
.padding(.horizontal, 12) .padding(.horizontal, 12)
.padding(.vertical, 6) .padding(.vertical, 6)
.background(quotedMsgFrameColor(qi, theme)) .background(quotedMsgFrameColor(qi, theme))
@ -338,7 +334,7 @@ struct ChatItemInfoView: View {
: theme.appColors.receivedMessage : theme.appColors.receivedMessage
} }
private func forwardedFromTab(_ forwardedFromItem: AChatItem) -> some View { @ViewBuilder private func forwardedFromTab(_ forwardedFromItem: AChatItem) -> some View {
ScrollView { ScrollView {
VStack(alignment: .leading, spacing: 16) { VStack(alignment: .leading, spacing: 16) {
details() details()
@ -358,9 +354,8 @@ struct ChatItemInfoView: View {
Button { Button {
Task { Task {
await MainActor.run { await MainActor.run {
ItemsModel.shared.loadOpenChat(forwardedFromItem.chatInfo.id) { ItemsModel.shared.loadOpenChat(forwardedFromItem.chatInfo.id)
dismiss() dismiss()
}
} }
} }
} label: { } label: {
@ -376,7 +371,7 @@ struct ChatItemInfoView: View {
} }
} }
private func forwardedFromSender(_ forwardedFromItem: AChatItem) -> some View { @ViewBuilder private func forwardedFromSender(_ forwardedFromItem: AChatItem) -> some View {
HStack { HStack {
ChatInfoImage(chat: Chat(chatInfo: forwardedFromItem.chatInfo), size: 48) ChatInfoImage(chat: Chat(chatInfo: forwardedFromItem.chatInfo), size: 48)
.padding(.trailing, 6) .padding(.trailing, 6)
@ -407,7 +402,7 @@ struct ChatItemInfoView: View {
} }
} }
private func deliveryTab(_ memberDeliveryStatuses: [MemberDeliveryStatus]) -> some View { @ViewBuilder private func deliveryTab(_ memberDeliveryStatuses: [MemberDeliveryStatus]) -> some View {
ScrollView { ScrollView {
VStack(alignment: .leading, spacing: 16) { VStack(alignment: .leading, spacing: 16) {
details() details()
@ -422,7 +417,7 @@ struct ChatItemInfoView: View {
.frame(maxHeight: .infinity, alignment: .top) .frame(maxHeight: .infinity, alignment: .top)
} }
private func memberDeliveryStatusesView(_ memberDeliveryStatuses: [MemberDeliveryStatus]) -> some View { @ViewBuilder private func memberDeliveryStatusesView(_ memberDeliveryStatuses: [MemberDeliveryStatus]) -> some View {
LazyVStack(alignment: .leading, spacing: 12) { LazyVStack(alignment: .leading, spacing: 12) {
let mss = membersStatuses(memberDeliveryStatuses) let mss = membersStatuses(memberDeliveryStatuses)
if !mss.isEmpty { if !mss.isEmpty {

View file

@ -18,10 +18,6 @@ extension EnvironmentValues {
static let defaultValue: Bool = true static let defaultValue: Bool = true
} }
struct ContainerBackground: EnvironmentKey {
static let defaultValue: UIColor = .clear
}
var showTimestamp: Bool { var showTimestamp: Bool {
get { self[ShowTimestamp.self] } get { self[ShowTimestamp.self] }
set { self[ShowTimestamp.self] = newValue } set { self[ShowTimestamp.self] = newValue }
@ -31,11 +27,6 @@ extension EnvironmentValues {
get { self[Revealed.self] } get { self[Revealed.self] }
set { self[Revealed.self] = newValue } set { self[Revealed.self] = newValue }
} }
var containerBackground: UIColor {
get { self[ContainerBackground.self] }
set { self[ContainerBackground.self] = newValue }
}
} }
struct ChatItemView: View { struct ChatItemView: View {

View file

@ -60,8 +60,6 @@ func apiLoadMessages(
chatState.unreadTotal = chat.chatStats.unreadCount chatState.unreadTotal = chat.chatStats.unreadCount
chatState.unreadAfter = navInfo.afterUnread chatState.unreadAfter = navInfo.afterUnread
chatState.unreadAfterNewestLoaded = navInfo.afterUnread chatState.unreadAfterNewestLoaded = navInfo.afterUnread
PreloadState.shared.clear()
} }
case let .before(paginationChatItemId, _): case let .before(paginationChatItemId, _):
newItems.append(contentsOf: oldItems) newItems.append(contentsOf: oldItems)
@ -106,22 +104,19 @@ func apiLoadMessages(
} }
} }
case .around: case .around:
var newSplits: [Int64] let newSplits: [Int64]
if openAroundItemId == nil { if openAroundItemId == nil {
newItems.append(contentsOf: oldItems) newItems.append(contentsOf: oldItems)
newSplits = await removeDuplicatesAndUpperSplits(&newItems, chat, chatState.splits, visibleItemIndexesNonReversed) newSplits = await removeDuplicatesAndUpperSplits(&newItems, chat, chatState.splits, visibleItemIndexesNonReversed)
} else { } else {
newSplits = [] newSplits = []
} }
let (itemIndex, splitIndex) = indexToInsertAround(chat.chatInfo.chatType, chat.chatItems.last, to: newItems, Set(newSplits)) // currently, items will always be added on top, which is index 0
//indexToInsertAroundTest() newItems.insert(contentsOf: chat.chatItems, at: 0)
newItems.insert(contentsOf: chat.chatItems, at: itemIndex)
newSplits.insert(chat.chatItems.last!.id, at: splitIndex)
let newReversed: [ChatItem] = newItems.reversed() let newReversed: [ChatItem] = newItems.reversed()
let orderedSplits = newSplits
await MainActor.run { await MainActor.run {
ItemsModel.shared.reversedChatItems = newReversed ItemsModel.shared.reversedChatItems = newReversed
chatState.splits = orderedSplits chatState.splits = [chat.chatItems.last!.id] + newSplits
chatState.unreadAfterItemId = chat.chatItems.last!.id chatState.unreadAfterItemId = chat.chatItems.last!.id
chatState.totalAfter = navInfo.afterTotal chatState.totalAfter = navInfo.afterTotal
chatState.unreadTotal = chat.chatStats.unreadCount chatState.unreadTotal = chat.chatStats.unreadCount
@ -135,16 +130,14 @@ func apiLoadMessages(
// no need to set it, count will be wrong // no need to set it, count will be wrong
// chatState.unreadAfterNewestLoaded = navInfo.afterUnread // chatState.unreadAfterNewestLoaded = navInfo.afterUnread
} }
PreloadState.shared.clear()
} }
case .last: case .last:
newItems.append(contentsOf: oldItems) newItems.append(contentsOf: oldItems)
let newSplits = await removeDuplicatesAndUnusedSplits(&newItems, chat, chatState.splits) removeDuplicates(&newItems, chat)
newItems.append(contentsOf: chat.chatItems) newItems.append(contentsOf: chat.chatItems)
let items = newItems let items = newItems
await MainActor.run { await MainActor.run {
ItemsModel.shared.reversedChatItems = items.reversed() ItemsModel.shared.reversedChatItems = items.reversed()
chatState.splits = newSplits
chatModel.updateChatInfo(chat.chatInfo) chatModel.updateChatInfo(chat.chatInfo)
chatState.unreadAfterNewestLoaded = 0 chatState.unreadAfterNewestLoaded = 0
} }
@ -241,14 +234,10 @@ private func removeDuplicatesAndModifySplitsOnAfterPagination(
let indexInSplitRanges = splits.firstIndex(of: paginationChatItemId) let indexInSplitRanges = splits.firstIndex(of: paginationChatItemId)
// Currently, it should always load from split range // Currently, it should always load from split range
let loadingFromSplitRange = indexInSplitRanges != nil let loadingFromSplitRange = indexInSplitRanges != nil
let topSplits: [Int64] var splitsToMerge: [Int64] = if let indexInSplitRanges, loadingFromSplitRange && indexInSplitRanges + 1 <= splits.count {
var splitsToMerge: [Int64] Array(splits[indexInSplitRanges + 1 ..< splits.count])
if let indexInSplitRanges, loadingFromSplitRange && indexInSplitRanges + 1 <= splits.count {
splitsToMerge = Array(splits[indexInSplitRanges + 1 ..< splits.count])
topSplits = Array(splits[0 ..< indexInSplitRanges + 1])
} else { } else {
splitsToMerge = [] []
topSplits = []
} }
newItems.removeAll(where: { new in newItems.removeAll(where: { new in
let duplicate = newIds.contains(new.id) let duplicate = newIds.contains(new.id)
@ -268,8 +257,8 @@ private func removeDuplicatesAndModifySplitsOnAfterPagination(
}) })
var newSplits: [Int64] = [] var newSplits: [Int64] = []
if firstItemIdBelowAllSplits != nil { if firstItemIdBelowAllSplits != nil {
// no splits below anymore, all were merged with bottom items // no splits anymore, all were merged with bottom items
newSplits = topSplits newSplits = []
} else { } else {
if !splitsToRemove.isEmpty { if !splitsToRemove.isEmpty {
var new = splits var new = splits
@ -331,28 +320,6 @@ private func removeDuplicatesAndUpperSplits(
return newSplits return newSplits
} }
private func removeDuplicatesAndUnusedSplits(
_ newItems: inout [ChatItem],
_ chat: Chat,
_ splits: [Int64]
) async -> [Int64] {
if splits.isEmpty {
removeDuplicates(&newItems, chat)
return splits
}
var newSplits = splits
let (newIds, _) = mapItemsToIds(chat.chatItems)
newItems.removeAll(where: {
let duplicate = newIds.contains($0.id)
if duplicate, let firstIndex = newSplits.firstIndex(of: $0.id) {
newSplits.remove(at: firstIndex)
}
return duplicate
})
return newSplits
}
// ids, number of unread items // ids, number of unread items
private func mapItemsToIds(_ items: [ChatItem]) -> (Set<Int64>, Int) { private func mapItemsToIds(_ items: [ChatItem]) -> (Set<Int64>, Int) {
var unreadInLoaded = 0 var unreadInLoaded = 0
@ -373,139 +340,3 @@ private func removeDuplicates(_ newItems: inout [ChatItem], _ chat: Chat) {
let (newIds, _) = mapItemsToIds(chat.chatItems) let (newIds, _) = mapItemsToIds(chat.chatItems)
newItems.removeAll { newIds.contains($0.id) } newItems.removeAll { newIds.contains($0.id) }
} }
private typealias SameTimeItem = (index: Int, item: ChatItem)
// return (item index, split index)
private func indexToInsertAround(_ chatType: ChatType, _ lastNew: ChatItem?, to: [ChatItem], _ splits: Set<Int64>) -> (Int, Int) {
guard to.count > 0, let lastNew = lastNew else { return (0, 0) }
// group sorting: item_ts, item_id
// everything else: created_at, item_id
let compareByTimeTs = chatType == .group
// in case several items have the same time as another item in the `to` array
var sameTime: [SameTimeItem] = []
// trying to find new split index for item looks difficult but allows to not use one more loop.
// The idea is to memorize how many splits were till any index (map number of splits until index)
// and use resulting itemIndex to decide new split index position.
// Because of the possibility to have many items with the same timestamp, it's possible to see `itemIndex < || == || > i`.
var splitsTillIndex: [Int] = []
var splitsPerPrevIndex = 0
for i in 0 ..< to.count {
let item = to[i]
splitsPerPrevIndex = splits.contains(item.id) ? splitsPerPrevIndex + 1 : splitsPerPrevIndex
splitsTillIndex.append(splitsPerPrevIndex)
let itemIsNewer = (compareByTimeTs ? item.meta.itemTs > lastNew.meta.itemTs : item.meta.createdAt > lastNew.meta.createdAt)
if itemIsNewer || i + 1 == to.count {
if (compareByTimeTs ? lastNew.meta.itemTs == item.meta.itemTs : lastNew.meta.createdAt == item.meta.createdAt) {
sameTime.append((i, item))
}
// time to stop the loop. Item is newer or it's the last item in `to` array, taking previous items and checking position inside them
let itemIndex: Int
if sameTime.count > 1, let first = sameTime.sorted(by: { prev, next in prev.item.meta.itemId < next.item.id }).first(where: { same in same.item.id > lastNew.id }) {
itemIndex = first.index
} else if sameTime.count == 1 {
itemIndex = sameTime[0].item.id > lastNew.id ? sameTime[0].index : sameTime[0].index + 1
} else {
itemIndex = itemIsNewer ? i : i + 1
}
let splitIndex = splitsTillIndex[min(itemIndex, splitsTillIndex.count - 1)]
let prevItemSplitIndex = itemIndex == 0 ? 0 : splitsTillIndex[min(itemIndex - 1, splitsTillIndex.count - 1)]
return (itemIndex, splitIndex == prevItemSplitIndex ? splitIndex : prevItemSplitIndex)
}
if (compareByTimeTs ? lastNew.meta.itemTs == item.meta.itemTs : lastNew.meta.createdAt == item.meta.createdAt) {
sameTime.append(SameTimeItem(index: i, item: item))
} else {
sameTime = []
}
}
// shouldn't be here
return (to.count, splits.count)
}
private func indexToInsertAroundTest() {
func assert(_ one: (Int, Int), _ two: (Int, Int)) {
if one != two {
logger.debug("\(String(describing: one)) != \(String(describing: two))")
fatalError()
}
}
let itemsToInsert = [ChatItem.getSample(3, .groupSnd, Date.init(timeIntervalSince1970: 3), "")]
let items1 = [
ChatItem.getSample(0, .groupSnd, Date.init(timeIntervalSince1970: 0), ""),
ChatItem.getSample(1, .groupSnd, Date.init(timeIntervalSince1970: 1), ""),
ChatItem.getSample(2, .groupSnd, Date.init(timeIntervalSince1970: 2), "")
]
assert(indexToInsertAround(.group, itemsToInsert.last, to: items1, Set([1])), (3, 1))
let items2 = [
ChatItem.getSample(0, .groupSnd, Date.init(timeIntervalSince1970: 0), ""),
ChatItem.getSample(1, .groupSnd, Date.init(timeIntervalSince1970: 1), ""),
ChatItem.getSample(2, .groupSnd, Date.init(timeIntervalSince1970: 3), "")
]
assert(indexToInsertAround(.group, itemsToInsert.last, to: items2, Set([2])), (3, 1))
let items3 = [
ChatItem.getSample(0, .groupSnd, Date.init(timeIntervalSince1970: 0), ""),
ChatItem.getSample(1, .groupSnd, Date.init(timeIntervalSince1970: 3), ""),
ChatItem.getSample(2, .groupSnd, Date.init(timeIntervalSince1970: 3), "")
]
assert(indexToInsertAround(.group, itemsToInsert.last, to: items3, Set([1])), (3, 1))
let items4 = [
ChatItem.getSample(0, .groupSnd, Date.init(timeIntervalSince1970: 0), ""),
ChatItem.getSample(4, .groupSnd, Date.init(timeIntervalSince1970: 3), ""),
ChatItem.getSample(5, .groupSnd, Date.init(timeIntervalSince1970: 3), "")
]
assert(indexToInsertAround(.group, itemsToInsert.last, to: items4, Set([4])), (1, 0))
let items5 = [
ChatItem.getSample(0, .groupSnd, Date.init(timeIntervalSince1970: 0), ""),
ChatItem.getSample(2, .groupSnd, Date.init(timeIntervalSince1970: 3), ""),
ChatItem.getSample(4, .groupSnd, Date.init(timeIntervalSince1970: 3), "")
]
assert(indexToInsertAround(.group, itemsToInsert.last, to: items5, Set([2])), (2, 1))
let items6 = [
ChatItem.getSample(4, .groupSnd, Date.init(timeIntervalSince1970: 4), ""),
ChatItem.getSample(5, .groupSnd, Date.init(timeIntervalSince1970: 4), ""),
ChatItem.getSample(6, .groupSnd, Date.init(timeIntervalSince1970: 4), "")
]
assert(indexToInsertAround(.group, itemsToInsert.last, to: items6, Set([5])), (0, 0))
let items7 = [
ChatItem.getSample(4, .groupSnd, Date.init(timeIntervalSince1970: 4), ""),
ChatItem.getSample(5, .groupSnd, Date.init(timeIntervalSince1970: 4), ""),
ChatItem.getSample(6, .groupSnd, Date.init(timeIntervalSince1970: 4), "")
]
assert(indexToInsertAround(.group, nil, to: items7, Set([6])), (0, 0))
let items8 = [
ChatItem.getSample(2, .groupSnd, Date.init(timeIntervalSince1970: 4), ""),
ChatItem.getSample(4, .groupSnd, Date.init(timeIntervalSince1970: 3), ""),
ChatItem.getSample(5, .groupSnd, Date.init(timeIntervalSince1970: 4), "")
]
assert(indexToInsertAround(.group, itemsToInsert.last, to: items8, Set([2])), (0, 0))
let items9 = [
ChatItem.getSample(2, .groupSnd, Date.init(timeIntervalSince1970: 3), ""),
ChatItem.getSample(4, .groupSnd, Date.init(timeIntervalSince1970: 3), ""),
ChatItem.getSample(5, .groupSnd, Date.init(timeIntervalSince1970: 4), "")
]
assert(indexToInsertAround(.group, itemsToInsert.last, to: items9, Set([5])), (1, 0))
let items10 = [
ChatItem.getSample(4, .groupSnd, Date.init(timeIntervalSince1970: 3), ""),
ChatItem.getSample(5, .groupSnd, Date.init(timeIntervalSince1970: 3), ""),
ChatItem.getSample(6, .groupSnd, Date.init(timeIntervalSince1970: 4), "")
]
assert(indexToInsertAround(.group, itemsToInsert.last, to: items10, Set([4])), (0, 0))
let items11: [ChatItem] = []
assert(indexToInsertAround(.group, itemsToInsert.last, to: items11, Set([])), (0, 0))
}

View file

@ -321,101 +321,6 @@ class ActiveChatState {
unreadAfter = 0 unreadAfter = 0
unreadAfterNewestLoaded = 0 unreadAfterNewestLoaded = 0
} }
func itemsRead(_ itemIds: Set<Int64>?, _ newItems: [ChatItem]) {
guard let itemIds else {
// special case when the whole chat became read
unreadTotal = 0
unreadAfter = 0
return
}
var unreadAfterItemIndex: Int = -1
// since it's more often that the newest items become read, it's logical to loop from the end of the list to finish it faster
var i = newItems.count - 1
var ids = itemIds
// intermediate variables to prevent re-setting state value a lot of times without reason
var newUnreadTotal = unreadTotal
var newUnreadAfter = unreadAfter
while i >= 0 {
let item = newItems[i]
if item.id == unreadAfterItemId {
unreadAfterItemIndex = i
}
if ids.contains(item.id) {
// was unread, now this item is read
if (unreadAfterItemIndex == -1) {
newUnreadAfter -= 1
}
newUnreadTotal -= 1
ids.remove(item.id)
if ids.isEmpty {
break
}
}
i -= 1
}
unreadTotal = newUnreadTotal
unreadAfter = newUnreadAfter
}
func itemAdded(_ item: (Int64, Bool), _ index: Int) {
if item.1 {
unreadAfter += 1
unreadTotal += 1
}
}
func itemsRemoved(_ itemIds: [(Int64, Int, Bool)], _ newItems: [ChatItem]) {
var newSplits: [Int64] = []
for split in splits {
let index = itemIds.firstIndex(where: { (delId, _, _) in delId == split })
// deleted the item that was right before the split between items, find newer item so it will act like the split
if let index {
let idx = itemIds[index].1 - itemIds.filter { (_, delIndex, _) in delIndex <= index }.count
let newSplit = newItems.count > idx && idx >= 0 ? newItems[idx].id : nil
// it the whole section is gone and splits overlap, don't add it at all
if let newSplit, !newSplits.contains(newSplit) {
newSplits.append(newSplit)
}
} else {
newSplits.append(split)
}
}
splits = newSplits
let index = itemIds.firstIndex(where: { (delId, _, _) in delId == unreadAfterItemId })
// unread after item was removed
if let index {
let idx = itemIds[index].1 - itemIds.filter { (_, delIndex, _) in delIndex <= index }.count
var newUnreadAfterItemId = newItems.count > idx && idx >= 0 ? newItems[idx].id : nil
let newUnreadAfterItemWasNull = newUnreadAfterItemId == nil
if newUnreadAfterItemId == nil {
// everything on top (including unread after item) were deleted, take top item as unread after id
newUnreadAfterItemId = newItems.first?.id
}
if let newUnreadAfterItemId {
unreadAfterItemId = newUnreadAfterItemId
totalAfter -= itemIds.filter { (_, delIndex, _) in delIndex > index }.count
unreadTotal -= itemIds.filter { (_, delIndex, isRcvNew) in delIndex <= index && isRcvNew }.count
unreadAfter -= itemIds.filter { (_, delIndex, isRcvNew) in delIndex > index && isRcvNew }.count
if newUnreadAfterItemWasNull {
// since the unread after item was moved one item after initial position, adjust counters accordingly
if newItems.first?.isRcvNew == true {
unreadTotal += 1
unreadAfter -= 1
}
}
} else {
// all items were deleted, 0 items in chatItems
unreadAfterItemId = -1
totalAfter = 0
unreadTotal = 0
unreadAfter = 0
}
} else {
totalAfter -= itemIds.count
}
}
} }
class BoxedValue<T: Hashable>: Equatable, Hashable { class BoxedValue<T: Hashable>: Equatable, Hashable {
@ -454,3 +359,101 @@ func visibleItemIndexesNonReversed(_ listState: EndlessScrollView<MergedItem>.Li
// visible items mapped to their underlying data structure which is ItemsModel.shared.reversedChatItems.reversed() // visible items mapped to their underlying data structure which is ItemsModel.shared.reversedChatItems.reversed()
return range return range
} }
class RecalculatePositions {
private var chatState: ActiveChatState { get { ItemsModel.shared.chatState } }
func read(_ itemIds: Set<Int64>?, _ newItems: [ChatItem]) {
guard let itemIds else {
// special case when the whole chat became read
chatState.unreadTotal = 0
chatState.unreadAfter = 0
return
}
var unreadAfterItemIndex: Int = -1
// since it's more often that the newest items become read, it's logical to loop from the end of the list to finish it faster
var i = newItems.count - 1
var ids = itemIds
// intermediate variables to prevent re-setting state value a lot of times without reason
var newUnreadTotal = chatState.unreadTotal
var newUnreadAfter = chatState.unreadAfter
while i >= 0 {
let item = newItems[i]
if item.id == chatState.unreadAfterItemId {
unreadAfterItemIndex = i
}
if ids.contains(item.id) {
// was unread, now this item is read
if (unreadAfterItemIndex == -1) {
newUnreadAfter -= 1
}
newUnreadTotal -= 1
ids.remove(item.id)
if ids.isEmpty {
break
}
}
i -= 1
}
chatState.unreadTotal = newUnreadTotal
chatState.unreadAfter = newUnreadAfter
}
func added(_ item: (Int64, Bool), _ index: Int) {
if item.1 {
chatState.unreadAfter += 1
chatState.unreadTotal += 1
}
}
func removed(_ itemIds: [(Int64, Int, Bool)], _ newItems: [ChatItem]) {
var newSplits: [Int64] = []
for split in chatState.splits {
let index = itemIds.firstIndex(where: { (delId, _, _) in delId == split })
// deleted the item that was right before the split between items, find newer item so it will act like the split
if let index {
let idx = itemIds[index].1 - itemIds.filter { (_, delIndex, _) in delIndex <= index }.count
let newSplit = newItems.count > idx && idx >= 0 ? newItems[idx].id : nil
// it the whole section is gone and splits overlap, don't add it at all
if let newSplit, !newSplits.contains(newSplit) {
newSplits.append(newSplit)
}
} else {
newSplits.append(split)
}
}
chatState.splits = newSplits
let index = itemIds.firstIndex(where: { (delId, _, _) in delId == chatState.unreadAfterItemId })
// unread after item was removed
if let index {
let idx = itemIds[index].1 - itemIds.filter { (_, delIndex, _) in delIndex <= index }.count
var newUnreadAfterItemId = newItems.count > idx && idx >= 0 ? newItems[idx].id : nil
let newUnreadAfterItemWasNull = newUnreadAfterItemId == nil
if newUnreadAfterItemId == nil {
// everything on top (including unread after item) were deleted, take top item as unread after id
newUnreadAfterItemId = newItems.first?.id
}
if let newUnreadAfterItemId {
chatState.unreadAfterItemId = newUnreadAfterItemId
chatState.totalAfter -= itemIds.filter { (_, delIndex, _) in delIndex > index }.count
chatState.unreadTotal -= itemIds.filter { (_, delIndex, isRcvNew) in delIndex <= index && isRcvNew }.count
chatState.unreadAfter -= itemIds.filter { (_, delIndex, isRcvNew) in delIndex > index && isRcvNew }.count
if newUnreadAfterItemWasNull {
// since the unread after item was moved one item after initial position, adjust counters accordingly
if newItems.first?.isRcvNew == true {
chatState.unreadTotal += 1
chatState.unreadAfter -= 1
}
}
} else {
// all items were deleted, 0 items in chatItems
chatState.unreadAfterItemId = -1
chatState.totalAfter = 0
chatState.unreadTotal = 0
chatState.unreadAfter = 0
}
} else {
chatState.totalAfter -= itemIds.count
}
}
func cleared() { chatState.clear() }
}

View file

@ -9,23 +9,25 @@
import SwiftUI import SwiftUI
import SimpleXChat import SimpleXChat
func loadLastItems(_ loadingMoreItems: Binding<Bool>, loadingBottomItems: Binding<Bool>, _ chat: Chat) async { func loadLastItems(_ loadingMoreItems: Binding<Bool>, loadingBottomItems: Binding<Bool>, _ chat: Chat) {
await MainActor.run { if ItemsModel.shared.chatState.totalAfter == 0 {
loadingMoreItems.wrappedValue = true return
loadingBottomItems.wrappedValue = true
} }
try? await Task.sleep(nanoseconds: 500_000000) loadingMoreItems.wrappedValue = true
if ChatModel.shared.chatId != chat.chatInfo.id { loadingBottomItems.wrappedValue = true
Task {
try? await Task.sleep(nanoseconds: 500_000000)
if ChatModel.shared.chatId != chat.chatInfo.id {
await MainActor.run {
loadingMoreItems.wrappedValue = false
}
return
}
await apiLoadMessages(chat.chatInfo.id, ChatPagination.last(count: 50), ItemsModel.shared.chatState)
await MainActor.run { await MainActor.run {
loadingMoreItems.wrappedValue = false loadingMoreItems.wrappedValue = false
loadingBottomItems.wrappedValue = false loadingBottomItems.wrappedValue = false
} }
return
}
await apiLoadMessages(chat.chatInfo.id, ChatPagination.last(count: 50), ItemsModel.shared.chatState)
await MainActor.run {
loadingMoreItems.wrappedValue = false
loadingBottomItems.wrappedValue = false
} }
} }
@ -34,12 +36,6 @@ class PreloadState {
var prevFirstVisible: Int64 = Int64.min var prevFirstVisible: Int64 = Int64.min
var prevItemsCount: Int = 0 var prevItemsCount: Int = 0
var preloading: Bool = false var preloading: Bool = false
func clear() {
prevFirstVisible = Int64.min
prevItemsCount = 0
preloading = false
}
} }
func preloadIfNeeded( func preloadIfNeeded(
@ -47,41 +43,26 @@ func preloadIfNeeded(
_ ignoreLoadingRequests: Binding<Int64?>, _ ignoreLoadingRequests: Binding<Int64?>,
_ listState: EndlessScrollView<MergedItem>.ListState, _ listState: EndlessScrollView<MergedItem>.ListState,
_ mergedItems: BoxedValue<MergedItems>, _ mergedItems: BoxedValue<MergedItems>,
loadItems: @escaping (Bool, ChatPagination) async -> Bool, loadItems: @escaping (Bool, ChatPagination) async -> Bool
loadLastItems: @escaping () async -> Void
) { ) {
let state = PreloadState.shared let state = PreloadState.shared
guard !listState.isScrolling && !listState.isAnimatedScrolling, guard !listState.isScrolling && !listState.isAnimatedScrolling,
state.prevFirstVisible != listState.firstVisibleItemIndex || state.prevItemsCount != mergedItems.boxedValue.indexInParentItems.count,
!state.preloading, !state.preloading,
listState.totalItemsCount > 0 listState.totalItemsCount > 0
else { else {
return return
} }
if state.prevFirstVisible != listState.firstVisibleItemId as! Int64 || state.prevItemsCount != mergedItems.boxedValue.indexInParentItems.count { state.prevFirstVisible = listState.firstVisibleItemId as! Int64
state.preloading = true state.prevItemsCount = mergedItems.boxedValue.indexInParentItems.count
let allowLoadMore = allowLoadMoreItems.wrappedValue state.preloading = true
Task { let allowLoadMore = allowLoadMoreItems.wrappedValue
defer { state.preloading = false } Task {
var triedToLoad = true defer {
await preloadItems(mergedItems.boxedValue, allowLoadMore, listState, ignoreLoadingRequests) { pagination in state.preloading = false
triedToLoad = await loadItems(false, pagination)
return triedToLoad
}
if triedToLoad {
state.prevFirstVisible = listState.firstVisibleItemId as! Int64
state.prevItemsCount = mergedItems.boxedValue.indexInParentItems.count
}
// it's important to ask last items when the view is fully covered with items. Otherwise, visible items from one
// split will be merged with last items and position of scroll will change unexpectedly.
if listState.itemsCanCoverScreen && !ItemsModel.shared.lastItemsLoaded {
await loadLastItems()
}
} }
} else if listState.itemsCanCoverScreen && !ItemsModel.shared.lastItemsLoaded { await preloadItems(mergedItems.boxedValue, allowLoadMore, listState, ignoreLoadingRequests) { pagination in
state.preloading = true await loadItems(false, pagination)
Task {
defer { state.preloading = false }
await loadLastItems()
} }
} }
} }
@ -124,7 +105,6 @@ async {
let triedToLoad = await loadItems(ChatPagination.before(chatItemId: loadFromItemId, count: ChatPagination.PRELOAD_COUNT)) let triedToLoad = await loadItems(ChatPagination.before(chatItemId: loadFromItemId, count: ChatPagination.PRELOAD_COUNT))
if triedToLoad && sizeWas == ItemsModel.shared.reversedChatItems.count && firstItemIdWas == ItemsModel.shared.reversedChatItems.last?.id { if triedToLoad && sizeWas == ItemsModel.shared.reversedChatItems.count && firstItemIdWas == ItemsModel.shared.reversedChatItems.last?.id {
ignoreLoadingRequests.wrappedValue = loadFromItemId ignoreLoadingRequests.wrappedValue = loadFromItemId
return false
} }
return triedToLoad return triedToLoad
} }

View file

@ -45,7 +45,7 @@ struct ChatView: View {
@State private var selectedMember: GMember? = nil @State private var selectedMember: GMember? = nil
// opening GroupLinkView on link button (incognito) // opening GroupLinkView on link button (incognito)
@State private var showGroupLinkSheet: Bool = false @State private var showGroupLinkSheet: Bool = false
@State private var groupLink: CreatedConnLink? @State private var groupLink: String?
@State private var groupLinkMemberRole: GroupMemberRole = .member @State private var groupLinkMemberRole: GroupMemberRole = .member
@State private var forwardedChatItems: [ChatItem] = [] @State private var forwardedChatItems: [ChatItem] = []
@State private var selectedChatItems: Set<Int64>? = nil @State private var selectedChatItems: Set<Int64>? = nil
@ -71,9 +71,10 @@ struct ChatView: View {
} }
} }
@ViewBuilder
private var viewBody: some View { private var viewBody: some View {
let cInfo = chat.chatInfo let cInfo = chat.chatInfo
return ZStack { ZStack {
let wallpaperImage = theme.wallpaper.type.image let wallpaperImage = theme.wallpaper.type.image
let wallpaperType = theme.wallpaper.type let wallpaperType = theme.wallpaper.type
let backgroundColor = theme.wallpaper.background ?? wallpaperType.defaultBackgroundColor(theme.base, theme.colors.background) let backgroundColor = theme.wallpaper.background ?? wallpaperType.defaultBackgroundColor(theme.base, theme.colors.background)
@ -90,32 +91,18 @@ struct ChatView: View {
if let groupInfo = chat.chatInfo.groupInfo, !composeState.message.isEmpty { if let groupInfo = chat.chatInfo.groupInfo, !composeState.message.isEmpty {
GroupMentionsView(groupInfo: groupInfo, composeState: $composeState, selectedRange: $selectedRange, keyboardVisible: $keyboardVisible) GroupMentionsView(groupInfo: groupInfo, composeState: $composeState, selectedRange: $selectedRange, keyboardVisible: $keyboardVisible)
} }
FloatingButtons(theme: theme, scrollView: scrollView, chat: chat, loadingMoreItems: $loadingMoreItems, loadingTopItems: $loadingTopItems, requestedTopScroll: $requestedTopScroll, loadingBottomItems: $loadingBottomItems, requestedBottomScroll: $requestedBottomScroll, animatedScrollingInProgress: $animatedScrollingInProgress, listState: scrollView.listState, model: floatingButtonModel, reloadItems: { FloatingButtons(theme: theme, scrollView: scrollView, chat: chat, loadingTopItems: $loadingTopItems, requestedTopScroll: $requestedTopScroll, loadingBottomItems: $loadingBottomItems, requestedBottomScroll: $requestedBottomScroll, animatedScrollingInProgress: $animatedScrollingInProgress, listState: scrollView.listState, model: floatingButtonModel)
mergedItems.boxedValue = MergedItems.create(im.reversedChatItems, revealedItems, im.chatState)
scrollView.updateItems(mergedItems.boxedValue.items)
}
)
} }
connectingText() connectingText()
if selectedChatItems == nil { if selectedChatItems == nil {
let reason = chat.chatInfo.userCantSendReason
ComposeView( ComposeView(
chat: chat, chat: chat,
composeState: $composeState, composeState: $composeState,
keyboardVisible: $keyboardVisible, keyboardVisible: $keyboardVisible,
keyboardHiddenDate: $keyboardHiddenDate, keyboardHiddenDate: $keyboardHiddenDate,
selectedRange: $selectedRange, selectedRange: $selectedRange
disabledText: reason?.composeLabel
) )
.disabled(!cInfo.sendMsgEnabled) .disabled(!cInfo.sendMsgEnabled)
.if(!cInfo.sendMsgEnabled) { v in
v.disabled(true).onTapGesture {
AlertManager.shared.showAlertMsg(
title: "You can't send messages!",
message: reason?.alertMessage
)
}
}
} else { } else {
SelectedItemsBottomToolbar( SelectedItemsBottomToolbar(
chatItems: ItemsModel.shared.reversedChatItems, chatItems: ItemsModel.shared.reversedChatItems,
@ -275,6 +262,7 @@ struct ChatView: View {
// this may already being loading because of changed chat id (see .onChange(of: chat.id) // this may already being loading because of changed chat id (see .onChange(of: chat.id)
if !loadingBottomItems { if !loadingBottomItems {
loadLastItems($loadingMoreItems, loadingBottomItems: $loadingBottomItems, chat)
allowLoadMoreItems = false allowLoadMoreItems = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
allowLoadMoreItems = true allowLoadMoreItems = true
@ -290,7 +278,7 @@ struct ChatView: View {
if chatModel.chatId == nil { if chatModel.chatId == nil {
chatModel.chatItemStatuses = [:] chatModel.chatItemStatuses = [:]
ItemsModel.shared.reversedChatItems = [] ItemsModel.shared.reversedChatItems = []
ItemsModel.shared.chatState.clear() ItemsModel.shared.chatItemsChangesListener.cleared()
chatModel.groupMembers = [] chatModel.groupMembers = []
chatModel.groupMembersIndexes.removeAll() chatModel.groupMembersIndexes.removeAll()
chatModel.membersLoaded = false chatModel.membersLoaded = false
@ -506,7 +494,7 @@ struct ChatView: View {
Button ("Cancel") { Button ("Cancel") {
closeSearch() closeSearch()
searchTextChanged("") Task { await loadChat(chat: chat) }
} }
} }
.padding(.horizontal) .padding(.horizontal)
@ -582,20 +570,13 @@ struct ChatView: View {
.onChange(of: im.reversedChatItems) { items in .onChange(of: im.reversedChatItems) { items in
mergedItems.boxedValue = MergedItems.create(items, revealedItems, im.chatState) mergedItems.boxedValue = MergedItems.create(items, revealedItems, im.chatState)
scrollView.updateItems(mergedItems.boxedValue.items) scrollView.updateItems(mergedItems.boxedValue.items)
if im.itemAdded {
im.itemAdded = false
if scrollView.listState.firstVisibleItemIndex < 2 {
scrollView.scrollToBottomAnimated()
} else {
scrollView.scroll(by: 34)
}
}
} }
.onChange(of: revealedItems) { revealed in .onChange(of: revealedItems) { revealed in
mergedItems.boxedValue = MergedItems.create(im.reversedChatItems, revealed, im.chatState) mergedItems.boxedValue = MergedItems.create(im.reversedChatItems, revealed, im.chatState)
scrollView.updateItems(mergedItems.boxedValue.items) scrollView.updateItems(mergedItems.boxedValue.items)
} }
.onChange(of: chat.id) { _ in .onChange(of: chat.id) { _ in
loadLastItems($loadingMoreItems, loadingBottomItems: $loadingBottomItems, chat)
allowLoadMoreItems = false allowLoadMoreItems = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
allowLoadMoreItems = true allowLoadMoreItems = true
@ -604,8 +585,33 @@ struct ChatView: View {
.padding(.vertical, -100) .padding(.vertical, -100)
.onTapGesture { hideKeyboard() } .onTapGesture { hideKeyboard() }
.onChange(of: searchText) { s in .onChange(of: searchText) { s in
if showSearch { guard showSearch else { return }
searchTextChanged(s) Task {
await loadChat(chat: chat, search: s)
mergedItems.boxedValue = MergedItems.create(im.reversedChatItems, revealedItems, im.chatState)
await MainActor.run {
scrollView.updateItems(mergedItems.boxedValue.items)
}
if !s.isEmpty {
scrollView.scrollToBottom()
} else if let index = scrollView.listState.items.lastIndex(where: { $0.hasUnread() }) {
// scroll to the top unread item
scrollView.scrollToItem(index)
loadLastItems($loadingMoreItems, loadingBottomItems: $loadingBottomItems, chat)
} else {
scrollView.scrollToBottom()
loadLastItems($loadingMoreItems, loadingBottomItems: $loadingBottomItems, chat)
}
}
}
.onChange(of: im.itemAdded) { added in
if added {
im.itemAdded = false
if scrollView.listState.firstVisibleItemIndex < 2 {
scrollView.scrollToBottomAnimated()
} else {
scrollView.scroll(by: 34)
}
} }
} }
} }
@ -640,29 +646,12 @@ struct ChatView: View {
if let unreadIndex { if let unreadIndex {
scrollView.scrollToItem(unreadIndex) scrollView.scrollToItem(unreadIndex)
} }
loadLastItems($loadingMoreItems, loadingBottomItems: $loadingBottomItems, chat)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
allowLoadMoreItems = true allowLoadMoreItems = true
} }
} }
private func searchTextChanged(_ s: String) {
Task {
await loadChat(chat: chat, search: s)
mergedItems.boxedValue = MergedItems.create(im.reversedChatItems, revealedItems, im.chatState)
await MainActor.run {
scrollView.updateItems(mergedItems.boxedValue.items)
}
if !s.isEmpty {
scrollView.scrollToBottom()
} else if let index = scrollView.listState.items.lastIndex(where: { $0.hasUnread() }) {
// scroll to the top unread item
scrollView.scrollToItem(index)
} else {
scrollView.scrollToBottom()
}
}
}
class FloatingButtonModel: ObservableObject { class FloatingButtonModel: ObservableObject {
@Published var unreadAbove: Int = 0 @Published var unreadAbove: Int = 0
@Published var unreadBelow: Int = 0 @Published var unreadBelow: Int = 0
@ -739,7 +728,6 @@ struct ChatView: View {
let theme: AppTheme let theme: AppTheme
let scrollView: EndlessScrollView<MergedItem> let scrollView: EndlessScrollView<MergedItem>
let chat: Chat let chat: Chat
@Binding var loadingMoreItems: Bool
@Binding var loadingTopItems: Bool @Binding var loadingTopItems: Bool
@Binding var requestedTopScroll: Bool @Binding var requestedTopScroll: Bool
@Binding var loadingBottomItems: Bool @Binding var loadingBottomItems: Bool
@ -747,7 +735,6 @@ struct ChatView: View {
@Binding var animatedScrollingInProgress: Bool @Binding var animatedScrollingInProgress: Bool
let listState: EndlessScrollView<MergedItem>.ListState let listState: EndlessScrollView<MergedItem>.ListState
@ObservedObject var model: FloatingButtonModel @ObservedObject var model: FloatingButtonModel
let reloadItems: () -> Void
var body: some View { var body: some View {
ZStack(alignment: .top) { ZStack(alignment: .top) {
@ -805,7 +792,7 @@ struct ChatView: View {
} }
} }
.onTapGesture { .onTapGesture {
if loadingBottomItems || !ItemsModel.shared.lastItemsLoaded { if loadingBottomItems {
requestedTopScroll = false requestedTopScroll = false
requestedBottomScroll = true requestedBottomScroll = true
} else { } else {
@ -825,7 +812,7 @@ struct ChatView: View {
} }
} }
.onChange(of: loadingBottomItems) { loading in .onChange(of: loadingBottomItems) { loading in
if !loading && requestedBottomScroll && ItemsModel.shared.lastItemsLoaded { if !loading && requestedBottomScroll {
requestedBottomScroll = false requestedBottomScroll = false
scrollToBottom() scrollToBottom()
} }
@ -834,25 +821,15 @@ struct ChatView: View {
} }
private func scrollToTopUnread() { private func scrollToTopUnread() {
Task { if let index = listState.items.lastIndex(where: { $0.hasUnread() }) {
if !ItemsModel.shared.chatState.splits.isEmpty { animatedScrollingInProgress = true
await MainActor.run { loadingMoreItems = true } // scroll to the top unread item
await loadChat(chatId: chat.id, openAroundItemId: nil, clearItems: false) Task {
await MainActor.run { reloadItems() }
if let index = listState.items.lastIndex(where: { $0.hasUnread() }) {
await MainActor.run { animatedScrollingInProgress = true }
await scrollView.scrollToItemAnimated(index)
await MainActor.run { animatedScrollingInProgress = false }
}
await MainActor.run { loadingMoreItems = false }
} else if let index = listState.items.lastIndex(where: { $0.hasUnread() }) {
await MainActor.run { animatedScrollingInProgress = true }
// scroll to the top unread item
await scrollView.scrollToItemAnimated(index) await scrollView.scrollToItemAnimated(index)
await MainActor.run { animatedScrollingInProgress = false } await MainActor.run { animatedScrollingInProgress = false }
} else {
logger.debug("No more unread items, total: \(listState.items.count)")
} }
} else {
logger.debug("No more unread items, total: \(listState.items.count)")
} }
} }
@ -1167,11 +1144,6 @@ struct ChatView: View {
} else { } else {
await loadChatItems(chat, pagination) await loadChatItems(chat, pagination)
} }
},
loadLastItems: {
if !loadingMoreItems {
await loadLastItems($loadingMoreItems, loadingBottomItems: $loadingBottomItems, chat)
}
} }
) )
} }
@ -1272,11 +1244,18 @@ struct ChatView: View {
nil nil
} }
let showAvatar = shouldShowAvatar(item, listItem.nextItem) let showAvatar = shouldShowAvatar(item, listItem.nextItem)
let itemSeparation: ItemSeparation
let single = switch merged { let single = switch merged {
case .single: true case .single: true
default: false default: false
} }
let itemSeparation = getItemSeparation(item, single || revealed ? listItem.prevItem: nil) if single || revealed {
let prev = listItem.prevItem
itemSeparation = getItemSeparation(item, prev)
let nextForGap = (item.mergeCategory != nil && item.mergeCategory == prev?.mergeCategory) || isLastItem ? nil : listItem.nextItem
} else {
itemSeparation = getItemSeparation(item, nil)
}
return VStack(spacing: 0) { return VStack(spacing: 0) {
if let last { if let last {
DateSeparator(date: last.meta.itemTs).padding(8) DateSeparator(date: last.meta.itemTs).padding(8)
@ -1286,10 +1265,10 @@ struct ChatView: View {
if let selected = selectedChatItems, chatItem.canBeDeletedForSelf { if let selected = selectedChatItems, chatItem.canBeDeletedForSelf {
Color.clear Color.clear
.contentShape(Rectangle()) .contentShape(Rectangle())
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
let checked = selected.contains(chatItem.id) let checked = selected.contains(chatItem.id)
selectUnselectChatItem(select: !checked, chatItem) selectUnselectChatItem(select: !checked, chatItem)
}) }
} }
} }
if let date = itemSeparation.date { if let date = itemSeparation.date {
@ -1338,9 +1317,6 @@ struct ChatView: View {
var unreadMentions: Int = 0 var unreadMentions: Int = 0
for i in range { for i in range {
if i < 0 || i >= im.reversedChatItems.count {
break
}
let ci = im.reversedChatItems[i] let ci = im.reversedChatItems[i]
if ci.isRcvNew { if ci.isRcvNew {
unreadItems.append(ci.id) unreadItems.append(ci.id)
@ -1478,7 +1454,7 @@ struct ChatView: View {
} }
HStack(alignment: .top, spacing: 10) { HStack(alignment: .top, spacing: 10) {
MemberProfileImage(member, size: memberImageSize, backgroundColor: theme.colors.background) MemberProfileImage(member, size: memberImageSize, backgroundColor: theme.colors.background)
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
if let mem = m.getGroupMember(member.groupMemberId) { if let mem = m.getGroupMember(member.groupMemberId) {
selectedMember = mem selectedMember = mem
} else { } else {
@ -1487,7 +1463,7 @@ struct ChatView: View {
m.groupMembersIndexes[member.groupMemberId] = m.groupMembers.count - 1 m.groupMembersIndexes[member.groupMemberId] = m.groupMembers.count - 1
selectedMember = mem selectedMember = mem
} }
}) }
chatItemWithMenu(ci, range, maxWidth, itemSeparation) chatItemWithMenu(ci, range, maxWidth, itemSeparation)
.onPreferenceChange(DetermineWidth.Key.self) { msgWidth = $0 } .onPreferenceChange(DetermineWidth.Key.self) { msgWidth = $0 }
} }
@ -1537,9 +1513,9 @@ struct ChatView: View {
} }
} }
func chatItemWithMenu(_ ci: ChatItem, _ range: ClosedRange<Int>?, _ maxWidth: CGFloat, _ itemSeparation: ItemSeparation) -> some View { @ViewBuilder func chatItemWithMenu(_ ci: ChatItem, _ range: ClosedRange<Int>?, _ maxWidth: CGFloat, _ itemSeparation: ItemSeparation) -> some View {
let alignment: Alignment = ci.chatDir.sent ? .trailing : .leading let alignment: Alignment = ci.chatDir.sent ? .trailing : .leading
return VStack(alignment: alignment.horizontal, spacing: 3) { VStack(alignment: alignment.horizontal, spacing: 3) {
HStack { HStack {
if ci.chatDir.sent { if ci.chatDir.sent {
goToItemButton(true) goToItemButton(true)
@ -1631,9 +1607,9 @@ struct ChatView: View {
.padding(.horizontal, 6) .padding(.horizontal, 6)
.padding(.vertical, 4) .padding(.vertical, 4)
.if(chat.chatInfo.featureEnabled(.reactions) && (ci.allowAddReaction || r.userReacted)) { v in .if(chat.chatInfo.featureEnabled(.reactions) && (ci.allowAddReaction || r.userReacted)) { v in
v.simultaneousGesture(TapGesture().onEnded { v.onTapGesture {
setReaction(ci, add: !r.userReacted, reaction: r.reaction) setReaction(ci, add: !r.userReacted, reaction: r.reaction)
}) }
} }
switch chat.chatInfo { switch chat.chatInfo {
case let .group(groupInfo): case let .group(groupInfo):
@ -2223,12 +2199,15 @@ struct ChatView: View {
} }
func goToItemInnerButton(_ alignStart: Bool, _ image: String, touchInProgress: Bool, _ onClick: @escaping () -> Void) -> some View { func goToItemInnerButton(_ alignStart: Bool, _ image: String, touchInProgress: Bool, _ onClick: @escaping () -> Void) -> some View {
Image(systemName: image) Button {
.resizable() onClick()
.frame(width: 13, height: 13) } label: {
.padding([alignStart ? .trailing : .leading], 10) Image(systemName: image)
.tint(theme.colors.secondary.opacity(touchInProgress ? 1.0 : 0.4)) .resizable()
.simultaneousGesture(TapGesture().onEnded(onClick)) .frame(width: 13, height: 13)
.padding([alignStart ? .trailing : .leading], 10)
.tint(theme.colors.secondary.opacity(touchInProgress ? 1.0 : 0.4))
}
} }
@ViewBuilder @ViewBuilder
@ -2389,7 +2368,7 @@ struct ReactionContextMenu: View {
@ViewBuilder private func groupMemberReactionList() -> some View { @ViewBuilder private func groupMemberReactionList() -> some View {
if memberReactions.isEmpty { if memberReactions.isEmpty {
ForEach(Array(repeating: 0, count: reactionCount.totalReacted), id: \.self) { _ in ForEach(Array(repeating: 0, count: reactionCount.totalReacted), id: \.self) { _ in
textSpace Text(verbatim: " ")
} }
} else { } else {
ForEach(memberReactions, id: \.groupMember.groupMemberId) { mr in ForEach(memberReactions, id: \.groupMember.groupMemberId) { mr in

View file

@ -18,7 +18,7 @@ struct ComposeLinkView: View {
var body: some View { var body: some View {
HStack(alignment: .center, spacing: 8) { HStack(alignment: .center, spacing: 8) {
if let linkPreview { if let linkPreview = linkPreview {
linkPreviewView(linkPreview) linkPreviewView(linkPreview)
} else { } else {
ProgressView() ProgressView()

View file

@ -327,7 +327,6 @@ struct ComposeView: View {
@Binding var keyboardVisible: Bool @Binding var keyboardVisible: Bool
@Binding var keyboardHiddenDate: Date @Binding var keyboardHiddenDate: Date
@Binding var selectedRange: NSRange @Binding var selectedRange: NSRange
var disabledText: LocalizedStringKey? = nil
@State var linkUrl: URL? = nil @State var linkUrl: URL? = nil
@State var hasSimplexLink: Bool = false @State var hasSimplexLink: Bool = false
@ -392,7 +391,7 @@ struct ComposeView: View {
Image(systemName: "paperclip") Image(systemName: "paperclip")
.resizable() .resizable()
} }
.disabled(composeState.attachmentDisabled || !chat.chatInfo.sendMsgEnabled || (chat.chatInfo.contact?.nextSendGrpInv ?? false)) .disabled(composeState.attachmentDisabled || !chat.userCanSend || (chat.chatInfo.contact?.nextSendGrpInv ?? false))
.frame(width: 25, height: 25) .frame(width: 25, height: 25)
.padding(.bottom, 16) .padding(.bottom, 16)
.padding(.leading, 12) .padding(.leading, 12)
@ -442,13 +441,19 @@ struct ComposeView: View {
: theme.colors.primary : theme.colors.primary
) )
.padding(.trailing, 12) .padding(.trailing, 12)
.disabled(!chat.chatInfo.sendMsgEnabled) .disabled(!chat.userCanSend)
if let disabledText { if chat.userIsObserver {
Text(disabledText) Text("you are observer")
.italic() .italic()
.foregroundColor(theme.colors.secondary) .foregroundColor(theme.colors.secondary)
.padding(.horizontal, 12) .padding(.horizontal, 12)
.onTapGesture {
AlertManager.shared.showAlertMsg(
title: "You can't send messages!",
message: "Please contact group admin."
)
}
} }
} }
} }
@ -474,8 +479,8 @@ struct ComposeView: View {
hasSimplexLink = false hasSimplexLink = false
} }
} }
.onChange(of: chat.chatInfo.sendMsgEnabled) { sendEnabled in .onChange(of: chat.userCanSend) { canSend in
if !sendEnabled { if !canSend {
cancelCurrentVoiceRecording() cancelCurrentVoiceRecording()
clearCurrentDraft() clearCurrentDraft()
clearState() clearState()
@ -1249,14 +1254,11 @@ struct ComposeView: View {
if pendingLinkUrl == url { if pendingLinkUrl == url {
composeState = composeState.copy(preview: .linkPreview(linkPreview: nil)) composeState = composeState.copy(preview: .linkPreview(linkPreview: nil))
getLinkPreview(url: url) { linkPreview in getLinkPreview(url: url) { linkPreview in
if let linkPreview, pendingLinkUrl == url { if let linkPreview = linkPreview,
pendingLinkUrl == url {
composeState = composeState.copy(preview: .linkPreview(linkPreview: linkPreview)) composeState = composeState.copy(preview: .linkPreview(linkPreview: linkPreview))
} else { pendingLinkUrl = nil
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
composeState = composeState.copy(preview: .noPreview)
}
} }
pendingLinkUrl = nil
} }
} }
} }

View file

@ -70,10 +70,8 @@ struct ContextItemView: View {
.lineLimit(lines) .lineLimit(lines)
} }
private func contextMsgPreview(_ contextItem: ChatItem) -> some View { private func contextMsgPreview(_ contextItem: ChatItem) -> Text {
let r = messageText(contextItem.text, contextItem.formattedText, sender: nil, preview: true, mentions: contextItem.mentions, userMemberId: nil, showSecrets: nil, backgroundColor: UIColor(background)) return attachment() + messageText(contextItem.text, contextItem.formattedText, nil, preview: true, mentions: contextItem.mentions, userMemberId: nil, showSecrets: false, secondaryColor: theme.colors.secondary)
let t = attachment() + Text(AttributedString(r.string))
return t.if(r.hasSecrets, transform: hiddenSecretsView)
func attachment() -> Text { func attachment() -> Text {
let isFileLoaded = if let fileSource = getLoadedFileSource(contextItem.file) { let isFileLoaded = if let fileSource = getLoadedFileSource(contextItem.file) {

View file

@ -15,7 +15,6 @@ struct SendMessageView: View {
@Binding var composeState: ComposeState @Binding var composeState: ComposeState
@Binding var selectedRange: NSRange @Binding var selectedRange: NSRange
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
@Environment(\.isEnabled) var isEnabled
var sendMessage: (Int?) -> Void var sendMessage: (Int?) -> Void
var sendLiveMessage: (() async -> Void)? = nil var sendLiveMessage: (() async -> Void)? = nil
var updateLiveMessage: (() async -> Void)? = nil var updateLiveMessage: (() async -> Void)? = nil
@ -256,7 +255,6 @@ struct SendMessageView: View {
} }
private struct RecordVoiceMessageButton: View { private struct RecordVoiceMessageButton: View {
@Environment(\.isEnabled) var isEnabled
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
var startVoiceMessageRecording: (() -> Void)? var startVoiceMessageRecording: (() -> Void)?
var finishVoiceMessageRecording: (() -> Void)? var finishVoiceMessageRecording: (() -> Void)?
@ -265,12 +263,13 @@ struct SendMessageView: View {
@State private var pressed: TimeInterval? = nil @State private var pressed: TimeInterval? = nil
var body: some View { var body: some View {
Image(systemName: isEnabled ? "mic.fill" : "mic") Button(action: {}) {
.resizable() Image(systemName: "mic.fill")
.scaledToFit() .resizable()
.frame(width: 20, height: 20) .scaledToFit()
.foregroundColor(isEnabled ? theme.colors.primary : theme.colors.secondary) .frame(width: 20, height: 20)
.opacity(holdingVMR ? 0.7 : 1) .foregroundColor(theme.colors.primary)
}
.disabled(disabled) .disabled(disabled)
.frame(width: 31, height: 31) .frame(width: 31, height: 31)
.padding([.bottom, .trailing], 4) .padding([.bottom, .trailing], 4)
@ -280,7 +279,9 @@ struct SendMessageView: View {
pressed = ProcessInfo.processInfo.systemUptime pressed = ProcessInfo.processInfo.systemUptime
startVoiceMessageRecording?() startVoiceMessageRecording?()
} else { } else {
if let pressed, ProcessInfo.processInfo.systemUptime - pressed >= 1 { let now = ProcessInfo.processInfo.systemUptime
if let pressed = pressed,
now - pressed >= 1 {
finishVoiceMessageRecording?() finishVoiceMessageRecording?()
} }
holdingVMR = false holdingVMR = false
@ -354,7 +355,7 @@ struct SendMessageView: View {
Image(systemName: "bolt.fill") Image(systemName: "bolt.fill")
.resizable() .resizable()
.scaledToFit() .scaledToFit()
.foregroundColor(isEnabled ? theme.colors.primary : theme.colors.secondary) .foregroundColor(theme.colors.primary)
.frame(width: 20, height: 20) .frame(width: 20, height: 20)
} }
.frame(width: 29, height: 29) .frame(width: 29, height: 29)

View file

@ -171,9 +171,6 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
visibleItems.last?.index ?? 0 visibleItems.last?.index ?? 0
} }
/// Specifies if visible items cover the whole screen or can cover it (if overscrolled)
var itemsCanCoverScreen: Bool = false
/// Whether there is a non-animated scroll to item in progress or not /// Whether there is a non-animated scroll to item in progress or not
var isScrolling: Bool = false var isScrolling: Bool = false
/// Whether there is an animated scroll to item in progress or not /// Whether there is an animated scroll to item in progress or not
@ -287,8 +284,7 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
func updateItems(_ items: [ScrollItem], _ forceReloadVisible: Bool = false) { func updateItems(_ items: [ScrollItem], _ forceReloadVisible: Bool = false) {
if !Thread.isMainThread { if !Thread.isMainThread {
logger.error("Use main thread to update items") fatalError("Use main thread to update items")
return
} }
if bounds.height == 0 { if bounds.height == 0 {
self.listState.items = items self.listState.items = items
@ -306,7 +302,6 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
if items.isEmpty { if items.isEmpty {
listState.visibleItems.forEach { item in item.view.removeFromSuperview() } listState.visibleItems.forEach { item in item.view.removeFromSuperview() }
listState.visibleItems = [] listState.visibleItems = []
listState.itemsCanCoverScreen = false
listState.firstVisibleItemId = EndlessScrollView<ScrollItem>.DEFAULT_ITEM_ID listState.firstVisibleItemId = EndlessScrollView<ScrollItem>.DEFAULT_ITEM_ID
listState.firstVisibleItemIndex = 0 listState.firstVisibleItemIndex = 0
listState.firstVisibleItemOffset = -insetTop listState.firstVisibleItemOffset = -insetTop
@ -327,7 +322,6 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
var oldVisible = listState.visibleItems var oldVisible = listState.visibleItems
var newVisible: [VisibleItem] = [] var newVisible: [VisibleItem] = []
var visibleItemsHeight: CGFloat = 0
let offsetsDiff = contentOffsetY - prevProcessedOffset let offsetsDiff = contentOffsetY - prevProcessedOffset
var shouldBeFirstVisible = items.firstIndex(where: { item in item.id == listState.firstVisibleItemId as! ScrollItem.ID }) ?? 0 var shouldBeFirstVisible = items.firstIndex(where: { item in item.id == listState.firstVisibleItemId as! ScrollItem.ID }) ?? 0
@ -345,11 +339,7 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
if let visibleIndex { if let visibleIndex {
let v = oldVisible.remove(at: visibleIndex) let v = oldVisible.remove(at: visibleIndex)
if forceReloadVisible || v.view.bounds.width != bounds.width || v.item.hashValue != item.hashValue { if forceReloadVisible || v.view.bounds.width != bounds.width || v.item.hashValue != item.hashValue {
let wasHeight = v.view.bounds.height
updateCell(v.view, i, items) updateCell(v.view, i, items)
if wasHeight < v.view.bounds.height && i == 0 && shouldBeFirstVisible == i {
v.view.frame.origin.y -= v.view.bounds.height - wasHeight
}
} }
visible = v visible = v
} else { } else {
@ -399,7 +389,6 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
addSubview(vis.view) addSubview(vis.view)
} }
newVisible.append(vis) newVisible.append(vis)
visibleItemsHeight += vis.view.frame.height
nextOffsetY = vis.view.frame.origin.y nextOffsetY = vis.view.frame.origin.y
} else { } else {
let vis: VisibleItem let vis: VisibleItem
@ -417,7 +406,6 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
addSubview(vis.view) addSubview(vis.view)
} }
newVisible.append(vis) newVisible.append(vis)
visibleItemsHeight += vis.view.frame.height
} }
if abs(nextOffsetY) < contentOffsetY && !allowOneMore { if abs(nextOffsetY) < contentOffsetY && !allowOneMore {
break break
@ -447,7 +435,6 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
} }
offset += vis.view.frame.height offset += vis.view.frame.height
newVisible.insert(vis, at: 0) newVisible.insert(vis, at: 0)
visibleItemsHeight += vis.view.frame.height
if offset >= contentOffsetY + bounds.height { if offset >= contentOffsetY + bounds.height {
break break
} }
@ -463,15 +450,11 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
prevProcessedOffset = contentOffsetY prevProcessedOffset = contentOffsetY
listState.visibleItems = newVisible listState.visibleItems = newVisible
// bottom drawing starts from 0 until top visible area at least (bound.height - insetTop) or above top bar (bounds.height). listState.items = items
// For visible items to preserve offset after adding more items having such height is enough
listState.itemsCanCoverScreen = visibleItemsHeight >= bounds.height - insetTop
listState.firstVisibleItemId = listState.visibleItems.first?.item.id ?? EndlessScrollView<ScrollItem>.DEFAULT_ITEM_ID listState.firstVisibleItemId = listState.visibleItems.first?.item.id ?? EndlessScrollView<ScrollItem>.DEFAULT_ITEM_ID
listState.firstVisibleItemIndex = listState.visibleItems.first?.index ?? 0 listState.firstVisibleItemIndex = listState.visibleItems.first?.index ?? 0
listState.firstVisibleItemOffset = listState.visibleItems.first?.offset ?? -insetTop listState.firstVisibleItemOffset = listState.visibleItems.first?.offset ?? -insetTop
// updating the items with the last step in order to call listener with fully updated state
listState.items = items
estimatedContentHeight.update(contentOffset, listState, averageItemHeight, itemsCountChanged) estimatedContentHeight.update(contentOffset, listState, averageItemHeight, itemsCountChanged)
scrollBarView.contentSize = CGSizeMake(bounds.width, estimatedContentHeight.virtualOverscrolledHeight) scrollBarView.contentSize = CGSizeMake(bounds.width, estimatedContentHeight.virtualOverscrolledHeight)
@ -534,7 +517,7 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
let y = if top { let y = if top {
min(estimatedContentHeight.bottomOffsetY - bounds.height, item.view.frame.origin.y - insetTop) min(estimatedContentHeight.bottomOffsetY - bounds.height, item.view.frame.origin.y - insetTop)
} else { } else {
max(estimatedContentHeight.topOffsetY - insetTop - insetBottom, item.view.frame.origin.y + item.view.bounds.height - bounds.height + insetBottom) max(estimatedContentHeight.topOffsetY - insetTop, item.view.frame.origin.y + item.view.bounds.height - bounds.height + insetBottom)
} }
setContentOffset(CGPointMake(contentOffset.x, y), animated: false) setContentOffset(CGPointMake(contentOffset.x, y), animated: false)
scrollBarView.flashScrollIndicators() scrollBarView.flashScrollIndicators()
@ -585,7 +568,7 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
let y = if top { let y = if top {
min(estimatedContentHeight.bottomOffsetY - bounds.height, item.view.frame.origin.y - insetTop) min(estimatedContentHeight.bottomOffsetY - bounds.height, item.view.frame.origin.y - insetTop)
} else { } else {
max(estimatedContentHeight.topOffsetY - insetTop - insetBottom, item.view.frame.origin.y + item.view.bounds.height - bounds.height + insetBottom) max(estimatedContentHeight.topOffsetY - insetTop, item.view.frame.origin.y + item.view.bounds.height - bounds.height + insetBottom)
} }
setContentOffset(CGPointMake(contentOffset.x, y), animated: true) setContentOffset(CGPointMake(contentOffset.x, y), animated: true)
scrollBarView.flashScrollIndicators() scrollBarView.flashScrollIndicators()
@ -649,7 +632,7 @@ class EndlessScrollView<ScrollItem>: UIScrollView, UIScrollViewDelegate, UIGestu
} }
(view as? ReusableView)?.prepareForReuse() (view as? ReusableView)?.prepareForReuse()
view.isHidden = true view.isHidden = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
if view.isHidden { view.removeFromSuperview() } if view.isHidden { view.removeFromSuperview() }
} }
} }

View file

@ -145,9 +145,9 @@ struct AddGroupMembersViewCommon: View {
return dummy return dummy
}() }()
private func inviteMembersButton() -> some View { @ViewBuilder private func inviteMembersButton() -> some View {
let label: LocalizedStringKey = groupInfo.businessChat == nil ? "Invite to group" : "Invite to chat" let label: LocalizedStringKey = groupInfo.businessChat == nil ? "Invite to group" : "Invite to chat"
return Button { Button {
inviteMembers() inviteMembers()
} label: { } label: {
HStack { HStack {

View file

@ -21,7 +21,7 @@ struct GroupChatInfoView: View {
@State var localAlias: String @State var localAlias: String
@FocusState private var aliasTextFieldFocused: Bool @FocusState private var aliasTextFieldFocused: Bool
@State private var alert: GroupChatInfoViewAlert? = nil @State private var alert: GroupChatInfoViewAlert? = nil
@State private var groupLink: CreatedConnLink? @State private var groupLink: String?
@State private var groupLinkMemberRole: GroupMemberRole = .member @State private var groupLinkMemberRole: GroupMemberRole = .member
@State private var groupLinkNavLinkActive: Bool = false @State private var groupLinkNavLinkActive: Bool = false
@State private var addMembersNavLinkActive: Bool = false @State private var addMembersNavLinkActive: Bool = false
@ -144,9 +144,17 @@ struct GroupChatInfoView: View {
let filteredMembers = s == "" let filteredMembers = s == ""
? members ? members
: members.filter { $0.wrapped.localAliasAndFullName.localizedLowercase.contains(s) } : members.filter { $0.wrapped.localAliasAndFullName.localizedLowercase.contains(s) }
MemberRowView(chat: chat, groupInfo: groupInfo, groupMember: GMember(groupInfo.membership), user: true, alert: $alert) MemberRowView(groupInfo: groupInfo, groupMember: GMember(groupInfo.membership), user: true, alert: $alert)
ForEach(filteredMembers) { member in ForEach(filteredMembers) { member in
MemberRowView(chat: chat, groupInfo: groupInfo, groupMember: member, alert: $alert) ZStack {
NavigationLink {
memberInfoView(member)
} label: {
EmptyView()
}
.opacity(0)
MemberRowView(groupInfo: groupInfo, groupMember: member, alert: $alert)
}
} }
} }
@ -284,9 +292,9 @@ struct GroupChatInfoView: View {
.disabled(!groupInfo.ready || chat.chatItems.isEmpty) .disabled(!groupInfo.ready || chat.chatItems.isEmpty)
} }
private func addMembersActionButton(width: CGFloat) -> some View { @ViewBuilder private func addMembersActionButton(width: CGFloat) -> some View {
ZStack { if chat.chatInfo.incognito {
if chat.chatInfo.incognito { ZStack {
InfoViewButton(image: "link.badge.plus", title: "invite", width: width) { InfoViewButton(image: "link.badge.plus", title: "invite", width: width) {
groupLinkNavLinkActive = true groupLinkNavLinkActive = true
} }
@ -298,7 +306,10 @@ struct GroupChatInfoView: View {
} }
.frame(width: 1, height: 1) .frame(width: 1, height: 1)
.hidden() .hidden()
} else { }
.disabled(!groupInfo.ready)
} else {
ZStack {
InfoViewButton(image: "person.fill.badge.plus", title: "invite", width: width) { InfoViewButton(image: "person.fill.badge.plus", title: "invite", width: width) {
addMembersNavLinkActive = true addMembersNavLinkActive = true
} }
@ -311,8 +322,8 @@ struct GroupChatInfoView: View {
.frame(width: 1, height: 1) .frame(width: 1, height: 1)
.hidden() .hidden()
} }
.disabled(!groupInfo.ready)
} }
.disabled(!groupInfo.ready)
} }
private func muteButton(width: CGFloat, nextNtfMode: MsgFilter) -> some View { private func muteButton(width: CGFloat, nextNtfMode: MsgFilter) -> some View {
@ -350,7 +361,6 @@ struct GroupChatInfoView: View {
} }
private struct MemberRowView: View { private struct MemberRowView: View {
var chat: Chat
var groupInfo: GroupInfo var groupInfo: GroupInfo
@ObservedObject var groupMember: GMember @ObservedObject var groupMember: GMember
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
@ -359,7 +369,7 @@ struct GroupChatInfoView: View {
var body: some View { var body: some View {
let member = groupMember.wrapped let member = groupMember.wrapped
let v1 = HStack{ let v = HStack{
MemberProfileImage(member, size: 38) MemberProfileImage(member, size: 38)
.padding(.trailing, 2) .padding(.trailing, 2)
// TODO server connection status // TODO server connection status
@ -376,20 +386,6 @@ struct GroupChatInfoView: View {
memberInfo(member) memberInfo(member)
} }
let v = ZStack {
if user {
v1
} else {
NavigationLink {
memberInfoView()
} label: {
EmptyView()
}
.opacity(0)
v1
}
}
if user { if user {
v v
} else if groupInfo.membership.memberRole >= .admin { } else if groupInfo.membership.memberRole >= .admin {
@ -414,11 +410,6 @@ struct GroupChatInfoView: View {
} }
} }
private func memberInfoView() -> some View {
GroupMemberInfoView(groupInfo: groupInfo, chat: chat, groupMember: groupMember)
.navigationBarHidden(false)
}
private func memberConnStatus(_ member: GroupMember) -> LocalizedStringKey { private func memberConnStatus(_ member: GroupMember) -> LocalizedStringKey {
if member.activeConn?.connDisabled ?? false { if member.activeConn?.connDisabled ?? false {
return "disabled" return "disabled"
@ -497,6 +488,11 @@ struct GroupChatInfoView: View {
.foregroundColor(theme.colors.secondary) .foregroundColor(theme.colors.secondary)
} }
} }
private func memberInfoView(_ groupMember: GMember) -> some View {
GroupMemberInfoView(groupInfo: groupInfo, chat: chat, groupMember: groupMember)
.navigationBarHidden(false)
}
private func groupLinkButton() -> some View { private func groupLinkButton() -> some View {
NavigationLink { NavigationLink {
@ -573,9 +569,9 @@ struct GroupChatInfoView: View {
} }
} }
private func leaveGroupButton() -> some View { @ViewBuilder private func leaveGroupButton() -> some View {
let label: LocalizedStringKey = groupInfo.businessChat == nil ? "Leave group" : "Leave chat" let label: LocalizedStringKey = groupInfo.businessChat == nil ? "Leave group" : "Leave chat"
return Button(role: .destructive) { Button(role: .destructive) {
alert = .leaveGroupAlert alert = .leaveGroupAlert
} label: { } label: {
Label(label, systemImage: "rectangle.portrait.and.arrow.right") Label(label, systemImage: "rectangle.portrait.and.arrow.right")

View file

@ -10,14 +10,12 @@ import SwiftUI
import SimpleXChat import SimpleXChat
struct GroupLinkView: View { struct GroupLinkView: View {
@EnvironmentObject var theme: AppTheme
var groupId: Int64 var groupId: Int64
@Binding var groupLink: CreatedConnLink? @Binding var groupLink: String?
@Binding var groupLinkMemberRole: GroupMemberRole @Binding var groupLinkMemberRole: GroupMemberRole
var showTitle: Bool = false var showTitle: Bool = false
var creatingGroup: Bool = false var creatingGroup: Bool = false
var linkCreatedCb: (() -> Void)? = nil var linkCreatedCb: (() -> Void)? = nil
@State private var showShortLink = true
@State private var creatingLink = false @State private var creatingLink = false
@State private var alert: GroupLinkAlert? @State private var alert: GroupLinkAlert?
@State private var shouldCreate = true @State private var shouldCreate = true
@ -71,10 +69,10 @@ struct GroupLinkView: View {
} }
} }
.frame(height: 36) .frame(height: 36)
SimpleXCreatedLinkQRCode(link: groupLink, short: $showShortLink) SimpleXLinkQRCode(uri: groupLink)
.id("simplex-qrcode-view-for-\(groupLink.simplexChatUri(short: showShortLink))") .id("simplex-qrcode-view-for-\(groupLink)")
Button { Button {
showShareSheet(items: [groupLink.simplexChatUri(short: showShortLink)]) showShareSheet(items: [simplexChatLink(groupLink)])
} label: { } label: {
Label("Share link", systemImage: "square.and.arrow.up") Label("Share link", systemImage: "square.and.arrow.up")
} }
@ -95,10 +93,6 @@ struct GroupLinkView: View {
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
} }
} }
} header: {
if let groupLink, groupLink.connShortLink != nil {
ToggleShortLinkHeader(text: Text(""), link: groupLink, short: $showShortLink)
}
} }
.alert(item: $alert) { alert in .alert(item: $alert) { alert in
switch alert { switch alert {
@ -164,8 +158,8 @@ struct GroupLinkView: View {
struct GroupLinkView_Previews: PreviewProvider { struct GroupLinkView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
@State var groupLink: CreatedConnLink? = CreatedConnLink(connFullLink: "https://simplex.chat/contact#/?v=1&smp=smp%3A%2F%2FPQUV2eL0t7OStZOoAsPEV2QYWt4-xilbakvGUGOItUo%3D%40smp6.simplex.im%2FK1rslx-m5bpXVIdMZg9NLUZ_8JBm8xTt%23MCowBQYDK2VuAyEALDeVe-sG8mRY22LsXlPgiwTNs9dbiLrNuA7f3ZMAJ2w%3D", connShortLink: nil) @State var groupLink: String? = "https://simplex.chat/contact#/?v=1&smp=smp%3A%2F%2FPQUV2eL0t7OStZOoAsPEV2QYWt4-xilbakvGUGOItUo%3D%40smp6.simplex.im%2FK1rslx-m5bpXVIdMZg9NLUZ_8JBm8xTt%23MCowBQYDK2VuAyEALDeVe-sG8mRY22LsXlPgiwTNs9dbiLrNuA7f3ZMAJ2w%3D"
@State var noGroupLink: CreatedConnLink? = nil @State var noGroupLink: String? = nil
return Group { return Group {
GroupLinkView(groupId: 1, groupLink: $groupLink, groupLinkMemberRole: Binding.constant(.member)) GroupLinkView(groupId: 1, groupLink: $groupLink, groupLinkMemberRole: Binding.constant(.member))

View file

@ -392,7 +392,7 @@ struct GroupMemberInfoView: View {
await MainActor.run { await MainActor.run {
progressIndicator = false progressIndicator = false
chatModel.addChat(Chat(chatInfo: .direct(contact: memberContact))) chatModel.addChat(Chat(chatInfo: .direct(contact: memberContact)))
ItemsModel.shared.loadOpenChat(memberContact.id) { ItemsModel.shared.loadOpenChat("@\(memberContact.id)") {
dismissAllSheets(animated: true) dismissAllSheets(animated: true)
} }
NetworkModel.shared.setContactNetworkStatus(memberContact, .connected) NetworkModel.shared.setContactNetworkStatus(memberContact, .connected)

View file

@ -196,9 +196,7 @@ struct GroupMentionsView: View {
newName = composeState.mentionMemberName(member.wrapped.memberProfile.displayName) newName = composeState.mentionMemberName(member.wrapped.memberProfile.displayName)
} }
mentions[newName] = CIMention(groupMember: member.wrapped) mentions[newName] = CIMention(groupMember: member.wrapped)
var msgMention = newName.contains(" ") || newName.last?.isPunctuation == true var msgMention = "@" + (newName.contains(" ") ? "'\(newName)'" : newName)
? "@'\(newName)'"
: "@\(newName)"
var newPos = r.location + msgMention.count var newPos = r.location + msgMention.count
let newMsgLength = composeState.message.count + msgMention.count - r.length let newMsgLength = composeState.message.count + msgMention.count - r.length
print(newPos) print(newPos)

View file

@ -18,7 +18,6 @@ struct GroupWelcomeView: View {
@State private var editMode = true @State private var editMode = true
@FocusState private var keyboardVisible: Bool @FocusState private var keyboardVisible: Bool
@State private var showSaveDialog = false @State private var showSaveDialog = false
@State private var showSecrets: Set<Int> = []
let maxByteCount = 1200 let maxByteCount = 1200
@ -59,8 +58,7 @@ struct GroupWelcomeView: View {
} }
private func textPreview() -> some View { private func textPreview() -> some View {
let r = messageText(welcomeText, parseSimpleXMarkdown(welcomeText), sender: nil, mentions: nil, userMemberId: nil, showSecrets: showSecrets, backgroundColor: UIColor(theme.colors.background)) messageText(welcomeText, parseSimpleXMarkdown(welcomeText), nil, mentions: nil, userMemberId: nil, showSecrets: false, secondaryColor: theme.colors.secondary)
return msgTextResultView(r, Text(AttributedString(r.string)), showSecrets: $showSecrets)
.frame(minHeight: 130, alignment: .topLeading) .frame(minHeight: 130, alignment: .topLeading)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
} }

View file

@ -90,11 +90,11 @@ struct ChatListNavLink: View {
.actionSheet(item: $actionSheet) { $0.actionSheet } .actionSheet(item: $actionSheet) { $0.actionSheet }
} }
private func contactNavLink(_ contact: Contact) -> some View { @ViewBuilder private func contactNavLink(_ contact: Contact) -> some View {
Group { Group {
if contact.activeConn == nil && contact.profile.contactLink != nil && contact.active { if contact.activeConn == nil && contact.profile.contactLink != nil && contact.active {
ChatPreviewView(chat: chat, progressByTimeout: Binding.constant(false)) ChatPreviewView(chat: chat, progressByTimeout: Binding.constant(false))
.frameCompat(height: dynamicRowHeight) .frame(height: dynamicRowHeight)
.swipeActions(edge: .trailing, allowsFullSwipe: true) { .swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button { Button {
deleteContactDialog( deleteContactDialog(
@ -121,7 +121,6 @@ struct ChatListNavLink: View {
selection: $chatModel.chatId, selection: $chatModel.chatId,
label: { ChatPreviewView(chat: chat, progressByTimeout: Binding.constant(false)) } label: { ChatPreviewView(chat: chat, progressByTimeout: Binding.constant(false)) }
) )
.frameCompat(height: dynamicRowHeight)
.swipeActions(edge: .leading, allowsFullSwipe: true) { .swipeActions(edge: .leading, allowsFullSwipe: true) {
markReadButton() markReadButton()
toggleFavoriteButton() toggleFavoriteButton()
@ -146,6 +145,7 @@ struct ChatListNavLink: View {
} }
.tint(.red) .tint(.red)
} }
.frame(height: dynamicRowHeight)
} }
} }
.alert(item: $alert) { $0.alert } .alert(item: $alert) { $0.alert }
@ -163,7 +163,7 @@ struct ChatListNavLink: View {
switch (groupInfo.membership.memberStatus) { switch (groupInfo.membership.memberStatus) {
case .memInvited: case .memInvited:
ChatPreviewView(chat: chat, progressByTimeout: $progressByTimeout) ChatPreviewView(chat: chat, progressByTimeout: $progressByTimeout)
.frameCompat(height: dynamicRowHeight) .frame(height: dynamicRowHeight)
.swipeActions(edge: .trailing, allowsFullSwipe: true) { .swipeActions(edge: .trailing, allowsFullSwipe: true) {
joinGroupButton() joinGroupButton()
if groupInfo.canDelete { if groupInfo.canDelete {
@ -183,7 +183,7 @@ struct ChatListNavLink: View {
.disabled(inProgress) .disabled(inProgress)
case .memAccepted: case .memAccepted:
ChatPreviewView(chat: chat, progressByTimeout: Binding.constant(false)) ChatPreviewView(chat: chat, progressByTimeout: Binding.constant(false))
.frameCompat(height: dynamicRowHeight) .frame(height: dynamicRowHeight)
.onTapGesture { .onTapGesture {
AlertManager.shared.showAlert(groupInvitationAcceptedAlert()) AlertManager.shared.showAlert(groupInvitationAcceptedAlert())
} }
@ -203,7 +203,7 @@ struct ChatListNavLink: View {
label: { ChatPreviewView(chat: chat, progressByTimeout: Binding.constant(false)) }, label: { ChatPreviewView(chat: chat, progressByTimeout: Binding.constant(false)) },
disabled: !groupInfo.ready disabled: !groupInfo.ready
) )
.frameCompat(height: dynamicRowHeight) .frame(height: dynamicRowHeight)
.swipeActions(edge: .leading, allowsFullSwipe: true) { .swipeActions(edge: .leading, allowsFullSwipe: true) {
markReadButton() markReadButton()
toggleFavoriteButton() toggleFavoriteButton()
@ -243,14 +243,14 @@ struct ChatListNavLink: View {
} }
} }
private func noteFolderNavLink(_ noteFolder: NoteFolder) -> some View { @ViewBuilder private func noteFolderNavLink(_ noteFolder: NoteFolder) -> some View {
NavLinkPlain( NavLinkPlain(
chatId: chat.chatInfo.id, chatId: chat.chatInfo.id,
selection: $chatModel.chatId, selection: $chatModel.chatId,
label: { ChatPreviewView(chat: chat, progressByTimeout: Binding.constant(false)) }, label: { ChatPreviewView(chat: chat, progressByTimeout: Binding.constant(false)) },
disabled: !noteFolder.ready disabled: !noteFolder.ready
) )
.frameCompat(height: dynamicRowHeight) .frame(height: dynamicRowHeight)
.swipeActions(edge: .leading, allowsFullSwipe: true) { .swipeActions(edge: .leading, allowsFullSwipe: true) {
markReadButton() markReadButton()
} }
@ -433,7 +433,6 @@ struct ChatListNavLink: View {
private func contactRequestNavLink(_ contactRequest: UserContactRequest) -> some View { private func contactRequestNavLink(_ contactRequest: UserContactRequest) -> some View {
ContactRequestView(contactRequest: contactRequest, chat: chat) ContactRequestView(contactRequest: contactRequest, chat: chat)
.frameCompat(height: dynamicRowHeight)
.swipeActions(edge: .trailing, allowsFullSwipe: true) { .swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button { Button {
Task { await acceptContactRequest(incognito: false, contactRequest: contactRequest) } Task { await acceptContactRequest(incognito: false, contactRequest: contactRequest) }
@ -452,6 +451,7 @@ struct ChatListNavLink: View {
} }
.tint(.red) .tint(.red)
} }
.frame(height: dynamicRowHeight)
.contentShape(Rectangle()) .contentShape(Rectangle())
.onTapGesture { showContactRequestDialog = true } .onTapGesture { showContactRequestDialog = true }
.confirmationDialog("Accept connection request?", isPresented: $showContactRequestDialog, titleVisibility: .visible) { .confirmationDialog("Accept connection request?", isPresented: $showContactRequestDialog, titleVisibility: .visible) {
@ -463,7 +463,6 @@ struct ChatListNavLink: View {
private func contactConnectionNavLink(_ contactConnection: PendingContactConnection) -> some View { private func contactConnectionNavLink(_ contactConnection: PendingContactConnection) -> some View {
ContactConnectionView(chat: chat) ContactConnectionView(chat: chat)
.frameCompat(height: dynamicRowHeight)
.swipeActions(edge: .trailing, allowsFullSwipe: true) { .swipeActions(edge: .trailing, allowsFullSwipe: true) {
Button { Button {
AlertManager.shared.showAlert(deleteContactConnectionAlert(contactConnection) { a in AlertManager.shared.showAlert(deleteContactConnectionAlert(contactConnection) { a in
@ -481,6 +480,7 @@ struct ChatListNavLink: View {
} }
.tint(theme.colors.primary) .tint(theme.colors.primary)
} }
.frame(height: dynamicRowHeight)
.appSheet(isPresented: $showContactConnectionInfo) { .appSheet(isPresented: $showContactConnectionInfo) {
Group { Group {
if case let .contactConnection(contactConnection) = chat.chatInfo { if case let .contactConnection(contactConnection) = chat.chatInfo {
@ -579,14 +579,14 @@ struct ChatListNavLink: View {
) )
} }
private func invalidJSONPreview(_ json: Data?) -> some View { private func invalidJSONPreview(_ json: String) -> some View {
Text("invalid chat data") Text("invalid chat data")
.foregroundColor(.red) .foregroundColor(.red)
.padding(4) .padding(4)
.frameCompat(height: dynamicRowHeight) .frame(height: dynamicRowHeight)
.onTapGesture { showInvalidJSON = true } .onTapGesture { showInvalidJSON = true }
.appSheet(isPresented: $showInvalidJSON) { .appSheet(isPresented: $showInvalidJSON) {
invalidJSONView(dataToString(json)) invalidJSONView(json)
.environment(\EnvironmentValues.refresh as! WritableKeyPath<EnvironmentValues, RefreshAction?>, nil) .environment(\EnvironmentValues.refresh as! WritableKeyPath<EnvironmentValues, RefreshAction?>, nil)
} }
} }
@ -595,27 +595,8 @@ struct ChatListNavLink: View {
Task { Task {
let ok = await connectContactViaAddress(contact.contactId, incognito, showAlert: { AlertManager.shared.showAlert($0) }) let ok = await connectContactViaAddress(contact.contactId, incognito, showAlert: { AlertManager.shared.showAlert($0) })
if ok { if ok {
ItemsModel.shared.loadOpenChat(contact.id) { ItemsModel.shared.loadOpenChat(contact.id)
AlertManager.shared.showAlert(connReqSentAlert(.contact)) AlertManager.shared.showAlert(connReqSentAlert(.contact))
}
}
}
}
}
extension View {
@inline(__always)
@ViewBuilder fileprivate func frameCompat(height: CGFloat) -> some View {
if #available(iOS 16, *) {
self.frame(height: height)
} else {
VStack(spacing: 0) {
Divider()
.padding(.leading, 16)
self
.frame(height: height)
.padding(.horizontal, 8)
.padding(.vertical, 8)
} }
} }
} }
@ -707,7 +688,7 @@ func joinGroup(_ groupId: Int64, _ onComplete: @escaping () async -> Void) {
} }
func getErrorAlert(_ error: Error, _ title: LocalizedStringKey) -> ErrorAlert { func getErrorAlert(_ error: Error, _ title: LocalizedStringKey) -> ErrorAlert {
if let r = error as? ChatError, if let r = error as? ChatResponse,
let alert = getNetworkErrorAlert(r) { let alert = getNetworkErrorAlert(r) {
return alert return alert
} else { } else {

View file

@ -148,10 +148,7 @@ struct ChatListView: View {
@State private var userPickerShown: Bool = false @State private var userPickerShown: Bool = false
@State private var sheet: SomeSheet<AnyView>? = nil @State private var sheet: SomeSheet<AnyView>? = nil
@StateObject private var chatTagsModel = ChatTagsModel.shared @StateObject private var chatTagsModel = ChatTagsModel.shared
// iOS 15 is required it to show/hide toolbar while chat is hidden/visible
@State private var viewOnScreen = true
@AppStorage(GROUP_DEFAULT_ONE_HAND_UI, store: groupDefaults) private var oneHandUI = true @AppStorage(GROUP_DEFAULT_ONE_HAND_UI, store: groupDefaults) private var oneHandUI = true
@AppStorage(DEFAULT_ONE_HAND_UI_CARD_SHOWN) private var oneHandUICardShown = false @AppStorage(DEFAULT_ONE_HAND_UI_CARD_SHOWN) private var oneHandUICardShown = false
@AppStorage(DEFAULT_ADDRESS_CREATION_CARD_SHOWN) private var addressCreationCardShown = false @AppStorage(DEFAULT_ADDRESS_CREATION_CARD_SHOWN) private var addressCreationCardShown = false
@ -206,17 +203,7 @@ struct ChatListView: View {
.navigationBarHidden(searchMode || oneHandUI) .navigationBarHidden(searchMode || oneHandUI)
} }
.scaleEffect(x: 1, y: oneHandUI ? -1 : 1, anchor: .center) .scaleEffect(x: 1, y: oneHandUI ? -1 : 1, anchor: .center)
.onAppear { .onDisappear() { activeUserPickerSheet = nil }
if #unavailable(iOS 16.0), !viewOnScreen {
viewOnScreen = true
}
}
.onDisappear {
activeUserPickerSheet = nil
if #unavailable(iOS 16.0) {
viewOnScreen = false
}
}
.refreshable { .refreshable {
AlertManager.shared.showAlert(Alert( AlertManager.shared.showAlert(Alert(
title: Text("Reconnect servers?"), title: Text("Reconnect servers?"),
@ -271,7 +258,7 @@ struct ChatListView: View {
} }
} else { } else {
if oneHandUI { if oneHandUI {
content().toolbar { bottomToolbarGroup() } content().toolbar { bottomToolbarGroup }
} else { } else {
content().toolbar { topToolbar } content().toolbar { topToolbar }
} }
@ -299,9 +286,9 @@ struct ChatListView: View {
} }
} }
@ToolbarContentBuilder func bottomToolbarGroup() -> some ToolbarContent { @ToolbarContentBuilder var bottomToolbarGroup: some ToolbarContent {
let padding: Double = Self.hasHomeIndicator ? 0 : 14 let padding: Double = Self.hasHomeIndicator ? 0 : 14
ToolbarItemGroup(placement: viewOnScreen ? .bottomBar : .principal) { ToolbarItemGroup(placement: .bottomBar) {
leadingToolbarItem.padding(.bottom, padding) leadingToolbarItem.padding(.bottom, padding)
Spacer() Spacer()
SubsStatusIndicator().padding(.bottom, padding) SubsStatusIndicator().padding(.bottom, padding)
@ -335,9 +322,9 @@ struct ChatListView: View {
} }
} }
private var chatList: some View { @ViewBuilder private var chatList: some View {
let cs = filteredChats() let cs = filteredChats()
return ZStack { ZStack {
ScrollViewReader { scrollProxy in ScrollViewReader { scrollProxy in
List { List {
if !chatModel.chats.isEmpty { if !chatModel.chats.isEmpty {
@ -367,7 +354,13 @@ struct ChatListView: View {
.offset(x: -8) .offset(x: -8)
} else { } else {
ForEach(cs, id: \.viewId) { chat in ForEach(cs, id: \.viewId) { chat in
ChatListNavLink(chat: chat, parentSheet: $sheet) VStack(spacing: .zero) {
Divider()
.padding(.leading, 16)
ChatListNavLink(chat: chat, parentSheet: $sheet)
.padding(.horizontal, 8)
.padding(.vertical, 6)
}
.scaleEffect(x: 1, y: oneHandUI ? -1 : 1, anchor: .center) .scaleEffect(x: 1, y: oneHandUI ? -1 : 1, anchor: .center)
.listRowSeparator(.hidden) .listRowSeparator(.hidden)
.listRowInsets(EdgeInsets()) .listRowInsets(EdgeInsets())
@ -798,7 +791,7 @@ struct TagsView: View {
} }
} }
private func expandedPresetTagsFiltersView() -> some View { @ViewBuilder private func expandedPresetTagsFiltersView() -> some View {
ForEach(PresetTag.allCases, id: \.id) { tag in ForEach(PresetTag.allCases, id: \.id) { tag in
if (chatTagsModel.presetTags[tag] ?? 0) > 0 { if (chatTagsModel.presetTags[tag] ?? 0) > 0 {
expandedTagFilterView(tag) expandedTagFilterView(tag)

View file

@ -187,14 +187,13 @@ struct ChatPreviewView: View {
.kerning(-2) .kerning(-2)
} }
private func chatPreviewLayout(_ text: Text?, draft: Bool = false, hasFilePreview: Bool = false, hasSecrets: Bool) -> some View { private func chatPreviewLayout(_ text: Text?, draft: Bool = false, _ hasFilePreview: Bool = false) -> some View {
ZStack(alignment: .topTrailing) { ZStack(alignment: .topTrailing) {
let s = chat.chatStats let s = chat.chatStats
let mentionWidth: CGFloat = if s.unreadMentions > 0 && s.unreadCount > 1 { dynamicSize(userFont).unreadCorner } else { 0 } let mentionWidth: CGFloat = if s.unreadMentions > 0 && s.unreadCount > 1 { dynamicSize(userFont).unreadCorner } else { 0 }
let t = text let t = text
.lineLimit(userFont <= .xxxLarge ? 2 : 1) .lineLimit(userFont <= .xxxLarge ? 2 : 1)
.multilineTextAlignment(.leading) .multilineTextAlignment(.leading)
.if(hasSecrets, transform: hiddenSecretsView)
.frame(maxWidth: .infinity, alignment: .topLeading) .frame(maxWidth: .infinity, alignment: .topLeading)
.padding(.leading, hasFilePreview ? 0 : 8) .padding(.leading, hasFilePreview ? 0 : 8)
.padding(.trailing, mentionWidth + (hasFilePreview ? 38 : 36)) .padding(.trailing, mentionWidth + (hasFilePreview ? 38 : 36))
@ -260,13 +259,11 @@ struct ChatPreviewView: View {
} }
} }
private func messageDraft(_ draft: ComposeState) -> (Text, Bool) { private func messageDraft(_ draft: ComposeState) -> Text {
let msg = draft.message let msg = draft.message
let r = messageText(msg, parseSimpleXMarkdown(msg), sender: nil, preview: true, mentions: draft.mentions, userMemberId: nil, showSecrets: nil, backgroundColor: UIColor(theme.colors.background)) return image("rectangle.and.pencil.and.ellipsis", color: theme.colors.primary)
return (image("rectangle.and.pencil.and.ellipsis", color: theme.colors.primary) + attachment()
+ attachment() + messageText(msg, parseSimpleXMarkdown(msg), nil, preview: true, mentions: draft.mentions, userMemberId: nil, showSecrets: false, secondaryColor: theme.colors.secondary)
+ Text(AttributedString(r.string)),
r.hasSecrets)
func image(_ s: String, color: Color = Color(uiColor: .tertiaryLabel)) -> Text { func image(_ s: String, color: Color = Color(uiColor: .tertiaryLabel)) -> Text {
Text(Image(systemName: s)).foregroundColor(color) + textSpace Text(Image(systemName: s)).foregroundColor(color) + textSpace
@ -282,11 +279,10 @@ struct ChatPreviewView: View {
} }
} }
func chatItemPreview(_ cItem: ChatItem) -> (Text, Bool) { func chatItemPreview(_ cItem: ChatItem) -> Text {
let itemText = cItem.meta.itemDeleted == nil ? cItem.text : markedDeletedText() let itemText = cItem.meta.itemDeleted == nil ? cItem.text : markedDeletedText()
let itemFormattedText = cItem.meta.itemDeleted == nil ? cItem.formattedText : nil let itemFormattedText = cItem.meta.itemDeleted == nil ? cItem.formattedText : nil
let r = messageText(itemText, itemFormattedText, sender: cItem.memberDisplayName, preview: true, mentions: cItem.mentions, userMemberId: chat.chatInfo.groupInfo?.membership.memberId, showSecrets: nil, backgroundColor: UIColor(theme.colors.background), prefix: prefix()) return messageText(itemText, itemFormattedText, cItem.memberDisplayName, icon: nil, preview: true, mentions: cItem.mentions, userMemberId: chat.chatInfo.groupInfo?.membership.memberId, showSecrets: false, secondaryColor: theme.colors.secondary, prefix: prefix())
return (Text(AttributedString(r.string)), r.hasSecrets)
// same texts are in markedDeletedText in MarkedDeletedItemView, but it returns LocalizedStringKey; // same texts are in markedDeletedText in MarkedDeletedItemView, but it returns LocalizedStringKey;
// can be refactored into a single function if functions calling these are changed to return same type // can be refactored into a single function if functions calling these are changed to return same type
@ -313,21 +309,19 @@ struct ChatPreviewView: View {
} }
} }
func prefix() -> NSAttributedString? { func prefix() -> Text {
switch cItem.content.msgContent { switch cItem.content.msgContent {
case let .report(_, reason): reason.attrString case let .report(_, reason): return Text(!itemText.isEmpty ? "\(reason.text): " : reason.text).italic().foregroundColor(Color.red)
default: nil default: return Text("")
} }
} }
} }
@ViewBuilder private func chatMessagePreview(_ cItem: ChatItem?, _ hasFilePreview: Bool = false) -> some View { @ViewBuilder private func chatMessagePreview(_ cItem: ChatItem?, _ hasFilePreview: Bool = false) -> some View {
if chatModel.draftChatId == chat.id, let draft = chatModel.draft { if chatModel.draftChatId == chat.id, let draft = chatModel.draft {
let (t, hasSecrets) = messageDraft(draft) chatPreviewLayout(messageDraft(draft), draft: true, hasFilePreview)
chatPreviewLayout(t, draft: true, hasFilePreview: hasFilePreview, hasSecrets: hasSecrets)
} else if let cItem = cItem { } else if let cItem = cItem {
let (t, hasSecrets) = chatItemPreview(cItem) chatPreviewLayout(itemStatusMark(cItem) + chatItemPreview(cItem), hasFilePreview)
chatPreviewLayout(itemStatusMark(cItem) + t, hasFilePreview: hasFilePreview, hasSecrets: hasSecrets)
} else { } else {
switch (chat.chatInfo) { switch (chat.chatInfo) {
case let .direct(contact): case let .direct(contact):
@ -354,6 +348,7 @@ struct ChatPreviewView: View {
} }
@ViewBuilder func chatItemContentPreview(_ chat: Chat, _ ci: ChatItem) -> some View { @ViewBuilder func chatItemContentPreview(_ chat: Chat, _ ci: ChatItem) -> some View {
let linkClicksEnabled = privacyChatListOpenLinksDefault.get() != PrivacyChatListOpenLinksMode.no
let mc = ci.content.msgContent let mc = ci.content.msgContent
switch mc { switch mc {
case let .link(_, preview): case let .link(_, preview):
@ -375,7 +370,17 @@ struct ChatPreviewView: View {
.cornerRadius(8) .cornerRadius(8)
} }
.onTapGesture { .onTapGesture {
openBrowserAlert(uri: preview.uri) switch privacyChatListOpenLinksDefault.get() {
case .yes: UIApplication.shared.open(preview.uri)
case .no: ItemsModel.shared.loadOpenChat(chat.id)
case .ask: AlertManager.shared.showAlert(
Alert(title: Text("Open web link?"),
message: Text(preview.uri.absoluteString),
primaryButton: .default(Text("Open chat"), action: { ItemsModel.shared.loadOpenChat(chat.id) }),
secondaryButton: .default(Text("Open link"), action: { UIApplication.shared.open(preview.uri) })
)
)
}
} }
} }
case let .image(_, image): case let .image(_, image):
@ -405,7 +410,7 @@ struct ChatPreviewView: View {
: chatPreviewInfoText("you are invited to group") : chatPreviewInfoText("you are invited to group")
} }
private func chatPreviewInfoText(_ text: LocalizedStringKey) -> some View { @ViewBuilder private func chatPreviewInfoText(_ text: LocalizedStringKey) -> some View {
Text(text) Text(text)
.frame(maxWidth: .infinity, minHeight: 44, maxHeight: 44, alignment: .topLeading) .frame(maxWidth: .infinity, minHeight: 44, maxHeight: 44, alignment: .topLeading)
.padding([.leading, .trailing], 8) .padding([.leading, .trailing], 8)
@ -485,7 +490,7 @@ struct ChatPreviewView: View {
} }
} }
func groupReportsIcon(size: CGFloat) -> some View { @ViewBuilder func groupReportsIcon(size: CGFloat) -> some View {
Image(systemName: "flag") Image(systemName: "flag")
.resizable() .resizable()
.scaledToFit() .scaledToFit()

View file

@ -14,7 +14,6 @@ struct ContactConnectionInfo: View {
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
@Environment(\.dismiss) var dismiss: DismissAction @Environment(\.dismiss) var dismiss: DismissAction
@State var contactConnection: PendingContactConnection @State var contactConnection: PendingContactConnection
@State private var showShortLink: Bool = true
@State private var alert: CCInfoAlert? @State private var alert: CCInfoAlert?
@State private var localAlias = "" @State private var localAlias = ""
@State private var showIncognitoSheet = false @State private var showIncognitoSheet = false
@ -62,19 +61,14 @@ struct ContactConnectionInfo: View {
} }
if contactConnection.initiated, if contactConnection.initiated,
let connLinkInv = contactConnection.connLinkInv { let connReqInv = contactConnection.connReqInv {
SimpleXCreatedLinkQRCode(link: connLinkInv, short: $showShortLink) SimpleXLinkQRCode(uri: simplexChatLink(connReqInv))
.id("simplex-invitation-qrcode-\(connLinkInv.simplexChatUri(short: showShortLink))")
incognitoEnabled() incognitoEnabled()
shareLinkButton(connLinkInv, short: showShortLink) shareLinkButton(connReqInv, theme.colors.secondary)
oneTimeLinkLearnMoreButton() oneTimeLinkLearnMoreButton(theme.colors.secondary)
} else { } else {
incognitoEnabled() incognitoEnabled()
oneTimeLinkLearnMoreButton() oneTimeLinkLearnMoreButton(theme.colors.secondary)
}
} header: {
if let connLinkInv = contactConnection.connLinkInv, connLinkInv.connShortLink != nil {
ToggleShortLinkHeader(text: Text(""), link: connLinkInv, short: $showShortLink)
} }
} footer: { } footer: {
sharedProfileInfo(contactConnection.incognito) sharedProfileInfo(contactConnection.incognito)
@ -173,22 +167,26 @@ struct ContactConnectionInfo: View {
} }
} }
private func shareLinkButton(_ connLinkInvitation: CreatedConnLink, short: Bool) -> some View { private func shareLinkButton(_ connReqInvitation: String, _ secondaryColor: Color) -> some View {
Button { Button {
showShareSheet(items: [connLinkInvitation.simplexChatUri(short: short)]) showShareSheet(items: [simplexChatLink(connReqInvitation)])
} label: { } label: {
Label("Share 1-time link", systemImage: "square.and.arrow.up") settingsRow("square.and.arrow.up", color: secondaryColor) {
Text("Share 1-time link")
}
} }
} }
private func oneTimeLinkLearnMoreButton() -> some View { private func oneTimeLinkLearnMoreButton(_ secondaryColor: Color) -> some View {
NavigationLink { NavigationLink {
AddContactLearnMore(showTitle: false) AddContactLearnMore(showTitle: false)
.navigationTitle("One-time invitation link") .navigationTitle("One-time invitation link")
.modifier(ThemedBackground()) .modifier(ThemedBackground())
.navigationBarTitleDisplayMode(.large) .navigationBarTitleDisplayMode(.large)
} label: { } label: {
Label("Learn more", systemImage: "info.circle") settingsRow("info.circle", color: secondaryColor) {
Text("Learn more")
}
} }
} }

View file

@ -245,7 +245,7 @@ struct ServersSummaryView: View {
} }
} }
private func smpServersListView( @ViewBuilder private func smpServersListView(
_ servers: [SMPServerSummary], _ servers: [SMPServerSummary],
_ statsStartedAt: Date, _ statsStartedAt: Date,
_ header: LocalizedStringKey? = nil, _ header: LocalizedStringKey? = nil,
@ -256,7 +256,7 @@ struct ServersSummaryView: View {
? serverAddress($0.smpServer) < serverAddress($1.smpServer) ? serverAddress($0.smpServer) < serverAddress($1.smpServer)
: $0.hasSubs && !$1.hasSubs : $0.hasSubs && !$1.hasSubs
} }
return Section { Section {
ForEach(sortedServers) { server in ForEach(sortedServers) { server in
smpServerView(server, statsStartedAt) smpServerView(server, statsStartedAt)
} }
@ -318,14 +318,14 @@ struct ServersSummaryView: View {
return onionHosts == .require ? .indigo : .accentColor return onionHosts == .require ? .indigo : .accentColor
} }
private func xftpServersListView( @ViewBuilder private func xftpServersListView(
_ servers: [XFTPServerSummary], _ servers: [XFTPServerSummary],
_ statsStartedAt: Date, _ statsStartedAt: Date,
_ header: LocalizedStringKey? = nil, _ header: LocalizedStringKey? = nil,
_ footer: LocalizedStringKey? = nil _ footer: LocalizedStringKey? = nil
) -> some View { ) -> some View {
let sortedServers = servers.sorted { serverAddress($0.xftpServer) < serverAddress($1.xftpServer) } let sortedServers = servers.sorted { serverAddress($0.xftpServer) < serverAddress($1.xftpServer) }
return Section { Section {
ForEach(sortedServers) { server in ForEach(sortedServers) { server in
xftpServerView(server, statsStartedAt) xftpServerView(server, statsStartedAt)
} }
@ -587,7 +587,7 @@ struct SMPStatsView: View {
} header: { } header: {
Text("Statistics") Text("Statistics")
} footer: { } footer: {
Text("Starting from \(localTimestamp(statsStartedAt)).") + textNewLine + Text("All data is kept private on your device.") Text("Starting from \(localTimestamp(statsStartedAt)).") + Text("\n") + Text("All data is kept private on your device.")
} }
} }
} }
@ -703,7 +703,7 @@ struct XFTPStatsView: View {
} header: { } header: {
Text("Statistics") Text("Statistics")
} footer: { } footer: {
Text("Starting from \(localTimestamp(statsStartedAt)).") + textNewLine + Text("All data is kept private on your device.") Text("Starting from \(localTimestamp(statsStartedAt)).") + Text("\n") + Text("All data is kept private on your device.")
} }
} }
} }

View file

@ -61,7 +61,7 @@ struct TagListView: View {
Button { Button {
showAlert( showAlert(
NSLocalizedString("Delete list?", comment: "alert title"), NSLocalizedString("Delete list?", comment: "alert title"),
message: String.localizedStringWithFormat(NSLocalizedString("All chats will be removed from the list %@, and the list deleted.", comment: "alert message"), text), message: NSLocalizedString("All chats will be removed from the list \(text), and the list deleted.", comment: "alert message"),
actions: {[ actions: {[
UIAlertAction( UIAlertAction(
title: NSLocalizedString("Cancel", comment: "alert action"), title: NSLocalizedString("Cancel", comment: "alert action"),
@ -138,7 +138,7 @@ struct TagListView: View {
} }
} }
private func radioButton(selected: Bool) -> some View { @ViewBuilder private func radioButton(selected: Bool) -> some View {
Image(systemName: selected ? "checkmark.circle.fill" : "circle") Image(systemName: selected ? "checkmark.circle.fill" : "circle")
.imageScale(.large) .imageScale(.large)
.foregroundStyle(selected ? Color.accentColor : Color(.tertiaryLabel)) .foregroundStyle(selected ? Color.accentColor : Color(.tertiaryLabel))

View file

@ -140,9 +140,9 @@ struct ContactListNavLink: View {
} }
} }
private func previewTitle(_ contact: Contact, titleColor: Color) -> some View { @ViewBuilder private func previewTitle(_ contact: Contact, titleColor: Color) -> some View {
let t = Text(chat.chatInfo.chatViewName).foregroundColor(titleColor) let t = Text(chat.chatInfo.chatViewName).foregroundColor(titleColor)
return ( (
contact.verified == true contact.verified == true
? verifiedIcon + t ? verifiedIcon + t
: t : t
@ -188,7 +188,8 @@ struct ContactListNavLink: View {
Task { Task {
let ok = await connectContactViaAddress(contact.contactId, incognito, showAlert: { alert = SomeAlert(alert: $0, id: "ContactListNavLink connectContactViaAddress") }) let ok = await connectContactViaAddress(contact.contactId, incognito, showAlert: { alert = SomeAlert(alert: $0, id: "ContactListNavLink connectContactViaAddress") })
if ok { if ok {
ItemsModel.shared.loadOpenChat(contact.id) { ItemsModel.shared.loadOpenChat(contact.id)
DispatchQueue.main.async {
dismissAllSheets(animated: true) { dismissAllSheets(animated: true) {
AlertManager.shared.showAlert(connReqSentAlert(.contact)) AlertManager.shared.showAlert(connReqSentAlert(.contact))
} }

View file

@ -173,7 +173,7 @@ struct DatabaseEncryptionView: View {
} }
return true return true
} catch let error { } catch let error {
if case .errorDatabase(.errorExport(.errorNotADatabase)) = error as? ChatError { if case .chatCmdError(_, .errorDatabase(.errorExport(.errorNotADatabase))) = error as? ChatResponse {
await operationEnded(.currentPassphraseError) await operationEnded(.currentPassphraseError)
} else { } else {
await operationEnded(.error(title: "Error encrypting database", error: "\(responseError(error))")) await operationEnded(.error(title: "Error encrypting database", error: "\(responseError(error))"))

View file

@ -28,7 +28,7 @@ struct DatabaseErrorView: View {
} }
} }
private func databaseErrorView() -> some View { @ViewBuilder private func databaseErrorView() -> some View {
VStack(alignment: .center, spacing: 20) { VStack(alignment: .center, spacing: 20) {
switch status { switch status {
case let .errorNotADatabase(dbFile): case let .errorNotADatabase(dbFile):
@ -141,7 +141,7 @@ struct DatabaseErrorView: View {
} }
private func migrationsText(_ ms: [String]) -> some View { private func migrationsText(_ ms: [String]) -> some View {
(Text("Migrations:").font(.subheadline) + textNewLine + Text(ms.joined(separator: "\n")).font(.caption)) (Text("Migrations:").font(.subheadline) + Text(verbatim: "\n") + Text(ms.joined(separator: "\n")).font(.caption))
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
.padding(.horizontal, 25) .padding(.horizontal, 25)
} }

View file

@ -279,7 +279,7 @@ struct DatabaseView: View {
case let .archiveExportedWithErrors(archivePath, errs): case let .archiveExportedWithErrors(archivePath, errs):
return Alert( return Alert(
title: Text("Chat database exported"), title: Text("Chat database exported"),
message: Text("You may save the exported archive.") + textNewLine + Text("Some file(s) were not exported:") + Text(archiveErrorsText(errs)), message: Text("You may save the exported archive.") + Text(verbatim: "\n") + Text("Some file(s) were not exported:") + Text(archiveErrorsText(errs)),
dismissButton: .default(Text("Continue")) { dismissButton: .default(Text("Continue")) {
showShareSheet(items: [archivePath]) showShareSheet(items: [archivePath])
} }

View file

@ -9,7 +9,6 @@
import SwiftUI import SwiftUI
extension View { extension View {
@inline(__always)
@ViewBuilder func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View { @ViewBuilder func `if`<Content: View>(_ condition: Bool, transform: (Self) -> Content) -> some View {
if condition { if condition {
transform(self) transform(self)
@ -37,9 +36,9 @@ struct PrivacyBlur: ViewModifier {
.overlay { .overlay {
if (blurred && enabled) { if (blurred && enabled) {
Color.clear.contentShape(Rectangle()) Color.clear.contentShape(Rectangle())
.simultaneousGesture(TapGesture().onEnded { .onTapGesture {
blurred = false blurred = false
}) }
} }
} }
.onReceive(NotificationCenter.default.publisher(for: .chatViewWillBeginScrolling)) { _ in .onReceive(NotificationCenter.default.publisher(for: .chatViewWillBeginScrolling)) { _ in

View file

@ -65,7 +65,7 @@ struct LocalAuthView: View {
// Clear sensitive data on screen just in case app fails to hide its views while new database is created // Clear sensitive data on screen just in case app fails to hide its views while new database is created
m.chatId = nil m.chatId = nil
ItemsModel.shared.reversedChatItems = [] ItemsModel.shared.reversedChatItems = []
ItemsModel.shared.chatState.clear() ItemsModel.shared.chatItemsChangesListener.cleared()
m.updateChats([]) m.updateChats([])
m.users = [] m.users = []
_ = kcAppPassword.set(password) _ = kcAppPassword.set(password)

View file

@ -28,7 +28,7 @@ struct PasscodeEntry: View {
} }
} }
private func passwordView() -> some View { @ViewBuilder private func passwordView() -> some View {
Text( Text(
password == "" password == ""
? " " ? " "

View file

@ -177,7 +177,7 @@ struct MigrateFromDevice: View {
case let .archiveExportedWithErrors(archivePath, errs): case let .archiveExportedWithErrors(archivePath, errs):
return Alert( return Alert(
title: Text("Chat database exported"), title: Text("Chat database exported"),
message: Text("You may migrate the exported database.") + textNewLine + Text("Some file(s) were not exported:") + Text(archiveErrorsText(errs)), message: Text("You may migrate the exported database.") + Text(verbatim: "\n") + Text("Some file(s) were not exported:") + Text(archiveErrorsText(errs)),
dismissButton: .default(Text("Continue")) { dismissButton: .default(Text("Continue")) {
Task { await uploadArchive(path: archivePath) } Task { await uploadArchive(path: archivePath) }
} }
@ -520,15 +520,15 @@ struct MigrateFromDevice: View {
chatReceiver = MigrationChatReceiver(ctrl: ctrl, databaseUrl: tempDatabaseUrl) { msg in chatReceiver = MigrationChatReceiver(ctrl: ctrl, databaseUrl: tempDatabaseUrl) { msg in
await MainActor.run { await MainActor.run {
switch msg { switch msg {
case let .result(.sndFileProgressXFTP(_, _, fileTransferMeta, sentSize, totalSize)): case let .sndFileProgressXFTP(_, _, fileTransferMeta, sentSize, totalSize):
if case let .uploadProgress(uploaded, total, _, _, _) = migrationState, uploaded != total { if case let .uploadProgress(uploaded, total, _, _, _) = migrationState, uploaded != total {
migrationState = .uploadProgress(uploadedBytes: sentSize, totalBytes: totalSize, fileId: fileTransferMeta.fileId, archivePath: archivePath, ctrl: ctrl) migrationState = .uploadProgress(uploadedBytes: sentSize, totalBytes: totalSize, fileId: fileTransferMeta.fileId, archivePath: archivePath, ctrl: ctrl)
} }
case .result(.sndFileRedirectStartXFTP): case .sndFileRedirectStartXFTP:
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
migrationState = .linkCreation migrationState = .linkCreation
} }
case let .result(.sndStandaloneFileComplete(_, fileTransferMeta, rcvURIs)): case let .sndStandaloneFileComplete(_, fileTransferMeta, rcvURIs):
let cfg = getNetCfg() let cfg = getNetCfg()
let proxy: NetworkProxy? = if cfg.socksProxy == nil { let proxy: NetworkProxy? = if cfg.socksProxy == nil {
nil nil
@ -546,7 +546,7 @@ struct MigrateFromDevice: View {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
migrationState = .linkShown(fileId: fileTransferMeta.fileId, link: data.addToLink(link: rcvURIs[0]), archivePath: archivePath, ctrl: ctrl) migrationState = .linkShown(fileId: fileTransferMeta.fileId, link: data.addToLink(link: rcvURIs[0]), archivePath: archivePath, ctrl: ctrl)
} }
case .result(.sndFileError): case .sndFileError:
alert = .error(title: "Upload failed", error: "Check your internet connection and try again") alert = .error(title: "Upload failed", error: "Check your internet connection and try again")
migrationState = .uploadFailed(totalBytes: totalBytes, archivePath: archivePath) migrationState = .uploadFailed(totalBytes: totalBytes, archivePath: archivePath)
default: default:
@ -691,7 +691,7 @@ private struct PassphraseConfirmationView: View {
migrationState = .uploadConfirmation migrationState = .uploadConfirmation
} }
} catch let error { } catch let error {
if case .errorDatabase(.errorOpen(.errorNotADatabase)) = error as? ChatError { if case .chatCmdError(_, .errorDatabase(.errorOpen(.errorNotADatabase))) = error as? ChatResponse {
showErrorOnMigrationIfNeeded(.errorNotADatabase(dbFile: ""), $alert) showErrorOnMigrationIfNeeded(.errorNotADatabase(dbFile: ""), $alert)
} else { } else {
alert = .error(title: "Error", error: NSLocalizedString("Error verifying passphrase:", comment: "") + " " + String(responseError(error))) alert = .error(title: "Error", error: NSLocalizedString("Error verifying passphrase:", comment: "") + " " + String(responseError(error)))
@ -733,11 +733,11 @@ func chatStoppedView() -> some View {
private class MigrationChatReceiver { private class MigrationChatReceiver {
let ctrl: chat_ctrl let ctrl: chat_ctrl
let databaseUrl: URL let databaseUrl: URL
let processReceivedMsg: (APIResult<ChatEvent>) async -> Void let processReceivedMsg: (ChatResponse) async -> Void
private var receiveLoop: Task<Void, Never>? private var receiveLoop: Task<Void, Never>?
private var receiveMessages = true private var receiveMessages = true
init(ctrl: chat_ctrl, databaseUrl: URL, _ processReceivedMsg: @escaping (APIResult<ChatEvent>) async -> Void) { init(ctrl: chat_ctrl, databaseUrl: URL, _ processReceivedMsg: @escaping (ChatResponse) async -> Void) {
self.ctrl = ctrl self.ctrl = ctrl
self.databaseUrl = databaseUrl self.databaseUrl = databaseUrl
self.processReceivedMsg = processReceivedMsg self.processReceivedMsg = processReceivedMsg
@ -752,9 +752,9 @@ private class MigrationChatReceiver {
func receiveMsgLoop() async { func receiveMsgLoop() async {
// TODO use function that has timeout // TODO use function that has timeout
if let msg: APIResult<ChatEvent> = await chatRecvMsg(ctrl) { if let msg = await chatRecvMsg(ctrl) {
Task { Task {
await TerminalItems.shared.addResult(msg) await TerminalItems.shared.add(.resp(.now, msg))
} }
logger.debug("processReceivedMsg: \(msg.responseType)") logger.debug("processReceivedMsg: \(msg.responseType)")
await processReceivedMsg(msg) await processReceivedMsg(msg)

View file

@ -496,10 +496,10 @@ struct MigrateToDevice: View {
chatReceiver = MigrationChatReceiver(ctrl: ctrl, databaseUrl: tempDatabaseUrl) { msg in chatReceiver = MigrationChatReceiver(ctrl: ctrl, databaseUrl: tempDatabaseUrl) { msg in
await MainActor.run { await MainActor.run {
switch msg { switch msg {
case let .result(.rcvFileProgressXFTP(_, _, receivedSize, totalSize, rcvFileTransfer)): case let .rcvFileProgressXFTP(_, _, receivedSize, totalSize, rcvFileTransfer):
migrationState = .downloadProgress(downloadedBytes: receivedSize, totalBytes: totalSize, fileId: rcvFileTransfer.fileId, link: link, archivePath: archivePath, ctrl: ctrl) migrationState = .downloadProgress(downloadedBytes: receivedSize, totalBytes: totalSize, fileId: rcvFileTransfer.fileId, link: link, archivePath: archivePath, ctrl: ctrl)
MigrationToDeviceState.save(.downloadProgress(link: link, archiveName: URL(fileURLWithPath: archivePath).lastPathComponent)) MigrationToDeviceState.save(.downloadProgress(link: link, archiveName: URL(fileURLWithPath: archivePath).lastPathComponent))
case .result(.rcvStandaloneFileComplete): case .rcvStandaloneFileComplete:
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
// User closed the whole screen before new state was saved // User closed the whole screen before new state was saved
if migrationState == nil { if migrationState == nil {
@ -509,10 +509,10 @@ struct MigrateToDevice: View {
MigrationToDeviceState.save(.archiveImport(archiveName: URL(fileURLWithPath: archivePath).lastPathComponent)) MigrationToDeviceState.save(.archiveImport(archiveName: URL(fileURLWithPath: archivePath).lastPathComponent))
} }
} }
case .result(.rcvFileError): case .rcvFileError:
alert = .error(title: "Download failed", error: "File was deleted or link is invalid") alert = .error(title: "Download failed", error: "File was deleted or link is invalid")
migrationState = .downloadFailed(totalBytes: totalBytes, link: link, archivePath: archivePath) migrationState = .downloadFailed(totalBytes: totalBytes, link: link, archivePath: archivePath)
case .error(.error(.noRcvFileUser)): case .chatError(_, .error(.noRcvFileUser)):
alert = .error(title: "Download failed", error: "File was deleted or link is invalid") alert = .error(title: "Download failed", error: "File was deleted or link is invalid")
migrationState = .downloadFailed(totalBytes: totalBytes, link: link, archivePath: archivePath) migrationState = .downloadFailed(totalBytes: totalBytes, link: link, archivePath: archivePath)
default: default:
@ -539,7 +539,7 @@ struct MigrateToDevice: View {
chatInitControllerRemovingDatabases() chatInitControllerRemovingDatabases()
} else if ChatModel.shared.chatRunning == true { } else if ChatModel.shared.chatRunning == true {
// cannot delete storage if chat is running // cannot delete storage if chat is running
try await stopChatAsync() try await apiStopChat()
} }
try await apiDeleteStorage() try await apiDeleteStorage()
try? FileManager.default.createDirectory(at: getWallpaperDirectory(), withIntermediateDirectories: true) try? FileManager.default.createDirectory(at: getWallpaperDirectory(), withIntermediateDirectories: true)
@ -623,7 +623,7 @@ struct MigrateToDevice: View {
AlertManager.shared.showAlert( AlertManager.shared.showAlert(
Alert( Alert(
title: Text("Error migrating settings"), title: Text("Error migrating settings"),
message: Text ("Some app settings were not migrated.") + textNewLine + Text(responseError(error))) message: Text ("Some app settings were not migrated.") + Text("\n") + Text(responseError(error)))
) )
} }
hideView() hideView()
@ -632,8 +632,6 @@ struct MigrateToDevice: View {
private func hideView() { private func hideView() {
onboardingStageDefault.set(.onboardingComplete) onboardingStageDefault.set(.onboardingComplete)
m.onboardingStage = .onboardingComplete m.onboardingStage = .onboardingComplete
m.migrationState = nil
MigrationToDeviceState.save(nil)
dismiss() dismiss()
} }
@ -751,11 +749,11 @@ private func progressView() -> some View {
private class MigrationChatReceiver { private class MigrationChatReceiver {
let ctrl: chat_ctrl let ctrl: chat_ctrl
let databaseUrl: URL let databaseUrl: URL
let processReceivedMsg: (APIResult<ChatEvent>) async -> Void let processReceivedMsg: (ChatResponse) async -> Void
private var receiveLoop: Task<Void, Never>? private var receiveLoop: Task<Void, Never>?
private var receiveMessages = true private var receiveMessages = true
init(ctrl: chat_ctrl, databaseUrl: URL, _ processReceivedMsg: @escaping (APIResult<ChatEvent>) async -> Void) { init(ctrl: chat_ctrl, databaseUrl: URL, _ processReceivedMsg: @escaping (ChatResponse) async -> Void) {
self.ctrl = ctrl self.ctrl = ctrl
self.databaseUrl = databaseUrl self.databaseUrl = databaseUrl
self.processReceivedMsg = processReceivedMsg self.processReceivedMsg = processReceivedMsg
@ -772,7 +770,7 @@ private class MigrationChatReceiver {
// TODO use function that has timeout // TODO use function that has timeout
if let msg = await chatRecvMsg(ctrl) { if let msg = await chatRecvMsg(ctrl) {
Task { Task {
await TerminalItems.shared.addResult(msg) await TerminalItems.shared.add(.resp(.now, msg))
} }
logger.debug("processReceivedMsg: \(msg.responseType)") logger.debug("processReceivedMsg: \(msg.responseType)")
await processReceivedMsg(msg) await processReceivedMsg(msg)

View file

@ -23,7 +23,7 @@ struct AddGroupView: View {
@State private var showTakePhoto = false @State private var showTakePhoto = false
@State private var chosenImage: UIImage? = nil @State private var chosenImage: UIImage? = nil
@State private var showInvalidNameAlert = false @State private var showInvalidNameAlert = false
@State private var groupLink: CreatedConnLink? @State private var groupLink: String?
@State private var groupLinkMemberRole: GroupMemberRole = .member @State private var groupLinkMemberRole: GroupMemberRole = .member
var body: some View { var body: some View {

View file

@ -85,7 +85,7 @@ struct NewChatSheet: View {
} }
} }
private func viewBody(_ showArchive: Bool) -> some View { @ViewBuilder private func viewBody(_ showArchive: Bool) -> some View {
List { List {
HStack { HStack {
ContactsListSearchBar( ContactsListSearchBar(
@ -258,7 +258,7 @@ struct ContactsList: View {
} }
} }
private func noResultSection(text: String) -> some View { @ViewBuilder private func noResultSection(text: String) -> some View {
Section { Section {
Text(text) Text(text)
.foregroundColor(theme.colors.secondary) .foregroundColor(theme.colors.secondary)

View file

@ -81,8 +81,7 @@ struct NewChatView: View {
@State var selection: NewChatOption @State var selection: NewChatOption
@State var showQRCodeScanner = false @State var showQRCodeScanner = false
@State private var invitationUsed: Bool = false @State private var invitationUsed: Bool = false
@State private var connLinkInvitation: CreatedConnLink = CreatedConnLink(connFullLink: "", connShortLink: nil) @State private var connReqInvitation: String = ""
@State private var showShortLink = true
@State private var creatingConnReq = false @State private var creatingConnReq = false
@State var choosingProfile = false @State var choosingProfile = false
@State private var pastedLink: String = "" @State private var pastedLink: String = ""
@ -175,12 +174,11 @@ struct NewChatView: View {
private func prepareAndInviteView() -> some View { private func prepareAndInviteView() -> some View {
ZStack { // ZStack is needed for views to not make transitions between each other ZStack { // ZStack is needed for views to not make transitions between each other
if connLinkInvitation.connFullLink != "" { if connReqInvitation != "" {
InviteView( InviteView(
invitationUsed: $invitationUsed, invitationUsed: $invitationUsed,
contactConnection: $contactConnection, contactConnection: $contactConnection,
connLinkInvitation: $connLinkInvitation, connReqInvitation: $connReqInvitation,
showShortLink: $showShortLink,
choosingProfile: $choosingProfile choosingProfile: $choosingProfile
) )
} else if creatingConnReq { } else if creatingConnReq {
@ -192,16 +190,16 @@ struct NewChatView: View {
} }
private func createInvitation() { private func createInvitation() {
if connLinkInvitation.connFullLink == "" && contactConnection == nil && !creatingConnReq { if connReqInvitation == "" && contactConnection == nil && !creatingConnReq {
creatingConnReq = true creatingConnReq = true
Task { Task {
_ = try? await Task.sleep(nanoseconds: 250_000000) _ = try? await Task.sleep(nanoseconds: 250_000000)
let (r, apiAlert) = await apiAddContact(incognito: incognitoGroupDefault.get()) let (r, apiAlert) = await apiAddContact(incognito: incognitoGroupDefault.get())
if let (connLink, pcc) = r { if let (connReq, pcc) = r {
await MainActor.run { await MainActor.run {
m.updateContactConnection(pcc) m.updateContactConnection(pcc)
m.showingInvitation = ShowingInvitation(pcc: pcc, connChatUsed: false) m.showingInvitation = ShowingInvitation(pcc: pcc, connChatUsed: false)
connLinkInvitation = connLink connReqInvitation = connReq
contactConnection = pcc contactConnection = pcc
} }
} else { } else {
@ -245,8 +243,7 @@ private struct InviteView: View {
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
@Binding var invitationUsed: Bool @Binding var invitationUsed: Bool
@Binding var contactConnection: PendingContactConnection? @Binding var contactConnection: PendingContactConnection?
@Binding var connLinkInvitation: CreatedConnLink @Binding var connReqInvitation: String
@Binding var showShortLink: Bool
@Binding var choosingProfile: Bool @Binding var choosingProfile: Bool
@AppStorage(GROUP_DEFAULT_INCOGNITO, store: groupDefaults) private var incognitoDefault = false @AppStorage(GROUP_DEFAULT_INCOGNITO, store: groupDefaults) private var incognitoDefault = false
@ -264,7 +261,7 @@ private struct InviteView: View {
NavigationLink { NavigationLink {
ActiveProfilePicker( ActiveProfilePicker(
contactConnection: $contactConnection, contactConnection: $contactConnection,
connLinkInvitation: $connLinkInvitation, connReqInvitation: $connReqInvitation,
incognitoEnabled: $incognitoDefault, incognitoEnabled: $incognitoDefault,
choosingProfile: $choosingProfile, choosingProfile: $choosingProfile,
selectedProfile: selectedProfile selectedProfile: selectedProfile
@ -299,7 +296,7 @@ private struct InviteView: View {
private func shareLinkView() -> some View { private func shareLinkView() -> some View {
HStack { HStack {
let link = connLinkInvitation.simplexChatUri(short: showShortLink) let link = simplexChatLink(connReqInvitation)
linkTextView(link) linkTextView(link)
Button { Button {
showShareSheet(items: [link]) showShareSheet(items: [link])
@ -313,9 +310,9 @@ private struct InviteView: View {
} }
private func qrCodeView() -> some View { private func qrCodeView() -> some View {
Section { Section(header: Text("Or show this code").foregroundColor(theme.colors.secondary)) {
SimpleXCreatedLinkQRCode(link: connLinkInvitation, short: $showShortLink, onShare: setInvitationUsed) SimpleXLinkQRCode(uri: connReqInvitation, onShare: setInvitationUsed)
.id("simplex-qrcode-view-for-\(connLinkInvitation.simplexChatUri(short: showShortLink))") .id("simplex-qrcode-view-for-\(connReqInvitation)")
.padding() .padding()
.background( .background(
RoundedRectangle(cornerRadius: 12, style: .continuous) RoundedRectangle(cornerRadius: 12, style: .continuous)
@ -325,8 +322,6 @@ private struct InviteView: View {
.listRowBackground(Color.clear) .listRowBackground(Color.clear)
.listRowSeparator(.hidden) .listRowSeparator(.hidden)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)) .listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
} header: {
ToggleShortLinkHeader(text: Text("Or show this code"), link: connLinkInvitation, short: $showShortLink)
} }
} }
@ -348,7 +343,7 @@ private struct ActiveProfilePicker: View {
@EnvironmentObject var chatModel: ChatModel @EnvironmentObject var chatModel: ChatModel
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
@Binding var contactConnection: PendingContactConnection? @Binding var contactConnection: PendingContactConnection?
@Binding var connLinkInvitation: CreatedConnLink @Binding var connReqInvitation: String
@Binding var incognitoEnabled: Bool @Binding var incognitoEnabled: Bool
@Binding var choosingProfile: Bool @Binding var choosingProfile: Bool
@State private var alert: SomeAlert? @State private var alert: SomeAlert?
@ -420,11 +415,12 @@ private struct ActiveProfilePicker: View {
} }
Task { Task {
do { do {
if let contactConn = contactConnection { if let contactConn = contactConnection,
let conn = try await apiChangeConnectionUser(connId: contactConn.pccConnId, userId: profile.userId) let conn = try await apiChangeConnectionUser(connId: contactConn.pccConnId, userId: profile.userId) {
await MainActor.run { await MainActor.run {
contactConnection = conn contactConnection = conn
connLinkInvitation = conn.connLinkInv ?? CreatedConnLink(connFullLink: "", connShortLink: nil) connReqInvitation = conn.connReqInv ?? ""
incognitoEnabled = false incognitoEnabled = false
chatModel.updateContactConnection(conn) chatModel.updateContactConnection(conn)
} }
@ -506,7 +502,7 @@ private struct ActiveProfilePicker: View {
} }
} }
private func profilerPickerUserOption(_ user: User) -> some View { @ViewBuilder private func profilerPickerUserOption(_ user: User) -> some View {
Button { Button {
if selectedProfile == user && incognitoEnabled { if selectedProfile == user && incognitoEnabled {
incognitoEnabled = false incognitoEnabled = false
@ -840,25 +836,23 @@ func sharedProfileInfo(_ incognito: Bool) -> Text {
} }
enum PlanAndConnectAlert: Identifiable { enum PlanAndConnectAlert: Identifiable {
case ownInvitationLinkConfirmConnect(connectionLink: CreatedConnLink, connectionPlan: ConnectionPlan, incognito: Bool) case ownInvitationLinkConfirmConnect(connectionLink: String, connectionPlan: ConnectionPlan, incognito: Bool)
case invitationLinkConnecting(connectionLink: CreatedConnLink) case invitationLinkConnecting(connectionLink: String)
case ownContactAddressConfirmConnect(connectionLink: CreatedConnLink, connectionPlan: ConnectionPlan, incognito: Bool) case ownContactAddressConfirmConnect(connectionLink: String, connectionPlan: ConnectionPlan, incognito: Bool)
case contactAddressConnectingConfirmReconnect(connectionLink: CreatedConnLink, connectionPlan: ConnectionPlan, incognito: Bool) case contactAddressConnectingConfirmReconnect(connectionLink: String, connectionPlan: ConnectionPlan, incognito: Bool)
case groupLinkConfirmConnect(connectionLink: CreatedConnLink, connectionPlan: ConnectionPlan, incognito: Bool) case groupLinkConfirmConnect(connectionLink: String, connectionPlan: ConnectionPlan, incognito: Bool)
case groupLinkConnectingConfirmReconnect(connectionLink: CreatedConnLink, connectionPlan: ConnectionPlan, incognito: Bool) case groupLinkConnectingConfirmReconnect(connectionLink: String, connectionPlan: ConnectionPlan, incognito: Bool)
case groupLinkConnecting(connectionLink: CreatedConnLink, groupInfo: GroupInfo?) case groupLinkConnecting(connectionLink: String, groupInfo: GroupInfo?)
case error(shortOrFullLink: String, alert: Alert)
var id: String { var id: String {
switch self { switch self {
case let .ownInvitationLinkConfirmConnect(connectionLink, _, _): return "ownInvitationLinkConfirmConnect \(connectionLink.connFullLink)" case let .ownInvitationLinkConfirmConnect(connectionLink, _, _): return "ownInvitationLinkConfirmConnect \(connectionLink)"
case let .invitationLinkConnecting(connectionLink): return "invitationLinkConnecting \(connectionLink.connFullLink)" case let .invitationLinkConnecting(connectionLink): return "invitationLinkConnecting \(connectionLink)"
case let .ownContactAddressConfirmConnect(connectionLink, _, _): return "ownContactAddressConfirmConnect \(connectionLink.connFullLink)" case let .ownContactAddressConfirmConnect(connectionLink, _, _): return "ownContactAddressConfirmConnect \(connectionLink)"
case let .contactAddressConnectingConfirmReconnect(connectionLink, _, _): return "contactAddressConnectingConfirmReconnect \(connectionLink.connFullLink)" case let .contactAddressConnectingConfirmReconnect(connectionLink, _, _): return "contactAddressConnectingConfirmReconnect \(connectionLink)"
case let .groupLinkConfirmConnect(connectionLink, _, _): return "groupLinkConfirmConnect \(connectionLink.connFullLink)" case let .groupLinkConfirmConnect(connectionLink, _, _): return "groupLinkConfirmConnect \(connectionLink)"
case let .groupLinkConnectingConfirmReconnect(connectionLink, _, _): return "groupLinkConnectingConfirmReconnect \(connectionLink.connFullLink)" case let .groupLinkConnectingConfirmReconnect(connectionLink, _, _): return "groupLinkConnectingConfirmReconnect \(connectionLink)"
case let .groupLinkConnecting(connectionLink, _): return "groupLinkConnecting \(connectionLink.connFullLink)" case let .groupLinkConnecting(connectionLink, _): return "groupLinkConnecting \(connectionLink)"
case let .error(shortOrFullLink, alert): return "error \(shortOrFullLink)"
} }
} }
} }
@ -941,22 +935,21 @@ func planAndConnectAlert(_ alert: PlanAndConnectAlert, dismiss: Bool, cleanup: (
dismissButton: .default(Text("OK")) { cleanup?() } dismissButton: .default(Text("OK")) { cleanup?() }
) )
} }
case let .error(_, alert): return alert
} }
} }
enum PlanAndConnectActionSheet: Identifiable { enum PlanAndConnectActionSheet: Identifiable {
case askCurrentOrIncognitoProfile(connectionLink: CreatedConnLink, connectionPlan: ConnectionPlan?, title: LocalizedStringKey) case askCurrentOrIncognitoProfile(connectionLink: String, connectionPlan: ConnectionPlan?, title: LocalizedStringKey)
case askCurrentOrIncognitoProfileDestructive(connectionLink: CreatedConnLink, connectionPlan: ConnectionPlan, title: LocalizedStringKey) case askCurrentOrIncognitoProfileDestructive(connectionLink: String, connectionPlan: ConnectionPlan, title: LocalizedStringKey)
case askCurrentOrIncognitoProfileConnectContactViaAddress(contact: Contact) case askCurrentOrIncognitoProfileConnectContactViaAddress(contact: Contact)
case ownGroupLinkConfirmConnect(connectionLink: CreatedConnLink, connectionPlan: ConnectionPlan, incognito: Bool?, groupInfo: GroupInfo) case ownGroupLinkConfirmConnect(connectionLink: String, connectionPlan: ConnectionPlan, incognito: Bool?, groupInfo: GroupInfo)
var id: String { var id: String {
switch self { switch self {
case let .askCurrentOrIncognitoProfile(connectionLink, _, _): return "askCurrentOrIncognitoProfile \(connectionLink.connFullLink)" case let .askCurrentOrIncognitoProfile(connectionLink, _, _): return "askCurrentOrIncognitoProfile \(connectionLink)"
case let .askCurrentOrIncognitoProfileDestructive(connectionLink, _, _): return "askCurrentOrIncognitoProfileDestructive \(connectionLink.connFullLink)" case let .askCurrentOrIncognitoProfileDestructive(connectionLink, _, _): return "askCurrentOrIncognitoProfileDestructive \(connectionLink)"
case let .askCurrentOrIncognitoProfileConnectContactViaAddress(contact): return "askCurrentOrIncognitoProfileConnectContactViaAddress \(contact.contactId)" case let .askCurrentOrIncognitoProfileConnectContactViaAddress(contact): return "askCurrentOrIncognitoProfileConnectContactViaAddress \(contact.contactId)"
case let .ownGroupLinkConfirmConnect(connectionLink, _, _, _): return "ownGroupLinkConfirmConnect \(connectionLink.connFullLink)" case let .ownGroupLinkConfirmConnect(connectionLink, _, _, _): return "ownGroupLinkConfirmConnect \(connectionLink)"
} }
} }
} }
@ -1015,7 +1008,7 @@ func planAndConnectActionSheet(_ sheet: PlanAndConnectActionSheet, dismiss: Bool
} }
func planAndConnect( func planAndConnect(
_ shortOrFullLink: String, _ connectionLink: String,
showAlert: @escaping (PlanAndConnectAlert) -> Void, showAlert: @escaping (PlanAndConnectAlert) -> Void,
showActionSheet: @escaping (PlanAndConnectActionSheet) -> Void, showActionSheet: @escaping (PlanAndConnectActionSheet) -> Void,
dismiss: Bool, dismiss: Bool,
@ -1025,8 +1018,8 @@ func planAndConnect(
filterKnownGroup: ((GroupInfo) -> Void)? = nil filterKnownGroup: ((GroupInfo) -> Void)? = nil
) { ) {
Task { Task {
let (result, alert) = await apiConnectPlan(connLink: shortOrFullLink) do {
if let (connectionLink, connectionPlan) = result { let connectionPlan = try await apiConnectPlan(connReq: connectionLink)
switch connectionPlan { switch connectionPlan {
case let .invitationLink(ilp): case let .invitationLink(ilp):
switch ilp { switch ilp {
@ -1035,40 +1028,32 @@ func planAndConnect(
if let incognito = incognito { if let incognito = incognito {
connectViaLink(connectionLink, connectionPlan: connectionPlan, dismiss: dismiss, incognito: incognito, cleanup: cleanup) connectViaLink(connectionLink, connectionPlan: connectionPlan, dismiss: dismiss, incognito: incognito, cleanup: cleanup)
} else { } else {
await MainActor.run { showActionSheet(.askCurrentOrIncognitoProfile(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "Connect via one-time link"))
showActionSheet(.askCurrentOrIncognitoProfile(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "Connect via one-time link"))
}
} }
case .ownLink: case .ownLink:
logger.debug("planAndConnect, .invitationLink, .ownLink, incognito=\(incognito?.description ?? "nil")") logger.debug("planAndConnect, .invitationLink, .ownLink, incognito=\(incognito?.description ?? "nil")")
await MainActor.run { if let incognito = incognito {
if let incognito = incognito { showAlert(.ownInvitationLinkConfirmConnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito))
showAlert(.ownInvitationLinkConfirmConnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito)) } else {
} else { showActionSheet(.askCurrentOrIncognitoProfileDestructive(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "Connect to yourself?\nThis is your own one-time link!"))
showActionSheet(.askCurrentOrIncognitoProfileDestructive(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "Connect to yourself?\nThis is your own one-time link!"))
}
} }
case let .connecting(contact_): case let .connecting(contact_):
logger.debug("planAndConnect, .invitationLink, .connecting, incognito=\(incognito?.description ?? "nil")") logger.debug("planAndConnect, .invitationLink, .connecting, incognito=\(incognito?.description ?? "nil")")
await MainActor.run { if let contact = contact_ {
if let contact = contact_ {
if let f = filterKnownContact {
f(contact)
} else {
openKnownContact(contact, dismiss: dismiss) { AlertManager.shared.showAlert(contactAlreadyConnectingAlert(contact)) }
}
} else {
showAlert(.invitationLinkConnecting(connectionLink: connectionLink))
}
}
case let .known(contact):
logger.debug("planAndConnect, .invitationLink, .known, incognito=\(incognito?.description ?? "nil")")
await MainActor.run {
if let f = filterKnownContact { if let f = filterKnownContact {
f(contact) f(contact)
} else { } else {
openKnownContact(contact, dismiss: dismiss) { AlertManager.shared.showAlert(contactAlreadyExistsAlert(contact)) } openKnownContact(contact, dismiss: dismiss) { AlertManager.shared.showAlert(contactAlreadyConnectingAlert(contact)) }
} }
} else {
showAlert(.invitationLinkConnecting(connectionLink: connectionLink))
}
case let .known(contact):
logger.debug("planAndConnect, .invitationLink, .known, incognito=\(incognito?.description ?? "nil")")
if let f = filterKnownContact {
f(contact)
} else {
openKnownContact(contact, dismiss: dismiss) { AlertManager.shared.showAlert(contactAlreadyExistsAlert(contact)) }
} }
} }
case let .contactAddress(cap): case let .contactAddress(cap):
@ -1078,109 +1063,83 @@ func planAndConnect(
if let incognito = incognito { if let incognito = incognito {
connectViaLink(connectionLink, connectionPlan: connectionPlan, dismiss: dismiss, incognito: incognito, cleanup: cleanup) connectViaLink(connectionLink, connectionPlan: connectionPlan, dismiss: dismiss, incognito: incognito, cleanup: cleanup)
} else { } else {
await MainActor.run { showActionSheet(.askCurrentOrIncognitoProfile(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "Connect via contact address"))
showActionSheet(.askCurrentOrIncognitoProfile(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "Connect via contact address"))
}
} }
case .ownLink: case .ownLink:
logger.debug("planAndConnect, .contactAddress, .ownLink, incognito=\(incognito?.description ?? "nil")") logger.debug("planAndConnect, .contactAddress, .ownLink, incognito=\(incognito?.description ?? "nil")")
await MainActor.run { if let incognito = incognito {
if let incognito = incognito { showAlert(.ownContactAddressConfirmConnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito))
showAlert(.ownContactAddressConfirmConnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito)) } else {
} else { showActionSheet(.askCurrentOrIncognitoProfileDestructive(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "Connect to yourself?\nThis is your own SimpleX address!"))
showActionSheet(.askCurrentOrIncognitoProfileDestructive(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "Connect to yourself?\nThis is your own SimpleX address!"))
}
} }
case .connectingConfirmReconnect: case .connectingConfirmReconnect:
logger.debug("planAndConnect, .contactAddress, .connectingConfirmReconnect, incognito=\(incognito?.description ?? "nil")") logger.debug("planAndConnect, .contactAddress, .connectingConfirmReconnect, incognito=\(incognito?.description ?? "nil")")
await MainActor.run { if let incognito = incognito {
if let incognito = incognito { showAlert(.contactAddressConnectingConfirmReconnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito))
showAlert(.contactAddressConnectingConfirmReconnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito)) } else {
} else { showActionSheet(.askCurrentOrIncognitoProfileDestructive(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "You have already requested connection!\nRepeat connection request?"))
showActionSheet(.askCurrentOrIncognitoProfileDestructive(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "You have already requested connection!\nRepeat connection request?"))
}
} }
case let .connectingProhibit(contact): case let .connectingProhibit(contact):
logger.debug("planAndConnect, .contactAddress, .connectingProhibit, incognito=\(incognito?.description ?? "nil")") logger.debug("planAndConnect, .contactAddress, .connectingProhibit, incognito=\(incognito?.description ?? "nil")")
await MainActor.run { if let f = filterKnownContact {
if let f = filterKnownContact { f(contact)
f(contact) } else {
} else { openKnownContact(contact, dismiss: dismiss) { AlertManager.shared.showAlert(contactAlreadyConnectingAlert(contact)) }
openKnownContact(contact, dismiss: dismiss) { AlertManager.shared.showAlert(contactAlreadyConnectingAlert(contact)) }
}
} }
case let .known(contact): case let .known(contact):
logger.debug("planAndConnect, .contactAddress, .known, incognito=\(incognito?.description ?? "nil")") logger.debug("planAndConnect, .contactAddress, .known, incognito=\(incognito?.description ?? "nil")")
await MainActor.run { if let f = filterKnownContact {
if let f = filterKnownContact { f(contact)
f(contact) } else {
} else { openKnownContact(contact, dismiss: dismiss) { AlertManager.shared.showAlert(contactAlreadyExistsAlert(contact)) }
openKnownContact(contact, dismiss: dismiss) { AlertManager.shared.showAlert(contactAlreadyExistsAlert(contact)) }
}
} }
case let .contactViaAddress(contact): case let .contactViaAddress(contact):
logger.debug("planAndConnect, .contactAddress, .contactViaAddress, incognito=\(incognito?.description ?? "nil")") logger.debug("planAndConnect, .contactAddress, .contactViaAddress, incognito=\(incognito?.description ?? "nil")")
if let incognito = incognito { if let incognito = incognito {
connectContactViaAddress_(contact, dismiss: dismiss, incognito: incognito, cleanup: cleanup) connectContactViaAddress_(contact, dismiss: dismiss, incognito: incognito, cleanup: cleanup)
} else { } else {
await MainActor.run { showActionSheet(.askCurrentOrIncognitoProfileConnectContactViaAddress(contact: contact))
showActionSheet(.askCurrentOrIncognitoProfileConnectContactViaAddress(contact: contact))
}
} }
} }
case let .groupLink(glp): case let .groupLink(glp):
switch glp { switch glp {
case .ok: case .ok:
await MainActor.run { if let incognito = incognito {
if let incognito = incognito { showAlert(.groupLinkConfirmConnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito))
showAlert(.groupLinkConfirmConnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito)) } else {
} else { showActionSheet(.askCurrentOrIncognitoProfile(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "Join group"))
showActionSheet(.askCurrentOrIncognitoProfile(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "Join group"))
}
} }
case let .ownLink(groupInfo): case let .ownLink(groupInfo):
logger.debug("planAndConnect, .groupLink, .ownLink, incognito=\(incognito?.description ?? "nil")") logger.debug("planAndConnect, .groupLink, .ownLink, incognito=\(incognito?.description ?? "nil")")
await MainActor.run { if let f = filterKnownGroup {
if let f = filterKnownGroup { f(groupInfo)
f(groupInfo)
}
showActionSheet(.ownGroupLinkConfirmConnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito, groupInfo: groupInfo))
} }
showActionSheet(.ownGroupLinkConfirmConnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito, groupInfo: groupInfo))
case .connectingConfirmReconnect: case .connectingConfirmReconnect:
logger.debug("planAndConnect, .groupLink, .connectingConfirmReconnect, incognito=\(incognito?.description ?? "nil")") logger.debug("planAndConnect, .groupLink, .connectingConfirmReconnect, incognito=\(incognito?.description ?? "nil")")
await MainActor.run { if let incognito = incognito {
if let incognito = incognito { showAlert(.groupLinkConnectingConfirmReconnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito))
showAlert(.groupLinkConnectingConfirmReconnect(connectionLink: connectionLink, connectionPlan: connectionPlan, incognito: incognito)) } else {
} else { showActionSheet(.askCurrentOrIncognitoProfileDestructive(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "You are already joining the group!\nRepeat join request?"))
showActionSheet(.askCurrentOrIncognitoProfileDestructive(connectionLink: connectionLink, connectionPlan: connectionPlan, title: "You are already joining the group!\nRepeat join request?"))
}
} }
case let .connectingProhibit(groupInfo_): case let .connectingProhibit(groupInfo_):
logger.debug("planAndConnect, .groupLink, .connectingProhibit, incognito=\(incognito?.description ?? "nil")") logger.debug("planAndConnect, .groupLink, .connectingProhibit, incognito=\(incognito?.description ?? "nil")")
await MainActor.run { showAlert(.groupLinkConnecting(connectionLink: connectionLink, groupInfo: groupInfo_))
showAlert(.groupLinkConnecting(connectionLink: connectionLink, groupInfo: groupInfo_))
}
case let .known(groupInfo): case let .known(groupInfo):
logger.debug("planAndConnect, .groupLink, .known, incognito=\(incognito?.description ?? "nil")") logger.debug("planAndConnect, .groupLink, .known, incognito=\(incognito?.description ?? "nil")")
await MainActor.run { if let f = filterKnownGroup {
if let f = filterKnownGroup { f(groupInfo)
f(groupInfo) } else {
} else { openKnownGroup(groupInfo, dismiss: dismiss) { AlertManager.shared.showAlert(groupAlreadyExistsAlert(groupInfo)) }
openKnownGroup(groupInfo, dismiss: dismiss) { AlertManager.shared.showAlert(groupAlreadyExistsAlert(groupInfo)) }
}
} }
} }
case let .error(chatError):
logger.debug("planAndConnect, .error \(chatErrorString(chatError))")
if let incognito = incognito {
connectViaLink(connectionLink, connectionPlan: nil, dismiss: dismiss, incognito: incognito, cleanup: cleanup)
} else {
showActionSheet(.askCurrentOrIncognitoProfile(connectionLink: connectionLink, connectionPlan: nil, title: "Connect via link"))
}
} }
} else if let alert { } catch {
await MainActor.run { logger.debug("planAndConnect, plan error")
showAlert(.error(shortOrFullLink: shortOrFullLink, alert: alert)) if let incognito = incognito {
connectViaLink(connectionLink, connectionPlan: nil, dismiss: dismiss, incognito: incognito, cleanup: cleanup)
} else {
showActionSheet(.askCurrentOrIncognitoProfile(connectionLink: connectionLink, connectionPlan: nil, title: "Connect via link"))
} }
} }
} }
@ -1202,22 +1161,22 @@ private func connectContactViaAddress_(_ contact: Contact, dismiss: Bool, incogn
} }
private func connectViaLink( private func connectViaLink(
_ connectionLink: CreatedConnLink, _ connectionLink: String,
connectionPlan: ConnectionPlan?, connectionPlan: ConnectionPlan?,
dismiss: Bool, dismiss: Bool,
incognito: Bool, incognito: Bool,
cleanup: (() -> Void)? cleanup: (() -> Void)?
) { ) {
Task { Task {
if let (connReqType, pcc) = await apiConnect(incognito: incognito, connLink: connectionLink) { if let (connReqType, pcc) = await apiConnect(incognito: incognito, connReq: connectionLink) {
await MainActor.run { await MainActor.run {
ChatModel.shared.updateContactConnection(pcc) ChatModel.shared.updateContactConnection(pcc)
} }
let crt: ConnReqType let crt: ConnReqType
crt = if let plan = connectionPlan { if let plan = connectionPlan {
planToConnReqType(plan) ?? connReqType crt = planToConnReqType(plan)
} else { } else {
connReqType crt = connReqType
} }
DispatchQueue.main.async { DispatchQueue.main.async {
if dismiss { if dismiss {
@ -1240,35 +1199,39 @@ private func connectViaLink(
} }
func openKnownContact(_ contact: Contact, dismiss: Bool, showAlreadyExistsAlert: (() -> Void)?) { func openKnownContact(_ contact: Contact, dismiss: Bool, showAlreadyExistsAlert: (() -> Void)?) {
let m = ChatModel.shared Task {
if let c = m.getContactChat(contact.contactId) { let m = ChatModel.shared
if dismiss { if let c = m.getContactChat(contact.contactId) {
dismissAllSheets(animated: true) { DispatchQueue.main.async {
ItemsModel.shared.loadOpenChat(c.id) { if dismiss {
dismissAllSheets(animated: true) {
ItemsModel.shared.loadOpenChat(c.id)
showAlreadyExistsAlert?()
}
} else {
ItemsModel.shared.loadOpenChat(c.id)
showAlreadyExistsAlert?() showAlreadyExistsAlert?()
} }
} }
} else {
ItemsModel.shared.loadOpenChat(c.id) {
showAlreadyExistsAlert?()
}
} }
} }
} }
func openKnownGroup(_ groupInfo: GroupInfo, dismiss: Bool, showAlreadyExistsAlert: (() -> Void)?) { func openKnownGroup(_ groupInfo: GroupInfo, dismiss: Bool, showAlreadyExistsAlert: (() -> Void)?) {
let m = ChatModel.shared Task {
if let g = m.getGroupChat(groupInfo.groupId) { let m = ChatModel.shared
if dismiss { if let g = m.getGroupChat(groupInfo.groupId) {
dismissAllSheets(animated: true) { DispatchQueue.main.async {
ItemsModel.shared.loadOpenChat(g.id) { if dismiss {
dismissAllSheets(animated: true) {
ItemsModel.shared.loadOpenChat(g.id)
showAlreadyExistsAlert?()
}
} else {
ItemsModel.shared.loadOpenChat(g.id)
showAlreadyExistsAlert?() showAlreadyExistsAlert?()
} }
} }
} else {
ItemsModel.shared.loadOpenChat(g.id) {
showAlreadyExistsAlert?()
}
} }
} }
} }
@ -1306,12 +1269,11 @@ enum ConnReqType: Equatable {
} }
} }
private func planToConnReqType(_ connectionPlan: ConnectionPlan) -> ConnReqType? { private func planToConnReqType(_ connectionPlan: ConnectionPlan) -> ConnReqType {
switch connectionPlan { switch connectionPlan {
case .invitationLink: .invitation case .invitationLink: return .invitation
case .contactAddress: .contact case .contactAddress: return .contact
case .groupLink: .groupLink case .groupLink: return .groupLink
case .error: nil
} }
} }

View file

@ -8,7 +8,6 @@
import SwiftUI import SwiftUI
import CoreImage.CIFilterBuiltins import CoreImage.CIFilterBuiltins
import SimpleXChat
struct MutableQRCode: View { struct MutableQRCode: View {
@Binding var uri: String @Binding var uri: String
@ -21,16 +20,6 @@ struct MutableQRCode: View {
} }
} }
struct SimpleXCreatedLinkQRCode: View {
let link: CreatedConnLink
@Binding var short: Bool
var onShare: (() -> Void)? = nil
var body: some View {
QRCode(uri: link.simplexChatUri(short: short), onShare: onShare)
}
}
struct SimpleXLinkQRCode: View { struct SimpleXLinkQRCode: View {
let uri: String let uri: String
var withLogo: Bool = true var withLogo: Bool = true
@ -42,6 +31,12 @@ struct SimpleXLinkQRCode: View {
} }
} }
func simplexChatLink(_ uri: String) -> String {
uri.starts(with: "simplex:/")
? uri.replacingOccurrences(of: "simplex:/", with: "https://simplex.chat/")
: uri
}
struct QRCode: View { struct QRCode: View {
let uri: String let uri: String
var withLogo: Bool = true var withLogo: Bool = true

View file

@ -43,23 +43,26 @@ struct OnboardingButtonStyle: ButtonStyle {
} }
} }
private enum OnboardingConditionsViewSheet: Identifiable { private enum ChooseServerOperatorsSheet: Identifiable {
case showInfo
case showConditions case showConditions
case configureOperators
var id: String { var id: String {
switch self { switch self {
case .showInfo: return "showInfo"
case .showConditions: return "showConditions" case .showConditions: return "showConditions"
case .configureOperators: return "configureOperators"
} }
} }
} }
struct OnboardingConditionsView: View { struct ChooseServerOperators: View {
@Environment(\.dismiss) var dismiss: DismissAction
@Environment(\.colorScheme) var colorScheme: ColorScheme
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
var onboarding: Bool
@State private var serverOperators: [ServerOperator] = [] @State private var serverOperators: [ServerOperator] = []
@State private var selectedOperatorIds = Set<Int64>() @State private var selectedOperatorIds = Set<Int64>()
@State private var sheetItem: OnboardingConditionsViewSheet? = nil @State private var sheetItem: ChooseServerOperatorsSheet? = nil
@State private var notificationsModeNavLinkActive = false @State private var notificationsModeNavLinkActive = false
@State private var justOpened = true @State private var justOpened = true
@ -67,47 +70,83 @@ struct OnboardingConditionsView: View {
var body: some View { var body: some View {
GeometryReader { g in GeometryReader { g in
let v = ScrollView { ScrollView {
VStack(alignment: .leading, spacing: 20) { VStack(alignment: .leading, spacing: 20) {
Text("Conditions of use") let title = Text("Server operators")
.font(.largeTitle) .font(.largeTitle)
.bold() .bold()
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.padding(.top, 25)
if onboarding {
Spacer() title.padding(.top, 25)
} else {
VStack(alignment: .leading, spacing: 20) { title
Text("Private chats, groups and your contacts are not accessible to server operators.")
.lineSpacing(2)
.frame(maxWidth: .infinity, alignment: .leading)
Text("""
By using SimpleX Chat you agree to:
- send only legal content in public groups.
- respect other users no spam.
""")
.lineSpacing(2)
.frame(maxWidth: .infinity, alignment: .leading)
Button("Privacy policy and conditions of use.") {
sheetItem = .showConditions
}
.frame(maxWidth: .infinity, alignment: .leading)
} }
.padding(.horizontal, 4)
infoText()
.frame(maxWidth: .infinity, alignment: .center)
Spacer() Spacer()
VStack(spacing: 12) { ForEach(serverOperators) { srvOperator in
acceptConditionsButton() operatorCheckView(srvOperator)
}
Button("Configure server operators") { VStack {
sheetItem = .configureOperators Text("SimpleX Chat and Flux made an agreement to include Flux-operated servers into the app.").padding(.bottom, 8)
Text("You can configure servers via settings.")
}
.font(.footnote)
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity, alignment: .center)
.padding(.horizontal, 16)
Spacer()
let reviewForOperators = selectedOperators.filter { !$0.conditionsAcceptance.conditionsAccepted }
let canReviewLater = reviewForOperators.allSatisfy { $0.conditionsAcceptance.usageAllowed }
let currEnabledOperatorIds = Set(serverOperators.filter { $0.enabled }.map { $0.operatorId })
VStack(spacing: 8) {
if !reviewForOperators.isEmpty {
reviewConditionsButton()
} else if selectedOperatorIds != currEnabledOperatorIds && !selectedOperatorIds.isEmpty {
setOperatorsButton()
} else {
continueButton()
} }
.frame(minHeight: 40) if onboarding {
Group {
if reviewForOperators.isEmpty {
Button("Conditions of use") {
sheetItem = .showConditions
}
} else {
Text("Conditions of use")
.foregroundColor(.clear)
}
}
.font(.system(size: 17, weight: .semibold))
.frame(minHeight: 40)
}
}
if !onboarding && !reviewForOperators.isEmpty {
VStack(spacing: 8) {
reviewLaterButton()
(
Text("Conditions will be accepted for enabled operators after 30 days.")
+ textSpace
+ Text("You can configure operators in Network & servers settings.")
)
.multilineTextAlignment(.center)
.font(.footnote)
.padding(.horizontal, 32)
}
.frame(maxWidth: .infinity)
.disabled(!canReviewLater)
.padding(.bottom)
} }
} }
.padding(25)
.frame(minHeight: g.size.height) .frame(minHeight: g.size.height)
} }
.onAppear { .onAppear {
@ -119,28 +158,131 @@ struct OnboardingConditionsView: View {
} }
.sheet(item: $sheetItem) { item in .sheet(item: $sheetItem) { item in
switch item { switch item {
case .showInfo:
ChooseServerOperatorsInfoView()
case .showConditions: case .showConditions:
SimpleConditionsView() UsageConditionsView(
.modifier(ThemedBackground(grouped: true)) currUserServers: Binding.constant([]),
case .configureOperators: userServers: Binding.constant([]),
ChooseServerOperators(serverOperators: serverOperators, selectedOperatorIds: $selectedOperatorIds) updated: false
.modifier(ThemedBackground()) )
.modifier(ThemedBackground(grouped: true))
} }
} }
.frame(maxHeight: .infinity, alignment: .top) .frame(maxHeight: .infinity, alignment: .top)
if #available(iOS 16.4, *) {
v.scrollBounceBehavior(.basedOnSize)
} else {
v
}
} }
.frame(maxHeight: .infinity, alignment: .top) .frame(maxHeight: .infinity, alignment: .top)
.navigationBarHidden(true) // necessary on iOS 15 .padding(onboarding ? 25 : 16)
}
private func infoText() -> some View {
Button {
sheetItem = .showInfo
} label: {
Label("How it helps privacy", systemImage: "info.circle")
.font(.headline)
}
}
@ViewBuilder private func operatorCheckView(_ serverOperator: ServerOperator) -> some View {
let checked = selectedOperatorIds.contains(serverOperator.operatorId)
let icon = checked ? "checkmark.circle.fill" : "circle"
let iconColor = checked ? theme.colors.primary : Color(uiColor: .tertiaryLabel).asAnotherColorFromSecondary(theme)
HStack(spacing: 10) {
Image(serverOperator.largeLogo(colorScheme))
.resizable()
.scaledToFit()
.frame(height: 48)
Spacer()
Image(systemName: icon)
.resizable()
.scaledToFit()
.frame(width: 26, height: 26)
.foregroundColor(iconColor)
}
.background(theme.colors.background)
.padding()
.clipShape(RoundedRectangle(cornerRadius: 18))
.overlay(
RoundedRectangle(cornerRadius: 18)
.stroke(Color(uiColor: .secondarySystemFill), lineWidth: 2)
)
.padding(.horizontal, 2)
.onTapGesture {
if checked {
selectedOperatorIds.remove(serverOperator.operatorId)
} else {
selectedOperatorIds.insert(serverOperator.operatorId)
}
}
}
private func reviewConditionsButton() -> some View {
NavigationLink("Review conditions") {
reviewConditionsView()
.navigationTitle("Conditions of use")
.navigationBarTitleDisplayMode(.large)
.toolbar { ToolbarItem(placement: .navigationBarTrailing, content: conditionsLinkButton) }
.modifier(ThemedBackground(grouped: true))
}
.buttonStyle(OnboardingButtonStyle(isDisabled: selectedOperatorIds.isEmpty))
.disabled(selectedOperatorIds.isEmpty)
}
private func setOperatorsButton() -> some View {
notificationsModeNavLinkButton {
Button {
Task {
if let enabledOperators = enabledOperators(serverOperators) {
let r = try await setServerOperators(operators: enabledOperators)
await MainActor.run {
ChatModel.shared.conditions = r
continueToNextStep()
}
} else {
await MainActor.run {
continueToNextStep()
}
}
}
} label: {
Text("Update")
}
.buttonStyle(OnboardingButtonStyle(isDisabled: selectedOperatorIds.isEmpty))
.disabled(selectedOperatorIds.isEmpty)
}
}
private func continueButton() -> some View {
notificationsModeNavLinkButton {
Button {
continueToNextStep()
} label: {
Text("Continue")
}
.buttonStyle(OnboardingButtonStyle(isDisabled: selectedOperatorIds.isEmpty))
.disabled(selectedOperatorIds.isEmpty)
}
}
private func reviewLaterButton() -> some View {
notificationsModeNavLinkButton {
Button {
continueToNextStep()
} label: {
Text("Review later")
}
.buttonStyle(.borderless)
}
} }
private func continueToNextStep() { private func continueToNextStep() {
onboardingStageDefault.set(.step4_SetNotificationsMode) if onboarding {
notificationsModeNavLinkActive = true onboardingStageDefault.set(.step4_SetNotificationsMode)
notificationsModeNavLinkActive = true
} else {
dismiss()
}
} }
func notificationsModeNavLinkButton(_ button: @escaping (() -> some View)) -> some View { func notificationsModeNavLinkButton(_ button: @escaping (() -> some View)) -> some View {
@ -163,6 +305,25 @@ struct OnboardingConditionsView: View {
.modifier(ThemedBackground()) .modifier(ThemedBackground())
} }
@ViewBuilder private func reviewConditionsView() -> some View {
let operatorsWithConditionsAccepted = ChatModel.shared.conditions.serverOperators.filter { $0.conditionsAcceptance.conditionsAccepted }
let acceptForOperators = selectedOperators.filter { !$0.conditionsAcceptance.conditionsAccepted }
VStack(alignment: .leading, spacing: 20) {
if !operatorsWithConditionsAccepted.isEmpty {
Text("Conditions are already accepted for these operator(s): **\(operatorsWithConditionsAccepted.map { $0.legalName_ }.joined(separator: ", "))**.")
Text("The same conditions will apply to operator(s): **\(acceptForOperators.map { $0.legalName_ }.joined(separator: ", "))**.")
} else {
Text("Conditions will be accepted for operator(s): **\(acceptForOperators.map { $0.legalName_ }.joined(separator: ", "))**.")
}
ConditionsTextView()
.frame(maxHeight: .infinity)
acceptConditionsButton()
.padding(.bottom)
.padding(.bottom)
}
.padding(.horizontal, 25)
}
private func acceptConditionsButton() -> some View { private func acceptConditionsButton() -> some View {
notificationsModeNavLinkButton { notificationsModeNavLinkButton {
Button { Button {
@ -196,10 +357,9 @@ struct OnboardingConditionsView: View {
} }
} }
} label: { } label: {
Text("Accept") Text("Accept conditions")
} }
.buttonStyle(OnboardingButtonStyle(isDisabled: selectedOperatorIds.isEmpty)) .buttonStyle(OnboardingButtonStyle())
.disabled(selectedOperatorIds.isEmpty)
} }
} }
@ -234,126 +394,6 @@ struct OnboardingConditionsView: View {
} }
} }
private enum ChooseServerOperatorsSheet: Identifiable {
case showInfo
var id: String {
switch self {
case .showInfo: return "showInfo"
}
}
}
struct ChooseServerOperators: View {
@Environment(\.dismiss) var dismiss: DismissAction
@Environment(\.colorScheme) var colorScheme: ColorScheme
@EnvironmentObject var theme: AppTheme
var serverOperators: [ServerOperator]
@Binding var selectedOperatorIds: Set<Int64>
@State private var sheetItem: ChooseServerOperatorsSheet? = nil
var body: some View {
GeometryReader { g in
ScrollView {
VStack(alignment: .leading, spacing: 20) {
Text("Server operators")
.font(.largeTitle)
.bold()
.frame(maxWidth: .infinity, alignment: .center)
.padding(.top, 25)
infoText()
.frame(maxWidth: .infinity, alignment: .center)
Spacer()
ForEach(serverOperators) { srvOperator in
operatorCheckView(srvOperator)
}
VStack {
Text("SimpleX Chat and Flux made an agreement to include Flux-operated servers into the app.").padding(.bottom, 8)
Text("You can configure servers via settings.")
}
.font(.footnote)
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity, alignment: .center)
.padding(.horizontal, 16)
Spacer()
VStack(spacing: 8) {
setOperatorsButton()
onboardingButtonPlaceholder()
}
}
.frame(minHeight: g.size.height)
}
.sheet(item: $sheetItem) { item in
switch item {
case .showInfo:
ChooseServerOperatorsInfoView()
}
}
.frame(maxHeight: .infinity, alignment: .top)
}
.frame(maxHeight: .infinity, alignment: .top)
.padding(25)
.interactiveDismissDisabled(selectedOperatorIds.isEmpty)
}
private func infoText() -> some View {
Button {
sheetItem = .showInfo
} label: {
Label("How it helps privacy", systemImage: "info.circle")
.font(.headline)
}
}
private func operatorCheckView(_ serverOperator: ServerOperator) -> some View {
let checked = selectedOperatorIds.contains(serverOperator.operatorId)
let icon = checked ? "checkmark.circle.fill" : "circle"
let iconColor = checked ? theme.colors.primary : Color(uiColor: .tertiaryLabel).asAnotherColorFromSecondary(theme)
return HStack(spacing: 10) {
Image(serverOperator.largeLogo(colorScheme))
.resizable()
.scaledToFit()
.frame(height: 48)
Spacer()
Image(systemName: icon)
.resizable()
.scaledToFit()
.frame(width: 26, height: 26)
.foregroundColor(iconColor)
}
.background(theme.colors.background)
.padding()
.clipShape(RoundedRectangle(cornerRadius: 18))
.overlay(
RoundedRectangle(cornerRadius: 18)
.stroke(Color(uiColor: .secondarySystemFill), lineWidth: 2)
)
.padding(.horizontal, 2)
.onTapGesture {
if checked {
selectedOperatorIds.remove(serverOperator.operatorId)
} else {
selectedOperatorIds.insert(serverOperator.operatorId)
}
}
}
private func setOperatorsButton() -> some View {
Button {
dismiss()
} label: {
Text("OK")
}
.buttonStyle(OnboardingButtonStyle(isDisabled: selectedOperatorIds.isEmpty))
.disabled(selectedOperatorIds.isEmpty)
}
}
let operatorsPostLink = URL(string: "https://simplex.chat/blog/20241125-servers-operated-by-flux-true-privacy-and-decentralization-for-all-users.html")! let operatorsPostLink = URL(string: "https://simplex.chat/blog/20241125-servers-operated-by-flux-true-privacy-and-decentralization-for-all-users.html")!
struct ChooseServerOperatorsInfoView: View { struct ChooseServerOperatorsInfoView: View {
@ -408,5 +448,5 @@ struct ChooseServerOperatorsInfoView: View {
} }
#Preview { #Preview {
OnboardingConditionsView() ChooseServerOperators(onboarding: true)
} }

View file

@ -62,7 +62,8 @@ struct CreateProfile: View {
.frame(height: 20) .frame(height: 20)
} footer: { } footer: {
VStack(alignment: .leading, spacing: 8) { VStack(alignment: .leading, spacing: 8) {
Text("Your profile is stored on your device and only shared with your contacts.") Text("Your profile, contacts and delivered messages are stored on your device.")
Text("The profile is only shared with your contacts.")
} }
.foregroundColor(theme.colors.secondary) .foregroundColor(theme.colors.secondary)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
@ -117,22 +118,25 @@ struct CreateFirstProfile: View {
@State private var nextStepNavLinkActive = false @State private var nextStepNavLinkActive = false
var body: some View { var body: some View {
let v = VStack(alignment: .leading, spacing: 16) { VStack(alignment: .leading, spacing: 20) {
VStack(alignment: .center, spacing: 16) { VStack(alignment: .center, spacing: 20) {
Text("Create profile") Text("Create your profile")
.font(.largeTitle) .font(.largeTitle)
.bold() .bold()
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
Text("Your profile is stored on your device and only shared with your contacts.") Text("Your profile, contacts and delivered messages are stored on your device.")
.font(.callout)
.foregroundColor(theme.colors.secondary)
.multilineTextAlignment(.center)
Text("The profile is only shared with your contacts.")
.font(.callout) .font(.callout)
.foregroundColor(theme.colors.secondary) .foregroundColor(theme.colors.secondary)
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
} }
.fixedSize(horizontal: false, vertical: true)
.frame(maxWidth: .infinity) // Ensures it takes up the full width .frame(maxWidth: .infinity) // Ensures it takes up the full width
.padding(.horizontal, 10) .padding(.horizontal, 10)
.onTapGesture { focusDisplayName = false }
HStack { HStack {
let name = displayName.trimmingCharacters(in: .whitespaces) let name = displayName.trimmingCharacters(in: .whitespaces)
@ -141,7 +145,6 @@ struct CreateFirstProfile: View {
TextField("Enter your name…", text: $displayName) TextField("Enter your name…", text: $displayName)
.focused($focusDisplayName) .focused($focusDisplayName)
.padding(.horizontal) .padding(.horizontal)
.padding(.trailing, 20)
.padding(.vertical, 10) .padding(.vertical, 10)
.background( .background(
RoundedRectangle(cornerRadius: 10, style: .continuous) RoundedRectangle(cornerRadius: 10, style: .continuous)
@ -170,23 +173,12 @@ struct CreateFirstProfile: View {
} }
} }
.onAppear() { .onAppear() {
if #available(iOS 16, *) { focusDisplayName = true
focusDisplayName = true
} else {
// it does not work before animation completes on iOS 15
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
focusDisplayName = true
}
}
} }
.padding(.horizontal, 25) .padding(.horizontal, 25)
.padding(.top, 10)
.padding(.bottom, 25) .padding(.bottom, 25)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
if #available(iOS 16, *) {
return v.padding(.top, 10)
} else {
return v.padding(.top, 75).ignoresSafeArea(.all, edges: .top)
}
} }
func createProfileButton() -> some View { func createProfileButton() -> some View {
@ -214,7 +206,7 @@ struct CreateFirstProfile: View {
} }
private func nextStepDestinationView() -> some View { private func nextStepDestinationView() -> some View {
OnboardingConditionsView() ChooseServerOperators(onboarding: true)
.navigationBarBackButtonHidden(true) .navigationBarBackButtonHidden(true)
.modifier(ThemedBackground()) .modifier(ThemedBackground())
} }
@ -243,15 +235,15 @@ private func showCreateProfileAlert(
_ error: Error _ error: Error
) { ) {
let m = ChatModel.shared let m = ChatModel.shared
switch error as? ChatError { switch error as? ChatResponse {
case .errorStore(.duplicateName), case .chatCmdError(_, .errorStore(.duplicateName)),
.error(.userExists): .chatCmdError(_, .error(.userExists)):
if m.currentUser == nil { if m.currentUser == nil {
AlertManager.shared.showAlert(duplicateUserAlert) AlertManager.shared.showAlert(duplicateUserAlert)
} else { } else {
showAlert(.duplicateUserError) showAlert(.duplicateUserError)
} }
case .error(.invalidDisplayName): case .chatCmdError(_, .error(.invalidDisplayName)):
if m.currentUser == nil { if m.currentUser == nil {
AlertManager.shared.showAlert(invalidDisplayNameAlert) AlertManager.shared.showAlert(invalidDisplayNameAlert)
} else { } else {

View file

@ -31,7 +31,7 @@ struct CreateSimpleXAddress: View {
Spacer() Spacer()
if let userAddress = m.userAddress { if let userAddress = m.userAddress {
SimpleXCreatedLinkQRCode(link: userAddress.connLinkContact, short: Binding.constant(false)) SimpleXLinkQRCode(uri: userAddress.connReqContact)
.frame(maxHeight: g.size.width) .frame(maxHeight: g.size.width)
shareQRCodeButton(userAddress) shareQRCodeButton(userAddress)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
@ -77,9 +77,9 @@ struct CreateSimpleXAddress: View {
progressIndicator = true progressIndicator = true
Task { Task {
do { do {
let connLinkContact = try await apiCreateUserAddress(short: false) let connReqContact = try await apiCreateUserAddress()
DispatchQueue.main.async { DispatchQueue.main.async {
m.userAddress = UserContactLink(connLinkContact: connLinkContact) m.userAddress = UserContactLink(connReqContact: connReqContact)
} }
await MainActor.run { progressIndicator = false } await MainActor.run { progressIndicator = false }
} catch let error { } catch let error {
@ -121,7 +121,7 @@ struct CreateSimpleXAddress: View {
private func shareQRCodeButton(_ userAddress: UserContactLink) -> some View { private func shareQRCodeButton(_ userAddress: UserContactLink) -> some View {
Button { Button {
showShareSheet(items: [simplexChatLink(userAddress.connLinkContact.simplexChatUri(short: false))]) showShareSheet(items: [simplexChatLink(userAddress.connReqContact)])
} label: { } label: {
Label("Share", systemImage: "square.and.arrow.up") Label("Share", systemImage: "square.and.arrow.up")
} }
@ -189,7 +189,7 @@ struct SendAddressMailView: View {
let messageBody = String(format: NSLocalizedString(""" let messageBody = String(format: NSLocalizedString("""
<p>Hi!</p> <p>Hi!</p>
<p><a href="%@">Connect to me via SimpleX Chat</a></p> <p><a href="%@">Connect to me via SimpleX Chat</a></p>
""", comment: "email text"), simplexChatLink(userAddress.connLinkContact.simplexChatUri(short: false))) """, comment: "email text"), simplexChatLink(userAddress.connReqContact))
MailView( MailView(
isShowing: self.$showMailView, isShowing: self.$showMailView,
result: $mailViewResult, result: $mailViewResult,

View file

@ -23,7 +23,7 @@ struct OnboardingView: View {
case .step3_CreateSimpleXAddress: // deprecated case .step3_CreateSimpleXAddress: // deprecated
CreateSimpleXAddress() CreateSimpleXAddress()
case .step3_ChooseServerOperators: case .step3_ChooseServerOperators:
OnboardingConditionsView() ChooseServerOperators(onboarding: true)
.navigationBarBackButtonHidden(true) .navigationBarBackButtonHidden(true)
.modifier(ThemedBackground()) .modifier(ThemedBackground())
case .step4_SetNotificationsMode: case .step4_SetNotificationsMode:
@ -44,7 +44,7 @@ enum OnboardingStage: String, Identifiable {
case step1_SimpleXInfo case step1_SimpleXInfo
case step2_CreateProfile // deprecated case step2_CreateProfile // deprecated
case step3_CreateSimpleXAddress // deprecated case step3_CreateSimpleXAddress // deprecated
case step3_ChooseServerOperators // changed to simplified conditions case step3_ChooseServerOperators
case step4_SetNotificationsMode case step4_SetNotificationsMode
case onboardingComplete case onboardingComplete

View file

@ -17,7 +17,7 @@ struct SetNotificationsMode: View {
var body: some View { var body: some View {
GeometryReader { g in GeometryReader { g in
let v = ScrollView { ScrollView {
VStack(alignment: .center, spacing: 20) { VStack(alignment: .center, spacing: 20) {
Text("Push notifications") Text("Push notifications")
.font(.largeTitle) .font(.largeTitle)
@ -57,17 +57,11 @@ struct SetNotificationsMode: View {
.padding(25) .padding(25)
.frame(minHeight: g.size.height) .frame(minHeight: g.size.height)
} }
if #available(iOS 16.4, *) {
v.scrollBounceBehavior(.basedOnSize)
} else {
v
}
} }
.frame(maxHeight: .infinity) .frame(maxHeight: .infinity)
.sheet(isPresented: $showInfo) { .sheet(isPresented: $showInfo) {
NotificationsInfoView() NotificationsInfoView()
} }
.navigationBarHidden(true) // necessary on iOS 15
} }
private func setNotificationsMode(_ token: DeviceToken, _ mode: NotificationsMode) { private func setNotificationsMode(_ token: DeviceToken, _ mode: NotificationsMode) {

View file

@ -18,7 +18,7 @@ struct SimpleXInfo: View {
var body: some View { var body: some View {
GeometryReader { g in GeometryReader { g in
let v = ScrollView { ScrollView {
VStack(alignment: .leading) { VStack(alignment: .leading) {
VStack(alignment: .center, spacing: 10) { VStack(alignment: .center, spacing: 10) {
Image(colorScheme == .light ? "logo" : "logo-light") Image(colorScheme == .light ? "logo" : "logo-light")
@ -36,7 +36,7 @@ struct SimpleXInfo: View {
.font(.headline) .font(.headline)
} }
} }
Spacer() Spacer()
VStack(alignment: .leading) { VStack(alignment: .leading) {
@ -66,9 +66,6 @@ struct SimpleXInfo: View {
} }
} }
} }
.padding(.horizontal, 25)
.padding(.top, 75)
.padding(.bottom, 25)
.frame(minHeight: g.size.height) .frame(minHeight: g.size.height)
} }
.sheet(isPresented: Binding( .sheet(isPresented: Binding(
@ -91,17 +88,14 @@ struct SimpleXInfo: View {
createProfileNavLinkActive: $createProfileNavLinkActive createProfileNavLinkActive: $createProfileNavLinkActive
) )
} }
if #available(iOS 16.4, *) {
v.scrollBounceBehavior(.basedOnSize)
} else {
v
}
} }
.onAppear() { .onAppear() {
setLastVersionDefault() setLastVersionDefault()
} }
.frame(maxHeight: .infinity) .frame(maxHeight: .infinity)
.navigationBarHidden(true) // necessary on iOS 15 .padding(.horizontal, 25)
.padding(.top, 75)
.padding(.bottom, 25)
} }
private func onboardingInfoRow(_ image: String, _ title: LocalizedStringKey, _ text: LocalizedStringKey, width: CGFloat) -> some View { private func onboardingInfoRow(_ image: String, _ title: LocalizedStringKey, _ text: LocalizedStringKey, width: CGFloat) -> some View {
@ -135,7 +129,6 @@ struct SimpleXInfo: View {
NavigationLink(isActive: $createProfileNavLinkActive) { NavigationLink(isActive: $createProfileNavLinkActive) {
CreateFirstProfile() CreateFirstProfile()
.modifier(ThemedBackground())
} label: { } label: {
EmptyView() EmptyView()
} }
@ -147,8 +140,6 @@ struct SimpleXInfo: View {
let textSpace = Text(verbatim: " ") let textSpace = Text(verbatim: " ")
let textNewLine = Text(verbatim: "\n")
struct SimpleXInfo_Previews: PreviewProvider { struct SimpleXInfo_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
SimpleXInfo(onboarding: true) SimpleXInfo(onboarding: true)

View file

@ -542,7 +542,7 @@ private let versionDescriptions: [VersionDescription] = [
), ),
VersionDescription( VersionDescription(
version: "v6.3", version: "v6.3",
post: URL(string: "https://simplex.chat/blog/20250308-simplex-chat-v6-3-new-user-experience-safety-in-public-groups.html"), // post: URL(string: "https://simplex.chat/blog/20241210-simplex-network-v6-2-servers-by-flux-business-chats.html"),
features: [ features: [
.feature(Description( .feature(Description(
icon: "at", icon: "at",
@ -594,6 +594,8 @@ func shouldShowWhatsNew() -> Bool {
} }
fileprivate struct NewOperatorsView: View { fileprivate struct NewOperatorsView: View {
@State private var showOperatorsSheet = false
var body: some View { var body: some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
Image((operatorsInfo[.flux] ?? ServerOperator.dummyOperatorInfo).largeLogo) Image((operatorsInfo[.flux] ?? ServerOperator.dummyOperatorInfo).largeLogo)
@ -604,7 +606,16 @@ fileprivate struct NewOperatorsView: View {
.multilineTextAlignment(.leading) .multilineTextAlignment(.leading)
.lineLimit(10) .lineLimit(10)
HStack { HStack {
Text("Enable Flux in Network & servers settings for better metadata privacy.") Button("Enable Flux") {
showOperatorsSheet = true
}
Text("for better metadata privacy.")
}
}
.sheet(isPresented: $showOperatorsSheet) {
NavigationView {
ChooseServerOperators(onboarding: false)
.modifier(ThemedBackground())
} }
} }
} }
@ -636,7 +647,8 @@ struct WhatsNewView: View {
case .showConditions: case .showConditions:
UsageConditionsView( UsageConditionsView(
currUserServers: Binding.constant([]), currUserServers: Binding.constant([]),
userServers: Binding.constant([]) userServers: Binding.constant([]),
updated: true
) )
.modifier(ThemedBackground(grouped: true)) .modifier(ThemedBackground(grouped: true))
} }

View file

@ -456,12 +456,12 @@ struct ConnectDesktopView: View {
} }
} catch let e { } catch let e {
await MainActor.run { await MainActor.run {
switch e as? ChatError { switch e as? ChatResponse {
case .errorRemoteCtrl(.badInvitation): alert = .badInvitationError case .chatCmdError(_, .errorRemoteCtrl(.badInvitation)): alert = .badInvitationError
case .error(.commandError): alert = .badInvitationError case .chatCmdError(_, .error(.commandError)): alert = .badInvitationError
case let .errorRemoteCtrl(.badVersion(v)): alert = .badVersionError(version: v) case let .chatCmdError(_, .errorRemoteCtrl(.badVersion(v))): alert = .badVersionError(version: v)
case .errorAgent(.RCP(.version)): alert = .badVersionError(version: nil) case .chatCmdError(_, .errorAgent(.RCP(.version))): alert = .badVersionError(version: nil)
case .errorAgent(.RCP(.ctrlAuth)): alert = .desktopDisconnectedError case .chatCmdError(_, .errorAgent(.RCP(.ctrlAuth))): alert = .desktopDisconnectedError
default: errorAlert(e) default: errorAlert(e)
} }
} }

View file

@ -145,18 +145,18 @@ struct TerminalView: View {
} }
func consoleSendMessage() { func consoleSendMessage() {
let cmd = ChatCommand.string(composeState.message)
if composeState.message.starts(with: "/sql") && (!prefPerformLA || !developerTools) { if composeState.message.starts(with: "/sql") && (!prefPerformLA || !developerTools) {
let resp: APIResult<ChatResponse2> = APIResult.error(ChatError.error(errorType: ChatErrorType.commandError(message: "Failed reading: empty"))) let resp = ChatResponse.chatCmdError(user_: nil, chatError: ChatError.error(errorType: ChatErrorType.commandError(message: "Failed reading: empty")))
Task { Task {
await TerminalItems.shared.addCommand(.now, .string(composeState.message), resp) await TerminalItems.shared.addCommand(.now, cmd, resp)
} }
} else { } else {
let cmd = composeState.message
DispatchQueue.global().async { DispatchQueue.global().async {
Task { Task {
await MainActor.run { composeState.inProgress = true } composeState.inProgress = true
await sendTerminalCmd(cmd) _ = await chatSendCmd(cmd)
await MainActor.run { composeState.inProgress = false } composeState.inProgress = false
} }
} }
} }
@ -164,38 +164,12 @@ struct TerminalView: View {
} }
} }
func sendTerminalCmd(_ cmd: String) async {
let start: Date = .now
await withCheckedContinuation { (cont: CheckedContinuation<Void, Never>) in
let d = sendSimpleXCmdStr(cmd)
Task {
guard let d else {
await TerminalItems.shared.addCommand(start, ChatCommand.string(cmd), APIResult<ChatResponse2>.error(.invalidJSON(json: nil)))
return
}
let r0: APIResult<ChatResponse0> = decodeAPIResult(d)
guard case .invalid = r0 else {
await TerminalItems.shared.addCommand(start, .string(cmd), r0)
return
}
let r1: APIResult<ChatResponse1> = decodeAPIResult(d)
guard case .invalid = r1 else {
await TerminalItems.shared.addCommand(start, .string(cmd), r1)
return
}
let r2: APIResult<ChatResponse2> = decodeAPIResult(d)
await TerminalItems.shared.addCommand(start, .string(cmd), r2)
}
cont.resume(returning: ())
}
}
struct TerminalView_Previews: PreviewProvider { struct TerminalView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
let chatModel = ChatModel() let chatModel = ChatModel()
chatModel.terminalItems = [ chatModel.terminalItems = [
.err(.now, APIResult<ChatResponse2>.invalid(type: "contactSubscribed", json: "{}".data(using: .utf8)!).unexpected), .resp(.now, ChatResponse.response(type: "contactSubscribed", json: "{}")),
.err(.now, APIResult<ChatResponse2>.invalid(type: "newChatItems", json: "{}".data(using: .utf8)!).unexpected) .resp(.now, ChatResponse.response(type: "newChatItems", json: "{}"))
] ]
return NavigationView { return NavigationView {
TerminalView() TerminalView()

View file

@ -38,6 +38,7 @@ extension AppSettings {
privacyLinkPreviewsGroupDefault.set(val) privacyLinkPreviewsGroupDefault.set(val)
def.setValue(val, forKey: DEFAULT_PRIVACY_LINK_PREVIEWS) def.setValue(val, forKey: DEFAULT_PRIVACY_LINK_PREVIEWS)
} }
if let val = privacyChatListOpenLinks { privacyChatListOpenLinksDefault.set(val) }
if let val = privacyShowChatPreviews { def.setValue(val, forKey: DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS) } if let val = privacyShowChatPreviews { def.setValue(val, forKey: DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS) }
if let val = privacySaveLastDraft { def.setValue(val, forKey: DEFAULT_PRIVACY_SAVE_LAST_DRAFT) } if let val = privacySaveLastDraft { def.setValue(val, forKey: DEFAULT_PRIVACY_SAVE_LAST_DRAFT) }
if let val = privacyProtectScreen { def.setValue(val, forKey: DEFAULT_PRIVACY_PROTECT_SCREEN) } if let val = privacyProtectScreen { def.setValue(val, forKey: DEFAULT_PRIVACY_PROTECT_SCREEN) }
@ -77,6 +78,7 @@ extension AppSettings {
c.privacyAskToApproveRelays = privacyAskToApproveRelaysGroupDefault.get() c.privacyAskToApproveRelays = privacyAskToApproveRelaysGroupDefault.get()
c.privacyAcceptImages = privacyAcceptImagesGroupDefault.get() c.privacyAcceptImages = privacyAcceptImagesGroupDefault.get()
c.privacyLinkPreviews = def.bool(forKey: DEFAULT_PRIVACY_LINK_PREVIEWS) c.privacyLinkPreviews = def.bool(forKey: DEFAULT_PRIVACY_LINK_PREVIEWS)
c.privacyChatListOpenLinks = privacyChatListOpenLinksDefault.get()
c.privacyShowChatPreviews = def.bool(forKey: DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS) c.privacyShowChatPreviews = def.bool(forKey: DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS)
c.privacySaveLastDraft = def.bool(forKey: DEFAULT_PRIVACY_SAVE_LAST_DRAFT) c.privacySaveLastDraft = def.bool(forKey: DEFAULT_PRIVACY_SAVE_LAST_DRAFT)
c.privacyProtectScreen = def.bool(forKey: DEFAULT_PRIVACY_PROTECT_SCREEN) c.privacyProtectScreen = def.bool(forKey: DEFAULT_PRIVACY_PROTECT_SCREEN)

View file

@ -19,7 +19,7 @@ struct MarkdownHelp: View {
mdFormat("_italic_", Text("italic").italic()) mdFormat("_italic_", Text("italic").italic())
mdFormat("~strike~", Text("strike").strikethrough()) mdFormat("~strike~", Text("strike").strikethrough())
mdFormat("`a + b`", Text("`a + b`").font(.body.monospaced())) mdFormat("`a + b`", Text("`a + b`").font(.body.monospaced()))
mdFormat("!1 colored!", Text("colored").foregroundColor(.red) + Text(verbatim: " (") + color("1", .red) + color("2", .green) + color("3", .blue) + color("4", .yellow) + color("5", .cyan) + Text("6").foregroundColor(.purple) + Text(verbatim: ")")) mdFormat("!1 colored!", Text("colored").foregroundColor(.red) + Text(" (") + color("1", .red) + color("2", .green) + color("3", .blue) + color("4", .yellow) + color("5", .cyan) + Text("6").foregroundColor(.purple) + Text(")"))
( (
mdFormat("#secret#", Text("secret") mdFormat("#secret#", Text("secret")
.foregroundColor(.clear) .foregroundColor(.clear)
@ -39,7 +39,7 @@ private func mdFormat(_ format: LocalizedStringKey, _ example: Text) -> some Vie
} }
private func color(_ s: String, _ c: Color) -> Text { private func color(_ s: String, _ c: Color) -> Text {
Text(s).foregroundColor(c) + Text(verbatim: ", ") Text(s).foregroundColor(c) + Text(", ")
} }
struct MarkdownHelp_Previews: PreviewProvider { struct MarkdownHelp_Previews: PreviewProvider {

View file

@ -209,16 +209,11 @@ struct AdvancedNetworkSettings: View {
} }
Section { Section {
Picker("Use web port", selection: $netCfg.smpWebPortServers) { Toggle("Use web port", isOn: $netCfg.smpWebPort)
ForEach(SMPWebPortServers.allCases, id: \.self) { Text($0.text) }
}
.frame(height: 36)
} header: { } header: {
Text("TCP port for messaging") Text("TCP port for messaging")
} footer: { } footer: {
netCfg.smpWebPortServers == .preset Text("Use TCP port \(netCfg.smpWebPort ? "443" : "5223") when no port is specified.")
? Text("Use TCP port 443 for preset servers only.")
: Text("Use TCP port \(netCfg.smpWebPortServers == .all ? "443" : "5223") when no port is specified.")
} }
Section("TCP connection") { Section("TCP connection") {
@ -373,8 +368,8 @@ struct AdvancedNetworkSettings: View {
let userMode = Text("A separate TCP connection will be used **for each chat profile you have in the app**.") let userMode = Text("A separate TCP connection will be used **for each chat profile you have in the app**.")
return switch mode { return switch mode {
case .user: userMode case .user: userMode
case .session: userMode + textNewLine + Text("New SOCKS credentials will be used every time you start the app.") case .session: userMode + Text("\n") + Text("New SOCKS credentials will be used every time you start the app.")
case .server: userMode + textNewLine + Text("New SOCKS credentials will be used for each server.") case .server: userMode + Text("\n") + Text("New SOCKS credentials will be used for each server.")
case .entity: Text("A separate TCP connection will be used **for each contact and group member**.\n**Please note**: if you have many connections, your battery and traffic consumption can be substantially higher and some connections may fail.") case .entity: Text("A separate TCP connection will be used **for each contact and group member**.\n**Please note**: if you have many connections, your battery and traffic consumption can be substantially higher and some connections may fail.")
} }
} }

View file

@ -20,11 +20,11 @@ private enum NetworkAlert: Identifiable {
} }
private enum NetworkAndServersSheet: Identifiable { private enum NetworkAndServersSheet: Identifiable {
case showConditions case showConditions(updated: Bool)
var id: String { var id: String {
switch self { switch self {
case .showConditions: return "showConditions" case let .showConditions(updated): return "showConditions \(updated)"
} }
} }
} }
@ -169,10 +169,11 @@ struct NetworkAndServers: View {
} }
.sheet(item: $sheetItem) { item in .sheet(item: $sheetItem) { item in
switch item { switch item {
case .showConditions: case let .showConditions(updated):
UsageConditionsView( UsageConditionsView(
currUserServers: $ss.servers.currUserServers, currUserServers: $ss.servers.currUserServers,
userServers: $ss.servers.userServers userServers: $ss.servers.userServers,
updated: updated
) )
.modifier(ThemedBackground(grouped: true)) .modifier(ThemedBackground(grouped: true))
} }
@ -218,7 +219,8 @@ struct NetworkAndServers: View {
private func conditionsButton(_ conditionsAction: UsageConditionsAction) -> some View { private func conditionsButton(_ conditionsAction: UsageConditionsAction) -> some View {
Button { Button {
sheetItem = .showConditions let updated = if case .review = conditionsAction { true } else { false }
sheetItem = .showConditions(updated: updated)
} label: { } label: {
switch conditionsAction { switch conditionsAction {
case .review: case .review:
@ -235,26 +237,30 @@ struct UsageConditionsView: View {
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
@Binding var currUserServers: [UserOperatorServers] @Binding var currUserServers: [UserOperatorServers]
@Binding var userServers: [UserOperatorServers] @Binding var userServers: [UserOperatorServers]
var updated: Bool
var body: some View { var body: some View {
VStack(alignment: .leading, spacing: 20) { VStack(alignment: .leading, spacing: 20) {
HStack {
if updated {
Text("Updated conditions").font(.largeTitle).bold()
} else {
Text("Conditions of use").font(.largeTitle).bold()
Spacer()
conditionsLinkButton()
}
}
.padding(.top)
.padding(.top)
switch ChatModel.shared.conditions.conditionsAction { switch ChatModel.shared.conditions.conditionsAction {
case .none: case .none:
regularConditionsHeader()
.padding(.top)
.padding(.top)
ConditionsTextView() ConditionsTextView()
.padding(.bottom) .padding(.bottom)
.padding(.bottom) .padding(.bottom)
case let .review(operators, deadline, _): case let .review(operators, deadline, _):
HStack {
Text("Updated conditions").font(.largeTitle).bold()
}
.padding(.top)
.padding(.top)
Text("Conditions will be accepted for the operator(s): **\(operators.map { $0.legalName_ }.joined(separator: ", "))**.") Text("Conditions will be accepted for the operator(s): **\(operators.map { $0.legalName_ }.joined(separator: ", "))**.")
ConditionsTextView() ConditionsTextView()
VStack(spacing: 8) { VStack(spacing: 8) {
@ -266,8 +272,10 @@ struct UsageConditionsView: View {
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
.frame(maxWidth: .infinity, alignment: .center) .frame(maxWidth: .infinity, alignment: .center)
.padding(.horizontal, 32) .padding(.horizontal, 32)
conditionsDiffButton(.footnote) if updated {
} else { conditionsDiffButton(.footnote)
}
} else if updated {
conditionsDiffButton() conditionsDiffButton()
.padding(.top) .padding(.top)
} }
@ -277,9 +285,6 @@ struct UsageConditionsView: View {
case let .accepted(operators): case let .accepted(operators):
regularConditionsHeader()
.padding(.top)
.padding(.top)
Text("Conditions are accepted for the operator(s): **\(operators.map { $0.legalName_ }.joined(separator: ", "))**.") Text("Conditions are accepted for the operator(s): **\(operators.map { $0.legalName_ }.joined(separator: ", "))**.")
ConditionsTextView() ConditionsTextView()
.padding(.bottom) .padding(.bottom)
@ -335,30 +340,6 @@ struct UsageConditionsView: View {
} }
} }
private func regularConditionsHeader() -> some View {
HStack {
Text("Conditions of use").font(.largeTitle).bold()
Spacer()
conditionsLinkButton()
}
}
struct SimpleConditionsView: View {
var body: some View {
VStack(alignment: .leading, spacing: 20) {
regularConditionsHeader()
.padding(.top)
.padding(.top)
ConditionsTextView()
.padding(.bottom)
.padding(.bottom)
}
.padding(.horizontal, 25)
.frame(maxHeight: .infinity)
}
}
func validateServers_(_ userServers: Binding<[UserOperatorServers]>, _ serverErrors: Binding<[UserServersError]>) { func validateServers_(_ userServers: Binding<[UserOperatorServers]>, _ serverErrors: Binding<[UserServersError]>) {
let userServersToValidate = userServers.wrappedValue let userServersToValidate = userServers.wrappedValue
Task { Task {

View file

@ -38,9 +38,9 @@ struct OperatorView: View {
.allowsHitTesting(!testing) .allowsHitTesting(!testing)
} }
private func operatorView() -> some View { @ViewBuilder private func operatorView() -> some View {
let duplicateHosts = findDuplicateHosts(serverErrors) let duplicateHosts = findDuplicateHosts(serverErrors)
return VStack { VStack {
List { List {
Section { Section {
infoViewLink() infoViewLink()
@ -500,14 +500,14 @@ struct SingleOperatorUsageConditionsView: View {
} }
} }
private func acceptConditionsButton() -> some View { @ViewBuilder private func acceptConditionsButton() -> some View {
let operatorIds = ChatModel.shared.conditions.serverOperators let operatorIds = ChatModel.shared.conditions.serverOperators
.filter { .filter {
$0.operatorId == userServers[operatorIndex].operator_.operatorId || // Opened operator $0.operatorId == userServers[operatorIndex].operator_.operatorId || // Opened operator
($0.enabled && !$0.conditionsAcceptance.conditionsAccepted) // Other enabled operators with conditions not accepted ($0.enabled && !$0.conditionsAcceptance.conditionsAccepted) // Other enabled operators with conditions not accepted
} }
.map { $0.operatorId } .map { $0.operatorId }
return Button { Button {
acceptForOperators(operatorIds, operatorIndex) acceptForOperators(operatorIds, operatorIndex)
} label: { } label: {
Text("Accept conditions") Text("Accept conditions")

View file

@ -38,9 +38,9 @@ struct YourServersView: View {
.allowsHitTesting(!testing) .allowsHitTesting(!testing)
} }
private func yourServersView() -> some View { @ViewBuilder private func yourServersView() -> some View {
let duplicateHosts = findDuplicateHosts(serverErrors) let duplicateHosts = findDuplicateHosts(serverErrors)
return List { List {
if !userServers[operatorIndex].smpServers.filter({ !$0.deleted }).isEmpty { if !userServers[operatorIndex].smpServers.filter({ !$0.deleted }).isEmpty {
Section { Section {
ForEach($userServers[operatorIndex].smpServers) { srv in ForEach($userServers[operatorIndex].smpServers) { srv in

View file

@ -14,13 +14,12 @@ struct PrivacySettings: View {
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
@AppStorage(DEFAULT_PRIVACY_ACCEPT_IMAGES) private var autoAcceptImages = true @AppStorage(DEFAULT_PRIVACY_ACCEPT_IMAGES) private var autoAcceptImages = true
@AppStorage(DEFAULT_PRIVACY_LINK_PREVIEWS) private var useLinkPreviews = true @AppStorage(DEFAULT_PRIVACY_LINK_PREVIEWS) private var useLinkPreviews = true
@State private var chatListOpenLinks = privacyChatListOpenLinksDefault.get()
@AppStorage(DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS) private var showChatPreviews = true @AppStorage(DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS) private var showChatPreviews = true
@AppStorage(DEFAULT_PRIVACY_SAVE_LAST_DRAFT) private var saveLastDraft = true @AppStorage(DEFAULT_PRIVACY_SAVE_LAST_DRAFT) private var saveLastDraft = true
@AppStorage(GROUP_DEFAULT_PRIVACY_ENCRYPT_LOCAL_FILES, store: groupDefaults) private var encryptLocalFiles = true @AppStorage(GROUP_DEFAULT_PRIVACY_ENCRYPT_LOCAL_FILES, store: groupDefaults) private var encryptLocalFiles = true
@AppStorage(GROUP_DEFAULT_PRIVACY_ASK_TO_APPROVE_RELAYS, store: groupDefaults) private var askToApproveRelays = true @AppStorage(GROUP_DEFAULT_PRIVACY_ASK_TO_APPROVE_RELAYS, store: groupDefaults) private var askToApproveRelays = true
@State private var simplexLinkMode = privacySimplexLinkModeDefault.get() @State private var simplexLinkMode = privacySimplexLinkModeDefault.get()
@AppStorage(DEFAULT_DEVELOPER_TOOLS) private var developerTools = false
@AppStorage(DEFAULT_PRIVACY_SHORT_LINKS) private var shortSimplexLinks = false
@AppStorage(DEFAULT_PRIVACY_PROTECT_SCREEN) private var protectScreen = false @AppStorage(DEFAULT_PRIVACY_PROTECT_SCREEN) private var protectScreen = false
@AppStorage(DEFAULT_PERFORM_LA) private var prefPerformLA = false @AppStorage(DEFAULT_PERFORM_LA) private var prefPerformLA = false
@State private var currentLAMode = privacyLocalAuthModeDefault.get() @State private var currentLAMode = privacyLocalAuthModeDefault.get()
@ -76,6 +75,17 @@ struct PrivacySettings: View {
privacyLinkPreviewsGroupDefault.set(linkPreviews) privacyLinkPreviewsGroupDefault.set(linkPreviews)
} }
} }
settingsRow("arrow.up.right.circle", color: theme.colors.secondary) {
Picker("Open links from chat list", selection: $chatListOpenLinks) {
ForEach(PrivacyChatListOpenLinksMode.allCases) { mode in
Text(mode.text)
}
}
}
.frame(height: 36)
.onChange(of: chatListOpenLinks) { mode in
privacyChatListOpenLinksDefault.set(mode)
}
settingsRow("message", color: theme.colors.secondary) { settingsRow("message", color: theme.colors.secondary) {
Toggle("Show last messages", isOn: $showChatPreviews) Toggle("Show last messages", isOn: $showChatPreviews)
} }
@ -101,11 +111,6 @@ struct PrivacySettings: View {
.onChange(of: simplexLinkMode) { mode in .onChange(of: simplexLinkMode) { mode in
privacySimplexLinkModeDefault.set(mode) privacySimplexLinkModeDefault.set(mode)
} }
if developerTools {
settingsRow("link.badge.plus", color: theme.colors.secondary) {
Toggle("Use short links (BETA)", isOn: $shortSimplexLinks)
}
}
} header: { } header: {
Text("Chats") Text("Chats")
.foregroundColor(theme.colors.secondary) .foregroundColor(theme.colors.secondary)

View file

@ -29,10 +29,10 @@ let DEFAULT_WEBRTC_ICE_SERVERS = "webrtcICEServers"
let DEFAULT_CALL_KIT_CALLS_IN_RECENTS = "callKitCallsInRecents" let DEFAULT_CALL_KIT_CALLS_IN_RECENTS = "callKitCallsInRecents"
let DEFAULT_PRIVACY_ACCEPT_IMAGES = "privacyAcceptImages" // unused. Use GROUP_DEFAULT_PRIVACY_ACCEPT_IMAGES instead let DEFAULT_PRIVACY_ACCEPT_IMAGES = "privacyAcceptImages" // unused. Use GROUP_DEFAULT_PRIVACY_ACCEPT_IMAGES instead
let DEFAULT_PRIVACY_LINK_PREVIEWS = "privacyLinkPreviews" // deprecated, moved to app group let DEFAULT_PRIVACY_LINK_PREVIEWS = "privacyLinkPreviews" // deprecated, moved to app group
let DEFAULT_PRIVACY_CHAT_LIST_OPEN_LINKS = "privacyChatListOpenLinks"
let DEFAULT_PRIVACY_SIMPLEX_LINK_MODE = "privacySimplexLinkMode" let DEFAULT_PRIVACY_SIMPLEX_LINK_MODE = "privacySimplexLinkMode"
let DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS = "privacyShowChatPreviews" let DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS = "privacyShowChatPreviews"
let DEFAULT_PRIVACY_SAVE_LAST_DRAFT = "privacySaveLastDraft" let DEFAULT_PRIVACY_SAVE_LAST_DRAFT = "privacySaveLastDraft"
let DEFAULT_PRIVACY_SHORT_LINKS = "privacyShortLinks"
let DEFAULT_PRIVACY_PROTECT_SCREEN = "privacyProtectScreen" let DEFAULT_PRIVACY_PROTECT_SCREEN = "privacyProtectScreen"
let DEFAULT_PRIVACY_DELIVERY_RECEIPTS_SET = "privacyDeliveryReceiptsSet" let DEFAULT_PRIVACY_DELIVERY_RECEIPTS_SET = "privacyDeliveryReceiptsSet"
let DEFAULT_PRIVACY_MEDIA_BLUR_RADIUS = "privacyMediaBlurRadius" let DEFAULT_PRIVACY_MEDIA_BLUR_RADIUS = "privacyMediaBlurRadius"
@ -99,7 +99,6 @@ let appDefaults: [String: Any] = [
DEFAULT_PRIVACY_SIMPLEX_LINK_MODE: SimpleXLinkMode.description.rawValue, DEFAULT_PRIVACY_SIMPLEX_LINK_MODE: SimpleXLinkMode.description.rawValue,
DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS: true, DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS: true,
DEFAULT_PRIVACY_SAVE_LAST_DRAFT: true, DEFAULT_PRIVACY_SAVE_LAST_DRAFT: true,
DEFAULT_PRIVACY_SHORT_LINKS: false,
DEFAULT_PRIVACY_PROTECT_SCREEN: false, DEFAULT_PRIVACY_PROTECT_SCREEN: false,
DEFAULT_PRIVACY_DELIVERY_RECEIPTS_SET: false, DEFAULT_PRIVACY_DELIVERY_RECEIPTS_SET: false,
DEFAULT_PRIVACY_MEDIA_BLUR_RADIUS: 0, DEFAULT_PRIVACY_MEDIA_BLUR_RADIUS: 0,
@ -184,6 +183,8 @@ let connectViaLinkTabDefault = EnumDefault<ConnectViaLinkTab>(defaults: UserDefa
let privacySimplexLinkModeDefault = EnumDefault<SimpleXLinkMode>(defaults: UserDefaults.standard, forKey: DEFAULT_PRIVACY_SIMPLEX_LINK_MODE, withDefault: .description) let privacySimplexLinkModeDefault = EnumDefault<SimpleXLinkMode>(defaults: UserDefaults.standard, forKey: DEFAULT_PRIVACY_SIMPLEX_LINK_MODE, withDefault: .description)
let privacyChatListOpenLinksDefault = EnumDefault<PrivacyChatListOpenLinksMode>(defaults: UserDefaults.standard, forKey: DEFAULT_PRIVACY_CHAT_LIST_OPEN_LINKS, withDefault: PrivacyChatListOpenLinksMode.ask)
let privacyLocalAuthModeDefault = EnumDefault<LAMode>(defaults: UserDefaults.standard, forKey: DEFAULT_LA_MODE, withDefault: .system) let privacyLocalAuthModeDefault = EnumDefault<LAMode>(defaults: UserDefaults.standard, forKey: DEFAULT_LA_MODE, withDefault: .system)
let privacyDeliveryReceiptsSet = BoolDefault(defaults: UserDefaults.standard, forKey: DEFAULT_PRIVACY_DELIVERY_RECEIPTS_SET) let privacyDeliveryReceiptsSet = BoolDefault(defaults: UserDefaults.standard, forKey: DEFAULT_PRIVACY_DELIVERY_RECEIPTS_SET)
@ -280,159 +281,159 @@ struct SettingsView: View {
} }
} }
func settingsView() -> some View { @ViewBuilder func settingsView() -> some View {
List { let user = chatModel.currentUser
let user = chatModel.currentUser List {
Section(header: Text("Settings").foregroundColor(theme.colors.secondary)) { Section(header: Text("Settings").foregroundColor(theme.colors.secondary)) {
NavigationLink {
NotificationsView()
.navigationTitle("Notifications")
.modifier(ThemedBackground(grouped: true))
} label: {
HStack {
notificationsIcon()
Text("Notifications")
}
}
.disabled(chatModel.chatRunning != true)
NavigationLink {
NetworkAndServers()
.navigationTitle("Network & servers")
.modifier(ThemedBackground(grouped: true))
} label: {
settingsRow("externaldrive.connected.to.line.below", color: theme.colors.secondary) { Text("Network & servers") }
}
.disabled(chatModel.chatRunning != true)
NavigationLink {
CallSettings()
.navigationTitle("Your calls")
.modifier(ThemedBackground(grouped: true))
} label: {
settingsRow("video", color: theme.colors.secondary) { Text("Audio & video calls") }
}
.disabled(chatModel.chatRunning != true)
NavigationLink {
PrivacySettings()
.navigationTitle("Your privacy")
.modifier(ThemedBackground(grouped: true))
} label: {
settingsRow("lock", color: theme.colors.secondary) { Text("Privacy & security") }
}
.disabled(chatModel.chatRunning != true)
if UIApplication.shared.supportsAlternateIcons {
NavigationLink { NavigationLink {
AppearanceSettings() NotificationsView()
.navigationTitle("Appearance") .navigationTitle("Notifications")
.modifier(ThemedBackground(grouped: true)) .modifier(ThemedBackground(grouped: true))
} label: { } label: {
settingsRow("sun.max", color: theme.colors.secondary) { Text("Appearance") } HStack {
notificationsIcon()
Text("Notifications")
}
} }
.disabled(chatModel.chatRunning != true) .disabled(chatModel.chatRunning != true)
}
}
Section(header: Text("Chat database").foregroundColor(theme.colors.secondary)) {
chatDatabaseRow()
NavigationLink {
MigrateFromDevice(showProgressOnSettings: $showProgress)
.toolbar {
// Redaction broken for `.navigationTitle` - using a toolbar item instead.
ToolbarItem(placement: .principal) {
Text("Migrate device").font(.headline)
}
}
.modifier(ThemedBackground(grouped: true))
.navigationBarTitleDisplayMode(.large)
} label: {
settingsRow("tray.and.arrow.up", color: theme.colors.secondary) { Text("Migrate to another device") }
}
}
Section(header: Text("Help").foregroundColor(theme.colors.secondary)) {
if let user = user {
NavigationLink { NavigationLink {
ChatHelp(dismissSettingsSheet: dismiss) NetworkAndServers()
.navigationTitle("Welcome \(user.displayName)!") .navigationTitle("Network & servers")
.modifier(ThemedBackground(grouped: true))
} label: {
settingsRow("externaldrive.connected.to.line.below", color: theme.colors.secondary) { Text("Network & servers") }
}
.disabled(chatModel.chatRunning != true)
NavigationLink {
CallSettings()
.navigationTitle("Your calls")
.modifier(ThemedBackground(grouped: true))
} label: {
settingsRow("video", color: theme.colors.secondary) { Text("Audio & video calls") }
}
.disabled(chatModel.chatRunning != true)
NavigationLink {
PrivacySettings()
.navigationTitle("Your privacy")
.modifier(ThemedBackground(grouped: true))
} label: {
settingsRow("lock", color: theme.colors.secondary) { Text("Privacy & security") }
}
.disabled(chatModel.chatRunning != true)
if UIApplication.shared.supportsAlternateIcons {
NavigationLink {
AppearanceSettings()
.navigationTitle("Appearance")
.modifier(ThemedBackground(grouped: true))
} label: {
settingsRow("sun.max", color: theme.colors.secondary) { Text("Appearance") }
}
.disabled(chatModel.chatRunning != true)
}
}
Section(header: Text("Chat database").foregroundColor(theme.colors.secondary)) {
chatDatabaseRow()
NavigationLink {
MigrateFromDevice(showProgressOnSettings: $showProgress)
.toolbar {
// Redaction broken for `.navigationTitle` - using a toolbar item instead.
ToolbarItem(placement: .principal) {
Text("Migrate device").font(.headline)
}
}
.modifier(ThemedBackground(grouped: true))
.navigationBarTitleDisplayMode(.large)
} label: {
settingsRow("tray.and.arrow.up", color: theme.colors.secondary) { Text("Migrate to another device") }
}
}
Section(header: Text("Help").foregroundColor(theme.colors.secondary)) {
if let user = user {
NavigationLink {
ChatHelp(dismissSettingsSheet: dismiss)
.navigationTitle("Welcome \(user.displayName)!")
.modifier(ThemedBackground())
.frame(maxHeight: .infinity, alignment: .top)
} label: {
settingsRow("questionmark", color: theme.colors.secondary) { Text("How to use it") }
}
}
NavigationLink {
WhatsNewView(viaSettings: true, updatedConditions: false)
.modifier(ThemedBackground())
.navigationBarTitleDisplayMode(.inline)
} label: {
settingsRow("plus", color: theme.colors.secondary) { Text("What's new") }
}
NavigationLink {
SimpleXInfo(onboarding: false)
.navigationBarTitle("", displayMode: .inline)
.modifier(ThemedBackground()) .modifier(ThemedBackground())
.frame(maxHeight: .infinity, alignment: .top) .frame(maxHeight: .infinity, alignment: .top)
} label: { } label: {
settingsRow("questionmark", color: theme.colors.secondary) { Text("How to use it") } settingsRow("info", color: theme.colors.secondary) { Text("About SimpleX Chat") }
} }
} settingsRow("number", color: theme.colors.secondary) {
NavigationLink { Button("Send questions and ideas") {
WhatsNewView(viaSettings: true, updatedConditions: false) dismiss()
.modifier(ThemedBackground()) DispatchQueue.main.async {
.navigationBarTitleDisplayMode(.inline) UIApplication.shared.open(simplexTeamURL)
} label: { }
settingsRow("plus", color: theme.colors.secondary) { Text("What's new") }
}
NavigationLink {
SimpleXInfo(onboarding: false)
.navigationBarTitle("", displayMode: .inline)
.modifier(ThemedBackground())
.frame(maxHeight: .infinity, alignment: .top)
} label: {
settingsRow("info", color: theme.colors.secondary) { Text("About SimpleX Chat") }
}
settingsRow("number", color: theme.colors.secondary) {
Button("Send questions and ideas") {
dismiss()
DispatchQueue.main.async {
UIApplication.shared.open(simplexTeamURL)
} }
} }
.disabled(chatModel.chatRunning != true)
settingsRow("envelope", color: theme.colors.secondary) { Text("[Send us email](mailto:chat@simplex.chat)") }
} }
.disabled(chatModel.chatRunning != true)
settingsRow("envelope", color: theme.colors.secondary) { Text("[Send us email](mailto:chat@simplex.chat)") }
}
Section(header: Text("Support SimpleX Chat").foregroundColor(theme.colors.secondary)) { Section(header: Text("Support SimpleX Chat").foregroundColor(theme.colors.secondary)) {
settingsRow("keyboard", color: theme.colors.secondary) { Text("[Contribute](https://github.com/simplex-chat/simplex-chat#contribute)") } settingsRow("keyboard", color: theme.colors.secondary) { Text("[Contribute](https://github.com/simplex-chat/simplex-chat#contribute)") }
settingsRow("star", color: theme.colors.secondary) { settingsRow("star", color: theme.colors.secondary) {
Button("Rate the app") { Button("Rate the app") {
if let scene = sceneDelegate.windowScene { if let scene = sceneDelegate.windowScene {
SKStoreReviewController.requestReview(in: scene) SKStoreReviewController.requestReview(in: scene)
}
} }
} }
ZStack(alignment: .leading) {
Image(colorScheme == .dark ? "github_light" : "github")
.resizable()
.frame(width: 24, height: 24)
.opacity(0.5)
.colorMultiply(theme.colors.secondary)
Text("[Star on GitHub](https://github.com/simplex-chat/simplex-chat)")
.padding(.leading, indent)
}
} }
ZStack(alignment: .leading) {
Image(colorScheme == .dark ? "github_light" : "github")
.resizable()
.frame(width: 24, height: 24)
.opacity(0.5)
.colorMultiply(theme.colors.secondary)
Text("[Star on GitHub](https://github.com/simplex-chat/simplex-chat)")
.padding(.leading, indent)
}
}
Section(header: Text("Develop").foregroundColor(theme.colors.secondary)) { Section(header: Text("Develop").foregroundColor(theme.colors.secondary)) {
NavigationLink { NavigationLink {
DeveloperView() DeveloperView()
.navigationTitle("Developer tools") .navigationTitle("Developer tools")
.modifier(ThemedBackground(grouped: true)) .modifier(ThemedBackground(grouped: true))
} label: { } label: {
settingsRow("chevron.left.forwardslash.chevron.right", color: theme.colors.secondary) { Text("Developer tools") } settingsRow("chevron.left.forwardslash.chevron.right", color: theme.colors.secondary) { Text("Developer tools") }
} }
NavigationLink { NavigationLink {
VersionView() VersionView()
.navigationBarTitle("App version") .navigationBarTitle("App version")
.modifier(ThemedBackground()) .modifier(ThemedBackground())
} label: { } label: {
Text("v\(appVersion ?? "?") (\(appBuild ?? "?"))") Text("v\(appVersion ?? "?") (\(appBuild ?? "?"))")
}
} }
} }
} .navigationTitle("Your settings")
.navigationTitle("Your settings") .modifier(ThemedBackground(grouped: true))
.modifier(ThemedBackground(grouped: true)) .onDisappear {
.onDisappear { chatModel.showingTerminal = false
chatModel.showingTerminal = false chatModel.terminalItems = []
chatModel.terminalItems = [] }
}
} }
private func chatDatabaseRow() -> some View { private func chatDatabaseRow() -> some View {
@ -527,7 +528,7 @@ struct ProfilePreview: View {
func profileName(_ profileOf: NamedChat) -> Text { func profileName(_ profileOf: NamedChat) -> Text {
var t = Text(profileOf.displayName).fontWeight(.semibold).font(.title2) var t = Text(profileOf.displayName).fontWeight(.semibold).font(.title2)
if profileOf.fullName != "" && profileOf.fullName != profileOf.displayName { if profileOf.fullName != "" && profileOf.fullName != profileOf.displayName {
t = t + Text(verbatim: " (" + profileOf.fullName + ")") t = t + Text(" (" + profileOf.fullName + ")")
// .font(.callout) // .font(.callout)
} }
return t return t

View file

@ -33,7 +33,7 @@ struct StorageView: View {
private func directoryView(_ name: LocalizedStringKey, _ contents: [String: Int64]) -> some View { private func directoryView(_ name: LocalizedStringKey, _ contents: [String: Int64]) -> some View {
Text(name).font(.headline) Text(name).font(.headline)
ForEach(Array(contents), id: \.key) { (key, value) in ForEach(Array(contents), id: \.key) { (key, value) in
Text(key).bold() + Text(verbatim: " ") + Text((ByteCountFormatter.string(fromByteCount: value, countStyle: .binary))) Text(key).bold() + Text(" ") + Text("\(ByteCountFormatter.string(fromByteCount: value, countStyle: .binary))")
} }
} }

View file

@ -8,7 +8,7 @@
import SwiftUI import SwiftUI
import MessageUI import MessageUI
@preconcurrency import SimpleXChat import SimpleXChat
struct UserAddressView: View { struct UserAddressView: View {
@Environment(\.dismiss) var dismiss: DismissAction @Environment(\.dismiss) var dismiss: DismissAction
@ -16,7 +16,6 @@ struct UserAddressView: View {
@EnvironmentObject var theme: AppTheme @EnvironmentObject var theme: AppTheme
@State var shareViaProfile = false @State var shareViaProfile = false
@State var autoCreate = false @State var autoCreate = false
@State private var showShortLink = true
@State private var aas = AutoAcceptState() @State private var aas = AutoAcceptState()
@State private var savedAAS = AutoAcceptState() @State private var savedAAS = AutoAcceptState()
@State private var showMailView = false @State private var showMailView = false
@ -136,8 +135,8 @@ struct UserAddressView: View {
@ViewBuilder private func existingAddressView(_ userAddress: UserContactLink) -> some View { @ViewBuilder private func existingAddressView(_ userAddress: UserContactLink) -> some View {
Section { Section {
SimpleXCreatedLinkQRCode(link: userAddress.connLinkContact, short: $showShortLink) SimpleXLinkQRCode(uri: userAddress.connReqContact)
.id("simplex-contact-address-qrcode-\(userAddress.connLinkContact.simplexChatUri(short: showShortLink))") .id("simplex-contact-address-qrcode-\(userAddress.connReqContact)")
shareQRCodeButton(userAddress) shareQRCodeButton(userAddress)
// if MFMailComposeViewController.canSendMail() { // if MFMailComposeViewController.canSendMail() {
// shareViaEmailButton(userAddress) // shareViaEmailButton(userAddress)
@ -154,7 +153,8 @@ struct UserAddressView: View {
} }
addressSettingsButton(userAddress) addressSettingsButton(userAddress)
} header: { } header: {
ToggleShortLinkHeader(text: Text("For social media"), link: userAddress.connLinkContact, short: $showShortLink) Text("For social media")
.foregroundColor(theme.colors.secondary)
} footer: { } footer: {
if aas.business { if aas.business {
Text("Add your team members to the conversations.") Text("Add your team members to the conversations.")
@ -193,10 +193,9 @@ struct UserAddressView: View {
progressIndicator = true progressIndicator = true
Task { Task {
do { do {
let short = UserDefaults.standard.bool(forKey: DEFAULT_PRIVACY_SHORT_LINKS) let connReqContact = try await apiCreateUserAddress()
let connLinkContact = try await apiCreateUserAddress(short: short)
DispatchQueue.main.async { DispatchQueue.main.async {
chatModel.userAddress = UserContactLink(connLinkContact: connLinkContact) chatModel.userAddress = UserContactLink(connReqContact: connReqContact)
alert = .shareOnCreate alert = .shareOnCreate
progressIndicator = false progressIndicator = false
} }
@ -232,7 +231,7 @@ struct UserAddressView: View {
private func shareQRCodeButton(_ userAddress: UserContactLink) -> some View { private func shareQRCodeButton(_ userAddress: UserContactLink) -> some View {
Button { Button {
showShareSheet(items: [simplexChatLink(userAddress.connLinkContact.simplexChatUri(short: showShortLink))]) showShareSheet(items: [simplexChatLink(userAddress.connReqContact)])
} label: { } label: {
settingsRow("square.and.arrow.up", color: theme.colors.secondary) { settingsRow("square.and.arrow.up", color: theme.colors.secondary) {
Text("Share address") Text("Share address")
@ -295,28 +294,6 @@ struct UserAddressView: View {
} }
} }
struct ToggleShortLinkHeader: View {
@EnvironmentObject var theme: AppTheme
let text: Text
var link: CreatedConnLink
@Binding var short: Bool
var body: some View {
if link.connShortLink == nil {
text.foregroundColor(theme.colors.secondary)
} else {
HStack {
text.foregroundColor(theme.colors.secondary)
Spacer()
Text(short ? "Full link" : "Short link")
.textCase(.none)
.foregroundColor(theme.colors.primary)
.onTapGesture { short.toggle() }
}
}
}
}
private struct AutoAcceptState: Equatable { private struct AutoAcceptState: Equatable {
var enable = false var enable = false
var incognito = false var incognito = false
@ -565,7 +542,7 @@ private func saveAAS(_ aas: Binding<AutoAcceptState>, _ savedAAS: Binding<AutoAc
struct UserAddressView_Previews: PreviewProvider { struct UserAddressView_Previews: PreviewProvider {
static var previews: some View { static var previews: some View {
let chatModel = ChatModel() let chatModel = ChatModel()
chatModel.userAddress = UserContactLink(connLinkContact: CreatedConnLink(connFullLink: "https://simplex.chat/contact#/?v=1&smp=smp%3A%2F%2FPQUV2eL0t7OStZOoAsPEV2QYWt4-xilbakvGUGOItUo%3D%40smp6.simplex.im%2FK1rslx-m5bpXVIdMZg9NLUZ_8JBm8xTt%23MCowBQYDK2VuAyEALDeVe-sG8mRY22LsXlPgiwTNs9dbiLrNuA7f3ZMAJ2w%3D", connShortLink: nil)) chatModel.userAddress = UserContactLink(connReqContact: "https://simplex.chat/contact#/?v=1&smp=smp%3A%2F%2FPQUV2eL0t7OStZOoAsPEV2QYWt4-xilbakvGUGOItUo%3D%40smp6.simplex.im%2FK1rslx-m5bpXVIdMZg9NLUZ_8JBm8xTt%23MCowBQYDK2VuAyEALDeVe-sG8mRY22LsXlPgiwTNs9dbiLrNuA7f3ZMAJ2w%3D")
return Group { return Group {

View file

@ -133,6 +133,7 @@ struct UserProfile: View {
.alert(item: $alert) { a in userProfileAlert(a, $profile.displayName) } .alert(item: $alert) { a in userProfileAlert(a, $profile.displayName) }
} }
@ViewBuilder
private func overlayButton( private func overlayButton(
_ systemName: String, _ systemName: String,
edge: Edge.Set, edge: Edge.Set,

View file

@ -221,11 +221,11 @@ struct UserProfilesView: View {
!user.hidden ? nil : trimmedSearchTextOrPassword !user.hidden ? nil : trimmedSearchTextOrPassword
} }
private func profileActionView(_ action: UserProfileAction) -> some View { @ViewBuilder private func profileActionView(_ action: UserProfileAction) -> some View {
let passwordValid = actionPassword == actionPassword.trimmingCharacters(in: .whitespaces) let passwordValid = actionPassword == actionPassword.trimmingCharacters(in: .whitespaces)
let passwordField = PassphraseField(key: $actionPassword, placeholder: "Profile password", valid: passwordValid) let passwordField = PassphraseField(key: $actionPassword, placeholder: "Profile password", valid: passwordValid)
let actionEnabled: (User) -> Bool = { user in actionPassword != "" && passwordValid && correctPassword(user, actionPassword) } let actionEnabled: (User) -> Bool = { user in actionPassword != "" && passwordValid && correctPassword(user, actionPassword) }
return List { List {
switch action { switch action {
case let .deleteUser(user, delSMPQueues): case let .deleteUser(user, delSMPQueues):
actionHeader("Delete profile", user) actionHeader("Delete profile", user)

View file

@ -9,10 +9,6 @@
<string>applinks:simplex.chat</string> <string>applinks:simplex.chat</string>
<string>applinks:www.simplex.chat</string> <string>applinks:www.simplex.chat</string>
<string>applinks:simplex.chat?mode=developer</string> <string>applinks:simplex.chat?mode=developer</string>
<string>applinks:*.simplex.im</string>
<string>applinks:*.simplex.im?mode=developer</string>
<string>applinks:*.simplexonflux.com</string>
<string>applinks:*.simplexonflux.com?mode=developer</string>
</array> </array>
<key>com.apple.security.application-groups</key> <key>com.apple.security.application-groups</key>
<array> <array>

View file

@ -2,9 +2,25 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd"> <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 http://docs.oasis-open.org/xliff/v1.2/os/xliff-core-1.2-strict.xsd">
<file original="en.lproj/Localizable.strings" source-language="en" target-language="bg" datatype="plaintext"> <file original="en.lproj/Localizable.strings" source-language="en" target-language="bg" datatype="plaintext">
<header> <header>
<tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="16.2" build-num="16C5032a"/> <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="15.4" build-num="15F31d"/>
</header> </header>
<body> <body>
<trans-unit id="&#10;" xml:space="preserve">
<source>
</source>
<target>
</target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id=" " xml:space="preserve">
<source> </source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id=" (" xml:space="preserve">
<source> (</source>
<target> (</target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id=" (can be copied)" xml:space="preserve"> <trans-unit id=" (can be copied)" xml:space="preserve">
<source> (can be copied)</source> <source> (can be copied)</source>
<target> (може да се копира)</target> <target> (може да се копира)</target>
@ -307,6 +323,11 @@
<target>%u пропуснати съобщения.</target> <target>%u пропуснати съобщения.</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="(" xml:space="preserve">
<source>(</source>
<target>(</target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="(new)" xml:space="preserve"> <trans-unit id="(new)" xml:space="preserve">
<source>(new)</source> <source>(new)</source>
<target>(ново)</target> <target>(ново)</target>
@ -317,6 +338,11 @@
<target>(това устройство v%@)</target> <target>(това устройство v%@)</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id=")" xml:space="preserve">
<source>)</source>
<target>)</target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="**Create 1-time link**: to create and share a new invitation link." xml:space="preserve"> <trans-unit id="**Create 1-time link**: to create and share a new invitation link." xml:space="preserve">
<source>**Create 1-time link**: to create and share a new invitation link.</source> <source>**Create 1-time link**: to create and share a new invitation link.</source>
<target>**Добави контакт**: за създаване на нов линк.</target> <target>**Добави контакт**: за създаване на нов линк.</target>
@ -381,6 +407,11 @@
<target>\*удебелен*</target> <target>\*удебелен*</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id=", " xml:space="preserve">
<source>, </source>
<target>, </target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="- connect to [directory service](simplex:/contact#/?v=1-4&amp;smp=smp%3A%2F%2Fu2dS9sG8nMNURyZwqASV4yROM28Er0luVTx5X1CsMrU%3D%40smp4.simplex.im%2FeXSPwqTkKyDO3px4fLf1wx3MvPdjdLW3%23%2F%3Fv%3D1-2%26dh%3DMCowBQYDK2VuAyEAaiv6MkMH44L2TcYrt_CsX3ZvM11WgbMEUn0hkIKTOho%253D%26srv%3Do5vmywmrnaxalvz6wi3zicyftgio6psuvyniis6gco6bp6ekl4cqj4id.onion) (BETA)!&#10;- delivery receipts (up to 20 members).&#10;- faster and more stable." xml:space="preserve"> <trans-unit id="- connect to [directory service](simplex:/contact#/?v=1-4&amp;smp=smp%3A%2F%2Fu2dS9sG8nMNURyZwqASV4yROM28Er0luVTx5X1CsMrU%3D%40smp4.simplex.im%2FeXSPwqTkKyDO3px4fLf1wx3MvPdjdLW3%23%2F%3Fv%3D1-2%26dh%3DMCowBQYDK2VuAyEAaiv6MkMH44L2TcYrt_CsX3ZvM11WgbMEUn0hkIKTOho%253D%26srv%3Do5vmywmrnaxalvz6wi3zicyftgio6psuvyniis6gco6bp6ekl4cqj4id.onion) (BETA)!&#10;- delivery receipts (up to 20 members).&#10;- faster and more stable." xml:space="preserve">
<source>- connect to [directory service](simplex:/contact#/?v=1-4&amp;smp=smp%3A%2F%2Fu2dS9sG8nMNURyZwqASV4yROM28Er0luVTx5X1CsMrU%3D%40smp4.simplex.im%2FeXSPwqTkKyDO3px4fLf1wx3MvPdjdLW3%23%2F%3Fv%3D1-2%26dh%3DMCowBQYDK2VuAyEAaiv6MkMH44L2TcYrt_CsX3ZvM11WgbMEUn0hkIKTOho%253D%26srv%3Do5vmywmrnaxalvz6wi3zicyftgio6psuvyniis6gco6bp6ekl4cqj4id.onion) (BETA)! <source>- connect to [directory service](simplex:/contact#/?v=1-4&amp;smp=smp%3A%2F%2Fu2dS9sG8nMNURyZwqASV4yROM28Er0luVTx5X1CsMrU%3D%40smp4.simplex.im%2FeXSPwqTkKyDO3px4fLf1wx3MvPdjdLW3%23%2F%3Fv%3D1-2%26dh%3DMCowBQYDK2VuAyEAaiv6MkMH44L2TcYrt_CsX3ZvM11WgbMEUn0hkIKTOho%253D%26srv%3Do5vmywmrnaxalvz6wi3zicyftgio6psuvyniis6gco6bp6ekl4cqj4id.onion) (BETA)!
- delivery receipts (up to 20 members). - delivery receipts (up to 20 members).
@ -417,6 +448,11 @@
- история на редактиране.</target> - история на редактиране.</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="." xml:space="preserve">
<source>.</source>
<target>.</target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="0 sec" xml:space="preserve"> <trans-unit id="0 sec" xml:space="preserve">
<source>0 sec</source> <source>0 sec</source>
<target>0 сек</target> <target>0 сек</target>
@ -431,7 +467,7 @@
<source>1 day</source> <source>1 day</source>
<target>1 ден</target> <target>1 ден</target>
<note>delete after time <note>delete after time
time interval</note> time interval</note>
</trans-unit> </trans-unit>
<trans-unit id="1 hour" xml:space="preserve"> <trans-unit id="1 hour" xml:space="preserve">
<source>1 hour</source> <source>1 hour</source>
@ -447,13 +483,13 @@ time interval</note>
<source>1 month</source> <source>1 month</source>
<target>1 месец</target> <target>1 месец</target>
<note>delete after time <note>delete after time
time interval</note> time interval</note>
</trans-unit> </trans-unit>
<trans-unit id="1 week" xml:space="preserve"> <trans-unit id="1 week" xml:space="preserve">
<source>1 week</source> <source>1 week</source>
<target>1 седмица</target> <target>1 седмица</target>
<note>delete after time <note>delete after time
time interval</note> time interval</note>
</trans-unit> </trans-unit>
<trans-unit id="1 year" xml:space="preserve"> <trans-unit id="1 year" xml:space="preserve">
<source>1 year</source> <source>1 year</source>
@ -483,6 +519,11 @@ time interval</note>
<target>30 секунди</target> <target>30 секунди</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id=": " xml:space="preserve">
<source>: </source>
<target>: </target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="&lt;p&gt;Hi!&lt;/p&gt;&#10;&lt;p&gt;&lt;a href=&quot;%@&quot;&gt;Connect to me via SimpleX Chat&lt;/a&gt;&lt;/p&gt;" xml:space="preserve"> <trans-unit id="&lt;p&gt;Hi!&lt;/p&gt;&#10;&lt;p&gt;&lt;a href=&quot;%@&quot;&gt;Connect to me via SimpleX Chat&lt;/a&gt;&lt;/p&gt;" xml:space="preserve">
<source>&lt;p&gt;Hi!&lt;/p&gt; <source>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;&lt;a href="%@"&gt;Connect to me via SimpleX Chat&lt;/a&gt;&lt;/p&gt;</source> &lt;p&gt;&lt;a href="%@"&gt;Connect to me via SimpleX Chat&lt;/a&gt;&lt;/p&gt;</source>
@ -490,6 +531,14 @@ time interval</note>
&lt;p&gt;&lt;a href="%@"&gt;Свържете се с мен чрез SimpleX Chat&lt;/a&gt;&lt;/p&gt;</target> &lt;p&gt;&lt;a href="%@"&gt;Свържете се с мен чрез SimpleX Chat&lt;/a&gt;&lt;/p&gt;</target>
<note>email text</note> <note>email text</note>
</trans-unit> </trans-unit>
<trans-unit id="@%@" xml:space="preserve">
<source>@%@</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="@'%@'" xml:space="preserve">
<source>@'%@'</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="A few more things" xml:space="preserve"> <trans-unit id="A few more things" xml:space="preserve">
<source>A few more things</source> <source>A few more things</source>
<target>Още няколко неща</target> <target>Още няколко неща</target>
@ -551,8 +600,8 @@ time interval</note>
<source>Accept</source> <source>Accept</source>
<target>Приеми</target> <target>Приеми</target>
<note>accept contact request via notification <note>accept contact request via notification
accept incoming call via notification accept incoming call via notification
swipe action</note> swipe action</note>
</trans-unit> </trans-unit>
<trans-unit id="Accept conditions" xml:space="preserve"> <trans-unit id="Accept conditions" xml:space="preserve">
<source>Accept conditions</source> <source>Accept conditions</source>
@ -573,7 +622,7 @@ swipe action</note>
<source>Accept incognito</source> <source>Accept incognito</source>
<target>Приеми инкогнито</target> <target>Приеми инкогнито</target>
<note>accept contact request via notification <note>accept contact request via notification
swipe action</note> swipe action</note>
</trans-unit> </trans-unit>
<trans-unit id="Accepted conditions" xml:space="preserve"> <trans-unit id="Accepted conditions" xml:space="preserve">
<source>Accepted conditions</source> <source>Accepted conditions</source>
@ -731,8 +780,8 @@ swipe action</note>
<target>Всички чатове и съобщения ще бъдат изтрити - това не може да бъде отменено!</target> <target>Всички чатове и съобщения ще бъдат изтрити - това не може да бъде отменено!</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="All chats will be removed from the list %@, and the list deleted." xml:space="preserve"> <trans-unit id="All chats will be removed from the list (text), and the list deleted." xml:space="preserve">
<source>All chats will be removed from the list %@, and the list deleted.</source> <source>All chats will be removed from the list (text), and the list deleted.</source>
<note>alert message</note> <note>alert message</note>
</trans-unit> </trans-unit>
<trans-unit id="All data is erased when it is entered." xml:space="preserve"> <trans-unit id="All data is erased when it is entered." xml:space="preserve">
@ -778,10 +827,6 @@ swipe action</note>
<source>All reports will be archived for you.</source> <source>All reports will be archived for you.</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="All servers" xml:space="preserve">
<source>All servers</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="All your contacts will remain connected." xml:space="preserve"> <trans-unit id="All your contacts will remain connected." xml:space="preserve">
<source>All your contacts will remain connected.</source> <source>All your contacts will remain connected.</source>
<target>Всички ваши контакти ще останат свързани.</target> <target>Всички ваши контакти ще останат свързани.</target>
@ -1063,6 +1108,10 @@ swipe action</note>
<target>Архивиране на база данни</target> <target>Архивиране на база данни</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Ask" xml:space="preserve">
<source>Ask</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Attach" xml:space="preserve"> <trans-unit id="Attach" xml:space="preserve">
<source>Attach</source> <source>Attach</source>
<target>Прикачи</target> <target>Прикачи</target>
@ -1300,12 +1349,6 @@ swipe action</note>
<target>Чрез чат профил (по подразбиране) или [чрез връзка](https://simplex.chat/blog/20230204-simplex-chat-v4-5-user-chat-profiles.html#transport-isolation) (БЕТА).</target> <target>Чрез чат профил (по подразбиране) или [чрез връзка](https://simplex.chat/blog/20230204-simplex-chat-v4-5-user-chat-profiles.html#transport-isolation) (БЕТА).</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="By using SimpleX Chat you agree to:&#10;- send only legal content in public groups.&#10;- respect other users no spam." xml:space="preserve">
<source>By using SimpleX Chat you agree to:
- send only legal content in public groups.
- respect other users no spam.</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Call already ended!" xml:space="preserve"> <trans-unit id="Call already ended!" xml:space="preserve">
<source>Call already ended!</source> <source>Call already ended!</source>
<target>Разговорът вече приключи!</target> <target>Разговорът вече приключи!</target>
@ -1354,7 +1397,7 @@ swipe action</note>
<source>Cancel</source> <source>Cancel</source>
<target>Отказ</target> <target>Отказ</target>
<note>alert action <note>alert action
alert button</note> alert button</note>
</trans-unit> </trans-unit>
<trans-unit id="Cancel migration" xml:space="preserve"> <trans-unit id="Cancel migration" xml:space="preserve">
<source>Cancel migration</source> <source>Cancel migration</source>
@ -1443,7 +1486,7 @@ alert button</note>
<source>Change self-destruct passcode</source> <source>Change self-destruct passcode</source>
<target>Промени кода за достъп за самоунищожение</target> <target>Промени кода за достъп за самоунищожение</target>
<note>authentication reason <note>authentication reason
set passcode view</note> set passcode view</note>
</trans-unit> </trans-unit>
<trans-unit id="Chat" xml:space="preserve"> <trans-unit id="Chat" xml:space="preserve">
<source>Chat</source> <source>Chat</source>
@ -1660,6 +1703,14 @@ set passcode view</note>
<source>Conditions of use</source> <source>Conditions of use</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Conditions will be accepted for enabled operators after 30 days." xml:space="preserve">
<source>Conditions will be accepted for enabled operators after 30 days.</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Conditions will be accepted for operator(s): **%@**." xml:space="preserve">
<source>Conditions will be accepted for operator(s): **%@**.</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Conditions will be accepted for the operator(s): **%@**." xml:space="preserve"> <trans-unit id="Conditions will be accepted for the operator(s): **%@**." xml:space="preserve">
<source>Conditions will be accepted for the operator(s): **%@**.</source> <source>Conditions will be accepted for the operator(s): **%@**.</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
@ -1677,10 +1728,6 @@ set passcode view</note>
<target>Конфигурирай ICE сървъри</target> <target>Конфигурирай ICE сървъри</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Configure server operators" xml:space="preserve">
<source>Configure server operators</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Confirm" xml:space="preserve"> <trans-unit id="Confirm" xml:space="preserve">
<source>Confirm</source> <source>Confirm</source>
<target>Потвърди</target> <target>Потвърди</target>
@ -2246,7 +2293,7 @@ This is your own one-time link!</source>
<source>Delete</source> <source>Delete</source>
<target>Изтрий</target> <target>Изтрий</target>
<note>alert action <note>alert action
swipe action</note> swipe action</note>
</trans-unit> </trans-unit>
<trans-unit id="Delete %lld messages of members?" xml:space="preserve"> <trans-unit id="Delete %lld messages of members?" xml:space="preserve">
<source>Delete %lld messages of members?</source> <source>Delete %lld messages of members?</source>
@ -2713,7 +2760,7 @@ swipe action</note>
<source>Download</source> <source>Download</source>
<target>Изтегли</target> <target>Изтегли</target>
<note>alert button <note>alert button
chat item action</note> chat item action</note>
</trans-unit> </trans-unit>
<trans-unit id="Download errors" xml:space="preserve"> <trans-unit id="Download errors" xml:space="preserve">
<source>Download errors</source> <source>Download errors</source>
@ -2785,8 +2832,8 @@ chat item action</note>
<target>Активиране (запазване на промените)</target> <target>Активиране (запазване на промените)</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Enable Flux in Network &amp; servers settings for better metadata privacy." xml:space="preserve"> <trans-unit id="Enable Flux" xml:space="preserve">
<source>Enable Flux in Network &amp; servers settings for better metadata privacy.</source> <source>Enable Flux</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Enable SimpleX Lock" xml:space="preserve"> <trans-unit id="Enable SimpleX Lock" xml:space="preserve">
@ -3339,9 +3386,7 @@ chat item action</note>
<trans-unit id="Error: %@" xml:space="preserve"> <trans-unit id="Error: %@" xml:space="preserve">
<source>Error: %@</source> <source>Error: %@</source>
<target>Грешка: %@</target> <target>Грешка: %@</target>
<note>alert message <note>alert message</note>
file error text
snd error text</note>
</trans-unit> </trans-unit>
<trans-unit id="Error: URL is invalid" xml:space="preserve"> <trans-unit id="Error: URL is invalid" xml:space="preserve">
<source>Error: URL is invalid</source> <source>Error: URL is invalid</source>
@ -3450,9 +3495,9 @@ snd error text</note>
%@</source> %@</source>
<note>alert message</note> <note>alert message</note>
</trans-unit> </trans-unit>
<trans-unit id="File is blocked by server operator:&#10;%@." xml:space="preserve"> <trans-unit id="File is blocked by server operator:&#10;(info.reason.text)." xml:space="preserve">
<source>File is blocked by server operator: <source>File is blocked by server operator:
%@.</source> (info.reason.text).</source>
<note>file error text</note> <note>file error text</note>
</trans-unit> </trans-unit>
<trans-unit id="File not found - most likely file was deleted or cancelled." xml:space="preserve"> <trans-unit id="File not found - most likely file was deleted or cancelled." xml:space="preserve">
@ -5260,7 +5305,7 @@ Requires compatible VPN.</source>
<trans-unit id="Open" xml:space="preserve"> <trans-unit id="Open" xml:space="preserve">
<source>Open</source> <source>Open</source>
<target>Отвори</target> <target>Отвори</target>
<note>alert action</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Open Settings" xml:space="preserve"> <trans-unit id="Open Settings" xml:space="preserve">
<source>Open Settings</source> <source>Open Settings</source>
@ -5290,15 +5335,23 @@ Requires compatible VPN.</source>
<target>Отвори група</target> <target>Отвори група</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Open link?" xml:space="preserve"> <trans-unit id="Open link" xml:space="preserve">
<source>Open link?</source> <source>Open link</source>
<note>alert title</note> <note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Open links from chat list" xml:space="preserve">
<source>Open links from chat list</source>
<note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Open migration to another device" xml:space="preserve"> <trans-unit id="Open migration to another device" xml:space="preserve">
<source>Open migration to another device</source> <source>Open migration to another device</source>
<target>Отвори миграцията към друго устройство</target> <target>Отвори миграцията към друго устройство</target>
<note>authentication reason</note> <note>authentication reason</note>
</trans-unit> </trans-unit>
<trans-unit id="Open web link?" xml:space="preserve">
<source>Open web link?</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Opening app…" xml:space="preserve"> <trans-unit id="Opening app…" xml:space="preserve">
<source>Opening app…</source> <source>Opening app…</source>
<target>Приложението се отваря…</target> <target>Приложението се отваря…</target>
@ -5585,19 +5638,11 @@ Error: %@</source>
<source>Privacy for your customers.</source> <source>Privacy for your customers.</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Privacy policy and conditions of use." xml:space="preserve">
<source>Privacy policy and conditions of use.</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Privacy redefined" xml:space="preserve"> <trans-unit id="Privacy redefined" xml:space="preserve">
<source>Privacy redefined</source> <source>Privacy redefined</source>
<target>Поверителността преосмислена</target> <target>Поверителността преосмислена</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Private chats, groups and your contacts are not accessible to server operators." xml:space="preserve">
<source>Private chats, groups and your contacts are not accessible to server operators.</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Private filenames" xml:space="preserve"> <trans-unit id="Private filenames" xml:space="preserve">
<source>Private filenames</source> <source>Private filenames</source>
<target>Поверителни имена на файлове</target> <target>Поверителни имена на файлове</target>
@ -5938,7 +5983,7 @@ Enable in *Network &amp; servers* settings.</source>
<source>Reject</source> <source>Reject</source>
<target>Отхвърляне</target> <target>Отхвърляне</target>
<note>reject incoming call via notification <note>reject incoming call via notification
swipe action</note> swipe action</note>
</trans-unit> </trans-unit>
<trans-unit id="Reject (sender NOT notified)" xml:space="preserve"> <trans-unit id="Reject (sender NOT notified)" xml:space="preserve">
<source>Reject (sender NOT notified)</source> <source>Reject (sender NOT notified)</source>
@ -6061,8 +6106,8 @@ swipe action</note>
<source>Report violation: only group moderators will see it.</source> <source>Report violation: only group moderators will see it.</source>
<note>report reason</note> <note>report reason</note>
</trans-unit> </trans-unit>
<trans-unit id="Report: %@" xml:space="preserve"> <trans-unit id="Report: (text.isEmpty ? reason.text : text)" xml:space="preserve">
<source>Report: %@</source> <source>Report: (text.isEmpty ? reason.text : text)</source>
<note>report in notification</note> <note>report in notification</note>
</trans-unit> </trans-unit>
<trans-unit id="Reporting messages to moderators is prohibited." xml:space="preserve"> <trans-unit id="Reporting messages to moderators is prohibited." xml:space="preserve">
@ -6157,6 +6202,10 @@ swipe action</note>
<source>Review conditions</source> <source>Review conditions</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Review later" xml:space="preserve">
<source>Review later</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Revoke" xml:space="preserve"> <trans-unit id="Revoke" xml:space="preserve">
<source>Revoke</source> <source>Revoke</source>
<target>Отзови</target> <target>Отзови</target>
@ -6203,7 +6252,7 @@ swipe action</note>
<source>Save</source> <source>Save</source>
<target>Запази</target> <target>Запази</target>
<note>alert button <note>alert button
chat item action</note> chat item action</note>
</trans-unit> </trans-unit>
<trans-unit id="Save (and notify contacts)" xml:space="preserve"> <trans-unit id="Save (and notify contacts)" xml:space="preserve">
<source>Save (and notify contacts)</source> <source>Save (and notify contacts)</source>
@ -6736,7 +6785,7 @@ chat item action</note>
<source>Share</source> <source>Share</source>
<target>Сподели</target> <target>Сподели</target>
<note>alert action <note>alert action
chat item action</note> chat item action</note>
</trans-unit> </trans-unit>
<trans-unit id="Share 1-time link" xml:space="preserve"> <trans-unit id="Share 1-time link" xml:space="preserve">
<source>Share 1-time link</source> <source>Share 1-time link</source>
@ -6792,10 +6841,6 @@ chat item action</note>
<target>Сподели с контактите</target> <target>Сподели с контактите</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Short link" xml:space="preserve">
<source>Short link</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Show QR code" xml:space="preserve"> <trans-unit id="Show QR code" xml:space="preserve">
<source>Show QR code</source> <source>Show QR code</source>
<target>Покажи QR код</target> <target>Покажи QR код</target>
@ -6889,10 +6934,6 @@ chat item action</note>
<source>SimpleX address or 1-time link?</source> <source>SimpleX address or 1-time link?</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="SimpleX channel link" xml:space="preserve">
<source>SimpleX channel link</source>
<note>simplex link type</note>
</trans-unit>
<trans-unit id="SimpleX contact address" xml:space="preserve"> <trans-unit id="SimpleX contact address" xml:space="preserve">
<source>SimpleX contact address</source> <source>SimpleX contact address</source>
<target>SimpleX адрес за контакт</target> <target>SimpleX адрес за контакт</target>
@ -6990,7 +7031,7 @@ chat item action</note>
<trans-unit id="Spam" xml:space="preserve"> <trans-unit id="Spam" xml:space="preserve">
<source>Spam</source> <source>Spam</source>
<note>blocking reason <note>blocking reason
report reason</note> report reason</note>
</trans-unit> </trans-unit>
<trans-unit id="Square, circle, or anything in between." xml:space="preserve"> <trans-unit id="Square, circle, or anything in between." xml:space="preserve">
<source>Square, circle, or anything in between.</source> <source>Square, circle, or anything in between.</source>
@ -7329,10 +7370,19 @@ It can happen because of some bug or when the connection is compromised.</source
<target>Старата база данни не бе премахната по време на миграцията, тя може да бъде изтрита.</target> <target>Старата база данни не бе премахната по време на миграцията, тя може да бъде изтрита.</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="The profile is only shared with your contacts." xml:space="preserve">
<source>The profile is only shared with your contacts.</source>
<target>Профилът се споделя само с вашите контакти.</target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="The same conditions will apply to operator **%@**." xml:space="preserve"> <trans-unit id="The same conditions will apply to operator **%@**." xml:space="preserve">
<source>The same conditions will apply to operator **%@**.</source> <source>The same conditions will apply to operator **%@**.</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="The same conditions will apply to operator(s): **%@**." xml:space="preserve">
<source>The same conditions will apply to operator(s): **%@**.</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="The second preset operator in the app!" xml:space="preserve"> <trans-unit id="The second preset operator in the app!" xml:space="preserve">
<source>The second preset operator in the app!</source> <source>The second preset operator in the app!</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
@ -7442,10 +7492,6 @@ It can happen because of some bug or when the connection is compromised.</source
<target>Това е вашят еднократен линк за връзка!</target> <target>Това е вашят еднократен линк за връзка!</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="This link requires a newer app version. Please upgrade the app or ask your contact to send a compatible link." xml:space="preserve">
<source>This link requires a newer app version. Please upgrade the app or ask your contact to send a compatible link.</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="This link was used with another mobile device, please create a new link on the desktop." xml:space="preserve"> <trans-unit id="This link was used with another mobile device, please create a new link on the desktop." xml:space="preserve">
<source>This link was used with another mobile device, please create a new link on the desktop.</source> <source>This link was used with another mobile device, please create a new link on the desktop.</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
@ -7728,10 +7774,6 @@ To connect, please ask your contact to create another connection link and check
<target>Непрочетено</target> <target>Непрочетено</target>
<note>swipe action</note> <note>swipe action</note>
</trans-unit> </trans-unit>
<trans-unit id="Unsupported connection link" xml:space="preserve">
<source>Unsupported connection link</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Up to 100 last messages are sent to new members." xml:space="preserve"> <trans-unit id="Up to 100 last messages are sent to new members." xml:space="preserve">
<source>Up to 100 last messages are sent to new members.</source> <source>Up to 100 last messages are sent to new members.</source>
<target>На новите членове се изпращат до последните 100 съобщения.</target> <target>На новите членове се изпращат до последните 100 съобщения.</target>
@ -7819,10 +7861,6 @@ To connect, please ask your contact to create another connection link and check
<source>Use TCP port %@ when no port is specified.</source> <source>Use TCP port %@ when no port is specified.</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Use TCP port 443 for preset servers only." xml:space="preserve">
<source>Use TCP port 443 for preset servers only.</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Use chat" xml:space="preserve"> <trans-unit id="Use chat" xml:space="preserve">
<source>Use chat</source> <source>Use chat</source>
<target>Използвай чата</target> <target>Използвай чата</target>
@ -7883,10 +7921,6 @@ To connect, please ask your contact to create another connection link and check
<source>Use servers</source> <source>Use servers</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Use short links (BETA)" xml:space="preserve">
<source>Use short links (BETA)</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Use the app while in the call." xml:space="preserve"> <trans-unit id="Use the app while in the call." xml:space="preserve">
<source>Use the app while in the call.</source> <source>Use the app while in the call.</source>
<target>Използвайте приложението по време на разговора.</target> <target>Използвайте приложението по време на разговора.</target>
@ -8168,6 +8202,10 @@ To connect, please ask your contact to create another connection link and check
<source>XFTP server</source> <source>XFTP server</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Yes" xml:space="preserve">
<source>Yes</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="You **must not** use the same database on two devices." xml:space="preserve"> <trans-unit id="You **must not** use the same database on two devices." xml:space="preserve">
<source>You **must not** use the same database on two devices.</source> <source>You **must not** use the same database on two devices.</source>
<target>**Не трябва** да използвате една и съща база данни на две устройства.</target> <target>**Не трябва** да използвате една и съща база данни на две устройства.</target>
@ -8257,6 +8295,10 @@ Repeat join request?</source>
<source>You can change it in Appearance settings.</source> <source>You can change it in Appearance settings.</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="You can configure operators in Network &amp; servers settings." xml:space="preserve">
<source>You can configure operators in Network &amp; servers settings.</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="You can configure servers via settings." xml:space="preserve"> <trans-unit id="You can configure servers via settings." xml:space="preserve">
<source>You can configure servers via settings.</source> <source>You can configure servers via settings.</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
@ -8490,6 +8532,11 @@ Repeat connection request?</source>
<target>Вашите ICE сървъри</target> <target>Вашите ICE сървъри</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Your SMP servers" xml:space="preserve">
<source>Your SMP servers</source>
<target>Вашите SMP сървъри</target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Your SimpleX address" xml:space="preserve"> <trans-unit id="Your SimpleX address" xml:space="preserve">
<source>Your SimpleX address</source> <source>Your SimpleX address</source>
<target>Вашият адрес в SimpleX</target> <target>Вашият адрес в SimpleX</target>
@ -8572,11 +8619,6 @@ Repeat connection request?</source>
<target>Вашият профил **%@** ще бъде споделен.</target> <target>Вашият профил **%@** ще бъде споделен.</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Your profile is stored on your device and only shared with your contacts." xml:space="preserve">
<source>Your profile is stored on your device and only shared with your contacts.</source>
<target>Профилът се споделя само с вашите контакти.</target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Your profile is stored on your device and shared only with your contacts. SimpleX servers cannot see your profile." xml:space="preserve"> <trans-unit id="Your profile is stored on your device and shared only with your contacts. SimpleX servers cannot see your profile." xml:space="preserve">
<source>Your profile is stored on your device and shared only with your contacts. SimpleX servers cannot see your profile.</source> <source>Your profile is stored on your device and shared only with your contacts. SimpleX servers cannot see your profile.</source>
<target>Вашият профил се съхранява на вашето устройство и се споделя само с вашите контакти. SimpleX сървърите не могат да видят вашия профил.</target> <target>Вашият профил се съхранява на вашето устройство и се споделя само с вашите контакти. SimpleX сървърите не могат да видят вашия профил.</target>
@ -8586,6 +8628,11 @@ Repeat connection request?</source>
<source>Your profile was changed. If you save it, the updated profile will be sent to all your contacts.</source> <source>Your profile was changed. If you save it, the updated profile will be sent to all your contacts.</source>
<note>alert message</note> <note>alert message</note>
</trans-unit> </trans-unit>
<trans-unit id="Your profile, contacts and delivered messages are stored on your device." xml:space="preserve">
<source>Your profile, contacts and delivered messages are stored on your device.</source>
<target>Вашият профил, контакти и доставени съобщения се съхраняват на вашето устройство.</target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="Your random profile" xml:space="preserve"> <trans-unit id="Your random profile" xml:space="preserve">
<source>Your random profile</source> <source>Your random profile</source>
<target>Вашият автоматично генериран профил</target> <target>Вашият автоматично генериран профил</target>
@ -8720,8 +8767,7 @@ Repeat connection request?</source>
<trans-unit id="blocked by admin" xml:space="preserve"> <trans-unit id="blocked by admin" xml:space="preserve">
<source>blocked by admin</source> <source>blocked by admin</source>
<target>блокиран от админ</target> <target>блокиран от админ</target>
<note>blocked chat item <note>marked deleted chat item preview text</note>
marked deleted chat item preview text</note>
</trans-unit> </trans-unit>
<trans-unit id="bold" xml:space="preserve"> <trans-unit id="bold" xml:space="preserve">
<source>bold</source> <source>bold</source>
@ -8890,7 +8936,7 @@ marked deleted chat item preview text</note>
<source>default (%@)</source> <source>default (%@)</source>
<target>по подразбиране (%@)</target> <target>по подразбиране (%@)</target>
<note>delete after time <note>delete after time
pref value</note> pref value</note>
</trans-unit> </trans-unit>
<trans-unit id="default (no)" xml:space="preserve"> <trans-unit id="default (no)" xml:space="preserve">
<source>default (no)</source> <source>default (no)</source>
@ -9016,10 +9062,19 @@ pref value</note>
<target>грешка</target> <target>грешка</target>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="event happened" xml:space="preserve">
<source>event happened</source>
<target>събитие се случи</target>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="expired" xml:space="preserve"> <trans-unit id="expired" xml:space="preserve">
<source>expired</source> <source>expired</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="for better metadata privacy." xml:space="preserve">
<source>for better metadata privacy.</source>
<note>No comment provided by engineer.</note>
</trans-unit>
<trans-unit id="forwarded" xml:space="preserve"> <trans-unit id="forwarded" xml:space="preserve">
<source>forwarded</source> <source>forwarded</source>
<target>препратено</target> <target>препратено</target>
@ -9225,8 +9280,8 @@ pref value</note>
<source>off</source> <source>off</source>
<target>изключено</target> <target>изключено</target>
<note>enabled status <note>enabled status
group pref value group pref value
time to disappear</note> time to disappear</note>
</trans-unit> </trans-unit>
<trans-unit id="offered %@" xml:space="preserve"> <trans-unit id="offered %@" xml:space="preserve">
<source>offered %@</source> <source>offered %@</source>
@ -9582,7 +9637,7 @@ last received msg: %2$@</source>
</file> </file>
<file original="en.lproj/SimpleX--iOS--InfoPlist.strings" source-language="en" target-language="bg" datatype="plaintext"> <file original="en.lproj/SimpleX--iOS--InfoPlist.strings" source-language="en" target-language="bg" datatype="plaintext">
<header> <header>
<tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="16.2" build-num="16C5032a"/> <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="15.4" build-num="15F31d"/>
</header> </header>
<body> <body>
<trans-unit id="CFBundleName" xml:space="preserve"> <trans-unit id="CFBundleName" xml:space="preserve">
@ -9619,7 +9674,7 @@ last received msg: %2$@</source>
</file> </file>
<file original="SimpleX NSE/en.lproj/InfoPlist.strings" source-language="en" target-language="bg" datatype="plaintext"> <file original="SimpleX NSE/en.lproj/InfoPlist.strings" source-language="en" target-language="bg" datatype="plaintext">
<header> <header>
<tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="16.2" build-num="16C5032a"/> <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="15.4" build-num="15F31d"/>
</header> </header>
<body> <body>
<trans-unit id="CFBundleDisplayName" xml:space="preserve"> <trans-unit id="CFBundleDisplayName" xml:space="preserve">
@ -9641,17 +9696,13 @@ last received msg: %2$@</source>
</file> </file>
<file original="SimpleX NSE/en.lproj/Localizable.strings" source-language="en" target-language="bg" datatype="plaintext"> <file original="SimpleX NSE/en.lproj/Localizable.strings" source-language="en" target-language="bg" datatype="plaintext">
<header> <header>
<tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="16.2" build-num="16C5032a"/> <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="15.4" build-num="15F31d"/>
</header> </header>
<body> <body>
<trans-unit id="%d new events" xml:space="preserve"> <trans-unit id="%d new events" xml:space="preserve">
<source>%d new events</source> <source>%d new events</source>
<note>notification body</note> <note>notification body</note>
</trans-unit> </trans-unit>
<trans-unit id="From %d chat(s)" xml:space="preserve">
<source>From %d chat(s)</source>
<note>notification body</note>
</trans-unit>
<trans-unit id="From: %@" xml:space="preserve"> <trans-unit id="From: %@" xml:space="preserve">
<source>From: %@</source> <source>From: %@</source>
<note>notification body</note> <note>notification body</note>
@ -9664,11 +9715,15 @@ last received msg: %2$@</source>
<source>New messages</source> <source>New messages</source>
<note>notification</note> <note>notification</note>
</trans-unit> </trans-unit>
<trans-unit id="New messages in %d chats" xml:space="preserve">
<source>New messages in %d chats</source>
<note>notification body</note>
</trans-unit>
</body> </body>
</file> </file>
<file original="SimpleX SE/en.lproj/InfoPlist.strings" source-language="en" target-language="bg" datatype="plaintext"> <file original="SimpleX SE/en.lproj/InfoPlist.strings" source-language="en" target-language="bg" datatype="plaintext">
<header> <header>
<tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="16.2" build-num="16C5032a"/> <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="15.4" build-num="15F31d"/>
</header> </header>
<body> <body>
<trans-unit id="CFBundleDisplayName" xml:space="preserve"> <trans-unit id="CFBundleDisplayName" xml:space="preserve">
@ -9687,7 +9742,7 @@ last received msg: %2$@</source>
</file> </file>
<file original="SimpleX SE/en.lproj/Localizable.strings" source-language="en" target-language="bg" datatype="plaintext"> <file original="SimpleX SE/en.lproj/Localizable.strings" source-language="en" target-language="bg" datatype="plaintext">
<header> <header>
<tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="16.2" build-num="16C5032a"/> <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="15.4" build-num="15F31d"/>
</header> </header>
<body> <body>
<trans-unit id="%@" xml:space="preserve"> <trans-unit id="%@" xml:space="preserve">

View file

@ -3,10 +3,10 @@
"project" : "SimpleX.xcodeproj", "project" : "SimpleX.xcodeproj",
"targetLocale" : "bg", "targetLocale" : "bg",
"toolInfo" : { "toolInfo" : {
"toolBuildNumber" : "16C5032a", "toolBuildNumber" : "15F31d",
"toolID" : "com.apple.dt.xcode", "toolID" : "com.apple.dt.xcode",
"toolName" : "Xcode", "toolName" : "Xcode",
"toolVersion" : "16.2" "toolVersion" : "15.4"
}, },
"version" : "1.0" "version" : "1.0"
} }

View file

@ -3422,8 +3422,8 @@ It can happen because of some bug or when the connection is compromised.</source
<source>The old database was not removed during the migration, it can be deleted.</source> <source>The old database was not removed during the migration, it can be deleted.</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="Your profile is stored on your device and only shared with your contacts." xml:space="preserve"> <trans-unit id="The profile is only shared with your contacts." xml:space="preserve">
<source>Your profile is stored on your device and only shared with your contacts.</source> <source>The profile is only shared with your contacts.</source>
<note>No comment provided by engineer.</note> <note>No comment provided by engineer.</note>
</trans-unit> </trans-unit>
<trans-unit id="The sender will NOT be notified" xml:space="preserve"> <trans-unit id="The sender will NOT be notified" xml:space="preserve">

Some files were not shown because too many files have changed in this diff Show more