@fluentui-react-native/tester 0.79.5 → 0.80.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.json +70 -1
- package/CHANGELOG.md +30 -2
- package/lib/TestComponents/Avatar/BasicAvatar.d.ts.map +1 -1
- package/lib/TestComponents/Avatar/BasicAvatar.js +1 -2
- package/lib/TestComponents/Avatar/BasicAvatar.js.map +1 -1
- package/lib/TestComponents/Badge/BadgeTest.d.ts.map +1 -1
- package/lib/TestComponents/Badge/BadgeTest.js +26 -5
- package/lib/TestComponents/Badge/BadgeTest.js.map +1 -1
- package/lib/TestComponents/Notification/NotificationTest.d.ts.map +1 -1
- package/lib/TestComponents/Notification/NotificationTest.js +168 -67
- package/lib/TestComponents/Notification/NotificationTest.js.map +1 -1
- package/lib-commonjs/TestComponents/Avatar/BasicAvatar.d.ts.map +1 -1
- package/lib-commonjs/TestComponents/Avatar/BasicAvatar.js +1 -2
- package/lib-commonjs/TestComponents/Avatar/BasicAvatar.js.map +1 -1
- package/lib-commonjs/TestComponents/Badge/BadgeTest.d.ts.map +1 -1
- package/lib-commonjs/TestComponents/Badge/BadgeTest.js +25 -4
- package/lib-commonjs/TestComponents/Badge/BadgeTest.js.map +1 -1
- package/lib-commonjs/TestComponents/Notification/NotificationTest.d.ts.map +1 -1
- package/lib-commonjs/TestComponents/Notification/NotificationTest.js +167 -66
- package/lib-commonjs/TestComponents/Notification/NotificationTest.js.map +1 -1
- package/package.json +4 -4
- package/src/TestComponents/Avatar/BasicAvatar.tsx +1 -10
- package/src/TestComponents/Badge/BadgeTest.tsx +39 -7
- package/src/TestComponents/Notification/NotificationTest.tsx +232 -123
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Notification } from '@fluentui-react-native/notification';
|
|
2
|
+
import { Notification, NotificationVariant, NotificationVariants } from '@fluentui-react-native/notification';
|
|
3
3
|
import { Test, TestSection, PlatformStatus } from '../Test';
|
|
4
|
+
import { Animated, StyleSheet, Switch, TextInput, View } from 'react-native';
|
|
5
|
+
import { Text } from '@fluentui-react-native/experimental-text';
|
|
6
|
+
import { ButtonV1 as Button } from '@fluentui-react-native/button';
|
|
7
|
+
import { StyledPicker } from '../Common/StyledPicker';
|
|
8
|
+
import { commonTestStyles as commonStyles } from '../Common/styles';
|
|
4
9
|
import { SvgIconProps } from '@fluentui-react-native/icon';
|
|
5
10
|
import PlayButton from './assets/play_button.svg';
|
|
6
11
|
|
|
@@ -9,156 +14,260 @@ const svgProps: SvgIconProps = {
|
|
|
9
14
|
};
|
|
10
15
|
const iconProps = { svgSource: svgProps };
|
|
11
16
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
onPress={() => {
|
|
18
|
-
console.log('Notification tapped');
|
|
19
|
-
}}
|
|
20
|
-
onActionPress={() => {
|
|
21
|
-
console.log('Undo tapped');
|
|
22
|
-
}}
|
|
23
|
-
>
|
|
24
|
-
Mail Archived
|
|
25
|
-
</Notification>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
17
|
+
const SHOW_HEIGHT = -50;
|
|
18
|
+
const BAR_SHOW_DURATION = 300;
|
|
19
|
+
const HIDE_DURATION = 250;
|
|
20
|
+
const AUTO_HIDE_DURATION = 3000;
|
|
21
|
+
const USE_NATIVE_DRIVER_IOS = true;
|
|
28
22
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
);
|
|
42
|
-
};
|
|
23
|
+
const styles = StyleSheet.create({
|
|
24
|
+
button: {
|
|
25
|
+
alignSelf: 'center',
|
|
26
|
+
marginBottom: 50,
|
|
27
|
+
},
|
|
28
|
+
notification: {
|
|
29
|
+
marginTop: 10,
|
|
30
|
+
},
|
|
31
|
+
textInput: {
|
|
32
|
+
borderWidth: 1,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
43
35
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
onPress={() => {
|
|
50
|
-
console.log('Notification tapped');
|
|
51
|
-
}}
|
|
52
|
-
onActionPress={() => {
|
|
53
|
-
console.log('Sign in tapped');
|
|
54
|
-
}}
|
|
55
|
-
>
|
|
56
|
-
Some items require you to sign in to view them
|
|
57
|
-
</Notification>
|
|
58
|
-
);
|
|
59
|
-
};
|
|
36
|
+
const CustomToast: React.FunctionComponent = () => {
|
|
37
|
+
const [variant, setVariant] = React.useState<NotificationVariant>('primary');
|
|
38
|
+
const [title, setTitle] = React.useState("Kat's iPhoneX");
|
|
39
|
+
const [message, setMessage] = React.useState('Listen to Emails • 7 mins');
|
|
40
|
+
const [action, setAction] = React.useState('Listen');
|
|
60
41
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
<Notification
|
|
64
|
-
variant={'danger'}
|
|
65
|
-
action="Retry"
|
|
66
|
-
onPress={() => {
|
|
67
|
-
console.log('Notification tapped');
|
|
68
|
-
}}
|
|
69
|
-
onActionPress={() => {
|
|
70
|
-
console.log('Retry tapped');
|
|
71
|
-
}}
|
|
72
|
-
>
|
|
73
|
-
There was a problem, and your recent changes may not have saved
|
|
74
|
-
</Notification>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
42
|
+
const [showIcon, setShowIcon] = React.useState(true);
|
|
43
|
+
const [showTitle, setShowTitle] = React.useState(true);
|
|
77
44
|
|
|
78
|
-
const WarningTest: React.FunctionComponent = () => {
|
|
79
45
|
return (
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
46
|
+
<View>
|
|
47
|
+
<StyledPicker
|
|
48
|
+
prompt="Variant"
|
|
49
|
+
selected={variant}
|
|
50
|
+
onChange={setVariant}
|
|
51
|
+
collection={NotificationVariants.filter((variant) => !variant.endsWith('Bar'))}
|
|
52
|
+
/>
|
|
53
|
+
<TextInput value={title} onChangeText={setTitle} style={styles.textInput} />
|
|
54
|
+
<TextInput value={message} onChangeText={setMessage} style={styles.textInput} />
|
|
55
|
+
<TextInput value={action} onChangeText={setAction} style={styles.textInput} />
|
|
56
|
+
<View style={commonStyles.switch}>
|
|
57
|
+
<Text>Show icon </Text>
|
|
58
|
+
<Switch value={showIcon} onValueChange={setShowIcon} />
|
|
59
|
+
</View>
|
|
60
|
+
<View style={commonStyles.switch}>
|
|
61
|
+
<Text>Show title </Text>
|
|
62
|
+
<Switch value={showTitle} onValueChange={setShowTitle} />
|
|
63
|
+
</View>
|
|
64
|
+
<View style={styles.notification}>
|
|
65
|
+
<Notification
|
|
66
|
+
variant={variant}
|
|
67
|
+
icon={showIcon ? iconProps : undefined}
|
|
68
|
+
title={showTitle ? title : undefined}
|
|
69
|
+
action={action}
|
|
70
|
+
onPress={() => {
|
|
71
|
+
console.log('Notification tapped');
|
|
72
|
+
}}
|
|
73
|
+
onActionPress={() => {
|
|
74
|
+
console.log('Notification action tapped');
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
{message}
|
|
78
|
+
</Notification>
|
|
79
|
+
</View>
|
|
80
|
+
</View>
|
|
88
81
|
);
|
|
89
82
|
};
|
|
90
83
|
|
|
91
|
-
const
|
|
84
|
+
const CustomBar: React.FunctionComponent = () => {
|
|
85
|
+
const [variant, setVariant] = React.useState<NotificationVariant>('primaryBar');
|
|
86
|
+
const [message, setMessage] = React.useState('Updating...');
|
|
87
|
+
|
|
92
88
|
return (
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
89
|
+
<View>
|
|
90
|
+
<StyledPicker
|
|
91
|
+
prompt="Variant"
|
|
92
|
+
selected={variant}
|
|
93
|
+
onChange={setVariant}
|
|
94
|
+
collection={NotificationVariants.filter((variant) => variant.endsWith('Bar'))}
|
|
95
|
+
/>
|
|
96
|
+
<TextInput value={message} onChangeText={setMessage} style={styles.textInput} />
|
|
97
|
+
<View style={styles.notification}>
|
|
98
|
+
<Notification
|
|
99
|
+
variant={variant}
|
|
100
|
+
onPress={() => {
|
|
101
|
+
console.log('Notification tapped');
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
{message}
|
|
105
|
+
</Notification>
|
|
106
|
+
</View>
|
|
107
|
+
</View>
|
|
101
108
|
);
|
|
102
109
|
};
|
|
103
110
|
|
|
104
|
-
const
|
|
111
|
+
const PrimaryWithAutoHide: React.FunctionComponent = () => {
|
|
112
|
+
const [visible, setVisible] = React.useState(false);
|
|
113
|
+
const onButtonPress = () => setVisible(!visible);
|
|
114
|
+
|
|
115
|
+
const [hidden, setHidden] = React.useState<boolean>(!visible);
|
|
116
|
+
const height = React.useRef(new Animated.Value(0)).current;
|
|
117
|
+
|
|
118
|
+
const show = () => {
|
|
119
|
+
setHidden(false);
|
|
120
|
+
Animated.sequence([
|
|
121
|
+
Animated.spring(height, {
|
|
122
|
+
toValue: SHOW_HEIGHT,
|
|
123
|
+
bounciness: 16,
|
|
124
|
+
speed: 20,
|
|
125
|
+
useNativeDriver: USE_NATIVE_DRIVER_IOS,
|
|
126
|
+
}),
|
|
127
|
+
Animated.delay(AUTO_HIDE_DURATION),
|
|
128
|
+
Animated.timing(height, {
|
|
129
|
+
toValue: 0,
|
|
130
|
+
duration: HIDE_DURATION,
|
|
131
|
+
useNativeDriver: USE_NATIVE_DRIVER_IOS,
|
|
132
|
+
}),
|
|
133
|
+
]).start(() => {
|
|
134
|
+
setHidden(true);
|
|
135
|
+
setVisible(false);
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const hide = () => {
|
|
140
|
+
Animated.timing(height, {
|
|
141
|
+
toValue: 0,
|
|
142
|
+
duration: HIDE_DURATION,
|
|
143
|
+
useNativeDriver: USE_NATIVE_DRIVER_IOS,
|
|
144
|
+
}).start(() => {
|
|
145
|
+
setHidden(true);
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
React.useLayoutEffect(() => {
|
|
150
|
+
if (visible) {
|
|
151
|
+
show();
|
|
152
|
+
} else {
|
|
153
|
+
hide();
|
|
154
|
+
}
|
|
155
|
+
}, [visible, height]);
|
|
156
|
+
|
|
157
|
+
const animatedViewProps = {
|
|
158
|
+
transform: [{ translateY: height }],
|
|
159
|
+
};
|
|
160
|
+
|
|
105
161
|
return (
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
162
|
+
<View>
|
|
163
|
+
<Button appearance="subtle" onClick={onButtonPress} style={styles.button}>
|
|
164
|
+
{visible ? 'Hide' : 'Show'}
|
|
165
|
+
</Button>
|
|
166
|
+
{!hidden && (
|
|
167
|
+
<Animated.View style={[animatedViewProps]}>
|
|
168
|
+
<Notification
|
|
169
|
+
variant={'primary'}
|
|
170
|
+
action="Undo"
|
|
171
|
+
onPress={() => {
|
|
172
|
+
console.log('Notification tapped');
|
|
173
|
+
}}
|
|
174
|
+
onActionPress={() => {
|
|
175
|
+
console.log('Undo tapped');
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
Mail Archived
|
|
179
|
+
</Notification>
|
|
180
|
+
</Animated.View>
|
|
181
|
+
)}
|
|
182
|
+
</View>
|
|
114
183
|
);
|
|
115
184
|
};
|
|
185
|
+
const PrimaryBarWithAutoHide: React.FunctionComponent = () => {
|
|
186
|
+
const [visible, setVisible] = React.useState(false);
|
|
187
|
+
const onButtonPress = () => setVisible(!visible);
|
|
188
|
+
|
|
189
|
+
const [hidden, setHidden] = React.useState<boolean>(!visible);
|
|
190
|
+
const height = React.useRef(new Animated.Value(0)).current;
|
|
191
|
+
|
|
192
|
+
const show = () => {
|
|
193
|
+
setHidden(false);
|
|
194
|
+
Animated.sequence([
|
|
195
|
+
Animated.timing(height, {
|
|
196
|
+
toValue: SHOW_HEIGHT,
|
|
197
|
+
duration: BAR_SHOW_DURATION,
|
|
198
|
+
useNativeDriver: USE_NATIVE_DRIVER_IOS,
|
|
199
|
+
}),
|
|
200
|
+
Animated.delay(AUTO_HIDE_DURATION),
|
|
201
|
+
Animated.timing(height, {
|
|
202
|
+
toValue: 0,
|
|
203
|
+
duration: HIDE_DURATION,
|
|
204
|
+
useNativeDriver: USE_NATIVE_DRIVER_IOS,
|
|
205
|
+
}),
|
|
206
|
+
]).start(() => {
|
|
207
|
+
setHidden(true);
|
|
208
|
+
setVisible(false);
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const hide = () => {
|
|
213
|
+
Animated.timing(height, {
|
|
214
|
+
toValue: 0,
|
|
215
|
+
duration: HIDE_DURATION,
|
|
216
|
+
useNativeDriver: USE_NATIVE_DRIVER_IOS,
|
|
217
|
+
}).start(() => {
|
|
218
|
+
setHidden(true);
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
React.useLayoutEffect(() => {
|
|
223
|
+
if (visible) {
|
|
224
|
+
show();
|
|
225
|
+
} else {
|
|
226
|
+
hide();
|
|
227
|
+
}
|
|
228
|
+
}, [visible, height]);
|
|
229
|
+
|
|
230
|
+
const animatedViewProps = {
|
|
231
|
+
transform: [{ translateY: height }],
|
|
232
|
+
};
|
|
116
233
|
|
|
117
|
-
const NeutralBarTest: React.FunctionComponent = () => {
|
|
118
234
|
return (
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
235
|
+
<View>
|
|
236
|
+
<Button appearance="subtle" onClick={onButtonPress} style={styles.button}>
|
|
237
|
+
{visible ? 'Hide' : 'Show'}
|
|
238
|
+
</Button>
|
|
239
|
+
{!hidden && (
|
|
240
|
+
<Animated.View style={[animatedViewProps]}>
|
|
241
|
+
<Notification
|
|
242
|
+
variant={'primaryBar'}
|
|
243
|
+
onPress={() => {
|
|
244
|
+
console.log('Notification tapped');
|
|
245
|
+
}}
|
|
246
|
+
>
|
|
247
|
+
Mail Sent
|
|
248
|
+
</Notification>
|
|
249
|
+
</Animated.View>
|
|
250
|
+
)}
|
|
251
|
+
</View>
|
|
127
252
|
);
|
|
128
253
|
};
|
|
129
254
|
|
|
130
255
|
const notificationSections: TestSection[] = [
|
|
131
256
|
{
|
|
132
|
-
name: '
|
|
133
|
-
component:
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: 'Primary with Title and Icon',
|
|
137
|
-
component: PrimaryTestWithTitleAndIcon,
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: 'Neutral',
|
|
141
|
-
component: NeutralTest,
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: 'Danger',
|
|
145
|
-
component: DangerTest,
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: 'Warning',
|
|
149
|
-
component: WarningTest,
|
|
257
|
+
name: 'Custom Toast',
|
|
258
|
+
component: CustomToast,
|
|
150
259
|
},
|
|
151
260
|
{
|
|
152
|
-
name: '
|
|
153
|
-
component:
|
|
261
|
+
name: 'Custom Bar',
|
|
262
|
+
component: CustomBar,
|
|
154
263
|
},
|
|
155
264
|
{
|
|
156
|
-
name: 'Primary
|
|
157
|
-
component:
|
|
265
|
+
name: 'Primary with auto-hide',
|
|
266
|
+
component: PrimaryWithAutoHide,
|
|
158
267
|
},
|
|
159
268
|
{
|
|
160
|
-
name: '
|
|
161
|
-
component:
|
|
269
|
+
name: 'Primary Bar with auto-hide',
|
|
270
|
+
component: PrimaryBarWithAutoHide,
|
|
162
271
|
},
|
|
163
272
|
];
|
|
164
273
|
|