Skip to content

Commit 41f83f6

Browse files
authored
Adds new accessible <Loading /> component and accompanying docs (#272)
* Add initial Loading component * Add initial LoadingScreen * Add LoadingScreens to example apps * export AutofocusContainerProps from core * Autofocus Loading * Add Loading to home screen examples * Added busy state to Loading Comp * Add initial Loading Doc * add style prop to Loading container style array * Add zIndex to ensure absolute position height * Update Loading docs * Add `touchableContainerAccessibilityProps` workaround to Loading comp * Added changesets * bump version
1 parent 5469949 commit 41f83f6

13 files changed

Lines changed: 183 additions & 2 deletions

File tree

.changeset/honest-shirts-guess.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@react-native-ama/extras': minor
3+
---
4+
5+
Added new `<Loading />` component to `extras` package

.changeset/metal-poets-whisper.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@react-native-ama/core': patch
3+
---
4+
5+
add export for `AutofocusContainerProps` type from `core` package

.changeset/sharp-mugs-poke.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@examples/shared-ui': minor
3+
'amaexample': minor
4+
'ama-expo-example': minor
5+
---
6+
7+
Added `<Loading />` component example screens

examples/bare/src/AppNavigator.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
FormScreen,
1010
Header,
1111
HomeScreen,
12+
LoadingScreen,
1213
PressableScreen,
1314
SwitchListItemScreen,
1415
TextScreen,
@@ -195,6 +196,14 @@ export const AppNavigator = () => {
195196
headerTitle: () => <Header title={'Carousel Demo'} autofocus />,
196197
}}
197198
/>
199+
<Stack.Screen
200+
name="Loading"
201+
component={LoadingScreen}
202+
options={{
203+
headerLeft: () => <BackButton />,
204+
headerTitle: () => <Header title={'Carousel Demo'} autofocus />,
205+
}}
206+
/>
198207
<Stack.Screen
199208
name="UseTimedAction"
200209
component={UseTimedActionScreen}
@@ -245,6 +254,7 @@ type StackParamList = {
245254
FlatListStatic: undefined;
246255
BottomSheet: undefined;
247256
Carousel: undefined;
257+
Loading: undefined;
248258
UseTimedAction: undefined;
249259
UseAMAContext: undefined;
250260
};

examples/expo/src/AppNavigation.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
FormScreen,
1010
Header,
1111
HomeScreen,
12+
LoadingScreen,
1213
PressableScreen,
1314
SwitchListItemScreen,
1415
TextScreen,
@@ -195,6 +196,14 @@ export const AppNavigator = () => {
195196
headerTitle: () => <Header title={'Carousel Demo'} autofocus />,
196197
}}
197198
/>
199+
<Stack.Screen
200+
name="Loading"
201+
component={LoadingScreen}
202+
options={{
203+
headerLeft: () => <BackButton />,
204+
headerTitle: () => <Header title={'Carousel Demo'} autofocus />,
205+
}}
206+
/>
198207
<Stack.Screen
199208
name="UseTimedAction"
200209
component={UseTimedActionScreen}
@@ -245,6 +254,7 @@ type StackParamList = {
245254
FlatListStatic: undefined;
246255
BottomSheet: undefined;
247256
Carousel: undefined;
257+
Loading: undefined;
248258
UseTimedAction: undefined;
249259
UseAMAContext: undefined;
250260
};

examples/shared/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export { Header } from './src/components/Header';
77
export { Spacer } from './src/components/Spacer';
88

99
// Screens
10+
export { LoadingScreen } from './src/screens/Loading.screen';
1011
export { CarouselScreen } from './src/screens/Carousel.screen';
1112
export { BottomSheetScreen } from './src/screens/BottomSheet.screen';
1213
export { ExpandablePressableScreen } from './src/screens/ExpandablePressableScreen';

examples/shared/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@examples/shared-ui",
3-
"version": "0.0.1",
3+
"version": "1.0.1",
44
"description": "Example Apps shared UI components",
55
"private": true,
66
"react-native": "index",

examples/shared/src/screens/Home.screen.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export const HomeScreen = ({ navigation }) => {
5757
<Spacer height={'normal'} />
5858

5959
<CTAPressable title="Carousel" onPress={() => navigate('Carousel')} />
60+
<Spacer height={'normal'} />
61+
<CTAPressable title="Loading" onPress={() => navigate('Loading')} />
6062

6163
{/* */}
6264
<Spacer height={'big'} />
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Loading } from '@react-native-ama/extras';
2+
import React from 'react';
3+
import { StyleSheet, View } from 'react-native';
4+
5+
import { CTAPressable } from '../components/CTAPressable';
6+
import { theme } from '../theme';
7+
8+
export const LoadingScreen = () => {
9+
const [isLoading, setIsLoading] = React.useState(false);
10+
11+
const triggerLoading = () => {
12+
setIsLoading(true);
13+
setTimeout(() => {
14+
setIsLoading(false);
15+
}, 1500);
16+
};
17+
18+
return (
19+
<View style={styles.container}>
20+
<Loading isLoading={isLoading} />
21+
<CTAPressable title="Trigger Loading" onPress={triggerLoading} />
22+
</View>
23+
);
24+
};
25+
26+
const styles = StyleSheet.create({
27+
container: {
28+
flex: 1,
29+
paddingHorizontal: theme.padding.big,
30+
paddingTop: theme.padding.big,
31+
},
32+
});

packages/core/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Components
2-
export { AutofocusContainer } from './components/AutofocusContainer';
2+
export {
3+
AutofocusContainer,
4+
type AutofocusContainerProps,
5+
} from './components/AutofocusContainer';
36
export {
47
AMAProvider,
58
useAMAContext,

0 commit comments

Comments
 (0)