Skip to content

Commit 0dbe7d3

Browse files
chore: added navigation to doc
1 parent 6589443 commit 0dbe7d3

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed

README.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,145 @@ const onSubmitPress = async () => {
763763

764764
![divider](https://ik.imagekit.io/Computools/rn-material-components/divider.png?updatedAt=1705067870577)
765765
</details>
766+
<details><summary>Navigation</summary>
767+
<br />
768+
<details><summary>Nav Bar</summary>
769+
<br />
770+
771+
**Properties**
772+
773+
| name | description | type | default |
774+
| ------ | ------ | ------ | ---- |
775+
| routes | required | NavBarRoute<T, Y>[] | - |
776+
| activeRouteName | required | T | - |
777+
| onRoutePress | required | (route: T) => void | - |
778+
| damping | - | number | 20 |
779+
| fixedLabelVisibility | - | boolean | false |
780+
| scrollDirection | 'UP' or 'DOWN'. Use this propert to hide/show NavBar on scroll. | ScrollDirection | - |
781+
| containerStyle | - | ViewStyle | false |
782+
783+
```
784+
export interface NavBarRoute<T, Y> {
785+
name: T;
786+
icon: React.FC<Y>;
787+
selectedIcon: React.FC<Y>;
788+
789+
label?: string;
790+
badge?: string;
791+
showBadge?: boolean;
792+
badgeSize?: BadgeSize;
793+
iconProps?: Y;
794+
}
795+
```
796+
797+
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.
798+
799+
See the example:
800+
```
801+
export const MyComponent: React.FC = () => {
802+
const scrollDirection = useSharedValue(ScrollDirection.UP);
803+
const scrollContext = useSharedValue(0);
804+
805+
const onScroll = (e: NativeSyntheticEvent<NativeScrollEvent>) => {
806+
const currentOffsetY = e.nativeEvent.contentOffset.y;
807+
808+
if (currentOffsetY <= 0 || currentOffsetY < scrollContext.value) {
809+
scrollDirection.value = ScrollDirection.UP;
810+
} else if (currentOffsetY >= scrollContext.value) {
811+
scrollDirection.value = ScrollDirection.DOWN;
812+
}
813+
814+
scrollContext.value = currentOffsetY;
815+
};
816+
817+
return (
818+
<>
819+
<Animated.ScrollView onScroll={onScroll}>
820+
<!-- scrollview content -->
821+
</Animated.ScrollView>
822+
<NavBar
823+
scrollDirection={scrollDirection}
824+
routes={routes}
825+
activeRouteName={activeRouteName}
826+
onRoutePress={setRoute}
827+
/>
828+
</>
829+
)
830+
}
831+
832+
```
833+
834+
![nav bar](https://ik.imagekit.io/Computools/rn-material-components/nav_bar.gif?updatedAt=1735922886681)
835+
![anim nav bar](https://ik.imagekit.io/Computools/rn-material-components/anim_nav_bar.gif?updatedAt=1735922886792)
836+
837+
</details>
838+
<details><summary>Tabs</summary>
839+
<br />
840+
841+
Each Tabs accepts the required property ```tabs```, an array of the Tab interface.
842+
843+
```
844+
export interface Tab<T, Y> extends Omit<TouchableOpacityProps, 'onPress'> {
845+
routeName: T;
846+
847+
title?: string;
848+
icon?: React.FC<Y>;
849+
iconProps?: Y;
850+
titleStyle?: TextStyle;
851+
}
852+
```
853+
854+
<details><summary>Primary Tabs</summary>
855+
<br />
856+
857+
**Properties**
858+
859+
| name | description | type | default |
860+
| ------ | ------ | ------ | ---- |
861+
| tabs | required | Tab<T, Y>[] | - |
862+
| activeTab | required | T | - |
863+
| onTabPress | required | T | - |
864+
| badgeSize | - | SMALL or BIG | BIG |
865+
| animConfig | - | (routeName: T) => void | - |
866+
| tabIconProps | - | Y | - |
867+
| tabStyle | - | ViewStyle | - |
868+
| badgeStyle | - | ViewStyle | - |
869+
| indicatorStyle | - | ViewStyle | - |
870+
| indicatorContainerStyle | - | ViewStyle | - |
871+
| tabsContainerStyle | - | ViewStyle | - |
872+
| tabInnerContentStyle | - | ViewStyle | - |
873+
| tabTitleStyle | - | TextStyle | - |
874+
875+
![primary tabs](https://ik.imagekit.io/Computools/rn-material-components/primary_tabs.gif?updatedAt=1735922886826)
876+
![primary tabs with badges](https://ik.imagekit.io/Computools/rn-material-components/secondary_tabs_with_badges.png?updatedAt=1735922619925)
877+
878+
</details>
879+
<details><summary>Secondary Tabs</summary>
880+
<br />
881+
882+
**Properties**
883+
884+
| name | description | type | default |
885+
| ------ | ------ | ------ | ---- |
886+
| tabs | required | Tab<T, Y>[] | - |
887+
| activeTab | required | T | - |
888+
| onTabPress | required | T | - |
889+
| badgeSize | - | SMALL or BIG | BIG |
890+
| animConfig | - | (routeName: T) => void | - |
891+
| tabIconProps | - | Y | - |
892+
| tabStyle | - | ViewStyle | - |
893+
| badgeStyle | - | ViewStyle | - |
894+
| indicatorStyle | - | ViewStyle | - |
895+
| tabsContainerStyle | - | ViewStyle | - |
896+
| tabInnerContentStyle | - | ViewStyle | - |
897+
| tabTitleStyle | - | TextStyle | - |
898+
899+
![secondary tabs](https://ik.imagekit.io/Computools/rn-material-components/secondart_tabs.gif?updatedAt=1735922886638)
900+
![secondary tabs with badges](https://ik.imagekit.io/Computools/rn-material-components/primary_tabs_with_badges.png?updatedAt=1735922619944)
901+
902+
</details>
903+
</details>
904+
</details>
766905
<details><summary>Sheets</summary>
767906
<br />
768907
<details><summary>Bottom Sheet</summary>

0 commit comments

Comments
 (0)