@expo/ui 56.0.3 → 56.0.4

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/android/build.gradle +2 -2
  3. package/build/universal/Button/index.d.ts.map +1 -1
  4. package/build/universal/Checkbox/index.d.ts.map +1 -1
  5. package/build/universal/Column/index.d.ts.map +1 -1
  6. package/build/universal/FieldGroup/FieldGroup.d.ts.map +1 -1
  7. package/build/universal/FieldGroup/FieldSection.d.ts.map +1 -1
  8. package/build/universal/Row/index.d.ts.map +1 -1
  9. package/build/universal/ScrollView/index.d.ts.map +1 -1
  10. package/build/universal/Slider/index.d.ts.map +1 -1
  11. package/build/universal/Spacer/index.d.ts.map +1 -1
  12. package/build/universal/Switch/index.d.ts.map +1 -1
  13. package/build/universal/Text/index.d.ts.map +1 -1
  14. package/expo-module.config.json +1 -1
  15. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3.module → 56.0.4/expo.modules.ui-56.0.4.module} +7 -7
  16. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.4/expo.modules.ui-56.0.4.module.md5 +1 -0
  17. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.4/expo.modules.ui-56.0.4.module.sha1 +1 -0
  18. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.4/expo.modules.ui-56.0.4.module.sha256 +1 -0
  19. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.4/expo.modules.ui-56.0.4.module.sha512 +1 -0
  20. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3.pom → 56.0.4/expo.modules.ui-56.0.4.pom} +1 -1
  21. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.4/expo.modules.ui-56.0.4.pom.md5 +1 -0
  22. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.4/expo.modules.ui-56.0.4.pom.sha1 +1 -0
  23. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.4/expo.modules.ui-56.0.4.pom.sha256 +1 -0
  24. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.4/expo.modules.ui-56.0.4.pom.sha512 +1 -0
  25. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml +4 -4
  26. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.md5 +1 -1
  27. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha1 +1 -1
  28. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha256 +1 -1
  29. package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha512 +1 -1
  30. package/package.json +3 -3
  31. package/src/ts-declarations/react-native-web.d.ts +112 -0
  32. package/src/universal/Button/index.tsx +37 -50
  33. package/src/universal/Checkbox/index.tsx +31 -18
  34. package/src/universal/Column/index.tsx +29 -18
  35. package/src/universal/FieldGroup/FieldGroup.tsx +24 -28
  36. package/src/universal/FieldGroup/FieldSection.tsx +62 -80
  37. package/src/universal/Row/index.tsx +37 -24
  38. package/src/universal/ScrollView/index.tsx +26 -15
  39. package/src/universal/Slider/index.tsx +21 -16
  40. package/src/universal/Spacer/index.tsx +18 -10
  41. package/src/universal/Switch/index.tsx +15 -10
  42. package/src/universal/Text/index.tsx +18 -37
  43. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.3/expo.modules.ui-56.0.3.module.md5 +0 -1
  44. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.3/expo.modules.ui-56.0.3.module.sha1 +0 -1
  45. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.3/expo.modules.ui-56.0.3.module.sha256 +0 -1
  46. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.3/expo.modules.ui-56.0.3.module.sha512 +0 -1
  47. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.3/expo.modules.ui-56.0.3.pom.md5 +0 -1
  48. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.3/expo.modules.ui-56.0.3.pom.sha1 +0 -1
  49. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.3/expo.modules.ui-56.0.3.pom.sha256 +0 -1
  50. package/local-maven-repo/expo/modules/ui/expo.modules.ui/56.0.3/expo.modules.ui-56.0.3.pom.sha512 +0 -1
  51. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3-sources.jar → 56.0.4/expo.modules.ui-56.0.4-sources.jar} +0 -0
  52. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3-sources.jar.md5 → 56.0.4/expo.modules.ui-56.0.4-sources.jar.md5} +0 -0
  53. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3-sources.jar.sha1 → 56.0.4/expo.modules.ui-56.0.4-sources.jar.sha1} +0 -0
  54. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3-sources.jar.sha256 → 56.0.4/expo.modules.ui-56.0.4-sources.jar.sha256} +0 -0
  55. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3-sources.jar.sha512 → 56.0.4/expo.modules.ui-56.0.4-sources.jar.sha512} +0 -0
  56. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3.aar → 56.0.4/expo.modules.ui-56.0.4.aar} +0 -0
  57. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3.aar.md5 → 56.0.4/expo.modules.ui-56.0.4.aar.md5} +0 -0
  58. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3.aar.sha1 → 56.0.4/expo.modules.ui-56.0.4.aar.sha1} +0 -0
  59. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3.aar.sha256 → 56.0.4/expo.modules.ui-56.0.4.aar.sha256} +0 -0
  60. /package/local-maven-repo/expo/modules/ui/expo.modules.ui/{56.0.3/expo.modules.ui-56.0.3.aar.sha512 → 56.0.4/expo.modules.ui-56.0.4.aar.sha512} +0 -0
@@ -1,9 +1,27 @@
1
- import { ScrollView, useColorScheme, type ViewStyle } from 'react-native';
1
+ import { ScrollView, StyleSheet, useColorScheme } from 'react-native';
2
2
 
3
3
  import { groupFieldGroupChildren } from './groupChildren';
4
4
  import type { FieldGroupProps } from './types';
5
5
  import { useUniversalLifecycle } from '../hooks';
6
6
 
7
+ const styles = StyleSheet.create({
8
+ container: {
9
+ backgroundColor: '#f2f2f7',
10
+ flex: 1,
11
+ },
12
+ containerDark: {
13
+ backgroundColor: '#000000',
14
+ },
15
+ hidden: {
16
+ display: 'none',
17
+ },
18
+ contentContainer: {
19
+ paddingHorizontal: 16,
20
+ paddingVertical: 16,
21
+ gap: 24,
22
+ },
23
+ });
24
+
7
25
  /**
8
26
  * A scrollable container for grouped settings-style rows, mirroring the look
9
27
  * of an iOS Settings screen. Render one or more
@@ -16,7 +34,7 @@ export function FieldGroup({
16
34
  style,
17
35
  onAppear,
18
36
  onDisappear,
19
- hidden,
37
+ hidden = false,
20
38
  testID,
21
39
  }: FieldGroupProps) {
22
40
  useUniversalLifecycle(onAppear, onDisappear);
@@ -26,36 +44,14 @@ export function FieldGroup({
26
44
  return (
27
45
  <ScrollView
28
46
  style={[
29
- containerBaseStyle,
30
- isDarkScheme ? containerDarkStyle : containerLightStyle,
47
+ styles.container,
48
+ isDarkScheme && styles.containerDark,
31
49
  style,
32
- hidden ? hiddenStyle : null,
50
+ hidden && styles.hidden,
33
51
  ]}
34
- contentContainerStyle={contentContainerStyle}
52
+ contentContainerStyle={styles.contentContainer}
35
53
  testID={testID}>
36
54
  {groupFieldGroupChildren(children)}
37
55
  </ScrollView>
38
56
  );
39
57
  }
40
-
41
- const containerBaseStyle: ViewStyle = {
42
- flex: 1,
43
- };
44
-
45
- const containerLightStyle: ViewStyle = {
46
- backgroundColor: '#f2f2f7',
47
- };
48
-
49
- const containerDarkStyle: ViewStyle = {
50
- backgroundColor: '#000000',
51
- };
52
-
53
- const hiddenStyle: ViewStyle = {
54
- display: 'none',
55
- };
56
-
57
- const contentContainerStyle: ViewStyle = {
58
- paddingHorizontal: 16,
59
- paddingVertical: 16,
60
- gap: 24,
61
- };
@@ -1,10 +1,62 @@
1
1
  import { Fragment } from 'react';
2
- import { Text, useColorScheme, View, type TextStyle, type ViewStyle } from 'react-native';
2
+ import { StyleSheet, Text, useColorScheme, View } from 'react-native';
3
3
 
4
4
  import { extractFieldSectionSlots } from './FieldSectionSlots';
5
5
  import type { FieldSectionProps } from './types';
6
6
  import { useUniversalLifecycle } from '../hooks';
7
7
 
8
+ const styles = StyleSheet.create({
9
+ hidden: {
10
+ display: 'none',
11
+ },
12
+ headerContainer: {
13
+ paddingHorizontal: 16,
14
+ paddingBottom: 8,
15
+ },
16
+ headerText: {
17
+ color: '#6c6c70',
18
+ fontSize: 14,
19
+ fontWeight: '500',
20
+ },
21
+ headerTextDark: {
22
+ color: '#98989e',
23
+ },
24
+ headerTextUppercase: {
25
+ textTransform: 'uppercase',
26
+ letterSpacing: 0.5,
27
+ fontSize: 13,
28
+ },
29
+ card: {
30
+ backgroundColor: '#ffffff',
31
+ borderRadius: 12,
32
+ overflow: 'hidden',
33
+ },
34
+ cardDark: {
35
+ backgroundColor: '#1c1c1e',
36
+ },
37
+ // Gives each row the same minimum height SwiftUI `Form` uses for single-line
38
+ // rows on iOS, so a text-only row doesn't collapse to its text intrinsic
39
+ // size. Taller content (e.g. a Switch) grows the row naturally. Horizontal
40
+ // padding matches SwiftUI `Form`'s built-in row leading/trailing inset.
41
+ rowWrapper: {
42
+ minHeight: 44,
43
+ justifyContent: 'center',
44
+ paddingHorizontal: 16,
45
+ },
46
+ divider: {
47
+ backgroundColor: '#e5e5ea',
48
+ height: 1,
49
+ marginLeft: 16,
50
+ },
51
+ dividerDark: {
52
+ backgroundColor: '#38383a',
53
+ },
54
+ footerContainer: {
55
+ paddingHorizontal: 16,
56
+ paddingTop: 8,
57
+ },
58
+ });
59
+
8
60
  /**
9
61
  * A grouped list of rows within a [`FieldGroup`](#fieldgroup). Each direct
10
62
  * child is rendered as a single row. Use `title` for a simple caption header,
@@ -27,105 +79,35 @@ export function FieldSection({
27
79
 
28
80
  const { header, footer, rows } = extractFieldSectionSlots(children);
29
81
 
30
- const containerStyle: ViewStyle = {
31
- ...style,
32
- ...(hidden ? { display: 'none' } : undefined),
33
- };
34
-
35
82
  const headerNode =
36
83
  header ??
37
84
  (title ? (
38
85
  <Text
39
86
  style={[
40
- headerTextStyle,
41
- isDarkScheme ? headerTextDarkStyle : headerTextLightStyle,
42
- titleUppercase ? headerTextUppercaseStyle : null,
87
+ styles.headerText,
88
+ isDarkScheme && styles.headerTextDark,
89
+ titleUppercase && styles.headerTextUppercase,
43
90
  ]}>
44
91
  {title}
45
92
  </Text>
46
93
  ) : null);
47
94
 
48
95
  return (
49
- <View style={containerStyle} testID={testID}>
50
- {headerNode ? <View style={headerContainerStyle}>{headerNode}</View> : null}
96
+ <View style={[style, hidden && styles.hidden]} testID={testID}>
97
+ {headerNode ? <View style={styles.headerContainer}>{headerNode}</View> : null}
51
98
  {rows.length > 0 ? (
52
- <View style={[cardBaseStyle, isDarkScheme ? cardDarkStyle : cardLightStyle]}>
99
+ <View style={[styles.card, isDarkScheme && styles.cardDark]}>
53
100
  {rows.map((child, index) => (
54
101
  <Fragment key={index}>
55
- <View style={rowWrapperStyle}>{child}</View>
102
+ <View style={styles.rowWrapper}>{child}</View>
56
103
  {index < rows.length - 1 ? (
57
- <View style={[dividerStyle, isDarkScheme ? dividerDarkStyle : dividerLightStyle]} />
104
+ <View style={[styles.divider, isDarkScheme && styles.dividerDark]} />
58
105
  ) : null}
59
106
  </Fragment>
60
107
  ))}
61
108
  </View>
62
109
  ) : null}
63
- {footer ? <View style={footerContainerStyle}>{footer}</View> : null}
110
+ {footer ? <View style={styles.footerContainer}>{footer}</View> : null}
64
111
  </View>
65
112
  );
66
113
  }
67
-
68
- const headerContainerStyle: ViewStyle = {
69
- paddingHorizontal: 16,
70
- paddingBottom: 8,
71
- };
72
-
73
- const headerTextStyle: TextStyle = {
74
- fontSize: 14,
75
- fontWeight: '500',
76
- };
77
-
78
- const headerTextLightStyle: TextStyle = {
79
- color: '#6c6c70',
80
- };
81
-
82
- const headerTextDarkStyle: TextStyle = {
83
- color: '#98989e',
84
- };
85
-
86
- const headerTextUppercaseStyle: TextStyle = {
87
- textTransform: 'uppercase',
88
- letterSpacing: 0.5,
89
- fontSize: 13,
90
- };
91
-
92
- const cardBaseStyle: ViewStyle = {
93
- borderRadius: 12,
94
- overflow: 'hidden',
95
- };
96
-
97
- const cardLightStyle: ViewStyle = {
98
- backgroundColor: '#ffffff',
99
- };
100
-
101
- const cardDarkStyle: ViewStyle = {
102
- backgroundColor: '#1c1c1e',
103
- };
104
-
105
- // Gives each row the same minimum height SwiftUI `Form` uses for single-line
106
- // rows on iOS, so a text-only row doesn't collapse to its text intrinsic
107
- // size. Taller content (e.g. a Switch) grows the row naturally. Horizontal
108
- // padding matches SwiftUI `Form`'s built-in row leading/trailing inset.
109
- const rowWrapperStyle: ViewStyle = {
110
- minHeight: 44,
111
- justifyContent: 'center',
112
- paddingHorizontal: 16,
113
- };
114
-
115
- const dividerStyle: ViewStyle = {
116
- height: 1,
117
- marginLeft: 16,
118
- };
119
-
120
- const dividerLightStyle: ViewStyle = {
121
- backgroundColor: '#e5e5ea',
122
- };
123
-
124
- const dividerDarkStyle: ViewStyle = {
125
- backgroundColor: '#38383a',
126
- };
127
-
128
- const footerContainerStyle: ViewStyle = {
129
- paddingHorizontal: 16,
130
- paddingTop: 8,
131
- };
@@ -1,14 +1,31 @@
1
- import { Pressable, View, type ViewStyle } from 'react-native';
1
+ import { Pressable, StyleSheet, View, type ViewStyle } from 'react-native';
2
2
 
3
3
  import type { RowProps } from './types';
4
4
  import { useUniversalLifecycle } from '../hooks';
5
5
  import type { UniversalAlignment } from '../types';
6
6
 
7
- const alignmentMap: Record<UniversalAlignment, ViewStyle['alignItems']> = {
8
- start: 'flex-start',
9
- center: 'center',
10
- end: 'flex-end',
11
- };
7
+ const styles = StyleSheet.create({
8
+ row: {
9
+ // Fill the parent's cross-axis by default so a `<Spacer flexible />`
10
+ // child has room to grow. Without this, a Row placed inside a `Column`
11
+ // with alignment other than 'stretch' is content-sized on web, which
12
+ // leaves flex children with no leftover space. SwiftUI and Compose
13
+ // achieve the same effect via their own layout phases.
14
+ alignSelf: 'stretch',
15
+ flexDirection: 'row',
16
+ },
17
+ hidden: { display: 'none' },
18
+ disabled: {
19
+ opacity: 0.5,
20
+ pointerEvents: 'none',
21
+ },
22
+ });
23
+
24
+ const alignmentStyles = StyleSheet.create({
25
+ start: { alignItems: 'flex-start' },
26
+ center: { alignItems: 'center' },
27
+ end: { alignItems: 'flex-end' },
28
+ } satisfies Record<UniversalAlignment, ViewStyle>);
12
29
 
13
30
  /**
14
31
  * A horizontal layout container that arranges its children from start to end.
@@ -21,31 +38,27 @@ export function Row({
21
38
  onPress,
22
39
  onAppear,
23
40
  onDisappear,
24
- disabled,
25
- hidden,
41
+ disabled = false,
42
+ hidden = false,
26
43
  testID,
27
44
  }: RowProps) {
28
45
  useUniversalLifecycle(onAppear, onDisappear);
29
46
 
30
- const viewStyle: ViewStyle = {
31
- // Fill the parent's cross-axis by default so a `<Spacer flexible />`
32
- // child has room to grow. Without this, a Row placed inside a `Column`
33
- // with alignment other than 'stretch' is content-sized on web, which
34
- // leaves flex children with no leftover space. SwiftUI and Compose
35
- // achieve the same effect via their own layout phases.
36
- alignSelf: 'stretch',
37
- flexDirection: 'row',
38
- alignItems: alignmentMap[alignment],
39
- gap: spacing,
40
- ...style,
41
- ...(hidden ? { display: 'none' } : undefined),
42
- ...(disabled ? { opacity: 0.5, pointerEvents: 'none' } : undefined),
43
- };
44
-
45
47
  const Container = onPress ? Pressable : View;
46
48
 
47
49
  return (
48
- <Container style={viewStyle} onPress={onPress} disabled={disabled} testID={testID}>
50
+ <Container
51
+ onPress={onPress}
52
+ disabled={disabled}
53
+ testID={testID}
54
+ style={[
55
+ styles.row,
56
+ alignmentStyles[alignment],
57
+ spacing != null && { gap: spacing },
58
+ style,
59
+ hidden && styles.hidden,
60
+ disabled && styles.disabled,
61
+ ]}>
49
62
  {children}
50
63
  </Container>
51
64
  );
@@ -1,8 +1,23 @@
1
- import { ScrollView as RNScrollView, type ViewStyle } from 'react-native';
1
+ import { ScrollView as RNScrollView, StyleSheet } from 'react-native';
2
2
 
3
3
  import type { ScrollViewProps } from './types';
4
4
  import { useUniversalLifecycle } from '../hooks';
5
5
 
6
+ const styles = StyleSheet.create({
7
+ container: {
8
+ // Constrain to viewport width so horizontal content overflows and scrolls
9
+ // instead of expanding the parent layout.
10
+ // @ts-expect-error
11
+ maxWidth: '100vw',
12
+ },
13
+ noGrow: { flexGrow: 0 },
14
+ hidden: { display: 'none' },
15
+ disabled: {
16
+ opacity: 0.5,
17
+ pointerEvents: 'none',
18
+ },
19
+ });
20
+
6
21
  /**
7
22
  * A scrollable container that supports vertical or horizontal scrolling.
8
23
  */
@@ -15,24 +30,14 @@ export function ScrollView({
15
30
  // API compatibility but silently ignored (RN ScrollView has no press handler).
16
31
  onAppear,
17
32
  onDisappear,
18
- disabled,
19
- hidden,
33
+ disabled = false,
34
+ hidden = false,
20
35
  testID,
21
36
  }: ScrollViewProps) {
22
37
  useUniversalLifecycle(onAppear, onDisappear);
23
38
 
24
39
  const isHorizontal = direction === 'horizontal';
25
40
 
26
- const containerStyle: ViewStyle = {
27
- // Constrain to viewport width so horizontal content overflows and scrolls
28
- // instead of expanding the parent layout.
29
- maxWidth: '100vw' as any,
30
- ...style,
31
- ...(style?.height != null ? { flexGrow: 0 } : undefined),
32
- ...(hidden ? { display: 'none' } : undefined),
33
- ...(disabled ? { opacity: 0.5, pointerEvents: 'none' } : undefined),
34
- };
35
-
36
41
  // react-native-web does not support separate vertical and horizontal indicator props,
37
42
  // so we map both to its single `showsIndicators` prop.
38
43
  const showVerticalIndicator = showsIndicators;
@@ -43,9 +48,15 @@ export function ScrollView({
43
48
  horizontal={isHorizontal}
44
49
  showsVerticalScrollIndicator={showVerticalIndicator}
45
50
  showsHorizontalScrollIndicator={showHorizontalIndicator}
46
- style={containerStyle}
47
51
  nestedScrollEnabled
48
- testID={testID}>
52
+ testID={testID}
53
+ style={[
54
+ styles.container,
55
+ style,
56
+ style?.height != null && styles.noGrow,
57
+ hidden && styles.hidden,
58
+ disabled && styles.disabled,
59
+ ]}>
49
60
  {children}
50
61
  </RNScrollView>
51
62
  );
@@ -1,7 +1,23 @@
1
- import { View, type ViewStyle } from 'react-native';
1
+ import type { ComponentProps } from 'react';
2
+ import { StyleSheet, unstable_createElement, View, type ViewProps } from 'react-native';
2
3
 
3
4
  import type { SliderProps } from './types';
4
5
 
6
+ const styles = StyleSheet.create({
7
+ view: {
8
+ alignSelf: 'stretch',
9
+ justifyContent: 'center',
10
+ },
11
+ input: {
12
+ width: '100%',
13
+ cursor: 'pointer',
14
+ },
15
+ });
16
+
17
+ const NativeSlider = (
18
+ props: Omit<ComponentProps<'input'>, 'style' | 'type'> & { style?: ViewProps['style'] }
19
+ ) => unstable_createElement('input', { ...props, type: 'range' });
20
+
5
21
  /**
6
22
  * A control for selecting a value from a continuous or stepped range.
7
23
  */
@@ -11,13 +27,12 @@ export function Slider({
11
27
  min = 0,
12
28
  max = 1,
13
29
  step,
14
- disabled,
30
+ disabled = false,
15
31
  testID,
16
32
  }: SliderProps) {
17
33
  return (
18
- <View style={containerStyle}>
19
- <input
20
- type="range"
34
+ <View style={styles.view}>
35
+ <NativeSlider
21
36
  value={value}
22
37
  min={min}
23
38
  max={max}
@@ -25,20 +40,10 @@ export function Slider({
25
40
  disabled={disabled}
26
41
  onChange={(e) => onValueChange(parseFloat(e.target.value))}
27
42
  data-testid={testID}
28
- style={inputStyle}
43
+ style={styles.input}
29
44
  />
30
45
  </View>
31
46
  );
32
47
  }
33
48
 
34
- const containerStyle: ViewStyle = {
35
- alignSelf: 'stretch',
36
- justifyContent: 'center',
37
- };
38
-
39
- const inputStyle: React.CSSProperties = {
40
- width: '100%',
41
- cursor: 'pointer',
42
- };
43
-
44
49
  export * from './types';
@@ -1,8 +1,13 @@
1
- import { View, type ViewStyle } from 'react-native';
1
+ import { StyleSheet, View } from 'react-native';
2
2
 
3
3
  import type { SpacerProps } from './types';
4
4
  import { useUniversalLifecycle } from '../hooks';
5
5
 
6
+ const styles = StyleSheet.create({
7
+ flexible: { flex: 1 },
8
+ hidden: { display: 'none' },
9
+ });
10
+
6
11
  /**
7
12
  * A layout spacer that produces empty space between siblings in a
8
13
  * `Row` or `Column`.
@@ -13,19 +18,22 @@ export function Spacer({
13
18
  style,
14
19
  onAppear,
15
20
  onDisappear,
16
- hidden,
21
+ hidden = false,
17
22
  testID,
18
23
  }: SpacerProps) {
19
24
  useUniversalLifecycle(onAppear, onDisappear);
20
25
 
21
- const viewStyle: ViewStyle = {
22
- ...(flexible ? { flex: 1 } : undefined),
23
- ...(size != null ? { width: size, height: size } : undefined),
24
- ...style,
25
- ...(hidden ? { display: 'none' } : undefined),
26
- };
27
-
28
- return <View style={viewStyle} testID={testID} />;
26
+ return (
27
+ <View
28
+ testID={testID}
29
+ style={[
30
+ flexible && styles.flexible,
31
+ size != null && { width: size, height: size },
32
+ style,
33
+ hidden && styles.hidden,
34
+ ]}
35
+ />
36
+ );
29
37
  }
30
38
 
31
39
  export * from './types';
@@ -1,21 +1,26 @@
1
- import { Switch as RNSwitch, View, Text } from 'react-native';
1
+ import { Switch as RNSwitch, View, Text, StyleSheet } from 'react-native';
2
2
 
3
3
  import type { SwitchProps } from './types';
4
4
 
5
+ const styles = StyleSheet.create({
6
+ view: {
7
+ flexDirection: 'row',
8
+ alignItems: 'center',
9
+ justifyContent: 'space-between',
10
+ gap: 8,
11
+ },
12
+ disabled: {
13
+ opacity: 0.5,
14
+ },
15
+ });
16
+
5
17
  /**
6
18
  * A toggle control that switches between on and off states.
7
19
  */
8
- export function Switch({ value, onValueChange, label, disabled, testID }: SwitchProps) {
20
+ export function Switch({ value, onValueChange, label, disabled = false, testID }: SwitchProps) {
9
21
  if (label) {
10
22
  return (
11
- <View
12
- style={{
13
- flexDirection: 'row',
14
- alignItems: 'center',
15
- justifyContent: 'space-between',
16
- gap: 8,
17
- opacity: disabled ? 0.5 : 1,
18
- }}>
23
+ <View style={[styles.view, disabled && styles.disabled]}>
19
24
  <Text>{label}</Text>
20
25
  <RNSwitch value={value} onValueChange={onValueChange} disabled={disabled} testID={testID} />
21
26
  </View>
@@ -1,8 +1,15 @@
1
- import { Text as RNText, useColorScheme, type TextStyle } from 'react-native';
1
+ import { Text as RNText, StyleSheet, useColorScheme } from 'react-native';
2
2
 
3
3
  import type { TextProps } from './types';
4
4
  import { useUniversalLifecycle } from '../hooks';
5
5
 
6
+ const styles = StyleSheet.create({
7
+ light: { color: '#000000' },
8
+ dark: { color: '#FFFFFF' },
9
+ hidden: { display: 'none' },
10
+ disabled: { opacity: 0.5 },
11
+ });
12
+
6
13
  /**
7
14
  * A component for displaying styled text content.
8
15
  */
@@ -14,56 +21,30 @@ export function Text({
14
21
  onPress,
15
22
  onAppear,
16
23
  onDisappear,
17
- disabled,
18
- hidden,
24
+ disabled = false,
25
+ hidden = false,
19
26
  testID,
20
27
  }: TextProps) {
21
28
  useUniversalLifecycle(onAppear, onDisappear);
22
29
 
23
30
  const isDarkScheme = useColorScheme() === 'dark';
24
31
 
25
- const textStyleOverrides: TextStyle = {
26
- ...(textStyle?.fontSize != null ? { fontSize: textStyle.fontSize } : undefined),
27
- ...(textStyle?.fontWeight != null ? { fontWeight: textStyle.fontWeight } : undefined),
28
- ...(textStyle?.fontFamily != null ? { fontFamily: textStyle.fontFamily } : undefined),
29
- ...(textStyle?.color != null ? { color: textStyle.color } : undefined),
30
- ...(textStyle?.lineHeight != null ? { lineHeight: textStyle.lineHeight } : undefined),
31
- ...(textStyle?.letterSpacing != null ? { letterSpacing: textStyle.letterSpacing } : undefined),
32
- ...(textStyle?.textAlign != null ? { textAlign: textStyle.textAlign } : undefined),
33
- };
34
-
35
32
  return (
36
33
  <RNText
37
- style={[
38
- isDarkScheme ? textDarkStyle : textLightStyle,
39
- style,
40
- textStyleOverrides,
41
- hidden ? hiddenStyle : null,
42
- disabled ? disabledStyle : null,
43
- ]}
44
34
  numberOfLines={numberOfLines}
45
35
  onPress={onPress}
46
36
  disabled={disabled}
47
- testID={testID}>
37
+ testID={testID}
38
+ style={[
39
+ isDarkScheme ? styles.dark : styles.light,
40
+ style,
41
+ textStyle,
42
+ hidden && styles.hidden,
43
+ disabled && styles.disabled,
44
+ ]}>
48
45
  {children}
49
46
  </RNText>
50
47
  );
51
48
  }
52
49
 
53
- const textLightStyle: TextStyle = {
54
- color: '#000000',
55
- };
56
-
57
- const textDarkStyle: TextStyle = {
58
- color: '#FFFFFF',
59
- };
60
-
61
- const hiddenStyle: TextStyle = {
62
- display: 'none',
63
- };
64
-
65
- const disabledStyle: TextStyle = {
66
- opacity: 0.5,
67
- };
68
-
69
50
  export * from './types';
@@ -1 +0,0 @@
1
- 5a7ca98cf0b7d42beb78532a4de00ee4d1597e6e
@@ -1 +0,0 @@
1
- 1b1e0569740ff5fbfa0a3412f1efbf8f7a5b3d577239f108ba4a5d51b39d41e6
@@ -1 +0,0 @@
1
- 5d627db27038fcf6c659f4b5d030a112c19097b15258e490b60da47867204ddffed145a62b649b24be23e8ddb6668b98c31a14059489398be5c8f76782138a82
@@ -1 +0,0 @@
1
- 0d85db163ef7ad2031fd783734fbbfc2
@@ -1 +0,0 @@
1
- b6801cacf665cc9e2aecf9d0bb04c98f0ed1aa29
@@ -1 +0,0 @@
1
- 8879720c37c6bebdc6150d3fed464da86ddcece3b0e75759ce3ab7f48943fe06
@@ -1 +0,0 @@
1
- 2ecda699c389b7f19611c8a6c00c5011f69fdfb9d25c02997f93ee1e8037fc441b499a230e68ad1683bd3a3f3b5e08c139e04268319788a2c9852eb148bbb356