Skip to content

Commit 802752d

Browse files
chore: updated readme
1 parent 6087e96 commit 802752d

File tree

2 files changed

+125
-1
lines changed

2 files changed

+125
-1
lines changed

README.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,130 @@ export const AppBodyLargeText: React.FC<PropsWithChildren> = ({children}) => {
212212
![linear activity indicator gif](https://ik.imagekit.io/Computools/rn-material-components/linear-indicator-gif.gif?updatedAt=1705066319092)
213213
</details>
214214
</details>
215+
<details><summary>App Bars</summary>
216+
<br />
217+
<details><summary>Bottom App Bar</summary>
218+
219+
**Properties**
220+
221+
| name | description | type | default |
222+
| ------ | ------ | ------ | ----|
223+
| iconButtons | required | IconButtonProps[] | - |
224+
| scrollDirection | UP or DOWN | sharedValue<ScrollDirection> | - |
225+
| FabIcon | Pass an icon to show FAB | React.FC | - |
226+
| fabLabel | - | string | - |
227+
| onFabPress | - | () => void | - |
228+
229+
To enable animation on scroll use ScrollView from Animated, create a shared value with a ScrollDirection value, scrollContext with a number value and manage them onScroll.
230+
231+
See the example:
232+
```
233+
export const MyComponent: React.FC = () => {
234+
const scrollDirection = useSharedValue(ScrollDirection.UP);
235+
const scrollContext = useSharedValue(0);
236+
237+
const onScroll = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
238+
const currentOffsetY = e.nativeEvent.contentOffset.y;
239+
240+
if (currentOffsetY <= 0 || currentOffsetY < scrollContext.value) {
241+
scrollDirection.value = ScrollDirection.UP;
242+
} else if (currentOffsetY >= scrollContext.value) {
243+
scrollDirection.value = ScrollDirection.DOWN;
244+
}
245+
246+
scrollContext.value = currentOffsetY;
247+
};
248+
249+
return (
250+
<>
251+
<Animated.ScrollView onScroll={onScroll}>
252+
<!-- scrollview content -->
253+
</Animated.ScrollView>
254+
<BottomAppBar scrollDirection={scrollDirection} />
255+
</>
256+
)
257+
}
258+
259+
```
260+
261+
[bottom app bar](https://ik.imagekit.io/Computools/rn-material-components/bottom-app-bar.gif?updatedAt=1734086950022)
262+
263+
</details>
264+
<br />
265+
<details><summary>Top App Bars</summary>
266+
<br />
267+
268+
To enable animation on scroll use ScrollView from Animated, create a shared value with ScrollStatus (0 if top is reached, 1 if target offset reached) value and manage it onScroll.
269+
270+
See the example:
271+
```
272+
export const MyComponent: React.FC = () => {
273+
const scrollStatus = useSharedValue(0);
274+
275+
const onScroll = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
276+
if (e.nativeEvent.contentOffset.y > 10) { // 10 is offset treashold when top app bar changes background color
277+
scrollStatus.value = 1;
278+
} else if (e.nativeEvent.contentOffset.y <= 10) {
279+
scrollStatus.value = 0;
280+
}
281+
};
282+
283+
return (
284+
<>
285+
<Animated.ScrollView onScroll={onScroll}>
286+
<!-- scrollview content -->
287+
</Animated.ScrollView>
288+
<TopAppBar scrollStatus={scrollStatus} />
289+
</>
290+
)
291+
}
292+
```
293+
294+
(animated top app bar)[https://ik.imagekit.io/Computools/rn-material-components/animated-top-app-bar.gif?updatedAt=1734088599114]
295+
296+
<details><summary>Center Aligned Top App Bar</summary>
297+
298+
**Properties**
299+
300+
| name | description | type | default |
301+
| ------ | ------ | ------ | ----|
302+
| title | required | string | - |
303+
| StartIcon | - | React.FC | - |
304+
| EndIcon | - | React.FC | - |
305+
| scrollStatus | 1 - scrolled down (backgoround color will changed); 0 - non-scrolled, top is reached | SharedValue<number> | - |
306+
| iconProps | - | T | - |
307+
| titleStyle | - | TextStyle | - |
308+
| defaultColor | - | ColorValue | - |
309+
| scrolledColor | - | ColorValue | - |
310+
| animationDuration | - | number | - |
311+
312+
[center aligned top app bar](https://ik.imagekit.io/Computools/rn-material-components/center_aligned_top_app_bar.png?updatedAt=1734088249862)
313+
</details>
314+
<br />
315+
<details><summary>Top App Bar</summary>
316+
317+
**Properties**
318+
319+
| name | description | type | default |
320+
| ------ | ------ | ------ | ----|
321+
| title | required | string | - |
322+
| size | SMALL, MEDIUM, LARGE | TopAppBarSize | - |
323+
| StartIcon | - | React.FC | - |
324+
| actions | - | IconButtonProps<T>[] | - |
325+
| scrollStatus | 1 - scrolled down (backgoround color will changed); 0 - non-scrolled, top is reached | SharedValue<number> | - |
326+
| iconProps | - | T | - |
327+
| titleStyle | - | TextStyle | - |
328+
| defaultColor | - | ColorValue | - |
329+
| scrolledColor | - | ColorValue | - |
330+
| animationDuration | - | number | - |
331+
332+
[small top app bar](https://ik.imagekit.io/Computools/rn-material-components/small_top_app_bar.png?updatedAt=1734088346321)
333+
[medium top app bar](https://ik.imagekit.io/Computools/rn-material-components/medium_top_app_bar.png?updatedAt=1734088346249)
334+
[large top app bar](https://ik.imagekit.io/Computools/rn-material-components/large_top_app_bar.png?updatedAt=1734088346230)
335+
336+
</details>
337+
</details>
338+
</details>
215339
<details><summary>Buttons</summary>
216340
<br />
217341
<details><summary>Common buttons</summary>

src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export {
2121
type CenterAlignedTopAppBarProps,
2222
} from './app-bars/top-app-bars/center-aligned-top-app-bar/CenterAlignedTopAppBar.component';
2323
export {TopAppBar, type TopAppBarProps, TopAppBarSize} from './app-bars/top-app-bars/top-app-bar/TopAppBar.component';
24-
export {BottomAppBar, type BottomAppBarProps, type BottomAppBarRef} from './app-bars/bottom-app-bar/BottomAppBar.component';
24+
export {BottomAppBar, type BottomAppBarProps, type BottomAppBarRef, ScrollDirection} from './app-bars/bottom-app-bar/BottomAppBar.component';
2525

2626
export {BottomSheet, type BottomSheetProps, type BottomSheetRef} from './sheets/bottom-sheet/BottomSheet.component';
2727
export {SideSheet, type SideSheetProps, type SideSheetRef, type StickySide} from './sheets/side-sheet/SideSheet.component';

0 commit comments

Comments
 (0)