@react-native-segmented-control/segmented-control 2.3.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,7 +19,7 @@ For Android and Web, it has a js implementation that mocks iOS 13 style of UISeg
19
19
  | v2.2.0 | >= 0.62 |
20
20
  | <= v2.2.0 | >= 0.57 |
21
21
 
22
- This module is NOT supported for expo.
22
+ This module is NOT supported in the Expo Go app on iOS, because it requires custom native code. You need to use a custom development client or eject into bare workflow in order to use this module on iOS.
23
23
 
24
24
  ## Getting started
25
25
 
@@ -225,6 +225,41 @@ An object container
225
225
  - `fontFamily`: overrides font-family of selected segment text
226
226
  - `fontWeight`: overrides font-weight of selected segment text
227
227
 
228
+ ### `tabStyle`
229
+
230
+ (Android and Web only) Styles the clickable surface which is responsible to change tabs
231
+ | Type | Required | Platform |
232
+ | ------ | -------- | -------- |
233
+ | object | No | Android, Web |
234
+
235
+ Extends [ViewStyles](https://reactnative.dev/docs/view-style-props)
236
+
237
+ ## Tips and Tricks
238
+
239
+ ### How can I increase the height of the tab ?
240
+
241
+ For android and IOS, simply pass `prop.style`:
242
+
243
+ ```json
244
+ {
245
+ "height": number
246
+ }
247
+ ```
248
+
249
+ For react-native-web, additionally pass :
250
+
251
+ ```json
252
+ {
253
+ "paddingVertical": number,
254
+ or
255
+ "height": number
256
+ }
257
+ ```
258
+
259
+ ### Adding padding makes text disappear on Android
260
+
261
+ If padding amount exceeds the fixed height of the container, it will shrink the text. So either increase the height or reduce your padding.
262
+
228
263
  ## Maintainers
229
264
 
230
265
  - [M.Haris Baig](https://github.com/harisbaig100)
package/index.d.ts CHANGED
@@ -6,10 +6,12 @@ import {
6
6
  ViewProps,
7
7
  NativeSyntheticEvent,
8
8
  NativeMethods,
9
- Constructor,
10
9
  TargetedEvent,
10
+ ViewStyle,
11
11
  } from 'react-native';
12
12
 
13
+ type Constructor<T> = new (...args: any[]) => T;
14
+
13
15
  export interface NativeSegmentedControlIOSChangeEvent extends TargetedEvent {
14
16
  value: string;
15
17
  selectedSegmentIndex: number;
@@ -104,6 +106,11 @@ export interface SegmentedControlProps extends ViewProps {
104
106
  * Active Font style properties of the Segmented Control
105
107
  */
106
108
  activeFontStyle?: FontStyle;
109
+
110
+ /**
111
+ * Touchable style properties for Segmented Control Tab
112
+ */
113
+ tabStyle?: ViewStyle;
107
114
  }
108
115
 
109
116
  /**
@@ -32,6 +32,7 @@ const SegmentedControl = ({
32
32
  values,
33
33
  tintColor,
34
34
  backgroundColor,
35
+ tabStyle,
35
36
  fontStyle,
36
37
  activeFontStyle,
37
38
  appearance,
@@ -101,6 +102,7 @@ const SegmentedControl = ({
101
102
  key={index}
102
103
  value={value}
103
104
  tintColor={tintColor}
105
+ tabStyle={tabStyle}
104
106
  fontStyle={fontStyle}
105
107
  activeFontStyle={activeFontStyle}
106
108
  appearance={colorScheme}
@@ -15,7 +15,7 @@ import {
15
15
  useColorScheme,
16
16
  } from 'react-native';
17
17
 
18
- import type {FontStyle} from './types';
18
+ import type {FontStyle, ViewStyle} from './types';
19
19
 
20
20
  type Props = $ReadOnly<{|
21
21
  value: string | number | Object,
@@ -25,6 +25,7 @@ type Props = $ReadOnly<{|
25
25
  enabled: boolean,
26
26
  fontStyle?: FontStyle,
27
27
  activeFontStyle?: FontStyle,
28
+ tabStyle?: ViewStyle,
28
29
  appearance?: 'dark' | 'light' | null,
29
30
  |}>;
30
31
 
@@ -42,6 +43,7 @@ export const SegmentedControlTab = ({
42
43
  fontStyle = {},
43
44
  activeFontStyle = {},
44
45
  appearance,
46
+ tabStyle,
45
47
  }: Props): React.Node => {
46
48
  const colorSchemeHook = useColorScheme();
47
49
  const colorScheme = appearance || colorSchemeHook;
@@ -82,10 +84,11 @@ export const SegmentedControlTab = ({
82
84
 
83
85
  return (
84
86
  <TouchableOpacity
85
- style={styles.container}
87
+ style={[styles.container, tabStyle]}
86
88
  disabled={!enabled}
87
- onPress={onSelect}>
88
- <View style={[styles.default]}>
89
+ onPress={onSelect}
90
+ accessibilityState={{selected: selected, disabled: !enabled}}>
91
+ <View style={styles.default}>
89
92
  {typeof value === 'number' || typeof value === 'object' ? (
90
93
  <Image source={value} style={styles.segmentImage} />
91
94
  ) : isBase64(value) ? (
package/js/types.js CHANGED
@@ -5,6 +5,7 @@
5
5
  import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
6
6
  import type {SyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes';
7
7
  import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
8
+ import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
8
9
 
9
10
  export type Event = SyntheticEvent<
10
11
  $ReadOnly<{|
@@ -13,6 +14,8 @@ export type Event = SyntheticEvent<
13
14
  |}>,
14
15
  >;
15
16
 
17
+ export type ViewStyle = ViewStyleProp;
18
+
16
19
  export type FontStyle = $ReadOnly<{|
17
20
  /**
18
21
  * Font Color of Segmented Control
@@ -99,4 +102,9 @@ export type SegmentedControlProps = $ReadOnly<{|
99
102
  * it will override fontStyle for the selected segment
100
103
  */
101
104
  activeFontStyle?: FontStyle,
105
+
106
+ /**
107
+ * Touchable style properties for Segmented Control Tab
108
+ */
109
+ tabStyle?: ViewStyle,
102
110
  |}>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-segmented-control/segmented-control",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "description": "React Native SegmentedControlIOS library",
5
5
  "main": "js/index.js",
6
6
  "types": "index.d.ts",
@@ -18,7 +18,8 @@
18
18
  "android": "react-native run-android",
19
19
  "flow": "flow",
20
20
  "lint": "eslint . --cache",
21
- "tsc": "tsc --noEmit"
21
+ "tsc": "tsc --noEmit",
22
+ "ci:publish": "yarn semantic-release"
22
23
  },
23
24
  "peerDependencies": {
24
25
  "react": ">=16.0",
@@ -27,29 +28,30 @@
27
28
  "devDependencies": {
28
29
  "@babel/core": "^7.10.2",
29
30
  "@babel/runtime": "^7.10.2",
30
- "@expo/webpack-config": "^0.12.22",
31
- "@react-native-community/eslint-config": "^2.0.0",
32
- "@semantic-release/git": "^8.0.0",
31
+ "@expo/webpack-config": "^0.17.2",
32
+ "@react-native-community/eslint-config": "^3.0.0",
33
+ "@semantic-release/git": "^10.0.1",
33
34
  "@types/react": "^17.0.0",
34
- "@types/react-native": "^0.63.46",
35
+ "@types/react-native": "^0.64.4",
35
36
  "babel-eslint": "^10.1.0",
36
- "babel-jest": "^26.0.1",
37
- "babel-preset-expo": "^8.2.1",
37
+ "babel-jest": "^29.0.3",
38
+ "babel-preset-expo": "^9.2.0",
38
39
  "eslint": "7",
39
- "eslint-plugin-prettier": "^3.1.2",
40
- "expo": "^38.0.10",
40
+ "eslint-plugin-prettier": "^4.2.1",
41
+ "expo": "^46.0.16",
41
42
  "flow-bin": "^0.142.0",
42
- "husky": "^4.0.10",
43
- "jest": "^26.0.1",
44
- "metro-react-native-babel-preset": "0.64.0",
43
+ "husky": "^8.0.1",
44
+ "jest": "^29.2.1",
45
+ "metro-react-native-babel-preset": "0.73.3",
45
46
  "react": "16.13.1",
46
47
  "react-dom": "16.13.1",
47
- "react-native": "0.63.2",
48
+ "react-native": "0.63.4",
49
+ "react-native-test-app": "1.4.6",
48
50
  "react-native-web": "^0.14.10",
49
51
  "react-test-renderer": "16.13.1",
50
52
  "rimraf": "^3.0.2",
51
- "semantic-release": "^17.0.4",
52
- "typescript": "^3.8.3"
53
+ "semantic-release": "^19.0.5",
54
+ "typescript": "^4.1.5"
53
55
  },
54
56
  "resolutions": {
55
57
  "@react-native-community/cli": "4.10.0"
@@ -62,7 +64,7 @@
62
64
  },
63
65
  "repository": {
64
66
  "type": "git",
65
- "url": "git+https://github.com/react-native-community/segmented-control.git"
67
+ "url": "git+https://github.com/react-native-segmented-control/segmented-control.git"
66
68
  },
67
69
  "keywords": [
68
70
  "SegmentedControlIOS",
@@ -71,9 +73,9 @@
71
73
  "author": "M.Haris Baig",
72
74
  "license": "MIT",
73
75
  "bugs": {
74
- "url": "https://github.com/react-native-community/segmented-control/issues"
76
+ "url": "https://github.com/react-native-segmented-control/segmented-control/issues"
75
77
  },
76
- "homepage": "https://github.com/react-native-community/segmented-control#readme",
78
+ "homepage": "https://github.com/react-native-segmented-control/segmented-control#readme",
77
79
  "publishConfig": {
78
80
  "access": "public"
79
81
  }