@expo/ui 58.0.27 → 58.0.29
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/CHANGELOG.md +23 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +9 -0
- package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +4 -0
- package/android/src/main/java/expo/modules/ui/RangeSliderView.kt +126 -0
- package/android/src/main/java/expo/modules/ui/ScrollDismissesKeyboard.kt +46 -0
- package/android/src/main/java/expo/modules/ui/SliderView.kt +31 -7
- package/android/src/main/java/expo/modules/ui/VerticalSliderView.kt +1 -8
- package/android/src/main/java/expo/modules/ui/menu/DropdownMenuPopup.kt +4 -0
- package/android/src/main/java/expo/modules/ui/menu/DropdownMenuRecords.kt +21 -0
- package/assets/check.xml +10 -0
- package/build/community/bottom-sheet/BottomSheet.ios.js +1 -0
- package/build/community/bottom-sheet/BottomSheet.ios.js.map +1 -1
- package/build/community/menu/MenuView.android.d.ts +1 -1
- package/build/community/menu/MenuView.android.js +188 -95
- package/build/community/menu/MenuView.android.js.map +1 -1
- package/build/jetpack-compose/DropdownMenu/index.d.ts +7 -0
- package/build/jetpack-compose/DropdownMenu/index.js.map +1 -1
- package/build/jetpack-compose/RangeSlider/index.d.ts +78 -0
- package/build/jetpack-compose/RangeSlider/index.js +51 -0
- package/build/jetpack-compose/RangeSlider/index.js.map +1 -0
- package/build/jetpack-compose/Slider/index.d.ts +15 -0
- package/build/jetpack-compose/Slider/index.js.map +1 -1
- package/build/jetpack-compose/index.d.ts +1 -0
- package/build/jetpack-compose/index.js +1 -0
- package/build/jetpack-compose/index.js.map +1 -1
- package/build/jetpack-compose/modifiers/index.d.ts +12 -0
- package/build/jetpack-compose/modifiers/index.js +11 -0
- package/build/jetpack-compose/modifiers/index.js.map +1 -1
- package/build/swift-ui/modifiers/index.d.ts +18 -3
- package/build/swift-ui/modifiers/index.js +18 -2
- package/build/swift-ui/modifiers/index.js.map +1 -1
- package/build/swift-ui/modifiers/symbolEffect.d.ts +49 -6
- package/build/swift-ui/modifiers/symbolEffect.js +1 -28
- package/build/swift-ui/modifiers/symbolEffect.js.map +1 -1
- package/build/swift-ui/modifiers/symbolEffectOptions.d.ts +22 -0
- package/build/swift-ui/modifiers/symbolEffectOptions.js +30 -0
- package/build/swift-ui/modifiers/symbolEffectOptions.js.map +1 -0
- package/build/universal/Picker/Picker.android.d.ts +1 -1
- package/build/universal/Picker/Picker.android.js +8 -3
- package/build/universal/Picker/Picker.android.js.map +1 -1
- package/build/universal/Picker/Picker.d.ts +1 -1
- package/build/universal/Picker/Picker.ios.d.ts +1 -1
- package/build/universal/Picker/Picker.ios.js +5 -2
- package/build/universal/Picker/Picker.ios.js.map +1 -1
- package/build/universal/Picker/Picker.js +2 -1
- package/build/universal/Picker/Picker.js.map +1 -1
- package/build/universal/Picker/types.d.ts +4 -0
- package/build/universal/Picker/types.js.map +1 -1
- package/ios/HostView.swift +0 -1
- package/ios/Modifiers/ContentTransitionModifier.swift +49 -0
- package/ios/RNHostView.swift +55 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.27/expo.modules.ui-58.0.27-sources.jar → 58.0.29/expo.modules.ui-58.0.29-sources.jar} +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29-sources.jar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29-sources.jar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29-sources.jar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29-sources.jar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.aar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.aar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.aar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.aar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.27/expo.modules.ui-58.0.27.module → 58.0.29/expo.modules.ui-58.0.29.module} +22 -22
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.module.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.module.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.module.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.module.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.27/expo.modules.ui-58.0.27.pom → 58.0.29/expo.modules.ui-58.0.29.pom} +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.pom.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.pom.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.pom.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.29/expo.modules.ui-58.0.29.pom.sha512 +1 -0
- package/package.json +1 -1
- package/src/community/bottom-sheet/BottomSheet.ios.tsx +5 -2
- package/src/community/menu/MenuView.android.tsx +193 -107
- package/src/jetpack-compose/DropdownMenu/index.tsx +9 -0
- package/src/jetpack-compose/RangeSlider/index.tsx +125 -0
- package/src/jetpack-compose/Slider/index.tsx +15 -0
- package/src/jetpack-compose/index.ts +1 -0
- package/src/jetpack-compose/modifiers/index.ts +13 -0
- package/src/swift-ui/modifiers/index.ts +28 -4
- package/src/swift-ui/modifiers/symbolEffect.ts +53 -27
- package/src/swift-ui/modifiers/symbolEffectOptions.ts +22 -0
- package/src/universal/Picker/Picker.android.tsx +9 -2
- package/src/universal/Picker/Picker.ios.tsx +5 -0
- package/src/universal/Picker/Picker.tsx +2 -0
- package/src/universal/Picker/types.ts +5 -0
- package/ios/Modifiers/HostViewContentMarginsMitigation.swift +0 -98
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27-sources.jar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27-sources.jar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27-sources.jar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27-sources.jar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.aar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.aar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.aar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.aar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.module.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.27/expo.modules.ui-58.0.27.pom.sha512 +0 -1
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Pressable, View } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Box } from '../../jetpack-compose/Box';
|
|
5
|
+
import {
|
|
6
|
+
DropdownMenuGroup,
|
|
7
|
+
DropdownMenuPopup,
|
|
8
|
+
SelectableDropdownMenuItem,
|
|
9
|
+
type MenuShapePosition,
|
|
10
|
+
type SelectableDropdownMenuItemColors,
|
|
11
|
+
} from '../../jetpack-compose/DropdownMenu';
|
|
6
12
|
import {
|
|
7
13
|
DropdownMenuItem,
|
|
8
14
|
type DropdownMenuItemElementColors,
|
|
@@ -10,14 +16,23 @@ import {
|
|
|
10
16
|
import { Host } from '../../jetpack-compose/Host';
|
|
11
17
|
import { Icon } from '../../jetpack-compose/Icon';
|
|
12
18
|
import { RNHostView } from '../../jetpack-compose/RNHostView';
|
|
19
|
+
import { Spacer } from '../../jetpack-compose/Spacer';
|
|
13
20
|
import { Text as ComposeText } from '../../jetpack-compose/Text';
|
|
14
21
|
import { useMaterialColors } from '../../jetpack-compose/colors';
|
|
22
|
+
import { height, verticalScroll } from '../../jetpack-compose/modifiers';
|
|
15
23
|
import type { PopupProperties } from '../../types';
|
|
16
24
|
import type { MenuAction, MenuComponentProps, MenuComponentRef, NativeActionEvent } from './types';
|
|
17
25
|
|
|
18
26
|
// Clipped popups drop the status bar offset, so edge-to-edge menus near the bottom detach from the anchor.
|
|
19
27
|
const POPUP_PROPERTIES: PopupProperties = { clippingEnabled: false };
|
|
20
28
|
|
|
29
|
+
const CHECK_ICON = require('../../../assets/check.xml');
|
|
30
|
+
|
|
31
|
+
// Compose's `MenuDefaults.GroupSpacing`.
|
|
32
|
+
const MENU_GROUP_SPACING = 2;
|
|
33
|
+
// Compose's `MenuDefaults.LeadingIconSize`.
|
|
34
|
+
const MENU_ITEM_ICON_SIZE = 20;
|
|
35
|
+
|
|
21
36
|
function actionId(action: MenuAction): string {
|
|
22
37
|
return action.id ?? action.title;
|
|
23
38
|
}
|
|
@@ -47,103 +62,177 @@ function buildElementColors(
|
|
|
47
62
|
};
|
|
48
63
|
}
|
|
49
64
|
|
|
50
|
-
|
|
51
|
-
action: MenuAction
|
|
65
|
+
function buildSelectableColors(
|
|
66
|
+
action: MenuAction,
|
|
67
|
+
destructiveColor: string
|
|
68
|
+
): SelectableDropdownMenuItemColors | undefined {
|
|
69
|
+
const colors = buildElementColors(action, destructiveColor);
|
|
70
|
+
if (colors == null) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
// A selected item keeps the destructive or custom colors instead of the selected-state colors.
|
|
74
|
+
return {
|
|
75
|
+
...colors,
|
|
76
|
+
selectedTextColor: colors.textColor,
|
|
77
|
+
selectedLeadingIconColor: colors.leadingIconColor,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type MenuGroup = { key: string; actions: MenuAction[] };
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Splits actions into the groups of a Material 3 Expressive menu. A `displayInline` action
|
|
85
|
+
* becomes a group of its own. Other actions that follow each other share a group.
|
|
86
|
+
*/
|
|
87
|
+
function groupActions(actions: MenuAction[], keyPrefix = ''): MenuGroup[] {
|
|
88
|
+
const groups: MenuGroup[] = [];
|
|
89
|
+
let run: MenuAction[] = [];
|
|
90
|
+
// The key of a run of actions comes from the inline action before it, not from its first action.
|
|
91
|
+
// So the group does not remount, and an open submenu in it does not close, when an action hides.
|
|
92
|
+
let runKey = `${keyPrefix}^`;
|
|
93
|
+
for (const action of actions) {
|
|
94
|
+
if (action.attributes?.hidden) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (action.displayInline && action.subactions && action.subactions.length > 0) {
|
|
98
|
+
if (run.length > 0) {
|
|
99
|
+
groups.push({ key: runKey, actions: run });
|
|
100
|
+
run = [];
|
|
101
|
+
}
|
|
102
|
+
const sectionKey = `${keyPrefix}${actionId(action)}`;
|
|
103
|
+
groups.push(...groupActions(action.subactions, `${sectionKey}/`));
|
|
104
|
+
runKey = `${sectionKey}$`;
|
|
105
|
+
} else {
|
|
106
|
+
run.push(action);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (run.length > 0) {
|
|
110
|
+
groups.push({ key: runKey, actions: run });
|
|
111
|
+
}
|
|
112
|
+
return groups;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
type MenuHandlers = {
|
|
52
116
|
onPressAction: MenuComponentProps['onPressAction'];
|
|
53
117
|
dismissAll: () => void;
|
|
54
118
|
destructiveColor: string;
|
|
55
119
|
};
|
|
56
120
|
|
|
57
|
-
function
|
|
58
|
-
const
|
|
121
|
+
function MenuGroups({ actions, ...handlers }: MenuHandlers & { actions: MenuAction[] }) {
|
|
122
|
+
const groups = groupActions(actions);
|
|
123
|
+
return groups.map((group, groupIndex) => (
|
|
124
|
+
<React.Fragment key={group.key}>
|
|
125
|
+
{groupIndex > 0 && <Spacer modifiers={[height(MENU_GROUP_SPACING)]} />}
|
|
126
|
+
<DropdownMenuGroup shapes={{ index: groupIndex, count: groups.length }}>
|
|
127
|
+
{group.actions.map((action, index) => (
|
|
128
|
+
<MenuActionItem
|
|
129
|
+
key={actionId(action)}
|
|
130
|
+
action={action}
|
|
131
|
+
shape={{ index, count: group.actions.length }}
|
|
132
|
+
{...handlers}
|
|
133
|
+
/>
|
|
134
|
+
))}
|
|
135
|
+
</DropdownMenuGroup>
|
|
136
|
+
</React.Fragment>
|
|
137
|
+
));
|
|
138
|
+
}
|
|
59
139
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
140
|
+
function MenuActionItem({
|
|
141
|
+
action,
|
|
142
|
+
shape,
|
|
143
|
+
onPressAction,
|
|
144
|
+
dismissAll,
|
|
145
|
+
destructiveColor,
|
|
146
|
+
}: MenuHandlers & { action: MenuAction; shape: MenuShapePosition }) {
|
|
147
|
+
const [submenuExpanded, setSubmenuExpanded] = React.useState(false);
|
|
63
148
|
|
|
64
|
-
const { subactions,
|
|
149
|
+
const { subactions, state, attributes, title, image, imageColor } = action;
|
|
65
150
|
// `image` is non-string only when caller passes an ImageSourcePropType
|
|
66
151
|
// (number from `require()` or `{ uri }`). The string form is iOS-only (SF Symbol).
|
|
67
152
|
const leadingIconSource = typeof image === 'string' || image == null ? null : image;
|
|
68
153
|
const elementColors = buildElementColors(action, destructiveColor);
|
|
154
|
+
const leadingIcon = leadingIconSource && (
|
|
155
|
+
<Icon source={leadingIconSource} size={MENU_ITEM_ICON_SIZE} tint={imageColor} />
|
|
156
|
+
);
|
|
69
157
|
|
|
70
158
|
if (subactions && subactions.length > 0) {
|
|
71
|
-
if (displayInline) {
|
|
72
|
-
return (
|
|
73
|
-
<>
|
|
74
|
-
<HorizontalDivider />
|
|
75
|
-
{subactions.map((sub) => (
|
|
76
|
-
<MenuActionItem
|
|
77
|
-
key={actionId(sub)}
|
|
78
|
-
action={sub}
|
|
79
|
-
onPressAction={onPressAction}
|
|
80
|
-
dismissAll={dismissAll}
|
|
81
|
-
destructiveColor={destructiveColor}
|
|
82
|
-
/>
|
|
83
|
-
))}
|
|
84
|
-
<HorizontalDivider />
|
|
85
|
-
</>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
159
|
return (
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
dismissAll
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
160
|
+
<Box>
|
|
161
|
+
<DropdownMenuItem
|
|
162
|
+
enabled={!attributes?.disabled}
|
|
163
|
+
shape={shape}
|
|
164
|
+
elementColors={elementColors}
|
|
165
|
+
onClick={() => setSubmenuExpanded(true)}>
|
|
166
|
+
<DropdownMenuItem.Text>
|
|
167
|
+
<ComposeText>{title}</ComposeText>
|
|
168
|
+
</DropdownMenuItem.Text>
|
|
169
|
+
{leadingIcon && (
|
|
170
|
+
<DropdownMenuItem.LeadingIcon>{leadingIcon}</DropdownMenuItem.LeadingIcon>
|
|
171
|
+
)}
|
|
172
|
+
</DropdownMenuItem>
|
|
173
|
+
<DropdownMenuPopup
|
|
174
|
+
expanded={submenuExpanded}
|
|
175
|
+
onDismissRequest={() => setSubmenuExpanded(false)}
|
|
176
|
+
anchorPosition="end"
|
|
177
|
+
properties={POPUP_PROPERTIES}
|
|
178
|
+
// Unlike `DropdownMenu`, `DropdownMenuPopup` does not scroll a menu taller than the window.
|
|
179
|
+
modifiers={[verticalScroll()]}>
|
|
180
|
+
<MenuGroups
|
|
181
|
+
actions={subactions}
|
|
182
|
+
onPressAction={onPressAction}
|
|
183
|
+
dismissAll={() => {
|
|
184
|
+
setSubmenuExpanded(false);
|
|
185
|
+
dismissAll();
|
|
186
|
+
}}
|
|
187
|
+
destructiveColor={destructiveColor}
|
|
188
|
+
/>
|
|
189
|
+
</DropdownMenuPopup>
|
|
190
|
+
</Box>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const onClick = () => {
|
|
195
|
+
onPressAction?.(makeEvent(action));
|
|
196
|
+
dismissAll();
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// An action with a `state` is a choice. Compose gives a selected choice a highlighted container
|
|
200
|
+
// and `SelectedLeadingIcon`, which replaces the leading icon while the item is selected, and
|
|
201
|
+
// exposes the selected state to screen readers.
|
|
202
|
+
if (state != null) {
|
|
203
|
+
const colors = buildSelectableColors(action, destructiveColor);
|
|
204
|
+
return (
|
|
205
|
+
<SelectableDropdownMenuItem
|
|
206
|
+
selected={state === 'on'}
|
|
207
|
+
enabled={!attributes?.disabled}
|
|
208
|
+
shapes={shape}
|
|
209
|
+
colors={colors}
|
|
210
|
+
onClick={onClick}>
|
|
211
|
+
<SelectableDropdownMenuItem.Text>
|
|
212
|
+
<ComposeText>{title}</ComposeText>
|
|
213
|
+
</SelectableDropdownMenuItem.Text>
|
|
214
|
+
{leadingIcon && (
|
|
215
|
+
<SelectableDropdownMenuItem.LeadingIcon>
|
|
216
|
+
{leadingIcon}
|
|
217
|
+
</SelectableDropdownMenuItem.LeadingIcon>
|
|
218
|
+
)}
|
|
219
|
+
<SelectableDropdownMenuItem.SelectedLeadingIcon>
|
|
220
|
+
<Icon source={CHECK_ICON} size={MENU_ITEM_ICON_SIZE} />
|
|
221
|
+
</SelectableDropdownMenuItem.SelectedLeadingIcon>
|
|
222
|
+
</SelectableDropdownMenuItem>
|
|
123
223
|
);
|
|
124
224
|
}
|
|
125
225
|
|
|
126
226
|
return (
|
|
127
227
|
<DropdownMenuItem
|
|
128
228
|
enabled={!attributes?.disabled}
|
|
229
|
+
shape={shape}
|
|
129
230
|
elementColors={elementColors}
|
|
130
|
-
onClick={
|
|
131
|
-
onPressAction?.(makeEvent(action));
|
|
132
|
-
dismissAll();
|
|
133
|
-
}}>
|
|
231
|
+
onClick={onClick}>
|
|
134
232
|
<DropdownMenuItem.Text>
|
|
135
233
|
<ComposeText>{title}</ComposeText>
|
|
136
234
|
</DropdownMenuItem.Text>
|
|
137
|
-
{
|
|
138
|
-
<DropdownMenuItem.LeadingIcon>
|
|
139
|
-
<Icon source={leadingIconSource} size={24} tint={imageColor} />
|
|
140
|
-
</DropdownMenuItem.LeadingIcon>
|
|
141
|
-
)}
|
|
142
|
-
{state === 'on' && (
|
|
143
|
-
<DropdownMenuItem.TrailingIcon>
|
|
144
|
-
<ComposeText>✓</ComposeText>
|
|
145
|
-
</DropdownMenuItem.TrailingIcon>
|
|
146
|
-
)}
|
|
235
|
+
{leadingIcon && <DropdownMenuItem.LeadingIcon>{leadingIcon}</DropdownMenuItem.LeadingIcon>}
|
|
147
236
|
</DropdownMenuItem>
|
|
148
237
|
);
|
|
149
238
|
}
|
|
@@ -151,7 +240,7 @@ function MenuActionItem({ action, onPressAction, dismissAll, destructiveColor }:
|
|
|
151
240
|
/**
|
|
152
241
|
* A drop-in replacement for `@react-native-menu/menu` on Android.
|
|
153
242
|
* Wraps the trigger in a `Pressable` (whose `onPress`/`onLongPress` opens the menu) and
|
|
154
|
-
* renders the actions tree as a controlled Material `
|
|
243
|
+
* renders the actions tree as a controlled Material 3 Expressive `DropdownMenuPopup`.
|
|
155
244
|
*
|
|
156
245
|
* Note: when `action.image` is a string, it is treated as an iOS SF Symbol and ignored
|
|
157
246
|
* on Android — pass an `ImageSourcePropType` (e.g. `require('./icon.xml')`) to render
|
|
@@ -198,37 +287,34 @@ export function MenuView(props: MenuComponentProps & { ref?: React.Ref<MenuCompo
|
|
|
198
287
|
return (
|
|
199
288
|
<View style={style} testID={testID}>
|
|
200
289
|
<Host colorScheme={colorScheme} matchContents>
|
|
201
|
-
<
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
))}
|
|
230
|
-
</DropdownMenu.Items>
|
|
231
|
-
</DropdownMenu>
|
|
290
|
+
<Box>
|
|
291
|
+
<RNHostView matchContents>
|
|
292
|
+
<Pressable
|
|
293
|
+
onPress={shouldOpenOnLongPress ? undefined : open}
|
|
294
|
+
onLongPress={shouldOpenOnLongPress ? open : undefined}
|
|
295
|
+
// Mirror upstream `@react-native-menu/menu`, which intercepts touches
|
|
296
|
+
// natively on a bare `ReactViewGroup`: no click sound, no focus
|
|
297
|
+
// highlight, no extra a11y node — children declare their own role.
|
|
298
|
+
android_disableSound
|
|
299
|
+
focusable={false}
|
|
300
|
+
accessible={false}>
|
|
301
|
+
{children}
|
|
302
|
+
</Pressable>
|
|
303
|
+
</RNHostView>
|
|
304
|
+
<DropdownMenuPopup
|
|
305
|
+
expanded={expanded}
|
|
306
|
+
onDismissRequest={dismissAll}
|
|
307
|
+
properties={POPUP_PROPERTIES}
|
|
308
|
+
// Unlike `DropdownMenu`, `DropdownMenuPopup` does not scroll a menu taller than the window.
|
|
309
|
+
modifiers={[verticalScroll()]}>
|
|
310
|
+
<MenuGroups
|
|
311
|
+
actions={actions}
|
|
312
|
+
onPressAction={onPressAction}
|
|
313
|
+
dismissAll={dismissAll}
|
|
314
|
+
destructiveColor={destructiveColor}
|
|
315
|
+
/>
|
|
316
|
+
</DropdownMenuPopup>
|
|
317
|
+
</Box>
|
|
232
318
|
</Host>
|
|
233
319
|
</View>
|
|
234
320
|
);
|
|
@@ -135,6 +135,14 @@ export interface DropdownMenuPopupProps {
|
|
|
135
135
|
*/
|
|
136
136
|
onDismissRequest?: () => void;
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* The side of the anchor where the menu opens, through Compose's `MenuAnchorPosition`. When
|
|
140
|
+
* there is not sufficient space on that side, Compose moves the menu to a different side. Use
|
|
141
|
+
* `'end'` for a submenu that opens next to its item.
|
|
142
|
+
* @default 'below'
|
|
143
|
+
*/
|
|
144
|
+
anchorPosition?: 'below' | 'above' | 'start' | 'end' | 'left' | 'right';
|
|
145
|
+
|
|
138
146
|
/**
|
|
139
147
|
* Properties for the popup window of the menu.
|
|
140
148
|
*/
|
|
@@ -149,6 +157,7 @@ export interface DropdownMenuPopupProps {
|
|
|
149
157
|
type NativeMenuPopupProps = {
|
|
150
158
|
expanded?: boolean;
|
|
151
159
|
onDismissRequest?: () => void;
|
|
160
|
+
anchorPosition?: DropdownMenuPopupProps['anchorPosition'];
|
|
152
161
|
properties?: PopupProperties;
|
|
153
162
|
modifiers?: ModifierConfig[];
|
|
154
163
|
children?: ReactNode;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
|
|
3
|
+
import type { ModifierConfig, ViewEvent } from '../../types';
|
|
4
|
+
import type { SliderColors } from '../Slider';
|
|
5
|
+
import { createViewModifierEventListener } from '../modifiers/utils';
|
|
6
|
+
|
|
7
|
+
export type { SliderColors };
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* An inclusive numeric range for `RangeSlider`.
|
|
11
|
+
*/
|
|
12
|
+
export type RangeSliderRange = {
|
|
13
|
+
/** The start of the range. */
|
|
14
|
+
start: number;
|
|
15
|
+
/** The end of the range, included in the selection. */
|
|
16
|
+
endInclusive: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export interface RangeSliderProps {
|
|
20
|
+
/**
|
|
21
|
+
* The selected start value. Changing this prop updates the native selection when the user is not dragging.
|
|
22
|
+
* @default 0
|
|
23
|
+
*/
|
|
24
|
+
startValue?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The selected end value. Changing this prop updates the native selection when the user is not dragging.
|
|
27
|
+
* @default 1
|
|
28
|
+
*/
|
|
29
|
+
endValue?: number;
|
|
30
|
+
/**
|
|
31
|
+
* The bounds of the entire track. The slider clamps values outside these bounds.
|
|
32
|
+
* @default \{ start: 0, endInclusive: 1 \}
|
|
33
|
+
*/
|
|
34
|
+
trackRange?: RangeSliderRange;
|
|
35
|
+
/**
|
|
36
|
+
* The number of selectable positions between the track bounds.
|
|
37
|
+
* Must be a nonnegative integer. `0` means continuous selection.
|
|
38
|
+
* @default 0
|
|
39
|
+
*/
|
|
40
|
+
steps?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the slider responds to user interaction.
|
|
43
|
+
* @default true
|
|
44
|
+
*/
|
|
45
|
+
enabled?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Colors for the thumbs, track, and tick marks. Omitted colors use the Material theme.
|
|
48
|
+
*/
|
|
49
|
+
colors?: SliderColors;
|
|
50
|
+
/**
|
|
51
|
+
* Called with both endpoints when the user changes the selection.
|
|
52
|
+
*/
|
|
53
|
+
onValueChange?: (range: RangeSliderRange) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Called when the user finishes changing the selection.
|
|
56
|
+
* It has no value argument. `onValueChange` reports the selection.
|
|
57
|
+
*/
|
|
58
|
+
onValueChangeFinished?: () => void;
|
|
59
|
+
/**
|
|
60
|
+
* Modifiers for the component.
|
|
61
|
+
*/
|
|
62
|
+
modifiers?: ModifierConfig[];
|
|
63
|
+
/**
|
|
64
|
+
* Custom content wrapped in `RangeSlider.StartThumb`, `RangeSlider.EndThumb`, or `RangeSlider.Track`.
|
|
65
|
+
*/
|
|
66
|
+
children?: React.ReactNode;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type NativeRangeSliderProps = Omit<RangeSliderProps, 'onValueChange' | 'onValueChangeFinished'> &
|
|
70
|
+
ViewEvent<'onValueChange', RangeSliderRange> &
|
|
71
|
+
ViewEvent<'onValueChangeFinished', void>;
|
|
72
|
+
|
|
73
|
+
const RangeSliderNativeView: React.ComponentType<NativeRangeSliderProps> = requireNativeView(
|
|
74
|
+
'ExpoUI',
|
|
75
|
+
'RangeSliderView'
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const SlotNativeView: React.ComponentType<{ slotName: string; children: React.ReactNode }> =
|
|
79
|
+
requireNativeView('ExpoUI', 'SlotView');
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Custom content for the start thumb of a `RangeSlider`.
|
|
83
|
+
* @platform android
|
|
84
|
+
*/
|
|
85
|
+
function StartThumb(props: { children: React.ReactNode }) {
|
|
86
|
+
return <SlotNativeView slotName="startThumb">{props.children}</SlotNativeView>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Custom content for the end thumb of a `RangeSlider`.
|
|
91
|
+
* @platform android
|
|
92
|
+
*/
|
|
93
|
+
function EndThumb(props: { children: React.ReactNode }) {
|
|
94
|
+
return <SlotNativeView slotName="endThumb">{props.children}</SlotNativeView>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Custom content for the track of a `RangeSlider`.
|
|
99
|
+
* @platform android
|
|
100
|
+
*/
|
|
101
|
+
function Track(props: { children: React.ReactNode }) {
|
|
102
|
+
return <SlotNativeView slotName="track">{props.children}</SlotNativeView>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* A Material 3 slider for selecting two values on a bounded track.
|
|
107
|
+
* It works only inside a `Host` component.
|
|
108
|
+
* @platform android
|
|
109
|
+
*/
|
|
110
|
+
export function RangeSlider(props: RangeSliderProps) {
|
|
111
|
+
const { modifiers, onValueChange, onValueChangeFinished, ...restProps } = props;
|
|
112
|
+
return (
|
|
113
|
+
<RangeSliderNativeView
|
|
114
|
+
{...restProps}
|
|
115
|
+
modifiers={modifiers}
|
|
116
|
+
{...(modifiers ? createViewModifierEventListener(modifiers) : undefined)}
|
|
117
|
+
onValueChange={onValueChange ? ({ nativeEvent }) => onValueChange(nativeEvent) : undefined}
|
|
118
|
+
onValueChangeFinished={onValueChangeFinished ? () => onValueChangeFinished() : undefined}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
RangeSlider.StartThumb = StartThumb;
|
|
124
|
+
RangeSlider.EndThumb = EndThumb;
|
|
125
|
+
RangeSlider.Track = Track;
|
|
@@ -19,11 +19,26 @@ const SlotNativeView: React.ComponentType<SlotNativeViewProps> = requireNativeVi
|
|
|
19
19
|
* @platform android
|
|
20
20
|
*/
|
|
21
21
|
export type SliderColors = {
|
|
22
|
+
/** The thumb color when enabled. */
|
|
22
23
|
thumbColor?: ColorValue;
|
|
24
|
+
/** The active track color when enabled. */
|
|
23
25
|
activeTrackColor?: ColorValue;
|
|
26
|
+
/** The inactive track color when enabled. */
|
|
24
27
|
inactiveTrackColor?: ColorValue;
|
|
28
|
+
/** The active tick color when enabled. */
|
|
25
29
|
activeTickColor?: ColorValue;
|
|
30
|
+
/** The inactive tick color when enabled. */
|
|
26
31
|
inactiveTickColor?: ColorValue;
|
|
32
|
+
/** The thumb color when disabled. */
|
|
33
|
+
disabledThumbColor?: ColorValue;
|
|
34
|
+
/** The active track color when disabled. */
|
|
35
|
+
disabledActiveTrackColor?: ColorValue;
|
|
36
|
+
/** The inactive track color when disabled. */
|
|
37
|
+
disabledInactiveTrackColor?: ColorValue;
|
|
38
|
+
/** The active tick color when disabled. */
|
|
39
|
+
disabledActiveTickColor?: ColorValue;
|
|
40
|
+
/** The inactive tick color when disabled. */
|
|
41
|
+
disabledInactiveTickColor?: ColorValue;
|
|
27
42
|
};
|
|
28
43
|
|
|
29
44
|
export interface SliderProps {
|
|
@@ -23,6 +23,7 @@ export * from './RNHostView';
|
|
|
23
23
|
export * from './DatePicker';
|
|
24
24
|
export * from './SegmentedButton';
|
|
25
25
|
export * from './Progress';
|
|
26
|
+
export * from './RangeSlider';
|
|
26
27
|
export * from './Slider';
|
|
27
28
|
export * from './Spacer';
|
|
28
29
|
export * from './SplitButtonLayout';
|
|
@@ -653,5 +653,18 @@ export const verticalScroll = () => createModifier('verticalScroll');
|
|
|
653
653
|
*/
|
|
654
654
|
export const horizontalScroll = () => createModifier('horizontalScroll');
|
|
655
655
|
|
|
656
|
+
/**
|
|
657
|
+
* Hides the keyboard and clears focus when the user starts to drag the scrollable content.
|
|
658
|
+
*
|
|
659
|
+
* When used with `verticalScroll()` or `horizontalScroll()` modifier, it must be placed
|
|
660
|
+
* before them in the modifier list.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* ```tsx
|
|
664
|
+
* modifiers={[scrollDismissesKeyboard(), verticalScroll()]}
|
|
665
|
+
* ```
|
|
666
|
+
*/
|
|
667
|
+
export const scrollDismissesKeyboard = () => createModifier('scrollDismissesKeyboard');
|
|
668
|
+
|
|
656
669
|
export { createModifier, createModifierWithEventListener } from './createModifier';
|
|
657
670
|
export { createViewModifierEventListener } from './utils';
|
|
@@ -23,7 +23,12 @@ import { progressViewStyle } from './progressViewStyle';
|
|
|
23
23
|
import { onScrollPhaseChange, useScrollGeometryChange } from './scrollObservation';
|
|
24
24
|
import { id, scrollPosition } from './scrollPosition';
|
|
25
25
|
import { resolveShapeStyle, type ShapeStyle } from './shapeStyle';
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
symbolEffect,
|
|
28
|
+
type ContentTransitionSymbolEffect,
|
|
29
|
+
type SymbolEffectOptions,
|
|
30
|
+
} from './symbolEffect';
|
|
31
|
+
import { flattenOptions } from './symbolEffectOptions';
|
|
27
32
|
import type { Color } from './types';
|
|
28
33
|
import { activityBackgroundTint, widgetAccentedRenderingMode, widgetURL } from './widgets';
|
|
29
34
|
|
|
@@ -1712,9 +1717,11 @@ export const textContentType = (
|
|
|
1712
1717
|
* Useful for animating changes in text content, especially numeric text.
|
|
1713
1718
|
* Use with the [`animation`](#animationanimationobject-animatedvalue) modifier to animate the transition when the content changes.
|
|
1714
1719
|
*
|
|
1715
|
-
* @param transitionType - The type of content transition.
|
|
1720
|
+
* @param transitionType - The type of content transition. The `'symbolEffect'` type applies a symbol effect transition to symbol images. Other views are unaffected by this transition. It requires iOS 17.0+, tvOS 17.0+, and macOS 14.0+. On earlier versions, the view does not change.
|
|
1716
1721
|
* @param params - Optional parameters.
|
|
1717
1722
|
* @param params.countsDown - Whether the numeric text counts down.
|
|
1723
|
+
* @param params.symbolEffect - The symbol effect to use with the `'symbolEffect'` type. Defaults to `{ effect: 'automatic' }`.
|
|
1724
|
+
* @param params.options - A set of options that configure how effects apply to symbol-based images. Use it with the `'symbolEffect'` type.
|
|
1718
1725
|
*
|
|
1719
1726
|
* @example
|
|
1720
1727
|
* ```tsx
|
|
@@ -1723,17 +1730,34 @@ export const textContentType = (
|
|
|
1723
1730
|
* </Text>
|
|
1724
1731
|
* ```
|
|
1725
1732
|
*
|
|
1733
|
+
* @example
|
|
1734
|
+
* ```tsx
|
|
1735
|
+
* <Image
|
|
1736
|
+
* systemName={isOn ? 'speaker.wave.2.fill' : 'speaker.slash.fill'}
|
|
1737
|
+
* modifiers={[
|
|
1738
|
+
* contentTransition('symbolEffect', { symbolEffect: { effect: 'replace', direction: 'downUp' } }),
|
|
1739
|
+
* animation(Animation.default, isOn),
|
|
1740
|
+
* ]}
|
|
1741
|
+
* />
|
|
1742
|
+
* ```
|
|
1743
|
+
*
|
|
1726
1744
|
* @platform ios 16.0+
|
|
1727
1745
|
* @platform tvos 16.0+
|
|
1728
1746
|
* @see Official [SwiftUI documentation](https://developer.apple.com/documentation/swiftui/view/contenttransition(_:)).
|
|
1729
1747
|
*/
|
|
1730
1748
|
export const contentTransition = (
|
|
1731
|
-
transitionType: 'numericText' | 'identity' | 'opacity' | 'interpolate',
|
|
1732
|
-
params?: {
|
|
1749
|
+
transitionType: 'numericText' | 'identity' | 'opacity' | 'interpolate' | 'symbolEffect',
|
|
1750
|
+
params?: {
|
|
1751
|
+
countsDown?: boolean;
|
|
1752
|
+
symbolEffect?: ContentTransitionSymbolEffect;
|
|
1753
|
+
options?: SymbolEffectOptions;
|
|
1754
|
+
}
|
|
1733
1755
|
) =>
|
|
1734
1756
|
createModifier('contentTransition', {
|
|
1735
1757
|
transitionType,
|
|
1736
1758
|
countsDown: params?.countsDown,
|
|
1759
|
+
symbolEffect: params?.symbolEffect,
|
|
1760
|
+
options: flattenOptions(params?.options),
|
|
1737
1761
|
});
|
|
1738
1762
|
|
|
1739
1763
|
export type ListStyle = 'automatic' | 'plain' | 'inset' | 'insetGrouped' | 'grouped' | 'sidebar';
|