Skip to content

Commit

Permalink
^.
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Aug 28, 2023
1 parent fd18af3 commit c934f79
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 33 deletions.
86 changes: 63 additions & 23 deletions Website/src/activitys/ModuleViewActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Toolbar } from "@Components/onsenui/Toolbar";
import { useStrings } from "@Hooks/useStrings";
import { Disappear } from "react-disappear";
import VerifiedIcon from "@mui/icons-material/Verified";
import { DeleteRounded, RefreshRounded } from "@mui/icons-material";
import LaunchIcon from "@mui/icons-material/Launch";
import Box from "@mui/material/Box";
import React from "react";
Expand Down Expand Up @@ -58,6 +59,8 @@ import Paper from "@mui/material/Paper";
import { BottomToolbar } from "@Components/onsenui/BottomToolbar";
import useMediaQuery from "@mui/material/useMediaQuery";
import { useBaseDialog } from "@Hooks/useBaseDialog";
import { useLog } from "@Hooks/native/useLog";
import { SuFile } from "@Native/SuFile";

type Extra = {
module: ModuleProps;
Expand All @@ -81,6 +84,8 @@ const ModuleViewActivity = () => {
const [open, setOpen] = useStateCallback(false);
const [scroll, setScroll] = React.useState<DialogProps["scroll"]>("paper");

const log = useLog("ModuleViewActivity");

const fullScreen = useMediaQuery(theme.breakpoints.down("md"));

const { modules } = useRepos();
Expand All @@ -89,6 +94,7 @@ const ModuleViewActivity = () => {

const { notes_url, zip_url, authorData, last_update } = extra;
const {
id,
name,
author,
mmrlAuthor,
Expand All @@ -107,6 +113,11 @@ const ModuleViewActivity = () => {
changeBoot,
} = extra.module;

const remove = new SuFile(`/data/adb/modules/${id}/remove`);
const moduleInstalled = new SuFile(`/data/adb/modules/${id}/module.prop`);

const [moduleRemoved, setModuleRemoved] = React.useState(remove.exist());

const categories = useFilterCategory(mmrlCategory);
const { data } = useFetch<string>(notes_url);
const formatLastUpdate = useFormatDate(last_update);
Expand Down Expand Up @@ -285,30 +296,59 @@ const ModuleViewActivity = () => {
</Button>
)}

<Button
disabled={!zip_url}
onClick={() => {
os.open(zip_url, {
target: "_blank",
features: {
color: theme.palette.primary.main,
<Stack direction="row" justifyContent="center" alignItems="center" spacing={1}>
{/* {os.isAndroid && moduleInstalled.exist() && (
<Button
sx={{
color: scheme[100],
border: `1px solid ${scheme[100]}80`,
minWidth: 160,
width: { sm: "unset", xs: "100%" },
alignSelf: "flex-end",
":hover": {
color: scheme[200],
border: `1px solid ${scheme[200]}80`,
},
}}
variant="outlined"
startIcon={moduleRemoved ? <RefreshRounded /> : <DeleteRounded />}
onClick={() => {
if (remove.exist()) {
setModuleRemoved(remove.delete());
} else {
setModuleRemoved(!remove.create());
}
}}
>
{moduleRemoved ? "Restore" : "Remove"}
</Button>
)} */}

<Button
disabled={!zip_url}
onClick={() => {
os.open(zip_url, {
target: "_blank",
features: {
color: theme.palette.primary.main,
},
});
}}
sx={(theme) => ({
bgcolor: scheme[100],
":hover": {
bgcolor: scheme[200],
},
});
}}
sx={(theme) => ({
bgcolor: scheme[100],
":hover": {
bgcolor: scheme[200],
},
minWidth: 160,
width: { sm: "unset", xs: "100%" },
alignSelf: "flex-end",
})}
variant="contained"
disableElevation
>
Download
</Button>
minWidth: 160,
width: { sm: "unset", xs: "100%" },
alignSelf: "flex-end",
})}
variant="contained"
disableElevation
>
Download
</Button>
</Stack>
</Stack>
</Stack>
</Box>
Expand Down
8 changes: 5 additions & 3 deletions Website/src/activitys/fragments/ExploreModuleFragment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ const ExploreModuleFragment = (props: ExploreModuleProps) => {
<Page.RelativeContent>
<Searchbar placeholder={strings.search_modules} onChange={(e) => setSearch(e.target.value)} />

{_DATA.currentData().map((module, index) => (
<ExploreModule index={index} key={module.id + index} moduleProps={module} />
))}
<Stack sx={{ mt: 1 }} direction="column" justifyContent="flex-start" alignItems="center" spacing={1}>
{_DATA.currentData().map((module, index) => (
<ExploreModule index={index} key={module.id + index} moduleProps={module} />
))}
</Stack>
</Page.RelativeContent>
</Page>
);
Expand Down
2 changes: 1 addition & 1 deletion Website/src/components/ExploreModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const ExploreModule = (props: Props) => {
cursor: "pointer",
bgcolor: shade(theme.palette.secondary.dark, -42),
},
mt: 1,
width: "100%",
boxShadow: "none",
}}
>
Expand Down
34 changes: 28 additions & 6 deletions Website/src/native/SuFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ class SuFile extends Native<NativeSuFile> {
}

public read(): string {
return this.getInterface.readFile(this.path);
if (this.isAndroid) {
return this.getInterface.readFile(this.path);
} else {
return "";
}
}

/**
Expand All @@ -34,23 +38,41 @@ class SuFile extends Native<NativeSuFile> {
*/
public list(): string;
public list(join?: string): string {
return this.getInterface.listFiles(this.path);
if (this.isAndroid) {
return this.getInterface.listFiles(this.path);
} else {
return "";
}
}

public exist(): boolean {
return this.getInterface.existFile(this.path);
if (this.isAndroid) {
return this.getInterface.existFile(this.path);
} else {
return false;
}
}

public delete(): boolean {
return this.getInterface.deleteFile(this.path);
if (this.isAndroid) {
return this.getInterface.deleteFile(this.path);
} else {
return false;
}
}

public deleteRecursive(): void {
this.getInterface.deleteRecursive(this.path);
if (this.isAndroid) {
this.getInterface.deleteRecursive(this.path);
}
}

public create(): boolean {
return this.getInterface.createFile(this.path);
if (this.isAndroid) {
return this.getInterface.createFile(this.path);
} else {
return false;
}
}

public static read(path: string): string {
Expand Down

0 comments on commit c934f79

Please sign in to comment.