|
|
@@ -51,8 +51,8 @@ const BUTTON_SIZES: Array<IButtonProps["size"]> = [
|
|
|
];
|
|
|
|
|
|
const BUTTON_TYPES_DATA = BUTTON_TYPES.map(item => ({
|
|
|
- __key: item as string,
|
|
|
- __title: item as string
|
|
|
+ __title: item as string,
|
|
|
+ __key: item as string
|
|
|
}));
|
|
|
|
|
|
const BUTTON_SPREAD_BEHAVIOURS: Array<IButtonProps["spreadBehaviour"]> = [
|
|
|
@@ -62,13 +62,13 @@ const BUTTON_SPREAD_BEHAVIOURS: Array<IButtonProps["spreadBehaviour"]> = [
|
|
|
];
|
|
|
|
|
|
const BUTTON_VARIANTS_DATA = BUTTON_VARIANTS.map(item => ({
|
|
|
- __key: item as string,
|
|
|
- __title: item as string
|
|
|
+ __title: item as string,
|
|
|
+ __key: item as string
|
|
|
}));
|
|
|
|
|
|
const BUTTON_SIZES_DATA = BUTTON_SIZES.map(item => ({
|
|
|
- __key: item as string,
|
|
|
- __title: item as string
|
|
|
+ __title: item as string,
|
|
|
+ __key: item as string
|
|
|
}));
|
|
|
|
|
|
const ButtonPage = () => {
|
|
|
@@ -137,25 +137,25 @@ const ButtonPage = () => {
|
|
|
|
|
|
useLayoutEffect(() => {
|
|
|
navigation.setOptions({
|
|
|
- headerShown: true,
|
|
|
header: () => <Header
|
|
|
isWrapSafeareaContext={false}
|
|
|
title={localize("button")}
|
|
|
navigation={navigation}
|
|
|
isGoBackEnable={true}
|
|
|
- />
|
|
|
+ />,
|
|
|
+ headerShown: true
|
|
|
});
|
|
|
}, []);
|
|
|
|
|
|
return <PageContainer
|
|
|
- isWorkWithHeaderSpace={false}
|
|
|
- isScrollable={true}
|
|
|
scrollViewProps={{
|
|
|
contentContainerStyle: stylesheet.scrollContent
|
|
|
}}
|
|
|
+ isWorkWithHeaderSpace={false}
|
|
|
scrollViewStyle={[
|
|
|
stylesheet.container
|
|
|
]}
|
|
|
+ isScrollable={true}
|
|
|
>
|
|
|
<View
|
|
|
style={[
|
|
|
@@ -163,9 +163,9 @@ const ButtonPage = () => {
|
|
|
]}
|
|
|
>
|
|
|
<Text
|
|
|
+ style={stylesheet.descText}
|
|
|
variant="bodyMediumSize"
|
|
|
color="mid"
|
|
|
- style={stylesheet.descText}
|
|
|
>
|
|
|
{localize("button-desc")}
|
|
|
</Text>
|
|
|
@@ -185,12 +185,6 @@ const ButtonPage = () => {
|
|
|
spreadBehaviour={BUTTON_SPREAD_BEHAVIOURS[spreadIndex]}
|
|
|
title={title || localize("example-button")}
|
|
|
variant={BUTTON_VARIANTS[variantIndex]}
|
|
|
- isCustomPadding={isCustomPadding}
|
|
|
- type={BUTTON_TYPES[typeIndex]}
|
|
|
- size={BUTTON_SIZES[sizeIndex]}
|
|
|
- iconDirection={iconDirection}
|
|
|
- isDisabled={isDisabled}
|
|
|
- isLoading={isLoading}
|
|
|
icon={showIcon ? ({
|
|
|
color,
|
|
|
size
|
|
|
@@ -201,6 +195,12 @@ const ButtonPage = () => {
|
|
|
style={{
|
|
|
marginBottom: spaces.spacingLg
|
|
|
}}
|
|
|
+ isCustomPadding={isCustomPadding}
|
|
|
+ type={BUTTON_TYPES[typeIndex]}
|
|
|
+ size={BUTTON_SIZES[sizeIndex]}
|
|
|
+ iconDirection={iconDirection}
|
|
|
+ isDisabled={isDisabled}
|
|
|
+ isLoading={isLoading}
|
|
|
onPress={() => {
|
|
|
}}
|
|
|
/>
|
|
|
@@ -211,10 +211,10 @@ const ButtonPage = () => {
|
|
|
}}
|
|
|
>
|
|
|
<Text
|
|
|
- variant="headlineSmallSize"
|
|
|
style={{
|
|
|
marginBottom: spaces.spacingSm
|
|
|
}}
|
|
|
+ variant="headlineSmallSize"
|
|
|
>
|
|
|
{localize("usage")}
|
|
|
</Text>
|
|
|
@@ -225,13 +225,13 @@ const ButtonPage = () => {
|
|
|
</View>
|
|
|
<TextInput
|
|
|
placeholder={localize("enter-text")}
|
|
|
+ style={{
|
|
|
+ marginBottom: spaces.spacingMd
|
|
|
+ }}
|
|
|
title={localize("button-title")}
|
|
|
spreadBehaviour="stretch"
|
|
|
onChangeText={setTitle}
|
|
|
value={title}
|
|
|
- style={{
|
|
|
- marginBottom: spaces.spacingMd
|
|
|
- }}
|
|
|
/>
|
|
|
<View
|
|
|
style={[
|
|
|
@@ -242,6 +242,12 @@ const ButtonPage = () => {
|
|
|
]}
|
|
|
>
|
|
|
<SelectBox
|
|
|
+ onChange={(selectedItems) => {
|
|
|
+ if (selectedItems.length > 0) {
|
|
|
+ const index = BUTTON_TYPES.indexOf(selectedItems[0]!.__key as IButtonProps["type"]);
|
|
|
+ if (index !== -1) setTypeIndex(index);
|
|
|
+ }
|
|
|
+ }}
|
|
|
initialSelectedItems={
|
|
|
|
|
|
BUTTON_TYPES_DATA[typeIndex]
|
|
|
@@ -256,16 +262,16 @@ const ButtonPage = () => {
|
|
|
titleExtractor={(item) => item.__title}
|
|
|
keyExtractor={(item) => item.__key}
|
|
|
title={localize("change-type")}
|
|
|
- spreadBehaviour="free"
|
|
|
data={BUTTON_TYPES_DATA}
|
|
|
+ spreadBehaviour="free"
|
|
|
+ />
|
|
|
+ <SelectBox
|
|
|
onChange={(selectedItems) => {
|
|
|
if (selectedItems.length > 0) {
|
|
|
- const index = BUTTON_TYPES.indexOf(selectedItems[0]!.__key as IButtonProps["type"]);
|
|
|
- if (index !== -1) setTypeIndex(index);
|
|
|
+ const index = BUTTON_VARIANTS.indexOf(selectedItems[0]!.__key as IButtonProps["variant"]);
|
|
|
+ if (index !== -1) setVariantIndex(index);
|
|
|
}
|
|
|
}}
|
|
|
- />
|
|
|
- <SelectBox
|
|
|
initialSelectedItems={
|
|
|
|
|
|
BUTTON_VARIANTS_DATA[variantIndex]
|
|
|
@@ -282,23 +288,23 @@ const ButtonPage = () => {
|
|
|
title={localize("change-variant")}
|
|
|
data={BUTTON_VARIANTS_DATA}
|
|
|
spreadBehaviour="free"
|
|
|
- onChange={(selectedItems) => {
|
|
|
- if (selectedItems.length > 0) {
|
|
|
- const index = BUTTON_VARIANTS.indexOf(selectedItems[0]!.__key as IButtonProps["variant"]);
|
|
|
- if (index !== -1) setVariantIndex(index);
|
|
|
- }
|
|
|
- }}
|
|
|
/>
|
|
|
<Button
|
|
|
+ onPress={() => {
|
|
|
+ setSpreadIndex(prev => prev + 1 > BUTTON_SPREAD_BEHAVIOURS.length - 1 ? 0 : prev + 1);
|
|
|
+ }}
|
|
|
title={`${localize("change-spread")}: ${BUTTON_SPREAD_BEHAVIOURS[spreadIndex]}`}
|
|
|
verticalLocationForStretchFix="center"
|
|
|
isFixVerticalStretch={true}
|
|
|
spreadBehaviour="free"
|
|
|
- onPress={() => {
|
|
|
- setSpreadIndex(prev => prev + 1 > BUTTON_SPREAD_BEHAVIOURS.length - 1 ? 0 : prev + 1);
|
|
|
- }}
|
|
|
/>
|
|
|
<SelectBox
|
|
|
+ onChange={(selectedItems) => {
|
|
|
+ if (selectedItems.length > 0) {
|
|
|
+ const index = BUTTON_SIZES.indexOf(selectedItems[0]!.__key as IButtonProps["size"]);
|
|
|
+ if (index !== -1) setSizeIndex(index);
|
|
|
+ }
|
|
|
+ }}
|
|
|
initialSelectedItems={
|
|
|
|
|
|
BUTTON_SIZES_DATA[sizeIndex]
|
|
|
@@ -313,14 +319,8 @@ const ButtonPage = () => {
|
|
|
titleExtractor={(item) => item.__title}
|
|
|
keyExtractor={(item) => item.__key}
|
|
|
title={localize("change-size")}
|
|
|
- spreadBehaviour="free"
|
|
|
data={BUTTON_SIZES_DATA}
|
|
|
- onChange={(selectedItems) => {
|
|
|
- if (selectedItems.length > 0) {
|
|
|
- const index = BUTTON_SIZES.indexOf(selectedItems[0]!.__key as IButtonProps["size"]);
|
|
|
- if (index !== -1) setSizeIndex(index);
|
|
|
- }
|
|
|
- }}
|
|
|
+ spreadBehaviour="free"
|
|
|
/>
|
|
|
<View
|
|
|
style={stylesheet.switchesContainer}
|
|
|
@@ -335,26 +335,26 @@ const ButtonPage = () => {
|
|
|
spreadBehaviour="free"
|
|
|
/>
|
|
|
<Switch
|
|
|
+ title={localize("toggle-icon")}
|
|
|
onPress={() => {
|
|
|
setShowIcon(!showIcon);
|
|
|
}}
|
|
|
- title={localize("toggle-icon")}
|
|
|
spreadBehaviour="free"
|
|
|
isActive={showIcon}
|
|
|
/>
|
|
|
<Switch
|
|
|
+ title={localize("toggle-loading")}
|
|
|
onPress={() => {
|
|
|
setIsLoading(!isLoading);
|
|
|
}}
|
|
|
- title={localize("toggle-loading")}
|
|
|
spreadBehaviour="free"
|
|
|
isActive={isLoading}
|
|
|
/>
|
|
|
<Switch
|
|
|
+ title={localize("toggle-disabled")}
|
|
|
onPress={() => {
|
|
|
setIsDisabled(!isDisabled);
|
|
|
}}
|
|
|
- title={localize("toggle-disabled")}
|
|
|
spreadBehaviour="free"
|
|
|
isActive={isDisabled}
|
|
|
/>
|