@boneframework/native-components 1.0.12 → 1.0.14

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.
@@ -35,7 +35,7 @@ function ActivityIndicator({ visible = false , type="default"}) {
35
35
  return (
36
36
  <View style={style}>
37
37
  <Animation
38
- source={require.main.require('assets/animations/loader.json')}
38
+ source={require('../../../../assets/animations/loader.json')}
39
39
  autoPlay={true}
40
40
  loop={true}
41
41
  style={{height: 100, width: 100, opacity: 1}}
@@ -0,0 +1,17 @@
1
+ import { createContext } from "react";
2
+
3
+ const AuthContext = createContext<{
4
+ login: () => void;
5
+ logout: () => void;
6
+ updateUser: () => void;
7
+ user?: object | null;
8
+ isLoading: boolean;
9
+ }>({
10
+ login: () => null,
11
+ logout: () => null,
12
+ updateUser: () => null,
13
+ user: null,
14
+ isLoading: false,
15
+ });
16
+
17
+ export default AuthContext;
@@ -1,4 +1,4 @@
1
- import {useContext} from "react";
1
+ import {useContext, useState} from "react";
2
2
 
3
3
  import AuthContext from "../contexts/auth";
4
4
  import authStorage from "../utilities/authStorage";
@@ -8,23 +8,27 @@ import usersApi from "../api/users";
8
8
  export default useAuth = () => {
9
9
  const profileApi = useApi(usersApi.getProfile);
10
10
  const {user, setUser} = useContext(AuthContext);
11
+ const {isLoading, setIsLoading} = useState(false);
11
12
 
12
13
  const login = async authToken => {
13
- // possibly don't wait here?
14
+ setIsLoading(true);
14
15
  await authStorage.storeAuthToken(authToken).then(async () => {
15
16
  const user = await profileApi.request(authToken);
16
17
  authStorage.storeUser(user.data);
17
18
  user.data.authToken = authToken;
18
19
  setUser(user.data);
20
+ setIsLoading(false);
19
21
  });
20
22
  }
21
23
 
22
24
  const updateUser = async user => {
25
+ setIsLoading(true);
23
26
  const authToken = user.authToken;
24
27
  await delete user.authToken;
25
28
  authStorage.storeUser(user);
26
29
  user.authToken = authToken;
27
30
  setUser({...user});
31
+ setIsLoading(false);
28
32
  }
29
33
 
30
34
  const logout = () => {
@@ -33,5 +37,5 @@ export default useAuth = () => {
33
37
  authStorage.removeUser();
34
38
  }
35
39
 
36
- return {login, logout, updateUser, user};
40
+ return {login, logout, updateUser, user, isLoading};
37
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boneframework/native-components",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Expo Components for Bone Framework",
5
5
  "main": "src/Bone.ts",
6
6
  "scripts": {
@@ -39,12 +39,12 @@ function RegisterScreen({postRegisterUrl}) {
39
39
  return (
40
40
  <>
41
41
  <ActivityIndicator visible={registerApi.loading} type={'overlay'}/>
42
- <ImageBackground blurRadius={10} style={styles.background} source={require.main.require('assets/background.png')} >
42
+ <ImageBackground blurRadius={10} style={styles.background} source={require('../../../../assets/background.png')} >
43
43
  <View style={styles.container}>
44
44
  <TouchableOpacity style={styles.cancelButton} onPress={onClose}>
45
45
  <Icon size={75} name={'close'} />
46
46
  </TouchableOpacity>
47
- <Image style={styles.logo} source={require.main.require('assets/logo.png')} />
47
+ <Image style={styles.logo} source={require('../../../../assets/logo.png')} />
48
48
 
49
49
  <Form
50
50
  initialValues={{ email: ''}}
@@ -7,9 +7,9 @@ import colors from '../../../../config/colors'
7
7
 
8
8
  function WelcomeScreen({loginOnPress = () => {}, registerOnPress = () => {}, title = 'BONE FRAMEWORK'}) {
9
9
  return (
10
- <ImageBackground blurRadius={10} style={styles.background} source={require.main.require('assets/background.png')} >
10
+ <ImageBackground blurRadius={10} style={styles.background} source={require('../../../../assets/background.png')} >
11
11
  <View style={styles.logoContainer}>
12
- <Image style={styles.logo} source={require.main.require('assets/logo.png')} />
12
+ <Image style={styles.logo} source={require('../../../../assets/logo.png')} />
13
13
  <Text style={styles.tagline}>{ title }</Text>
14
14
  </View>
15
15
  <View style={styles.buttonContainer}>
package/contexts/auth.js DELETED
@@ -1,5 +0,0 @@
1
- import React from "react";
2
-
3
- const AuthContext = React.createContext();
4
-
5
- export default AuthContext;