-
Notifications
You must be signed in to change notification settings - Fork 1
/
root.component.js
68 lines (64 loc) · 1.72 KB
/
root.component.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import "./style.css";
export default function Root(props) {
//return <section>{props.name} is mounted!</section>;
function requestBarcodePermission() {
window.Android.requestBarcodePermission();
}
function requestCameraPermission() {
window.Android.requestCameraPermission();
}
function requestLocationPermission() {
window.Android.requestLocationPermission();
}
return (
<div style={{ textAlign: "center", border: "3px", padding: "20px" }}>
{props.name} is mounted
<div
className="buttonView"
>
<Button onClick={requestBarcodePermission}>Scan BarCode</Button>
<Button onClick={requestLocationPermission}>Get GeoLocation</Button>
<Button onClick={requestCameraPermission}>Open Camera</Button>
</div>
</div>
);
}
// Button.jsx
import React from "react";
// interface ButtonProps {
// children: React.Node;
// onClick: () => void;
// className?: string;
// // Add optional props for customization (e.g., button type, disabled state)
// type?: 'button' | 'submit' | 'reset'; // Common button types
// disabled?: boolean;
// }
const Button = ({
children,
onClick,
className,
type = "button", // Set default type
disabled = false,
...rest
}) => {
const buttonStyles = {
backgroundColor: "blue",
color: "white",
fontWeight: "bold",
padding: "0.5rem 1rem",
borderRadius: "5px",
cursor: disabled ? "not-allowed" : "pointer",
};
return (
<button
type={type}
disabled={disabled}
className={`${className} ${disabled ? "disabled" : ""}`} // Add a class for disabled state (optional)
onClick={onClick}
style={buttonStyles}
{...rest}
>
{children}
</button>
);
};