mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
feat: Add 3D rotation to view - takeover of PR# 5950 (#8136)
* feat: add 3d rotation * chore: fix build errors * chore: fix tslint errors * chore: add @types/chai dev dep * chore: unused import cleanup * chore: update tests for x,y rotation * chore: rebase upstream/master * fix: iOS Affine Transform test verification * feat(css): Added optional css-tree parser (#8076) * feat(css): Added optional css-tree parser * test: css-tree parser compat tests * test: more css-tree compat tests * feat(dialogs): Setting the size of popup dialog thru dialog options (#8041) * Added iOS specific height and width attributes to ShowModalOptions * Set the height and width of the popup dialog to the presenting controller * dialog options ios attributes presentationStyle, height & width are made optional * Updated NativeScript.api.md for public API changes * Update with git properties * Public API * CLA update * fix: use iOS native-helper for 3d-rotate * test: Fix tests using _getTransformMismatchError * fix: view.__hasTransfrom not set updating properly * test: fix css-animations test page Co-authored-by: Alexander Vakrilov <alexander.vakrilov@gmail.com> Co-authored-by: Darin Dimitrov <darin.dimitrov@gmail.com> Co-authored-by: Shailesh Lolam <slolam@live.com> Co-authored-by: Dimitar Topuzov <dtopuzov@gmail.com>
This commit is contained in:

committed by
Alexander Vakrilov

parent
8550c3293d
commit
e8f5ac8522
11
nativescript-core/utils/native-helper.d.ts
vendored
11
nativescript-core/utils/native-helper.d.ts
vendored
@ -155,5 +155,14 @@ export module ios {
|
||||
*/
|
||||
export function getVisibleViewController(rootViewController: any/* UIViewController*/): any/* UIViewController*/;
|
||||
|
||||
export class UIDocumentInteractionControllerDelegateImpl {}
|
||||
/**
|
||||
*
|
||||
* @param transform Applies a rotation transform over X,Y and Z axis
|
||||
* @param x Rotation over X axis in degrees
|
||||
* @param y Rotation over Y axis in degrees
|
||||
* @param z Rotation over Z axis in degrees
|
||||
*/
|
||||
export function applyRotateTransform(transform: any /* CATransform3D*/, x: number, y: number, z: number): any /* CATransform3D*/;
|
||||
|
||||
export class UIDocumentInteractionControllerDelegateImpl { }
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import {
|
||||
write as traceWrite
|
||||
} from "../trace";
|
||||
|
||||
const radToDeg = Math.PI / 180;
|
||||
|
||||
function isOrientationLandscape(orientation: number) {
|
||||
return orientation === UIDeviceOrientation.LandscapeLeft /* 3 */ ||
|
||||
orientation === UIDeviceOrientation.LandscapeRight /* 4 */;
|
||||
@ -114,23 +116,39 @@ export module ios {
|
||||
|
||||
}
|
||||
|
||||
export function applyRotateTransform(transform: CATransform3D, x: number, y: number, z: number): CATransform3D {
|
||||
if (x) {
|
||||
transform = CATransform3DRotate(transform, x * radToDeg, 1, 0, 0);
|
||||
}
|
||||
|
||||
if (y) {
|
||||
transform = CATransform3DRotate(transform, y * radToDeg, 0, 1, 0);
|
||||
}
|
||||
|
||||
if (z) {
|
||||
transform = CATransform3DRotate(transform, z * radToDeg, 0, 0, 1);
|
||||
}
|
||||
|
||||
return transform;
|
||||
}
|
||||
|
||||
export class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UIDocumentInteractionControllerDelegate {
|
||||
public static ObjCProtocols = [UIDocumentInteractionControllerDelegate];
|
||||
|
||||
|
||||
public getViewController(): UIViewController {
|
||||
const app = UIApplication.sharedApplication;
|
||||
|
||||
|
||||
return app.keyWindow.rootViewController;
|
||||
}
|
||||
|
||||
|
||||
public documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) {
|
||||
return this.getViewController();
|
||||
}
|
||||
|
||||
|
||||
public documentInteractionControllerViewForPreview(controller: UIDocumentInteractionController) {
|
||||
return this.getViewController().view;
|
||||
}
|
||||
|
||||
|
||||
public documentInteractionControllerRectForPreview(controller: UIDocumentInteractionController): CGRect {
|
||||
return this.getViewController().view.frame;
|
||||
}
|
||||
|
1
nativescript-core/utils/utils.d.ts
vendored
1
nativescript-core/utils/utils.d.ts
vendored
@ -251,6 +251,7 @@ export module ios {
|
||||
* Returns the visible UIViewController.
|
||||
*/
|
||||
export function getVisibleViewController(rootViewController: any/* UIViewController*/): any/* UIViewController*/;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ export function openFile(filePath: string): boolean {
|
||||
const path = filePath.replace("~", appPath);
|
||||
|
||||
const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path));
|
||||
controller.delegate = <UIDocumentInteractionControllerDelegate> new ios.UIDocumentInteractionControllerDelegateImpl();
|
||||
controller.delegate = <UIDocumentInteractionControllerDelegate>new ios.UIDocumentInteractionControllerDelegateImpl();
|
||||
|
||||
return controller.presentPreviewAnimated(true);
|
||||
}
|
||||
@ -48,4 +48,4 @@ export function openUrl(location: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
mainScreenScale = UIScreen.mainScreen.scale;
|
||||
mainScreenScale = UIScreen.mainScreen.scale;
|
Reference in New Issue
Block a user