@akylas/nativescript 9.0.25 → 9.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abortcontroller/abortsignal.js.map +1 -1
- package/abortcontroller/index.js.map +1 -1
- package/accessibility/accessibility-common.js.map +1 -1
- package/accessibility/accessibility-css-helper.js.map +1 -1
- package/accessibility/accessibility-properties.js.map +1 -1
- package/accessibility/accessibility-service-common.js.map +1 -1
- package/accessibility/accessibility-service.android.js.map +1 -1
- package/accessibility/accessibility-service.ios.js.map +1 -1
- package/accessibility/accessibility-types.js.map +1 -1
- package/accessibility/font-scale-common.js.map +1 -1
- package/accessibility/font-scale.android.js.map +1 -1
- package/accessibility/font-scale.ios.js.map +1 -1
- package/accessibility/index.android.js.map +1 -1
- package/accessibility/index.ios.js.map +1 -1
- package/animation-frame/animation-native.android.js.map +1 -1
- package/animation-frame/animation-native.ios.js.map +1 -1
- package/animation-frame/index.js.map +1 -1
- package/application/application-common.d.ts +205 -3
- package/application/application-common.js +438 -55
- package/application/application-common.js.map +1 -1
- package/application/application-interfaces.d.ts +67 -1
- package/application/application-interfaces.js.map +1 -1
- package/application/application-shims.js.map +1 -1
- package/application/application.android.d.ts +39 -0
- package/application/application.android.js +239 -18
- package/application/application.android.js.map +1 -1
- package/application/application.d.ts +161 -54
- package/application/application.ios.d.ts +189 -28
- package/application/application.ios.js +892 -390
- package/application/application.ios.js.map +1 -1
- package/application/helpers-common.d.ts +7 -0
- package/application/helpers-common.js +46 -1
- package/application/helpers-common.js.map +1 -1
- package/application/helpers.android.js.map +1 -1
- package/application/helpers.ios.js.map +1 -1
- package/application/index.android.js.map +1 -1
- package/application/index.ios.js.map +1 -1
- package/application/scene-delegate-bridge.d.ts +60 -0
- package/application/scene-delegate-bridge.js +138 -0
- package/application/scene-delegate-bridge.js.map +1 -0
- package/application-settings/application-settings-common.js.map +1 -1
- package/application-settings/index.android.js.map +1 -1
- package/application-settings/index.ios.js.map +1 -1
- package/bundle-entry-points.js.map +1 -1
- package/cli-hooks/before-checkForChanges.mjs +0 -11
- package/color/color-common.js +16 -5
- package/color/color-common.js.map +1 -1
- package/color/color-types.js.map +1 -1
- package/color/color-utils.d.ts +4 -1
- package/color/color-utils.js +14 -9
- package/color/color-utils.js.map +1 -1
- package/color/index.android.js.map +1 -1
- package/color/index.ios.js.map +1 -1
- package/color/known-colors.js.map +1 -1
- package/config/config.interface.d.ts +45 -3
- package/config/config.interface.js.map +1 -1
- package/config/index.js.map +1 -1
- package/connectivity/index.android.js.map +1 -1
- package/connectivity/index.ios.js.map +1 -1
- package/console/index.js.map +1 -1
- package/core-types/animation-types.js.map +1 -1
- package/core-types/index.d.ts +25 -2
- package/core-types/index.js +23 -0
- package/core-types/index.js.map +1 -1
- package/core-types/validators.js.map +1 -1
- package/css/CSS3Parser.js +3 -2
- package/css/CSS3Parser.js.map +1 -1
- package/css/CSSNativeScript.js.map +1 -1
- package/css/css-tree-parser.js +5 -1
- package/css/css-tree-parser.js.map +1 -1
- package/css/lib/parse/index.js +5 -1
- package/css/lib/parse/index.js.map +1 -1
- package/css/parser.js +20 -3
- package/css/parser.js.map +1 -1
- package/css/reworkcss.js.map +1 -1
- package/css/system-classes.d.ts +9 -0
- package/css/system-classes.js +23 -0
- package/css/system-classes.js.map +1 -1
- package/css-mediaquery/index.d.ts +6 -1
- package/css-mediaquery/index.js +35 -6
- package/css-mediaquery/index.js.map +1 -1
- package/css-value/reworkcss-value.js.map +1 -1
- package/data/observable/index.d.ts +23 -0
- package/data/observable/index.js +50 -9
- package/data/observable/index.js.map +1 -1
- package/data/observable-array/index.js.map +1 -1
- package/data/virtual-array/index.js.map +1 -1
- package/debugger/InspectorBackendCommands.js.map +1 -1
- package/debugger/devtools-elements-interfaces.js.map +1 -1
- package/debugger/devtools-elements.common.js.map +1 -1
- package/debugger/devtools-elements.js.map +1 -1
- package/debugger/dom-types.js +31 -1
- package/debugger/dom-types.js.map +1 -1
- package/debugger/index.js.map +1 -1
- package/debugger/webinspector-css.js.map +1 -1
- package/debugger/webinspector-dom.js.map +1 -1
- package/debugger/webinspector-network.android.js.map +1 -1
- package/debugger/webinspector-network.d.ts +29 -0
- package/debugger/webinspector-network.ios.js.map +1 -1
- package/fetch/index.d.ts +79 -0
- package/fetch/index.js +408 -0
- package/fetch/index.js.map +1 -0
- package/file-system/file-system-access.android.d.ts +1 -0
- package/file-system/file-system-access.android.js +18 -21
- package/file-system/file-system-access.android.js.map +1 -1
- package/file-system/file-system-access.ios.js +21 -13
- package/file-system/file-system-access.ios.js.map +1 -1
- package/file-system/index.d.ts +3 -3
- package/file-system/index.js.map +1 -1
- package/fps-meter/fps-native.android.js.map +1 -1
- package/fps-meter/fps-native.ios.js.map +1 -1
- package/fps-meter/index.js.map +1 -1
- package/global-types.d.ts +40 -34
- package/globals/global-utils.d.ts +6 -1
- package/globals/global-utils.js +10 -5
- package/globals/global-utils.js.map +1 -1
- package/globals/index.js +22 -9
- package/globals/index.js.map +1 -1
- package/globals/polyfills/polyfill-xhr.js.map +1 -1
- package/globals/polyfills/utils.js +2 -0
- package/globals/polyfills/utils.js.map +1 -1
- package/http/http-interfaces.js.map +1 -1
- package/http/http-request/http-request-common.js.map +1 -1
- package/http/http-request/index.android.js +5 -1
- package/http/http-request/index.android.js.map +1 -1
- package/http/http-request/index.ios.js.map +1 -1
- package/http/http-request-internal/http-request-internal-common.d.ts +6 -1
- package/http/http-request-internal/http-request-internal-common.js +19 -0
- package/http/http-request-internal/http-request-internal-common.js.map +1 -1
- package/http/http-request-internal/index.android.d.ts +7 -1
- package/http/http-request-internal/index.android.js +8 -6
- package/http/http-request-internal/index.android.js.map +1 -1
- package/http/http-request-internal/index.ios.d.ts +7 -1
- package/http/http-request-internal/index.ios.js +34 -17
- package/http/http-request-internal/index.ios.js.map +1 -1
- package/http/index.js.map +1 -1
- package/image-asset/image-asset-common.js.map +1 -1
- package/image-asset/index.android.js.map +1 -1
- package/image-asset/index.ios.js.map +1 -1
- package/image-source/image-source-common.js.map +1 -1
- package/image-source/index.android.js.map +1 -1
- package/image-source/index.ios.js +7 -6
- package/image-source/index.ios.js.map +1 -1
- package/index.d.ts +3 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/inspector_modules.js +1 -1
- package/inspector_modules.js.map +1 -1
- package/js-libs/easysax/easysax.d.ts +49 -7
- package/js-libs/easysax/easysax.js +631 -747
- package/js-libs/easysax/easysax.js.map +1 -0
- package/matrix/index.js.map +1 -1
- package/media-query-list/index.js +57 -15
- package/media-query-list/index.js.map +1 -1
- package/module-name-resolver/helpers.d.ts +1 -1
- package/module-name-resolver/helpers.js.map +1 -1
- package/module-name-resolver/index.d.ts +2 -2
- package/module-name-resolver/index.js.map +1 -1
- package/module-name-resolver/non-bundle-workflow-compat.js.map +1 -1
- package/module-name-resolver/qualifier-matcher/index.js.map +1 -1
- package/native-window/index.d.ts +426 -0
- package/native-window/index.js +4 -0
- package/native-window/index.js.map +1 -0
- package/native-window/native-window-common.d.ts +153 -0
- package/native-window/native-window-common.js +340 -0
- package/native-window/native-window-common.js.map +1 -0
- package/native-window/native-window-interfaces.d.ts +186 -0
- package/native-window/native-window-interfaces.js +90 -0
- package/native-window/native-window-interfaces.js.map +1 -0
- package/native-window/native-window.android.d.ts +59 -0
- package/native-window/native-window.android.js +175 -0
- package/native-window/native-window.android.js.map +1 -0
- package/native-window/native-window.ios.d.ts +61 -0
- package/native-window/native-window.ios.js +218 -0
- package/native-window/native-window.ios.js.map +1 -0
- package/native-window/window-base.d.ts +111 -0
- package/native-window/window-base.js +91 -0
- package/native-window/window-base.js.map +1 -0
- package/package.json +3 -3
- package/platform/common.js.map +1 -1
- package/platform/device/index.android.js.map +1 -1
- package/platform/device/index.ios.js.map +1 -1
- package/platform/index.js.map +1 -1
- package/platform/screen/index.android.js.map +1 -1
- package/platform/screen/index.ios.d.ts +1 -0
- package/platform/screen/index.ios.js +6 -2
- package/platform/screen/index.ios.js.map +1 -1
- package/platforms/android/java/org/nativescript/widgets/BorderDrawable.java +5 -6
- package/platforms/android/java/org/nativescript/widgets/BoxShadowDrawable.java +0 -6
- package/platforms/android/java/org/nativescript/widgets/CommonLayoutParams.java +56 -0
- package/platforms/android/java/org/nativescript/widgets/ContentLayout.java +20 -4
- package/platforms/android/java/org/nativescript/widgets/CustomTransition.java +26 -9
- package/platforms/android/java/org/nativescript/widgets/FlexLine.java +3 -3
- package/platforms/android/java/org/nativescript/widgets/FlexboxLayout.java +194 -731
- package/platforms/android/java/org/nativescript/widgets/ImageView.java +2 -2
- package/platforms/android/java/org/nativescript/widgets/Utils.java +37 -9
- package/platforms/android/java/org/nativescript/widgets/ViewHelper.java +78 -0
- package/platforms/android/java/org/nativescript/widgets/image/BitmapOwner.java +1 -4
- package/platforms/android/java/org/nativescript/widgets/image/Worker.java +99 -76
- package/platforms/android/native-api-usage.json +11 -0
- package/platforms/ios/src/NativeScriptMainWindow.swift +72 -39
- package/profiling/index.js.map +1 -1
- package/references.d.ts +5 -2
- package/text/formatted-string.js.map +1 -1
- package/text/index.android.js.map +1 -1
- package/text/index.ios.js.map +1 -1
- package/text/span.js.map +1 -1
- package/text/text-common.js +1 -1
- package/text/text-common.js.map +1 -1
- package/timer/index.android.js +2 -1
- package/timer/index.android.js.map +1 -1
- package/timer/index.ios.js.map +1 -1
- package/trace/index.d.ts +2 -2
- package/trace/index.js.map +1 -1
- package/ui/action-bar/action-bar-common.js.map +1 -1
- package/ui/action-bar/index.android.js +7 -11
- package/ui/action-bar/index.android.js.map +1 -1
- package/ui/action-bar/index.d.ts +13 -1
- package/ui/action-bar/index.ios.js +26 -0
- package/ui/action-bar/index.ios.js.map +1 -1
- package/ui/activity-indicator/activity-indicator-common.js.map +1 -1
- package/ui/activity-indicator/index.android.js.map +1 -1
- package/ui/activity-indicator/index.ios.js.map +1 -1
- package/ui/animation/animation-common.js.map +1 -1
- package/ui/animation/animation-interfaces.js.map +1 -1
- package/ui/animation/animation-shared.js.map +1 -1
- package/ui/animation/animation-types.js.map +1 -1
- package/ui/animation/index.android.js.map +1 -1
- package/ui/animation/index.ios.js +6 -1
- package/ui/animation/index.ios.js.map +1 -1
- package/ui/animation/keyframe-animation.d.ts +3 -1
- package/ui/animation/keyframe-animation.js +72 -3
- package/ui/animation/keyframe-animation.js.map +1 -1
- package/ui/builder/binding-builder.d.ts +8 -0
- package/ui/builder/binding-builder.js +12 -0
- package/ui/builder/binding-builder.js.map +1 -1
- package/ui/builder/component-builder/index.d.ts +7 -4
- package/ui/builder/component-builder/index.js +13 -7
- package/ui/builder/component-builder/index.js.map +1 -1
- package/ui/builder/index.d.ts +16 -2
- package/ui/builder/index.js +61 -13
- package/ui/builder/index.js.map +1 -1
- package/ui/button/button-common.js.map +1 -1
- package/ui/button/index.android.js +4 -3
- package/ui/button/index.android.js.map +1 -1
- package/ui/button/index.ios.js.map +1 -1
- package/ui/content-view/index.js +2 -0
- package/ui/content-view/index.js.map +1 -1
- package/ui/core/bindable/bindable-expressions.js.map +1 -1
- package/ui/core/bindable/bindable-resources.js.map +1 -1
- package/ui/core/bindable/bindable-types.d.ts +15 -0
- package/ui/core/bindable/bindable-types.js.map +1 -1
- package/ui/core/bindable/index.d.ts +1 -1
- package/ui/core/bindable/index.js +14 -8
- package/ui/core/bindable/index.js.map +1 -1
- package/ui/core/control-state-change/index.android.js.map +1 -1
- package/ui/core/control-state-change/index.ios.js.map +1 -1
- package/ui/core/properties/index.d.ts +37 -2
- package/ui/core/properties/index.js +205 -29
- package/ui/core/properties/index.js.map +1 -1
- package/ui/core/properties/property-shared.js +11 -2
- package/ui/core/properties/property-shared.js.map +1 -1
- package/ui/core/view/index.android.d.ts +5 -0
- package/ui/core/view/index.android.js +89 -15
- package/ui/core/view/index.android.js.map +1 -1
- package/ui/core/view/index.d.ts +58 -1
- package/ui/core/view/index.ios.d.ts +1 -0
- package/ui/core/view/index.ios.js +48 -11
- package/ui/core/view/index.ios.js.map +1 -1
- package/ui/core/view/view-common.d.ts +37 -0
- package/ui/core/view/view-common.js +81 -0
- package/ui/core/view/view-common.js.map +1 -1
- package/ui/core/view/view-helper/index.android.d.ts +1 -0
- package/ui/core/view/view-helper/index.android.js +8 -0
- package/ui/core/view/view-helper/index.android.js.map +1 -1
- package/ui/core/view/view-helper/index.d.ts +46 -0
- package/ui/core/view/view-helper/index.ios.d.ts +42 -0
- package/ui/core/view/view-helper/index.ios.js +170 -5
- package/ui/core/view/view-helper/index.ios.js.map +1 -1
- package/ui/core/view/view-helper/view-helper-common.js +21 -3
- package/ui/core/view/view-helper/view-helper-common.js.map +1 -1
- package/ui/core/view/view-helper/view-helper-shared.js.map +1 -1
- package/ui/core/view/view-interfaces.js.map +1 -1
- package/ui/core/view-base/index.js +75 -36
- package/ui/core/view-base/index.js.map +1 -1
- package/ui/core/view-base/utils.js.map +1 -1
- package/ui/core/weak-event-listener/index.js.map +1 -1
- package/ui/date-picker/date-picker-common.js.map +1 -1
- package/ui/date-picker/index.android.js +1 -1
- package/ui/date-picker/index.android.js.map +1 -1
- package/ui/date-picker/index.ios.js.map +1 -1
- package/ui/dialogs/dialogs-common.js.map +1 -1
- package/ui/dialogs/index.android.js +5 -5
- package/ui/dialogs/index.android.js.map +1 -1
- package/ui/dialogs/index.ios.js.map +1 -1
- package/ui/editable-text-base/editable-text-base-common.js.map +1 -1
- package/ui/editable-text-base/index.android.d.ts +2 -0
- package/ui/editable-text-base/index.android.js +17 -7
- package/ui/editable-text-base/index.android.js.map +1 -1
- package/ui/editable-text-base/index.d.ts +8 -0
- package/ui/editable-text-base/index.ios.js.map +1 -1
- package/ui/embedding/index.android.js.map +1 -1
- package/ui/embedding/index.ios.js.map +1 -1
- package/ui/enums/enums.js.map +1 -1
- package/ui/enums/index.js.map +1 -1
- package/ui/frame/activity.android.js.map +1 -1
- package/ui/frame/fragment.android.js.map +1 -1
- package/ui/frame/fragment.ios.js.map +1 -1
- package/ui/frame/fragment.transitions.android.d.ts +12 -9
- package/ui/frame/fragment.transitions.android.js +105 -90
- package/ui/frame/fragment.transitions.android.js.map +1 -1
- package/ui/frame/fragment.transitions.types.js.map +1 -1
- package/ui/frame/frame-common.d.ts +14 -2
- package/ui/frame/frame-common.js +51 -24
- package/ui/frame/frame-common.js.map +1 -1
- package/ui/frame/frame-constants.d.ts +9 -0
- package/ui/frame/frame-constants.js +10 -0
- package/ui/frame/frame-constants.js.map +1 -0
- package/ui/frame/frame-helper-for-android.d.ts +2 -2
- package/ui/frame/frame-helper-for-android.js +14 -5
- package/ui/frame/frame-helper-for-android.js.map +1 -1
- package/ui/frame/frame-helpers.js.map +1 -1
- package/ui/frame/frame-interfaces.d.ts +1 -1
- package/ui/frame/frame-interfaces.js.map +1 -1
- package/ui/frame/frame-stack.d.ts +22 -1
- package/ui/frame/frame-stack.js +43 -5
- package/ui/frame/frame-stack.js.map +1 -1
- package/ui/frame/index.android.d.ts +2 -2
- package/ui/frame/index.android.js +161 -56
- package/ui/frame/index.android.js.map +1 -1
- package/ui/frame/index.d.ts +15 -5
- package/ui/frame/index.ios.d.ts +1 -1
- package/ui/frame/index.ios.js +86 -26
- package/ui/frame/index.ios.js.map +1 -1
- package/ui/gestures/gestures-common.js.map +1 -1
- package/ui/gestures/gestures-types.d.ts +2 -0
- package/ui/gestures/gestures-types.js.map +1 -1
- package/ui/gestures/index.android.d.ts +1 -1
- package/ui/gestures/index.android.js +177 -133
- package/ui/gestures/index.android.js.map +1 -1
- package/ui/gestures/index.ios.js +36 -7
- package/ui/gestures/index.ios.js.map +1 -1
- package/ui/gestures/touch-manager.d.ts +1 -2
- package/ui/gestures/touch-manager.js +79 -50
- package/ui/gestures/touch-manager.js.map +1 -1
- package/ui/html-view/html-view-common.js.map +1 -1
- package/ui/html-view/index.android.js.map +1 -1
- package/ui/html-view/index.ios.js.map +1 -1
- package/ui/image/image-common.js +1 -1
- package/ui/image/image-common.js.map +1 -1
- package/ui/image/index.android.js +14 -2
- package/ui/image/index.android.js.map +1 -1
- package/ui/image/index.ios.js.map +1 -1
- package/ui/image/symbol-effects-common.js.map +1 -1
- package/ui/image/symbol-effects.android.js.map +1 -1
- package/ui/image/symbol-effects.ios.js.map +1 -1
- package/ui/image-cache/image-cache-common.js.map +1 -1
- package/ui/image-cache/index.android.js +1 -2
- package/ui/image-cache/index.android.js.map +1 -1
- package/ui/image-cache/index.ios.js.map +1 -1
- package/ui/index.d.ts +2 -2
- package/ui/index.js.map +1 -1
- package/ui/label/index.android.js.map +1 -1
- package/ui/label/index.ios.js.map +1 -1
- package/ui/layouts/absolute-layout/absolute-layout-common.js.map +1 -1
- package/ui/layouts/absolute-layout/index.android.js.map +1 -1
- package/ui/layouts/absolute-layout/index.ios.js +3 -0
- package/ui/layouts/absolute-layout/index.ios.js.map +1 -1
- package/ui/layouts/dock-layout/dock-layout-common.js.map +1 -1
- package/ui/layouts/dock-layout/index.android.js.map +1 -1
- package/ui/layouts/dock-layout/index.ios.js +3 -0
- package/ui/layouts/dock-layout/index.ios.js.map +1 -1
- package/ui/layouts/flexbox-layout/flexbox-layout-common.d.ts +7 -0
- package/ui/layouts/flexbox-layout/flexbox-layout-common.js +18 -0
- package/ui/layouts/flexbox-layout/flexbox-layout-common.js.map +1 -1
- package/ui/layouts/flexbox-layout/index.android.d.ts +5 -0
- package/ui/layouts/flexbox-layout/index.android.js +15 -0
- package/ui/layouts/flexbox-layout/index.android.js.map +1 -1
- package/ui/layouts/flexbox-layout/index.d.ts +19 -1
- package/ui/layouts/flexbox-layout/index.ios.d.ts +2 -0
- package/ui/layouts/flexbox-layout/index.ios.js +246 -195
- package/ui/layouts/flexbox-layout/index.ios.js.map +1 -1
- package/ui/layouts/grid-layout/grid-layout-common.js.map +1 -1
- package/ui/layouts/grid-layout/index.android.js.map +1 -1
- package/ui/layouts/grid-layout/index.ios.js +3 -0
- package/ui/layouts/grid-layout/index.ios.js.map +1 -1
- package/ui/layouts/index.js.map +1 -1
- package/ui/layouts/layout-base-common.d.ts +1 -0
- package/ui/layouts/layout-base-common.js +23 -1
- package/ui/layouts/layout-base-common.js.map +1 -1
- package/ui/layouts/layout-base.android.js.map +1 -1
- package/ui/layouts/layout-base.ios.js.map +1 -1
- package/ui/layouts/liquid-glass/index.android.js.map +1 -1
- package/ui/layouts/liquid-glass/index.ios.d.ts +0 -1
- package/ui/layouts/liquid-glass/index.ios.js +2 -43
- package/ui/layouts/liquid-glass/index.ios.js.map +1 -1
- package/ui/layouts/liquid-glass/liquid-glass-common.js.map +1 -1
- package/ui/layouts/liquid-glass-container/index.android.js.map +1 -1
- package/ui/layouts/liquid-glass-container/index.ios.d.ts +0 -1
- package/ui/layouts/liquid-glass-container/index.ios.js +2 -43
- package/ui/layouts/liquid-glass-container/index.ios.js.map +1 -1
- package/ui/layouts/liquid-glass-container/liquid-glass-container-common.js.map +1 -1
- package/ui/layouts/root-layout/index.android.js.map +1 -1
- package/ui/layouts/root-layout/index.ios.js.map +1 -1
- package/ui/layouts/root-layout/root-layout-common.js.map +1 -1
- package/ui/layouts/root-layout/root-layout-stack.js.map +1 -1
- package/ui/layouts/stack-layout/index.android.js.map +1 -1
- package/ui/layouts/stack-layout/index.ios.js +3 -0
- package/ui/layouts/stack-layout/index.ios.js.map +1 -1
- package/ui/layouts/stack-layout/stack-layout-common.js.map +1 -1
- package/ui/layouts/wrap-layout/index.android.js.map +1 -1
- package/ui/layouts/wrap-layout/index.ios.js +3 -0
- package/ui/layouts/wrap-layout/index.ios.js.map +1 -1
- package/ui/layouts/wrap-layout/wrap-layout-common.js.map +1 -1
- package/ui/list-picker/index.android.d.ts +1 -0
- package/ui/list-picker/index.android.js +6 -5
- package/ui/list-picker/index.android.js.map +1 -1
- package/ui/list-picker/index.ios.js.map +1 -1
- package/ui/list-picker/list-picker-common.js.map +1 -1
- package/ui/list-view/index.android.js +19 -11
- package/ui/list-view/index.android.js.map +1 -1
- package/ui/list-view/index.d.ts +47 -3
- package/ui/list-view/index.ios.d.ts +13 -3
- package/ui/list-view/index.ios.js +132 -41
- package/ui/list-view/index.ios.js.map +1 -1
- package/ui/list-view/list-view-common.d.ts +19 -0
- package/ui/list-view/list-view-common.js +30 -0
- package/ui/list-view/list-view-common.js.map +1 -1
- package/ui/page/events.js.map +1 -1
- package/ui/page/index.android.js.map +1 -1
- package/ui/page/index.d.ts +1 -1
- package/ui/page/index.ios.d.ts +3 -1
- package/ui/page/index.ios.js +33 -20
- package/ui/page/index.ios.js.map +1 -1
- package/ui/page/page-common.d.ts +5 -1
- package/ui/page/page-common.js.map +1 -1
- package/ui/placeholder/index.android.js.map +1 -1
- package/ui/placeholder/index.js.map +1 -1
- package/ui/placeholder/placeholder-common.js.map +1 -1
- package/ui/progress/index.android.js.map +1 -1
- package/ui/progress/index.ios.js.map +1 -1
- package/ui/progress/progress-common.js.map +1 -1
- package/ui/proxy-view-container/index.js.map +1 -1
- package/ui/repeater/index.d.ts +2 -1
- package/ui/repeater/index.js.map +1 -1
- package/ui/scroll-view/index.android.d.ts +2 -1
- package/ui/scroll-view/index.android.js +4 -1
- package/ui/scroll-view/index.android.js.map +1 -1
- package/ui/scroll-view/index.d.ts +53 -0
- package/ui/scroll-view/index.ios.d.ts +13 -1
- package/ui/scroll-view/index.ios.js +100 -20
- package/ui/scroll-view/index.ios.js.map +1 -1
- package/ui/scroll-view/scroll-view-common.d.ts +13 -0
- package/ui/scroll-view/scroll-view-common.js +27 -0
- package/ui/scroll-view/scroll-view-common.js.map +1 -1
- package/ui/search-bar/index.android.js +2 -2
- package/ui/search-bar/index.android.js.map +1 -1
- package/ui/search-bar/index.ios.js.map +1 -1
- package/ui/search-bar/search-bar-common.js.map +1 -1
- package/ui/segmented-bar/index.android.js +8 -8
- package/ui/segmented-bar/index.android.js.map +1 -1
- package/ui/segmented-bar/index.ios.js.map +1 -1
- package/ui/segmented-bar/segmented-bar-common.d.ts +5 -1
- package/ui/segmented-bar/segmented-bar-common.js +6 -1
- package/ui/segmented-bar/segmented-bar-common.js.map +1 -1
- package/ui/slider/index.android.js +1 -2
- package/ui/slider/index.android.js.map +1 -1
- package/ui/slider/index.ios.js.map +1 -1
- package/ui/slider/slider-common.js.map +1 -1
- package/ui/split-view/index.android.js.map +1 -1
- package/ui/split-view/index.ios.js.map +1 -1
- package/ui/split-view/split-view-common.js.map +1 -1
- package/ui/styling/background-common.d.ts +2 -0
- package/ui/styling/background-common.js +10 -2
- package/ui/styling/background-common.js.map +1 -1
- package/ui/styling/background.android.d.ts +4 -1
- package/ui/styling/background.android.js +5 -2
- package/ui/styling/background.android.js.map +1 -1
- package/ui/styling/background.d.ts +2 -2
- package/ui/styling/background.ios.d.ts +1 -1
- package/ui/styling/background.ios.js +10 -3
- package/ui/styling/background.ios.js.map +1 -1
- package/ui/styling/box-shadow.js.map +1 -1
- package/ui/styling/clip-path-function.js.map +1 -1
- package/ui/styling/converters.js.map +1 -1
- package/ui/styling/css-animation-parser.js.map +1 -1
- package/ui/styling/css-selector.d.ts +60 -13
- package/ui/styling/css-selector.js +311 -50
- package/ui/styling/css-selector.js.map +1 -1
- package/ui/styling/css-shadow.js.map +1 -1
- package/ui/styling/css-stroke.js.map +1 -1
- package/ui/styling/css-transform.js.map +1 -1
- package/ui/styling/css-utils.d.ts +16 -0
- package/ui/styling/css-utils.js +121 -7
- package/ui/styling/css-utils.js.map +1 -1
- package/ui/styling/font-common.js.map +1 -1
- package/ui/styling/font-interfaces.js.map +1 -1
- package/ui/styling/font.android.js.map +1 -1
- package/ui/styling/font.ios.js.map +1 -1
- package/ui/styling/length-shared.d.ts +2 -0
- package/ui/styling/length-shared.js +29 -2
- package/ui/styling/length-shared.js.map +1 -1
- package/ui/styling/linear-gradient.js.map +1 -1
- package/ui/styling/style/index.d.ts +29 -2
- package/ui/styling/style/index.js +1 -0
- package/ui/styling/style/index.js.map +1 -1
- package/ui/styling/style-properties.d.ts +5 -0
- package/ui/styling/style-properties.js +172 -101
- package/ui/styling/style-properties.js.map +1 -1
- package/ui/styling/style-scope.d.ts +24 -3
- package/ui/styling/style-scope.js +461 -63
- package/ui/styling/style-scope.js.map +1 -1
- package/ui/styling/styling-profile.js.map +1 -1
- package/ui/styling/styling-shared.js.map +1 -1
- package/ui/switch/index.android.js +1 -1
- package/ui/switch/index.android.js.map +1 -1
- package/ui/switch/index.ios.js +5 -1
- package/ui/switch/index.ios.js.map +1 -1
- package/ui/switch/switch-common.js.map +1 -1
- package/ui/tab-view/index.android.js +13 -17
- package/ui/tab-view/index.android.js.map +1 -1
- package/ui/tab-view/index.d.ts +5 -3
- package/ui/tab-view/index.ios.d.ts +2 -1
- package/ui/tab-view/index.ios.js +83 -20
- package/ui/tab-view/index.ios.js.map +1 -1
- package/ui/tab-view/tab-view-common.d.ts +6 -1
- package/ui/tab-view/tab-view-common.js +17 -1
- package/ui/tab-view/tab-view-common.js.map +1 -1
- package/ui/text-base/formatted-string.js.map +1 -1
- package/ui/text-base/index.android.js +6 -9
- package/ui/text-base/index.android.js.map +1 -1
- package/ui/text-base/index.ios.d.ts +3 -0
- package/ui/text-base/index.ios.js +26 -4
- package/ui/text-base/index.ios.js.map +1 -1
- package/ui/text-base/span.js.map +1 -1
- package/ui/text-base/text-base-common.js.map +1 -1
- package/ui/text-field/index.android.js.map +1 -1
- package/ui/text-field/index.ios.js +13 -5
- package/ui/text-field/index.ios.js.map +1 -1
- package/ui/text-field/text-field-common.js.map +1 -1
- package/ui/text-view/index.android.js.map +1 -1
- package/ui/text-view/index.ios.js.map +1 -1
- package/ui/text-view/text-view-common.js.map +1 -1
- package/ui/time-picker/index.android.js +1 -1
- package/ui/time-picker/index.android.js.map +1 -1
- package/ui/time-picker/index.ios.js.map +1 -1
- package/ui/time-picker/time-picker-common.js.map +1 -1
- package/ui/transition/fade-transition.android.js.map +1 -1
- package/ui/transition/fade-transition.ios.js.map +1 -1
- package/ui/transition/flip-transition.android.js.map +1 -1
- package/ui/transition/index.android.js.map +1 -1
- package/ui/transition/index.d.ts +2 -1
- package/ui/transition/index.ios.js.map +1 -1
- package/ui/transition/modal-transition.android.js.map +1 -1
- package/ui/transition/modal-transition.ios.js +33 -5
- package/ui/transition/modal-transition.ios.js.map +1 -1
- package/ui/transition/page-transition.android.d.ts +4 -0
- package/ui/transition/page-transition.android.js +171 -86
- package/ui/transition/page-transition.android.js.map +1 -1
- package/ui/transition/page-transition.ios.d.ts +5 -0
- package/ui/transition/page-transition.ios.js +298 -36
- package/ui/transition/page-transition.ios.js.map +1 -1
- package/ui/transition/shared-transition-helper.android.d.ts +3 -0
- package/ui/transition/shared-transition-helper.android.js +9 -0
- package/ui/transition/shared-transition-helper.android.js.map +1 -1
- package/ui/transition/shared-transition-helper.d.ts +7 -0
- package/ui/transition/shared-transition-helper.ios.d.ts +48 -0
- package/ui/transition/shared-transition-helper.ios.js +977 -95
- package/ui/transition/shared-transition-helper.ios.js.map +1 -1
- package/ui/transition/shared-transition.d.ts +134 -0
- package/ui/transition/shared-transition.js +90 -2
- package/ui/transition/shared-transition.js.map +1 -1
- package/ui/transition/slide-transition.android.js.map +1 -1
- package/ui/transition/slide-transition.ios.js.map +1 -1
- package/ui/utils.android.js.map +1 -1
- package/ui/utils.d.ts +2 -0
- package/ui/utils.ios.js.map +1 -1
- package/ui/web-view/index.android.js +1 -1
- package/ui/web-view/index.android.js.map +1 -1
- package/ui/web-view/index.ios.js.map +1 -1
- package/ui/web-view/web-view-common.js.map +1 -1
- package/ui/web-view/web-view-interfaces.js.map +1 -1
- package/utils/android-runtime-version.d.ts +12 -0
- package/utils/android-runtime-version.js +36 -0
- package/utils/android-runtime-version.js.map +1 -0
- package/utils/animation-helpers.js.map +1 -1
- package/utils/common.js.map +1 -1
- package/utils/constants.android.js.map +1 -1
- package/utils/constants.ios.js.map +1 -1
- package/utils/debug-source.js.map +1 -1
- package/utils/debug.js.map +1 -1
- package/utils/index.android.js.map +1 -1
- package/utils/index.ios.js.map +1 -1
- package/utils/layout-helper/index.android.js.map +1 -1
- package/utils/layout-helper/index.ios.js +11 -3
- package/utils/layout-helper/index.ios.js.map +1 -1
- package/utils/layout-helper/layout-helper-common.js.map +1 -1
- package/utils/layout-helper/layout-helper-shared.js.map +1 -1
- package/utils/lazy.js.map +1 -1
- package/utils/macrotask-scheduler.js.map +1 -1
- package/utils/mainthread-helper.android.js.map +1 -1
- package/utils/mainthread-helper.ios.js.map +1 -1
- package/utils/module-merge.js.map +1 -1
- package/utils/native-helper-for-android.js +9 -3
- package/utils/native-helper-for-android.js.map +1 -1
- package/utils/native-helper.android.d.ts +66 -2
- package/utils/native-helper.android.js.map +1 -1
- package/utils/native-helper.d.ts +2 -2
- package/utils/native-helper.ios.d.ts +52 -2
- package/utils/native-helper.ios.js +35 -5
- package/utils/native-helper.ios.js.map +1 -1
- package/utils/native-helper.types.d.ts +2 -0
- package/utils/number-utils.js.map +1 -1
- package/utils/platform-check.d.ts +1 -1
- package/utils/platform-check.js.map +1 -1
- package/utils/shared.js.map +1 -1
- package/utils/types.js.map +1 -1
- package/utils/utils-shared.js.map +1 -1
- package/wgc/atob.js.map +1 -1
- package/wgc/btoa.js.map +1 -1
- package/wgc/crypto/SubtleCrypto.js.map +1 -1
- package/wgc/crypto/index.d.ts +1 -1
- package/wgc/crypto/index.js +12 -8
- package/wgc/crypto/index.js.map +1 -1
- package/wgc/index.js.map +1 -1
- package/xhr/index.d.ts +5 -4
- package/xhr/index.js +18 -18
- package/xhr/index.js.map +1 -1
- package/xml/index.d.ts +2 -2
- package/xml/index.js +1 -1
- package/xml/index.js.map +1 -1
- package/LICENSE +0 -19
- package/fetch/index.mjs +0 -535
|
@@ -3,13 +3,162 @@ import { isNumber } from '../../utils/types';
|
|
|
3
3
|
import { Screen } from '../../platform';
|
|
4
4
|
import { CORE_ANIMATION_DEFAULTS } from '../../utils/animation-helpers';
|
|
5
5
|
import { ios as iOSUtils } from '../../utils/native-helper';
|
|
6
|
+
import { Color } from '../../color';
|
|
7
|
+
import { Trace } from '../../trace';
|
|
8
|
+
function getControllerPage(controller) {
|
|
9
|
+
return controller?.['_entry']?.resolvedPage ?? controller?._owner?.deref?.() ?? controller?.owner?.deref?.() ?? null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Frame, in the container coordinates, of what the view really shows.
|
|
13
|
+
* An aspect fit image view has letterbox around its image: animating its bounds would stretch the image
|
|
14
|
+
* and make it jump to the right size at the end of the transition.
|
|
15
|
+
* Aspect fill (cropped) and non image views simply use their bounds.
|
|
16
|
+
*/
|
|
17
|
+
function getDisplayedFrame(view, container) {
|
|
18
|
+
let rect = view.bounds;
|
|
19
|
+
if (view instanceof UIImageView && view.image && view.contentMode === 1 /* UIViewContentMode.ScaleAspectFit */) {
|
|
20
|
+
const imageSize = view.image.size;
|
|
21
|
+
if (imageSize.width > 0 && imageSize.height > 0 && rect.size.width > 0 && rect.size.height > 0) {
|
|
22
|
+
const scale = Math.min(rect.size.width / imageSize.width, rect.size.height / imageSize.height);
|
|
23
|
+
const width = imageSize.width * scale;
|
|
24
|
+
const height = imageSize.height * scale;
|
|
25
|
+
rect = CGRectMake(rect.origin.x + (rect.size.width - width) / 2, rect.origin.y + (rect.size.height - height) / 2, width, height);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return view.convertRectToView(rect, container);
|
|
29
|
+
}
|
|
30
|
+
// when both sides are images, the snapshot is filled like the source one: both ends then show the exact same pixels
|
|
31
|
+
// (the end frame of an aspect fit image has the aspect ratio of the image)
|
|
32
|
+
function getSnapshotContentMode(from, to) {
|
|
33
|
+
return from instanceof UIImageView ? from.contentMode : to.contentMode;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Apply a drop shadow behind the destination view during an interactive
|
|
37
|
+
* dismiss so it looks elevated above the source (Apple Music–style).
|
|
38
|
+
*
|
|
39
|
+
* Shadow + rounded corners can't coexist on the same CALayer on iOS — both
|
|
40
|
+
* `masksToBounds = true` and `layer.mask` clip the shadow as part of the
|
|
41
|
+
* compositing pipeline. So the shadow lives on a SIBLING CALayer inserted
|
|
42
|
+
* below the modal's layer in its superlayer (the same pattern NS uses for
|
|
43
|
+
* box-shadow via `outerShadowContainerLayer`). The modal keeps its own
|
|
44
|
+
* `cornerRadius` + `masksToBounds` so subviews still clip to the rounded
|
|
45
|
+
* shape.
|
|
46
|
+
*
|
|
47
|
+
* Because the shadow layer is a sibling (not a child), it doesn't inherit
|
|
48
|
+
* the modal's transform automatically — `syncInteractiveDismissShadow`
|
|
49
|
+
* mirrors transform/position/bounds during the drag.
|
|
50
|
+
*
|
|
51
|
+
* Falsy `shadowConfig` is a no-op.
|
|
52
|
+
*/
|
|
53
|
+
export function applyInteractiveDismissShadow(presentedView, shadowConfig) {
|
|
54
|
+
if (!presentedView?.layer || !shadowConfig)
|
|
55
|
+
return;
|
|
56
|
+
const layer = presentedView.layer;
|
|
57
|
+
const superlayer = layer.superlayer;
|
|
58
|
+
if (!superlayer)
|
|
59
|
+
return;
|
|
60
|
+
const bounds = layer.bounds;
|
|
61
|
+
if (bounds.size.width <= 0 || bounds.size.height <= 0)
|
|
62
|
+
return;
|
|
63
|
+
// Idempotent.
|
|
64
|
+
if (presentedView.__sharedTransitionShadowLayer)
|
|
65
|
+
return;
|
|
66
|
+
const cfg = shadowConfig === true ? {} : shadowConfig;
|
|
67
|
+
const colorInput = cfg.color ?? '#000';
|
|
68
|
+
let cgColor;
|
|
69
|
+
try {
|
|
70
|
+
const nsColor = typeof colorInput === 'string' ? new Color(colorInput) : colorInput;
|
|
71
|
+
cgColor = nsColor.ios?.CGColor || nsColor.CGColor || UIColor.blackColor.CGColor;
|
|
72
|
+
}
|
|
73
|
+
catch (_) {
|
|
74
|
+
cgColor = UIColor.blackColor.CGColor;
|
|
75
|
+
}
|
|
76
|
+
const opacity = isNumber(cfg.opacity) ? cfg.opacity : 0.3;
|
|
77
|
+
const radius = isNumber(cfg.radius) ? cfg.radius : 30;
|
|
78
|
+
const offsetX = isNumber(cfg.offset?.x) ? cfg.offset.x : 0;
|
|
79
|
+
const offsetY = isNumber(cfg.offset?.y) ? cfg.offset.y : 8;
|
|
80
|
+
const cornerRadius = layer.cornerRadius || 0;
|
|
81
|
+
const roundedRectPath = UIBezierPath.bezierPathWithRoundedRectCornerRadius(CGRectMake(0, 0, bounds.size.width, bounds.size.height), cornerRadius).CGPath;
|
|
82
|
+
const shadowLayer = CALayer.layer();
|
|
83
|
+
// Match the modal's geometry so shadow tracks 1:1.
|
|
84
|
+
shadowLayer.anchorPoint = layer.anchorPoint;
|
|
85
|
+
shadowLayer.bounds = bounds;
|
|
86
|
+
shadowLayer.position = layer.position;
|
|
87
|
+
shadowLayer.transform = layer.transform;
|
|
88
|
+
shadowLayer.shadowColor = cgColor;
|
|
89
|
+
shadowLayer.shadowOpacity = opacity;
|
|
90
|
+
shadowLayer.shadowRadius = radius;
|
|
91
|
+
shadowLayer.shadowOffset = CGSizeMake(offsetX, offsetY);
|
|
92
|
+
// Explicit shadowPath = shadow renders from this shape outward;
|
|
93
|
+
// the layer itself stays fully transparent.
|
|
94
|
+
shadowLayer.shadowPath = roundedRectPath;
|
|
95
|
+
CATransaction.begin();
|
|
96
|
+
CATransaction.setDisableActions(true);
|
|
97
|
+
superlayer.insertSublayerBelow(shadowLayer, layer);
|
|
98
|
+
CATransaction.commit();
|
|
99
|
+
presentedView.__sharedTransitionShadowLayer = shadowLayer;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Mirror the modal layer's geometry onto the sibling shadow layer so the
|
|
103
|
+
* shadow tracks the interactive drag. Called from the gesture handlers
|
|
104
|
+
* after the modal's state has been updated (either via direct transform
|
|
105
|
+
* in morph mode, or via `interactiveController.updateInteractiveTransition`
|
|
106
|
+
* for the non-morph modal/page case driven by UIViewPropertyAnimator).
|
|
107
|
+
*
|
|
108
|
+
* Reads the layer's **presentation** values when an animation is in flight
|
|
109
|
+
* — model values would point at the animation's end state and snap the
|
|
110
|
+
* shadow there. Falls back to model values when no animation is running.
|
|
111
|
+
*/
|
|
112
|
+
export function syncInteractiveDismissShadow(presentedView) {
|
|
113
|
+
const shadowLayer = presentedView?.__sharedTransitionShadowLayer;
|
|
114
|
+
if (!shadowLayer || !presentedView?.layer)
|
|
115
|
+
return;
|
|
116
|
+
const layer = presentedView.layer;
|
|
117
|
+
const pres = typeof layer.presentationLayer === 'function' ? layer.presentationLayer() : null;
|
|
118
|
+
const src = pres || layer;
|
|
119
|
+
const b = src.bounds;
|
|
120
|
+
CATransaction.begin();
|
|
121
|
+
CATransaction.setDisableActions(true);
|
|
122
|
+
shadowLayer.bounds = b;
|
|
123
|
+
shadowLayer.position = src.position;
|
|
124
|
+
shadowLayer.anchorPoint = src.anchorPoint;
|
|
125
|
+
shadowLayer.transform = src.transform;
|
|
126
|
+
shadowLayer.shadowPath = UIBezierPath.bezierPathWithRoundedRectCornerRadius(CGRectMake(0, 0, b.size.width, b.size.height), src.cornerRadius || 0).CGPath;
|
|
127
|
+
CATransaction.commit();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Remove the sibling shadow layer. Safe to call repeatedly / when no
|
|
131
|
+
* shadow was applied.
|
|
132
|
+
*/
|
|
133
|
+
export function removeInteractiveDismissShadow(presentedView) {
|
|
134
|
+
const shadowLayer = presentedView?.__sharedTransitionShadowLayer;
|
|
135
|
+
if (!shadowLayer)
|
|
136
|
+
return;
|
|
137
|
+
CATransaction.begin();
|
|
138
|
+
CATransaction.setDisableActions(true);
|
|
139
|
+
shadowLayer.removeFromSuperlayer();
|
|
140
|
+
CATransaction.commit();
|
|
141
|
+
presentedView.__sharedTransitionShadowLayer = null;
|
|
142
|
+
}
|
|
6
143
|
export class SharedTransitionHelper {
|
|
7
144
|
static animate(state, transitionContext, type) {
|
|
8
|
-
const transition = state.instance;
|
|
9
145
|
setTimeout(async () => {
|
|
10
146
|
// Run on next tick
|
|
11
147
|
// ensures that existing UI state finishes before snapshotting
|
|
12
148
|
// (eg, button touch up state)
|
|
149
|
+
// Any exception thrown before the animation starts would leave `completeTransition` uncalled
|
|
150
|
+
// and UIKit stuck in the middle of the transition (blank page, dead back button, hidden shared views)
|
|
151
|
+
try {
|
|
152
|
+
await SharedTransitionHelper.run(state, transitionContext, type);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
SharedTransitionHelper.recover(state, transitionContext, type, error);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
static async run(state, transitionContext, type) {
|
|
160
|
+
const transition = state.instance;
|
|
161
|
+
{
|
|
13
162
|
switch (state.activeType) {
|
|
14
163
|
case SharedTransitionAnimationType.present: {
|
|
15
164
|
// console.log('-- Transition present --');
|
|
@@ -25,7 +174,10 @@ export class SharedTransitionHelper {
|
|
|
25
174
|
transitionContext.containerView.insertSubviewAboveSubview(transition.presented.view, transition.presenting.view);
|
|
26
175
|
}
|
|
27
176
|
transition.presented.view.layoutIfNeeded();
|
|
28
|
-
const { sharedElements, presented, presenting } = SharedTransition.getSharedElements(state.page, state.toPage);
|
|
177
|
+
const { sharedElements: allSharedElements, presented, presenting } = SharedTransition.getSharedElements(state.page, state.toPage);
|
|
178
|
+
// like on android, pageStart.sharedTransitionTags restricts the elements which are shared between both pages
|
|
179
|
+
const startTags = state.pageStart?.sharedTransitionTags ? Object.keys(state.pageStart.sharedTransitionTags) : null;
|
|
180
|
+
const sharedElements = startTags?.length ? allSharedElements.filter((v) => startTags.indexOf(v.sharedTransitionTag) !== -1) : allSharedElements;
|
|
29
181
|
const sharedElementTags = sharedElements.map((v) => v.sharedTransitionTag);
|
|
30
182
|
if (!transition.sharedElements) {
|
|
31
183
|
transition.sharedElements = {
|
|
@@ -34,6 +186,10 @@ export class SharedTransitionHelper {
|
|
|
34
186
|
independent: [],
|
|
35
187
|
};
|
|
36
188
|
}
|
|
189
|
+
// Track every matched source view so cleanup can restore alpha,
|
|
190
|
+
// including duplicates (same album surfacing in multiple lists)
|
|
191
|
+
// that we hide but don't create a snapshot for.
|
|
192
|
+
transition.sharedElements._allPresentingViews = sharedElements.slice();
|
|
37
193
|
if (SharedTransition.DEBUG) {
|
|
38
194
|
console.log(` ${type}: Present`);
|
|
39
195
|
console.log(`1. Found sharedTransitionTags to animate:`, sharedElementTags);
|
|
@@ -46,12 +202,22 @@ export class SharedTransitionHelper {
|
|
|
46
202
|
const pageEndTags = pageEnd?.sharedTransitionTags || {};
|
|
47
203
|
// console.log('pageEndIndependentTags:', pageEndIndependentTags);
|
|
48
204
|
const positionSharedTags = async () => {
|
|
205
|
+
const processedTags = new Set();
|
|
49
206
|
for (const presentingView of sharedElements) {
|
|
50
207
|
const presentingSharedElement = presentingView.ios;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
208
|
+
const tag = presentingView.sharedTransitionTag;
|
|
209
|
+
if (processedTags.has(tag)) {
|
|
210
|
+
// The same item can appear in multiple lists on the source page
|
|
211
|
+
// (e.g., a featured album also surfacing in "Recently Played").
|
|
212
|
+
// Each instance has the same sharedTransitionTag. Only the first
|
|
213
|
+
// one becomes the snapshot origin; the rest must still be hidden
|
|
214
|
+
// so they don't show through behind the animating snapshot.
|
|
215
|
+
if (presentingSharedElement) {
|
|
216
|
+
presentingSharedElement.alpha = 0;
|
|
217
|
+
}
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
processedTags.add(tag);
|
|
55
221
|
const presentedView = presented.find((v) => v.sharedTransitionTag === presentingView.sharedTransitionTag);
|
|
56
222
|
const presentedSharedElement = presentedView.ios;
|
|
57
223
|
const pageEndProps = pageEndTags[presentingView.sharedTransitionTag];
|
|
@@ -60,21 +226,31 @@ export class SharedTransitionHelper {
|
|
|
60
226
|
await pageEndProps?.callback(presentedView, 'present');
|
|
61
227
|
}
|
|
62
228
|
// treat images differently...
|
|
229
|
+
let imageSourceChangeListener;
|
|
63
230
|
if (presentedSharedElement instanceof UIImageView) {
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
|
|
231
|
+
// In case the image is loaded async, keep the snapshot's image in sync with
|
|
232
|
+
// the destination view's image. We hold a ref so we can detach the listener
|
|
233
|
+
// on cleanup (the View would otherwise hold a strong ref via the observers
|
|
234
|
+
// map and the snapshot closure would leak).
|
|
235
|
+
imageSourceChangeListener = () => {
|
|
67
236
|
snapshot.image = iOSUtils.snapshotView(presentedSharedElement, Screen.mainScreen.scale);
|
|
68
237
|
snapshot.tintColor = presentedSharedElement.tintColor;
|
|
69
|
-
}
|
|
238
|
+
};
|
|
239
|
+
presentedView.on('imageSourceChange', imageSourceChangeListener);
|
|
70
240
|
snapshot.tintColor = presentedSharedElement.tintColor;
|
|
71
|
-
snapshot.contentMode = presentedSharedElement
|
|
241
|
+
snapshot.contentMode = getSnapshotContentMode(presentingSharedElement, presentedSharedElement);
|
|
242
|
+
// Seed the snapshot with the source's already-loaded image so the very
|
|
243
|
+
// first frame of the animation isn't blank if the destination image is
|
|
244
|
+
// still loading.
|
|
245
|
+
if (presentingSharedElement instanceof UIImageView) {
|
|
246
|
+
snapshot.image = presentingSharedElement.image;
|
|
247
|
+
}
|
|
72
248
|
}
|
|
73
249
|
iOSUtils.copyLayerProperties(snapshot, presentingSharedElement, pageEndProps?.propertiesToMatch);
|
|
74
250
|
snapshot.clipsToBounds = true;
|
|
75
251
|
// console.log('---> snapshot: ', snapshot);
|
|
76
|
-
const startFrame =
|
|
77
|
-
const endFrame =
|
|
252
|
+
const startFrame = getDisplayedFrame(presentingSharedElement, transitionContext.containerView);
|
|
253
|
+
const endFrame = getDisplayedFrame(presentedSharedElement, transitionContext.containerView);
|
|
78
254
|
snapshot.frame = startFrame;
|
|
79
255
|
if (SharedTransition.DEBUG) {
|
|
80
256
|
console.log('---> ', presentingView.sharedTransitionTag, ' frame:', iOSUtils.printCGRect(snapshot.frame));
|
|
@@ -96,86 +272,115 @@ export class SharedTransitionHelper {
|
|
|
96
272
|
startOpacity: presentedView.opacity,
|
|
97
273
|
endOpacity: presentingView.opacity,
|
|
98
274
|
propertiesToMatch: pageEndProps?.propertiesToMatch,
|
|
275
|
+
imageSourceChangeListener,
|
|
99
276
|
});
|
|
100
277
|
// set initial opacity to match the source view opacity
|
|
101
278
|
snapshot.alpha = presentingView.opacity;
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
|
|
279
|
+
// Hide both while animating in the transition context.
|
|
280
|
+
//
|
|
281
|
+
// We mutate native alpha directly rather than NS `opacity` so the NS-side
|
|
282
|
+
// style remains the user's intended value (typically 1). If we instead set
|
|
283
|
+
// `view.opacity = 0` and then a transition was interrupted before cleanup
|
|
284
|
+
// (or the page was reused), `startOpacity` here could capture 0 from a prior
|
|
285
|
+
// run and the cleanup below would leave the destination invisible.
|
|
286
|
+
presentingSharedElement.alpha = 0;
|
|
287
|
+
presentedSharedElement.alpha = 0;
|
|
105
288
|
}
|
|
106
289
|
};
|
|
107
290
|
const positionIndependentTags = async () => {
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
291
|
+
// "Independent" tags appear on only one of the two pages (or were
|
|
292
|
+
// explicitly enumerated in pageEnd.sharedTransitionTags). We auto-discover
|
|
293
|
+
// them so authors don't have to enumerate every tag manually:
|
|
294
|
+
// - source-only (orphan on presenting): fade *out* on present, fade
|
|
295
|
+
// back in on dismiss. e.g., a "FEATURED ALBUM" label on a hero card
|
|
296
|
+
// that has no counterpart on the destination page.
|
|
297
|
+
// - destination-only (orphan on presented): fade *in* on present, fade
|
|
298
|
+
// back out on dismiss. e.g., metadata that only exists on the detail
|
|
299
|
+
// page.
|
|
300
|
+
// Authors can override per-tag via pageStart / pageEnd `sharedTransitionTags`
|
|
301
|
+
// (e.g. add `y: -20` to slide while fading), or opt a view out entirely
|
|
302
|
+
// with `sharedTransitionIgnore`.
|
|
303
|
+
const orphanTags = [];
|
|
304
|
+
const seenOrphan = new Set();
|
|
305
|
+
const addOrphan = (tag) => {
|
|
306
|
+
if (!tag || seenOrphan.has(tag) || sharedElementTags.includes(tag))
|
|
307
|
+
return;
|
|
308
|
+
seenOrphan.add(tag);
|
|
309
|
+
orphanTags.push(tag);
|
|
310
|
+
};
|
|
311
|
+
for (const v of presenting)
|
|
312
|
+
addOrphan(v.sharedTransitionTag);
|
|
313
|
+
for (const v of presented)
|
|
314
|
+
addOrphan(v.sharedTransitionTag);
|
|
315
|
+
// Tags the user listed in pageEnd.sharedTransitionTags but that don't
|
|
316
|
+
// match a real view are silently skipped further down — keep them in
|
|
317
|
+
// the iteration so per-tag config still applies to existing orphans.
|
|
318
|
+
for (const tag in pageEndTags)
|
|
319
|
+
addOrphan(tag);
|
|
320
|
+
for (const tag of orphanTags) {
|
|
321
|
+
const pageStartIndependentProps = pageStart?.sharedTransitionTags ? pageStart?.sharedTransitionTags[tag] : null;
|
|
322
|
+
const pageEndProps = pageEndTags[tag];
|
|
323
|
+
let independentView = presenting.find((v) => v.sharedTransitionTag === tag);
|
|
324
|
+
let isPresented = false;
|
|
325
|
+
if (!independentView) {
|
|
326
|
+
independentView = presented.find((v) => v.sharedTransitionTag === tag);
|
|
118
327
|
if (!independentView) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
isPresented = true;
|
|
124
|
-
}
|
|
125
|
-
const independentSharedElement = independentView.ios;
|
|
126
|
-
if (pageEndProps?.callback) {
|
|
127
|
-
await pageEndProps?.callback(independentView, 'present');
|
|
128
|
-
}
|
|
129
|
-
// let snapshot: UIImageView;
|
|
130
|
-
// if (isPresented) {
|
|
131
|
-
// snapshot = UIImageView.alloc().init();
|
|
132
|
-
// } else {
|
|
133
|
-
const snapshot = UIImageView.alloc().initWithImage(iOSUtils.snapshotView(independentSharedElement, Screen.mainScreen.scale));
|
|
134
|
-
// }
|
|
135
|
-
if (independentSharedElement instanceof UIImageView) {
|
|
136
|
-
// in case the image is loaded async, we need to update the snapshot when it changes
|
|
137
|
-
// todo: remove listener on transition end
|
|
138
|
-
// if (isPresented) {
|
|
139
|
-
// independentView.on('imageSourceChange', () => {
|
|
140
|
-
// snapshot.image = iOSNativeHelper.snapshotView(independentSharedElement, Screen.mainScreen.scale);
|
|
141
|
-
// snapshot.tintColor = independentSharedElement.tintColor;
|
|
142
|
-
// });
|
|
143
|
-
// }
|
|
144
|
-
snapshot.tintColor = independentSharedElement.tintColor;
|
|
145
|
-
snapshot.contentMode = independentSharedElement.contentMode;
|
|
328
|
+
// Tag declared in config but no matching view; skip (don't
|
|
329
|
+
// break — later tags might still resolve).
|
|
330
|
+
continue;
|
|
146
331
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// console.log('startFrameAdjusted:', tag, iOSNativeHelper.printCGRect(startFrameAdjusted));
|
|
153
|
-
// if (pageStartIndependentProps?.scale) {
|
|
154
|
-
// snapshot.transform = CGAffineTransformConcat(CGAffineTransformMakeTranslation(startFrameAdjusted.origin.x, startFrameAdjusted.origin.y), CGAffineTransformMakeScale(pageStartIndependentProps.scale.x, pageStartIndependentProps.scale.y))
|
|
155
|
-
// } else {
|
|
156
|
-
snapshot.frame = startFrame; //startFrameAdjusted;
|
|
157
|
-
// }
|
|
158
|
-
if (SharedTransition.DEBUG) {
|
|
159
|
-
console.log('---> ', independentView.sharedTransitionTag, ' frame:', iOSUtils.printCGRect(snapshot.frame));
|
|
160
|
-
}
|
|
161
|
-
const endFrameRect = getRectFromProps(pageEndProps);
|
|
162
|
-
const endFrame = CGRectMake(startFrame.origin.x + endFrameRect.x, startFrame.origin.y + endFrameRect.y, startFrame.size.width, startFrame.size.height);
|
|
163
|
-
// console.log('endFrame:', tag, iOSNativeHelper.printCGRect(endFrame));
|
|
164
|
-
transition.sharedElements.independent.push({
|
|
165
|
-
view: independentView,
|
|
166
|
-
isPresented,
|
|
167
|
-
startFrame,
|
|
168
|
-
snapshot,
|
|
169
|
-
endFrame,
|
|
170
|
-
startTransform: independentSharedElement.transform,
|
|
171
|
-
scale: pageEndProps.scale,
|
|
172
|
-
startOpacity: independentView.opacity,
|
|
173
|
-
endOpacity: isNumber(pageEndProps.opacity) ? pageEndProps.opacity : 0,
|
|
174
|
-
propertiesToMatch: pageEndProps?.propertiesToMatch,
|
|
175
|
-
zIndex: isNumber(pageEndProps?.zIndex) ? pageEndProps.zIndex : 0,
|
|
176
|
-
});
|
|
177
|
-
independentView.opacity = 0;
|
|
332
|
+
isPresented = true;
|
|
333
|
+
}
|
|
334
|
+
const independentSharedElement = independentView.ios;
|
|
335
|
+
if (pageEndProps?.callback) {
|
|
336
|
+
await pageEndProps?.callback(independentView, 'present');
|
|
178
337
|
}
|
|
338
|
+
const snapshot = UIImageView.alloc().initWithImage(iOSUtils.snapshotView(independentSharedElement, Screen.mainScreen.scale));
|
|
339
|
+
if (independentSharedElement instanceof UIImageView) {
|
|
340
|
+
snapshot.tintColor = independentSharedElement.tintColor;
|
|
341
|
+
snapshot.contentMode = independentSharedElement.contentMode;
|
|
342
|
+
}
|
|
343
|
+
snapshot.clipsToBounds = true;
|
|
344
|
+
// Copy layer properties (cornerRadius, borderWidth/Color)
|
|
345
|
+
// from the source view so the snapshot renders with the
|
|
346
|
+
// same rounded corners. Without this, source-side
|
|
347
|
+
// thumbnails/buttons appear with sharp square corners
|
|
348
|
+
// during a non-morph interactive dismiss — the snapshot
|
|
349
|
+
// is what the user sees through the dismissing modal,
|
|
350
|
+
// and its layer is freshly created with cornerRadius 0.
|
|
351
|
+
iOSUtils.copyLayerProperties(snapshot, independentSharedElement, pageEndProps?.propertiesToMatch);
|
|
352
|
+
const startFrame = independentSharedElement.convertRectToView(independentSharedElement.bounds, transitionContext.containerView);
|
|
353
|
+
snapshot.frame = startFrame;
|
|
354
|
+
if (SharedTransition.DEBUG) {
|
|
355
|
+
console.log('---> ', independentView.sharedTransitionTag, ' frame:', iOSUtils.printCGRect(snapshot.frame));
|
|
356
|
+
}
|
|
357
|
+
const endFrameRect = getRectFromProps(pageEndProps);
|
|
358
|
+
const endFrame = CGRectMake(startFrame.origin.x + (endFrameRect.x || 0), startFrame.origin.y + (endFrameRect.y || 0), startFrame.size.width, startFrame.size.height);
|
|
359
|
+
// Opacity defaults are side-aware: source-only orphans fade out (1 → 0),
|
|
360
|
+
// destination-only orphans fade in (0 → 1). The values are read back
|
|
361
|
+
// during dismiss as `endOpacity → startOpacity` so the return phase is
|
|
362
|
+
// automatically symmetric. Author-supplied opacity always wins.
|
|
363
|
+
const startOpacity = isNumber(pageStartIndependentProps?.opacity) ? pageStartIndependentProps.opacity : isPresented ? 0 : independentView.opacity;
|
|
364
|
+
const endOpacity = isNumber(pageEndProps?.opacity) ? pageEndProps.opacity : isPresented ? independentView.opacity : 0;
|
|
365
|
+
// Snapshot's initial visible alpha. Default UIImageView alpha is 1;
|
|
366
|
+
// destination-only orphans need to start at 0 so the fade-in is
|
|
367
|
+
// visible, hence we always set it explicitly.
|
|
368
|
+
snapshot.alpha = startOpacity;
|
|
369
|
+
transition.sharedElements.independent.push({
|
|
370
|
+
view: independentView,
|
|
371
|
+
isPresented,
|
|
372
|
+
startFrame,
|
|
373
|
+
snapshot,
|
|
374
|
+
endFrame,
|
|
375
|
+
startTransform: independentSharedElement.transform,
|
|
376
|
+
scale: pageEndProps?.scale,
|
|
377
|
+
startOpacity,
|
|
378
|
+
endOpacity,
|
|
379
|
+
propertiesToMatch: pageEndProps?.propertiesToMatch,
|
|
380
|
+
zIndex: isNumber(pageEndProps?.zIndex) ? pageEndProps.zIndex : 0,
|
|
381
|
+
});
|
|
382
|
+
// Native alpha; see comment in positionSharedTags.
|
|
383
|
+
independentSharedElement.alpha = 0;
|
|
179
384
|
}
|
|
180
385
|
};
|
|
181
386
|
// position all sharedTransitionTag elements
|
|
@@ -183,7 +388,7 @@ export class SharedTransitionHelper {
|
|
|
183
388
|
await positionIndependentTags();
|
|
184
389
|
// combine to order by zIndex and add to transition context
|
|
185
390
|
const snapshotData = transition.sharedElements.presenting.concat(transition.sharedElements.independent);
|
|
186
|
-
snapshotData.sort((a, b) => (a.zIndex
|
|
391
|
+
snapshotData.sort((a, b) => (a.zIndex || 0) - (b.zIndex || 0));
|
|
187
392
|
if (SharedTransition.DEBUG) {
|
|
188
393
|
console.log(`zIndex settings:`, snapshotData.map((s) => {
|
|
189
394
|
return {
|
|
@@ -199,16 +404,56 @@ export class SharedTransitionHelper {
|
|
|
199
404
|
// Important: always set after above shared element positions have had their start positions set
|
|
200
405
|
transition.presented.view.alpha = isNumber(pageStart?.opacity) ? pageStart?.opacity : 0;
|
|
201
406
|
transition.presented.view.frame = CGRectMake(startFrame.x, startFrame.y, startFrame.width, startFrame.height);
|
|
407
|
+
// Optional top-corner rounding for sheet-style transitions (e.g.
|
|
408
|
+
// a modal that's rounded at the bottom of the screen and flattens
|
|
409
|
+
// as it slides up). Setting maskedCorners and masksToBounds here
|
|
410
|
+
// (before the animation) so they're stable during the animated
|
|
411
|
+
// cornerRadius change.
|
|
412
|
+
if (isNumber(pageStart?.cornerRadius) || isNumber(pageEnd?.cornerRadius)) {
|
|
413
|
+
const layer = transition.presented.view.layer;
|
|
414
|
+
// top-left | top-right | bottom-left | bottom-right (CACornerMask bits)
|
|
415
|
+
layer.maskedCorners = 15;
|
|
416
|
+
layer.masksToBounds = true;
|
|
417
|
+
if (isNumber(pageStart?.cornerRadius)) {
|
|
418
|
+
layer.cornerRadius = pageStart.cornerRadius;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
202
421
|
const cleanupPresent = () => {
|
|
203
422
|
for (const presented of transition.sharedElements.presented) {
|
|
204
|
-
|
|
423
|
+
// Detach the per-transition imageSourceChange listener registered
|
|
424
|
+
// during positionSharedTags so it doesn't leak (the snapshot is gone).
|
|
425
|
+
if (presented.imageSourceChangeListener) {
|
|
426
|
+
presented.view.off('imageSourceChange', presented.imageSourceChangeListener);
|
|
427
|
+
presented.imageSourceChangeListener = null;
|
|
428
|
+
}
|
|
429
|
+
// Restore the destination native alpha from the NS opacity (the source
|
|
430
|
+
// of truth). NS opacity wasn't modified during the transition, so this
|
|
431
|
+
// reflects the user's intended visibility (typically 1).
|
|
432
|
+
presented.view.ios.alpha = presented.view.opacity;
|
|
433
|
+
}
|
|
434
|
+
// Restore native alpha on every source view we touched — including
|
|
435
|
+
// duplicates that share a sharedTransitionTag and were hidden without
|
|
436
|
+
// a snapshot. Even though the source page is being removed, the View
|
|
437
|
+
// instances may be reused on subsequent navigations.
|
|
438
|
+
for (const sourceView of transition.sharedElements._allPresentingViews || []) {
|
|
439
|
+
if (sourceView?.ios) {
|
|
440
|
+
sourceView.ios.alpha = sourceView.opacity;
|
|
441
|
+
}
|
|
205
442
|
}
|
|
206
443
|
for (const presenting of transition.sharedElements.presenting) {
|
|
207
444
|
presenting.snapshot.removeFromSuperview();
|
|
445
|
+
if (type === 'page') {
|
|
446
|
+
// the page we left is detached: give its views back so none stays hidden when it is shown again
|
|
447
|
+
// (the way back is not necessarily done with this transition instance nor with the same shared elements)
|
|
448
|
+
presenting.view.opacity = presenting.startOpacity;
|
|
449
|
+
}
|
|
208
450
|
}
|
|
209
451
|
for (const independent of transition.sharedElements.independent) {
|
|
210
452
|
independent.snapshot.removeFromSuperview();
|
|
211
453
|
if (independent.isPresented) {
|
|
454
|
+
independent.view.ios.alpha = independent.view.opacity;
|
|
455
|
+
}
|
|
456
|
+
else if (type === 'page') {
|
|
212
457
|
independent.view.opacity = independent.startOpacity;
|
|
213
458
|
}
|
|
214
459
|
}
|
|
@@ -232,6 +477,12 @@ export class SharedTransitionHelper {
|
|
|
232
477
|
transition.presented.view.alpha = isNumber(pageEnd?.opacity) ? pageEnd?.opacity : 1;
|
|
233
478
|
const endFrame = getRectFromProps(pageEnd);
|
|
234
479
|
transition.presented.view.frame = CGRectMake(endFrame.x, endFrame.y, endFrame.width, endFrame.height);
|
|
480
|
+
// Animate cornerRadius alongside the page frame. Implicit animation
|
|
481
|
+
// of cornerRadius is supported on iOS 11+, both inside
|
|
482
|
+
// UIView.animateWith… and UIViewPropertyAnimator's animations block.
|
|
483
|
+
if (isNumber(pageEnd?.cornerRadius)) {
|
|
484
|
+
transition.presented.view.layer.cornerRadius = pageEnd.cornerRadius;
|
|
485
|
+
}
|
|
235
486
|
if (pageOut) {
|
|
236
487
|
if (isNumber(pageOut.opacity)) {
|
|
237
488
|
transition.presenting.view.alpha = pageOut?.opacity;
|
|
@@ -248,8 +499,11 @@ export class SharedTransitionHelper {
|
|
|
248
499
|
// owner.presented.view.layoutIfNeeded();
|
|
249
500
|
for (const presented of transition.sharedElements.presented) {
|
|
250
501
|
const presentingMatch = transition.sharedElements.presenting.find((v) => v.view.sharedTransitionTag === presented.view.sharedTransitionTag);
|
|
502
|
+
if (!presentingMatch) {
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
251
505
|
// Workaround wrong origin due ongoing layout process.
|
|
252
|
-
const updatedEndFrame =
|
|
506
|
+
const updatedEndFrame = getDisplayedFrame(presented.view.ios, transitionContext.containerView);
|
|
253
507
|
const correctedEndFrame = CGRectMake(updatedEndFrame.origin.x, updatedEndFrame.origin.y, presentingMatch.endFrame.size.width, presentingMatch.endFrame.size.height);
|
|
254
508
|
presentingMatch.snapshot.frame = correctedEndFrame;
|
|
255
509
|
// apply view and layer properties to the snapshot view to match the source/presented view
|
|
@@ -310,23 +564,57 @@ export class SharedTransitionHelper {
|
|
|
310
564
|
});
|
|
311
565
|
if (type === 'page') {
|
|
312
566
|
transitionContext.containerView.insertSubviewBelowSubview(transition.presenting.view, transition.presented.view);
|
|
567
|
+
// UIKit's standard pop places the incoming source view off to the
|
|
568
|
+
// left so it can slide into position; for custom shared transitions
|
|
569
|
+
// (where the destination either slides down or morphs to source) we
|
|
570
|
+
// don't want that lateral slide. Pin the source to its fullscreen
|
|
571
|
+
// frame so it stays put underneath the animating destination.
|
|
572
|
+
// Users can still opt into a custom source animation via `pageOut`.
|
|
573
|
+
const sourceDefaults = getRectFromProps(null);
|
|
574
|
+
transition.presenting.view.frame = CGRectMake(0, 0, sourceDefaults.width, sourceDefaults.height);
|
|
575
|
+
}
|
|
576
|
+
// Morph + interactive dismiss: the gesture handler drives the
|
|
577
|
+
// animation via transforms and finalizes by calling cancel/finish
|
|
578
|
+
// on the transitionContext. Running the standard snapshot + spring
|
|
579
|
+
// rig here would race that and frequently call completeTransition(true)
|
|
580
|
+
// *before* the user's gesture ended — causing the dismiss to commit
|
|
581
|
+
// even on a cancel. Skip the rest of the dismiss setup entirely.
|
|
582
|
+
if (state.interactive?.dismiss?.morph && state.interactiveBegan) {
|
|
583
|
+
return;
|
|
313
584
|
}
|
|
314
585
|
// console.log('transitionContext.containerView.subviews.count:', transitionContext.containerView.subviews.count);
|
|
315
586
|
if (SharedTransition.DEBUG) {
|
|
316
587
|
console.log(` ${type}: Dismiss`);
|
|
317
|
-
console.log(`1. Dismiss sharedTransitionTags to animate:`, transition.sharedElements
|
|
588
|
+
console.log(`1. Dismiss sharedTransitionTags to animate:`, transition.sharedElements?.presented?.map((p) => p.view.sharedTransitionTag));
|
|
318
589
|
console.log(`2. Add back previously stored sharedElements to dismiss:`);
|
|
319
590
|
}
|
|
320
591
|
const pageOut = state.pageOut;
|
|
321
592
|
const pageEnd = state.pageEnd;
|
|
322
593
|
const pageEndTags = pageEnd?.sharedTransitionTags || {};
|
|
323
594
|
const pageReturn = state.pageReturn;
|
|
595
|
+
if (type === 'page') {
|
|
596
|
+
// rebuild from what is currently shown instead of replaying what was recorded on the way in
|
|
597
|
+
SharedTransitionHelper.rebuildDismissElements(state, transitionContext);
|
|
598
|
+
}
|
|
599
|
+
else if (!transition.sharedElements) {
|
|
600
|
+
transition.sharedElements = { presented: [], presenting: [], independent: [] };
|
|
601
|
+
}
|
|
324
602
|
for (const p of transition.sharedElements.presented) {
|
|
325
|
-
|
|
603
|
+
// Use native alpha (not NS opacity) so we don't pollute the NS-side
|
|
604
|
+
// value if the dismiss is interrupted; cleanup restores from NS opacity.
|
|
605
|
+
p.view.ios.alpha = 0;
|
|
606
|
+
}
|
|
607
|
+
// Ensure top-corner masking + clipping is in place before we animate
|
|
608
|
+
// cornerRadius back toward the start value. If the present pass already
|
|
609
|
+
// set these, this is a harmless no-op.
|
|
610
|
+
if (isNumber(pageReturn?.cornerRadius)) {
|
|
611
|
+
const layer = transition.presented.view.layer;
|
|
612
|
+
layer.maskedCorners = 15; // top-left | top-right | bottom-left | bottom-right
|
|
613
|
+
layer.masksToBounds = true;
|
|
326
614
|
}
|
|
327
615
|
// combine to order by zIndex and add to transition context
|
|
328
616
|
const snapshotData = transition.sharedElements.presenting.concat(transition.sharedElements.independent);
|
|
329
|
-
snapshotData.sort((a, b) => (a.zIndex
|
|
617
|
+
snapshotData.sort((a, b) => (a.zIndex || 0) - (b.zIndex || 0));
|
|
330
618
|
if (SharedTransition.DEBUG) {
|
|
331
619
|
console.log(`zIndex settings:`, snapshotData.map((s) => {
|
|
332
620
|
return {
|
|
@@ -344,6 +632,11 @@ export class SharedTransitionHelper {
|
|
|
344
632
|
}
|
|
345
633
|
// now that all the callbacks had their chance to run, we can take the snapshots
|
|
346
634
|
for (const data of snapshotData) {
|
|
635
|
+
if (data.rebuilt) {
|
|
636
|
+
// snapshot of the popped view already taken and positioned
|
|
637
|
+
transitionContext.containerView.addSubview(data.snapshot);
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
347
640
|
const view = data.view.ios;
|
|
348
641
|
const currentAlpha = view.alpha;
|
|
349
642
|
if (pageReturn?.useStartOpacity) {
|
|
@@ -365,13 +658,43 @@ export class SharedTransitionHelper {
|
|
|
365
658
|
// add snapshot to animate
|
|
366
659
|
transitionContext.containerView.addSubview(data.snapshot);
|
|
367
660
|
}
|
|
661
|
+
// Hide every source-side shared element now that snapshots have been
|
|
662
|
+
// captured. The animating snapshot covers them; without this, the user
|
|
663
|
+
// sees a "double image" — the real source element AND the snapshot
|
|
664
|
+
// animating over it back to its position. Use the full list (not just
|
|
665
|
+
// the deduped `presenting`) so duplicates from sister lists are hidden
|
|
666
|
+
// too. Restored in cleanupDismiss below.
|
|
667
|
+
for (const sourceView of transition.sharedElements._allPresentingViews || []) {
|
|
668
|
+
if (sourceView?.ios) {
|
|
669
|
+
sourceView.ios.alpha = 0;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
368
672
|
const cleanupDismiss = () => {
|
|
673
|
+
// Restore alpha on every source view we hid — including duplicate
|
|
674
|
+
// sources with the same sharedTransitionTag — using NS opacity as
|
|
675
|
+
// the source of truth.
|
|
676
|
+
for (const sourceView of transition.sharedElements._allPresentingViews || []) {
|
|
677
|
+
if (sourceView?.ios) {
|
|
678
|
+
sourceView.ios.alpha = sourceView.opacity;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
369
681
|
for (const presenting of transition.sharedElements.presenting) {
|
|
370
|
-
presenting.view.opacity = presenting.startOpacity;
|
|
371
682
|
presenting.snapshot.removeFromSuperview();
|
|
372
683
|
}
|
|
684
|
+
for (const presented of transition.sharedElements.presented) {
|
|
685
|
+
// Detach the imageSourceChange listener and restore alpha. Even though
|
|
686
|
+
// the destination page is being torn down, NS Views can outlive their
|
|
687
|
+
// nativeView and we shouldn't leak observers.
|
|
688
|
+
if (presented.imageSourceChangeListener) {
|
|
689
|
+
presented.view.off('imageSourceChange', presented.imageSourceChangeListener);
|
|
690
|
+
presented.imageSourceChangeListener = null;
|
|
691
|
+
}
|
|
692
|
+
if (presented.view.ios) {
|
|
693
|
+
presented.view.ios.alpha = presented.view.opacity;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
373
696
|
for (const independent of transition.sharedElements.independent) {
|
|
374
|
-
independent.view.
|
|
697
|
+
independent.view.ios.alpha = independent.view.opacity;
|
|
375
698
|
independent.snapshot.removeFromSuperview();
|
|
376
699
|
}
|
|
377
700
|
SharedTransition.finishState(transition.id);
|
|
@@ -390,6 +713,11 @@ export class SharedTransitionHelper {
|
|
|
390
713
|
transition.presented.view.alpha = isNumber(pageReturn?.opacity) ? pageReturn?.opacity : 0;
|
|
391
714
|
const endFrame = getRectFromProps(pageReturn, getPageStartDefaultsForType(type));
|
|
392
715
|
transition.presented.view.frame = CGRectMake(endFrame.x, endFrame.y, endFrame.width, endFrame.height);
|
|
716
|
+
// Animate cornerRadius back toward the start value (e.g. a sheet
|
|
717
|
+
// re-rounds as it slides offscreen).
|
|
718
|
+
if (isNumber(pageReturn?.cornerRadius)) {
|
|
719
|
+
transition.presented.view.layer.cornerRadius = pageReturn.cornerRadius;
|
|
720
|
+
}
|
|
393
721
|
if (pageOut) {
|
|
394
722
|
// always return to defaults if pageOut had been used
|
|
395
723
|
transition.presenting.view.alpha = 1;
|
|
@@ -439,8 +767,147 @@ export class SharedTransitionHelper {
|
|
|
439
767
|
break;
|
|
440
768
|
}
|
|
441
769
|
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Called when the animation setup threw: put everything back in a sane state and always complete the transition,
|
|
774
|
+
* otherwise UIKit stays in the middle of the navigation transition.
|
|
775
|
+
*/
|
|
776
|
+
static recover(state, transitionContext, type, error) {
|
|
777
|
+
const transition = state.instance;
|
|
778
|
+
console.error(`SharedTransition (${state.activeType === SharedTransitionAnimationType.present ? 'present' : 'dismiss'}) failed, completing the transition without animation:`, error);
|
|
779
|
+
const isPresent = state.activeType === SharedTransitionAnimationType.present;
|
|
780
|
+
try {
|
|
781
|
+
const elements = transition?.sharedElements;
|
|
782
|
+
if (elements) {
|
|
783
|
+
for (const p of elements.presented || []) {
|
|
784
|
+
p.view.opacity = isNumber(p.startOpacity) ? p.startOpacity : 1;
|
|
785
|
+
}
|
|
786
|
+
for (const p of elements.presenting || []) {
|
|
787
|
+
p.view.opacity = isNumber(p.startOpacity) ? p.startOpacity : 1;
|
|
788
|
+
p.snapshot?.removeFromSuperview();
|
|
789
|
+
}
|
|
790
|
+
for (const p of elements.independent || []) {
|
|
791
|
+
p.view.opacity = isNumber(p.startOpacity) ? p.startOpacity : 1;
|
|
792
|
+
p.snapshot?.removeFromSuperview();
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
if (type === 'page') {
|
|
796
|
+
const shown = isPresent ? transition.presented : transition.presenting;
|
|
797
|
+
if (shown?.view) {
|
|
798
|
+
shown.view.alpha = 1;
|
|
799
|
+
const frame = getRectFromProps(isPresent ? state.pageEnd : null);
|
|
800
|
+
shown.view.frame = CGRectMake(frame.x, frame.y, frame.width, frame.height);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
catch (err) {
|
|
805
|
+
if (Trace.isEnabled()) {
|
|
806
|
+
Trace.write(`SharedTransition recover failed: ${err}`, Trace.categories.Transition, Trace.messageType.error);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
if (isPresent) {
|
|
810
|
+
SharedTransition.updateState(transition.id, { activeType: SharedTransitionAnimationType.dismiss });
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
SharedTransition.finishState(transition.id);
|
|
814
|
+
transition.sharedElements = null;
|
|
815
|
+
}
|
|
816
|
+
// when the user cancelled (interactive pop) we must report it, otherwise the navigation controller is left inconsistent
|
|
817
|
+
transitionContext.completeTransition(!transitionContext.transitionWasCancelled);
|
|
818
|
+
SharedTransition.notifyEvent(SharedTransition.finishedEvent, {
|
|
819
|
+
id: transition.id,
|
|
820
|
+
type,
|
|
821
|
+
action: isPresent ? 'present' : 'dismiss',
|
|
442
822
|
});
|
|
443
823
|
}
|
|
824
|
+
/**
|
|
825
|
+
* Rebuilds the shared elements to animate on the way back from the pages that are currently shown.
|
|
826
|
+
* The elements recorded on the way in can not be reused: the popped page might now show another photo (same tag
|
|
827
|
+
* pattern, other value) or its views might have been recycled, and the transition passed to goBack can be a new instance.
|
|
828
|
+
*/
|
|
829
|
+
static rebuildDismissElements(state, transitionContext) {
|
|
830
|
+
const transition = state.instance;
|
|
831
|
+
// roles are set from the navigation operation (see PageTransition.iosNavigatedController)
|
|
832
|
+
const poppedPage = getControllerPage(transition.presented);
|
|
833
|
+
const returnPage = state.page ?? getControllerPage(transition.presenting);
|
|
834
|
+
const previous = transition.sharedElements;
|
|
835
|
+
const presenting = [];
|
|
836
|
+
const presented = [];
|
|
837
|
+
const pageEndTags = state.pageEnd?.sharedTransitionTags || {};
|
|
838
|
+
const containerView = transitionContext.containerView;
|
|
839
|
+
// the page we go back to was removed from the container during the present
|
|
840
|
+
transition.presenting?.view?.layoutIfNeeded();
|
|
841
|
+
if (SharedTransition.DEBUG) {
|
|
842
|
+
console.log(`Dismiss: popped page ${poppedPage}, return page ${returnPage}`);
|
|
843
|
+
}
|
|
844
|
+
if (poppedPage && returnPage) {
|
|
845
|
+
const { sharedElements, presented: poppedViews } = SharedTransition.getSharedElements(returnPage, poppedPage);
|
|
846
|
+
if (SharedTransition.DEBUG) {
|
|
847
|
+
console.log(`Dismiss: tags on return page ${sharedElements.map((v) => v.sharedTransitionTag)}, on popped page ${poppedViews.map((v) => v.sharedTransitionTag)}`);
|
|
848
|
+
}
|
|
849
|
+
const tagFilter = state.pageStart?.sharedTransitionTags ? Object.keys(state.pageStart.sharedTransitionTags) : null;
|
|
850
|
+
for (const returnView of sharedElements) {
|
|
851
|
+
const tag = returnView.sharedTransitionTag;
|
|
852
|
+
if (tagFilter?.length && tagFilter.indexOf(tag) === -1) {
|
|
853
|
+
continue;
|
|
854
|
+
}
|
|
855
|
+
const poppedView = poppedViews.find((v) => v.sharedTransitionTag === tag);
|
|
856
|
+
const returnNative = returnView.ios;
|
|
857
|
+
const poppedNative = poppedView?.ios;
|
|
858
|
+
if (!returnNative || !poppedNative || !poppedNative.window) {
|
|
859
|
+
continue;
|
|
860
|
+
}
|
|
861
|
+
const pageEndProps = pageEndTags[tag];
|
|
862
|
+
const recorded = previous?.presenting?.find((p) => p.view === returnView);
|
|
863
|
+
// the view was hidden on the way in
|
|
864
|
+
const startOpacity = recorded ? recorded.startOpacity : returnView.opacity > 0 ? returnView.opacity : 1;
|
|
865
|
+
const poppedFrame = getDisplayedFrame(poppedNative, containerView);
|
|
866
|
+
const returnFrame = getDisplayedFrame(returnNative, containerView);
|
|
867
|
+
const snapshot = UIImageView.alloc().init();
|
|
868
|
+
if (poppedNative instanceof UIImageView) {
|
|
869
|
+
snapshot.tintColor = poppedNative.tintColor;
|
|
870
|
+
snapshot.contentMode = getSnapshotContentMode(returnNative, poppedNative);
|
|
871
|
+
}
|
|
872
|
+
snapshot.image = iOSUtils.snapshotView(poppedNative, Screen.mainScreen.scale);
|
|
873
|
+
iOSUtils.copyLayerProperties(snapshot, poppedNative, pageEndProps?.propertiesToMatch);
|
|
874
|
+
snapshot.clipsToBounds = true;
|
|
875
|
+
snapshot.frame = poppedFrame;
|
|
876
|
+
snapshot.alpha = poppedView.opacity;
|
|
877
|
+
presenting.push({
|
|
878
|
+
view: returnView,
|
|
879
|
+
startFrame: returnFrame,
|
|
880
|
+
endFrame: poppedFrame,
|
|
881
|
+
snapshot,
|
|
882
|
+
startOpacity,
|
|
883
|
+
endOpacity: poppedView.opacity,
|
|
884
|
+
propertiesToMatch: pageEndProps?.propertiesToMatch,
|
|
885
|
+
zIndex: isNumber(pageEndProps?.zIndex) ? pageEndProps.zIndex : 0,
|
|
886
|
+
rebuilt: true,
|
|
887
|
+
});
|
|
888
|
+
presented.push({
|
|
889
|
+
view: poppedView,
|
|
890
|
+
startFrame: poppedFrame,
|
|
891
|
+
endFrame: returnFrame,
|
|
892
|
+
startOpacity: poppedView.opacity,
|
|
893
|
+
endOpacity: startOpacity,
|
|
894
|
+
propertiesToMatch: pageEndProps?.propertiesToMatch,
|
|
895
|
+
});
|
|
896
|
+
// hide both while animating within the transition context
|
|
897
|
+
returnView.opacity = 0;
|
|
898
|
+
poppedView.opacity = 0;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
// independent elements are only recorded on the way in
|
|
902
|
+
transition.sharedElements = {
|
|
903
|
+
presented,
|
|
904
|
+
presenting,
|
|
905
|
+
independent: previous?.independent || [],
|
|
906
|
+
};
|
|
907
|
+
for (const independent of transition.sharedElements.independent) {
|
|
908
|
+
independent.view.opacity = 0;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
444
911
|
static interactiveStart(state, interactiveState, type) {
|
|
445
912
|
SharedTransition.notifyEvent(SharedTransition.startedEvent, {
|
|
446
913
|
id: state.instance.id,
|
|
@@ -450,20 +917,79 @@ export class SharedTransitionHelper {
|
|
|
450
917
|
switch (type) {
|
|
451
918
|
case 'page':
|
|
452
919
|
interactiveState.transitionContext.containerView.insertSubviewBelowSubview(state.instance.presenting.view, state.instance.presented.view);
|
|
920
|
+
// Pin the source view to its fullscreen frame so it doesn't slide
|
|
921
|
+
// in from off-left as the user drags. The default UIKit pop expects
|
|
922
|
+
// to animate the source from off-left; for shared-element / morph
|
|
923
|
+
// transitions we want the source to stay put underneath the
|
|
924
|
+
// animating destination so the visuals feel connected.
|
|
925
|
+
{
|
|
926
|
+
const sourceDefaults = getRectFromProps(null);
|
|
927
|
+
state.instance.presenting.view.frame = CGRectMake(0, 0, sourceDefaults.width, sourceDefaults.height);
|
|
928
|
+
}
|
|
929
|
+
SharedTransitionHelper.rebuildDismissElements(state, interactiveState.transitionContext);
|
|
453
930
|
break;
|
|
454
931
|
}
|
|
932
|
+
// Apply the dismiss shadow here, not from the gesture handler. UIKit
|
|
933
|
+
// reparents the presented view into the transition containerView as
|
|
934
|
+
// part of starting the interactive transition; applying earlier would
|
|
935
|
+
// attach the shadow to the now-orphaned old superlayer.
|
|
936
|
+
if (state.interactive?.dismiss?.shadow && state.instance?.presented?.view) {
|
|
937
|
+
applyInteractiveDismissShadow(state.instance.presented.view, state.interactive.dismiss.shadow);
|
|
938
|
+
}
|
|
455
939
|
}
|
|
456
940
|
static interactiveUpdate(state, interactiveState, type, percent) {
|
|
457
941
|
if (interactiveState) {
|
|
942
|
+
if (state.interactive?.dismiss?.morph) {
|
|
943
|
+
// Morph mode: the gesture handler drives the destination view's
|
|
944
|
+
// transform directly. We only forward the event so observers can
|
|
945
|
+
// react to the gesture's percentage.
|
|
946
|
+
SharedTransition.notifyEvent(SharedTransition.interactiveUpdateEvent, {
|
|
947
|
+
id: state?.instance?.id,
|
|
948
|
+
type,
|
|
949
|
+
percent,
|
|
950
|
+
});
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
458
953
|
if (!interactiveState.added) {
|
|
954
|
+
// Defer setup until the gesture has clearly committed to a horizontal
|
|
955
|
+
// dismiss motion. A vertical scroll on a descendant scroll view also
|
|
956
|
+
// triggers the page-level pan gesture (NS pan recognizers don't yield
|
|
957
|
+
// to scroll-view pans by default), producing near-zero percent values.
|
|
958
|
+
// Without this guard we'd mount the dismiss snapshots and hide the
|
|
959
|
+
// destination during a scroll, making the image look "stuck" until the
|
|
960
|
+
// cancel animation runs.
|
|
961
|
+
if (Math.abs(percent) < 0.05) {
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
459
964
|
interactiveState.added = true;
|
|
460
965
|
for (const p of state.instance.sharedElements.presented) {
|
|
461
|
-
|
|
966
|
+
// Native alpha (not NS opacity) for the same reason as the dismiss path:
|
|
967
|
+
// if the user lets go without crossing the threshold, cancel uses NS
|
|
968
|
+
// opacity as source of truth to restore.
|
|
969
|
+
p.view.ios.alpha = 0;
|
|
462
970
|
}
|
|
463
971
|
for (const p of state.instance.sharedElements.presenting) {
|
|
464
972
|
p.snapshot.alpha = p.endOpacity;
|
|
465
973
|
interactiveState.transitionContext.containerView.addSubview(p.snapshot);
|
|
466
974
|
}
|
|
975
|
+
// Re-mount independent (orphan) snapshots so they're available to
|
|
976
|
+
// animate alongside the gesture. They were removed in present cleanup
|
|
977
|
+
// but the records (including their snapshots) live on transition.sharedElements.
|
|
978
|
+
// Source-only orphans were left at alpha 0 since present; their snapshots
|
|
979
|
+
// pick up where the present animation left off (endOpacity).
|
|
980
|
+
for (const ind of state.instance.sharedElements.independent) {
|
|
981
|
+
ind.snapshot.alpha = ind.endOpacity;
|
|
982
|
+
interactiveState.transitionContext.containerView.addSubview(ind.snapshot);
|
|
983
|
+
}
|
|
984
|
+
// Hide every source-side shared element (including duplicates that share
|
|
985
|
+
// a sharedTransitionTag in sister lists) so the user only sees the
|
|
986
|
+
// animating snapshot — not the snapshot AND the real source element
|
|
987
|
+
// simultaneously ("double image" during interactive dismissal).
|
|
988
|
+
for (const sourceView of state.instance.sharedElements._allPresentingViews || []) {
|
|
989
|
+
if (sourceView?.ios) {
|
|
990
|
+
sourceView.ios.alpha = 0;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
467
993
|
const pageStart = state.pageStart;
|
|
468
994
|
const startFrame = getRectFromProps(pageStart, getPageStartDefaultsForType(type));
|
|
469
995
|
interactiveState.propertyAnimator = UIViewPropertyAnimator.alloc().initWithDurationDampingRatioAnimations(1, 1, () => {
|
|
@@ -472,8 +998,25 @@ export class SharedTransitionHelper {
|
|
|
472
998
|
iOSUtils.copyLayerProperties(p.snapshot, p.view.ios, p.propertiesToMatch);
|
|
473
999
|
p.snapshot.alpha = 1;
|
|
474
1000
|
}
|
|
1001
|
+
// Animate orphan snapshots back toward their start state alongside
|
|
1002
|
+
// the rest of the dismiss. For source-only orphans this is the
|
|
1003
|
+
// fade-back-in that mirrors the fade-out of present.
|
|
1004
|
+
for (const ind of state.instance.sharedElements.independent) {
|
|
1005
|
+
ind.snapshot.alpha = ind.startOpacity;
|
|
1006
|
+
if (ind.scale) {
|
|
1007
|
+
ind.snapshot.transform = ind.startTransform;
|
|
1008
|
+
}
|
|
1009
|
+
else {
|
|
1010
|
+
ind.snapshot.frame = ind.startFrame;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
475
1013
|
state.instance.presented.view.alpha = isNumber(state.pageReturn?.opacity) ? state.pageReturn?.opacity : 0;
|
|
476
1014
|
state.instance.presented.view.frame = CGRectMake(startFrame.x, startFrame.y, state.instance.presented.view.bounds.size.width, state.instance.presented.view.bounds.size.height);
|
|
1015
|
+
// Drive cornerRadius via the same percent the user controls — round
|
|
1016
|
+
// the page back up as they pan it offscreen.
|
|
1017
|
+
if (isNumber(state.pageReturn?.cornerRadius)) {
|
|
1018
|
+
state.instance.presented.view.layer.cornerRadius = state.pageReturn.cornerRadius;
|
|
1019
|
+
}
|
|
477
1020
|
});
|
|
478
1021
|
}
|
|
479
1022
|
interactiveState.propertyAnimator.fractionComplete = percent;
|
|
@@ -485,17 +1028,108 @@ export class SharedTransitionHelper {
|
|
|
485
1028
|
}
|
|
486
1029
|
}
|
|
487
1030
|
static interactiveCancel(state, interactiveState, type) {
|
|
1031
|
+
if (state?.instance && interactiveState && state.interactive?.dismiss?.morph) {
|
|
1032
|
+
// Morph mode cancel — spring the destination view back to identity.
|
|
1033
|
+
const view = state.instance.presented?.view;
|
|
1034
|
+
let didFinalize = false;
|
|
1035
|
+
const finalize = () => {
|
|
1036
|
+
if (didFinalize)
|
|
1037
|
+
return;
|
|
1038
|
+
didFinalize = true;
|
|
1039
|
+
if (view)
|
|
1040
|
+
view.transform = CGAffineTransformIdentity;
|
|
1041
|
+
// Restore the source-side element alphas that the gesture hid on
|
|
1042
|
+
// engagement so the source page is correct when shown again.
|
|
1043
|
+
for (const v of state.instance.sharedElements?._allPresentingViews || []) {
|
|
1044
|
+
if (v?.ios)
|
|
1045
|
+
v.ios.alpha = v.opacity;
|
|
1046
|
+
}
|
|
1047
|
+
if (interactiveState.transitionContext) {
|
|
1048
|
+
interactiveState.transitionContext.cancelInteractiveTransition();
|
|
1049
|
+
interactiveState.transitionContext.completeTransition(false);
|
|
1050
|
+
}
|
|
1051
|
+
SharedTransition.updateState(state?.instance?.id, {
|
|
1052
|
+
interactiveBegan: false,
|
|
1053
|
+
interactiveCancelled: true,
|
|
1054
|
+
});
|
|
1055
|
+
SharedTransition.notifyEvent(SharedTransition.interactiveCancelledEvent, {
|
|
1056
|
+
id: state?.instance?.id,
|
|
1057
|
+
type,
|
|
1058
|
+
});
|
|
1059
|
+
};
|
|
1060
|
+
if (view) {
|
|
1061
|
+
iOSUtils.animateWithSpring({
|
|
1062
|
+
animations: () => {
|
|
1063
|
+
view.transform = CGAffineTransformIdentity;
|
|
1064
|
+
// Cross-fade sources back IN PARALLEL with the spring so
|
|
1065
|
+
// they're visible from frame one of the snap-back. This
|
|
1066
|
+
// also makes the source restoration robust to a new
|
|
1067
|
+
// gesture interrupting our completion callback.
|
|
1068
|
+
for (const v of state.instance.sharedElements?._allPresentingViews || []) {
|
|
1069
|
+
if (v?.ios)
|
|
1070
|
+
v.ios.alpha = v.opacity;
|
|
1071
|
+
}
|
|
1072
|
+
},
|
|
1073
|
+
completion: () => finalize(),
|
|
1074
|
+
});
|
|
1075
|
+
// Safety: ensure finalize runs even if the animation completion
|
|
1076
|
+
// is dropped (e.g. interrupted by another gesture).
|
|
1077
|
+
setTimeout(finalize, 800);
|
|
1078
|
+
}
|
|
1079
|
+
else {
|
|
1080
|
+
finalize();
|
|
1081
|
+
}
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
if (state?.instance && interactiveState && !interactiveState.added) {
|
|
1085
|
+
// The gesture engaged the interactive transition but never crossed the
|
|
1086
|
+
// motion threshold in interactiveUpdate (e.g., the user was scrolling
|
|
1087
|
+
// vertically). Nothing was visually set up — just tell UIKit we're
|
|
1088
|
+
// cancelling and clear the flags.
|
|
1089
|
+
if (interactiveState.transitionContext) {
|
|
1090
|
+
interactiveState.transitionContext.cancelInteractiveTransition();
|
|
1091
|
+
interactiveState.transitionContext.completeTransition(false);
|
|
1092
|
+
}
|
|
1093
|
+
SharedTransition.updateState(state?.instance?.id, {
|
|
1094
|
+
interactiveBegan: false,
|
|
1095
|
+
interactiveCancelled: true,
|
|
1096
|
+
});
|
|
1097
|
+
SharedTransition.notifyEvent(SharedTransition.interactiveCancelledEvent, {
|
|
1098
|
+
id: state?.instance?.id,
|
|
1099
|
+
type,
|
|
1100
|
+
});
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
488
1103
|
if (state?.instance && interactiveState?.added && interactiveState?.propertyAnimator) {
|
|
489
1104
|
interactiveState.propertyAnimator.reversed = true;
|
|
490
1105
|
const duration = isNumber(state.pageEnd?.duration) ? state.pageEnd?.duration / 1000 : CORE_ANIMATION_DEFAULTS.duration;
|
|
491
1106
|
interactiveState.propertyAnimator.continueAnimationWithTimingParametersDurationFactor(null, duration);
|
|
492
1107
|
setTimeout(() => {
|
|
493
1108
|
for (const p of state.instance.sharedElements.presented) {
|
|
494
|
-
|
|
1109
|
+
// Restore native alpha from NS opacity (the user-intended value).
|
|
1110
|
+
p.view.ios.alpha = p.view.opacity;
|
|
1111
|
+
}
|
|
1112
|
+
// Restore alpha on every source view we hid during interactiveUpdate
|
|
1113
|
+
// (including duplicates from sister lists).
|
|
1114
|
+
for (const sourceView of state.instance.sharedElements._allPresentingViews || []) {
|
|
1115
|
+
if (sourceView?.ios) {
|
|
1116
|
+
sourceView.ios.alpha = sourceView.opacity;
|
|
1117
|
+
}
|
|
495
1118
|
}
|
|
496
1119
|
for (const p of state.instance.sharedElements.presenting) {
|
|
497
1120
|
p.snapshot.removeFromSuperview();
|
|
498
1121
|
}
|
|
1122
|
+
// Tear down orphan snapshots that interactiveUpdate re-mounted. The
|
|
1123
|
+
// source-only orphans' view.alpha stays at 0 — we're returning to the
|
|
1124
|
+
// presented (modal-on-top) state, so they should remain hidden until
|
|
1125
|
+
// a real dismiss completes. Cancel/finish for the next dismiss owns
|
|
1126
|
+
// the eventual restore.
|
|
1127
|
+
for (const ind of state.instance.sharedElements.independent) {
|
|
1128
|
+
ind.snapshot.removeFromSuperview();
|
|
1129
|
+
// Reset snapshot alpha to its post-present end state so a subsequent
|
|
1130
|
+
// interactiveUpdate picks up from the right place.
|
|
1131
|
+
ind.snapshot.alpha = ind.endOpacity;
|
|
1132
|
+
}
|
|
499
1133
|
state.instance.presented.view.alpha = 1;
|
|
500
1134
|
interactiveState.propertyAnimator = null;
|
|
501
1135
|
interactiveState.added = false;
|
|
@@ -513,15 +1147,263 @@ export class SharedTransitionHelper {
|
|
|
513
1147
|
}
|
|
514
1148
|
}
|
|
515
1149
|
static interactiveFinish(state, interactiveState, type) {
|
|
1150
|
+
if (state?.instance && interactiveState && state.interactive?.dismiss?.morph) {
|
|
1151
|
+
// Morph mode finish — animate the destination view to the matching
|
|
1152
|
+
// source element's frame and fade it out, then complete.
|
|
1153
|
+
const view = state.instance.presented?.view;
|
|
1154
|
+
const destPresented = state.instance.sharedElements?.presented?.[0];
|
|
1155
|
+
const destTag = destPresented?.view?.sharedTransitionTag;
|
|
1156
|
+
const matchingSource = state.instance.sharedElements?.presenting?.find?.((p) => p.view.sharedTransitionTag === destTag);
|
|
1157
|
+
const srcIos = matchingSource?.view?.ios;
|
|
1158
|
+
const destSharedIos = destPresented?.view?.ios;
|
|
1159
|
+
const containerView = interactiveState.transitionContext?.containerView;
|
|
1160
|
+
let targetTransform = null;
|
|
1161
|
+
if (view && srcIos && containerView) {
|
|
1162
|
+
const sourceFrame = srcIos.convertRectToView(srcIos.bounds, containerView);
|
|
1163
|
+
const bounds = view.bounds;
|
|
1164
|
+
if (bounds.size.width > 0 && bounds.size.height > 0 && sourceFrame.size.width > 0 && sourceFrame.size.height > 0) {
|
|
1165
|
+
// Anchor the modal's transform on the *internal* matched
|
|
1166
|
+
// element (e.g. the album art inside the modal) so that the
|
|
1167
|
+
// modal and the matched element converge along the same
|
|
1168
|
+
// trajectory to the source thumbnail. Without this, the modal
|
|
1169
|
+
// scales around its own center while the matched-element
|
|
1170
|
+
// snapshot flies separately to source — making the two visibly
|
|
1171
|
+
// drift apart mid-spring.
|
|
1172
|
+
//
|
|
1173
|
+
// Pick a uniform scale that takes the modal's matched element
|
|
1174
|
+
// to the source's size. For square album art (both sides) this
|
|
1175
|
+
// is exact; for slightly off-square sources (e.g. 360×380) we
|
|
1176
|
+
// match width and let the small remainder be hidden by the
|
|
1177
|
+
// fade-out.
|
|
1178
|
+
const destSharedFrameInModal = destSharedIos ? destSharedIos.convertRectToView(destSharedIos.bounds, view) : null;
|
|
1179
|
+
const sx = sourceFrame.size.width / bounds.size.width;
|
|
1180
|
+
const sy = sourceFrame.size.height / bounds.size.height;
|
|
1181
|
+
const targetCx = sourceFrame.origin.x + sourceFrame.size.width / 2;
|
|
1182
|
+
const targetCy = sourceFrame.origin.y + sourceFrame.size.height / 2;
|
|
1183
|
+
const modalCx = bounds.size.width / 2;
|
|
1184
|
+
const modalCy = bounds.size.height / 2;
|
|
1185
|
+
let tx;
|
|
1186
|
+
let ty;
|
|
1187
|
+
if (destSharedFrameInModal && destSharedFrameInModal.size.width > 0 && destSharedFrameInModal.size.height > 0) {
|
|
1188
|
+
// Place the internal album art's center on the source's
|
|
1189
|
+
// center. After scaling around modal center, internal art's
|
|
1190
|
+
// visual center = modalCenter + (internalArtCenter - modalCenter) * scale + translation.
|
|
1191
|
+
const internalCx = destSharedFrameInModal.origin.x + destSharedFrameInModal.size.width / 2;
|
|
1192
|
+
const internalCy = destSharedFrameInModal.origin.y + destSharedFrameInModal.size.height / 2;
|
|
1193
|
+
tx = targetCx - modalCx - (internalCx - modalCx) * sx;
|
|
1194
|
+
ty = targetCy - modalCy - (internalCy - modalCy) * sy;
|
|
1195
|
+
}
|
|
1196
|
+
else {
|
|
1197
|
+
// Fallback: align modal center on source center.
|
|
1198
|
+
tx = targetCx - modalCx;
|
|
1199
|
+
ty = targetCy - modalCy;
|
|
1200
|
+
}
|
|
1201
|
+
targetTransform = CGAffineTransformConcat(CGAffineTransformMakeTranslation(tx, ty), CGAffineTransformMakeScale(sx, sy));
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
// Build a snapshot fly-back for each shared element so the album
|
|
1205
|
+
// art (etc.) does a real shared-element transition to its source
|
|
1206
|
+
// frame in parallel with the destination view's shrink+fade.
|
|
1207
|
+
// Without this, the image rides along with the morphing view and
|
|
1208
|
+
// lands at a visually offset position rather than precisely back
|
|
1209
|
+
// at the source thumbnail.
|
|
1210
|
+
const sharedSnapshots = [];
|
|
1211
|
+
if (containerView) {
|
|
1212
|
+
for (const presented of state.instance.sharedElements?.presented || []) {
|
|
1213
|
+
const destSharedView = presented.view?.ios;
|
|
1214
|
+
const tag = presented.view?.sharedTransitionTag;
|
|
1215
|
+
if (!destSharedView || !tag)
|
|
1216
|
+
continue;
|
|
1217
|
+
const sourceShared = state.instance.sharedElements?.presenting?.find?.((p) => p.view.sharedTransitionTag === tag);
|
|
1218
|
+
const srcSharedView = sourceShared?.view?.ios;
|
|
1219
|
+
if (!srcSharedView)
|
|
1220
|
+
continue;
|
|
1221
|
+
const startFrame = destSharedView.convertRectToView(destSharedView.bounds, containerView);
|
|
1222
|
+
const endFrame = srcSharedView.convertRectToView(srcSharedView.bounds, containerView);
|
|
1223
|
+
if (startFrame.size.width <= 0 || endFrame.size.width <= 0)
|
|
1224
|
+
continue;
|
|
1225
|
+
const snap = UIImageView.alloc().init();
|
|
1226
|
+
if (destSharedView instanceof UIImageView && destSharedView.image) {
|
|
1227
|
+
snap.image = destSharedView.image;
|
|
1228
|
+
snap.contentMode = destSharedView.contentMode;
|
|
1229
|
+
snap.tintColor = destSharedView.tintColor;
|
|
1230
|
+
}
|
|
1231
|
+
else {
|
|
1232
|
+
try {
|
|
1233
|
+
snap.image = iOSUtils.snapshotView(presented.view.ios, Screen.mainScreen.scale);
|
|
1234
|
+
}
|
|
1235
|
+
catch (e) {
|
|
1236
|
+
continue;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
snap.clipsToBounds = true;
|
|
1240
|
+
snap.layer.cornerRadius = destSharedView.layer?.cornerRadius || 0;
|
|
1241
|
+
snap.frame = startFrame;
|
|
1242
|
+
containerView.addSubview(snap);
|
|
1243
|
+
// Hide the destination shared element so we don't see it
|
|
1244
|
+
// shrinking inside the morphing view at the same time the
|
|
1245
|
+
// snapshot is flying back to source — that would double up.
|
|
1246
|
+
destSharedView.alpha = 0;
|
|
1247
|
+
sharedSnapshots.push({
|
|
1248
|
+
snap,
|
|
1249
|
+
endFrame,
|
|
1250
|
+
endCornerRadius: srcSharedView.layer?.cornerRadius || 0,
|
|
1251
|
+
srcSharedView,
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
// Identify which source NS views have a matching fly-back snapshot.
|
|
1256
|
+
// Those sources stay at alpha 0 through the spring and are restored
|
|
1257
|
+
// inside finalize(), so the snapshot doesn't overlay an already-
|
|
1258
|
+
// visible source mid-flight (which looks like two images for a beat).
|
|
1259
|
+
const snapshottedSources = new Set();
|
|
1260
|
+
for (const entry of sharedSnapshots) {
|
|
1261
|
+
if (entry.srcSharedView)
|
|
1262
|
+
snapshottedSources.add(entry.srcSharedView);
|
|
1263
|
+
}
|
|
1264
|
+
// Source-only orphan views (album thumbnails, badges, etc.) were
|
|
1265
|
+
// already restored to their opacity by the gesture handler at morph
|
|
1266
|
+
// engagement, so we don't need fade-in snapshots here — they're
|
|
1267
|
+
// already visible behind the morphing modal.
|
|
1268
|
+
let didFinalize = false;
|
|
1269
|
+
const finalize = () => {
|
|
1270
|
+
if (didFinalize)
|
|
1271
|
+
return;
|
|
1272
|
+
didFinalize = true;
|
|
1273
|
+
// Detach the imageSourceChange listeners that were attached during
|
|
1274
|
+
// PRESENT — the destination View is about to be torn down.
|
|
1275
|
+
for (const presented of state.instance.sharedElements?.presented || []) {
|
|
1276
|
+
if (presented.imageSourceChangeListener) {
|
|
1277
|
+
presented.view.off('imageSourceChange', presented.imageSourceChangeListener);
|
|
1278
|
+
presented.imageSourceChangeListener = null;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
// Restore the snapshotted sources (held at alpha 0 through the
|
|
1282
|
+
// spring) immediately before removing the snapshot, so the
|
|
1283
|
+
// snapshot's last frame and the source's first visible frame
|
|
1284
|
+
// coincide exactly — no double-image, no gap.
|
|
1285
|
+
for (const entry of sharedSnapshots) {
|
|
1286
|
+
const srcSharedView = entry.srcSharedView;
|
|
1287
|
+
if (srcSharedView) {
|
|
1288
|
+
const nsView = state.instance.sharedElements?.presenting?.find?.((p) => p.view?.ios === srcSharedView)?.view;
|
|
1289
|
+
srcSharedView.alpha = nsView ? nsView.opacity : 1;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
for (const { snap } of sharedSnapshots) {
|
|
1293
|
+
snap.removeFromSuperview();
|
|
1294
|
+
}
|
|
1295
|
+
// Independent (orphan) views were restored at gesture engagement,
|
|
1296
|
+
// so they're already visible. Just tear down any leftover present-
|
|
1297
|
+
// phase snapshots that weren't removed in present cleanup, and
|
|
1298
|
+
// ensure alpha is set from NS opacity for safety in case the
|
|
1299
|
+
// engagement code path was bypassed.
|
|
1300
|
+
for (const independent of state.instance?.sharedElements?.independent || []) {
|
|
1301
|
+
if (independent.view?.ios) {
|
|
1302
|
+
independent.view.ios.alpha = independent.view.opacity;
|
|
1303
|
+
}
|
|
1304
|
+
independent.snapshot?.removeFromSuperview();
|
|
1305
|
+
}
|
|
1306
|
+
if (view) {
|
|
1307
|
+
view.transform = CGAffineTransformIdentity;
|
|
1308
|
+
view.alpha = 1;
|
|
1309
|
+
}
|
|
1310
|
+
// Remove the sibling shadow view if interactive engagement added one.
|
|
1311
|
+
removeInteractiveDismissShadow(view);
|
|
1312
|
+
SharedTransition.finishState(state.instance.id);
|
|
1313
|
+
if (interactiveState.transitionContext) {
|
|
1314
|
+
interactiveState.transitionContext.finishInteractiveTransition();
|
|
1315
|
+
interactiveState.transitionContext.completeTransition(true);
|
|
1316
|
+
}
|
|
1317
|
+
SharedTransition.notifyEvent(SharedTransition.finishedEvent, {
|
|
1318
|
+
id: state?.instance?.id,
|
|
1319
|
+
type,
|
|
1320
|
+
action: 'interactiveFinish',
|
|
1321
|
+
});
|
|
1322
|
+
};
|
|
1323
|
+
if (view && targetTransform) {
|
|
1324
|
+
const shadowViewToAnimate = view.__sharedTransitionShadowView;
|
|
1325
|
+
iOSUtils.animateWithSpring({
|
|
1326
|
+
animations: () => {
|
|
1327
|
+
view.transform = targetTransform;
|
|
1328
|
+
view.alpha = 0;
|
|
1329
|
+
// Drive the sibling shadow view through the same spring so it
|
|
1330
|
+
// shrinks + translates with the modal as it morphs to the
|
|
1331
|
+
// source. Also fade it out so it doesn't linger behind the
|
|
1332
|
+
// finalizing snapshot.
|
|
1333
|
+
if (shadowViewToAnimate) {
|
|
1334
|
+
shadowViewToAnimate.transform = targetTransform;
|
|
1335
|
+
shadowViewToAnimate.alpha = 0;
|
|
1336
|
+
}
|
|
1337
|
+
// Restore source-side element alphas IN PARALLEL with the
|
|
1338
|
+
// destination's morph + fade — but skip sources that have
|
|
1339
|
+
// a flying snapshot. Those are held at alpha 0 and
|
|
1340
|
+
// revealed by finalize() right before the snapshot is
|
|
1341
|
+
// removed, so the user never sees both the snapshot AND
|
|
1342
|
+
// the source visible at the same time.
|
|
1343
|
+
for (const v of state.instance.sharedElements?._allPresentingViews || []) {
|
|
1344
|
+
if (v?.ios && !snapshottedSources.has(v.ios)) {
|
|
1345
|
+
v.ios.alpha = v.opacity;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
// Source-only orphan views were already restored at
|
|
1349
|
+
// engagement; nothing more to do for them here.
|
|
1350
|
+
// Fly each shared-element snapshot to its source frame.
|
|
1351
|
+
// Rides the same spring so the image lands precisely back
|
|
1352
|
+
// at the source position as the destination view fades.
|
|
1353
|
+
for (const { snap, endFrame, endCornerRadius } of sharedSnapshots) {
|
|
1354
|
+
snap.frame = endFrame;
|
|
1355
|
+
snap.layer.cornerRadius = endCornerRadius;
|
|
1356
|
+
}
|
|
1357
|
+
},
|
|
1358
|
+
completion: () => finalize(),
|
|
1359
|
+
});
|
|
1360
|
+
// Safety: ensure finalize runs even if the animation completion
|
|
1361
|
+
// is dropped (e.g. interrupted by another gesture).
|
|
1362
|
+
setTimeout(finalize, 800);
|
|
1363
|
+
}
|
|
1364
|
+
else {
|
|
1365
|
+
// No target transform; ensure sources are still restored.
|
|
1366
|
+
for (const v of state.instance.sharedElements?._allPresentingViews || []) {
|
|
1367
|
+
if (v?.ios)
|
|
1368
|
+
v.ios.alpha = v.opacity;
|
|
1369
|
+
}
|
|
1370
|
+
finalize();
|
|
1371
|
+
}
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
516
1374
|
if (state?.instance && interactiveState?.added && interactiveState?.propertyAnimator) {
|
|
517
1375
|
interactiveState.propertyAnimator.reversed = false;
|
|
518
1376
|
const duration = isNumber(state.pageReturn?.duration) ? state.pageReturn?.duration / 1000 : CORE_ANIMATION_DEFAULTS.duration;
|
|
519
1377
|
interactiveState.propertyAnimator.continueAnimationWithTimingParametersDurationFactor(null, duration);
|
|
520
1378
|
setTimeout(() => {
|
|
1379
|
+
// Restore alpha on every source view we hid (including duplicates) so
|
|
1380
|
+
// the source page is visible if shown again.
|
|
1381
|
+
for (const sourceView of state.instance.sharedElements._allPresentingViews || []) {
|
|
1382
|
+
if (sourceView?.ios) {
|
|
1383
|
+
sourceView.ios.alpha = sourceView.opacity;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
521
1386
|
for (const presenting of state.instance.sharedElements.presenting) {
|
|
522
|
-
presenting.view.opacity = presenting.startOpacity;
|
|
523
1387
|
presenting.snapshot.removeFromSuperview();
|
|
524
1388
|
}
|
|
1389
|
+
for (const presented of state.instance.sharedElements.presented) {
|
|
1390
|
+
if (presented.imageSourceChangeListener) {
|
|
1391
|
+
presented.view.off('imageSourceChange', presented.imageSourceChangeListener);
|
|
1392
|
+
presented.imageSourceChangeListener = null;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
// Restore alpha on independent (orphan) source views and tear down
|
|
1396
|
+
// their snapshots. Without this, source-only orphans (any non-matched
|
|
1397
|
+
// sharedTransitionTag on the source page) stay at alpha 0 forever,
|
|
1398
|
+
// leaving the page visibly blank where they used to be. The non-morph
|
|
1399
|
+
// interactive path drives a propertyAnimator instead of running the
|
|
1400
|
+
// dismiss snapshot/animation rig, so the standard cleanup doesn't run.
|
|
1401
|
+
for (const ind of state.instance.sharedElements.independent) {
|
|
1402
|
+
if (ind.view?.ios) {
|
|
1403
|
+
ind.view.ios.alpha = ind.view.opacity;
|
|
1404
|
+
}
|
|
1405
|
+
ind.snapshot?.removeFromSuperview();
|
|
1406
|
+
}
|
|
525
1407
|
SharedTransition.finishState(state.instance.id);
|
|
526
1408
|
interactiveState.propertyAnimator = null;
|
|
527
1409
|
interactiveState.added = false;
|