@boneframework/native-components 1.0.34 → 1.0.36

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.
@@ -7,6 +7,10 @@ import useStyle from "../hooks/useStyle";
7
7
  function ActivityIndicator({ visible = false , type="default", animationSource}) {
8
8
  const defaultStyles = useStyle();
9
9
 
10
+ if (!animationSource) {
11
+ animationSource = '../../../../assets/animations/loader.json'
12
+ }
13
+
10
14
  const styles = StyleSheet.create({
11
15
  overlay: {
12
16
  flex:1,
@@ -33,7 +33,7 @@ function Image({style, uri, onPress, handleError = error => console.error, sourc
33
33
  imageSource = source;
34
34
  }
35
35
 
36
- if ((null !== user.authToken.accessToken && protectedUri == true) || protectedUri == false) {
36
+ if ((null !== user?.authToken?.accessToken && protectedUri == true) || protectedUri == false) {
37
37
  return (
38
38
  <ExpoImage
39
39
  source={imageSource}
@@ -1,6 +1,6 @@
1
1
  import * as Linking from "expo-linking";
2
2
  import {useEffect} from "react";
3
- import router from 'ex';
3
+ import {router} from 'expo-router';
4
4
 
5
5
  import routes from '../../../../config/routes';
6
6
 
@@ -13,7 +13,7 @@ export default useLinking = () => {
13
13
  if (parts.path !== null && parts.path !== '') {
14
14
  switch (parts.path) {
15
15
  case routes.USER_ACTIVATION:
16
- router.navigate(routes.USER_ACTIVATION, parts.queryParams);
16
+ router.navigate({pathname: routes.USER_ACTIVATION, params: parts.queryParams});
17
17
  break;
18
18
  }
19
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boneframework/native-components",
3
- "version": "1.0.34",
3
+ "version": "1.0.36",
4
4
  "description": "Expo Components for Bone Framework",
5
5
  "main": "src/Bone.ts",
6
6
  "scripts": {
@@ -1,41 +1,39 @@
1
- import {Image, ImageBackground, Keyboard, StyleSheet, View} from "react-native";
2
- import * as Linking from 'expo-linking';
1
+ import {ImageBackground, Keyboard, StyleSheet, View} from "react-native";
2
+ import {router, useGlobalSearchParams} from 'expo-router';
3
3
  import React, {useEffect, useState} from "react";
4
- import * as Yup from 'yup'
5
4
 
6
- import Button from '../components/Button';
7
- import CheckEmailScreen from '../screens/CheckEmailScreen';
8
- import Text from '../components/Text';
9
5
  import ActivityIndicator from "../components/ActivityIndicator";
10
- import Animation from "../components/Animation";
11
6
  import {ErrorMessage, Form, FormField, SubmitButton} from "../components/forms";
12
7
  import ResendActivationScreen from "../screens/ResendActivationlScreen";
13
8
  import SetPasswordScreen from "../screens/SetPasswordScreen";
14
9
  import useApi from "../hooks/useApi";
15
10
  import useAuth from "../hooks/useAuth";
16
- import useLinking from "../hooks/useLinking";
17
11
  import userApi from "../api/users";
18
12
 
19
13
  import settings from "../../../../config/settings";
20
14
  import routes from "../../../../config/routes";
21
- import colors from '../../../../config/colors';
22
15
 
23
- function ActivateUserScreen({navigation, route}) {
16
+ function ActivateUserScreen() {
17
+ const STATUS_BEGIN = 'start_validating';
24
18
  const STATUS_VALIDATE = 'validate_email_token';
25
19
  const STATUS_RESEND = 'resend_email_token';
26
20
  const STATUS_SET_PASSWORD = 'set_password';
21
+
27
22
  const activationApi = useApi(userApi.activateAccount);
28
23
  const resendActivationApi = useApi(userApi.resendactivationEmail);
29
24
  const validateEmailTokenApi = useApi(userApi.validateEmailToken);
30
- const [status, setStatus] = useState(STATUS_VALIDATE);
25
+
26
+ const [status, setStatus] = useState(STATUS_BEGIN);
31
27
  const [error, setError] = useState();
32
28
  const [tokenError, setTokenError] = useState();
29
+
33
30
  const {login} = useAuth();
34
- const url = Linking.useURL();
35
- const email = route.params.email;
36
- const token = route.params.token;
31
+ const params = useGlobalSearchParams();
32
+ const email = params.email;
33
+ const token = params.token;
37
34
 
38
35
  const validateEmailToken = async () => {
36
+ setStatus(STATUS_VALIDATE);
39
37
  const result = await validateEmailTokenApi.request(email, token);
40
38
 
41
39
  if (result.data.ok) {
@@ -53,6 +51,15 @@ function ActivateUserScreen({navigation, route}) {
53
51
  }
54
52
  }
55
53
 
54
+ const convertResponse = (data) => {
55
+ return {
56
+ accessToken: data.access_token,
57
+ expiresIn: data.expires_in,
58
+ refreshToken: data.refresh_token,
59
+ tokenType: data.token_type,
60
+ }
61
+ }
62
+
56
63
  const handleSubmit = async userInfo => {
57
64
  Keyboard.dismiss();
58
65
  try {
@@ -76,7 +83,7 @@ function ActivateUserScreen({navigation, route}) {
76
83
  return;
77
84
  }
78
85
 
79
- login({accessToken: result.data.access_token, refreshToken: result.data.refresh_token});
86
+ login(convertResponse(result.data)).then(router.navigate(routes.HOME));
80
87
  } catch (error) {
81
88
  setError(error);
82
89
  console.error(error);
@@ -94,7 +101,7 @@ function ActivateUserScreen({navigation, route}) {
94
101
  }
95
102
 
96
103
  useEffect(() => {
97
- if (status === STATUS_VALIDATE) {
104
+ if (status === STATUS_BEGIN) {
98
105
  validateEmailToken();
99
106
  }
100
107
  });
@@ -9,7 +9,7 @@ import colors from '../../../../config/colors'
9
9
  function WelcomeScreen({loginOnPress = () => {}, registerOnPress = () => {}, title = 'BONE FRAMEWORK', isLoading = false}) {
10
10
  return (
11
11
  <ImageBackground blurRadius={10} style={styles.background} source={require('../../../../assets/background.png')} >
12
- <ActivityIndicator visible={isLoading} type={'overlay'}/>
12
+ <ActivityIndicator visible={isLoading} type={'overlay'} />
13
13
  <View style={styles.logoContainer}>
14
14
  <Image style={styles.logo} source={require('../../../../assets/logo.png')} />
15
15
  <Text style={styles.tagline}>{ title }</Text>