From 179f744fb95bf95f0b3da55ee7a33c093036eec3 Mon Sep 17 00:00:00 2001 From: Der_Googler <54764558+DerGoogler@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:58:55 +0200 Subject: [PATCH] Some fixes --- .../app/default/release/output-metadata.json | 8 +- Website/src/activitys/MainActivity.tsx | 5 +- Website/src/activitys/MainApplication.tsx | 120 ++++++++++++------ 3 files changed, 85 insertions(+), 48 deletions(-) diff --git a/Android/app/default/release/output-metadata.json b/Android/app/default/release/output-metadata.json index bf2044a1..c38ab03d 100644 --- a/Android/app/default/release/output-metadata.json +++ b/Android/app/default/release/output-metadata.json @@ -33,26 +33,26 @@ "filters": [ { "filterType": "ABI", - "value": "armeabi-v7a" + "value": "x86" } ], "attributes": [], "versionCode": 176, "versionName": "1.7.6", - "outputFile": "app-default-armeabi-v7a-release.apk" + "outputFile": "app-default-x86-release.apk" }, { "type": "ONE_OF_MANY", "filters": [ { "filterType": "ABI", - "value": "x86" + "value": "armeabi-v7a" } ], "attributes": [], "versionCode": 176, "versionName": "1.7.6", - "outputFile": "app-default-x86-release.apk" + "outputFile": "app-default-armeabi-v7a-release.apk" }, { "type": "ONE_OF_MANY", diff --git a/Website/src/activitys/MainActivity.tsx b/Website/src/activitys/MainActivity.tsx index 761c8314..bdca661c 100644 --- a/Website/src/activitys/MainActivity.tsx +++ b/Website/src/activitys/MainActivity.tsx @@ -1,8 +1,7 @@ import { CloseRounded } from "@mui/icons-material"; import { useState } from "react"; import { RouterUtil } from "@Util/RouterUtil"; -import { Context, Extra, IntentPusher } from "../hooks/useActivity"; -import { obj } from "googlers-tools"; +import { IntentPusher } from "../hooks/useActivity"; import { useSettings } from "@Hooks/useSettings"; import React from "react"; import { Button, Typography } from "@mui/material"; @@ -119,7 +118,7 @@ const MainActivity = (): JSX.Element => { const route = { component: React.memo(props.component), props: { - key: props.key || props.component.name, + key: props.component.name || props.key, }, }; diff --git a/Website/src/activitys/MainApplication.tsx b/Website/src/activitys/MainApplication.tsx index bfcc171e..1a96b6ac 100644 --- a/Website/src/activitys/MainApplication.tsx +++ b/Website/src/activitys/MainApplication.tsx @@ -1,7 +1,7 @@ import CodeRoundedIcon from "@mui/icons-material/CodeRounded"; import React from "react"; import Typography from "@mui/material/Typography"; -import Avatar from "@mui/material/Avatar"; +import ArrowBackIcon from "@mui/icons-material/ArrowBack"; import FetchTextActivity from "./FetchTextActivity"; import ModuleFragment from "./fragments/ModuleFragment"; import TerminalActivity from "./TerminalActivity"; @@ -32,7 +32,12 @@ import InputBase from "@mui/material/InputBase"; import SearchIcon from "@mui/icons-material/Search"; import ClearIcon from "@mui/icons-material/Clear"; +interface SearchbarRef { + clear(): void; +} + interface SearchbarProps { + value: string; onSearch(term: string): void; placeholder: string; } @@ -40,36 +45,48 @@ interface SearchbarProps { const Clear = motion(ClearIcon); const Search = motion(SearchIcon); const MotionTypography = motion(Typography); -const SearchBar = motion( - React.forwardRef((props, ref) => { - const [term, setTerm] = React.useState(""); - const { onSearch, placeholder } = props; +const MotionInputBase = motion(InputBase); +const SearchBar = React.forwardRef((props, ref) => { + const { onSearch, placeholder, value } = props; + const [term, setTerm] = React.useState(value); - const handleTermChange = (e) => { - setTerm(e.target.value); - }; + const handleTermChange = (e) => { + setTerm(e.target.value); + }; - return ( - - ); - }) -); + React.useImperativeHandle( + ref, + () => ({ + clear() { + setTerm(""); + }, + }), + [] + ); + + return ( + + ); +}); const MainApplication = () => { const { strings } = useStrings(); @@ -81,6 +98,8 @@ const MainApplication = () => { const [localModules, setLocalModules] = React.useState([]); const [updateableModules, setUpdateableModules] = React.useState(modules); + const searchRef = React.useRef(null); + const [isVisible, setVisible] = React.useState(false); const [search, setSearch] = React.useState(""); @@ -248,13 +267,29 @@ const MainApplication = () => { } }, []); - const handleSearchState = () => { - setVisible((prev) => { - if (prev) { + const handleOpenSearch = () => { + if (isVisible) { + if (searchRef.current) { setSearch(""); + searchRef.current.clear(); } - return !prev; - }); + } else { + setVisible((prev) => !prev); + } + }; + + const handleSearch = () => { + if (isVisible) { + setVisible((prev) => { + if (prev && searchRef.current) { + setSearch(""); + searchRef.current.clear(); + } + return !prev; + }); + } else { + context.splitter.show(); + } }; const renderToolbar = () => { @@ -263,10 +298,14 @@ const MainApplication = () => { { - context.splitter.show(); + iconProps={{ + initial: { opacity: 0 }, + animate: { opacity: 1 }, + exit: { opacity: 0 }, }} + // @ts-ignore + icon={isVisible ? ArrowBackIcon : Menu} + onClick={handleSearch} /> { ) : ( setSearch(term)} placeholder={strings("search_modules")} /> @@ -327,7 +365,7 @@ const MainApplication = () => { }} // @ts-ignore icon={isVisible ? Clear : Search} - onClick={handleSearchState} + onClick={handleOpenSearch} />