@boneframework/native-components 1.0.6 → 1.0.8

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/README.md CHANGED
@@ -2,8 +2,11 @@
2
2
  React Native expo components for BoneFramework WIP
3
3
  ## project level files referred to in code
4
4
  ```
5
- @/config/settings
6
- @/config/cache
5
+ config/settings
6
+ config/cache
7
+ assets/background.png
8
+ assets/logo.png
9
+ assets/animations/loader.json
7
10
  ```
8
11
  ## install these at root level:
9
12
  ```
package/api/client.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {create} from 'apisauce';
2
2
 
3
3
  import cache from '../utilities/cache';
4
- import settings from '@/config/settings';
5
- import cacheSettings from '@/config/cache';
4
+ import settings from '../../../../config/settings';
5
+ import cacheSettings from '../../../../config/cache';
6
6
 
7
7
  const apiClient = create({
8
8
  baseURL: settings.apiUrl
@@ -35,7 +35,7 @@ function ActivityIndicator({ visible = false , type="default"}) {
35
35
  return (
36
36
  <View style={style}>
37
37
  <Animation
38
- source={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}}
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import {View, StyleSheet, Platform, TouchableOpacity, TouchableHighlight} from "react-native";
3
3
 
4
4
  import Text from '../components/Text'
5
- import colors from '../config/colors'
6
- import defaultStyles from '../config/styles'
5
+ import colors from '../../../../config/colors'
6
+ import defaultStyles from '../../../../config/styles'
7
7
 
8
8
  function Button({title, onPress, color, textColor}) {
9
9
  return (
@@ -0,0 +1,45 @@
1
+ import {useEffect, useState} from "react";
2
+ import * as Location from "expo-location";
3
+ import {Platform, useColorScheme} from "react-native";
4
+
5
+ import colors from "@/config/colors";
6
+ import logger from "@/utility/logger";
7
+
8
+ export default useStyle = () => {
9
+ const colorScheme = useColorScheme();
10
+ const [mode, setMode] = useState();
11
+ const dark = colorScheme == 'dark'
12
+ const style = {
13
+ dark: dark,
14
+ text: {
15
+ color: dark ? colors.light : colors.dark,
16
+ ...Platform.select({
17
+ ios: {
18
+ fontSize: 20,
19
+ fontFamily: "Helvetica",
20
+ },
21
+ android: {
22
+ fontSize: 18,
23
+ fontFamily: "Roboto",
24
+ },
25
+ })
26
+ },
27
+ box: {},
28
+ errorText: {},
29
+ flipswitch: {},
30
+ navButton: {},
31
+ formInput: {},
32
+ backgroundColor: dark ? colors.dark : colors.light,
33
+ colors: colors
34
+ };
35
+
36
+ style.box.backgroundColor = dark ? style.colors.darkish : style.colors.white;
37
+ style.flipswitch.onColor = dark ? style.colors.secondary : style.colors.secondary;
38
+ style.flipswitch.offColor = dark ? style.colors.darkish : style.colors.medium;
39
+ style.formInput.backgroundColor = dark ? style.colors.darkish : style.colors.white;
40
+ style.formInput.text = dark ? style.colors.medium : style.colors.dark;
41
+ style.errorText.color = dark ? style.colors.secondary : style.colors.primary;
42
+ style.navButton.color = dark ? style.colors.light : style.colors.white;
43
+
44
+ return style;
45
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boneframework/native-components",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Expo Components for Bone Framework",
5
5
  "main": "src/Bone.ts",
6
6
  "scripts": {
@@ -34,6 +34,7 @@
34
34
  "expo-auth-session": "^5.5.2",
35
35
  "expo-secure-store": "^13.0.2",
36
36
  "jwt-decode": "^4.0.0",
37
+ "lottie-react-native": "^6.7.2",
37
38
  "react": "18.2.0",
38
39
  "yup": "^1.4.0"
39
40
  }
@@ -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('../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('../assets/logo.png')} />
47
+ <Image style={styles.logo} source={require('../../../../assets/logo.png')} />
48
48
 
49
49
  <Form
50
50
  initialValues={{ email: ''}}
@@ -3,14 +3,14 @@ import {Image, ImageBackground, StyleSheet, Text, View} from "react-native";
3
3
  import {exchangeCodeAsync, makeRedirectUri, useAuthRequest} from "expo-auth-session";
4
4
 
5
5
  import Button from '../components/Button'
6
- import colors from '@/config/colors'
6
+ import colors from '../../../../config/colors'
7
7
 
8
- function WelcomeScreen({loginOnPress = () => {}, registerOnPress = () => {}}) {
8
+ function WelcomeScreen({loginOnPress = () => {}, registerOnPress = () => {}, title = 'BONE FRAMEWORK'}) {
9
9
  return (
10
- <ImageBackground blurRadius={10} style={styles.background} source={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('@/assets/logo.png')} />
13
- <Text style={styles.tagline}>BONE FRAMEWORK</Text>
12
+ <Image style={styles.logo} source={require('../../../../assets/logo.png')} />
13
+ <Text style={styles.tagline}>{ title }</Text>
14
14
  </View>
15
15
  <View style={styles.buttonContainer}>
16
16
  <Button title="login" color="primary" onPress={loginOnPress} ></Button>
@@ -0,0 +1,53 @@
1
+ import AsyncStorage from "@react-native-async-storage/async-storage";
2
+ import dayjs from "dayjs";
3
+
4
+ import logger from './logger';
5
+
6
+ const prefix = 'cache';
7
+ const expiryInMinutes = 5;
8
+
9
+ const store = async (key, value) => {
10
+ try {
11
+ const item = {
12
+ value: value,
13
+ timeatamp: Date.now()
14
+ };
15
+ await AsyncStorage.setItem(prefix + key, JSON.stringify(item));
16
+ } catch (error) {
17
+ console.log(error);
18
+ }
19
+ }
20
+
21
+ const get = async (key) => {
22
+ try {
23
+ const value = await AsyncStorage.getItem(prefix + key);
24
+ const item = JSON.parse(value);
25
+
26
+ if (!item) {
27
+ return null;
28
+ }
29
+
30
+ if (isExpired(item)) {
31
+ await AsyncStorage.removeItem(prefix + key);
32
+
33
+ return null;
34
+ }
35
+
36
+ return item.value;
37
+
38
+ } catch (error) {
39
+ logger.log(error);
40
+ }
41
+ };
42
+
43
+ const isExpired = (item) => {
44
+ const now = dayjs();
45
+ const storedTime = dayjs(item.timeatamp);
46
+
47
+ return now.diff(storedTime, 'minute') > expiryInMinutes;
48
+ }
49
+
50
+ export default {
51
+ get,
52
+ store
53
+ }