readest/packages/swift-rs/src-rs
Huang Xin 145e3318d6
feat(reader): Page Flip page-turn style on Android, iOS and desktop (#7160)
* feat(reader): add Page Flip page-turn style on Android, iOS and desktop

Page Flip lifts the whole sheet over the spine instead of curling a
corner. It is a separate Animation Style next to Page Curl, offered in
the apps only; a spread and the web turn it as a Page Curl.

The sheet follows a physical profile model ported from page-turn-core
(MIT, notice kept in each port): PageFlipModel.kt, PageFlipModel.swift
and pageFlipModel.ts are line-for-line ports and share the same tests.
Android draws it in NativePaperView (GLES 3), iOS in NativePaperView
(Metal), and desktop in the captured-turn WebGL renderer, which asks
for WebGL 2 only for surfaces built for Page Flip. A released flip
settles on its own physics instead of a fixed easing.

On macOS a backward turn showed the previous page for a few frames
while it was captured. macOS now covers the webview with a snapshot
during that capture, as Android and iOS already do, which also fixes
the same flash for Page Curl on macOS.

Verified:
- pnpm test (1199 files pass), pnpm lint, pnpm fmt:check,
  pnpm clippy:check, pnpm test:rust, browser tests for the renderer.
- Tests that fail without the change:
  - page-flip-model.test.ts: without the unturn phase a tap's return
    jumps, "expected 0.13785… to be less than 0.12".
  - captured-turn.browser.test.ts "settles a chosen Page Flip on its
    own physics in both directions": without the settle it fails with
    "expected 0 to be greater than 4".
  - ControlPanelUpdateReset.test.tsx "offers Page Flip in the apps" and
    "shows a synced Page Flip as Page Curl on the web".
- Android: taps and drags in both directions on a phone, with an
  earlier build of this change.
- macOS: forward flip recorded at about 60 fps.

Not run:
- The macOS backward cover in the app (a system permission prompt
  blocked the run).
- Android after moving the flip choice to the turn host (rebuild
  pending).
- iOS on a simulator or device; the Metal shaders were compiled at
  runtime with makeLibrary(source:) only.
- Windows and Linux have no native cover, so a backward turn there
  still shows the previous page briefly, for both styles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(ios): build Swift plugins with SwiftPM's native build system

Swift 6.4 (Xcode 27.1) builds packages with Swift Build by default. It
writes the static libraries to `Products/<Config>-<sdk>` instead of the
triple directory swift-rs links from, and prelinks each module so the
@_cdecl entry points (init_plugin_*, register_plugin, run_plugin_command)
are local symbols Rust cannot link.

An incremental iOS build therefore linked whatever plugin libraries an
older build had left in the triple directory: the app built and
installed, but ran old plugin Swift ("No command paper_curl found for
plugin native-bridge", so no native page turn worked). A clean build
failed with "could not find native static library `Tauri`", then with
undefined `_init_plugin_*` symbols once pointed at the new directory.
Passing `--build-system native` restores the layout and the exported
symbols.

Verified:
- With the plugin build caches cleared, `pnpm dev-ios` fails without
  the change ("could not find native static library `Tauri`") and
  builds and installs with it.
- On an iPhone XS Max (iOS 18.7) the new build turns a page with the
  native turn and logs no error, where the old build failed every turn.
- rustfmt --check on the changed file.

Not run: the simulator build, and a build with an older Xcode (not
checked which older SwiftPM versions accept `--build-system native`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 12:57:43 +01:00
..
types feat(reader): slide and page curl turn animations (#555) (#4940) 2026-07-05 20:49:57 +02:00
autorelease.rs feat(reader): slide and page curl turn animations (#555) (#4940) 2026-07-05 20:49:57 +02:00
build.rs feat(reader): Page Flip page-turn style on Android, iOS and desktop (#7160) 2026-10-30 12:57:43 +01:00
dark_magic.rs feat(reader): slide and page curl turn animations (#555) (#4940) 2026-07-05 20:49:57 +02:00
lib.rs feat(reader): slide and page curl turn animations (#555) (#4940) 2026-07-05 20:49:57 +02:00
swift.rs feat(reader): slide and page curl turn animations (#555) (#4940) 2026-07-05 20:49:57 +02:00
swift_arg.rs feat(reader): slide and page curl turn animations (#555) (#4940) 2026-07-05 20:49:57 +02:00
swift_ret.rs feat(reader): slide and page curl turn animations (#555) (#4940) 2026-07-05 20:49:57 +02:00
test-build.rs feat(reader): slide and page curl turn animations (#555) (#4940) 2026-07-05 20:49:57 +02:00