esoftplay 0.0.142-a → 0.0.142-c

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.
@@ -307,7 +307,7 @@ export default class m {
307
307
  if (upload) {
308
308
  let fd = new FormData();
309
309
  Object.keys(post).map(function (key) {
310
- if (key !== undefined) {
310
+ if (key !== undefined && post[key] !== undefined) {
311
311
  fd.append(key, post[key])
312
312
  }
313
313
  });
@@ -9,7 +9,7 @@ export interface LibGradientArgs {
9
9
  }
10
10
  export interface LibGradientProps {
11
11
  style?: StyleProp<ViewStyle>,
12
- children: any,
12
+ children?: any,
13
13
  direction: "top-to-bottom" | "bottom-to-top" | "left-to-right" | "right-to-left" | "top-left-to-bottom-right" | "bottom-right-to-top-left" | "top-right-to-bottom-left" | "bottom-left-to-top-right",
14
14
  colors: string[]
15
15
  }
@@ -54,7 +54,7 @@ export default function m(props: LibGradientProps): any {
54
54
  colors={props.colors}
55
55
  style={props.style}
56
56
  {...direction[props.direction]} >
57
- {props.children}
57
+ {props?.children}
58
58
  </LinearGradient>
59
59
  )
60
60
  }
@@ -0,0 +1,105 @@
1
+ // withHooks
2
+
3
+ import { LibFont } from 'esoftplay/cache/lib/font/import';
4
+ import { LibGradient } from 'esoftplay/cache/lib/gradient/import';
5
+ import { LibIcon } from 'esoftplay/cache/lib/icon/import';
6
+ import { LibStyle } from 'esoftplay/cache/lib/style/import';
7
+ import React, { useRef } from 'react';
8
+ import { FlatList, TextInput, View } from 'react-native';
9
+
10
+
11
+ export interface LibNumbermeterArgs {
12
+
13
+ }
14
+ export interface LibNumbermeterProps {
15
+ range: [number, number],
16
+ onValueChange: (value: number) => void,
17
+ valueDisplayEdit?: (value: string) => string
18
+ }
19
+ export default function m(props: LibNumbermeterProps): any {
20
+ const valueRef = useRef<TextInput>(null)
21
+
22
+ let value = useRef(0)
23
+
24
+
25
+ function interpolate(input: number, inputRange: number[], outputRange: number[], clamp = true) {
26
+ if (inputRange.length !== outputRange.length || inputRange.length < 2) {
27
+ throw new Error("Input and output ranges must have the same length and at least two values.");
28
+ }
29
+
30
+ // Find the segment of the range where the input belongs
31
+ for (let i = 0; i < inputRange.length - 1; i++) {
32
+ if (input >= inputRange[i] && input <= inputRange[i + 1]) {
33
+ // Interpolate within this segment
34
+ const t = (input - inputRange[i]) / (inputRange[i + 1] - inputRange[i]);
35
+ const value = outputRange[i] + t * (outputRange[i + 1] - outputRange[i]);
36
+ return clamp
37
+ ? Math.max(outputRange[0], Math.min(outputRange[outputRange.length - 1], value))
38
+ : value;
39
+ }
40
+ }
41
+
42
+ // If the input is outside the range, clamp to the nearest bound
43
+ if (clamp) {
44
+ if (input < inputRange[0]) {
45
+ return outputRange[0];
46
+ }
47
+ if (input > inputRange[inputRange.length - 1]) {
48
+ return outputRange[outputRange.length - 1];
49
+ }
50
+ }
51
+
52
+ throw new Error("Input value could not be interpolated.");
53
+ }
54
+
55
+ const max = props.range[1]
56
+ const min = String(props.range[0])
57
+
58
+ function display(input: string) {
59
+ if (props.valueDisplayEdit) {
60
+ return props.valueDisplayEdit(input)
61
+ } else
62
+ return input
63
+ }
64
+
65
+ return (
66
+ <View>
67
+ <View style={{ alignItems: 'center' }} >
68
+ <TextInput editable={false} ref={valueRef} style={{ fontFamily: LibFont("MonoSpace"), fontSize: 50, fontWeight: "bold" }} defaultValue={props.valueDisplayEdit ? props.valueDisplayEdit?.(min) : min} />
69
+ <LibIcon name='triangle' size={15} style={{ marginLeft: -2, transform: [{ rotate: "180deg" }], textAlign: 'center' }} />
70
+ </View>
71
+ <View style={{ height: 100, backgroundColor: '#fff' }} >
72
+ <FlatList
73
+ horizontal
74
+ onScroll={(e) => {
75
+ const val = interpolate(e.nativeEvent.contentOffset.x, [0, max * 10], [props.range[0], max]).toFixed(0)
76
+ valueRef.current?.setNativeProps({ text: display(val) })
77
+ if (Number(val) != value.current) {
78
+ value.current = Number(val)
79
+ props.onValueChange(Number(val))
80
+ }
81
+
82
+ }}
83
+ style={{ flex: 1 }}
84
+ bounces={false}
85
+ scrollEventThrottle={16}
86
+ data={new Array(max).fill(0)}
87
+ ListHeaderComponent={<View style={{ width: LibStyle.width * 0.5 }} />}
88
+ ListFooterComponent={<View style={{ width: LibStyle.width * 0.5 }} />}
89
+ renderItem={({ item, index }) => {
90
+ return (
91
+ <View style={{ justifyContent: 'center', marginBottom: 20, marginTop: 10 }} >
92
+ <View style={{ marginHorizontal: 3, height: (((index + 1) % 5) == 0) ? 70 : 60, backgroundColor: '#222', width: 4, borderRadius: 2 }} />
93
+ </View>
94
+ )
95
+ }}
96
+ />
97
+ <View pointerEvents='none' style={{ position: 'absolute', left: 0, top: 0, bottom: 0, right: 0, flexDirection: 'row' }} >
98
+ <LibGradient direction='left-to-right' colors={["rgba(255,255,255,1)","rgba(255,255,255,0.9)" ,"rgba(255,255,255,0.0)"]} style={{ width: LibStyle.width * 0.4, height: 100 }} />
99
+ <View style={{ flex: 1 }} />
100
+ <LibGradient direction='right-to-left' colors={["rgba(255,255,255,1)","rgba(255,255,255,0.9)" ,"rgba(255,255,255,0.0)"]} style={{ width: LibStyle.width * 0.4, height: 100 }} />
101
+ </View>
102
+ </View>
103
+ </View>
104
+ )
105
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.142-a",
3
+ "version": "0.0.142-c",
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",