Skip to content

Commit

Permalink
feat: update render/react for use with txiki.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jspngh committed Jun 14, 2024
1 parent 94385e9 commit 42bdea3
Show file tree
Hide file tree
Showing 28 changed files with 30 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/render/react/components/Arc/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeArc = bridge.NativeRender.NativeComponents.Arc;

const modes = {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Button/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeButton = bridge.NativeRender.NativeComponents.Button;

function setButtonProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Calendar/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeCalendar = bridge.NativeRender.NativeComponents.Calendar;

function setCalendarProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Canvas/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeButton = bridge.NativeRender.NativeComponents.Button;

function setCanvasProps(comp, newProps, oldProps) {
Expand Down
5 changes: 3 additions & 2 deletions src/render/react/components/Chart/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeChart = bridge.NativeRender.NativeComponents.Chart;

const chartType = {
Expand Down Expand Up @@ -243,7 +243,8 @@ function setChartProps(comp, newProps, oldProps) {
comp.dataset[prop.substring(5)] = newProps[prop];
}
});
comp.refresh();
// This gives issues: invalid call to setPointNum?
// comp.refresh();
}

export class ChartComp extends NativeChart {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Checkbox/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeView = bridge.NativeRender.NativeComponents.Checkbox;

function setCheckboxProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Dropdownlist/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeDropdownlist = bridge.NativeRender.NativeComponents.Dropdownlist;

function setListProps(comp, newProps, oldProps) {
Expand Down
5 changes: 1 addition & 4 deletions src/render/react/components/GIF/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import {
styleGetterProp,
} from "../config";

const fs = require("fs");
const path = require("path");

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeGIF = bridge.NativeRender.NativeComponents.GIF;

async function getGIFBinary(url) {
Expand Down
10 changes: 4 additions & 6 deletions src/render/react/components/Image/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import {
styleGetterProp,
} from "../config";

const fs = require("fs");
const path = require("path");

const bridge = globalThis.SJSJSBridge;
const path = globalThis[Symbol.for('tjs.internal.modules.path')];
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeImage = bridge.NativeRender.NativeComponents.Image;

async function getImageBinary(url) {
Expand All @@ -38,9 +36,9 @@ function setImageProps(comp, newProps, oldProps) {
}
if (!isValidUrl(url)) {
if (!path.isAbsolute(url)) {
url = path.resolve(__dirname, url);
url = path.resolve(url);
}
fs.readFile(url, { encoding: "binary" })
tjs.readFile(url, { encoding: "binary" })
.then((data) => {
comp.setImageBinary(data.buffer);
})
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Input/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeView = bridge.NativeRender.NativeComponents.Textarea;

function setInputProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Keyboard/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeView = bridge.NativeRender.NativeComponents.Keyboard;

const modes = {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Line/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeLine = bridge.NativeRender.NativeComponents.Line;

function setLineProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Mask/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeMask = bridge.NativeRender.NativeComponents.Mask;

function setMaskProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/ProgressBar/comp.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CommonComponentApi } from "../common/index";
import { STYLE_TYPE, handleEvent, setStyle, styleGetterProp } from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeProgressBar = bridge.NativeRender.NativeComponents.ProgressBar;

function setProgressBarProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Roller/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeRoller = bridge.NativeRender.NativeComponents.Roller;

function setRollerProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Slider/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeSlider = bridge.NativeRender.NativeComponents.Slider;

function setSliderProps(comp, newProps, oldProps) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeComp = bridge.NativeRender.NativeComponents.Switch;

function setSwitchProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Tabs/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeTabs = bridge.NativeRender.NativeComponents.TabView;

function setTabsProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Text/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeText = bridge.NativeRender.NativeComponents.Text;

function setTextProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Textarea/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeView = bridge.NativeRender.NativeComponents.Textarea;

function setTextareaProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/View/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeView = bridge.NativeRender.NativeComponents.View;

function setViewProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/components/Window/comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
styleGetterProp,
} from "../config";

const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeComp = bridge.NativeRender.NativeComponents.Window;

function setWindowProps(comp, newProps, oldProps) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/core/animate/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const NativeAnimate = bridge.NativeRender.Animate;

export const EAnimateEasingFunc = {
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/core/dimensions/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const dimensions = bridge.NativeRender.dimensions;

export const Dimensions = dimensions;
2 changes: 0 additions & 2 deletions src/render/react/core/renderer/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import reconciler from "../reconciler";

const bridge = globalThis.SJSJSBridge;

const containerInfo = new Set();

export class Renderer {
Expand Down
3 changes: 0 additions & 3 deletions src/render/react/core/style/post.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { isValidUrl } from "../../utils/helpers";
import { BUILT_IN_SYMBOL } from "../style/symbol";

const path = require("path");
const fs = require("fs");

async function getImageBinary(url) {
const resp = await fetch(url, {});
const imageBuffer = await resp.arrayBuffer();
Expand Down
2 changes: 1 addition & 1 deletion src/render/react/core/theme/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const bridge = globalThis.SJSJSBridge;
const bridge = globalThis[Symbol.for('lvgljs')];
const nativeTheme = bridge.NativeRender.theme;

export const Theme = {
Expand Down

0 comments on commit 42bdea3

Please sign in to comment.