|
|
@@ -3,13 +3,16 @@ import {
|
|
|
useState
|
|
|
} from "react";
|
|
|
import {
|
|
|
+ ScrollView,
|
|
|
View
|
|
|
} from "react-native";
|
|
|
import stylesheet from "./stylesheet";
|
|
|
import {
|
|
|
NCoreUIKitLocalize,
|
|
|
+ type IButtonProps,
|
|
|
NCoreUIKitTheme,
|
|
|
PageContainer,
|
|
|
+ TextInput,
|
|
|
Button,
|
|
|
Header
|
|
|
} from "ncore-ui-kit";
|
|
|
@@ -20,6 +23,36 @@ import type RootStackParamList from "../../navigation/type";
|
|
|
import type {
|
|
|
NativeStackNavigationProp
|
|
|
} from "@react-navigation/native-stack";
|
|
|
+import {
|
|
|
+ Home as HomeIcon
|
|
|
+} from "lucide-react-native";
|
|
|
+
|
|
|
+const BUTTON_TYPES: Array<IButtonProps["type"]> = [
|
|
|
+ "primary",
|
|
|
+ "danger",
|
|
|
+ "warning",
|
|
|
+ "neutral",
|
|
|
+ "success",
|
|
|
+ "info"
|
|
|
+];
|
|
|
+
|
|
|
+const BUTTON_SPREAD_BEHAVIOURS: Array<IButtonProps["spreadBehaviour"]> = [
|
|
|
+ "baseline",
|
|
|
+ "stretch",
|
|
|
+ "free"
|
|
|
+];
|
|
|
+
|
|
|
+const BUTTON_VARIANTS: Array<IButtonProps["variant"]> = [
|
|
|
+ "filled",
|
|
|
+ "outline",
|
|
|
+ "ghost"
|
|
|
+];
|
|
|
+
|
|
|
+const BUTTON_SIZES: Array<IButtonProps["size"]> = [
|
|
|
+ "small",
|
|
|
+ "medium",
|
|
|
+ "large"
|
|
|
+];
|
|
|
|
|
|
const ButtonPage = () => {
|
|
|
const {
|
|
|
@@ -35,10 +68,17 @@ const ButtonPage = () => {
|
|
|
|
|
|
const navigation = useNavigation<NativeStackNavigationProp<RootStackParamList>>();
|
|
|
|
|
|
- const [
|
|
|
- variant,
|
|
|
- setVariant
|
|
|
- ] = useState<number>(0);
|
|
|
+ const [typeIndex, setTypeIndex] = useState<number>(0);
|
|
|
+ const [spreadIndex, setSpreadIndex] = useState<number>(0);
|
|
|
+ const [variantIndex, setVariantIndex] = useState<number>(0);
|
|
|
+ const [sizeIndex, setSizeIndex] = useState<number>(1);
|
|
|
+ const [title, setTitle] = useState<string>("");
|
|
|
+
|
|
|
+ const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
|
+ const [isDisabled, setIsDisabled] = useState<boolean>(false);
|
|
|
+ const [isCustomPadding, setIsCustomPadding] = useState<boolean>(false);
|
|
|
+ const [showIcon, setShowIcon] = useState<boolean>(false);
|
|
|
+ const [iconDirection, setIconDirection] = useState<"left" | "right">("left");
|
|
|
|
|
|
useLayoutEffect(() => {
|
|
|
navigation.setOptions({
|
|
|
@@ -52,15 +92,6 @@ const ButtonPage = () => {
|
|
|
});
|
|
|
}, []);
|
|
|
|
|
|
- const buttonVariants: Array<"primary" | "danger" | "warning" | "neutral" | "success" | "info"> = [
|
|
|
- "primary",
|
|
|
- "danger",
|
|
|
- "warning",
|
|
|
- "neutral",
|
|
|
- "success",
|
|
|
- "info"
|
|
|
- ];
|
|
|
-
|
|
|
return <PageContainer
|
|
|
isScrollable={false}
|
|
|
isWorkWithHeaderSpace={false}
|
|
|
@@ -68,40 +99,144 @@ const ButtonPage = () => {
|
|
|
stylesheet.container
|
|
|
]}
|
|
|
>
|
|
|
- <View
|
|
|
- style={[
|
|
|
- stylesheet.contentContainer
|
|
|
- ]}
|
|
|
+ <ScrollView
|
|
|
+ style={{ width: "100%", flex: 1 }}
|
|
|
+ contentContainerStyle={{ alignItems: "center", paddingBottom: 50 }}
|
|
|
+ showsVerticalScrollIndicator={false}
|
|
|
>
|
|
|
<View
|
|
|
- style={{
|
|
|
- borderColor: colors.content.border.subtle,
|
|
|
- marginBottom: spaces.spacingMd,
|
|
|
- borderRadius: radiuses.form,
|
|
|
- borderWidth: borders.line,
|
|
|
- padding: spaces.spacingMd,
|
|
|
- minHeight: 120
|
|
|
- }}
|
|
|
+ style={[
|
|
|
+ stylesheet.contentContainer
|
|
|
+ ]}
|
|
|
>
|
|
|
- <Button
|
|
|
- title={`variant = ${buttonVariants[variant]}`}
|
|
|
- spreadBehaviour="stretch"
|
|
|
- type={buttonVariants[variant]}
|
|
|
+ <View
|
|
|
+ style={{
|
|
|
+ borderColor: colors.content.border.subtle,
|
|
|
+ marginBottom: spaces.spacingMd,
|
|
|
+ borderRadius: radiuses.form,
|
|
|
+ borderWidth: borders.line,
|
|
|
+ padding: spaces.spacingMd,
|
|
|
+ minHeight: 120,
|
|
|
+ alignItems: "center",
|
|
|
+ justifyContent: "center"
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Button
|
|
|
+ title={title || "Example Button"}
|
|
|
+ spreadBehaviour={BUTTON_SPREAD_BEHAVIOURS[spreadIndex]}
|
|
|
+ type={BUTTON_TYPES[typeIndex]}
|
|
|
+ variant={BUTTON_VARIANTS[variantIndex]}
|
|
|
+ size={BUTTON_SIZES[sizeIndex]}
|
|
|
+ isLoading={isLoading}
|
|
|
+ isDisabled={isDisabled}
|
|
|
+ isCustomPadding={isCustomPadding}
|
|
|
+ iconDirection={iconDirection}
|
|
|
+ icon={showIcon ? ({ color, size }) => <HomeIcon color={color as string} size={size} /> : undefined}
|
|
|
+ style={{
|
|
|
+ marginBottom: spaces.spacingLg
|
|
|
+ }}
|
|
|
+ onPress={() => {
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </View>
|
|
|
+ <TextInput
|
|
|
+ value={title}
|
|
|
+ onChangeText={setTitle}
|
|
|
+ placeholder="Enter text"
|
|
|
+ title="Button Title"
|
|
|
style={{
|
|
|
- marginBottom: spaces.spacingLg
|
|
|
+ marginBottom: spaces.spacingMd
|
|
|
}}
|
|
|
+ />
|
|
|
+ <Button
|
|
|
+ title={`Change Type: ${BUTTON_TYPES[typeIndex]}`}
|
|
|
+ spreadBehaviour="free"
|
|
|
+ variant="outline"
|
|
|
+ style={{ marginBottom: spaces.spacingMd }}
|
|
|
onPress={() => {
|
|
|
+ setTypeIndex((typeIndex + 1) % BUTTON_TYPES.length);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <Button
|
|
|
+ title={`Change Variant: ${BUTTON_VARIANTS[variantIndex]}`}
|
|
|
+ spreadBehaviour="free"
|
|
|
+ variant="outline"
|
|
|
+ style={{ marginBottom: spaces.spacingMd }}
|
|
|
+ onPress={() => {
|
|
|
+ setVariantIndex((variantIndex + 1) % BUTTON_VARIANTS.length);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <Button
|
|
|
+ title={`Change Spread: ${BUTTON_SPREAD_BEHAVIOURS[spreadIndex]}`}
|
|
|
+ spreadBehaviour="free"
|
|
|
+ variant="outline"
|
|
|
+ style={{ marginBottom: spaces.spacingMd }}
|
|
|
+ onPress={() => {
|
|
|
+ setSpreadIndex((spreadIndex + 1) % BUTTON_SPREAD_BEHAVIOURS.length);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <Button
|
|
|
+ title={`Change Size: ${BUTTON_SIZES[sizeIndex]}`}
|
|
|
+ spreadBehaviour="free"
|
|
|
+ variant="outline"
|
|
|
+ style={{ marginBottom: spaces.spacingMd }}
|
|
|
+ onPress={() => {
|
|
|
+ setSizeIndex((sizeIndex + 1) % BUTTON_SIZES.length);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <Button
|
|
|
+ title={`Toggle Icon: ${showIcon ? "ON" : "OFF"}`}
|
|
|
+ spreadBehaviour="free"
|
|
|
+ variant="outline"
|
|
|
+ style={{ marginBottom: spaces.spacingMd }}
|
|
|
+ icon={showIcon ? ({
|
|
|
+ size
|
|
|
+ }) => <HomeIcon
|
|
|
+ color={"white"}
|
|
|
+ size={size}
|
|
|
+ /> : undefined}
|
|
|
+ onPress={() => {
|
|
|
+ setShowIcon(!showIcon);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <Button
|
|
|
+ title={`Toggle Icon Direction: ${iconDirection}`}
|
|
|
+ spreadBehaviour="free"
|
|
|
+ variant="outline"
|
|
|
+ style={{ marginBottom: spaces.spacingMd }}
|
|
|
+ onPress={() => {
|
|
|
+ setIconDirection(iconDirection === "left" ? "right" : "left");
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <Button
|
|
|
+ title={`Toggle Loading: ${isLoading ? "ON" : "OFF"}`}
|
|
|
+ spreadBehaviour="free"
|
|
|
+ variant="outline"
|
|
|
+ style={{ marginBottom: spaces.spacingMd }}
|
|
|
+ onPress={() => {
|
|
|
+ setIsLoading(!isLoading);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <Button
|
|
|
+ title={`Toggle Disabled: ${isDisabled ? "ON" : "OFF"}`}
|
|
|
+ spreadBehaviour="free"
|
|
|
+ variant="outline"
|
|
|
+ style={{ marginBottom: spaces.spacingMd }}
|
|
|
+ onPress={() => {
|
|
|
+ setIsDisabled(!isDisabled);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ <Button
|
|
|
+ title={`Toggle Custom Padding: ${isCustomPadding ? "ON" : "OFF"}`}
|
|
|
+ spreadBehaviour="free"
|
|
|
+ variant="outline"
|
|
|
+ style={{ marginBottom: spaces.spacingMd }}
|
|
|
+ onPress={() => {
|
|
|
+ setIsCustomPadding(!isCustomPadding);
|
|
|
}}
|
|
|
/>
|
|
|
</View>
|
|
|
- <Button
|
|
|
- title="Change Variant"
|
|
|
- spreadBehaviour="stretch"
|
|
|
- onPress={() => {
|
|
|
- setVariant(variant + 1 > buttonVariants.length - 1 ? 0 : variant + 1);
|
|
|
- }}
|
|
|
- />
|
|
|
- </View>
|
|
|
+ </ScrollView>
|
|
|
</PageContainer>;
|
|
|
};
|
|
|
export default ButtonPage;
|