satya164 / react-native-tab-view

A cross-platform Tab View component for React Native
MIT License
5.13k stars 1.07k forks source link

Turn off font scaling for label #1315

Closed Daavidaviid closed 2 years ago

Daavidaviid commented 2 years ago

Description

Currently we can't define allowFontScaling easily

Alternatives

No response

Inspirations & examples

Here is a working patch :

diff --git a/node_modules/react-native-tab-view/lib/commonjs/TabBar.js b/node_modules/react-native-tab-view/lib/commonjs/TabBar.js
index 5ef999f..8330683 100644
--- a/node_modules/react-native-tab-view/lib/commonjs/TabBar.js
+++ b/node_modules/react-native-tab-view/lib/commonjs/TabBar.js
@@ -245,7 +245,8 @@ class TabBar extends React.Component {
       indicatorStyle,
       contentContainerStyle,
       style,
-      indicatorContainerStyle
+      indicatorContainerStyle,
+      allowFontScaling
     } = this.props;
     const {
       layout,
@@ -352,7 +353,8 @@ class TabBar extends React.Component {
           route
         }),
         labelStyle: labelStyle,
-        style: tabStyle
+        style: tabStyle,
+        allowFontScaling,
       };
       return renderTabBarItem ? renderTabBarItem(props) : /*#__PURE__*/React.createElement(_TabBarItem.default, props);
     }))));
diff --git a/node_modules/react-native-tab-view/lib/commonjs/TabBarItem.js b/node_modules/react-native-tab-view/lib/commonjs/TabBarItem.js
index 877a78b..e243ca5 100644
--- a/node_modules/react-native-tab-view/lib/commonjs/TabBarItem.js
+++ b/node_modules/react-native-tab-view/lib/commonjs/TabBarItem.js
@@ -77,7 +77,8 @@ class TabBarItem extends React.Component {
       style,
       onLayout,
       onPress,
-      onLongPress
+      onLongPress,
+      allowFontScaling,
     } = this.props;
     const tabIndex = navigationState.routes.indexOf(route);
     const isFocused = navigationState.index === tabIndex;
@@ -127,7 +128,8 @@ class TabBarItem extends React.Component {
             marginTop: 0
           } : null, labelStyle, {
             color
-          }]
+          }], 
+          allowFontScaling,
         }, labelText);
       }

diff --git a/node_modules/react-native-tab-view/lib/module/TabBar.js b/node_modules/react-native-tab-view/lib/module/TabBar.js
index b287a8a..3586f18 100644
--- a/node_modules/react-native-tab-view/lib/module/TabBar.js
+++ b/node_modules/react-native-tab-view/lib/module/TabBar.js
@@ -226,7 +226,8 @@ export default class TabBar extends React.Component {
       indicatorStyle,
       contentContainerStyle,
       style,
-      indicatorContainerStyle
+      indicatorContainerStyle,
+      allowFontScaling,
     } = this.props;
     const {
       layout,
@@ -333,7 +334,8 @@ export default class TabBar extends React.Component {
           route
         }),
         labelStyle: labelStyle,
-        style: tabStyle
+        style: tabStyle,
+        allowFontScaling,
       };
       return renderTabBarItem ? renderTabBarItem(props) : /*#__PURE__*/React.createElement(TabBarItem, props);
     }))));
diff --git a/node_modules/react-native-tab-view/lib/module/TabBarItem.js b/node_modules/react-native-tab-view/lib/module/TabBarItem.js
index 9161c2c..6ac0324 100644
--- a/node_modules/react-native-tab-view/lib/module/TabBarItem.js
+++ b/node_modules/react-native-tab-view/lib/module/TabBarItem.js
@@ -58,7 +58,8 @@ export default class TabBarItem extends React.Component {
       style,
       onLayout,
       onPress,
-      onLongPress
+      onLongPress,
+      allowFontScaling
     } = this.props;
     const tabIndex = navigationState.routes.indexOf(route);
     const isFocused = navigationState.index === tabIndex;
@@ -108,7 +109,8 @@ export default class TabBarItem extends React.Component {
             marginTop: 0
           } : null, labelStyle, {
             color
-          }]
+          }],
+          allowFontScaling,
         }, labelText);
       }

diff --git a/node_modules/react-native-tab-view/lib/typescript/src/TabBar.d.ts b/node_modules/react-native-tab-view/lib/typescript/src/TabBar.d.ts
index 565223e..c25e220 100644
--- a/node_modules/react-native-tab-view/lib/typescript/src/TabBar.d.ts
+++ b/node_modules/react-native-tab-view/lib/typescript/src/TabBar.d.ts
@@ -36,6 +36,7 @@ export declare type Props<T extends Route> = SceneRendererProps & {
     labelStyle?: StyleProp<TextStyle>;
     contentContainerStyle?: StyleProp<ViewStyle>;
     style?: StyleProp<ViewStyle>;
+    allowFontScaling?: boolean;
 };
 declare type State = {
     layout: Layout;
github-actions[bot] commented 2 years ago

Hey! Thanks for opening the issue. The issue doesn't seem to contain a link to a repro (a snack.expo.dev link or link to a GitHub repo under your username).

Can you provide a minimal repro which demonstrates the issue? A repro will help us debug the issue faster. Please try to keep the repro as small as possible and make sure that we can run it without additional setup.

github-actions[bot] commented 2 years ago

Couldn't find version numbers for the following packages in the issue:

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

github-actions[bot] commented 2 years ago

Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it.