Skip to content

Commit

Permalink
chore: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Apr 29, 2024
1 parent 2e00617 commit 89daed2
Show file tree
Hide file tree
Showing 87 changed files with 30,815 additions and 2,084 deletions.
2 changes: 1 addition & 1 deletion apps/demo/src/plugin-demos/canvas-pixi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</ActionBar>
</Page.actionBar>
<GridLayout width="100%" height="100%">
<canvas:Canvas width="100%" height="100%" id="canvas" layoutChanged="{{canvasLoaded}}" loaded="{{loaded}}"
<canvas:Canvas id="canvas" ready="{{canvasLoaded}}" loaded="{{loaded}}"
unloaded="{{unloaded}}"/>
</GridLayout>
</Page>
3 changes: 1 addition & 2 deletions apps/demo/src/plugin-demos/canvas.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ loaded="{{ rectLoaded }}"


<!-- <WebView rowSpan="2" colSpan="2" height="100%" width="100%" loaded="loaded"/> -->
<canvas:Canvas rowSpan="2" colSpan="2" ready="{{ canvasLoaded }}"
layoutChanged="{{ onLayout }}"/>
<canvas:Canvas rowSpan="2" colSpan="2" ready="{{ canvasLoaded }}" />
<!-- <Button height="40" text="Draw" tap="{{ draw }}"/> -->

<!-- <ScrollView rowSpan="4" visibility="{{ show ? 'visible': 'collapse' }}" orientation="vertical">
Expand Down
10 changes: 4 additions & 6 deletions packages/canvas-pixi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ class NSCPIXIApplication extends Pixii.Application {
view = document.createElement('canvas');
view.nativeElement = context.canvas;
}
const width = props.width || clientWidth //* Screen.mainScreen.scale;
const height = props.height || clientHeight //* Screen.mainScreen.scale;
const width = props.width || clientWidth * Screen.mainScreen.scale;
const height = props.height || clientHeight * Screen.mainScreen.scale;

PIXI.settings.RESOLUTION = 1;
// PIXI.settings.RESOLUTION = 1;


console.log(width, height, Screen.mainScreen.widthDIPs, Screen.mainScreen.heightDIPs, Screen.mainScreen.widthPixels, Screen.mainScreen.heightPixels,)
super({
...props,
resolution: 1,
resolution: Screen.mainScreen.scale,
view,
width,
height,
Expand Down
33 changes: 23 additions & 10 deletions packages/canvas/Canvas/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DOMMatrix } from '../Canvas2D';
import { CanvasRenderingContext2D } from '../Canvas2D/CanvasRenderingContext2D';
import { WebGLRenderingContext } from '../WebGL/WebGLRenderingContext';
import { WebGL2RenderingContext } from '../WebGL2/WebGL2RenderingContext';
import { ImageSource, Utils, profile, Screen } from '@nativescript/core';
import { ImageSource, Utils, profile, Screen, PercentLength } from '@nativescript/core';
declare var NSCCanvas, NSCCanvasListener;

export * from './common';
Expand Down Expand Up @@ -95,6 +95,7 @@ export class Canvas extends CanvasBase {
this._handleEvents(event);
};
}
this._canvas.autoScale = false;
}

[ignoreTouchEventsProperty.setNative](value: boolean) {
Expand All @@ -120,9 +121,11 @@ export class Canvas extends CanvasBase {
}

set width(value) {
this.style.width = value ?? 0;
this._didLayout = false;
this._layoutNative(true);
if (value !== null || value !== undefined) {
this.style.width = value;
this._didLayout = false;
this._layoutNative(true);
}
}

//@ts-ignore
Expand All @@ -131,9 +134,11 @@ export class Canvas extends CanvasBase {
}

set height(value) {
this.style.height = value ?? 0;
this._didLayout = false;
this._layoutNative(true);
if (value !== null || value !== undefined) {
this.style.height = value;
this._didLayout = false;
this._layoutNative(true);
}
}

private _iosOverflowSafeArea = false;
Expand Down Expand Up @@ -227,7 +232,7 @@ export class Canvas extends CanvasBase {
}

public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number) {
const nativeView = this.nativeView;
const nativeView = this._canvas;
if (nativeView) {
const width = Utils.layout.getMeasureSpecSize(widthMeasureSpec);
const height = Utils.layout.getMeasureSpecSize(heightMeasureSpec);
Expand Down Expand Up @@ -270,7 +275,7 @@ export class Canvas extends CanvasBase {

const size = this._logicalSize;

// this._canvas.forceLayout(size.width, size.height);
this._canvas.forceLayout(size.width, size.height);

if (this._is2D) {
this._2dContext?.native?.__resize?.(size.width, size.height);
Expand All @@ -280,6 +285,13 @@ export class Canvas extends CanvasBase {
}
}


_setNativeViewFrame(nativeView: any, frame: any): void {
nativeView.frame = frame;
this._canvas.forceLayout(frame.size.width, frame.size.height);
}


getContext(type: string, options?: any): CanvasRenderingContext2D | WebGLRenderingContext | WebGL2RenderingContext | null {
if (!this._canvas) {
return null;
Expand All @@ -291,7 +303,8 @@ export class Canvas extends CanvasBase {
}

if (!this._2dContext) {
this._layoutNative(true);
//this._layoutNative(true);
console.log(this.width, this.height, this._canvas.frame.size.width, this._canvas.frame.size.height, this._canvas.subviews[0].frame.size.width, this._canvas.subviews[0].frame.size.height);

const opts = { ...defaultOpts, ...this._handleContextOptions(type, options), fontColor: this.parent?.style?.color?.android || -16777216 };

Expand Down
48 changes: 48 additions & 0 deletions packages/canvas/platforms/ios/CanvasNative.xcframework/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>CanvasNative.framework/CanvasNative</string>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>CanvasNative.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>CanvasNative.framework/CanvasNative</string>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>CanvasNative.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
Binary file not shown.
Loading

0 comments on commit 89daed2

Please sign in to comment.