Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Oct 12, 2023
1 parent 083d1ce commit 179f744
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 48 deletions.
8 changes: 4 additions & 4 deletions Android/app/default/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions Website/src/activitys/MainActivity.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
},
};

Expand Down
120 changes: 79 additions & 41 deletions Website/src/activitys/MainApplication.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -32,44 +32,61 @@ 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;
}

const Clear = motion(ClearIcon);
const Search = motion(SearchIcon);
const MotionTypography = motion(Typography);
const SearchBar = motion(
React.forwardRef<any, SearchbarProps>((props, ref) => {
const [term, setTerm] = React.useState("");
const { onSearch, placeholder } = props;
const MotionInputBase = motion(InputBase);
const SearchBar = React.forwardRef<SearchbarRef, SearchbarProps>((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 (
<InputBase
ref={ref}
autoFocus
fullWidth
value={term}
inputProps={{
"aria-label": placeholder,
onKeyDown(e) {
if (e.key === "Enter") {
e.preventDefault();
onSearch(term);
}
},
}}
onChange={handleTermChange}
placeholder={placeholder}
/>
);
})
);
React.useImperativeHandle(
ref,
() => ({
clear() {
setTerm("");
},
}),
[]
);

return (
<MotionInputBase
ref={ref as any}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
autoFocus
fullWidth
value={term}
inputProps={{
"aria-label": placeholder,
onKeyDown(e) {
if (e.key === "Enter") {
e.preventDefault();
onSearch(term);
}
},
}}
onChange={handleTermChange}
placeholder={placeholder}
/>
);
});

const MainApplication = () => {
const { strings } = useStrings();
Expand All @@ -81,6 +98,8 @@ const MainApplication = () => {
const [localModules, setLocalModules] = React.useState<Module[]>([]);
const [updateableModules, setUpdateableModules] = React.useState<Module[]>(modules);

const searchRef = React.useRef<SearchbarRef | null>(null);

const [isVisible, setVisible] = React.useState(false);
const [search, setSearch] = React.useState("");

Expand Down Expand Up @@ -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 = () => {
Expand All @@ -263,10 +298,14 @@ const MainApplication = () => {
<AnimatePresence>
<Toolbar.Left>
<Toolbar.Button
icon={Menu}
onClick={() => {
context.splitter.show();
iconProps={{
initial: { opacity: 0 },
animate: { opacity: 1 },
exit: { opacity: 0 },
}}
// @ts-ignore
icon={isVisible ? ArrowBackIcon : Menu}
onClick={handleSearch}
/>
</Toolbar.Left>
<Toolbar.Center
Expand Down Expand Up @@ -309,9 +348,8 @@ const MainApplication = () => {
</MotionTypography>
) : (
<SearchBar
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
ref={searchRef as any}
value={search}
onSearch={(term) => setSearch(term)}
placeholder={strings("search_modules")}
/>
Expand All @@ -327,7 +365,7 @@ const MainApplication = () => {
}}
// @ts-ignore
icon={isVisible ? Clear : Search}
onClick={handleSearchState}
onClick={handleOpenSearch}
/>
</Toolbar.Right>
</AnimatePresence>
Expand Down

0 comments on commit 179f744

Please sign in to comment.