@momo-kits/foundation 0.92.26-beta.19 → 0.92.26-beta.20
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/Application/Components.tsx +60 -63
- package/Application/StackScreen.tsx +10 -9
- package/Layout/types.ts +0 -19
- package/package.json +1 -1
- package/Layout/AnimatedInputSearch.tsx +0 -62
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Animated,
|
|
10
10
|
BackHandler,
|
|
11
11
|
DeviceEventEmitter,
|
|
12
|
+
Dimensions,
|
|
12
13
|
StatusBar,
|
|
13
14
|
StyleSheet,
|
|
14
15
|
TouchableOpacity,
|
|
@@ -31,8 +32,11 @@ import {PopupNotify} from '../Popup';
|
|
|
31
32
|
import {Badge, BadgeDot} from '../Badge';
|
|
32
33
|
import {HeaderType} from '../Layout/types';
|
|
33
34
|
import Navigation from './Navigation';
|
|
34
|
-
import {InputSearchProps} from '../Input';
|
|
35
|
-
|
|
35
|
+
import {InputSearch, InputSearchProps} from '../Input';
|
|
36
|
+
|
|
37
|
+
const SCREEN_PADDING = 12;
|
|
38
|
+
const BACK_WIDTH = 28;
|
|
39
|
+
const {width: screenWidth} = Dimensions.get('window');
|
|
36
40
|
|
|
37
41
|
/**
|
|
38
42
|
* default navigation button used header nav
|
|
@@ -520,18 +524,64 @@ const HeaderExtendHeader: React.FC<{
|
|
|
520
524
|
navigation,
|
|
521
525
|
}) => {
|
|
522
526
|
const {theme} = useContext(ApplicationContext);
|
|
523
|
-
|
|
524
|
-
const
|
|
527
|
+
const [rightSpace, setRightSpace] = useState(0);
|
|
528
|
+
const animated = useRef(new Animated.Value(0));
|
|
525
529
|
|
|
526
530
|
useEffect(() => {
|
|
527
531
|
const listener = animatedValue.addListener(({value}) => {
|
|
528
|
-
|
|
532
|
+
animated.current.setValue(value);
|
|
529
533
|
});
|
|
530
534
|
return () => {
|
|
531
535
|
animatedValue?.removeListener(listener);
|
|
532
536
|
};
|
|
533
537
|
}, []);
|
|
534
538
|
|
|
539
|
+
const height = animated.current.interpolate({
|
|
540
|
+
inputRange: [0, 100],
|
|
541
|
+
outputRange: [heightHeader + 52, heightHeader],
|
|
542
|
+
extrapolate: 'clamp',
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
const translateX = animated.current.interpolate({
|
|
546
|
+
inputRange: [0, 100],
|
|
547
|
+
outputRange: [SCREEN_PADDING, BACK_WIDTH + SCREEN_PADDING * 2],
|
|
548
|
+
extrapolate: 'clamp',
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
navigation!.onHeaderRightChange = (width: number) => {
|
|
552
|
+
setRightSpace(width);
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
const renderInputView = (hasColorBG: boolean = false) => {
|
|
556
|
+
return (
|
|
557
|
+
<Animated.View
|
|
558
|
+
style={{
|
|
559
|
+
justifyContent: 'flex-end',
|
|
560
|
+
height,
|
|
561
|
+
}}>
|
|
562
|
+
<Animated.View
|
|
563
|
+
style={{
|
|
564
|
+
transform: [{translateX}],
|
|
565
|
+
marginVertical: Spacing.S,
|
|
566
|
+
width: animated.current.interpolate({
|
|
567
|
+
inputRange: [0, 100],
|
|
568
|
+
outputRange: [
|
|
569
|
+
screenWidth - SCREEN_PADDING * 2,
|
|
570
|
+
screenWidth - SCREEN_PADDING * 3 - BACK_WIDTH - rightSpace,
|
|
571
|
+
],
|
|
572
|
+
extrapolate: 'clamp',
|
|
573
|
+
}),
|
|
574
|
+
}}>
|
|
575
|
+
<InputSearch
|
|
576
|
+
{...inputSearchProps}
|
|
577
|
+
hasColorBG={hasColorBG}
|
|
578
|
+
showButtonText={false}
|
|
579
|
+
/>
|
|
580
|
+
</Animated.View>
|
|
581
|
+
</Animated.View>
|
|
582
|
+
);
|
|
583
|
+
};
|
|
584
|
+
|
|
535
585
|
if (inputSearchProps) {
|
|
536
586
|
if (headerType === 'surface') {
|
|
537
587
|
return (
|
|
@@ -543,30 +593,11 @@ const HeaderExtendHeader: React.FC<{
|
|
|
543
593
|
backgroundColor: theme.colors.background.surface,
|
|
544
594
|
borderBottomWidth: 1,
|
|
545
595
|
borderColor: theme.colors.border.default,
|
|
546
|
-
height
|
|
547
|
-
inputRange: [0, 100],
|
|
548
|
-
outputRange: [heightHeader + 52, heightHeader],
|
|
549
|
-
extrapolate: 'clamp',
|
|
550
|
-
}),
|
|
596
|
+
height,
|
|
551
597
|
},
|
|
552
598
|
]}
|
|
553
599
|
/>
|
|
554
|
-
|
|
555
|
-
style={{
|
|
556
|
-
justifyContent: 'flex-end',
|
|
557
|
-
height: heightAnimated.current.interpolate({
|
|
558
|
-
inputRange: [0, 100],
|
|
559
|
-
outputRange: [heightHeader + 52, heightHeader],
|
|
560
|
-
extrapolate: 'clamp',
|
|
561
|
-
}),
|
|
562
|
-
}}>
|
|
563
|
-
<AnimatedInputSearch
|
|
564
|
-
animatedValue={animatedValue}
|
|
565
|
-
navigation={navigation}
|
|
566
|
-
{...inputSearchProps}
|
|
567
|
-
hasColorBG={true}
|
|
568
|
-
/>
|
|
569
|
-
</Animated.View>
|
|
600
|
+
{renderInputView(true)}
|
|
570
601
|
</>
|
|
571
602
|
);
|
|
572
603
|
}
|
|
@@ -578,11 +609,7 @@ const HeaderExtendHeader: React.FC<{
|
|
|
578
609
|
style={[
|
|
579
610
|
styles.headerBox,
|
|
580
611
|
{
|
|
581
|
-
height
|
|
582
|
-
inputRange: [0, 100],
|
|
583
|
-
outputRange: [heightHeader + 52, heightHeader],
|
|
584
|
-
extrapolate: 'clamp',
|
|
585
|
-
}),
|
|
612
|
+
height,
|
|
586
613
|
},
|
|
587
614
|
]}>
|
|
588
615
|
<Image
|
|
@@ -592,22 +619,7 @@ const HeaderExtendHeader: React.FC<{
|
|
|
592
619
|
style={styles.headerBackground}
|
|
593
620
|
/>
|
|
594
621
|
</Animated.View>
|
|
595
|
-
|
|
596
|
-
<Animated.View
|
|
597
|
-
style={{
|
|
598
|
-
justifyContent: 'flex-end',
|
|
599
|
-
height: heightAnimated.current.interpolate({
|
|
600
|
-
inputRange: [0, 100],
|
|
601
|
-
outputRange: [heightHeader + 52, heightHeader],
|
|
602
|
-
extrapolate: 'clamp',
|
|
603
|
-
}),
|
|
604
|
-
}}>
|
|
605
|
-
<AnimatedInputSearch
|
|
606
|
-
animatedValue={animatedValue}
|
|
607
|
-
navigation={navigation}
|
|
608
|
-
{...inputSearchProps}
|
|
609
|
-
/>
|
|
610
|
-
</Animated.View>
|
|
622
|
+
{renderInputView()}
|
|
611
623
|
</>
|
|
612
624
|
);
|
|
613
625
|
}
|
|
@@ -622,22 +634,7 @@ const HeaderExtendHeader: React.FC<{
|
|
|
622
634
|
style={styles.headerBackground}
|
|
623
635
|
/>
|
|
624
636
|
</View>
|
|
625
|
-
|
|
626
|
-
<Animated.View
|
|
627
|
-
style={{
|
|
628
|
-
justifyContent: 'flex-end',
|
|
629
|
-
height: heightAnimated.current.interpolate({
|
|
630
|
-
inputRange: [0, 100],
|
|
631
|
-
outputRange: [heightHeader + 52, heightHeader],
|
|
632
|
-
extrapolate: 'clamp',
|
|
633
|
-
}),
|
|
634
|
-
}}>
|
|
635
|
-
<AnimatedInputSearch
|
|
636
|
-
animatedValue={animatedValue}
|
|
637
|
-
navigation={navigation}
|
|
638
|
-
{...inputSearchProps}
|
|
639
|
-
/>
|
|
640
|
-
</Animated.View>
|
|
637
|
+
{renderInputView()}
|
|
641
638
|
</>
|
|
642
639
|
);
|
|
643
640
|
}
|
|
@@ -122,9 +122,18 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
122
122
|
* set options for screen
|
|
123
123
|
*/
|
|
124
124
|
useLayoutEffect(() => {
|
|
125
|
+
let defaultOptions = {
|
|
126
|
+
headerRight: {
|
|
127
|
+
type: 'toolkit',
|
|
128
|
+
},
|
|
129
|
+
};
|
|
125
130
|
if (options) {
|
|
126
|
-
|
|
131
|
+
defaultOptions = {
|
|
132
|
+
...defaultOptions,
|
|
133
|
+
...options,
|
|
134
|
+
};
|
|
127
135
|
}
|
|
136
|
+
navigation.setOptions(defaultOptions);
|
|
128
137
|
}, [options]);
|
|
129
138
|
|
|
130
139
|
/**
|
|
@@ -151,14 +160,6 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
151
160
|
};
|
|
152
161
|
}, []);
|
|
153
162
|
|
|
154
|
-
useEffect(() => {
|
|
155
|
-
navigation.setOptions({
|
|
156
|
-
headerRight: {
|
|
157
|
-
type: 'toolkit',
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
}, []);
|
|
161
|
-
|
|
162
163
|
/**
|
|
163
164
|
* tracking for screen load
|
|
164
165
|
*/
|
package/Layout/types.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {Animated} from 'react-native';
|
|
2
|
-
import {InputSearchProps, InputSearchRef} from '../Input';
|
|
3
|
-
import {LegacyRef} from 'react';
|
|
4
|
-
|
|
5
1
|
export type HeaderType = 'default' | 'surface' | 'extended' | 'search' | 'none';
|
|
6
2
|
|
|
7
3
|
export type GridContextProps = {
|
|
@@ -25,18 +21,3 @@ export type GridContextProps = {
|
|
|
25
21
|
*/
|
|
26
22
|
getSizeSpan: (span: number) => number;
|
|
27
23
|
};
|
|
28
|
-
|
|
29
|
-
export type AnimatedInputSearchProps = {
|
|
30
|
-
animatedValue: Animated.Value;
|
|
31
|
-
headerRightWidth: number;
|
|
32
|
-
heightHeader: number;
|
|
33
|
-
headerType: HeaderType;
|
|
34
|
-
inputSearchProps?: InputSearchProps;
|
|
35
|
-
inputRef?: LegacyRef<InputSearchRef>;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type ExtendHeaderProps = {
|
|
39
|
-
headerBackground: string;
|
|
40
|
-
animatedValue: Animated.Value;
|
|
41
|
-
heightHeader: number;
|
|
42
|
-
};
|
package/package.json
CHANGED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, {FC, useEffect, useRef, useState} from 'react';
|
|
2
|
-
import {InputSearch, InputSearchProps} from '../Input';
|
|
3
|
-
import {Animated, Dimensions} from 'react-native';
|
|
4
|
-
import {Spacing} from '../Consts';
|
|
5
|
-
import {scaleSize} from '../Text';
|
|
6
|
-
import Navigation from '../Application/Navigation';
|
|
7
|
-
|
|
8
|
-
export interface AnimatedInputSearchProps extends InputSearchProps {
|
|
9
|
-
animatedValue: Animated.Value;
|
|
10
|
-
navigation?: Navigation;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const SCREEN_PADDING = 12;
|
|
14
|
-
const BACK_WIDTH = 28;
|
|
15
|
-
|
|
16
|
-
const AnimatedInputSearch: FC<AnimatedInputSearchProps> = ({
|
|
17
|
-
animatedValue,
|
|
18
|
-
navigation,
|
|
19
|
-
...props
|
|
20
|
-
}) => {
|
|
21
|
-
const {width: screenWidth} = Dimensions.get('window');
|
|
22
|
-
const widthAnimated = useRef(new Animated.Value(0));
|
|
23
|
-
const [rightSpace, setRightSpace] = useState(0);
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
const listener = animatedValue.addListener(({value}) => {
|
|
27
|
-
widthAnimated.current.setValue(value);
|
|
28
|
-
});
|
|
29
|
-
return () => {
|
|
30
|
-
animatedValue?.removeListener(listener);
|
|
31
|
-
};
|
|
32
|
-
}, []);
|
|
33
|
-
|
|
34
|
-
navigation!.onHeaderRightChange = (width: number) => {
|
|
35
|
-
setRightSpace(width);
|
|
36
|
-
};
|
|
37
|
-
const translateX = widthAnimated.current.interpolate({
|
|
38
|
-
inputRange: [0, 100],
|
|
39
|
-
outputRange: [SCREEN_PADDING, BACK_WIDTH + SCREEN_PADDING * 2],
|
|
40
|
-
extrapolate: 'clamp',
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<Animated.View
|
|
45
|
-
style={{
|
|
46
|
-
transform: [{translateX}],
|
|
47
|
-
marginVertical: Spacing.S,
|
|
48
|
-
width: widthAnimated.current.interpolate({
|
|
49
|
-
inputRange: [0, 100],
|
|
50
|
-
outputRange: [
|
|
51
|
-
screenWidth - SCREEN_PADDING * 2,
|
|
52
|
-
screenWidth - SCREEN_PADDING * 3 - BACK_WIDTH - rightSpace,
|
|
53
|
-
],
|
|
54
|
-
extrapolate: 'clamp',
|
|
55
|
-
}),
|
|
56
|
-
}}>
|
|
57
|
-
<InputSearch {...props} showButtonText={false} />
|
|
58
|
-
</Animated.View>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export default AnimatedInputSearch;
|