mirror of
https://github.com/kusti8/proton-native.git
synced 2026-05-15 14:15:50 -06:00
Warn on lack of App/Window and passing children to Button
This commit is contained in:
parent
ec9228c941
commit
3912d25d9c
3 changed files with 21 additions and 8 deletions
|
|
@ -9,7 +9,7 @@ import { getBackend } from "../backends/index";
|
|||
declare global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
BUTTON: React.PropsWithChildren<Props>
|
||||
BUTTON: React.PropsWithChildren<Props>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ export default (p: Props) => {
|
|||
};
|
||||
const defaultProps = {
|
||||
style: {},
|
||||
onPress: () => { },
|
||||
onPress: () => {},
|
||||
title: "Button"
|
||||
};
|
||||
|
||||
|
|
@ -52,6 +52,11 @@ export default (p: Props) => {
|
|||
|
||||
const containerProps = Container(
|
||||
child => {
|
||||
if (child.type === "text")
|
||||
throw new Error(
|
||||
"Button takes no children. If you are trying to set the title, use the title prop."
|
||||
);
|
||||
|
||||
child.element.setParent(element);
|
||||
if (child.node) {
|
||||
yogaProps.node.insertChild(child.node, yogaProps.node.getChildCount());
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ interface ImageStyle extends React.CSSProperties {
|
|||
declare global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
IMAGE: Props
|
||||
IMAGE: Props;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -124,6 +124,8 @@ export default (p: Props) => {
|
|||
style: (style: ImageStyle) => {
|
||||
if (style.resizeMode) {
|
||||
resizeMode.r = style.resizeMode;
|
||||
} else {
|
||||
resizeMode.r = "cover";
|
||||
}
|
||||
element.setStyleSheet(style);
|
||||
yogaProps.applyYogaStyle(style);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import propChecker from "../utils/propChecker";
|
||||
import { disconnectDevtools } from "../devtools";
|
||||
import { Container } from "./Container";
|
||||
import { getBackend } from '../backends/index'
|
||||
import { getBackend } from "../backends/index";
|
||||
import { Component } from "./Base";
|
||||
|
||||
export interface Root {
|
||||
|
|
@ -13,14 +13,14 @@ export default (props: {}) => {
|
|||
const propTypes = {};
|
||||
const defaultProps = {};
|
||||
|
||||
const AppElement = getBackend()["AppElement"]
|
||||
const AppElement = getBackend()["AppElement"];
|
||||
const element = new AppElement();
|
||||
|
||||
props = propChecker(props, propTypes, defaultProps, "Root");
|
||||
|
||||
const containerProps = Container(
|
||||
() => { },
|
||||
() => { }
|
||||
() => {},
|
||||
() => {}
|
||||
);
|
||||
|
||||
const quit = () => {
|
||||
|
|
@ -35,7 +35,13 @@ export default (props: {}) => {
|
|||
const interval = setInterval(() => {
|
||||
if (containerProps.children && containerProps.children.length) {
|
||||
for (let i = 0; i < containerProps.children[0].children.length; i++) {
|
||||
const closed = containerProps.children[0].children[i].element.getClosed();
|
||||
if (!containerProps.children[0].children[i].element.getClosed)
|
||||
throw new Error(
|
||||
"Could not find Window or App. Did you forget to define one?"
|
||||
);
|
||||
const closed = containerProps.children[0].children[
|
||||
i
|
||||
].element.getClosed();
|
||||
if (!closed) {
|
||||
element.runLoop();
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue