@hero-design/rn 8.118.1-alpha.0 → 8.118.2-alpha.0
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/CHANGELOG.md +8 -2
- package/es/index.js +62 -30
- package/lib/index.js +62 -30
- package/package.json +1 -1
- package/src/components/FAB/ActionGroup/index.tsx +4 -2
- package/src/components/FAB/FAB.tsx +69 -41
- package/testUtils/setup.tsx +3 -2
- package/types/components/FAB/FAB.d.ts +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
# @hero-design/rn
|
|
2
2
|
|
|
3
|
-
## 8.118.
|
|
3
|
+
## 8.118.2-alpha.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- [`82a9532c5364c2dea2ffc96153103522295aa868`](https://github.com/Thinkei/hero-design/commit/82a9532c5364c2dea2ffc96153103522295aa868) Thanks [@
|
|
7
|
+
- [#4706](https://github.com/Thinkei/hero-design/pull/4706) [`82a9532c5364c2dea2ffc96153103522295aa868`](https://github.com/Thinkei/hero-design/commit/82a9532c5364c2dea2ffc96153103522295aa868) Thanks [@tqdungit](https://github.com/tqdungit)! - Trigger alpha release for rn
|
|
8
|
+
|
|
9
|
+
## 8.118.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#4719](https://github.com/Thinkei/hero-design/pull/4719) [`2d4e3f901018d95280909eac099ad387982ff1b7`](https://github.com/Thinkei/hero-design/commit/2d4e3f901018d95280909eac099ad387982ff1b7) Thanks [@ttkien](https://github.com/ttkien)! - [FAB] Fix redundant FAB button with bottom navigation
|
|
8
14
|
|
|
9
15
|
## 8.118.0
|
|
10
16
|
|
package/es/index.js
CHANGED
|
@@ -23780,7 +23780,7 @@ var FAB$1 = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
23780
23780
|
var onPress = _ref3.onPress,
|
|
23781
23781
|
title = _ref3.title,
|
|
23782
23782
|
icon = _ref3.icon,
|
|
23783
|
-
|
|
23783
|
+
iconAnimated = _ref3.animated,
|
|
23784
23784
|
testID = _ref3.testID,
|
|
23785
23785
|
active = _ref3.active,
|
|
23786
23786
|
style = _ref3.style;
|
|
@@ -23807,49 +23807,78 @@ var FAB$1 = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
23807
23807
|
React__default.useImperativeHandle(ref, function () {
|
|
23808
23808
|
return {
|
|
23809
23809
|
show: function show() {
|
|
23810
|
-
|
|
23811
|
-
|
|
23812
|
-
useNativeDriver: true
|
|
23813
|
-
}).start();
|
|
23810
|
+
var animated = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
23811
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
|
|
23814
23812
|
setDisplayState({
|
|
23815
23813
|
hideButton: false,
|
|
23816
23814
|
hideTitle: false
|
|
23817
23815
|
});
|
|
23818
23816
|
animateWidth();
|
|
23819
|
-
|
|
23820
|
-
|
|
23821
|
-
|
|
23822
|
-
|
|
23817
|
+
if (animated) {
|
|
23818
|
+
Animated.parallel([Animated.spring(animatedValues.opacity, {
|
|
23819
|
+
toValue: 1,
|
|
23820
|
+
useNativeDriver: true
|
|
23821
|
+
}), Animated.spring(animatedValues.translateY, {
|
|
23822
|
+
toValue: 0,
|
|
23823
|
+
useNativeDriver: true
|
|
23824
|
+
})]).start(callback);
|
|
23825
|
+
} else {
|
|
23826
|
+
animatedValues.opacity.setValue(1);
|
|
23827
|
+
animatedValues.translateY.setValue(0);
|
|
23828
|
+
}
|
|
23823
23829
|
},
|
|
23824
23830
|
collapse: function collapse() {
|
|
23825
|
-
|
|
23826
|
-
|
|
23827
|
-
useNativeDriver: true
|
|
23828
|
-
}), Animated.spring(animatedValues.translateY, {
|
|
23829
|
-
toValue: 0,
|
|
23830
|
-
useNativeDriver: true
|
|
23831
|
-
})]).start();
|
|
23832
|
-
animateWidth();
|
|
23831
|
+
var animated = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
23832
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
|
|
23833
23833
|
setDisplayState({
|
|
23834
23834
|
hideButton: false,
|
|
23835
23835
|
hideTitle: true
|
|
23836
23836
|
});
|
|
23837
|
+
animateWidth();
|
|
23838
|
+
if (animated) {
|
|
23839
|
+
Animated.parallel([Animated.spring(animatedValues.opacity, {
|
|
23840
|
+
toValue: 1,
|
|
23841
|
+
useNativeDriver: true
|
|
23842
|
+
}), Animated.spring(animatedValues.translateY, {
|
|
23843
|
+
toValue: 0,
|
|
23844
|
+
useNativeDriver: true
|
|
23845
|
+
})]).start(callback);
|
|
23846
|
+
} else {
|
|
23847
|
+
animatedValues.opacity.setValue(1);
|
|
23848
|
+
animatedValues.translateY.setValue(0);
|
|
23849
|
+
}
|
|
23837
23850
|
},
|
|
23838
23851
|
hide: function hide() {
|
|
23839
|
-
|
|
23840
|
-
|
|
23841
|
-
|
|
23842
|
-
|
|
23843
|
-
|
|
23844
|
-
|
|
23845
|
-
|
|
23852
|
+
var animated = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
23853
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
|
|
23854
|
+
if (animated) {
|
|
23855
|
+
Animated.stagger(20, [Animated.spring(animatedValues.opacity, {
|
|
23856
|
+
toValue: 0,
|
|
23857
|
+
useNativeDriver: true
|
|
23858
|
+
}), Animated.spring(animatedValues.translateY, {
|
|
23859
|
+
toValue: 1,
|
|
23860
|
+
useNativeDriver: true
|
|
23861
|
+
})]).start(function (arg) {
|
|
23862
|
+
animateWidth();
|
|
23863
|
+
setDisplayState(function (previousState) {
|
|
23864
|
+
return _objectSpread2(_objectSpread2({}, previousState), {}, {
|
|
23865
|
+
hideButton: true
|
|
23866
|
+
});
|
|
23867
|
+
});
|
|
23868
|
+
if (callback) {
|
|
23869
|
+
callback(arg);
|
|
23870
|
+
}
|
|
23871
|
+
});
|
|
23872
|
+
} else {
|
|
23873
|
+
animatedValues.opacity.setValue(0);
|
|
23874
|
+
animatedValues.translateY.setValue(1);
|
|
23846
23875
|
animateWidth();
|
|
23847
23876
|
setDisplayState(function (previousState) {
|
|
23848
23877
|
return _objectSpread2(_objectSpread2({}, previousState), {}, {
|
|
23849
23878
|
hideButton: true
|
|
23850
23879
|
});
|
|
23851
23880
|
});
|
|
23852
|
-
}
|
|
23881
|
+
}
|
|
23853
23882
|
}
|
|
23854
23883
|
};
|
|
23855
23884
|
}, []);
|
|
@@ -23879,7 +23908,7 @@ var FAB$1 = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
|
23879
23908
|
})
|
|
23880
23909
|
}
|
|
23881
23910
|
}, isIconOnly ? /*#__PURE__*/React__default.createElement(IconOnlyContent, {
|
|
23882
|
-
animated:
|
|
23911
|
+
animated: iconAnimated,
|
|
23883
23912
|
active: active,
|
|
23884
23913
|
icon: active ? 'add' : icon
|
|
23885
23914
|
}) : /*#__PURE__*/React__default.createElement(IconWithTextContent, {
|
|
@@ -23978,15 +24007,18 @@ var ActionGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
23978
24007
|
React__default.useEffect(function () {
|
|
23979
24008
|
Animated.spring(animatedValue.current, {
|
|
23980
24009
|
toValue: active ? 1 : 0,
|
|
23981
|
-
delay: 100,
|
|
23982
24010
|
useNativeDriver: Platform.OS !== 'web'
|
|
23983
24011
|
}).start();
|
|
23984
24012
|
if (active) {
|
|
23985
24013
|
var _fabRef$current4;
|
|
23986
|
-
(_fabRef$current4 = fabRef.current) === null || _fabRef$current4 === void 0 || _fabRef$current4.collapse()
|
|
24014
|
+
(_fabRef$current4 = fabRef.current) === null || _fabRef$current4 === void 0 || _fabRef$current4.collapse(true, function () {
|
|
24015
|
+
var _fabRef$current5;
|
|
24016
|
+
(_fabRef$current5 = fabRef.current) === null || _fabRef$current5 === void 0 || _fabRef$current5.hide(false);
|
|
24017
|
+
});
|
|
23987
24018
|
} else {
|
|
23988
|
-
var _fabRef$
|
|
23989
|
-
(_fabRef$
|
|
24019
|
+
var _fabRef$current6, _fabRef$current7;
|
|
24020
|
+
(_fabRef$current6 = fabRef.current) === null || _fabRef$current6 === void 0 || _fabRef$current6.collapse(false);
|
|
24021
|
+
(_fabRef$current7 = fabRef.current) === null || _fabRef$current7 === void 0 || _fabRef$current7.show();
|
|
23990
24022
|
}
|
|
23991
24023
|
}, [active]);
|
|
23992
24024
|
var actionGroupOpacity = animatedValue.current.interpolate({
|
package/lib/index.js
CHANGED
|
@@ -23809,7 +23809,7 @@ var FAB$1 = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
23809
23809
|
var onPress = _ref3.onPress,
|
|
23810
23810
|
title = _ref3.title,
|
|
23811
23811
|
icon = _ref3.icon,
|
|
23812
|
-
|
|
23812
|
+
iconAnimated = _ref3.animated,
|
|
23813
23813
|
testID = _ref3.testID,
|
|
23814
23814
|
active = _ref3.active,
|
|
23815
23815
|
style = _ref3.style;
|
|
@@ -23836,49 +23836,78 @@ var FAB$1 = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
23836
23836
|
React__namespace.default.useImperativeHandle(ref, function () {
|
|
23837
23837
|
return {
|
|
23838
23838
|
show: function show() {
|
|
23839
|
-
|
|
23840
|
-
|
|
23841
|
-
useNativeDriver: true
|
|
23842
|
-
}).start();
|
|
23839
|
+
var animated = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
23840
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
|
|
23843
23841
|
setDisplayState({
|
|
23844
23842
|
hideButton: false,
|
|
23845
23843
|
hideTitle: false
|
|
23846
23844
|
});
|
|
23847
23845
|
animateWidth();
|
|
23848
|
-
|
|
23849
|
-
|
|
23850
|
-
|
|
23851
|
-
|
|
23846
|
+
if (animated) {
|
|
23847
|
+
reactNative.Animated.parallel([reactNative.Animated.spring(animatedValues.opacity, {
|
|
23848
|
+
toValue: 1,
|
|
23849
|
+
useNativeDriver: true
|
|
23850
|
+
}), reactNative.Animated.spring(animatedValues.translateY, {
|
|
23851
|
+
toValue: 0,
|
|
23852
|
+
useNativeDriver: true
|
|
23853
|
+
})]).start(callback);
|
|
23854
|
+
} else {
|
|
23855
|
+
animatedValues.opacity.setValue(1);
|
|
23856
|
+
animatedValues.translateY.setValue(0);
|
|
23857
|
+
}
|
|
23852
23858
|
},
|
|
23853
23859
|
collapse: function collapse() {
|
|
23854
|
-
|
|
23855
|
-
|
|
23856
|
-
useNativeDriver: true
|
|
23857
|
-
}), reactNative.Animated.spring(animatedValues.translateY, {
|
|
23858
|
-
toValue: 0,
|
|
23859
|
-
useNativeDriver: true
|
|
23860
|
-
})]).start();
|
|
23861
|
-
animateWidth();
|
|
23860
|
+
var animated = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
23861
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
|
|
23862
23862
|
setDisplayState({
|
|
23863
23863
|
hideButton: false,
|
|
23864
23864
|
hideTitle: true
|
|
23865
23865
|
});
|
|
23866
|
+
animateWidth();
|
|
23867
|
+
if (animated) {
|
|
23868
|
+
reactNative.Animated.parallel([reactNative.Animated.spring(animatedValues.opacity, {
|
|
23869
|
+
toValue: 1,
|
|
23870
|
+
useNativeDriver: true
|
|
23871
|
+
}), reactNative.Animated.spring(animatedValues.translateY, {
|
|
23872
|
+
toValue: 0,
|
|
23873
|
+
useNativeDriver: true
|
|
23874
|
+
})]).start(callback);
|
|
23875
|
+
} else {
|
|
23876
|
+
animatedValues.opacity.setValue(1);
|
|
23877
|
+
animatedValues.translateY.setValue(0);
|
|
23878
|
+
}
|
|
23866
23879
|
},
|
|
23867
23880
|
hide: function hide() {
|
|
23868
|
-
|
|
23869
|
-
|
|
23870
|
-
|
|
23871
|
-
|
|
23872
|
-
|
|
23873
|
-
|
|
23874
|
-
|
|
23881
|
+
var animated = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
23882
|
+
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
|
|
23883
|
+
if (animated) {
|
|
23884
|
+
reactNative.Animated.stagger(20, [reactNative.Animated.spring(animatedValues.opacity, {
|
|
23885
|
+
toValue: 0,
|
|
23886
|
+
useNativeDriver: true
|
|
23887
|
+
}), reactNative.Animated.spring(animatedValues.translateY, {
|
|
23888
|
+
toValue: 1,
|
|
23889
|
+
useNativeDriver: true
|
|
23890
|
+
})]).start(function (arg) {
|
|
23891
|
+
animateWidth();
|
|
23892
|
+
setDisplayState(function (previousState) {
|
|
23893
|
+
return _objectSpread2(_objectSpread2({}, previousState), {}, {
|
|
23894
|
+
hideButton: true
|
|
23895
|
+
});
|
|
23896
|
+
});
|
|
23897
|
+
if (callback) {
|
|
23898
|
+
callback(arg);
|
|
23899
|
+
}
|
|
23900
|
+
});
|
|
23901
|
+
} else {
|
|
23902
|
+
animatedValues.opacity.setValue(0);
|
|
23903
|
+
animatedValues.translateY.setValue(1);
|
|
23875
23904
|
animateWidth();
|
|
23876
23905
|
setDisplayState(function (previousState) {
|
|
23877
23906
|
return _objectSpread2(_objectSpread2({}, previousState), {}, {
|
|
23878
23907
|
hideButton: true
|
|
23879
23908
|
});
|
|
23880
23909
|
});
|
|
23881
|
-
}
|
|
23910
|
+
}
|
|
23882
23911
|
}
|
|
23883
23912
|
};
|
|
23884
23913
|
}, []);
|
|
@@ -23908,7 +23937,7 @@ var FAB$1 = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
23908
23937
|
})
|
|
23909
23938
|
}
|
|
23910
23939
|
}, isIconOnly ? /*#__PURE__*/React__namespace.default.createElement(IconOnlyContent, {
|
|
23911
|
-
animated:
|
|
23940
|
+
animated: iconAnimated,
|
|
23912
23941
|
active: active,
|
|
23913
23942
|
icon: active ? 'add' : icon
|
|
23914
23943
|
}) : /*#__PURE__*/React__namespace.default.createElement(IconWithTextContent, {
|
|
@@ -24007,15 +24036,18 @@ var ActionGroup = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
24007
24036
|
React__namespace.default.useEffect(function () {
|
|
24008
24037
|
reactNative.Animated.spring(animatedValue.current, {
|
|
24009
24038
|
toValue: active ? 1 : 0,
|
|
24010
|
-
delay: 100,
|
|
24011
24039
|
useNativeDriver: reactNative.Platform.OS !== 'web'
|
|
24012
24040
|
}).start();
|
|
24013
24041
|
if (active) {
|
|
24014
24042
|
var _fabRef$current4;
|
|
24015
|
-
(_fabRef$current4 = fabRef.current) === null || _fabRef$current4 === void 0 || _fabRef$current4.collapse()
|
|
24043
|
+
(_fabRef$current4 = fabRef.current) === null || _fabRef$current4 === void 0 || _fabRef$current4.collapse(true, function () {
|
|
24044
|
+
var _fabRef$current5;
|
|
24045
|
+
(_fabRef$current5 = fabRef.current) === null || _fabRef$current5 === void 0 || _fabRef$current5.hide(false);
|
|
24046
|
+
});
|
|
24016
24047
|
} else {
|
|
24017
|
-
var _fabRef$
|
|
24018
|
-
(_fabRef$
|
|
24048
|
+
var _fabRef$current6, _fabRef$current7;
|
|
24049
|
+
(_fabRef$current6 = fabRef.current) === null || _fabRef$current6 === void 0 || _fabRef$current6.collapse(false);
|
|
24050
|
+
(_fabRef$current7 = fabRef.current) === null || _fabRef$current7 === void 0 || _fabRef$current7.show();
|
|
24019
24051
|
}
|
|
24020
24052
|
}, [active]);
|
|
24021
24053
|
var actionGroupOpacity = animatedValue.current.interpolate({
|
package/package.json
CHANGED
|
@@ -113,13 +113,15 @@ const ActionGroup = forwardRef<ActionGroupHandles, ActionGroupProps>(
|
|
|
113
113
|
React.useEffect(() => {
|
|
114
114
|
Animated.spring(animatedValue.current, {
|
|
115
115
|
toValue: active ? 1 : 0,
|
|
116
|
-
delay: 100,
|
|
117
116
|
useNativeDriver: Platform.OS !== 'web',
|
|
118
117
|
}).start();
|
|
119
118
|
|
|
120
119
|
if (active) {
|
|
121
|
-
fabRef.current?.collapse()
|
|
120
|
+
fabRef.current?.collapse(true, () => {
|
|
121
|
+
fabRef.current?.hide(false);
|
|
122
|
+
});
|
|
122
123
|
} else {
|
|
124
|
+
fabRef.current?.collapse(false);
|
|
123
125
|
fabRef.current?.show();
|
|
124
126
|
}
|
|
125
127
|
}, [active]);
|
|
@@ -16,11 +16,12 @@ import {
|
|
|
16
16
|
StyledFABText,
|
|
17
17
|
StyledIconContainer,
|
|
18
18
|
} from './StyledFAB';
|
|
19
|
+
import { noop } from '../../utils/functions';
|
|
19
20
|
|
|
20
21
|
export type FABHandles = {
|
|
21
|
-
show: () => void;
|
|
22
|
-
collapse: () => void;
|
|
23
|
-
hide: () => void;
|
|
22
|
+
show: (animated?: boolean, callback?: Animated.EndCallback) => void;
|
|
23
|
+
collapse: (animated?: boolean, callback?: Animated.EndCallback) => void;
|
|
24
|
+
hide: (animated?: boolean, callback?: Animated.EndCallback) => void;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
if (Platform.OS === 'android') {
|
|
@@ -120,7 +121,10 @@ const animateWidth = () => {
|
|
|
120
121
|
};
|
|
121
122
|
|
|
122
123
|
const FAB = forwardRef<FABHandles, FABProps>(
|
|
123
|
-
(
|
|
124
|
+
(
|
|
125
|
+
{ onPress, title, icon, animated: iconAnimated, testID, active, style },
|
|
126
|
+
ref
|
|
127
|
+
) => {
|
|
124
128
|
const theme = useTheme();
|
|
125
129
|
const [displayState, setDisplayState] = React.useState({
|
|
126
130
|
hideTitle: false,
|
|
@@ -141,12 +145,7 @@ const FAB = forwardRef<FABHandles, FABProps>(
|
|
|
141
145
|
React.useImperativeHandle(
|
|
142
146
|
ref,
|
|
143
147
|
() => ({
|
|
144
|
-
show: () => {
|
|
145
|
-
Animated.spring(animatedValues.translateY, {
|
|
146
|
-
toValue: 0,
|
|
147
|
-
useNativeDriver: true,
|
|
148
|
-
}).start();
|
|
149
|
-
|
|
148
|
+
show: (animated = true, callback: Animated.EndCallback = noop) => {
|
|
150
149
|
setDisplayState({
|
|
151
150
|
hideButton: false,
|
|
152
151
|
hideTitle: false,
|
|
@@ -154,47 +153,76 @@ const FAB = forwardRef<FABHandles, FABProps>(
|
|
|
154
153
|
|
|
155
154
|
animateWidth();
|
|
156
155
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
156
|
+
if (animated) {
|
|
157
|
+
Animated.parallel([
|
|
158
|
+
Animated.spring(animatedValues.opacity, {
|
|
159
|
+
toValue: 1,
|
|
160
|
+
useNativeDriver: true,
|
|
161
|
+
}),
|
|
162
|
+
Animated.spring(animatedValues.translateY, {
|
|
163
|
+
toValue: 0,
|
|
164
|
+
useNativeDriver: true,
|
|
165
|
+
}),
|
|
166
|
+
]).start(callback);
|
|
167
|
+
} else {
|
|
168
|
+
animatedValues.opacity.setValue(1);
|
|
169
|
+
animatedValues.translateY.setValue(0);
|
|
170
|
+
}
|
|
161
171
|
},
|
|
162
|
-
collapse: () => {
|
|
163
|
-
Animated.parallel([
|
|
164
|
-
Animated.spring(animatedValues.opacity, {
|
|
165
|
-
toValue: 1,
|
|
166
|
-
useNativeDriver: true,
|
|
167
|
-
}),
|
|
168
|
-
Animated.spring(animatedValues.translateY, {
|
|
169
|
-
toValue: 0,
|
|
170
|
-
useNativeDriver: true,
|
|
171
|
-
}),
|
|
172
|
-
]).start();
|
|
173
|
-
|
|
174
|
-
animateWidth();
|
|
175
|
-
|
|
172
|
+
collapse: (animated = true, callback: Animated.EndCallback = noop) => {
|
|
176
173
|
setDisplayState({
|
|
177
174
|
hideButton: false,
|
|
178
175
|
hideTitle: true,
|
|
179
176
|
});
|
|
177
|
+
|
|
178
|
+
animateWidth();
|
|
179
|
+
|
|
180
|
+
if (animated) {
|
|
181
|
+
Animated.parallel([
|
|
182
|
+
Animated.spring(animatedValues.opacity, {
|
|
183
|
+
toValue: 1,
|
|
184
|
+
useNativeDriver: true,
|
|
185
|
+
}),
|
|
186
|
+
Animated.spring(animatedValues.translateY, {
|
|
187
|
+
toValue: 0,
|
|
188
|
+
useNativeDriver: true,
|
|
189
|
+
}),
|
|
190
|
+
]).start(callback);
|
|
191
|
+
} else {
|
|
192
|
+
animatedValues.opacity.setValue(1);
|
|
193
|
+
animatedValues.translateY.setValue(0);
|
|
194
|
+
}
|
|
180
195
|
},
|
|
181
|
-
hide: () => {
|
|
182
|
-
|
|
183
|
-
Animated.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
196
|
+
hide: (animated = true, callback: Animated.EndCallback = noop) => {
|
|
197
|
+
if (animated) {
|
|
198
|
+
Animated.stagger(20, [
|
|
199
|
+
Animated.spring(animatedValues.opacity, {
|
|
200
|
+
toValue: 0,
|
|
201
|
+
useNativeDriver: true,
|
|
202
|
+
}),
|
|
203
|
+
Animated.spring(animatedValues.translateY, {
|
|
204
|
+
toValue: 1,
|
|
205
|
+
useNativeDriver: true,
|
|
206
|
+
}),
|
|
207
|
+
]).start((arg) => {
|
|
208
|
+
animateWidth();
|
|
209
|
+
setDisplayState((previousState) => ({
|
|
210
|
+
...previousState,
|
|
211
|
+
hideButton: true,
|
|
212
|
+
}));
|
|
213
|
+
if (callback) {
|
|
214
|
+
callback(arg);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
} else {
|
|
218
|
+
animatedValues.opacity.setValue(0);
|
|
219
|
+
animatedValues.translateY.setValue(1);
|
|
192
220
|
animateWidth();
|
|
193
221
|
setDisplayState((previousState) => ({
|
|
194
222
|
...previousState,
|
|
195
223
|
hideButton: true,
|
|
196
224
|
}));
|
|
197
|
-
}
|
|
225
|
+
}
|
|
198
226
|
},
|
|
199
227
|
}),
|
|
200
228
|
[]
|
|
@@ -243,7 +271,7 @@ const FAB = forwardRef<FABHandles, FABProps>(
|
|
|
243
271
|
>
|
|
244
272
|
{isIconOnly ? (
|
|
245
273
|
<IconOnlyContent
|
|
246
|
-
animated={
|
|
274
|
+
animated={iconAnimated}
|
|
247
275
|
active={active}
|
|
248
276
|
icon={active ? 'add' : icon}
|
|
249
277
|
/>
|
package/testUtils/setup.tsx
CHANGED
|
@@ -9,10 +9,11 @@ jest.mock('react-native-vector-icons', () => ({
|
|
|
9
9
|
|
|
10
10
|
jest.mock('react-native', () => {
|
|
11
11
|
const RN = jest.requireActual('react-native');
|
|
12
|
-
|
|
13
12
|
const mockedAnimatedFunctions = {
|
|
14
13
|
setImmediate: () => jest.fn(),
|
|
15
|
-
start: () =>
|
|
14
|
+
start: jest.fn((callback?: (result: { finished: boolean }) => void) => {
|
|
15
|
+
callback?.({ finished: true });
|
|
16
|
+
}),
|
|
16
17
|
stop: () => jest.fn(),
|
|
17
18
|
_isUsingNativeDriver: () => jest.fn(),
|
|
18
19
|
_startNativeLoop: () => jest.fn(),
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { Animated } from 'react-native';
|
|
3
4
|
import type { IconName } from '../Icon';
|
|
4
5
|
export type FABHandles = {
|
|
5
|
-
show: () => void;
|
|
6
|
-
collapse: () => void;
|
|
7
|
-
hide: () => void;
|
|
6
|
+
show: (animated?: boolean, callback?: Animated.EndCallback) => void;
|
|
7
|
+
collapse: (animated?: boolean, callback?: Animated.EndCallback) => void;
|
|
8
|
+
hide: (animated?: boolean, callback?: Animated.EndCallback) => void;
|
|
8
9
|
};
|
|
9
10
|
export interface FABProps {
|
|
10
11
|
/**
|