1- import { type MenuAction , MenuView , type NativeActionEvent } from '@expo/ui/community/menu' ;
21import { Stack , useRouter } from 'expo-router' ;
32import { useThemeColor } from 'heroui-native/hooks' ;
4- import { ChevronLeftIcon , EllipsisIcon , SquarePenIcon } from 'lucide-uniwind/png' ;
5- import { useCallback , useMemo } from 'react' ;
3+ import { Menu } from 'heroui-native/menu' ;
4+ import {
5+ ChevronLeftIcon ,
6+ EllipsisIcon ,
7+ PencilIcon ,
8+ PinIcon ,
9+ SquarePenIcon ,
10+ } from 'lucide-uniwind/png' ;
11+ import { useCallback } from 'react' ;
612import { useTranslation } from 'react-i18next' ;
7- import { StyleSheet , View } from 'react-native' ;
13+ import { Pressable , StyleSheet , View } from 'react-native' ;
814import { useSafeAreaInsets } from 'react-native-safe-area-context' ;
15+
916import { HeaderIconButton } from '../components/HeaderIconButton' ;
1017import { useMainHeaderTopicActions } from './useMainHeaderTopicActions' ;
1118
@@ -22,38 +29,6 @@ export function MainHeader() {
2229 const goBack = useCallback ( ( ) => {
2330 router . back ( ) ;
2431 } , [ router ] ) ;
25- const menuActions = useMemo < MenuAction [ ] > (
26- ( ) => [
27- {
28- id : 'rename-topic' ,
29- image : 'pencil' ,
30- title : t ( 'topic.actions.rename' ) ,
31- } ,
32- {
33- attributes : { disabled : topicActions . isPinActionDisabled } ,
34- id : 'toggle-pin-topic' ,
35- image : topicActions . isTopicPinned ? 'pin.slash' : 'pin' ,
36- state : topicActions . isTopicPinned ? 'on' : 'off' ,
37- title : t ( topicActions . isTopicPinned ? 'topic.actions.unpin' : 'topic.actions.pin' ) ,
38- } ,
39- ] ,
40- [ t , topicActions . isPinActionDisabled , topicActions . isTopicPinned ] ,
41- ) ;
42- const handleMenuAction = useCallback (
43- ( event : NativeActionEvent ) => {
44- const actionId = event . nativeEvent . event ;
45-
46- if ( actionId === 'rename-topic' ) {
47- topicActions . openRenameTopic ( ) ;
48- return ;
49- }
50-
51- if ( actionId === 'toggle-pin-topic' ) {
52- void topicActions . toggleTopicPin ( ) ;
53- }
54- } ,
55- [ topicActions ] ,
56- ) ;
5732
5833 return (
5934 < >
@@ -72,15 +47,46 @@ export function MainHeader() {
7247 < SquarePenIcon className = "size-6 text-foreground" strokeWidth = { 2 } />
7348 </ HeaderIconButton >
7449 { topicActions . isTopicActionsVisible ? (
75- < MenuView actions = { menuActions } onPressAction = { handleMenuAction } >
76- < View
77- accessibilityLabel = { t ( 'topic.actions.more' ) }
78- accessibilityRole = "button"
79- className = "size-9 items-center justify-center"
80- >
81- < EllipsisIcon className = "size-6 text-foreground" strokeWidth = { 2 } />
82- </ View >
83- </ MenuView >
50+ < Menu presentation = "popover" >
51+ < Menu . Trigger asChild >
52+ < Pressable
53+ accessibilityLabel = { t ( 'topic.actions.more' ) }
54+ accessibilityRole = "button"
55+ className = "size-9 items-center justify-center active:opacity-60"
56+ hitSlop = { 8 }
57+ testID = "topic-actions-menu"
58+ >
59+ < EllipsisIcon className = "size-6 text-foreground" strokeWidth = { 2 } />
60+ </ Pressable >
61+ </ Menu . Trigger >
62+ < Menu . Portal >
63+ < Menu . Overlay />
64+ < Menu . Content align = "end" placement = "bottom" presentation = "popover" width = { 210 } >
65+ < Menu . Item
66+ className = "flex-row items-center gap-3"
67+ onPress = { topicActions . openRenameTopic }
68+ testID = "topic-actions-rename"
69+ >
70+ < PencilIcon className = "size-5 text-foreground" strokeWidth = { 2 } />
71+ < Menu . ItemTitle > { t ( 'topic.actions.rename' ) } </ Menu . ItemTitle >
72+ </ Menu . Item >
73+ < Menu . Item
74+ className = "flex-row items-center gap-3"
75+ isDisabled = { topicActions . isPinActionDisabled }
76+ isSelected = { topicActions . isTopicPinned }
77+ onPress = { ( ) => void topicActions . toggleTopicPin ( ) }
78+ testID = "topic-actions-toggle-pin"
79+ >
80+ < PinIcon className = "size-5 text-foreground" strokeWidth = { 2 } />
81+ < Menu . ItemTitle >
82+ { t (
83+ topicActions . isTopicPinned ? 'topic.actions.unpin' : 'topic.actions.pin' ,
84+ ) }
85+ </ Menu . ItemTitle >
86+ </ Menu . Item >
87+ </ Menu . Content >
88+ </ Menu . Portal >
89+ </ Menu >
8490 ) : null }
8591 </ View >
8692 </ View >
0 commit comments