Skip to content

Commit

Permalink
chore: try implement switching between dark and light themes, dependi…
Browse files Browse the repository at this point in the history
…ng on the Telegram theme
  • Loading branch information
cronnoss committed Aug 25, 2024
1 parent 77e7f14 commit 46a5371
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function App() {
const [connected, setConnected] = useState<boolean>(false);
const [platform, setPlatform] = useState<string | null>(null);
const [code, setCode] = useState<string | null>(null);
const [color, setColor] = useState<string | null>(null);

const userPlatform = useCallback(() => {
setPlatform(WebApp.platform === "unknown" ? null : WebApp.platform);
Expand All @@ -49,9 +50,20 @@ function App() {
});
}, []);

const userColor = useCallback(() => {
setColor(WebApp.colorScheme);
}, []);

const showColorAlert = useCallback(() => {
if (color) {
WebApp.showAlert(color);
}
}, [color]);

useEffect(() => {
WebApp.expand();
userPlatform();
userColor();
setConnected(tonConnectUI.connected);

tonConnectUI.onStatusChange((status) => {
Expand Down Expand Up @@ -105,6 +117,15 @@ function App() {
<hr/>
</>
)}
{color && (
<>
<div className="button-container">
<b>Show color</b>
<button onClick={showColorAlert}>Show</button>
</div>
<hr/>
</>
)}
<div className="button-container">
<b>Show scanner</b>
<button onClick={openScan}>Start</button>
Expand Down

0 comments on commit 46a5371

Please sign in to comment.