esoftplay 0.0.126-e → 0.0.126-g

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/bin/build.js CHANGED
@@ -120,7 +120,12 @@ if (fs.existsSync(packjson)) {
120
120
  "associatedDomains": [
121
121
  "applinks:*.domain.com",
122
122
  "applinks:domain.com"
123
- ]
123
+ ],
124
+ "infoPlist": {
125
+ "LSApplicationQueriesSchemes": [
126
+ "itms-apps"
127
+ ]
128
+ }
124
129
  }
125
130
 
126
131
  fs.writeFile(appjson, JSON.stringify($appjson, null, 2), (err) => {
@@ -313,6 +318,7 @@ export default function App() {
313
318
  'react-native-safe-area-context',
314
319
  'react-native-screens',
315
320
  'react-native-webview',
321
+ 'sp-react-native-in-app-updates',
316
322
  'shorthash',
317
323
  'usestable'
318
324
  ]
@@ -369,22 +375,24 @@ export default function App() {
369
375
  // fs.writeFileSync('../@firebase/app/dist/index.rn.cjs.js', firebaseText)
370
376
  // }
371
377
  // /* end AsyncStorage @firebase section */
372
- if (fs.existsSync('../@expo/vector-icons')) {
373
- let esoftplayIcon = ''
374
- fs.readdir('../@expo/vector-icons/build', (err, files) => {
375
- const dfiles = files.filter((file) => file.includes('d.ts'))
376
- dfiles.map((dfile, i) => {
377
- const rdfile = fs.readFileSync('../@expo/vector-icons/build/' + dfile, { encoding: 'utf8' })
378
- const names = (/import\("\.\/createIconSet"\)\.Icon<((.*))\,.*>/g).exec(rdfile);
379
- if (names && names[1].includes('|')) {
380
- esoftplayIcon += 'export type ' + dfile.replace('.d.ts', 'Types') + ' = ' + names[1] + '\n';
381
- }
378
+ if (appjson)
379
+
380
+ if (fs.existsSync('../@expo/vector-icons')) {
381
+ let esoftplayIcon = ''
382
+ fs.readdir('../@expo/vector-icons/build', (err, files) => {
383
+ const dfiles = files.filter((file) => file.includes('d.ts'))
384
+ dfiles.map((dfile, i) => {
385
+ const rdfile = fs.readFileSync('../@expo/vector-icons/build/' + dfile, { encoding: 'utf8' })
386
+ const names = (/import\("\.\/createIconSet"\)\.Icon<((.*))\,.*>/g).exec(rdfile);
387
+ if (names && names[1].includes('|')) {
388
+ esoftplayIcon += 'export type ' + dfile.replace('.d.ts', 'Types') + ' = ' + names[1] + '\n';
389
+ }
390
+ })
391
+ fs.writeFileSync('../@expo/vector-icons/build/esoftplay_icons.ts', esoftplayIcon)
382
392
  })
383
- fs.writeFileSync('../@expo/vector-icons/build/esoftplay_icons.ts', esoftplayIcon)
384
- })
385
- } else {
386
- console.log("@expo/vector-icons not installed")
387
- }
393
+ } else {
394
+ console.log("@expo/vector-icons not installed")
395
+ }
388
396
  console.log('Please wait until processes has finished...');
389
397
  });
390
398
  }
@@ -0,0 +1,75 @@
1
+ // withHooks
2
+
3
+ import useGlobalState from 'esoftplay/global';
4
+ import { useEffect } from 'react';
5
+ import { Platform } from 'react-native';
6
+ import SpInAppUpdates, { IAUInstallStatus, IAUUpdateKind, NeedsUpdateResponse, StartUpdateOptions, StatusUpdateEvent } from 'sp-react-native-in-app-updates';
7
+
8
+
9
+ export interface LibAuto_updateArgs {
10
+
11
+ }
12
+ export interface LibAuto_updateProps {
13
+
14
+ }
15
+
16
+
17
+ const HIGH_PRIORITY_UPDATE = 5;
18
+ const stateOtherData = useGlobalState<any>(null)
19
+ const stateNeedsUpdate = useGlobalState<boolean>(false)
20
+ const stateError = useGlobalState('')
21
+
22
+
23
+ export function startUpdating() {
24
+ checkForUpdates()
25
+ }
26
+
27
+ export function checkForUpdates() {
28
+ const inAppUpdates = new SpInAppUpdates(true)
29
+ inAppUpdates.checkNeedsUpdate().then((result: NeedsUpdateResponse) => {
30
+ stateNeedsUpdate.set(result.shouldUpdate)
31
+ stateOtherData.set(result)
32
+ if (result.shouldUpdate) {
33
+ doUpdate()
34
+ }
35
+ }).catch((e) => {
36
+ stateError.set(e)
37
+ })
38
+ }
39
+
40
+ function doUpdate() {
41
+ const inAppUpdates = new SpInAppUpdates(true)
42
+
43
+ const onStatusUpdate = (status: StatusUpdateEvent) => {
44
+ if (status.status === IAUInstallStatus.DOWNLOADED) {
45
+ inAppUpdates.installUpdate();
46
+ inAppUpdates.removeStatusUpdateListener(finalStatus => { });
47
+ }
48
+ }
49
+
50
+ if (!!stateNeedsUpdate?.get()) {
51
+ let updateOptions: StartUpdateOptions = {};
52
+ if (Platform.OS === 'android' && stateOtherData.get()) {
53
+ if (stateOtherData.get()?.updatePriority >= HIGH_PRIORITY_UPDATE) {
54
+ updateOptions = {
55
+ updateType: IAUUpdateKind.IMMEDIATE,
56
+ };
57
+ } else {
58
+ updateOptions = {
59
+ updateType: IAUUpdateKind.FLEXIBLE,
60
+ };
61
+ }
62
+ }
63
+ inAppUpdates.addStatusUpdateListener(onStatusUpdate);
64
+ inAppUpdates.startUpdate(updateOptions)
65
+ }
66
+ }
67
+
68
+ export default function m(props: LibAuto_updateProps): any {
69
+
70
+ useEffect(() => {
71
+ checkForUpdates()
72
+ }, [])
73
+
74
+ return null
75
+ }
@@ -3,9 +3,9 @@
3
3
  import { useSafeState } from 'esoftplay';
4
4
 
5
5
 
6
- import React, { useCallback } from 'react';
6
+ import React, { useEffect } from 'react';
7
7
  import { Pressable } from 'react-native';
8
- import Animated, { interpolate, useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
8
+ import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
9
9
 
10
10
 
11
11
  export interface LibCollapsArgs {
@@ -17,42 +17,51 @@ export interface LibCollapsProps {
17
17
  style?: any
18
18
  }
19
19
  export default function m(props: LibCollapsProps): any {
20
- const animHeight = useSharedValue(-1)
21
- const bodyHeight = useSharedValue(1)
22
20
  const [expand, setExpand] = useSafeState(props.show)
21
+ const opacity = useSharedValue(0);
22
+ const translateY = useSharedValue(-10);
23
23
 
24
- const heightStyle = useAnimatedStyle(() => {
24
+ const animatedStyle = useAnimatedStyle(() => {
25
25
  return {
26
- overflow: 'hidden',
27
- height: interpolate(animHeight.value,
28
- [0, 1, 2],
29
- [0, bodyHeight.value, bodyHeight.value * 2]),
30
- opacity: interpolate(animHeight.value,
31
- [-1, 0],
32
- [0, 1])
26
+ opacity: opacity.value,
27
+ transform: [{ translateY: translateY.value }],
28
+ };
29
+ });
30
+
31
+ useEffect(() => {
32
+ if (expand) {
33
+ toggleAnimation()
33
34
  }
34
- })
35
+ }, [expand])
36
+
37
+ const toggleAnimation = () => {
38
+ opacity.value = withTiming(opacity.value === 0 ? 1 : 0, { duration: 300 }, (status) => {
39
+ if (opacity.value == 0 && status) {
40
+ runOnJS(setExpand)(false)
41
+ }
42
+ });
43
+ translateY.value = withTiming(opacity.value !== 0 ? -10 : 0, { duration: 300})
44
+ };
35
45
 
36
- const toggle = useCallback(() => {
37
- animHeight.value = animHeight.value == 0 ? withSpring(1) : withTiming(0)
38
- setExpand(animHeight.value != 1)
39
- }, [])
46
+ function toggle() {
47
+ if (!expand) {
48
+ setExpand(true)
49
+ } else {
50
+ toggleAnimation()
51
+ }
52
+ }
40
53
 
41
54
  return (
42
- <Animated.View style={{ overflow: 'hidden' }} >
43
- <Pressable onPress={toggle} >
55
+ <Animated.View>
56
+ <Pressable onPress={toggle} style={{zIndex:11}} >
44
57
  {props.header(expand)}
45
58
  </Pressable>
46
- <Animated.View
47
- onLayout={({ nativeEvent: { layout: { height } } }) => {
48
- if (height && animHeight.value == -1) {
49
- bodyHeight.value = height + 5
50
- animHeight.value = props.show ? 1 : 0
51
- }
52
- }}
53
- style={[heightStyle]}>
54
- {props.children}
55
- </Animated.View>
59
+ {expand &&
60
+ <Animated.View
61
+ style={[{ paddingBottom: expand ? 10 : 0, zIndex:10 }, animatedStyle]}>
62
+ {props.children}
63
+ </Animated.View>
64
+ }
56
65
  </Animated.View>
57
66
  )
58
67
  }
@@ -1,5 +1,6 @@
1
1
  // noPage
2
2
 
3
+ import { LibAuto_update } from 'esoftplay/cache/lib/auto_update/import';
3
4
  import { LibComponent } from 'esoftplay/cache/lib/component/import';
4
5
 
5
6
 
@@ -16,6 +17,10 @@ export default class m extends LibComponent<UserMainProps, UserMainState> {
16
17
  }
17
18
 
18
19
  render(): any {
19
- return null
20
+ return (
21
+ <>
22
+ <LibAuto_update />
23
+ </>
24
+ )
20
25
  }
21
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.126-e",
3
+ "version": "0.0.126-g",
4
4
  "description": "embedding data from esoftplay framework (web based) into mobile app",
5
5
  "main": "cache/index.js",
6
6
  "types": "../../index.d.ts",