implement the install external apk api

This commit is contained in:
Aria Moradi
2021-09-09 05:14:17 +04:30
parent 7710c287c5
commit 09f92c853d
2 changed files with 63 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ import React from 'react';
import Slide, { SlideProps } from '@material-ui/core/Slide';
import Snackbar from '@material-ui/core/Snackbar';
import MuiAlert, { Color as Severity } from '@material-ui/lab/Alert';
import cloneObject from 'util/cloneObject';
function removeToast(id: string) {
const container = document.querySelector(`#${id}`)!!;
@@ -27,7 +28,7 @@ interface IToastProps{
severity: Severity
}
function Toast(props: IToastProps) {
export function Toast(props: IToastProps) {
const { message, severity } = props;
const [open, setOpen] = React.useState(true);
@@ -61,3 +62,20 @@ export default function makeToast(message: string, severity: Severity) {
setTimeout(() => removeToast(container.id), 3500);
}
export function makeToaster(
[toasts, setToasts] : [React.ReactElement[],
(arg0: React.ReactElement[]) => void],
): [React.ReactElement[], ((message: string, severity: Severity) => void)] {
return [toasts, (message: string, severity: Severity) => {
const curToasts = cloneObject(toasts);
curToasts.push(
<Toast
key={Math.floor(Math.random() * 1000) + 1}
message={message}
severity={severity}
/>,
);
setToasts(curToasts);
}];
}