@kiosinc/commons-rn 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +31 -0
- package/lib/commonjs/auth/api/authentication.js +20 -0
- package/lib/commonjs/auth/api/authentication.js.map +1 -0
- package/lib/commonjs/auth/appLogo.svg +9 -0
- package/lib/commonjs/auth/hooks/useAuthenticateRequests.js +52 -0
- package/lib/commonjs/auth/hooks/useAuthenticateRequests.js.map +1 -0
- package/lib/commonjs/auth/hooks/useAuthentication.js +89 -0
- package/lib/commonjs/auth/hooks/useAuthentication.js.map +1 -0
- package/lib/commonjs/auth/index.js +33 -0
- package/lib/commonjs/auth/index.js.map +1 -0
- package/lib/commonjs/auth/providers/authentication/AuthenticationProvider.js +57 -0
- package/lib/commonjs/auth/providers/authentication/AuthenticationProvider.js.map +1 -0
- package/lib/commonjs/auth/providers/authentication/actions/authentication.actions.js +13 -0
- package/lib/commonjs/auth/providers/authentication/actions/authentication.actions.js.map +1 -0
- package/lib/commonjs/auth/providers/authentication/index.js +50 -0
- package/lib/commonjs/auth/providers/authentication/index.js.map +1 -0
- package/lib/commonjs/auth/providers/authentication/reducer/authentication.reducer.js +21 -0
- package/lib/commonjs/auth/providers/authentication/reducer/authentication.reducer.js.map +1 -0
- package/lib/commonjs/auth/providers/authentication/types/authentication.types.js +11 -0
- package/lib/commonjs/auth/providers/authentication/types/authentication.types.js.map +1 -0
- package/lib/commonjs/auth/screens/LoginScreen.js +131 -0
- package/lib/commonjs/auth/screens/LoginScreen.js.map +1 -0
- package/lib/commonjs/auth/screens/ResetPassword.js +90 -0
- package/lib/commonjs/auth/screens/ResetPassword.js.map +1 -0
- package/lib/commonjs/auth/screens/ResetPasswordInstructionsSent.js +34 -0
- package/lib/commonjs/auth/screens/ResetPasswordInstructionsSent.js.map +1 -0
- package/lib/commonjs/auth/screens/SignUp.js +176 -0
- package/lib/commonjs/auth/screens/SignUp.js.map +1 -0
- package/lib/commonjs/auth/screens/SignUpPassword.js +103 -0
- package/lib/commonjs/auth/screens/SignUpPassword.js.map +1 -0
- package/lib/commonjs/auth/screens/VerifyPhoneNumber.js +95 -0
- package/lib/commonjs/auth/screens/VerifyPhoneNumber.js.map +1 -0
- package/lib/commonjs/auth/screens/index.js +37 -0
- package/lib/commonjs/auth/screens/index.js.map +1 -0
- package/lib/commonjs/auth/screens/validators.js +39 -0
- package/lib/commonjs/auth/screens/validators.js.map +1 -0
- package/lib/commonjs/components/Alert.js +109 -0
- package/lib/commonjs/components/Alert.js.map +1 -0
- package/lib/commonjs/components/Badge.js +20 -0
- package/lib/commonjs/components/Badge.js.map +1 -0
- package/lib/commonjs/components/BottomSheet.js +60 -0
- package/lib/commonjs/components/BottomSheet.js.map +1 -0
- package/lib/commonjs/components/Button.js +20 -0
- package/lib/commonjs/components/Button.js.map +1 -0
- package/lib/commonjs/components/Card.js +19 -0
- package/lib/commonjs/components/Card.js.map +1 -0
- package/lib/commonjs/components/Divider.js +19 -0
- package/lib/commonjs/components/Divider.js.map +1 -0
- package/lib/commonjs/components/FAB.js +19 -0
- package/lib/commonjs/components/FAB.js.map +1 -0
- package/lib/commonjs/components/Header.js +73 -0
- package/lib/commonjs/components/Header.js.map +1 -0
- package/lib/commonjs/components/IconButton.js +19 -0
- package/lib/commonjs/components/IconButton.js.map +1 -0
- package/lib/commonjs/components/Image.js +45 -0
- package/lib/commonjs/components/Image.js.map +1 -0
- package/lib/commonjs/components/KeyboardAvoidingView.js +23 -0
- package/lib/commonjs/components/KeyboardAvoidingView.js.map +1 -0
- package/lib/commonjs/components/LineLoader.js +61 -0
- package/lib/commonjs/components/LineLoader.js.map +1 -0
- package/lib/commonjs/components/LinkButton.js +32 -0
- package/lib/commonjs/components/LinkButton.js.map +1 -0
- package/lib/commonjs/components/OtpInputs.js +97 -0
- package/lib/commonjs/components/OtpInputs.js.map +1 -0
- package/lib/commonjs/components/ParentView.js +81 -0
- package/lib/commonjs/components/ParentView.js.map +1 -0
- package/lib/commonjs/components/Searchbar.js +22 -0
- package/lib/commonjs/components/Searchbar.js.map +1 -0
- package/lib/commonjs/components/SelectionDialog.js +130 -0
- package/lib/commonjs/components/SelectionDialog.js.map +1 -0
- package/lib/commonjs/components/Snackbar.js +69 -0
- package/lib/commonjs/components/Snackbar.js.map +1 -0
- package/lib/commonjs/components/Surface.js +19 -0
- package/lib/commonjs/components/Surface.js.map +1 -0
- package/lib/commonjs/components/Text.js +20 -0
- package/lib/commonjs/components/Text.js.map +1 -0
- package/lib/commonjs/components/TextInput.js +65 -0
- package/lib/commonjs/components/TextInput.js.map +1 -0
- package/lib/commonjs/components/ToggleButton.js +19 -0
- package/lib/commonjs/components/ToggleButton.js.map +1 -0
- package/lib/commonjs/components/Video.js +42 -0
- package/lib/commonjs/components/Video.js.map +1 -0
- package/lib/commonjs/components/View.js +20 -0
- package/lib/commonjs/components/View.js.map +1 -0
- package/lib/commonjs/components/index.js +174 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/index.js +37 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/theme/index.js +43 -0
- package/lib/commonjs/theme/index.js.map +1 -0
- package/lib/commonjs/theme/theme.js +126 -0
- package/lib/commonjs/theme/theme.js.map +1 -0
- package/lib/commonjs/theme/tokens.js +204 -0
- package/lib/commonjs/theme/tokens.js.map +1 -0
- package/lib/commonjs/types/index.d.js +2 -0
- package/lib/commonjs/types/index.d.js.map +1 -0
- package/lib/commonjs/types/svg.d.js +2 -0
- package/lib/commonjs/types/svg.d.js.map +1 -0
- package/lib/module/auth/api/authentication.js +11 -0
- package/lib/module/auth/api/authentication.js.map +1 -0
- package/lib/module/auth/appLogo.svg +9 -0
- package/lib/module/auth/hooks/useAuthenticateRequests.js +44 -0
- package/lib/module/auth/hooks/useAuthenticateRequests.js.map +1 -0
- package/lib/module/auth/hooks/useAuthentication.js +81 -0
- package/lib/module/auth/hooks/useAuthentication.js.map +1 -0
- package/lib/module/auth/index.js +5 -0
- package/lib/module/auth/index.js.map +1 -0
- package/lib/module/auth/providers/authentication/AuthenticationProvider.js +45 -0
- package/lib/module/auth/providers/authentication/AuthenticationProvider.js.map +1 -0
- package/lib/module/auth/providers/authentication/actions/authentication.actions.js +6 -0
- package/lib/module/auth/providers/authentication/actions/authentication.actions.js.map +1 -0
- package/lib/module/auth/providers/authentication/index.js +5 -0
- package/lib/module/auth/providers/authentication/index.js.map +1 -0
- package/lib/module/auth/providers/authentication/reducer/authentication.reducer.js +14 -0
- package/lib/module/auth/providers/authentication/reducer/authentication.reducer.js.map +1 -0
- package/lib/module/auth/providers/authentication/types/authentication.types.js +5 -0
- package/lib/module/auth/providers/authentication/types/authentication.types.js.map +1 -0
- package/lib/module/auth/screens/LoginScreen.js +121 -0
- package/lib/module/auth/screens/LoginScreen.js.map +1 -0
- package/lib/module/auth/screens/ResetPassword.js +82 -0
- package/lib/module/auth/screens/ResetPassword.js.map +1 -0
- package/lib/module/auth/screens/ResetPasswordInstructionsSent.js +26 -0
- package/lib/module/auth/screens/ResetPasswordInstructionsSent.js.map +1 -0
- package/lib/module/auth/screens/SignUp.js +168 -0
- package/lib/module/auth/screens/SignUp.js.map +1 -0
- package/lib/module/auth/screens/SignUpPassword.js +95 -0
- package/lib/module/auth/screens/SignUpPassword.js.map +1 -0
- package/lib/module/auth/screens/VerifyPhoneNumber.js +87 -0
- package/lib/module/auth/screens/VerifyPhoneNumber.js.map +1 -0
- package/lib/module/auth/screens/index.js +29 -0
- package/lib/module/auth/screens/index.js.map +1 -0
- package/lib/module/auth/screens/validators.js +31 -0
- package/lib/module/auth/screens/validators.js.map +1 -0
- package/lib/module/components/Alert.js +100 -0
- package/lib/module/components/Alert.js.map +1 -0
- package/lib/module/components/Badge.js +12 -0
- package/lib/module/components/Badge.js.map +1 -0
- package/lib/module/components/BottomSheet.js +52 -0
- package/lib/module/components/BottomSheet.js.map +1 -0
- package/lib/module/components/Button.js +12 -0
- package/lib/module/components/Button.js.map +1 -0
- package/lib/module/components/Card.js +11 -0
- package/lib/module/components/Card.js.map +1 -0
- package/lib/module/components/Divider.js +11 -0
- package/lib/module/components/Divider.js.map +1 -0
- package/lib/module/components/FAB.js +11 -0
- package/lib/module/components/FAB.js.map +1 -0
- package/lib/module/components/Header.js +66 -0
- package/lib/module/components/Header.js.map +1 -0
- package/lib/module/components/IconButton.js +11 -0
- package/lib/module/components/IconButton.js.map +1 -0
- package/lib/module/components/Image.js +35 -0
- package/lib/module/components/Image.js.map +1 -0
- package/lib/module/components/KeyboardAvoidingView.js +15 -0
- package/lib/module/components/KeyboardAvoidingView.js.map +1 -0
- package/lib/module/components/LineLoader.js +52 -0
- package/lib/module/components/LineLoader.js.map +1 -0
- package/lib/module/components/LinkButton.js +24 -0
- package/lib/module/components/LinkButton.js.map +1 -0
- package/lib/module/components/OtpInputs.js +87 -0
- package/lib/module/components/OtpInputs.js.map +1 -0
- package/lib/module/components/ParentView.js +72 -0
- package/lib/module/components/ParentView.js.map +1 -0
- package/lib/module/components/Searchbar.js +14 -0
- package/lib/module/components/Searchbar.js.map +1 -0
- package/lib/module/components/SelectionDialog.js +121 -0
- package/lib/module/components/SelectionDialog.js.map +1 -0
- package/lib/module/components/Snackbar.js +60 -0
- package/lib/module/components/Snackbar.js.map +1 -0
- package/lib/module/components/Surface.js +11 -0
- package/lib/module/components/Surface.js.map +1 -0
- package/lib/module/components/Text.js +12 -0
- package/lib/module/components/Text.js.map +1 -0
- package/lib/module/components/TextInput.js +56 -0
- package/lib/module/components/TextInput.js.map +1 -0
- package/lib/module/components/ToggleButton.js +11 -0
- package/lib/module/components/ToggleButton.js.map +1 -0
- package/lib/module/components/Video.js +32 -0
- package/lib/module/components/Video.js.map +1 -0
- package/lib/module/components/View.js +12 -0
- package/lib/module/components/View.js.map +1 -0
- package/lib/module/components/index.js +25 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/theme/index.js +36 -0
- package/lib/module/theme/index.js.map +1 -0
- package/lib/module/theme/theme.js +119 -0
- package/lib/module/theme/theme.js.map +1 -0
- package/lib/module/theme/tokens.js +198 -0
- package/lib/module/theme/tokens.js.map +1 -0
- package/lib/module/types/index.d.js +2 -0
- package/lib/module/types/index.d.js.map +1 -0
- package/lib/module/types/svg.d.js +2 -0
- package/lib/module/types/svg.d.js.map +1 -0
- package/lib/typescript/src/auth/api/authentication.d.ts +4 -0
- package/lib/typescript/src/auth/api/authentication.d.ts.map +1 -0
- package/lib/typescript/src/auth/hooks/useAuthenticateRequests.d.ts +2 -0
- package/lib/typescript/src/auth/hooks/useAuthenticateRequests.d.ts.map +1 -0
- package/lib/typescript/src/auth/hooks/useAuthentication.d.ts +19 -0
- package/lib/typescript/src/auth/hooks/useAuthentication.d.ts.map +1 -0
- package/lib/typescript/src/auth/index.d.ts +5 -0
- package/lib/typescript/src/auth/index.d.ts.map +1 -0
- package/lib/typescript/src/auth/providers/authentication/AuthenticationProvider.d.ts +8 -0
- package/lib/typescript/src/auth/providers/authentication/AuthenticationProvider.d.ts.map +1 -0
- package/lib/typescript/src/auth/providers/authentication/actions/authentication.actions.d.ts +3 -0
- package/lib/typescript/src/auth/providers/authentication/actions/authentication.actions.d.ts.map +1 -0
- package/lib/typescript/src/auth/providers/authentication/index.d.ts +5 -0
- package/lib/typescript/src/auth/providers/authentication/index.d.ts.map +1 -0
- package/lib/typescript/src/auth/providers/authentication/reducer/authentication.reducer.d.ts +3 -0
- package/lib/typescript/src/auth/providers/authentication/reducer/authentication.reducer.d.ts.map +1 -0
- package/lib/typescript/src/auth/providers/authentication/types/authentication.types.d.ts +15 -0
- package/lib/typescript/src/auth/providers/authentication/types/authentication.types.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/LoginScreen.d.ts +3 -0
- package/lib/typescript/src/auth/screens/LoginScreen.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/ResetPassword.d.ts +3 -0
- package/lib/typescript/src/auth/screens/ResetPassword.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/ResetPasswordInstructionsSent.d.ts +8 -0
- package/lib/typescript/src/auth/screens/ResetPasswordInstructionsSent.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/SignUp.d.ts +9 -0
- package/lib/typescript/src/auth/screens/SignUp.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/SignUpPassword.d.ts +8 -0
- package/lib/typescript/src/auth/screens/SignUpPassword.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/VerifyPhoneNumber.d.ts +8 -0
- package/lib/typescript/src/auth/screens/VerifyPhoneNumber.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/index.d.ts +3 -0
- package/lib/typescript/src/auth/screens/index.d.ts.map +1 -0
- package/lib/typescript/src/auth/screens/validators.d.ts +36 -0
- package/lib/typescript/src/auth/screens/validators.d.ts.map +1 -0
- package/lib/typescript/src/components/Alert.d.ts +19 -0
- package/lib/typescript/src/components/Alert.d.ts.map +1 -0
- package/lib/typescript/src/components/Badge.d.ts +9 -0
- package/lib/typescript/src/components/Badge.d.ts.map +1 -0
- package/lib/typescript/src/components/BottomSheet.d.ts +7 -0
- package/lib/typescript/src/components/BottomSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/Button.d.ts +9 -0
- package/lib/typescript/src/components/Button.d.ts.map +1 -0
- package/lib/typescript/src/components/Card.d.ts +9 -0
- package/lib/typescript/src/components/Card.d.ts.map +1 -0
- package/lib/typescript/src/components/Divider.d.ts +9 -0
- package/lib/typescript/src/components/Divider.d.ts.map +1 -0
- package/lib/typescript/src/components/FAB.d.ts +9 -0
- package/lib/typescript/src/components/FAB.d.ts.map +1 -0
- package/lib/typescript/src/components/Header.d.ts +18 -0
- package/lib/typescript/src/components/Header.d.ts.map +1 -0
- package/lib/typescript/src/components/IconButton.d.ts +9 -0
- package/lib/typescript/src/components/IconButton.d.ts.map +1 -0
- package/lib/typescript/src/components/Image.d.ts +9 -0
- package/lib/typescript/src/components/Image.d.ts.map +1 -0
- package/lib/typescript/src/components/KeyboardAvoidingView.d.ts +9 -0
- package/lib/typescript/src/components/KeyboardAvoidingView.d.ts.map +1 -0
- package/lib/typescript/src/components/LineLoader.d.ts +10 -0
- package/lib/typescript/src/components/LineLoader.d.ts.map +1 -0
- package/lib/typescript/src/components/LinkButton.d.ts +9 -0
- package/lib/typescript/src/components/LinkButton.d.ts.map +1 -0
- package/lib/typescript/src/components/OtpInputs.d.ts +18 -0
- package/lib/typescript/src/components/OtpInputs.d.ts.map +1 -0
- package/lib/typescript/src/components/ParentView.d.ts +19 -0
- package/lib/typescript/src/components/ParentView.d.ts.map +1 -0
- package/lib/typescript/src/components/Searchbar.d.ts +9 -0
- package/lib/typescript/src/components/Searchbar.d.ts.map +1 -0
- package/lib/typescript/src/components/SelectionDialog.d.ts +20 -0
- package/lib/typescript/src/components/SelectionDialog.d.ts.map +1 -0
- package/lib/typescript/src/components/Snackbar.d.ts +15 -0
- package/lib/typescript/src/components/Snackbar.d.ts.map +1 -0
- package/lib/typescript/src/components/Surface.d.ts +9 -0
- package/lib/typescript/src/components/Surface.d.ts.map +1 -0
- package/lib/typescript/src/components/Text.d.ts +13 -0
- package/lib/typescript/src/components/Text.d.ts.map +1 -0
- package/lib/typescript/src/components/TextInput.d.ts +12 -0
- package/lib/typescript/src/components/TextInput.d.ts.map +1 -0
- package/lib/typescript/src/components/ToggleButton.d.ts +9 -0
- package/lib/typescript/src/components/ToggleButton.d.ts.map +1 -0
- package/lib/typescript/src/components/Video.d.ts +4 -0
- package/lib/typescript/src/components/Video.d.ts.map +1 -0
- package/lib/typescript/src/components/View.d.ts +9 -0
- package/lib/typescript/src/components/View.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +25 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +284 -0
- package/lib/typescript/src/theme/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/theme.d.ts +4 -0
- package/lib/typescript/src/theme/theme.d.ts.map +1 -0
- package/lib/typescript/src/theme/tokens.d.ts +371 -0
- package/lib/typescript/src/theme/tokens.d.ts.map +1 -0
- package/package.json +191 -0
- package/src/auth/api/authentication.ts +13 -0
- package/src/auth/appLogo.svg +9 -0
- package/src/auth/hooks/useAuthenticateRequests.ts +56 -0
- package/src/auth/hooks/useAuthentication.ts +106 -0
- package/src/auth/index.ts +4 -0
- package/src/auth/providers/authentication/AuthenticationProvider.tsx +68 -0
- package/src/auth/providers/authentication/actions/authentication.actions.ts +10 -0
- package/src/auth/providers/authentication/index.ts +4 -0
- package/src/auth/providers/authentication/reducer/authentication.reducer.ts +21 -0
- package/src/auth/providers/authentication/types/authentication.types.ts +17 -0
- package/src/auth/screens/LoginScreen.tsx +140 -0
- package/src/auth/screens/ResetPassword.tsx +85 -0
- package/src/auth/screens/ResetPasswordInstructionsSent.tsx +32 -0
- package/src/auth/screens/SignUp.tsx +176 -0
- package/src/auth/screens/SignUpPassword.tsx +124 -0
- package/src/auth/screens/VerifyPhoneNumber.tsx +100 -0
- package/src/auth/screens/index.tsx +26 -0
- package/src/auth/screens/validators.ts +73 -0
- package/src/components/Alert.tsx +157 -0
- package/src/components/Badge.tsx +50 -0
- package/src/components/BottomSheet.tsx +72 -0
- package/src/components/Button.tsx +47 -0
- package/src/components/Card.tsx +47 -0
- package/src/components/Divider.tsx +47 -0
- package/src/components/FAB.tsx +47 -0
- package/src/components/Header.tsx +123 -0
- package/src/components/IconButton.tsx +47 -0
- package/src/components/Image.tsx +78 -0
- package/src/components/KeyboardAvoidingView.tsx +55 -0
- package/src/components/LineLoader.tsx +70 -0
- package/src/components/LinkButton.tsx +64 -0
- package/src/components/OtpInputs.tsx +149 -0
- package/src/components/ParentView.tsx +164 -0
- package/src/components/Searchbar.tsx +47 -0
- package/src/components/SelectionDialog.tsx +191 -0
- package/src/components/Snackbar.tsx +83 -0
- package/src/components/Surface.tsx +47 -0
- package/src/components/Text.tsx +70 -0
- package/src/components/TextInput.tsx +116 -0
- package/src/components/ToggleButton.tsx +47 -0
- package/src/components/Video.tsx +37 -0
- package/src/components/View.tsx +55 -0
- package/src/components/index.ts +24 -0
- package/src/index.tsx +5 -0
- package/src/theme/index.ts +37 -0
- package/src/theme/theme.ts +125 -0
- package/src/theme/tokens.ts +209 -0
- package/src/types/index.d.ts +1 -0
- package/src/types/svg.d.ts +4 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { t } from 'i18next';
|
|
2
|
+
import * as yup from 'yup';
|
|
3
|
+
|
|
4
|
+
export const EMAIL_REGEX =
|
|
5
|
+
/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$|^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[^@\s]+\.[^@\s]+$/;
|
|
6
|
+
|
|
7
|
+
const displayName = yup
|
|
8
|
+
.string()
|
|
9
|
+
.required(t('authentication.displayNameRequired'))
|
|
10
|
+
.label(t('authentication.displayNameRequired'));
|
|
11
|
+
|
|
12
|
+
const businessName = yup
|
|
13
|
+
.string()
|
|
14
|
+
.required(t('authentication.businessNameRequired'))
|
|
15
|
+
.label(t('authentication.businessName'));
|
|
16
|
+
|
|
17
|
+
const emailForLogin = yup
|
|
18
|
+
.string()
|
|
19
|
+
.required(t('authentication.requiredEmailForLogin'))
|
|
20
|
+
.matches(EMAIL_REGEX, t('authentication.validEmail'))
|
|
21
|
+
.label(t('authentication.email'));
|
|
22
|
+
|
|
23
|
+
const emailForSignup = yup
|
|
24
|
+
.string()
|
|
25
|
+
.required(t('authentication.requiredEmailForSignUp'))
|
|
26
|
+
.matches(EMAIL_REGEX, t('authentication.validEmail'))
|
|
27
|
+
.label(t('authentication.email'));
|
|
28
|
+
|
|
29
|
+
const phoneNumber = yup
|
|
30
|
+
.string()
|
|
31
|
+
.required(t('authentication.requiredPhoneNumber'))
|
|
32
|
+
.label(t('authentication.phoneNumber'));
|
|
33
|
+
|
|
34
|
+
const password = yup
|
|
35
|
+
.string()
|
|
36
|
+
.required(t('authentication.requiredPassword'))
|
|
37
|
+
.label(t('authentication.password'));
|
|
38
|
+
|
|
39
|
+
const newPassword = yup
|
|
40
|
+
.string()
|
|
41
|
+
.required()
|
|
42
|
+
.min(8, t('authentication.minLength'))
|
|
43
|
+
.matches(/[a-z]/, t('authentication.1lowerChar'))
|
|
44
|
+
.matches(/[A-Z]/, t('authentication.1upperChar'))
|
|
45
|
+
.matches(/[0-9]/, t('authentication.1number'))
|
|
46
|
+
.matches(/[!@#$%^&*(),.?":{}|<>]/, t('authentication.1special'))
|
|
47
|
+
.label(t('authentication.password'));
|
|
48
|
+
|
|
49
|
+
const code = yup.string().required().min(6);
|
|
50
|
+
|
|
51
|
+
export const signUpValidationSchema = yup.object().shape({
|
|
52
|
+
displayName,
|
|
53
|
+
email: emailForSignup,
|
|
54
|
+
phoneNumber,
|
|
55
|
+
name: businessName,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const loginValidationSchema = yup.object().shape({
|
|
59
|
+
email: emailForLogin,
|
|
60
|
+
password,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const resetPasswordValidationSchema = yup.object().shape({
|
|
64
|
+
email: emailForLogin,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const verificationValidationSchema = yup.object().shape({
|
|
68
|
+
code,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export const passwordVerificationSchema = yup.object().shape({
|
|
72
|
+
password: newPassword,
|
|
73
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import React, { useState, useCallback } from 'react';
|
|
2
|
+
import { Dialog, Text, useTheme } from 'react-native-paper';
|
|
3
|
+
import { t } from 'i18next';
|
|
4
|
+
import { Button } from './Button';
|
|
5
|
+
|
|
6
|
+
interface ButtonProps {
|
|
7
|
+
label: string;
|
|
8
|
+
onPress?: () => void;
|
|
9
|
+
mode?: 'text' | 'outlined' | 'contained' | 'elevated' | 'contained-tonal';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface AlertParams {
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
isDismissable?: boolean;
|
|
16
|
+
buttons?: ButtonProps[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface AlertHandle {
|
|
20
|
+
show: (params: AlertParams) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const useAlertHook = () => {
|
|
24
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
25
|
+
const [params, setParams] = useState<AlertParams>({});
|
|
26
|
+
const {
|
|
27
|
+
title = '',
|
|
28
|
+
description = '',
|
|
29
|
+
isDismissable = true,
|
|
30
|
+
buttons = [],
|
|
31
|
+
} = params;
|
|
32
|
+
|
|
33
|
+
const show = useCallback((parameters: AlertParams) => {
|
|
34
|
+
setParams(parameters);
|
|
35
|
+
setIsVisible(true);
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
const hide = useCallback(() => {
|
|
39
|
+
setIsVisible(false);
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
isVisible,
|
|
44
|
+
show,
|
|
45
|
+
hide,
|
|
46
|
+
title,
|
|
47
|
+
description,
|
|
48
|
+
isDismissable,
|
|
49
|
+
buttons,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
let rootLevelRef: AlertHandle | null = null;
|
|
54
|
+
|
|
55
|
+
export const Alert = () => {
|
|
56
|
+
const { isVisible, show, hide, buttons, isDismissable, title, description } =
|
|
57
|
+
useAlertHook();
|
|
58
|
+
const theme = useTheme();
|
|
59
|
+
|
|
60
|
+
const [
|
|
61
|
+
button1 = {
|
|
62
|
+
label: t('ok'),
|
|
63
|
+
onPress: () => {},
|
|
64
|
+
mode: 'text',
|
|
65
|
+
},
|
|
66
|
+
button2,
|
|
67
|
+
button3,
|
|
68
|
+
] = buttons;
|
|
69
|
+
|
|
70
|
+
const ref: any = React.useRef(null);
|
|
71
|
+
|
|
72
|
+
React.useImperativeHandle(
|
|
73
|
+
ref,
|
|
74
|
+
React.useCallback(
|
|
75
|
+
() => ({
|
|
76
|
+
show,
|
|
77
|
+
}),
|
|
78
|
+
[show]
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
rootLevelRef = ref.current;
|
|
84
|
+
}, [ref]);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<Dialog
|
|
88
|
+
style={{
|
|
89
|
+
backgroundColor: theme.colors.background,
|
|
90
|
+
}}
|
|
91
|
+
dismissable={isDismissable}
|
|
92
|
+
dismissableBackButton={isDismissable}
|
|
93
|
+
onDismiss={() => {
|
|
94
|
+
if (isVisible) {
|
|
95
|
+
hide();
|
|
96
|
+
}
|
|
97
|
+
}}
|
|
98
|
+
visible={isVisible}
|
|
99
|
+
>
|
|
100
|
+
{Boolean(title) && (
|
|
101
|
+
<Dialog.Content>
|
|
102
|
+
<Text variant="titleMedium">{title}</Text>
|
|
103
|
+
</Dialog.Content>
|
|
104
|
+
)}
|
|
105
|
+
{Boolean(description) && (
|
|
106
|
+
<Dialog.Content>
|
|
107
|
+
<Text variant="bodyMedium">{description}</Text>
|
|
108
|
+
</Dialog.Content>
|
|
109
|
+
)}
|
|
110
|
+
<Dialog.Actions>
|
|
111
|
+
{button3 && (
|
|
112
|
+
<Button
|
|
113
|
+
mx="8"
|
|
114
|
+
mode={button3?.mode || 'text'}
|
|
115
|
+
onPress={() => {
|
|
116
|
+
hide();
|
|
117
|
+
button3?.onPress?.();
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
{button3.label}
|
|
121
|
+
</Button>
|
|
122
|
+
)}
|
|
123
|
+
{button2 && (
|
|
124
|
+
<Button
|
|
125
|
+
ml="2"
|
|
126
|
+
mode={button2?.mode || 'text'}
|
|
127
|
+
onPress={() => {
|
|
128
|
+
hide();
|
|
129
|
+
button2?.onPress?.();
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
{button2?.label}
|
|
133
|
+
</Button>
|
|
134
|
+
)}
|
|
135
|
+
{button1 && (
|
|
136
|
+
<Button
|
|
137
|
+
ml="2"
|
|
138
|
+
mode={button1?.mode || 'text'}
|
|
139
|
+
onPress={() => {
|
|
140
|
+
hide();
|
|
141
|
+
button1?.onPress?.();
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
{button1.label}
|
|
145
|
+
</Button>
|
|
146
|
+
)}
|
|
147
|
+
</Dialog.Actions>
|
|
148
|
+
</Dialog>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
Alert.displayName = 'Alert';
|
|
153
|
+
|
|
154
|
+
//@ts-ignore
|
|
155
|
+
Alert.show = (params: AlertParams) => {
|
|
156
|
+
rootLevelRef?.show(params);
|
|
157
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Badge as B, type BadgeProps } from 'react-native-paper';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
backgroundColor,
|
|
5
|
+
backgroundColorShorthand,
|
|
6
|
+
type BackgroundColorProps,
|
|
7
|
+
border,
|
|
8
|
+
type BorderProps,
|
|
9
|
+
type ColorProps,
|
|
10
|
+
composeRestyleFunctions,
|
|
11
|
+
layout,
|
|
12
|
+
type LayoutProps,
|
|
13
|
+
position,
|
|
14
|
+
type PositionProps,
|
|
15
|
+
spacing,
|
|
16
|
+
type SpacingProps,
|
|
17
|
+
spacingShorthand,
|
|
18
|
+
type SpacingShorthandProps,
|
|
19
|
+
useRestyle,
|
|
20
|
+
type BackgroundColorShorthandProps,
|
|
21
|
+
} from '@shopify/restyle';
|
|
22
|
+
|
|
23
|
+
import { type ThemeType } from '../theme';
|
|
24
|
+
import React from 'react';
|
|
25
|
+
|
|
26
|
+
type RestyleProps = ColorProps<ThemeType> &
|
|
27
|
+
SpacingProps<ThemeType> &
|
|
28
|
+
SpacingShorthandProps<ThemeType> &
|
|
29
|
+
LayoutProps<ThemeType> &
|
|
30
|
+
PositionProps<ThemeType> &
|
|
31
|
+
BorderProps<ThemeType> &
|
|
32
|
+
BackgroundColorProps<ThemeType> &
|
|
33
|
+
BackgroundColorShorthandProps<ThemeType>;
|
|
34
|
+
|
|
35
|
+
const restyleFunctions = composeRestyleFunctions<ThemeType, RestyleProps>([
|
|
36
|
+
spacing,
|
|
37
|
+
spacingShorthand,
|
|
38
|
+
layout,
|
|
39
|
+
position,
|
|
40
|
+
border,
|
|
41
|
+
backgroundColor,
|
|
42
|
+
backgroundColorShorthand,
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
type propsType = RestyleProps & BadgeProps;
|
|
46
|
+
|
|
47
|
+
export const Badge = ({ children, ...rest }: propsType) => {
|
|
48
|
+
const props = useRestyle(restyleFunctions, rest);
|
|
49
|
+
return <B {...props}>{children}</B>;
|
|
50
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useTheme } from 'react-native-paper';
|
|
3
|
+
import { ParentView, View } from '../components';
|
|
4
|
+
import BS, { BottomSheetBackdrop } from '@gorhom/bottom-sheet';
|
|
5
|
+
import { StyleSheet } from 'react-native';
|
|
6
|
+
|
|
7
|
+
export const BottomSheet = React.forwardRef<
|
|
8
|
+
typeof BS,
|
|
9
|
+
{
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
pressBehavior?: 'close' | 'collapse' | 'none';
|
|
12
|
+
snapPoints: Array<string>;
|
|
13
|
+
}
|
|
14
|
+
>(({ children, pressBehavior = 'none', snapPoints, ...rest }, ref) => {
|
|
15
|
+
const theme = useTheme();
|
|
16
|
+
|
|
17
|
+
const renderBackdrop = useCallback(
|
|
18
|
+
(props: any) => (
|
|
19
|
+
<BottomSheetBackdrop
|
|
20
|
+
{...props}
|
|
21
|
+
pressBehavior={pressBehavior}
|
|
22
|
+
disappearsOnIndex={-1}
|
|
23
|
+
appearsOnIndex={1}
|
|
24
|
+
>
|
|
25
|
+
<View
|
|
26
|
+
style={[
|
|
27
|
+
styles.backdrop,
|
|
28
|
+
{
|
|
29
|
+
backgroundColor: theme.colors.backdrop,
|
|
30
|
+
},
|
|
31
|
+
]}
|
|
32
|
+
/>
|
|
33
|
+
</BottomSheetBackdrop>
|
|
34
|
+
),
|
|
35
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
+
[]
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<BS
|
|
41
|
+
android_keyboardInputMode="adjustPan"
|
|
42
|
+
keyboardBlurBehavior="restore"
|
|
43
|
+
handleStyle={[
|
|
44
|
+
styles.handleStyle,
|
|
45
|
+
{
|
|
46
|
+
backgroundColor: theme.colors.background,
|
|
47
|
+
},
|
|
48
|
+
]}
|
|
49
|
+
handleIndicatorStyle={{
|
|
50
|
+
backgroundColor: theme.colors.onBackground,
|
|
51
|
+
}}
|
|
52
|
+
backdropComponent={renderBackdrop}
|
|
53
|
+
enablePanDownToClose={true}
|
|
54
|
+
snapPoints={snapPoints}
|
|
55
|
+
ref={ref as any}
|
|
56
|
+
index={-1}
|
|
57
|
+
{...rest}
|
|
58
|
+
>
|
|
59
|
+
<ParentView topInset={false}>{children}</ParentView>
|
|
60
|
+
</BS>
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const styles = StyleSheet.create({
|
|
65
|
+
backdrop: {
|
|
66
|
+
flex: 1,
|
|
67
|
+
},
|
|
68
|
+
handleStyle: {
|
|
69
|
+
borderTopRightRadius: 10,
|
|
70
|
+
borderTopLeftRadius: 10,
|
|
71
|
+
},
|
|
72
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button as B, type ButtonProps } from 'react-native-paper';
|
|
3
|
+
import {
|
|
4
|
+
useRestyle,
|
|
5
|
+
spacing,
|
|
6
|
+
border,
|
|
7
|
+
composeRestyleFunctions,
|
|
8
|
+
type SpacingProps,
|
|
9
|
+
type BorderProps,
|
|
10
|
+
type BackgroundColorProps,
|
|
11
|
+
backgroundColor,
|
|
12
|
+
backgroundColorShorthand,
|
|
13
|
+
layout,
|
|
14
|
+
position,
|
|
15
|
+
spacingShorthand,
|
|
16
|
+
type SpacingShorthandProps,
|
|
17
|
+
type LayoutProps,
|
|
18
|
+
type PositionProps,
|
|
19
|
+
type BackgroundColorShorthandProps,
|
|
20
|
+
} from '@shopify/restyle';
|
|
21
|
+
import { type ThemeType } from '../theme';
|
|
22
|
+
|
|
23
|
+
type RestyleProps = SpacingProps<ThemeType> &
|
|
24
|
+
SpacingShorthandProps<ThemeType> &
|
|
25
|
+
LayoutProps<ThemeType> &
|
|
26
|
+
PositionProps<ThemeType> &
|
|
27
|
+
BorderProps<ThemeType> &
|
|
28
|
+
BackgroundColorProps<ThemeType> &
|
|
29
|
+
BackgroundColorShorthandProps<ThemeType>;
|
|
30
|
+
|
|
31
|
+
const restyleFunctions = composeRestyleFunctions<ThemeType, RestyleProps>([
|
|
32
|
+
spacing,
|
|
33
|
+
spacingShorthand,
|
|
34
|
+
layout,
|
|
35
|
+
position,
|
|
36
|
+
border,
|
|
37
|
+
backgroundColor,
|
|
38
|
+
backgroundColorShorthand,
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
type TextProps = Omit<RestyleProps, 'variant'> & ButtonProps;
|
|
42
|
+
|
|
43
|
+
export const Button: React.FC<TextProps> = ({ children, ...rest }) => {
|
|
44
|
+
const restyleProps = useRestyle(restyleFunctions, rest);
|
|
45
|
+
|
|
46
|
+
return <B {...restyleProps}>{children}</B>;
|
|
47
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Card as C, type CardProps } from 'react-native-paper';
|
|
3
|
+
import {
|
|
4
|
+
useRestyle,
|
|
5
|
+
spacing,
|
|
6
|
+
border,
|
|
7
|
+
backgroundColor,
|
|
8
|
+
backgroundColorShorthand,
|
|
9
|
+
type SpacingProps,
|
|
10
|
+
type BorderProps,
|
|
11
|
+
type BackgroundColorProps,
|
|
12
|
+
composeRestyleFunctions,
|
|
13
|
+
type SpacingShorthandProps,
|
|
14
|
+
type LayoutProps,
|
|
15
|
+
type PositionProps,
|
|
16
|
+
spacingShorthand,
|
|
17
|
+
layout,
|
|
18
|
+
position,
|
|
19
|
+
type BackgroundColorShorthandProps,
|
|
20
|
+
} from '@shopify/restyle';
|
|
21
|
+
import { type ThemeType } from '../theme';
|
|
22
|
+
|
|
23
|
+
type RestyleProps = SpacingProps<ThemeType> &
|
|
24
|
+
SpacingShorthandProps<ThemeType> &
|
|
25
|
+
LayoutProps<ThemeType> &
|
|
26
|
+
PositionProps<ThemeType> &
|
|
27
|
+
BorderProps<ThemeType> &
|
|
28
|
+
BackgroundColorProps<ThemeType> &
|
|
29
|
+
BackgroundColorShorthandProps<ThemeType>;
|
|
30
|
+
|
|
31
|
+
const restyleFunctions = composeRestyleFunctions<ThemeType, RestyleProps>([
|
|
32
|
+
spacing,
|
|
33
|
+
spacingShorthand,
|
|
34
|
+
layout,
|
|
35
|
+
position,
|
|
36
|
+
border,
|
|
37
|
+
backgroundColor,
|
|
38
|
+
backgroundColorShorthand,
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
type Props = RestyleProps & CardProps;
|
|
42
|
+
|
|
43
|
+
export const Card = ({ ...rest }: Props) => {
|
|
44
|
+
const props = useRestyle(restyleFunctions as any, rest);
|
|
45
|
+
|
|
46
|
+
return <C {...(props as any)} />;
|
|
47
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Divider as D, type DividerProps } from 'react-native-paper';
|
|
3
|
+
import {
|
|
4
|
+
useRestyle,
|
|
5
|
+
spacing,
|
|
6
|
+
border,
|
|
7
|
+
backgroundColor,
|
|
8
|
+
backgroundColorShorthand,
|
|
9
|
+
type SpacingProps,
|
|
10
|
+
type BorderProps,
|
|
11
|
+
type BackgroundColorProps,
|
|
12
|
+
composeRestyleFunctions,
|
|
13
|
+
type SpacingShorthandProps,
|
|
14
|
+
type LayoutProps,
|
|
15
|
+
type PositionProps,
|
|
16
|
+
spacingShorthand,
|
|
17
|
+
layout,
|
|
18
|
+
position,
|
|
19
|
+
type BackgroundColorShorthandProps,
|
|
20
|
+
} from '@shopify/restyle';
|
|
21
|
+
import { type ThemeType } from '../theme';
|
|
22
|
+
|
|
23
|
+
type RestyleProps = SpacingProps<ThemeType> &
|
|
24
|
+
SpacingShorthandProps<ThemeType> &
|
|
25
|
+
LayoutProps<ThemeType> &
|
|
26
|
+
PositionProps<ThemeType> &
|
|
27
|
+
BorderProps<ThemeType> &
|
|
28
|
+
BackgroundColorProps<ThemeType> &
|
|
29
|
+
BackgroundColorShorthandProps<ThemeType>;
|
|
30
|
+
|
|
31
|
+
const restyleFunctions = composeRestyleFunctions<ThemeType, RestyleProps>([
|
|
32
|
+
spacing,
|
|
33
|
+
spacingShorthand,
|
|
34
|
+
layout,
|
|
35
|
+
position,
|
|
36
|
+
border,
|
|
37
|
+
backgroundColor,
|
|
38
|
+
backgroundColorShorthand,
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
type Props = RestyleProps & DividerProps;
|
|
42
|
+
|
|
43
|
+
export const Divider = ({ ...rest }: Props) => {
|
|
44
|
+
const props = useRestyle(restyleFunctions as any, rest);
|
|
45
|
+
|
|
46
|
+
return <D {...props} />;
|
|
47
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FAB as F, type FABProps } from 'react-native-paper';
|
|
3
|
+
import {
|
|
4
|
+
useRestyle,
|
|
5
|
+
spacing,
|
|
6
|
+
border,
|
|
7
|
+
backgroundColor,
|
|
8
|
+
backgroundColorShorthand,
|
|
9
|
+
type SpacingProps,
|
|
10
|
+
type BorderProps,
|
|
11
|
+
type BackgroundColorProps,
|
|
12
|
+
composeRestyleFunctions,
|
|
13
|
+
type SpacingShorthandProps,
|
|
14
|
+
type LayoutProps,
|
|
15
|
+
type PositionProps,
|
|
16
|
+
spacingShorthand,
|
|
17
|
+
layout,
|
|
18
|
+
position,
|
|
19
|
+
type BackgroundColorShorthandProps,
|
|
20
|
+
} from '@shopify/restyle';
|
|
21
|
+
import { type ThemeType } from '../theme';
|
|
22
|
+
|
|
23
|
+
type RestyleProps = SpacingProps<ThemeType> &
|
|
24
|
+
SpacingShorthandProps<ThemeType> &
|
|
25
|
+
LayoutProps<ThemeType> &
|
|
26
|
+
PositionProps<ThemeType> &
|
|
27
|
+
BorderProps<ThemeType> &
|
|
28
|
+
BackgroundColorProps<ThemeType> &
|
|
29
|
+
BackgroundColorShorthandProps<ThemeType>;
|
|
30
|
+
|
|
31
|
+
const restyleFunctions = composeRestyleFunctions<ThemeType, RestyleProps>([
|
|
32
|
+
spacing,
|
|
33
|
+
spacingShorthand,
|
|
34
|
+
layout,
|
|
35
|
+
position,
|
|
36
|
+
border,
|
|
37
|
+
backgroundColor,
|
|
38
|
+
backgroundColorShorthand,
|
|
39
|
+
]);
|
|
40
|
+
|
|
41
|
+
type Props = RestyleProps & FABProps;
|
|
42
|
+
|
|
43
|
+
export const FAB = ({ ...rest }: Props) => {
|
|
44
|
+
const props = useRestyle(restyleFunctions as any, rest);
|
|
45
|
+
|
|
46
|
+
return <F {...props} />;
|
|
47
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Text } from '../components';
|
|
3
|
+
import { Appbar, Menu, useTheme } from 'react-native-paper';
|
|
4
|
+
import { IconButton } from '../components';
|
|
5
|
+
import { View } from '../components';
|
|
6
|
+
import { useNavigation } from '@react-navigation/native';
|
|
7
|
+
import { type GestureResponderEvent, type ViewProps } from 'react-native';
|
|
8
|
+
import {
|
|
9
|
+
useRestyle,
|
|
10
|
+
spacing,
|
|
11
|
+
border,
|
|
12
|
+
backgroundColor,
|
|
13
|
+
backgroundColorShorthand,
|
|
14
|
+
type SpacingProps,
|
|
15
|
+
type BorderProps,
|
|
16
|
+
type BackgroundColorProps,
|
|
17
|
+
composeRestyleFunctions,
|
|
18
|
+
type SpacingShorthandProps,
|
|
19
|
+
type LayoutProps,
|
|
20
|
+
type PositionProps,
|
|
21
|
+
spacingShorthand,
|
|
22
|
+
layout,
|
|
23
|
+
position,
|
|
24
|
+
type BackgroundColorShorthandProps,
|
|
25
|
+
} from '@shopify/restyle';
|
|
26
|
+
import { type ThemeType } from '../theme';
|
|
27
|
+
|
|
28
|
+
type RestyleProps = SpacingProps<ThemeType> &
|
|
29
|
+
SpacingShorthandProps<ThemeType> &
|
|
30
|
+
LayoutProps<ThemeType> &
|
|
31
|
+
PositionProps<ThemeType> &
|
|
32
|
+
BorderProps<ThemeType> &
|
|
33
|
+
BackgroundColorProps<ThemeType> &
|
|
34
|
+
BackgroundColorShorthandProps<ThemeType>;
|
|
35
|
+
|
|
36
|
+
const restyleFunctions = composeRestyleFunctions<ThemeType, RestyleProps>([
|
|
37
|
+
spacing,
|
|
38
|
+
spacingShorthand,
|
|
39
|
+
layout,
|
|
40
|
+
position,
|
|
41
|
+
border,
|
|
42
|
+
backgroundColor,
|
|
43
|
+
backgroundColorShorthand,
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
type Props = RestyleProps &
|
|
47
|
+
ViewProps & {
|
|
48
|
+
textAlign?: 'center' | 'right' | 'left';
|
|
49
|
+
title?: string;
|
|
50
|
+
customRightOptions?: React.ReactNode;
|
|
51
|
+
menuOptions?: Array<{
|
|
52
|
+
leadingIcon: string;
|
|
53
|
+
title: string;
|
|
54
|
+
onPress: (e?: GestureResponderEvent) => void;
|
|
55
|
+
}>;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const Header: React.FC<Props> = ({
|
|
59
|
+
title,
|
|
60
|
+
menuOptions,
|
|
61
|
+
textAlign = 'center',
|
|
62
|
+
customRightOptions = null,
|
|
63
|
+
...rest
|
|
64
|
+
}) => {
|
|
65
|
+
const props = useRestyle(restyleFunctions, rest);
|
|
66
|
+
|
|
67
|
+
const navigation = useNavigation();
|
|
68
|
+
const [visible, setVisible] = React.useState(false);
|
|
69
|
+
const theme = useTheme();
|
|
70
|
+
|
|
71
|
+
const openMenu = () => setVisible(true);
|
|
72
|
+
const closeMenu = () => setVisible(false);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<View
|
|
76
|
+
height={60}
|
|
77
|
+
flexDirection="row"
|
|
78
|
+
alignItems="center"
|
|
79
|
+
{...(props as ViewProps)}
|
|
80
|
+
>
|
|
81
|
+
{navigation.canGoBack() ? (
|
|
82
|
+
<IconButton icon="arrow-left" onPress={navigation.goBack} />
|
|
83
|
+
) : (
|
|
84
|
+
<View width={40} />
|
|
85
|
+
)}
|
|
86
|
+
<Text flex={1} textAlign={textAlign} variant="titleMedium">
|
|
87
|
+
{title}
|
|
88
|
+
</Text>
|
|
89
|
+
{menuOptions && (
|
|
90
|
+
<Menu
|
|
91
|
+
style={{
|
|
92
|
+
backgroundColor: theme.colors.background,
|
|
93
|
+
}}
|
|
94
|
+
contentStyle={{
|
|
95
|
+
backgroundColor: theme.colors.background,
|
|
96
|
+
}}
|
|
97
|
+
visible={visible}
|
|
98
|
+
onDismiss={closeMenu}
|
|
99
|
+
anchor={<Appbar.Action icon="dots-vertical" onPress={openMenu} />}
|
|
100
|
+
>
|
|
101
|
+
{menuOptions.map((menuOption) => {
|
|
102
|
+
const onPress = () => {
|
|
103
|
+
closeMenu();
|
|
104
|
+
menuOption.onPress();
|
|
105
|
+
};
|
|
106
|
+
return (
|
|
107
|
+
<Menu.Item
|
|
108
|
+
style={{
|
|
109
|
+
backgroundColor: theme.colors.background,
|
|
110
|
+
}}
|
|
111
|
+
key={menuOption.title}
|
|
112
|
+
{...menuOption}
|
|
113
|
+
onPress={onPress}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
})}
|
|
117
|
+
</Menu>
|
|
118
|
+
)}
|
|
119
|
+
{customRightOptions}
|
|
120
|
+
{!menuOptions && !customRightOptions && <View width={40} />}
|
|
121
|
+
</View>
|
|
122
|
+
);
|
|
123
|
+
};
|