Skip to content

Commit 479cc9a

Browse files
authored
Merge pull request #31 from DerGoogler/1.6.4
1.6.4
2 parents 580cbe0 + bff5707 commit 479cc9a

File tree

6 files changed

+113
-42
lines changed

6 files changed

+113
-42
lines changed

Android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ android {
1414
applicationId 'com.dergoogler.mmrl'
1515
minSdk 26
1616
targetSdk 33
17-
versionName '1.6.3'
18-
versionCode 163
17+
versionName '1.6.4'
18+
versionCode 164
1919
externalNativeBuild {
2020
cmake {
2121
cppFlags "-llog"

Website/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"description": "",
44
"config": {
55
"application_id": "com.dergoogler.mmrl",
6-
"version_name": "1.6.3",
7-
"version_code": 163
6+
"version_name": "1.6.4",
7+
"version_code": 164
88
},
99
"main": "index.tsx",
1010
"keywords": [],

Website/src/activitys/DAPITestActivity.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import { Page } from "@Components/onsenui/Page";
2727
import { os } from "@Native/Os";
2828
import { useActivity } from "@Hooks/useActivity";
2929
import { useStrings } from "@Hooks/useStrings";
30-
import DescriptonActivity from "./DescriptonActivity";
3130
import { Markup } from "@Components/Markdown";
31+
import FetchTextActivity from "./FetchTextActivity";
3232

3333
interface CustomCommand extends Command {
3434
icon: React.ElementType;
@@ -140,11 +140,11 @@ const DAPITestActivity = () => {
140140

141141
const handlePreview = () => {
142142
context.pushPage({
143-
component: DescriptonActivity,
143+
component: FetchTextActivity,
144144
key: "dapi-preview",
145145
extra: {
146146
title: "Preview",
147-
desc: description,
147+
data: description,
148148
},
149149
});
150150
};

Website/src/activitys/FetchTextActivity.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { MissingInternet } from "@Components/MissingInternet";
1212

1313
type FetchTextActivityExtra = {
1414
title: string;
15+
data: string;
1516
url: string;
1617
};
1718

@@ -30,7 +31,7 @@ function FetchTextActivity() {
3031

3132
const initialState: State<string> = {
3233
error: undefined,
33-
data: undefined,
34+
data: extra.data || undefined,
3435
};
3536

3637
// Keep state logic separated

Website/src/activitys/fragments/ExploreModuleFragment.tsx

Lines changed: 99 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@ import { Searchbar } from "@Components/Searchbar";
33
import React from "react";
44
import { useActivity } from "@Hooks/useActivity";
55
import { useRepos } from "@Hooks/useRepos";
6-
import { Box, Pagination, Stack, Typography } from "@mui/material";
6+
import Stack from "@mui/material/Stack";
7+
import Pagination from "@mui/material/Pagination";
8+
import Box from "@mui/material/Box";
9+
import Button from "@mui/material/Button";
10+
import Dialog from "@mui/material/Dialog";
11+
import DialogActions from "@mui/material/DialogActions";
12+
import DialogContent from "@mui/material/DialogContent";
13+
import DialogTitle from "@mui/material/DialogTitle";
14+
import InputLabel from "@mui/material/InputLabel";
15+
import OutlinedInput from "@mui/material/OutlinedInput";
16+
import MenuItem from "@mui/material/MenuItem";
17+
import FormControl from "@mui/material/FormControl";
18+
import Select, { SelectChangeEvent } from "@mui/material/Select";
719
import { useStrings } from "@Hooks/useStrings";
820
import { usePagination } from "@Hooks/usePagination";
921
import RepoActivity from "@Activitys/RepoActivity";
@@ -30,13 +42,39 @@ const ExploreModuleFragment = (props: ExploreModuleProps) => {
3042
const { isNetworkAvailable } = useNetwork();
3143
const [search, setSearch] = React.useState("");
3244

33-
const applyFilter = props.applyFilter(modules, search);
45+
const [open, setOpen] = React.useState(false);
46+
const [exploreFilter, setExploreFilter] = React.useState<number | string>("none");
47+
48+
const filterSystem = () => {
49+
const applyFilter = props.applyFilter(modules, search);
50+
51+
switch (exploreFilter) {
52+
case "none":
53+
return applyFilter;
54+
case "date_oldest":
55+
return applyFilter.sort(function (a, b) {
56+
var da = new Date(a.last_update).getTime();
57+
var db = new Date(b.last_update).getTime();
58+
59+
return da - db;
60+
});
61+
case "date_newest":
62+
return applyFilter.sort(function (a, b) {
63+
var da = new Date(a.last_update).getTime();
64+
var db = new Date(b.last_update).getTime();
65+
66+
return db - da;
67+
});
68+
default:
69+
return applyFilter;
70+
}
71+
};
3472

3573
const [page, setPage] = React.useState(1);
3674

3775
const PER_PAGE = 20;
38-
const count = Math.ceil(applyFilter.length / PER_PAGE);
39-
const _DATA = usePagination(applyFilter, PER_PAGE);
76+
const count = Math.ceil(filterSystem().length / PER_PAGE);
77+
const _DATA = usePagination(filterSystem(), PER_PAGE);
4078

4179
if (!isNetworkAvailable) {
4280
return (
@@ -95,20 +133,20 @@ const ExploreModuleFragment = (props: ExploreModuleProps) => {
95133
);
96134
}
97135

98-
// if (modulesLoading) {
99-
// return (
100-
// <ProgressCircular
101-
// indeterminate
102-
// style={{
103-
// position: "absolute",
104-
// left: "50%",
105-
// top: "50%",
106-
// WebkitTransform: "translate(-50%, -50%)",
107-
// transform: "translate(-50%, -50%)",
108-
// }}
109-
// />
110-
// );
111-
// } else {
136+
const handleChange = (event: SelectChangeEvent<typeof exploreFilter>) => {
137+
setExploreFilter(event.target.value);
138+
};
139+
140+
const handleClickOpen = () => {
141+
setOpen(true);
142+
};
143+
144+
const handleClose = (event: React.SyntheticEvent<unknown>, reason?: string) => {
145+
if (reason !== "backdropClick") {
146+
setOpen(false);
147+
}
148+
};
149+
112150
return (
113151
<Page
114152
renderToolbar={props.renderToolbar}
@@ -133,17 +171,58 @@ const ExploreModuleFragment = (props: ExploreModuleProps) => {
133171
}}
134172
>
135173
<Page.RelativeContent>
136-
<Searchbar placeholder={strings.search_modules} onChange={(e) => setSearch(e.target.value)} />
174+
<Searchbar onFilterClick={handleClickOpen} placeholder={strings.search_modules} onChange={(e) => setSearch(e.target.value)} />
137175

138176
<Stack sx={{ mt: 1 }} direction="column" justifyContent="flex-start" alignItems="center" spacing={1}>
139177
{_DATA.currentData().map((module, index) => (
140178
<ExploreModule index={index} key={module.id + index} moduleProps={module} />
141179
))}
142180
</Stack>
143181
</Page.RelativeContent>
182+
183+
<Dialog disableEscapeKeyDown open={open} onClose={handleClose}>
184+
<DialogTitle>Apply a filter</DialogTitle>
185+
<DialogContent>
186+
<Box component="form" sx={{ display: "flex", flexWrap: "wrap" }}>
187+
<FormControl sx={{ m: 1, minWidth: 120 }}>
188+
<InputLabel id="demo-dialog-select-label">Filter</InputLabel>
189+
<Select
190+
labelId="demo-dialog-select-label"
191+
id="demo-dialog-select"
192+
value={exploreFilter}
193+
onChange={handleChange}
194+
input={<OutlinedInput label="Filter" />}
195+
>
196+
<MenuItem value="none">
197+
<em>No filter</em>
198+
</MenuItem>
199+
<MenuItem value="date_oldest">By date (oldest)</MenuItem>
200+
<MenuItem value="date_newest">By date (newest)</MenuItem>
201+
</Select>
202+
</FormControl>
203+
</Box>
204+
</DialogContent>
205+
<DialogActions>
206+
<Button
207+
sx={{
208+
color: scheme[500],
209+
}}
210+
onClick={handleClose}
211+
>
212+
Cancel
213+
</Button>
214+
<Button
215+
sx={{
216+
color: scheme[500],
217+
}}
218+
onClick={handleClose}
219+
>
220+
Apply
221+
</Button>
222+
</DialogActions>
223+
</Dialog>
144224
</Page>
145225
);
146-
// }
147226
};
148227

149228
export default ExploreModuleFragment;

Website/src/components/Searchbar.tsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@ import useShadeColor from "../hooks/useShadeColor";
55
import Paper from "@mui/material/Paper";
66
import InputBase from "@mui/material/InputBase";
77
import IconButton from "@mui/material/IconButton";
8-
import SearchIcon from "@mui/icons-material/Search";
98
import { useTheme } from "@Hooks/useTheme";
109
import { useSettings } from "@Hooks/useSettings";
10+
import FilterListIcon from "@mui/icons-material/FilterList";
1111

1212
type SearchbarProps = {
13+
onFilterClick?: React.MouseEventHandler<HTMLButtonElement>;
1314
onChange: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
1415
placeholder: string;
1516
};
1617

17-
export const Searchbar = ({ placeholder, onChange }: SearchbarProps) => {
18-
const { scheme } = useTheme();
19-
const shade = useShadeColor();
20-
const { settings } = useSettings();
21-
18+
export const Searchbar = ({ placeholder, onChange, onFilterClick }: SearchbarProps) => {
2219
return (
2320
<Paper
2421
component="form"
@@ -30,14 +27,8 @@ export const Searchbar = ({ placeholder, onChange }: SearchbarProps) => {
3027
width: "100%",
3128
}}
3229
>
33-
<IconButton
34-
// onClick={() => {
35-
// onSearch(value);
36-
// }}
37-
sx={{ p: "10px" }}
38-
aria-label="menu"
39-
>
40-
<SearchIcon />
30+
<IconButton onClick={onFilterClick} sx={{ p: "10px" }} aria-label="menu">
31+
<FilterListIcon />
4132
</IconButton>
4233
<FormControl fullWidth>
4334
<InputBase

0 commit comments

Comments
 (0)