Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions apps/mobile/src/components/ui/MenuPopup.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,31 @@ import {
Text,
} from "@expo/ui/jetpack-compose";
import { defaultMinSize, padding, size, width } from "@expo/ui/jetpack-compose/modifiers";
import { View } from "react-native";
import { Pressable } from "react-native";
import { resolveScaledTextRole } from "../../lib/appearancePreferences";

import { useAndroidControlSizing } from "./useAndroidControlSizing";
import { useAppearancePreferences } from "../../features/settings/appearance/AppearancePreferencesProvider";
import type { MenuPopupProps } from "./MenuPopup";
import { isAppSymbolName, SymbolView, type AppSymbolName } from "./AppSymbol";

// The glyph is a React Native view hosted in the Compose row, and its native host consumes
// every touch over it, so the row's onClick never sees a tap on the icon. The glyph runs the
// row's action itself; the row stays the accessible element.
function MenuIcon(props: {
readonly name: AppSymbolName;
readonly onPress: () => void;
readonly destructive?: boolean;
readonly disabled?: boolean;
}) {
const { iconSize } = useAndroidControlSizing();
return (
<RNHostView matchContents modifiers={[size(iconSize, iconSize)]}>
<View
<Pressable
accessible={false}
focusable={false}
disabled={props.disabled}
onPress={props.onPress}
style={{ width: iconSize, height: iconSize }}
importantForAccessibility="no-hide-descendants"
>
Expand All @@ -40,7 +48,7 @@ function MenuIcon(props: {
: "accent-foreground"
}
/>
</View>
</Pressable>
</RNHostView>
);
}
Expand All @@ -60,7 +68,7 @@ export function MenuPopup(props: MenuPopupProps) {
{props.parent ? (
<DropdownMenuItem onClick={props.onBack} modifiers={itemModifiers}>
<DropdownMenuItem.LeadingIcon>
<MenuIcon name="arrow.left" />
<MenuIcon name="arrow.left" onPress={props.onBack} />
</DropdownMenuItem.LeadingIcon>
<DropdownMenuItem.Text>
<Text color={foreground} style={{ typography: "bodyLarge", ...body }}>
Expand Down Expand Up @@ -88,6 +96,7 @@ export function MenuPopup(props: MenuPopupProps) {
<DropdownMenuItem.LeadingIcon>
<MenuIcon
name={action.image}
onPress={() => props.onPress(action)}
destructive={action.attributes?.destructive}
disabled={action.attributes?.disabled}
/>
Expand Down Expand Up @@ -116,11 +125,19 @@ export function MenuPopup(props: MenuPopupProps) {
</DropdownMenuItem.Text>
{(action.subactions?.length ?? 0) > 0 ? (
<DropdownMenuItem.TrailingIcon>
<MenuIcon name="chevron.right" disabled={action.attributes?.disabled} />
<MenuIcon
name="chevron.right"
onPress={() => props.onPress(action)}
disabled={action.attributes?.disabled}
/>
</DropdownMenuItem.TrailingIcon>
) : action.state === "on" ? (
<DropdownMenuItem.TrailingIcon>
<MenuIcon name="checkmark" disabled={action.attributes?.disabled} />
<MenuIcon
name="checkmark"
onPress={() => props.onPress(action)}
disabled={action.attributes?.disabled}
/>
</DropdownMenuItem.TrailingIcon>
) : null}
</DropdownMenuItem>
Expand Down
Loading