Skip to content

Commit

Permalink
Merge pull request #2504 from gluestack/release/alert-dialog-useRNModal
Browse files Browse the repository at this point in the history
Release/alert dialog useRNModal
  • Loading branch information
gluestackadmin authored Oct 4, 2024
2 parents ee316b8 + fff51d1 commit 5a08c01
Show file tree
Hide file tree
Showing 61 changed files with 553 additions and 885 deletions.
2 changes: 1 addition & 1 deletion example/storybook-nativewind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@gluestack-style/animation-resolver": "^1.0.4",
"@gluestack-style/react": "^1.0.57",
"@gluestack-ui/config": "^1.1.19",
"@gluestack-ui/themed": "^1.1.53",
"@gluestack-ui/themed": "^1.1.54",
"@gluestack/design-system": "^0.5.36",
"@gorhom/bottom-sheet": "^5.0.0-alpha.10",
"@legendapp/motion": "^2.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ This is an illustration of **Badge** component.
action: {
control: 'select',
options: ['error', 'warning', 'success', 'info', 'muted'],
default: 'success',
default: 'muted',
},
},
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const FormControlMeta: ComponentMeta<typeof FormControl> = {
},
},
args: {
isInvalid: true,
isRequired: true,
isInvalid: false,
isRequired: false,
isDisabled: false,
size: 'md',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,60 @@ import {
FormControlErrorIcon,
FormControlErrorText,
} from '@/components/ui/form-control';
import { AlertCircleIcon } from 'lucide-react-native';
import { AlertCircleIcon } from '@/components/ui/icon';
import { Input, InputField } from '@/components/ui/input';
import { Button, ButtonText } from '@/components/ui/button';
import { VStack } from '@/components/ui/vstack';

const FormControlBasic = ({ isInvalid: propsIsInvalid, ...props }: any) => {
const [isInvalid, setIsInvalid] = React.useState(propsIsInvalid);
const [inputValue, setInputValue] = React.useState('12345');

const handleSubmit = () => {
if (inputValue.length < 6) {
setIsInvalid(true);
} else {
setIsInvalid(false);
}
};

React.useEffect(() => {
setIsInvalid(propsIsInvalid);
}, [propsIsInvalid]);

const FormControlBasic = ({ ...props }: any) => {
return (
<FormControl {...props}>
<FormControlLabel>
<FormControlLabelText>Password</FormControlLabelText>
</FormControlLabel>
<Input>
<InputField
type="password"
defaultValue="12345"
placeholder="password"
/>
</Input>

<FormControlHelper>
<FormControlHelperText>
Must be atleast 6 characters.
</FormControlHelperText>
</FormControlHelper>

<FormControlError>
<FormControlErrorIcon as={AlertCircleIcon} />
<FormControlErrorText>
Atleast 6 characters are required.
</FormControlErrorText>
</FormControlError>
</FormControl>
<VStack className="w-full max-w-[300px] rounded-md border border-background-200 p-4">
<FormControl isInvalid={isInvalid} {...props}>
<FormControlLabel>
<FormControlLabelText>Password</FormControlLabelText>
</FormControlLabel>
<Input className="my-1" size={props.size}>
<InputField
type="password"
placeholder="password"
value={inputValue}
onChange={(e) => setInputValue(e.target.value)}
/>
</Input>

<FormControlHelper>
<FormControlHelperText>
Must be atleast 6 characters.
</FormControlHelperText>
</FormControlHelper>

<FormControlError>
<FormControlErrorIcon as={AlertCircleIcon} />
<FormControlErrorText>
Atleast 6 characters are required.
</FormControlErrorText>
</FormControlError>
</FormControl>

<Button className="w-fit self-end mt-4" size="sm" onPress={handleSubmit}>
<ButtonText>Submit</ButtonText>
</Button>
</VStack>
);
};

Expand Down
Loading

0 comments on commit 5a08c01

Please sign in to comment.