|
|
@ -2,31 +2,22 @@ import { |
|
|
|
Renderer, |
|
|
|
Renderer, |
|
|
|
View, |
|
|
|
View, |
|
|
|
Text, |
|
|
|
Text, |
|
|
|
Button, |
|
|
|
|
|
|
|
Window, |
|
|
|
Window, |
|
|
|
Image, |
|
|
|
Image, |
|
|
|
useEventHandler |
|
|
|
|
|
|
|
} from "@nodegui/react-nodegui"; |
|
|
|
} from "@nodegui/react-nodegui"; |
|
|
|
import path from "path"; |
|
|
|
import path from "path"; |
|
|
|
import React, { useState } from "react"; |
|
|
|
import React from "react"; |
|
|
|
import { AspectRatioMode, QPushButtonEvents } from "@nodegui/nodegui"; |
|
|
|
import { AspectRatioMode } from "@nodegui/nodegui"; |
|
|
|
|
|
|
|
|
|
|
|
import imageUrl from "../assets/sample.jpg"; |
|
|
|
import imageUrl from "../assets/nodegui.jpg"; |
|
|
|
const distImgUrl = path.resolve(__dirname, imageUrl); |
|
|
|
const distImgUrl = path.resolve(__dirname, imageUrl); |
|
|
|
|
|
|
|
const minSize = {width: 500, height: 400}; |
|
|
|
|
|
|
|
|
|
|
|
const fixedSize = { width: 500, height: 500 }; |
|
|
|
|
|
|
|
const App = () => { |
|
|
|
const App = () => { |
|
|
|
const [time, setTime] = useState(new Date()); |
|
|
|
|
|
|
|
const btnHandler = useEventHandler( |
|
|
|
|
|
|
|
{ [QPushButtonEvents.clicked]: () => setTime(new Date()) }, |
|
|
|
|
|
|
|
[] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Window minSize={fixedSize} maxSize={fixedSize} styleSheet={styleSheet}> |
|
|
|
<Window minSize={minSize} styleSheet={styleSheet}> |
|
|
|
<View id="container"> |
|
|
|
<View id="container"> |
|
|
|
<Button text="Update Time" on={btnHandler} /> |
|
|
|
<Text style="font-size: 15px; font-weight: bold; margin-bottom: 20px;">Hello World</Text> |
|
|
|
<Text id="result">{`${time}`}</Text> |
|
|
|
|
|
|
|
<Text id="result">{`Time in epoc: ${time.getTime()}`}</Text> |
|
|
|
|
|
|
|
<Image |
|
|
|
<Image |
|
|
|
style={imageStyle} |
|
|
|
style={imageStyle} |
|
|
|
src={distImgUrl} |
|
|
|
src={distImgUrl} |
|
|
@ -38,7 +29,9 @@ const App = () => { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const imageStyle = ` |
|
|
|
const imageStyle = ` |
|
|
|
height: "70%"; |
|
|
|
height: "100px"; |
|
|
|
|
|
|
|
width: "100px"; |
|
|
|
|
|
|
|
qproperty-alignment: 'AlignHCenter'; |
|
|
|
`;
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
const styleSheet = ` |
|
|
|
const styleSheet = ` |
|
|
@ -48,15 +41,6 @@ const styleSheet = ` |
|
|
|
min-height: '100%'; |
|
|
|
min-height: '100%'; |
|
|
|
align-items: 'center'; |
|
|
|
align-items: 'center'; |
|
|
|
justify-content: 'center'; |
|
|
|
justify-content: 'center'; |
|
|
|
background-color: black; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#opBtn { |
|
|
|
|
|
|
|
font-size: 20px; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#result { |
|
|
|
|
|
|
|
font-size: 12px; |
|
|
|
|
|
|
|
flex: 1; |
|
|
|
|
|
|
|
color: cyan; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
`;
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|