[UI > Components] Add Summary, reorganise
This commit is contained in:
parent
371688c805
commit
23e00b6237
2 changed files with 41 additions and 0 deletions
32
src/ui/components/Summary.tsx
Normal file
32
src/ui/components/Summary.tsx
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import { getAssetIDByName } from "@ui/assets";
|
||||||
|
import { ReactNative as RN } from "@metro/common";
|
||||||
|
import { Forms } from "@ui/components";
|
||||||
|
|
||||||
|
// TODO: Animated would be awesome
|
||||||
|
// TODO: Destructuring Forms doesn't work here. Why?
|
||||||
|
|
||||||
|
interface SummaryProps {
|
||||||
|
label: string;
|
||||||
|
icon?: string;
|
||||||
|
noPadding?: boolean;
|
||||||
|
children: JSX.Element | JSX.Element[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Summary({ label, icon, noPadding = false, children }: SummaryProps) {
|
||||||
|
const [hidden, setHidden] = React.useState(true);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Forms.FormRow
|
||||||
|
label={label}
|
||||||
|
leading={icon && <Forms.FormRow.Icon source={getAssetIDByName(icon)} />}
|
||||||
|
trailing={<Forms.FormRow.Arrow style={{ transform: [{ rotate: `${hidden ? 180 : 90}deg` }] }} source={getAssetIDByName("down_arrow")} />}
|
||||||
|
onPress={() => setHidden(!hidden)}
|
||||||
|
/>
|
||||||
|
{!hidden && <>
|
||||||
|
<Forms.FormDivider />
|
||||||
|
<RN.View style={!noPadding && { paddingHorizontal: 15 }}>{children}</RN.View>
|
||||||
|
</>}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
9
src/ui/components/index.ts
Normal file
9
src/ui/components/index.ts
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import { findByDisplayName, findByProps } from "@metro/filters";
|
||||||
|
|
||||||
|
// Discord
|
||||||
|
export const Forms = findByProps("Form", "FormSection");
|
||||||
|
export const General = findByProps("Button", "Text", "View");
|
||||||
|
export const Search = findByDisplayName("StaticSearchBarContainer");
|
||||||
|
|
||||||
|
// Vendetta
|
||||||
|
export { default as Summary } from "@ui/components/Summary";
|
Loading…
Reference in a new issue