Skip to content

Commit

Permalink
Merge branch 'main' into fix/back-button-ripple
Browse files Browse the repository at this point in the history
  • Loading branch information
kacperkapusciak committed Aug 1, 2023
2 parents 6e136eb + dcb4e4c commit 931bf2b
Show file tree
Hide file tree
Showing 41 changed files with 453 additions and 219 deletions.
10 changes: 9 additions & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ runs:
restore-keys: |
${{ runner.os }}-yarn-
- name: Check for changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
package-json:
- '**/package.json'
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
if: steps.yarn-cache.outputs.cache-hit != 'true' || steps.changes.outputs.package-json == 'true'
run: yarn install --immutable
shell: bash
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,3 @@ jobs:

- name: Verify built type definitions are correct
run: yarn typescript

- name: Verify paths for types
run: node scripts/check-types-path.js
21 changes: 20 additions & 1 deletion example/__typechecks__/static.check.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const RootStack = createStackNavigator({
Guest: {
screens: {
Login: () => null,
Register: () => null,
Register: (_: StaticScreenProps<{ method: 'email' | 'social' }>) =>
null,
},
},
User: {
Expand Down Expand Up @@ -104,6 +105,14 @@ navigation.navigate('Settings', undefined);
// @ts-expect-error
navigation.navigate('Settings', { nonexistent: 'test' });

/**
* Infer params from component props for inside group
*/
navigation.navigate('Register', { method: 'email' });

// @ts-expect-error
navigation.navigate('Register', { method: 'token' });

/**
* Infer params from nested navigator
*/
Expand Down Expand Up @@ -177,3 +186,13 @@ createBottomTabNavigator({
},
},
});

/**
* Requires `screens` to be defined
*/
// @ts-expect-error
createStackNavigator({});

createStackNavigator({
screens: {},
});
5 changes: 5 additions & 0 deletions example/src/Screens/TabView/AutoWidthTabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ export const AutoWidthTabBar = () => {
scrollEnabled
indicatorStyle={styles.indicator}
style={styles.tabbar}
contentContainerStyle={styles.tabbarContentContainer}
labelStyle={styles.label}
tabStyle={styles.tabStyle}
gap={20}
/>
);

Expand Down Expand Up @@ -77,6 +79,9 @@ const styles = StyleSheet.create({
tabbar: {
backgroundColor: '#3f51b5',
},
tabbarContentContainer: {
paddingHorizontal: 10,
},
indicator: {
backgroundColor: '#ffeb3b',
},
Expand Down
27 changes: 23 additions & 4 deletions example/src/Screens/TabView/CustomIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { Ionicons } from '@expo/vector-icons';
import * as React from 'react';
import { Animated, I18nManager, StyleSheet, Text, View } from 'react-native';
import {
Animated,
I18nManager,
StyleProp,
StyleSheet,
Text,
View,
ViewStyle,
} from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import {
NavigationState,
Expand Down Expand Up @@ -49,9 +57,12 @@ export const CustomIndicator = () => {
props: SceneRendererProps & {
navigationState: State;
getTabWidth: (i: number) => number;
gap?: number;
width?: number | string;
style?: StyleProp<ViewStyle>;
}
) => {
const { position, navigationState, getTabWidth } = props;
const { position, getTabWidth, gap, width, style } = props;
const inputRange = [
0, 0.48, 0.49, 0.51, 0.52, 1, 1.48, 1.49, 1.51, 1.52, 2,
];
Expand All @@ -73,16 +84,19 @@ export const CustomIndicator = () => {
inputRange: inputRange,
outputRange: inputRange.map((x) => {
const i = Math.round(x);
return i * getTabWidth(i) * (I18nManager.isRTL ? -1 : 1);
return (
(i * getTabWidth(i) + i * (gap ?? 0)) * (I18nManager.isRTL ? -1 : 1)
);
}),
});

return (
<Animated.View
style={[
style,
styles.container,
{
width: `${100 / navigationState.routes.length}%`,
width: width,
transform: [{ translateX }] as any,
},
]}
Expand Down Expand Up @@ -119,6 +133,8 @@ export const CustomIndicator = () => {
renderBadge={renderBadge}
renderIndicator={renderIndicator}
style={styles.tabbar}
contentContainerStyle={styles.tabbarContentContainer}
gap={20}
/>
</View>
);
Expand Down Expand Up @@ -151,6 +167,9 @@ const styles = StyleSheet.create({
backgroundColor: '#263238',
overflow: 'hidden',
},
tabbarContentContainer: {
paddingHorizontal: 10,
},
icon: {
backgroundColor: 'transparent',
color: 'white',
Expand Down
5 changes: 5 additions & 0 deletions example/src/Screens/TabView/ScrollableTabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ export const ScrollableTabBar = () => {
scrollEnabled
indicatorStyle={styles.indicator}
style={styles.tabbar}
contentContainerStyle={styles.tabbarContentContainer}
tabStyle={styles.tab}
labelStyle={styles.label}
gap={20}
/>
);

Expand Down Expand Up @@ -74,6 +76,9 @@ const styles = StyleSheet.create({
tabbar: {
backgroundColor: '#3f51b5',
},
tabbarContentContainer: {
paddingHorizontal: 10,
},
tab: {
width: 120,
},
Expand Down
5 changes: 5 additions & 0 deletions example/src/Screens/TabView/TabBarIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export const TabBarIcon = () => {
indicatorStyle={styles.indicator}
renderIcon={renderIcon}
style={styles.tabbar}
contentContainerStyle={styles.tabbarContentContainer}
gap={20}
/>
);

Expand Down Expand Up @@ -76,6 +78,9 @@ const styles = StyleSheet.create({
tabbar: {
backgroundColor: '#e91e63',
},
tabbarContentContainer: {
paddingHorizontal: '10%',
},
indicator: {
backgroundColor: '#ffeb3b',
},
Expand Down
4 changes: 4 additions & 0 deletions packages/bottom-tabs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [7.0.0-alpha.2](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@7.0.0-alpha.1...@react-navigation/bottom-tabs@7.0.0-alpha.2) (2023-06-22)

**Note:** Version bump only for package @react-navigation/bottom-tabs

# [7.0.0-alpha.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@7.0.0-alpha.0...@react-navigation/bottom-tabs@7.0.0-alpha.1) (2023-03-01)

### Bug Fixes
Expand Down
6 changes: 3 additions & 3 deletions packages/bottom-tabs/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@react-navigation/bottom-tabs",
"description": "Bottom tab navigator following iOS design guidelines",
"version": "7.0.0-alpha.1",
"version": "7.0.0-alpha.2",
"keywords": [
"react-native-component",
"react-component",
Expand Down Expand Up @@ -36,7 +36,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/elements": "^1.4.0-alpha.0",
"@react-navigation/elements": "^1.4.0-alpha.1",
"color": "^4.2.3"
},
"devDependencies": {
Expand All @@ -48,7 +48,7 @@
"del-cli": "^5.0.0",
"react": "18.2.0",
"react-native": "0.71.8",
"react-native-builder-bob": "^0.20.4",
"react-native-builder-bob": "^0.21.0",
"react-native-safe-area-context": "4.5.0",
"react-native-screens": "~3.20.0",
"typescript": "^4.9.4"
Expand Down
18 changes: 18 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [7.0.0-alpha.2](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@7.0.0-alpha.1...@react-navigation/core@7.0.0-alpha.2) (2023-06-22)

### Bug Fixes

* fix infering params when a screen is in a group ([5e9f001](https://github.com/react-navigation/react-navigation/commit/5e9f001e770637ce8f438da981b5d069aa7a4532)), closes [#11325](https://github.com/react-navigation/react-navigation/issues/11325) - by @satya164

### Code Refactoring

* drop custom fromEntries in favor of Object.fromEntries ([9fe34b4](https://github.com/react-navigation/react-navigation/commit/9fe34b445fcb86e5666f61e144007d7540f014fa)), closes [/reactnative.dev/blog/2022/06/21/version-069#highlights-of-069](https://github.com//reactnative.dev/blog/2022/06/21/version-069/issues/highlights-of-069) - by @satya164

### Features

* support a top-level path configuration in linking config ([1d0297e](https://github.com/react-navigation/react-navigation/commit/1d0297ed17788c01d7b901ad04b63d3f37f47266)) - by @satya164

### BREAKING CHANGES

* this means we now require at least iOS 12.2 and React Native 0.69 whose minimum supported iOS version is 12.4

# [7.0.0-alpha.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@7.0.0-alpha.0...@react-navigation/core@7.0.0-alpha.1) (2023-03-01)

### Bug Fixes
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@react-navigation/core",
"description": "Core utilities for building navigators",
"version": "7.0.0-alpha.1",
"version": "7.0.0-alpha.2",
"keywords": [
"react",
"react-native",
Expand Down Expand Up @@ -49,7 +49,7 @@
"del-cli": "^5.0.0",
"immer": "^9.0.16",
"react": "18.2.0",
"react-native-builder-bob": "^0.20.4",
"react-native-builder-bob": "^0.21.0",
"react-test-renderer": "18.1.0",
"typescript": "^4.9.4"
},
Expand Down
23 changes: 13 additions & 10 deletions packages/core/src/StaticNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ type FlatType<T> = { [K in keyof T]: T[K] } & {};
* keyof T doesn't work for union types. We can use distributive conditional types instead.
* https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
*/
type KeysOf<T> = T extends any ? keyof T : never;
type KeysOf<T> = T extends {} ? keyof T : never;

/**
* We get a union type when using keyof, but we want an intersection instead.
* https://stackoverflow.com/a/50375286/1665026
*/
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
k: infer I
) => void
? I
: never;

type UnknownToUndefined<T> = unknown extends T ? undefined : T;

Expand All @@ -39,14 +49,7 @@ type ParamsForScreen<T> = T extends { screen: StaticNavigation<any, any, any> }
? NavigatorScreenParams<StaticParamList<T>> | undefined
: UnknownToUndefined<ParamsForScreenComponent<T>>;

type ParamListForScreens<
Screens extends StaticConfigScreens<
ParamListBase,
NavigationState,
{},
EventMapBase
>
> = {
type ParamListForScreens<Screens extends unknown> = {
[Key in KeysOf<Screens>]: ParamsForScreen<Screens[Key]>;
};

Expand All @@ -73,7 +76,7 @@ type ParamListForGroups<
>;
};
}
? ParamListForScreens<Groups[keyof Groups]['screens']>
? ParamListForScreens<UnionToIntersection<Groups[keyof Groups]['screens']>>
: {};

type StaticConfigScreens<
Expand Down
4 changes: 4 additions & 0 deletions packages/devtools/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [7.0.0-alpha.2](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@7.0.0-alpha.1...@react-navigation/devtools@7.0.0-alpha.2) (2023-06-22)

**Note:** Version bump only for package @react-navigation/devtools

# [7.0.0-alpha.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@7.0.0-alpha.0...@react-navigation/devtools@7.0.0-alpha.1) (2023-03-01)

### Bug Fixes
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@react-navigation/devtools",
"description": "Developer tools for React Navigation",
"version": "7.0.0-alpha.1",
"version": "7.0.0-alpha.2",
"keywords": [
"react",
"react-native",
Expand Down Expand Up @@ -47,7 +47,7 @@
"@types/react": "~18.0.27",
"del-cli": "^5.0.0",
"react": "18.2.0",
"react-native-builder-bob": "^0.20.4",
"react-native-builder-bob": "^0.21.0",
"typescript": "^4.9.4"
},
"peerDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions packages/drawer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [7.0.0-alpha.2](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@7.0.0-alpha.1...@react-navigation/drawer@7.0.0-alpha.2) (2023-06-22)

**Note:** Version bump only for package @react-navigation/drawer

# [7.0.0-alpha.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@7.0.0-alpha.0...@react-navigation/drawer@7.0.0-alpha.1) (2023-03-01)

### Bug Fixes
Expand Down
8 changes: 4 additions & 4 deletions packages/drawer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@react-navigation/drawer",
"description": "Drawer navigator component with animated transitions and gesturess",
"version": "7.0.0-alpha.1",
"description": "Integration for the drawer component from react-native-drawer-layout",
"version": "7.0.0-alpha.2",
"keywords": [
"react-native-component",
"react-component",
Expand Down Expand Up @@ -41,7 +41,7 @@
"clean": "del lib"
},
"dependencies": {
"@react-navigation/elements": "^1.4.0-alpha.0",
"@react-navigation/elements": "^1.4.0-alpha.1",
"color": "^4.2.3",
"react-native-drawer-layout": "workspace:^",
"use-latest-callback": "^0.1.5"
Expand All @@ -54,7 +54,7 @@
"del-cli": "^5.0.0",
"react": "18.2.0",
"react-native": "0.71.8",
"react-native-builder-bob": "^0.20.4",
"react-native-builder-bob": "^0.21.0",
"react-native-gesture-handler": "~2.9.0",
"react-native-reanimated": "~2.14.4",
"react-native-safe-area-context": "4.5.0",
Expand Down
Loading

0 comments on commit 931bf2b

Please sign in to comment.