Revenge/src/ui/components/Summary.tsx

28 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-02-13 20:34:58 +00:00
import { SummaryProps } from "@types";
2023-02-26 02:20:01 +00:00
import { Forms } from "@ui/components";
import { getAssetIDByName } from "@ui/assets";
import { ReactNative as RN } from "@metro/common";
// TODO: Destructuring Forms doesn't work here. Why?
2023-03-04 22:33:00 +00:00
export default function Summary({ label, icon, noPadding = false, noAnimation = false, children }: SummaryProps) {
const [hidden, setHidden] = React.useState(true);
return (
<>
<Forms.FormRow
label={label}
leading={icon && <Forms.FormRow.Icon source={getAssetIDByName(icon)} />}
2023-03-04 22:33:00 +00:00
trailing={<Forms.FormRow.Arrow style={{ transform: [{ rotate: `${hidden ? 180 : 90}deg` }] }} />}
onPress={() => {
setHidden(!hidden);
if (!noAnimation) RN.LayoutAnimation.configureNext(RN.LayoutAnimation.Presets.easeInEaseOut);
}}
/>
{!hidden && <>
<Forms.FormDivider />
<RN.View style={!noPadding && { paddingHorizontal: 15 }}>{children}</RN.View>
</>}
</>
)
}