From f78045f9d28f515d5f1dd5d9a013a90f0d75d3cf Mon Sep 17 00:00:00 2001 From: Der_Googler <54764558+DerGoogler@users.noreply.github.com> Date: Sun, 17 Sep 2023 19:54:18 +0200 Subject: [PATCH 1/3] Bump version --- Android/app/build.gradle | 4 ++-- Website/package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Android/app/build.gradle b/Android/app/build.gradle index 0fe97123..2b959032 100755 --- a/Android/app/build.gradle +++ b/Android/app/build.gradle @@ -14,8 +14,8 @@ android { applicationId 'com.dergoogler.mmrl' minSdk 26 targetSdk 33 - versionName '1.6.3' - versionCode 163 + versionName '1.6.4' + versionCode 164 externalNativeBuild { cmake { cppFlags "-llog" diff --git a/Website/package.json b/Website/package.json index f6123f7d..ae3d35d0 100644 --- a/Website/package.json +++ b/Website/package.json @@ -3,8 +3,8 @@ "description": "", "config": { "application_id": "com.dergoogler.mmrl", - "version_name": "1.6.3", - "version_code": 163 + "version_name": "1.6.4", + "version_code": 164 }, "main": "index.tsx", "keywords": [], From e7dd0be34da338ca1391450b09815171a774e981 Mon Sep 17 00:00:00 2001 From: Der_Googler <54764558+DerGoogler@users.noreply.github.com> Date: Sun, 17 Sep 2023 21:50:00 +0200 Subject: [PATCH 2/3] Add filter for explore --- .../fragments/ExploreModuleFragment.tsx | 119 +++++++++++++++--- Website/src/components/Searchbar.tsx | 19 +-- 2 files changed, 104 insertions(+), 34 deletions(-) diff --git a/Website/src/activitys/fragments/ExploreModuleFragment.tsx b/Website/src/activitys/fragments/ExploreModuleFragment.tsx index ee9a797d..01b46789 100644 --- a/Website/src/activitys/fragments/ExploreModuleFragment.tsx +++ b/Website/src/activitys/fragments/ExploreModuleFragment.tsx @@ -3,7 +3,19 @@ import { Searchbar } from "@Components/Searchbar"; import React from "react"; import { useActivity } from "@Hooks/useActivity"; import { useRepos } from "@Hooks/useRepos"; -import { Box, Pagination, Stack, Typography } from "@mui/material"; +import Stack from "@mui/material/Stack"; +import Pagination from "@mui/material/Pagination"; +import Box from "@mui/material/Box"; +import Button from "@mui/material/Button"; +import Dialog from "@mui/material/Dialog"; +import DialogActions from "@mui/material/DialogActions"; +import DialogContent from "@mui/material/DialogContent"; +import DialogTitle from "@mui/material/DialogTitle"; +import InputLabel from "@mui/material/InputLabel"; +import OutlinedInput from "@mui/material/OutlinedInput"; +import MenuItem from "@mui/material/MenuItem"; +import FormControl from "@mui/material/FormControl"; +import Select, { SelectChangeEvent } from "@mui/material/Select"; import { useStrings } from "@Hooks/useStrings"; import { usePagination } from "@Hooks/usePagination"; import RepoActivity from "@Activitys/RepoActivity"; @@ -30,13 +42,39 @@ const ExploreModuleFragment = (props: ExploreModuleProps) => { const { isNetworkAvailable } = useNetwork(); const [search, setSearch] = React.useState(""); - const applyFilter = props.applyFilter(modules, search); + const [open, setOpen] = React.useState(false); + const [exploreFilter, setExploreFilter] = React.useState("none"); + + const filterSystem = () => { + const applyFilter = props.applyFilter(modules, search); + + switch (exploreFilter) { + case "none": + return applyFilter; + case "date_oldest": + return applyFilter.sort(function (a, b) { + var da = new Date(a.last_update).getTime(); + var db = new Date(b.last_update).getTime(); + + return da - db; + }); + case "date_newest": + return applyFilter.sort(function (a, b) { + var da = new Date(a.last_update).getTime(); + var db = new Date(b.last_update).getTime(); + + return db - da; + }); + default: + return applyFilter; + } + }; const [page, setPage] = React.useState(1); const PER_PAGE = 20; - const count = Math.ceil(applyFilter.length / PER_PAGE); - const _DATA = usePagination(applyFilter, PER_PAGE); + const count = Math.ceil(filterSystem().length / PER_PAGE); + const _DATA = usePagination(filterSystem(), PER_PAGE); if (!isNetworkAvailable) { return ( @@ -95,20 +133,20 @@ const ExploreModuleFragment = (props: ExploreModuleProps) => { ); } - // if (modulesLoading) { - // return ( - // - // ); - // } else { + const handleChange = (event: SelectChangeEvent) => { + setExploreFilter(event.target.value); + }; + + const handleClickOpen = () => { + setOpen(true); + }; + + const handleClose = (event: React.SyntheticEvent, reason?: string) => { + if (reason !== "backdropClick") { + setOpen(false); + } + }; + return ( { }} > - setSearch(e.target.value)} /> + setSearch(e.target.value)} /> {_DATA.currentData().map((module, index) => ( @@ -141,9 +179,50 @@ const ExploreModuleFragment = (props: ExploreModuleProps) => { ))} + + + Apply a filter + + + + Filter + + + + + + + + + ); - // } }; export default ExploreModuleFragment; diff --git a/Website/src/components/Searchbar.tsx b/Website/src/components/Searchbar.tsx index 3882c9fc..75671752 100644 --- a/Website/src/components/Searchbar.tsx +++ b/Website/src/components/Searchbar.tsx @@ -5,20 +5,17 @@ import useShadeColor from "../hooks/useShadeColor"; import Paper from "@mui/material/Paper"; import InputBase from "@mui/material/InputBase"; import IconButton from "@mui/material/IconButton"; -import SearchIcon from "@mui/icons-material/Search"; import { useTheme } from "@Hooks/useTheme"; import { useSettings } from "@Hooks/useSettings"; +import FilterListIcon from "@mui/icons-material/FilterList"; type SearchbarProps = { + onFilterClick?: React.MouseEventHandler; onChange: React.ChangeEventHandler; placeholder: string; }; -export const Searchbar = ({ placeholder, onChange }: SearchbarProps) => { - const { scheme } = useTheme(); - const shade = useShadeColor(); - const { settings } = useSettings(); - +export const Searchbar = ({ placeholder, onChange, onFilterClick }: SearchbarProps) => { return ( { width: "100%", }} > - { - // onSearch(value); - // }} - sx={{ p: "10px" }} - aria-label="menu" - > - + + Date: Sun, 17 Sep 2023 21:55:05 +0200 Subject: [PATCH 3/3] Fix #29 and #26 --- Website/src/activitys/DAPITestActivity.tsx | 6 +++--- Website/src/activitys/FetchTextActivity.tsx | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Website/src/activitys/DAPITestActivity.tsx b/Website/src/activitys/DAPITestActivity.tsx index e861508d..2b42a618 100644 --- a/Website/src/activitys/DAPITestActivity.tsx +++ b/Website/src/activitys/DAPITestActivity.tsx @@ -27,8 +27,8 @@ import { Page } from "@Components/onsenui/Page"; import { os } from "@Native/Os"; import { useActivity } from "@Hooks/useActivity"; import { useStrings } from "@Hooks/useStrings"; -import DescriptonActivity from "./DescriptonActivity"; import { Markup } from "@Components/Markdown"; +import FetchTextActivity from "./FetchTextActivity"; interface CustomCommand extends Command { icon: React.ElementType; @@ -140,11 +140,11 @@ const DAPITestActivity = () => { const handlePreview = () => { context.pushPage({ - component: DescriptonActivity, + component: FetchTextActivity, key: "dapi-preview", extra: { title: "Preview", - desc: description, + data: description, }, }); }; diff --git a/Website/src/activitys/FetchTextActivity.tsx b/Website/src/activitys/FetchTextActivity.tsx index da3eb67e..619495fd 100644 --- a/Website/src/activitys/FetchTextActivity.tsx +++ b/Website/src/activitys/FetchTextActivity.tsx @@ -12,6 +12,7 @@ import { MissingInternet } from "@Components/MissingInternet"; type FetchTextActivityExtra = { title: string; + data: string; url: string; }; @@ -30,7 +31,7 @@ function FetchTextActivity() { const initialState: State = { error: undefined, - data: undefined, + data: extra.data || undefined, }; // Keep state logic separated