@akylas/nativescript 8.5.10 → 8.6.2
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/index.d.ts +1 -1
- package/abortcontroller/index.js +4 -4
- package/abortcontroller/index.js.map +1 -1
- package/accessibility/accessibility-properties.js +1 -1
- package/accessibility/accessibility-properties.js.map +1 -1
- package/accessibility/font-scale-common.js +1 -1
- package/accessibility/font-scale-common.js.map +1 -1
- package/accessibility/index.android.js +24 -6
- package/accessibility/index.android.js.map +1 -1
- package/animation-frame/index.js +12 -1
- package/animation-frame/index.js.map +1 -1
- package/application/application-common.d.ts +2 -1
- package/application/application-common.js +2 -0
- package/application/application-common.js.map +1 -1
- package/application/application-interfaces.d.ts +6 -0
- package/application/application.android.d.ts +4 -0
- package/application/application.android.js +4 -0
- package/application/application.android.js.map +1 -1
- package/application/application.d.ts +18 -0
- package/application/application.ios.d.ts +2 -0
- package/application/application.ios.js +35 -1
- package/application/application.ios.js.map +1 -1
- package/application-settings/index.android.d.ts +2 -0
- package/application-settings/index.android.js +19 -0
- package/application-settings/index.android.js.map +1 -1
- package/application-settings/index.d.ts +12 -0
- package/application-settings/index.ios.d.ts +2 -0
- package/application-settings/index.ios.js +11 -0
- package/application-settings/index.ios.js.map +1 -1
- package/color/color-common.d.ts +14 -13
- package/color/color-common.js +2 -1
- package/color/color-common.js.map +1 -1
- package/color/index.android.d.ts +1 -1
- package/color/index.android.js +1 -1
- package/color/index.android.js.map +1 -1
- package/color/index.ios.d.ts +1 -1
- package/color/index.ios.js +1 -1
- package/color/index.ios.js.map +1 -1
- package/config/config.interface.d.ts +20 -6
- package/core-types/index.d.ts +7 -0
- package/core-types/index.js +7 -0
- package/core-types/index.js.map +1 -1
- package/css/CSS3Parser.js.map +1 -1
- package/css/system-classes.d.ts +2 -2
- package/data/observable/index.js.map +1 -1
- package/debugger/InspectorBackendCommands.ios.js.map +1 -1
- package/debugger/webinspector-css.ios.js.map +1 -1
- package/debugger/webinspector-dom.ios.js.map +1 -1
- package/debugger/webinspector-network.ios.js.map +1 -1
- package/file-system/index.d.ts +3 -3
- package/file-system/index.js +4 -4
- package/file-system/index.js.map +1 -1
- package/global-types.d.ts +1 -1
- package/image-asset/image-asset-common.js +13 -10
- package/image-asset/image-asset-common.js.map +1 -1
- package/image-asset/index.android.js +2 -2
- package/image-asset/index.android.js.map +1 -1
- package/image-asset/index.ios.js +1 -1
- package/image-asset/index.ios.js.map +1 -1
- package/package.json +1 -1
- package/platform/common.d.ts +8 -0
- package/platform/common.js +12 -0
- package/platform/common.js.map +1 -0
- package/platform/index.android.d.ts +1 -7
- package/platform/index.android.js +2 -6
- package/platform/index.android.js.map +1 -1
- package/platform/index.d.ts +5 -6
- package/platform/index.ios.d.ts +1 -7
- package/platform/index.ios.js +2 -6
- package/platform/index.ios.js.map +1 -1
- package/platforms/android/native-api-usage.json +6 -0
- package/platforms/android/widgets-release.aar +0 -0
- package/platforms/ios/TNSWidgets.xcframework/Info.plist +7 -7
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Info.plist +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Resources/Info.plist +7 -7
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/Resources/Info.plist +7 -7
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/A/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/TNSWidgets.framework/Versions/Current/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +82 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-maccatalyst/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +82 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +1 -1
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/aarch64/TNSWidgets.yml +82 -0
- package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/Relocations/x86_64/TNSWidgets.yml +82 -0
- package/platforms/ios/src/UIView+NativeScript.h +2 -0
- package/platforms/ios/src/UIView+NativeScript.m +15 -0
- package/profiling/index.js +2 -2
- package/profiling/index.js.map +1 -1
- package/ui/action-bar/action-bar-common.js.map +1 -1
- package/ui/action-bar/index.android.js +3 -2
- package/ui/action-bar/index.android.js.map +1 -1
- package/ui/action-bar/index.ios.js +4 -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 +6 -5
- package/ui/activity-indicator/index.android.js.map +1 -1
- package/ui/animation/index.ios.d.ts +3 -0
- package/ui/animation/index.ios.js +235 -70
- package/ui/animation/index.ios.js.map +1 -1
- package/ui/builder/xml2ui.js.map +1 -1
- package/ui/button/button-common.js.map +1 -1
- package/ui/button/index.android.js +1 -1
- package/ui/button/index.android.js.map +1 -1
- package/ui/button/index.ios.d.ts +1 -0
- package/ui/button/index.ios.js +27 -11
- package/ui/button/index.ios.js.map +1 -1
- package/ui/content-view/index.js +1 -1
- package/ui/content-view/index.js.map +1 -1
- package/ui/core/view/index.android.d.ts +16 -3
- package/ui/core/view/index.android.js +55 -46
- package/ui/core/view/index.android.js.map +1 -1
- package/ui/core/view/index.d.ts +2 -2
- package/ui/core/view/index.ios.d.ts +2 -2
- package/ui/core/view/index.ios.js +114 -50
- package/ui/core/view/index.ios.js.map +1 -1
- package/ui/core/view/view-common.d.ts +5 -4
- package/ui/core/view/view-common.js +20 -3
- package/ui/core/view/view-common.js.map +1 -1
- package/ui/core/view/view-helper/index.d.ts +2 -1
- package/ui/core/view/view-helper/index.ios.d.ts +1 -0
- package/ui/core/view/view-helper/index.ios.js +8 -5
- package/ui/core/view/view-helper/index.ios.js.map +1 -1
- package/ui/core/view-base/index.d.ts +8 -1
- package/ui/core/view-base/index.js +50 -16
- package/ui/core/view-base/index.js.map +1 -1
- package/ui/date-picker/date-picker-common.js.map +1 -1
- package/ui/dialogs/dialogs-common.js +3 -3
- package/ui/dialogs/dialogs-common.js.map +1 -1
- package/ui/editable-text-base/editable-text-base-common.d.ts +2 -0
- package/ui/editable-text-base/editable-text-base-common.js +6 -0
- package/ui/editable-text-base/editable-text-base-common.js.map +1 -1
- package/ui/editable-text-base/index.android.d.ts +2 -3
- package/ui/editable-text-base/index.android.js +39 -13
- package/ui/editable-text-base/index.android.js.map +1 -1
- package/ui/editable-text-base/index.ios.js +7 -1
- package/ui/editable-text-base/index.ios.js.map +1 -1
- package/ui/frame/fragment.transitions.android.js +9 -6
- package/ui/frame/fragment.transitions.android.js.map +1 -1
- package/ui/frame/frame-common.js +17 -6
- package/ui/frame/frame-common.js.map +1 -1
- package/ui/frame/index.android.js +28 -5
- package/ui/frame/index.android.js.map +1 -1
- package/ui/frame/index.ios.js.map +1 -1
- package/ui/gestures/gestures-common.d.ts +232 -7
- package/ui/gestures/gestures-common.js +98 -4
- package/ui/gestures/gestures-common.js.map +1 -1
- package/ui/gestures/index.d.ts +2 -289
- package/ui/gestures/touch-manager.js +2 -2
- package/ui/gestures/touch-manager.js.map +1 -1
- package/ui/html-view/html-view-common.js.map +1 -1
- package/ui/image/image-common.js +1 -1
- package/ui/image/image-common.js.map +1 -1
- package/ui/image-cache/image-cache-common.js.map +1 -1
- package/ui/image-cache/index.ios.js +13 -13
- package/ui/image-cache/index.ios.js.map +1 -1
- package/ui/index.d.ts +1 -1
- package/ui/index.js +1 -1
- package/ui/index.js.map +1 -1
- package/ui/label/index.android.d.ts +3 -3
- package/ui/label/index.android.js +1 -5
- package/ui/label/index.android.js.map +1 -1
- package/ui/label/index.ios.d.ts +1 -0
- package/ui/label/index.ios.js +30 -8
- package/ui/label/index.ios.js.map +1 -1
- package/ui/layouts/absolute-layout/absolute-layout-common.js.map +1 -1
- package/ui/layouts/dock-layout/dock-layout-common.js +1 -1
- package/ui/layouts/dock-layout/dock-layout-common.js.map +1 -1
- package/ui/layouts/flexbox-layout/flexbox-layout-common.js +5 -5
- package/ui/layouts/flexbox-layout/flexbox-layout-common.js.map +1 -1
- package/ui/layouts/grid-layout/grid-layout-common.d.ts +7 -2
- package/ui/layouts/grid-layout/grid-layout-common.js +32 -6
- package/ui/layouts/grid-layout/grid-layout-common.js.map +1 -1
- package/ui/layouts/grid-layout/index.android.d.ts +9 -3
- package/ui/layouts/grid-layout/index.android.js +67 -38
- package/ui/layouts/grid-layout/index.android.js.map +1 -1
- package/ui/layouts/layout-base-common.js +2 -1
- package/ui/layouts/layout-base-common.js.map +1 -1
- package/ui/layouts/layout-base.android.js +3 -0
- package/ui/layouts/layout-base.android.js.map +1 -1
- package/ui/layouts/root-layout/index.ios.js +7 -2
- 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/stack-layout/stack-layout-common.js +1 -1
- package/ui/layouts/stack-layout/stack-layout-common.js.map +1 -1
- package/ui/layouts/wrap-layout/wrap-layout-common.js +3 -3
- package/ui/layouts/wrap-layout/wrap-layout-common.js.map +1 -1
- package/ui/list-picker/index.ios.js +1 -7
- 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.map +1 -1
- package/ui/list-view/index.ios.js.map +1 -1
- package/ui/list-view/list-view-common.js.map +1 -1
- package/ui/page/index.android.js +4 -2
- package/ui/page/index.android.js.map +1 -1
- package/ui/page/index.d.ts +0 -4
- package/ui/page/index.ios.d.ts +0 -2
- package/ui/page/index.ios.js +28 -25
- package/ui/page/index.ios.js.map +1 -1
- package/ui/page/page-common.d.ts +1 -1
- package/ui/page/page-common.js +10 -4
- package/ui/page/page-common.js.map +1 -1
- package/ui/placeholder/index.android.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.js.map +1 -1
- package/ui/scroll-view/index.android.d.ts +1 -1
- package/ui/scroll-view/index.android.js +10 -6
- package/ui/scroll-view/index.android.js.map +1 -1
- package/ui/scroll-view/index.ios.d.ts +1 -2
- package/ui/scroll-view/index.ios.js +6 -8
- package/ui/scroll-view/index.ios.js.map +1 -1
- package/ui/scroll-view/scroll-view-common.d.ts +3 -5
- package/ui/scroll-view/scroll-view-common.js +23 -25
- package/ui/scroll-view/scroll-view-common.js.map +1 -1
- package/ui/search-bar/index.android.js +12 -1
- package/ui/search-bar/index.android.js.map +1 -1
- package/ui/search-bar/search-bar-common.js +1 -1
- package/ui/search-bar/search-bar-common.js.map +1 -1
- package/ui/segmented-bar/index.android.js +3 -2
- package/ui/segmented-bar/index.android.js.map +1 -1
- package/ui/segmented-bar/segmented-bar-common.js.map +1 -1
- package/ui/slider/slider-common.js +3 -3
- package/ui/slider/slider-common.js.map +1 -1
- package/ui/styling/background-common.d.ts +5 -4
- package/ui/styling/background-common.js +3 -0
- package/ui/styling/background-common.js.map +1 -1
- package/ui/styling/background.d.ts +13 -4
- package/ui/styling/background.ios.d.ts +26 -0
- package/ui/styling/background.ios.js +665 -368
- package/ui/styling/background.ios.js.map +1 -1
- package/ui/styling/box-shadow.d.ts +1 -0
- package/ui/styling/box-shadow.js.map +1 -1
- package/ui/styling/css-selector.js.map +1 -1
- package/ui/styling/css-shadow.d.ts +4 -4
- package/ui/styling/css-shadow.js +7 -75
- package/ui/styling/css-shadow.js.map +1 -1
- package/ui/styling/css-stroke.d.ts +12 -0
- package/ui/styling/css-stroke.js +19 -0
- package/ui/styling/css-stroke.js.map +1 -0
- package/ui/styling/css-utils.d.ts +7 -1
- package/ui/styling/css-utils.js +52 -0
- package/ui/styling/css-utils.js.map +1 -1
- package/ui/styling/font-common.d.ts +1 -1
- package/ui/styling/font-common.js +18 -11
- package/ui/styling/font-common.js.map +1 -1
- package/ui/styling/font-interfaces.d.ts +1 -1
- package/ui/styling/font.android.d.ts +0 -1
- package/ui/styling/font.android.js +9 -15
- package/ui/styling/font.android.js.map +1 -1
- package/ui/styling/font.d.ts +2 -2
- package/ui/styling/font.ios.js +15 -11
- package/ui/styling/font.ios.js.map +1 -1
- package/ui/styling/style/index.d.ts +8 -4
- package/ui/styling/style/index.js.map +1 -1
- package/ui/styling/style-properties.js +12 -2
- package/ui/styling/style-properties.js.map +1 -1
- package/ui/styling/style-scope.js +2 -2
- package/ui/styling/style-scope.js.map +1 -1
- package/ui/switch/switch-common.js.map +1 -1
- package/ui/tab-view/index.android.js +8 -4
- package/ui/tab-view/index.android.js.map +1 -1
- package/ui/tab-view/index.ios.js.map +1 -1
- package/ui/tab-view/tab-view-common.js +2 -2
- package/ui/tab-view/tab-view-common.js.map +1 -1
- package/ui/text-base/formatted-string.d.ts +3 -1
- package/ui/text-base/formatted-string.js +8 -0
- package/ui/text-base/formatted-string.js.map +1 -1
- package/ui/text-base/index.android.d.ts +5 -2
- package/ui/text-base/index.android.js +55 -37
- package/ui/text-base/index.android.js.map +1 -1
- package/ui/text-base/index.d.ts +16 -3
- package/ui/text-base/index.ios.d.ts +2 -2
- package/ui/text-base/index.ios.js +16 -15
- package/ui/text-base/index.ios.js.map +1 -1
- package/ui/text-base/span.d.ts +3 -1
- package/ui/text-base/span.js +6 -0
- package/ui/text-base/span.js.map +1 -1
- package/ui/text-base/text-base-common.d.ts +10 -4
- package/ui/text-base/text-base-common.js +33 -5
- package/ui/text-base/text-base-common.js.map +1 -1
- package/ui/text-field/index.android.d.ts +5 -0
- package/ui/text-field/index.android.js +36 -16
- package/ui/text-field/index.android.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/time-picker/time-picker-common.js +8 -2
- package/ui/time-picker/time-picker-common.js.map +1 -1
- package/ui/transition/index.d.ts +1 -0
- package/ui/transition/page-transition.android.d.ts +5 -2
- package/ui/transition/page-transition.android.js +59 -19
- package/ui/transition/page-transition.android.js.map +1 -1
- package/ui/transition/page-transition.d.ts +3 -1
- package/ui/transition/shared-transition.js +3 -3
- package/ui/transition/shared-transition.js.map +1 -1
- package/ui/utils.d.ts +16 -19
- package/ui/utils.ios.d.ts +11 -10
- package/ui/utils.ios.js +37 -37
- package/ui/utils.ios.js.map +1 -1
- package/ui/web-view/web-view-common.js.map +1 -1
- package/utils/android/index.js +14 -2
- package/utils/android/index.js.map +1 -1
- package/utils/common.d.ts +3 -1
- package/utils/common.js +5 -1
- package/utils/common.js.map +1 -1
- package/utils/debug.js +1 -1
- package/utils/debug.js.map +1 -1
- package/utils/index.android.js +5 -3
- package/utils/index.android.js.map +1 -1
- package/utils/index.d.ts +2 -2
- package/utils/ios/index.d.ts +0 -1
- package/utils/ios/index.js +0 -65
- package/utils/ios/index.js.map +1 -1
- package/utils/native-helper.d.ts +0 -7
- package/utils/platform-check.js +1 -1
- package/utils/platform-check.js.map +1 -1
- package/xhr/index.js.map +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { LinearGradient } from './linear-gradient';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Screen } from '../../platform';
|
|
3
|
+
import { isDataURI, isFileOrResourcePath, layout } from '../../utils';
|
|
4
4
|
import { ios as iosViewUtils } from '../utils';
|
|
5
5
|
import { ImageSource } from '../../image-source';
|
|
6
6
|
import { parse as cssParse } from '../../css-value';
|
|
7
|
-
import { Length } from './style-properties';
|
|
8
7
|
export * from './background-common';
|
|
9
8
|
const clearCGColor = UIColor.clearColor.CGColor;
|
|
9
|
+
const uriPattern = /url\(('|")(.*?)\1\)/;
|
|
10
10
|
const symbolUrl = Symbol('backgroundImageUrl');
|
|
11
11
|
export var CacheMode;
|
|
12
12
|
(function (CacheMode) {
|
|
@@ -20,59 +20,262 @@ export var ios;
|
|
|
20
20
|
if (!nativeView) {
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
// Unset this in case another layer handles background color (e.g. gradient)
|
|
24
|
+
nativeView.layer.backgroundColor = null;
|
|
25
|
+
// Cleanup of previous values
|
|
26
|
+
clearBackgroundVisualEffects(view);
|
|
27
|
+
// Borders, shadows, etc
|
|
28
|
+
drawBackgroundVisualEffects(view);
|
|
29
|
+
if (!background.image) {
|
|
30
|
+
callback(background?.color?.ios);
|
|
27
31
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
else {
|
|
33
|
+
if (!(background.image instanceof LinearGradient)) {
|
|
34
|
+
setUIColorFromImage(view, nativeView, callback, flip);
|
|
35
|
+
}
|
|
31
36
|
}
|
|
32
|
-
|
|
37
|
+
}
|
|
38
|
+
ios.createBackgroundUIColor = createBackgroundUIColor;
|
|
39
|
+
function drawBackgroundVisualEffects(view) {
|
|
40
|
+
const background = view.style.backgroundInternal;
|
|
41
|
+
const nativeView = view.nativeViewProtected;
|
|
42
|
+
const layer = nativeView.layer;
|
|
43
|
+
let needsLayerAdjustmentOnScroll = false;
|
|
44
|
+
// Add new gradient layer or update existing one
|
|
33
45
|
if (background.image instanceof LinearGradient) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
subscribeForScrollNotifications(view);
|
|
46
|
+
if (!nativeView.gradientLayer) {
|
|
47
|
+
nativeView.gradientLayer = CAGradientLayer.new();
|
|
48
|
+
layer.insertSublayerAtIndex(nativeView.gradientLayer, 0);
|
|
49
|
+
}
|
|
50
|
+
iosViewUtils.drawGradient(nativeView, nativeView.gradientLayer, background.image);
|
|
51
|
+
needsLayerAdjustmentOnScroll = true;
|
|
41
52
|
}
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
// Initialize clipping mask (usually for clip-path and non-uniform rounded borders)
|
|
54
|
+
maskLayerIfNeeded(nativeView, background);
|
|
55
|
+
if (background.hasUniformBorder()) {
|
|
44
56
|
const borderColor = background.getUniformBorderColor();
|
|
45
|
-
layer.borderColor =
|
|
57
|
+
layer.borderColor = borderColor?.ios?.CGColor;
|
|
46
58
|
layer.borderWidth = layout.toDeviceIndependentPixels(background.getUniformBorderWidth());
|
|
47
|
-
|
|
48
|
-
const cornerRadius = layout.toDeviceIndependentPixels(background.getUniformBorderRadius());
|
|
49
|
-
layer.cornerRadius = Math.min(Math.min(renderSize.width / 2, renderSize.height / 2), cornerRadius);
|
|
59
|
+
layer.cornerRadius = getUniformBorderRadius(view, layer.bounds);
|
|
50
60
|
}
|
|
51
61
|
else {
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
drawNonUniformBorders(nativeView, background);
|
|
63
|
+
needsLayerAdjustmentOnScroll = true;
|
|
54
64
|
}
|
|
55
|
-
// Clip-path should be called after borders are applied
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
drawClipPath(nativeView, background);
|
|
65
|
+
// Clip-path should be called after borders are applied
|
|
66
|
+
if (nativeView.maskType === iosViewUtils.LayerMask.CLIP_PATH && layer.mask instanceof CAShapeLayer) {
|
|
67
|
+
layer.mask.path = generateClipPath(view, layer.bounds);
|
|
59
68
|
}
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
if (background.hasBoxShadow()) {
|
|
70
|
+
drawBoxShadow(view);
|
|
71
|
+
needsLayerAdjustmentOnScroll = true;
|
|
63
72
|
}
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
if (needsLayerAdjustmentOnScroll) {
|
|
74
|
+
registerAdjustLayersOnScrollListener(view);
|
|
66
75
|
}
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
}
|
|
77
|
+
ios.drawBackgroundVisualEffects = drawBackgroundVisualEffects;
|
|
78
|
+
function clearBackgroundVisualEffects(view) {
|
|
79
|
+
const nativeView = view.nativeViewProtected;
|
|
80
|
+
if (!nativeView) {
|
|
81
|
+
return;
|
|
69
82
|
}
|
|
70
|
-
|
|
83
|
+
const background = view.style.backgroundInternal;
|
|
84
|
+
const hasGradientBackground = background.image && background.image instanceof LinearGradient;
|
|
85
|
+
// Remove mask if there is no clip path or non-uniform border with radius
|
|
86
|
+
let needsMask;
|
|
87
|
+
switch (nativeView.maskType) {
|
|
88
|
+
case iosViewUtils.LayerMask.BORDER:
|
|
89
|
+
needsMask = !background.hasUniformBorder() && background.hasBorderRadius();
|
|
90
|
+
break;
|
|
91
|
+
case iosViewUtils.LayerMask.CLIP_PATH:
|
|
92
|
+
needsMask = !!background.clipPath;
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
needsMask = false;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
if (!needsMask) {
|
|
99
|
+
clearLayerMask(nativeView);
|
|
100
|
+
}
|
|
101
|
+
// Clear box shadow if it's no longer needed
|
|
102
|
+
if (background.clearFlags & 2 /* BackgroundClearFlags.CLEAR_BOX_SHADOW */) {
|
|
103
|
+
clearBoxShadow(nativeView);
|
|
104
|
+
}
|
|
105
|
+
// Non-uniform borders cleanup
|
|
106
|
+
if (nativeView.hasNonUniformBorder) {
|
|
107
|
+
if (nativeView.hasNonUniformBorderColor && background.hasUniformBorderColor()) {
|
|
108
|
+
clearNonUniformColorBorders(nativeView);
|
|
109
|
+
}
|
|
110
|
+
if (background.hasUniformBorder()) {
|
|
111
|
+
clearNonUniformBorders(nativeView);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (nativeView.gradientLayer && !hasGradientBackground) {
|
|
115
|
+
nativeView.gradientLayer.removeFromSuperlayer();
|
|
116
|
+
nativeView.gradientLayer = null;
|
|
117
|
+
}
|
|
118
|
+
// Force unset scroll listener
|
|
119
|
+
unregisterAdjustLayersOnScrollListener(view);
|
|
120
|
+
// Reset clear flags
|
|
71
121
|
background.clearFlags = 0 /* BackgroundClearFlags.NONE */;
|
|
72
122
|
}
|
|
73
|
-
ios.
|
|
123
|
+
ios.clearBackgroundVisualEffects = clearBackgroundVisualEffects;
|
|
124
|
+
function generateShadowLayerPaths(view, bounds) {
|
|
125
|
+
const background = view.style.backgroundInternal;
|
|
126
|
+
const nativeView = view.nativeViewProtected;
|
|
127
|
+
const layer = nativeView.layer;
|
|
128
|
+
const boxShadow = background.getBoxShadow();
|
|
129
|
+
const spreadRadius = layout.toDeviceIndependentPixels(boxShadow.spreadRadius);
|
|
130
|
+
const { width, height } = bounds.size;
|
|
131
|
+
let innerPath, shadowPath;
|
|
132
|
+
// Generate more detailed paths if view has border radius
|
|
133
|
+
if (background.hasBorderRadius()) {
|
|
134
|
+
if (background.hasUniformBorder()) {
|
|
135
|
+
const cornerRadius = layer.cornerRadius;
|
|
136
|
+
const cappedRadius = getBorderCapRadius(cornerRadius, width / 2, height / 2);
|
|
137
|
+
const cappedOuterRadii = {
|
|
138
|
+
topLeft: cappedRadius,
|
|
139
|
+
topRight: cappedRadius,
|
|
140
|
+
bottomLeft: cappedRadius,
|
|
141
|
+
bottomRight: cappedRadius,
|
|
142
|
+
};
|
|
143
|
+
const cappedOuterRadiiWithSpread = {
|
|
144
|
+
topLeft: cappedRadius + spreadRadius,
|
|
145
|
+
topRight: cappedRadius + spreadRadius,
|
|
146
|
+
bottomLeft: cappedRadius + spreadRadius,
|
|
147
|
+
bottomRight: cappedRadius + spreadRadius,
|
|
148
|
+
};
|
|
149
|
+
innerPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadii);
|
|
150
|
+
shadowPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadiiWithSpread, spreadRadius);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const outerTopLeftRadius = layout.toDeviceIndependentPixels(background.borderTopLeftRadius);
|
|
154
|
+
const outerTopRightRadius = layout.toDeviceIndependentPixels(background.borderTopRightRadius);
|
|
155
|
+
const outerBottomRightRadius = layout.toDeviceIndependentPixels(background.borderBottomRightRadius);
|
|
156
|
+
const outerBottomLeftRadius = layout.toDeviceIndependentPixels(background.borderBottomLeftRadius);
|
|
157
|
+
const topRadii = outerTopLeftRadius + outerTopRightRadius;
|
|
158
|
+
const rightRadii = outerTopRightRadius + outerBottomRightRadius;
|
|
159
|
+
const bottomRadii = outerBottomRightRadius + outerBottomLeftRadius;
|
|
160
|
+
const leftRadii = outerBottomLeftRadius + outerTopLeftRadius;
|
|
161
|
+
const cappedOuterRadii = {
|
|
162
|
+
topLeft: getBorderCapRadius(outerTopLeftRadius, (outerTopLeftRadius / topRadii) * width, (outerTopLeftRadius / leftRadii) * height),
|
|
163
|
+
topRight: getBorderCapRadius(outerTopRightRadius, (outerTopRightRadius / topRadii) * width, (outerTopRightRadius / rightRadii) * height),
|
|
164
|
+
bottomLeft: getBorderCapRadius(outerBottomLeftRadius, (outerBottomLeftRadius / bottomRadii) * width, (outerBottomLeftRadius / leftRadii) * height),
|
|
165
|
+
bottomRight: getBorderCapRadius(outerBottomRightRadius, (outerBottomRightRadius / bottomRadii) * width, (outerBottomRightRadius / rightRadii) * height),
|
|
166
|
+
};
|
|
167
|
+
// Add spread radius to corners that actually have radius as shadow has grown larger
|
|
168
|
+
// than view itself and needs to be rounded accordingly
|
|
169
|
+
const cappedOuterRadiiWithSpread = {
|
|
170
|
+
topLeft: cappedOuterRadii.topLeft > 0 ? cappedOuterRadii.topLeft + spreadRadius : cappedOuterRadii.topLeft,
|
|
171
|
+
topRight: cappedOuterRadii.topRight > 0 ? cappedOuterRadii.topRight + spreadRadius : cappedOuterRadii.topRight,
|
|
172
|
+
bottomLeft: cappedOuterRadii.bottomLeft > 0 ? cappedOuterRadii.bottomLeft + spreadRadius : cappedOuterRadii.bottomLeft,
|
|
173
|
+
bottomRight: cappedOuterRadii.bottomRight > 0 ? cappedOuterRadii.bottomRight + spreadRadius : cappedOuterRadii.bottomRight,
|
|
174
|
+
};
|
|
175
|
+
innerPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadii);
|
|
176
|
+
shadowPath = generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadiiWithSpread, spreadRadius);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
innerPath = CGPathCreateWithRect(bounds, null);
|
|
181
|
+
shadowPath = CGPathCreateWithRect(CGRectInset(bounds, -spreadRadius, -spreadRadius), null);
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
maskPath: generateShadowMaskPath(bounds, boxShadow, innerPath),
|
|
185
|
+
shadowPath,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
ios.generateShadowLayerPaths = generateShadowLayerPaths;
|
|
189
|
+
function generateClipPath(view, bounds) {
|
|
190
|
+
const background = view.style.backgroundInternal;
|
|
191
|
+
const { origin, size } = bounds;
|
|
192
|
+
const position = {
|
|
193
|
+
left: origin.x,
|
|
194
|
+
top: origin.y,
|
|
195
|
+
bottom: size.height,
|
|
196
|
+
right: size.width,
|
|
197
|
+
};
|
|
198
|
+
if (position.right === 0 || position.bottom === 0) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
let path;
|
|
202
|
+
const clipPath = background.clipPath;
|
|
203
|
+
const functionName = clipPath.substring(0, clipPath.indexOf('('));
|
|
204
|
+
const value = clipPath.replace(`${functionName}(`, '').replace(')', '');
|
|
205
|
+
switch (functionName) {
|
|
206
|
+
case 'rect':
|
|
207
|
+
path = rectPath(value, position);
|
|
208
|
+
break;
|
|
209
|
+
case 'inset':
|
|
210
|
+
path = insetPath(value, position);
|
|
211
|
+
break;
|
|
212
|
+
case 'circle':
|
|
213
|
+
path = circlePath(value, position);
|
|
214
|
+
break;
|
|
215
|
+
case 'ellipse':
|
|
216
|
+
path = ellipsePath(value, position);
|
|
217
|
+
break;
|
|
218
|
+
case 'polygon':
|
|
219
|
+
path = polygonPath(value, position);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
return path;
|
|
223
|
+
}
|
|
224
|
+
ios.generateClipPath = generateClipPath;
|
|
225
|
+
function getUniformBorderRadius(view, bounds) {
|
|
226
|
+
const background = view.style.backgroundInternal;
|
|
227
|
+
const { width, height } = bounds.size;
|
|
228
|
+
const cornerRadius = layout.toDeviceIndependentPixels(background.getUniformBorderRadius());
|
|
229
|
+
return Math.min(Math.min(width / 2, height / 2), cornerRadius);
|
|
230
|
+
}
|
|
231
|
+
ios.getUniformBorderRadius = getUniformBorderRadius;
|
|
232
|
+
function generateNonUniformBorderInnerClipRoundedPath(view, bounds) {
|
|
233
|
+
const background = view.style.backgroundInternal;
|
|
234
|
+
const cappedOuterRadii = calculateNonUniformBorderCappedRadii(bounds, background);
|
|
235
|
+
return generateNonUniformBorderInnerClipPath(bounds, background, cappedOuterRadii);
|
|
236
|
+
}
|
|
237
|
+
ios.generateNonUniformBorderInnerClipRoundedPath = generateNonUniformBorderInnerClipRoundedPath;
|
|
238
|
+
function generateNonUniformBorderOuterClipRoundedPath(view, bounds) {
|
|
239
|
+
const background = view.style.backgroundInternal;
|
|
240
|
+
const cappedOuterRadii = calculateNonUniformBorderCappedRadii(bounds, background);
|
|
241
|
+
return generateNonUniformBorderOuterClipPath(bounds, cappedOuterRadii);
|
|
242
|
+
}
|
|
243
|
+
ios.generateNonUniformBorderOuterClipRoundedPath = generateNonUniformBorderOuterClipRoundedPath;
|
|
244
|
+
function generateNonUniformMultiColorBorderRoundedPaths(view, bounds) {
|
|
245
|
+
const background = view.style.backgroundInternal;
|
|
246
|
+
return generateNonUniformMultiColorBorderPaths(bounds, background);
|
|
247
|
+
}
|
|
248
|
+
ios.generateNonUniformMultiColorBorderRoundedPaths = generateNonUniformMultiColorBorderRoundedPaths;
|
|
74
249
|
})(ios || (ios = {}));
|
|
75
|
-
function
|
|
250
|
+
function maskLayerIfNeeded(nativeView, background) {
|
|
251
|
+
const layer = nativeView.layer;
|
|
252
|
+
// Check if layer should be masked
|
|
253
|
+
if (!(layer.mask instanceof CAShapeLayer)) {
|
|
254
|
+
// Since layers can only accept up to a single mask at a time, clip path is given more priority
|
|
255
|
+
if (background.clipPath) {
|
|
256
|
+
nativeView.maskType = iosViewUtils.LayerMask.CLIP_PATH;
|
|
257
|
+
}
|
|
258
|
+
else if (!background.hasUniformBorder() && background.hasBorderRadius()) {
|
|
259
|
+
nativeView.maskType = iosViewUtils.LayerMask.BORDER;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
nativeView.maskType = null;
|
|
263
|
+
}
|
|
264
|
+
if (nativeView.maskType != null) {
|
|
265
|
+
nativeView.originalMask = layer.mask;
|
|
266
|
+
layer.mask = CAShapeLayer.new();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function clearLayerMask(nativeView) {
|
|
271
|
+
if (nativeView.outerShadowContainerLayer) {
|
|
272
|
+
nativeView.outerShadowContainerLayer.mask = null;
|
|
273
|
+
}
|
|
274
|
+
nativeView.layer.mask = nativeView.originalMask;
|
|
275
|
+
nativeView.originalMask = null;
|
|
276
|
+
nativeView.maskType = null;
|
|
277
|
+
}
|
|
278
|
+
function onBackgroundViewScroll(args) {
|
|
76
279
|
const view = args.object;
|
|
77
280
|
const nativeView = view.nativeViewProtected;
|
|
78
281
|
if (nativeView instanceof UIScrollView) {
|
|
@@ -80,61 +283,62 @@ function onScroll(args) {
|
|
|
80
283
|
}
|
|
81
284
|
}
|
|
82
285
|
function adjustLayersForScrollView(nativeView) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
286
|
+
// Compensates with transition for the background layers for scrolling in ScrollView based controls.
|
|
287
|
+
CATransaction.begin();
|
|
288
|
+
CATransaction.setDisableActions(true);
|
|
289
|
+
const offset = nativeView.contentOffset;
|
|
290
|
+
const transform = {
|
|
291
|
+
a: 1,
|
|
292
|
+
b: 0,
|
|
293
|
+
c: 0,
|
|
294
|
+
d: 1,
|
|
295
|
+
tx: offset.x,
|
|
296
|
+
ty: offset.y,
|
|
297
|
+
};
|
|
298
|
+
if (nativeView.layer.mask) {
|
|
299
|
+
nativeView.layer.mask.setAffineTransform(transform);
|
|
300
|
+
}
|
|
301
|
+
// Nested layers
|
|
302
|
+
if (nativeView.gradientLayer) {
|
|
303
|
+
nativeView.gradientLayer.setAffineTransform(transform);
|
|
304
|
+
}
|
|
305
|
+
if (nativeView.borderLayer) {
|
|
306
|
+
nativeView.borderLayer.setAffineTransform(transform);
|
|
102
307
|
}
|
|
308
|
+
if (nativeView.outerShadowContainerLayer) {
|
|
309
|
+
// Update bounds of shadow layer as it belongs to parent view
|
|
310
|
+
nativeView.outerShadowContainerLayer.bounds = nativeView.bounds;
|
|
311
|
+
nativeView.outerShadowContainerLayer.setAffineTransform(transform);
|
|
312
|
+
}
|
|
313
|
+
CATransaction.setDisableActions(false);
|
|
314
|
+
CATransaction.commit();
|
|
103
315
|
}
|
|
104
|
-
function
|
|
316
|
+
function unregisterAdjustLayersOnScrollListener(view) {
|
|
105
317
|
if (view.nativeViewProtected instanceof UIScrollView) {
|
|
106
|
-
view.off('scroll',
|
|
318
|
+
view.off('scroll', onBackgroundViewScroll);
|
|
107
319
|
}
|
|
108
320
|
}
|
|
109
|
-
function
|
|
321
|
+
function registerAdjustLayersOnScrollListener(view) {
|
|
110
322
|
if (view.nativeViewProtected instanceof UIScrollView) {
|
|
111
|
-
view.
|
|
323
|
+
view.off('scroll', onBackgroundViewScroll);
|
|
324
|
+
view.on('scroll', onBackgroundViewScroll);
|
|
112
325
|
adjustLayersForScrollView(view.nativeViewProtected);
|
|
113
326
|
}
|
|
114
327
|
}
|
|
328
|
+
function clearNonUniformColorBorders(nativeView) {
|
|
329
|
+
if (nativeView.borderLayer) {
|
|
330
|
+
nativeView.borderLayer.mask = null;
|
|
331
|
+
nativeView.borderLayer.sublayers = null;
|
|
332
|
+
}
|
|
333
|
+
nativeView.hasNonUniformBorderColor = false;
|
|
334
|
+
}
|
|
115
335
|
function clearNonUniformBorders(nativeView) {
|
|
116
336
|
if (nativeView.borderLayer) {
|
|
117
337
|
nativeView.borderLayer.removeFromSuperlayer();
|
|
338
|
+
nativeView.borderLayer = null;
|
|
118
339
|
}
|
|
119
|
-
|
|
120
|
-
nativeView.layer.mask = nativeView.borderOriginalMask;
|
|
121
|
-
nativeView.hasBorderMask = false;
|
|
122
|
-
nativeView.borderOriginalMask = null;
|
|
123
|
-
}
|
|
124
|
-
if (nativeView.topBorderLayer) {
|
|
125
|
-
nativeView.topBorderLayer.removeFromSuperlayer();
|
|
126
|
-
}
|
|
127
|
-
if (nativeView.rightBorderLayer) {
|
|
128
|
-
nativeView.rightBorderLayer.removeFromSuperlayer();
|
|
129
|
-
}
|
|
130
|
-
if (nativeView.bottomBorderLayer) {
|
|
131
|
-
nativeView.bottomBorderLayer.removeFromSuperlayer();
|
|
132
|
-
}
|
|
133
|
-
if (nativeView.leftBorderLayer) {
|
|
134
|
-
nativeView.leftBorderLayer.removeFromSuperlayer();
|
|
135
|
-
}
|
|
340
|
+
nativeView.hasNonUniformBorder = false;
|
|
136
341
|
}
|
|
137
|
-
const pattern = /url\(('|")(.*?)\1\)/;
|
|
138
342
|
function setUIColorFromImage(view, nativeView, callback, flip) {
|
|
139
343
|
const frame = nativeView.frame;
|
|
140
344
|
const boundsWidth = view.scaleX ? frame.size.width / view.scaleX : frame.size.width;
|
|
@@ -146,7 +350,7 @@ function setUIColorFromImage(view, nativeView, callback, flip) {
|
|
|
146
350
|
const background = style.backgroundInternal;
|
|
147
351
|
let imageUri = background.image;
|
|
148
352
|
if (imageUri) {
|
|
149
|
-
const match = imageUri.match(
|
|
353
|
+
const match = imageUri.match(uriPattern);
|
|
150
354
|
if (match && match[2]) {
|
|
151
355
|
imageUri = match[2];
|
|
152
356
|
}
|
|
@@ -314,11 +518,11 @@ function getDrawParams(image, background, width, height) {
|
|
|
314
518
|
}
|
|
315
519
|
function uiColorFromImage(img, view, callback, flip) {
|
|
316
520
|
const background = view.style.backgroundInternal;
|
|
317
|
-
|
|
521
|
+
const nativeView = view.nativeViewProtected;
|
|
522
|
+
if (!img || !nativeView) {
|
|
318
523
|
callback(background.color && background.color.ios);
|
|
319
524
|
return;
|
|
320
525
|
}
|
|
321
|
-
const nativeView = view.nativeViewProtected;
|
|
322
526
|
const frame = nativeView.frame;
|
|
323
527
|
const boundsWidth = view.scaleX ? frame.size.width / view.scaleX : frame.size.width;
|
|
324
528
|
const boundsHeight = view.scaleY ? frame.size.height / view.scaleY : frame.size.height;
|
|
@@ -384,29 +588,12 @@ function cssValueToDeviceIndependentPixels(source, total) {
|
|
|
384
588
|
return parseFloat(source);
|
|
385
589
|
}
|
|
386
590
|
}
|
|
387
|
-
function
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const { width, height } = layer.bounds.size;
|
|
394
|
-
const { x, y } = layer.bounds.origin;
|
|
395
|
-
const left = x;
|
|
396
|
-
const top = y;
|
|
397
|
-
const right = x + width;
|
|
398
|
-
const bottom = y + height;
|
|
399
|
-
const { min, max } = Math;
|
|
400
|
-
const borderTopWidth = max(0, layout.toDeviceIndependentPixels(background.borderTopWidth));
|
|
401
|
-
const borderRightWidth = max(0, layout.toDeviceIndependentPixels(background.borderRightWidth));
|
|
402
|
-
const borderBottomWidth = max(0, layout.toDeviceIndependentPixels(background.borderBottomWidth));
|
|
403
|
-
const borderLeftWidth = max(0, layout.toDeviceIndependentPixels(background.borderLeftWidth));
|
|
404
|
-
const borderVWidth = borderTopWidth + borderBottomWidth;
|
|
405
|
-
const borderHWidth = borderLeftWidth + borderRightWidth;
|
|
406
|
-
const cappedBorderTopWidth = borderTopWidth && borderTopWidth * min(1, height / borderVWidth);
|
|
407
|
-
const cappedBorderRightWidth = borderRightWidth && borderRightWidth * min(1, width / borderHWidth);
|
|
408
|
-
const cappedBorderBottomWidth = borderBottomWidth && borderBottomWidth * min(1, height / borderVWidth);
|
|
409
|
-
const cappedBorderLeftWidth = borderLeftWidth && borderLeftWidth * min(1, width / borderHWidth);
|
|
591
|
+
function getBorderCapRadius(a, b, c) {
|
|
592
|
+
return a && Math.min(a, Math.min(b, c));
|
|
593
|
+
}
|
|
594
|
+
function calculateNonUniformBorderCappedRadii(bounds, background) {
|
|
595
|
+
const { width, height } = bounds.size;
|
|
596
|
+
const { x, y } = bounds.origin;
|
|
410
597
|
const outerTopLeftRadius = layout.toDeviceIndependentPixels(background.borderTopLeftRadius);
|
|
411
598
|
const outerTopRightRadius = layout.toDeviceIndependentPixels(background.borderTopRightRadius);
|
|
412
599
|
const outerBottomRightRadius = layout.toDeviceIndependentPixels(background.borderBottomRightRadius);
|
|
@@ -415,310 +602,420 @@ function drawUniformColorNonUniformBorders(nativeView, background) {
|
|
|
415
602
|
const rightRadii = outerTopRightRadius + outerBottomRightRadius;
|
|
416
603
|
const bottomRadii = outerBottomRightRadius + outerBottomLeftRadius;
|
|
417
604
|
const leftRadii = outerBottomLeftRadius + outerTopLeftRadius;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
nativeView.
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (cappedBorderTopWidth > 0 || cappedBorderLeftWidth > 0) {
|
|
443
|
-
CGPathMoveToPoint(borderPath, null, left + cappedOuterTopLeftRadius, top + cappedBorderTopWidth);
|
|
444
|
-
}
|
|
445
|
-
else {
|
|
446
|
-
CGPathMoveToPoint(borderPath, null, left, top);
|
|
447
|
-
}
|
|
448
|
-
if (cappedBorderTopWidth > 0 || cappedBorderRightWidth > 0) {
|
|
449
|
-
const innerTopRightWRadius = max(0, cappedOuterTopRightRadius - cappedBorderRightWidth);
|
|
450
|
-
const innerTopRightHRadius = max(0, cappedOuterTopRightRadius - cappedBorderTopWidth);
|
|
451
|
-
const innerTopRightMaxRadius = max(innerTopRightWRadius, innerTopRightHRadius);
|
|
452
|
-
const innerTopRightTransform = CGAffineTransformMake(innerTopRightMaxRadius && innerTopRightWRadius / innerTopRightMaxRadius, 0, 0, innerTopRightMaxRadius && innerTopRightHRadius / innerTopRightMaxRadius, right - cappedBorderRightWidth - innerTopRightWRadius, top + cappedBorderTopWidth + innerTopRightHRadius);
|
|
453
|
-
CGPathAddArc(borderPath, innerTopRightTransform, 0, 0, innerTopRightMaxRadius, (Math.PI * 3) / 2, 0, false);
|
|
454
|
-
}
|
|
455
|
-
else {
|
|
456
|
-
CGPathMoveToPoint(borderPath, null, right, top);
|
|
457
|
-
}
|
|
458
|
-
if (cappedBorderBottomWidth > 0 || cappedBorderRightWidth > 0) {
|
|
459
|
-
const innerBottomRightWRadius = max(0, cappedOuterBottomRightRadius - cappedBorderRightWidth);
|
|
460
|
-
const innerBottomRightHRadius = max(0, cappedOuterBottomRightRadius - cappedBorderBottomWidth);
|
|
461
|
-
const innerBottomRightMaxRadius = max(innerBottomRightWRadius, innerBottomRightHRadius);
|
|
462
|
-
const innerBottomRightTransform = CGAffineTransformMake(innerBottomRightMaxRadius && innerBottomRightWRadius / innerBottomRightMaxRadius, 0, 0, innerBottomRightMaxRadius && innerBottomRightHRadius / innerBottomRightMaxRadius, right - cappedBorderRightWidth - innerBottomRightWRadius, bottom - cappedBorderBottomWidth - innerBottomRightHRadius);
|
|
463
|
-
CGPathAddArc(borderPath, innerBottomRightTransform, 0, 0, innerBottomRightMaxRadius, 0, Math.PI / 2, false);
|
|
464
|
-
}
|
|
465
|
-
else {
|
|
466
|
-
CGPathAddLineToPoint(borderPath, null, right, bottom);
|
|
467
|
-
}
|
|
468
|
-
if (cappedBorderBottomWidth > 0 || cappedBorderLeftWidth > 0) {
|
|
469
|
-
const innerBottomLeftWRadius = max(0, cappedOuterBottomLeftRadius - cappedBorderLeftWidth);
|
|
470
|
-
const innerBottomLeftHRadius = max(0, cappedOuterBottomLeftRadius - cappedBorderBottomWidth);
|
|
471
|
-
const innerBottomLeftMaxRadius = max(innerBottomLeftWRadius, innerBottomLeftHRadius);
|
|
472
|
-
const innerBottomLeftTransform = CGAffineTransformMake(innerBottomLeftMaxRadius && innerBottomLeftWRadius / innerBottomLeftMaxRadius, 0, 0, innerBottomLeftMaxRadius && innerBottomLeftHRadius / innerBottomLeftMaxRadius, left + cappedBorderLeftWidth + innerBottomLeftWRadius, bottom - cappedBorderBottomWidth - innerBottomLeftHRadius);
|
|
473
|
-
CGPathAddArc(borderPath, innerBottomLeftTransform, 0, 0, innerBottomLeftMaxRadius, Math.PI / 2, Math.PI, false);
|
|
474
|
-
}
|
|
475
|
-
else {
|
|
476
|
-
CGPathAddLineToPoint(borderPath, null, left, bottom);
|
|
605
|
+
const cappedOuterRadii = {
|
|
606
|
+
topLeft: getBorderCapRadius(outerTopLeftRadius, (outerTopLeftRadius / topRadii) * width, (outerTopLeftRadius / leftRadii) * height),
|
|
607
|
+
topRight: getBorderCapRadius(outerTopRightRadius, (outerTopRightRadius / topRadii) * width, (outerTopRightRadius / rightRadii) * height),
|
|
608
|
+
bottomLeft: getBorderCapRadius(outerBottomLeftRadius, (outerBottomLeftRadius / bottomRadii) * width, (outerBottomLeftRadius / leftRadii) * height),
|
|
609
|
+
bottomRight: getBorderCapRadius(outerBottomRightRadius, (outerBottomRightRadius / bottomRadii) * width, (outerBottomRightRadius / rightRadii) * height),
|
|
610
|
+
};
|
|
611
|
+
return cappedOuterRadii;
|
|
612
|
+
}
|
|
613
|
+
function drawNonUniformBorders(nativeView, background) {
|
|
614
|
+
const layer = nativeView.layer;
|
|
615
|
+
const layerBounds = layer.bounds;
|
|
616
|
+
layer.borderColor = null;
|
|
617
|
+
layer.borderWidth = 0;
|
|
618
|
+
layer.cornerRadius = 0;
|
|
619
|
+
const cappedOuterRadii = calculateNonUniformBorderCappedRadii(layerBounds, background);
|
|
620
|
+
if (nativeView.maskType === iosViewUtils.LayerMask.BORDER && layer.mask instanceof CAShapeLayer) {
|
|
621
|
+
layer.mask.path = generateNonUniformBorderOuterClipPath(layerBounds, cappedOuterRadii);
|
|
622
|
+
}
|
|
623
|
+
if (background.hasBorderWidth()) {
|
|
624
|
+
if (!nativeView.hasNonUniformBorder) {
|
|
625
|
+
nativeView.borderLayer = CAShapeLayer.new();
|
|
626
|
+
nativeView.borderLayer.fillRule = kCAFillRuleEvenOdd;
|
|
627
|
+
layer.addSublayer(nativeView.borderLayer);
|
|
628
|
+
nativeView.hasNonUniformBorder = true;
|
|
477
629
|
}
|
|
478
|
-
if (
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
const innerTopLeftMaxRadius = max(innerTopLeftWRadius, innerTopLeftHRadius);
|
|
482
|
-
const innerTopLeftTransform = CGAffineTransformMake(innerTopLeftMaxRadius && innerTopLeftWRadius / innerTopLeftMaxRadius, 0, 0, innerTopLeftMaxRadius && innerTopLeftHRadius / innerTopLeftMaxRadius, left + cappedBorderLeftWidth + innerTopLeftWRadius, top + cappedBorderTopWidth + innerTopLeftHRadius);
|
|
483
|
-
CGPathAddArc(borderPath, innerTopLeftTransform, 0, 0, innerTopLeftMaxRadius, Math.PI, (Math.PI * 3) / 2, false);
|
|
630
|
+
if (background.hasUniformBorderColor()) {
|
|
631
|
+
nativeView.borderLayer.fillColor = background.borderTopColor?.ios?.CGColor || UIColor.blackColor.CGColor;
|
|
632
|
+
nativeView.borderLayer.path = generateNonUniformBorderInnerClipPath(layerBounds, background, cappedOuterRadii);
|
|
484
633
|
}
|
|
485
634
|
else {
|
|
486
|
-
|
|
635
|
+
// Non-uniform borders need more layers in order to display multiple colors at the same time
|
|
636
|
+
let borderTopLayer, borderRightLayer, borderBottomLayer, borderLeftLayer;
|
|
637
|
+
if (!nativeView.hasNonUniformBorderColor) {
|
|
638
|
+
const maskLayer = CAShapeLayer.new();
|
|
639
|
+
maskLayer.fillRule = kCAFillRuleEvenOdd;
|
|
640
|
+
nativeView.borderLayer.mask = maskLayer;
|
|
641
|
+
borderTopLayer = CAShapeLayer.new();
|
|
642
|
+
borderRightLayer = CAShapeLayer.new();
|
|
643
|
+
borderBottomLayer = CAShapeLayer.new();
|
|
644
|
+
borderLeftLayer = CAShapeLayer.new();
|
|
645
|
+
nativeView.borderLayer.addSublayer(borderTopLayer);
|
|
646
|
+
nativeView.borderLayer.addSublayer(borderRightLayer);
|
|
647
|
+
nativeView.borderLayer.addSublayer(borderBottomLayer);
|
|
648
|
+
nativeView.borderLayer.addSublayer(borderLeftLayer);
|
|
649
|
+
nativeView.hasNonUniformBorderColor = true;
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
borderTopLayer = nativeView.borderLayer.sublayers[0];
|
|
653
|
+
borderRightLayer = nativeView.borderLayer.sublayers[1];
|
|
654
|
+
borderBottomLayer = nativeView.borderLayer.sublayers[2];
|
|
655
|
+
borderLeftLayer = nativeView.borderLayer.sublayers[3];
|
|
656
|
+
}
|
|
657
|
+
const paths = generateNonUniformMultiColorBorderPaths(layerBounds, background);
|
|
658
|
+
borderTopLayer.fillColor = background.borderTopColor?.ios?.CGColor || UIColor.blackColor.CGColor;
|
|
659
|
+
borderTopLayer.path = paths[0];
|
|
660
|
+
borderRightLayer.fillColor = background.borderRightColor?.ios?.CGColor || UIColor.blackColor.CGColor;
|
|
661
|
+
borderRightLayer.path = paths[1];
|
|
662
|
+
borderBottomLayer.fillColor = background.borderBottomColor?.ios?.CGColor || UIColor.blackColor.CGColor;
|
|
663
|
+
borderBottomLayer.path = paths[2];
|
|
664
|
+
borderLeftLayer.fillColor = background.borderLeftColor?.ios?.CGColor || UIColor.blackColor.CGColor;
|
|
665
|
+
borderLeftLayer.path = paths[3];
|
|
666
|
+
// Clip inner area to create borders
|
|
667
|
+
if (nativeView.borderLayer.mask instanceof CAShapeLayer) {
|
|
668
|
+
nativeView.borderLayer.mask.path = generateNonUniformBorderInnerClipPath(layerBounds, background, cappedOuterRadii);
|
|
669
|
+
}
|
|
487
670
|
}
|
|
488
|
-
CGPathCloseSubpath(borderPath);
|
|
489
|
-
const borderLayer = CAShapeLayer.layer();
|
|
490
|
-
borderLayer.fillColor = (background.borderTopColor && background.borderTopColor.ios.CGColor) || UIColor.blackColor.CGColor;
|
|
491
|
-
borderLayer.fillRule = kCAFillRuleEvenOdd;
|
|
492
|
-
borderLayer.path = borderPath;
|
|
493
|
-
layer.addSublayer(borderLayer);
|
|
494
|
-
nativeView.borderLayer = borderLayer;
|
|
495
671
|
}
|
|
496
|
-
nativeView.hasNonUniformBorder = true;
|
|
497
672
|
}
|
|
498
|
-
function
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
673
|
+
function calculateInnerBorderClipRadius(radius, insetX, insetY) {
|
|
674
|
+
const innerXRadius = Math.max(0, radius - insetX);
|
|
675
|
+
const innerYRadius = Math.max(0, radius - insetY);
|
|
676
|
+
const innerMaxRadius = Math.max(innerXRadius, innerYRadius);
|
|
677
|
+
return {
|
|
678
|
+
xRadius: innerXRadius,
|
|
679
|
+
yRadius: innerYRadius,
|
|
680
|
+
maxRadius: innerMaxRadius,
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Generates a path that represents the rounded view area.
|
|
685
|
+
*
|
|
686
|
+
* @param bounds
|
|
687
|
+
* @param cappedRadii
|
|
688
|
+
* @param offset
|
|
689
|
+
* @returns
|
|
690
|
+
*/
|
|
691
|
+
export function generateNonUniformBorderOuterClipPath(bounds, cappedRadii, offset = 0) {
|
|
692
|
+
const { width, height } = bounds.size;
|
|
693
|
+
const { x, y } = bounds.origin;
|
|
694
|
+
const left = x - offset;
|
|
695
|
+
const top = y - offset;
|
|
696
|
+
const right = x + width + offset;
|
|
697
|
+
const bottom = y + height + offset;
|
|
698
|
+
const clipPath = CGPathCreateMutable();
|
|
699
|
+
CGPathMoveToPoint(clipPath, null, left + cappedRadii.topLeft, top);
|
|
700
|
+
CGPathAddArcToPoint(clipPath, null, right, top, right, top + cappedRadii.topRight, cappedRadii.topRight);
|
|
701
|
+
CGPathAddArcToPoint(clipPath, null, right, bottom, right - cappedRadii.bottomRight, bottom, cappedRadii.bottomRight);
|
|
702
|
+
CGPathAddArcToPoint(clipPath, null, left, bottom, left, bottom - cappedRadii.bottomLeft, cappedRadii.bottomLeft);
|
|
703
|
+
CGPathAddArcToPoint(clipPath, null, left, top, left + cappedRadii.topLeft, top, cappedRadii.topLeft);
|
|
704
|
+
CGPathCloseSubpath(clipPath);
|
|
705
|
+
return clipPath;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* Generates a path that represents the area inside borders.
|
|
709
|
+
*
|
|
710
|
+
* @param bounds
|
|
711
|
+
* @param background
|
|
712
|
+
* @param cappedOuterRadii
|
|
713
|
+
* @returns
|
|
714
|
+
*/
|
|
715
|
+
function generateNonUniformBorderInnerClipPath(bounds, background, cappedOuterRadii) {
|
|
716
|
+
const { width, height } = bounds.size;
|
|
717
|
+
const { x, y } = bounds.origin;
|
|
718
|
+
const position = {
|
|
719
|
+
left: x,
|
|
720
|
+
top: y,
|
|
721
|
+
bottom: y + height,
|
|
722
|
+
right: x + width,
|
|
513
723
|
};
|
|
514
|
-
const
|
|
515
|
-
const
|
|
516
|
-
const
|
|
517
|
-
const
|
|
724
|
+
const borderTopWidth = Math.max(0, layout.toDeviceIndependentPixels(background.borderTopWidth));
|
|
725
|
+
const borderRightWidth = Math.max(0, layout.toDeviceIndependentPixels(background.borderRightWidth));
|
|
726
|
+
const borderBottomWidth = Math.max(0, layout.toDeviceIndependentPixels(background.borderBottomWidth));
|
|
727
|
+
const borderLeftWidth = Math.max(0, layout.toDeviceIndependentPixels(background.borderLeftWidth));
|
|
728
|
+
const borderVWidth = borderTopWidth + borderBottomWidth;
|
|
729
|
+
const borderHWidth = borderLeftWidth + borderRightWidth;
|
|
730
|
+
const cappedBorderTopWidth = borderTopWidth && borderTopWidth * Math.min(1, height / borderVWidth);
|
|
731
|
+
const cappedBorderRightWidth = borderRightWidth && borderRightWidth * Math.min(1, width / borderHWidth);
|
|
732
|
+
const cappedBorderBottomWidth = borderBottomWidth && borderBottomWidth * Math.min(1, height / borderVWidth);
|
|
733
|
+
const cappedBorderLeftWidth = borderLeftWidth && borderLeftWidth * Math.min(1, width / borderHWidth);
|
|
734
|
+
const clipPath = CGPathCreateMutable();
|
|
735
|
+
CGPathAddRect(clipPath, null, CGRectMake(x, y, width, height));
|
|
736
|
+
// Inner clip paths
|
|
737
|
+
if (cappedBorderTopWidth > 0 || cappedBorderLeftWidth > 0) {
|
|
738
|
+
CGPathMoveToPoint(clipPath, null, position.left + cappedOuterRadii.topLeft, position.top + cappedBorderTopWidth);
|
|
739
|
+
}
|
|
740
|
+
else {
|
|
741
|
+
CGPathMoveToPoint(clipPath, null, position.left, position.top);
|
|
742
|
+
}
|
|
743
|
+
if (cappedBorderTopWidth > 0 || cappedBorderRightWidth > 0) {
|
|
744
|
+
const { xRadius, yRadius, maxRadius } = calculateInnerBorderClipRadius(cappedOuterRadii.topRight, cappedBorderRightWidth, cappedBorderTopWidth);
|
|
745
|
+
const innerTopRightTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.right - cappedBorderRightWidth - xRadius, position.top + cappedBorderTopWidth + yRadius);
|
|
746
|
+
CGPathAddArc(clipPath, innerTopRightTransform, 0, 0, maxRadius, (Math.PI * 3) / 2, 0, false);
|
|
747
|
+
}
|
|
748
|
+
else {
|
|
749
|
+
CGPathAddLineToPoint(clipPath, null, position.right, position.top);
|
|
750
|
+
}
|
|
751
|
+
if (cappedBorderBottomWidth > 0 || cappedBorderRightWidth > 0) {
|
|
752
|
+
const { xRadius, yRadius, maxRadius } = calculateInnerBorderClipRadius(cappedOuterRadii.bottomRight, cappedBorderRightWidth, cappedBorderBottomWidth);
|
|
753
|
+
const innerBottomRightTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.right - cappedBorderRightWidth - xRadius, position.bottom - cappedBorderBottomWidth - yRadius);
|
|
754
|
+
CGPathAddArc(clipPath, innerBottomRightTransform, 0, 0, maxRadius, 0, Math.PI / 2, false);
|
|
755
|
+
}
|
|
756
|
+
else {
|
|
757
|
+
CGPathAddLineToPoint(clipPath, null, position.right, position.bottom);
|
|
758
|
+
}
|
|
759
|
+
if (cappedBorderBottomWidth > 0 || cappedBorderLeftWidth > 0) {
|
|
760
|
+
const { xRadius, yRadius, maxRadius } = calculateInnerBorderClipRadius(cappedOuterRadii.bottomLeft, cappedBorderLeftWidth, cappedBorderBottomWidth);
|
|
761
|
+
const innerBottomLeftTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.left + cappedBorderLeftWidth + xRadius, position.bottom - cappedBorderBottomWidth - yRadius);
|
|
762
|
+
CGPathAddArc(clipPath, innerBottomLeftTransform, 0, 0, maxRadius, Math.PI / 2, Math.PI, false);
|
|
763
|
+
}
|
|
764
|
+
else {
|
|
765
|
+
CGPathAddLineToPoint(clipPath, null, position.left, position.bottom);
|
|
766
|
+
}
|
|
767
|
+
if (cappedBorderTopWidth > 0 || cappedBorderLeftWidth > 0) {
|
|
768
|
+
const { xRadius, yRadius, maxRadius } = calculateInnerBorderClipRadius(cappedOuterRadii.topLeft, cappedBorderLeftWidth, cappedBorderTopWidth);
|
|
769
|
+
const innerTopLeftTransform = CGAffineTransformMake(maxRadius && xRadius / maxRadius, 0, 0, maxRadius && yRadius / maxRadius, position.left + cappedBorderLeftWidth + xRadius, position.top + cappedBorderTopWidth + yRadius);
|
|
770
|
+
CGPathAddArc(clipPath, innerTopLeftTransform, 0, 0, maxRadius, Math.PI, (Math.PI * 3) / 2, false);
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
CGPathAddLineToPoint(clipPath, null, position.left, position.top);
|
|
774
|
+
}
|
|
775
|
+
CGPathCloseSubpath(clipPath);
|
|
776
|
+
return clipPath;
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Calculates the needed widths for creating triangular shapes for each border.
|
|
780
|
+
* To achieve this, all border widths are scaled according to view bounds.
|
|
781
|
+
*
|
|
782
|
+
* @param bounds
|
|
783
|
+
* @param background
|
|
784
|
+
* @returns
|
|
785
|
+
*/
|
|
786
|
+
function getBorderTriangleWidths(bounds, background) {
|
|
787
|
+
const width = bounds.origin.x + bounds.size.width;
|
|
788
|
+
const height = bounds.origin.y + bounds.size.height;
|
|
789
|
+
const borderTopWidth = Math.max(0, layout.toDeviceIndependentPixels(background.borderTopWidth));
|
|
790
|
+
const borderRightWidth = Math.max(0, layout.toDeviceIndependentPixels(background.borderRightWidth));
|
|
791
|
+
const borderBottomWidth = Math.max(0, layout.toDeviceIndependentPixels(background.borderBottomWidth));
|
|
792
|
+
const borderLeftWidth = Math.max(0, layout.toDeviceIndependentPixels(background.borderLeftWidth));
|
|
793
|
+
const verticalBorderWidth = borderTopWidth + borderBottomWidth;
|
|
794
|
+
const horizontalBorderWidth = borderLeftWidth + borderRightWidth;
|
|
795
|
+
let verticalBorderMultiplier = verticalBorderWidth > 0 ? height / verticalBorderWidth : 0;
|
|
796
|
+
let horizontalBorderMultiplier = horizontalBorderWidth > 0 ? width / horizontalBorderWidth : 0;
|
|
797
|
+
// Both directions should consider each other in order to scale widths properly, as a view might have different width and height
|
|
798
|
+
if (verticalBorderMultiplier > 0 && verticalBorderMultiplier < horizontalBorderMultiplier) {
|
|
799
|
+
horizontalBorderMultiplier -= horizontalBorderMultiplier - verticalBorderMultiplier;
|
|
800
|
+
}
|
|
801
|
+
if (horizontalBorderMultiplier > 0 && horizontalBorderMultiplier < verticalBorderMultiplier) {
|
|
802
|
+
verticalBorderMultiplier -= verticalBorderMultiplier - horizontalBorderMultiplier;
|
|
803
|
+
}
|
|
804
|
+
return {
|
|
805
|
+
top: borderTopWidth * verticalBorderMultiplier,
|
|
806
|
+
right: borderRightWidth * horizontalBorderMultiplier,
|
|
807
|
+
bottom: borderBottomWidth * verticalBorderMultiplier,
|
|
808
|
+
left: borderLeftWidth * horizontalBorderMultiplier,
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Generates paths for visualizing borders with different colors per side.
|
|
813
|
+
* This is achieved by extending all borders enough to consume entire view size,
|
|
814
|
+
* then using an even-odd inner mask to clip and eventually render borders according to their corresponding width.
|
|
815
|
+
*
|
|
816
|
+
* @param bounds
|
|
817
|
+
* @param background
|
|
818
|
+
* @returns
|
|
819
|
+
*/
|
|
820
|
+
function generateNonUniformMultiColorBorderPaths(bounds, background) {
|
|
821
|
+
const { width, height } = bounds.size;
|
|
822
|
+
const { x, y } = bounds.origin;
|
|
823
|
+
const position = {
|
|
824
|
+
left: x,
|
|
825
|
+
top: y,
|
|
826
|
+
bottom: y + height,
|
|
827
|
+
right: x + width,
|
|
828
|
+
};
|
|
829
|
+
const borderWidths = getBorderTriangleWidths(bounds, background);
|
|
830
|
+
const paths = new Array(4);
|
|
518
831
|
const lto = {
|
|
519
|
-
x:
|
|
520
|
-
y:
|
|
832
|
+
x: position.left,
|
|
833
|
+
y: position.top,
|
|
521
834
|
}; // left-top-outside
|
|
522
835
|
const lti = {
|
|
523
|
-
x:
|
|
524
|
-
y:
|
|
836
|
+
x: position.left + borderWidths.left,
|
|
837
|
+
y: position.top + borderWidths.top,
|
|
525
838
|
}; // left-top-inside
|
|
526
839
|
const rto = {
|
|
527
|
-
x:
|
|
528
|
-
y:
|
|
840
|
+
x: position.right,
|
|
841
|
+
y: position.top,
|
|
529
842
|
}; // right-top-outside
|
|
530
843
|
const rti = {
|
|
531
|
-
x:
|
|
532
|
-
y:
|
|
844
|
+
x: position.right - borderWidths.right,
|
|
845
|
+
y: position.top + borderWidths.top,
|
|
533
846
|
}; // right-top-inside
|
|
534
847
|
const rbo = {
|
|
535
|
-
x:
|
|
536
|
-
y:
|
|
848
|
+
x: position.right,
|
|
849
|
+
y: position.bottom,
|
|
537
850
|
}; // right-bottom-outside
|
|
538
851
|
const rbi = {
|
|
539
|
-
x:
|
|
540
|
-
y:
|
|
852
|
+
x: position.right - borderWidths.right,
|
|
853
|
+
y: position.bottom - borderWidths.bottom,
|
|
541
854
|
}; // right-bottom-inside
|
|
542
855
|
const lbo = {
|
|
543
|
-
x:
|
|
544
|
-
y:
|
|
856
|
+
x: position.left,
|
|
857
|
+
y: position.bottom,
|
|
545
858
|
}; // left-bottom-outside
|
|
546
859
|
const lbi = {
|
|
547
|
-
x:
|
|
548
|
-
y:
|
|
860
|
+
x: position.left + borderWidths.left,
|
|
861
|
+
y: position.bottom - borderWidths.bottom,
|
|
549
862
|
}; // left-bottom-inside
|
|
550
|
-
let hasNonUniformBorder;
|
|
551
863
|
const borderTopColor = background.borderTopColor;
|
|
552
|
-
|
|
864
|
+
const borderRightColor = background.borderRightColor;
|
|
865
|
+
const borderBottomColor = background.borderBottomColor;
|
|
866
|
+
const borderLeftColor = background.borderLeftColor;
|
|
867
|
+
if (borderWidths.top > 0 && borderTopColor?.ios) {
|
|
553
868
|
const topBorderPath = CGPathCreateMutable();
|
|
554
869
|
CGPathMoveToPoint(topBorderPath, null, lto.x, lto.y);
|
|
555
870
|
CGPathAddLineToPoint(topBorderPath, null, rto.x, rto.y);
|
|
556
871
|
CGPathAddLineToPoint(topBorderPath, null, rti.x, rti.y);
|
|
557
|
-
|
|
872
|
+
if (rti.x !== lti.x) {
|
|
873
|
+
CGPathAddLineToPoint(topBorderPath, null, lti.x, lti.y);
|
|
874
|
+
}
|
|
558
875
|
CGPathAddLineToPoint(topBorderPath, null, lto.x, lto.y);
|
|
559
|
-
|
|
560
|
-
topBorderLayer.fillColor = background.borderTopColor.ios.CGColor;
|
|
561
|
-
topBorderLayer.path = topBorderPath;
|
|
562
|
-
borderLayer.addSublayer(topBorderLayer);
|
|
563
|
-
nativeView.topBorderLayer = topBorderLayer;
|
|
564
|
-
hasNonUniformBorder = true;
|
|
876
|
+
paths[0] = topBorderPath;
|
|
565
877
|
}
|
|
566
|
-
|
|
567
|
-
if (right > 0 && borderRightColor && borderRightColor.ios) {
|
|
878
|
+
if (borderWidths.right > 0 && borderRightColor?.ios) {
|
|
568
879
|
const rightBorderPath = CGPathCreateMutable();
|
|
569
880
|
CGPathMoveToPoint(rightBorderPath, null, rto.x, rto.y);
|
|
570
881
|
CGPathAddLineToPoint(rightBorderPath, null, rbo.x, rbo.y);
|
|
571
882
|
CGPathAddLineToPoint(rightBorderPath, null, rbi.x, rbi.y);
|
|
572
|
-
|
|
883
|
+
if (rbi.y !== rti.y) {
|
|
884
|
+
CGPathAddLineToPoint(rightBorderPath, null, rti.x, rti.y);
|
|
885
|
+
}
|
|
573
886
|
CGPathAddLineToPoint(rightBorderPath, null, rto.x, rto.y);
|
|
574
|
-
|
|
575
|
-
rightBorderLayer.fillColor = background.borderRightColor.ios.CGColor;
|
|
576
|
-
rightBorderLayer.path = rightBorderPath;
|
|
577
|
-
borderLayer.addSublayer(rightBorderLayer);
|
|
578
|
-
nativeView.rightBorderLayer = rightBorderLayer;
|
|
579
|
-
hasNonUniformBorder = true;
|
|
887
|
+
paths[1] = rightBorderPath;
|
|
580
888
|
}
|
|
581
|
-
|
|
582
|
-
if (bottom > 0 && borderBottomColor && borderBottomColor.ios) {
|
|
889
|
+
if (borderWidths.bottom > 0 && borderBottomColor?.ios) {
|
|
583
890
|
const bottomBorderPath = CGPathCreateMutable();
|
|
584
891
|
CGPathMoveToPoint(bottomBorderPath, null, rbo.x, rbo.y);
|
|
585
892
|
CGPathAddLineToPoint(bottomBorderPath, null, lbo.x, lbo.y);
|
|
586
893
|
CGPathAddLineToPoint(bottomBorderPath, null, lbi.x, lbi.y);
|
|
587
|
-
|
|
894
|
+
if (lbi.x !== rbi.x) {
|
|
895
|
+
CGPathAddLineToPoint(bottomBorderPath, null, rbi.x, rbi.y);
|
|
896
|
+
}
|
|
588
897
|
CGPathAddLineToPoint(bottomBorderPath, null, rbo.x, rbo.y);
|
|
589
|
-
|
|
590
|
-
bottomBorderLayer.fillColor = background.borderBottomColor.ios.CGColor;
|
|
591
|
-
bottomBorderLayer.path = bottomBorderPath;
|
|
592
|
-
borderLayer.addSublayer(bottomBorderLayer);
|
|
593
|
-
nativeView.bottomBorderLayer = bottomBorderLayer;
|
|
594
|
-
hasNonUniformBorder = true;
|
|
898
|
+
paths[2] = bottomBorderPath;
|
|
595
899
|
}
|
|
596
|
-
|
|
597
|
-
if (left > 0 && borderLeftColor && borderLeftColor.ios) {
|
|
900
|
+
if (borderWidths.left > 0 && borderLeftColor?.ios) {
|
|
598
901
|
const leftBorderPath = CGPathCreateMutable();
|
|
599
902
|
CGPathMoveToPoint(leftBorderPath, null, lbo.x, lbo.y);
|
|
600
903
|
CGPathAddLineToPoint(leftBorderPath, null, lto.x, lto.y);
|
|
601
904
|
CGPathAddLineToPoint(leftBorderPath, null, lti.x, lti.y);
|
|
602
|
-
|
|
905
|
+
if (lti.y !== lbi.y) {
|
|
906
|
+
CGPathAddLineToPoint(leftBorderPath, null, lbi.x, lbi.y);
|
|
907
|
+
}
|
|
603
908
|
CGPathAddLineToPoint(leftBorderPath, null, lbo.x, lbo.y);
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
borderLayer.addSublayer(leftBorderLayer);
|
|
608
|
-
nativeView.leftBorderLayer = leftBorderLayer;
|
|
609
|
-
hasNonUniformBorder = true;
|
|
610
|
-
}
|
|
611
|
-
nativeView.hasNonUniformBorder = hasNonUniformBorder;
|
|
909
|
+
paths[3] = leftBorderPath;
|
|
910
|
+
}
|
|
911
|
+
return paths;
|
|
612
912
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
const
|
|
616
|
-
layer
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
layer.shadowRadius = Length.toDevicePixels(boxShadow.blurRadius, 0.0);
|
|
628
|
-
layer.shadowColor = boxShadow.color.ios.CGColor;
|
|
629
|
-
// prettier-ignore
|
|
630
|
-
layer.shadowOffset = CGSizeMake(Length.toDevicePixels(boxShadow.offsetX, 0.0), Length.toDevicePixels(boxShadow.offsetY, 0.0));
|
|
631
|
-
// this should match the view's border radius
|
|
632
|
-
let cornerRadius;
|
|
633
|
-
if (typeof view.style.borderRadius !== 'number') {
|
|
634
|
-
cornerRadius = Length.toDevicePixels(view.style.borderRadius, 0.0);
|
|
913
|
+
function drawBoxShadow(view) {
|
|
914
|
+
const background = view.style.backgroundInternal;
|
|
915
|
+
const nativeView = view.nativeViewProtected;
|
|
916
|
+
const layer = nativeView.layer;
|
|
917
|
+
// There is no parent to add shadow to
|
|
918
|
+
if (!layer.superlayer) {
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
const bounds = nativeView.bounds;
|
|
922
|
+
const boxShadow = background.getBoxShadow();
|
|
923
|
+
// Initialize outer shadows
|
|
924
|
+
let outerShadowContainerLayer;
|
|
925
|
+
if (nativeView.outerShadowContainerLayer) {
|
|
926
|
+
outerShadowContainerLayer = nativeView.outerShadowContainerLayer;
|
|
635
927
|
}
|
|
636
928
|
else {
|
|
637
|
-
|
|
929
|
+
outerShadowContainerLayer = CALayer.new();
|
|
930
|
+
// TODO: Make this dynamic when views get support for multiple shadows
|
|
931
|
+
const shadowLayer = CALayer.new();
|
|
932
|
+
// This mask is necessary to maintain transparent background
|
|
933
|
+
const maskLayer = CAShapeLayer.new();
|
|
934
|
+
maskLayer.fillRule = kCAFillRuleEvenOdd;
|
|
935
|
+
shadowLayer.mask = maskLayer;
|
|
936
|
+
outerShadowContainerLayer.addSublayer(shadowLayer);
|
|
937
|
+
// Instead of nesting it, add shadow container layer underneath view so that it's not affected by border masking
|
|
938
|
+
layer.superlayer.insertSublayerBelow(outerShadowContainerLayer, layer);
|
|
939
|
+
nativeView.outerShadowContainerLayer = outerShadowContainerLayer;
|
|
940
|
+
}
|
|
941
|
+
// Apply clip path to shadow
|
|
942
|
+
if (nativeView.maskType === iosViewUtils.LayerMask.CLIP_PATH && layer.mask instanceof CAShapeLayer) {
|
|
943
|
+
if (!outerShadowContainerLayer.mask) {
|
|
944
|
+
outerShadowContainerLayer.mask = CAShapeLayer.new();
|
|
945
|
+
}
|
|
946
|
+
if (outerShadowContainerLayer.mask instanceof CAShapeLayer) {
|
|
947
|
+
outerShadowContainerLayer.mask.path = layer.mask.path;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
outerShadowContainerLayer.bounds = bounds;
|
|
951
|
+
outerShadowContainerLayer.anchorPoint = layer.anchorPoint;
|
|
952
|
+
outerShadowContainerLayer.position = nativeView.center;
|
|
953
|
+
outerShadowContainerLayer.zPosition = layer.zPosition;
|
|
954
|
+
// Inherit view visibility values
|
|
955
|
+
outerShadowContainerLayer.opacity = layer.opacity;
|
|
956
|
+
outerShadowContainerLayer.hidden = layer.hidden;
|
|
957
|
+
const outerShadowLayers = outerShadowContainerLayer.sublayers;
|
|
958
|
+
if (outerShadowLayers?.count) {
|
|
959
|
+
for (let i = 0, count = outerShadowLayers.count; i < count; i++) {
|
|
960
|
+
const shadowLayer = outerShadowLayers[i];
|
|
961
|
+
const shadowRadius = layout.toDeviceIndependentPixels(boxShadow.blurRadius);
|
|
962
|
+
const spreadRadius = layout.toDeviceIndependentPixels(boxShadow.spreadRadius);
|
|
963
|
+
const offsetX = layout.toDeviceIndependentPixels(boxShadow.offsetX);
|
|
964
|
+
const offsetY = layout.toDeviceIndependentPixels(boxShadow.offsetY);
|
|
965
|
+
const { maskPath, shadowPath } = ios.generateShadowLayerPaths(view, bounds);
|
|
966
|
+
shadowLayer.allowsEdgeAntialiasing = true;
|
|
967
|
+
shadowLayer.contentsScale = Screen.mainScreen.scale;
|
|
968
|
+
// Shadow opacity is handled on the shadow's color instance
|
|
969
|
+
shadowLayer.shadowOpacity = boxShadow.color?.a ? boxShadow.color.a / 255 : 1;
|
|
970
|
+
shadowLayer.shadowRadius = shadowRadius;
|
|
971
|
+
shadowLayer.shadowColor = boxShadow.color?.ios?.CGColor;
|
|
972
|
+
shadowLayer.shadowOffset = CGSizeMake(offsetX, offsetY);
|
|
973
|
+
// Apply spread radius by expanding shadow layer bounds (this has a nice glow with radii set to 0)
|
|
974
|
+
shadowLayer.shadowPath = shadowPath;
|
|
975
|
+
// A mask that ensures that view maintains transparent background
|
|
976
|
+
if (shadowLayer.mask instanceof CAShapeLayer) {
|
|
977
|
+
shadowLayer.mask.path = maskPath;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
638
980
|
}
|
|
639
|
-
// apply spreadRadius by expanding shadow layer bounds
|
|
640
|
-
// prettier-ignore
|
|
641
|
-
const bounds = CGRectInset(nativeView.bounds, -Length.toDevicePixels(boxShadow.spreadRadius, 0.0), -Length.toDevicePixels(boxShadow.spreadRadius, 0.0));
|
|
642
|
-
// This has the nice glow with box shadow of 0,0
|
|
643
|
-
layer.shadowPath = UIBezierPath.bezierPathWithRoundedRectCornerRadius(bounds, cornerRadius).CGPath;
|
|
644
981
|
}
|
|
645
982
|
function clearBoxShadow(nativeView) {
|
|
646
|
-
nativeView.
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
return;
|
|
983
|
+
if (nativeView.outerShadowContainerLayer) {
|
|
984
|
+
nativeView.outerShadowContainerLayer.removeFromSuperlayer();
|
|
985
|
+
nativeView.outerShadowContainerLayer = null;
|
|
650
986
|
}
|
|
651
|
-
layer.masksToBounds = true;
|
|
652
|
-
layer.shadowOffset = CGSizeMake(0, 0);
|
|
653
|
-
layer.shadowColor = UIColor.clearColor.CGColor;
|
|
654
|
-
layer.cornerRadius = 0.0;
|
|
655
|
-
layer.shadowRadius = 0.0;
|
|
656
|
-
layer.shadowOpacity = 0.0;
|
|
657
987
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
break;
|
|
680
|
-
case 'inset':
|
|
681
|
-
path = insetPath(value, bounds);
|
|
682
|
-
break;
|
|
683
|
-
case 'circle':
|
|
684
|
-
path = circlePath(value, bounds);
|
|
685
|
-
break;
|
|
686
|
-
case 'ellipse':
|
|
687
|
-
path = ellipsePath(value, bounds);
|
|
688
|
-
break;
|
|
689
|
-
case 'polygon':
|
|
690
|
-
path = polygonPath(value, bounds);
|
|
691
|
-
break;
|
|
692
|
-
}
|
|
693
|
-
if (path) {
|
|
694
|
-
const shape = CAShapeLayer.layer();
|
|
695
|
-
shape.path = path;
|
|
696
|
-
layer.mask = shape;
|
|
697
|
-
nativeView.clipsToBounds = true;
|
|
698
|
-
const borderWidth = background.getUniformBorderWidth();
|
|
699
|
-
const borderColor = background.getUniformBorderColor();
|
|
700
|
-
if (borderWidth > 0 && borderColor instanceof Color) {
|
|
701
|
-
const borderLayer = CAShapeLayer.layer();
|
|
702
|
-
borderLayer.path = path;
|
|
703
|
-
borderLayer.lineWidth = borderWidth * 2;
|
|
704
|
-
borderLayer.strokeColor = borderColor.ios.CGColor;
|
|
705
|
-
borderLayer.fillColor = clearCGColor;
|
|
706
|
-
borderLayer.frame = nativeView.bounds;
|
|
707
|
-
layer.borderColor = undefined;
|
|
708
|
-
layer.borderWidth = 0;
|
|
709
|
-
layer.addSublayer(borderLayer);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
988
|
+
/**
|
|
989
|
+
* Creates a mask that ensures no shadow will be displayed underneath transparent backgrounds.
|
|
990
|
+
*
|
|
991
|
+
* @param bounds
|
|
992
|
+
* @param boxShadow
|
|
993
|
+
* @param bordersClipPath
|
|
994
|
+
* @returns
|
|
995
|
+
*/
|
|
996
|
+
function generateShadowMaskPath(bounds, boxShadow, innerClipPath) {
|
|
997
|
+
const shadowRadius = layout.toDeviceIndependentPixels(boxShadow.blurRadius);
|
|
998
|
+
const spreadRadius = layout.toDeviceIndependentPixels(boxShadow.spreadRadius);
|
|
999
|
+
const offsetX = layout.toDeviceIndependentPixels(boxShadow.offsetX);
|
|
1000
|
+
const offsetY = layout.toDeviceIndependentPixels(boxShadow.offsetY);
|
|
1001
|
+
// This value has to be large enough to avoid clipping shadow halo effect
|
|
1002
|
+
const outerRectRadius = shadowRadius * 3 + spreadRadius;
|
|
1003
|
+
const maskPath = CGPathCreateMutable();
|
|
1004
|
+
// Proper clip position and size
|
|
1005
|
+
const outerRect = CGRectOffset(CGRectInset(bounds, -outerRectRadius, -outerRectRadius), offsetX, offsetY);
|
|
1006
|
+
CGPathAddPath(maskPath, null, innerClipPath);
|
|
1007
|
+
CGPathAddRect(maskPath, null, outerRect);
|
|
1008
|
+
return maskPath;
|
|
712
1009
|
}
|
|
713
|
-
function rectPath(value,
|
|
1010
|
+
function rectPath(value, position) {
|
|
714
1011
|
const arr = value.split(/[\s]+/);
|
|
715
|
-
const top = cssValueToDeviceIndependentPixels(arr[0],
|
|
716
|
-
const right = cssValueToDeviceIndependentPixels(arr[1],
|
|
717
|
-
const bottom = cssValueToDeviceIndependentPixels(arr[2],
|
|
718
|
-
const left = cssValueToDeviceIndependentPixels(arr[3],
|
|
1012
|
+
const top = cssValueToDeviceIndependentPixels(arr[0], position.top);
|
|
1013
|
+
const right = cssValueToDeviceIndependentPixels(arr[1], position.right);
|
|
1014
|
+
const bottom = cssValueToDeviceIndependentPixels(arr[2], position.bottom);
|
|
1015
|
+
const left = cssValueToDeviceIndependentPixels(arr[3], position.left);
|
|
719
1016
|
return UIBezierPath.bezierPathWithRect(CGRectMake(left, top, right - left, bottom - top)).CGPath;
|
|
720
1017
|
}
|
|
721
|
-
function insetPath(value,
|
|
1018
|
+
function insetPath(value, position) {
|
|
722
1019
|
const arr = value.split(/[\s]+/);
|
|
723
1020
|
let topString;
|
|
724
1021
|
let rightString;
|
|
@@ -742,40 +1039,40 @@ function insetPath(value, bounds) {
|
|
|
742
1039
|
bottomString = arr[2];
|
|
743
1040
|
leftString = arr[3];
|
|
744
1041
|
}
|
|
745
|
-
const top = cssValueToDeviceIndependentPixels(topString,
|
|
746
|
-
const right = cssValueToDeviceIndependentPixels('100%',
|
|
747
|
-
const bottom = cssValueToDeviceIndependentPixels('100%',
|
|
748
|
-
const left = cssValueToDeviceIndependentPixels(leftString,
|
|
1042
|
+
const top = cssValueToDeviceIndependentPixels(topString, position.bottom);
|
|
1043
|
+
const right = cssValueToDeviceIndependentPixels('100%', position.right) - cssValueToDeviceIndependentPixels(rightString, position.right);
|
|
1044
|
+
const bottom = cssValueToDeviceIndependentPixels('100%', position.bottom) - cssValueToDeviceIndependentPixels(bottomString, position.bottom);
|
|
1045
|
+
const left = cssValueToDeviceIndependentPixels(leftString, position.right);
|
|
749
1046
|
return UIBezierPath.bezierPathWithRect(CGRectMake(left, top, right - left, bottom - top)).CGPath;
|
|
750
1047
|
}
|
|
751
|
-
function circlePath(value,
|
|
1048
|
+
function circlePath(value, position) {
|
|
752
1049
|
const arr = value.split(/[\s]+/);
|
|
753
|
-
const radius = cssValueToDeviceIndependentPixels(arr[0], (
|
|
754
|
-
const y = cssValueToDeviceIndependentPixels(arr[2],
|
|
755
|
-
const x = cssValueToDeviceIndependentPixels(arr[3],
|
|
1050
|
+
const radius = cssValueToDeviceIndependentPixels(arr[0], (position.right > position.bottom ? position.bottom : position.right) / 2);
|
|
1051
|
+
const y = cssValueToDeviceIndependentPixels(arr[2], position.bottom);
|
|
1052
|
+
const x = cssValueToDeviceIndependentPixels(arr[3], position.right);
|
|
756
1053
|
return UIBezierPath.bezierPathWithArcCenterRadiusStartAngleEndAngleClockwise(CGPointMake(x, y), radius, 0, 360, true).CGPath;
|
|
757
1054
|
}
|
|
758
|
-
function ellipsePath(value,
|
|
1055
|
+
function ellipsePath(value, position) {
|
|
759
1056
|
const arr = value.split(/[\s]+/);
|
|
760
|
-
const rX = cssValueToDeviceIndependentPixels(arr[0],
|
|
761
|
-
const rY = cssValueToDeviceIndependentPixels(arr[1],
|
|
762
|
-
const cX = cssValueToDeviceIndependentPixels(arr[3],
|
|
763
|
-
const cY = cssValueToDeviceIndependentPixels(arr[4],
|
|
1057
|
+
const rX = cssValueToDeviceIndependentPixels(arr[0], position.right);
|
|
1058
|
+
const rY = cssValueToDeviceIndependentPixels(arr[1], position.bottom);
|
|
1059
|
+
const cX = cssValueToDeviceIndependentPixels(arr[3], position.right);
|
|
1060
|
+
const cY = cssValueToDeviceIndependentPixels(arr[4], position.bottom);
|
|
764
1061
|
const left = cX - rX;
|
|
765
1062
|
const top = cY - rY;
|
|
766
1063
|
const width = rX * 2;
|
|
767
1064
|
const height = rY * 2;
|
|
768
1065
|
return UIBezierPath.bezierPathWithOvalInRect(CGRectMake(left, top, width, height)).CGPath;
|
|
769
1066
|
}
|
|
770
|
-
function polygonPath(value,
|
|
1067
|
+
function polygonPath(value, position) {
|
|
771
1068
|
const path = CGPathCreateMutable();
|
|
772
1069
|
let firstPoint;
|
|
773
1070
|
const arr = value.split(/[,]+/);
|
|
774
1071
|
for (let i = 0; i < arr.length; i++) {
|
|
775
1072
|
const xy = arr[i].trim().split(/[\s]+/);
|
|
776
1073
|
const point = {
|
|
777
|
-
x: cssValueToDeviceIndependentPixels(xy[0],
|
|
778
|
-
y: cssValueToDeviceIndependentPixels(xy[1],
|
|
1074
|
+
x: cssValueToDeviceIndependentPixels(xy[0], position.right),
|
|
1075
|
+
y: cssValueToDeviceIndependentPixels(xy[1], position.bottom),
|
|
779
1076
|
};
|
|
780
1077
|
if (!firstPoint) {
|
|
781
1078
|
firstPoint = point;
|