Skip to content

Commit 08d0e8a

Browse files
committed
StoryScreen: combine duplicate toolbar blocks into one
1 parent ebb72ef commit 08d0e8a

1 file changed

Lines changed: 73 additions & 70 deletions

File tree

screens/StoryScreen.jsx

Lines changed: 73 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -510,83 +510,86 @@ export default function StoryScreen() {
510510

511511
return (
512512
<Container {...containerProps}>
513-
{!isPreview && tabView === 'web' && (
513+
{!isPreview && (
514514
<Stack.Toolbar placement="right">
515-
<Stack.Toolbar.Menu icon="ellipsis">
516-
<Stack.Toolbar.MenuAction
517-
icon="arrow.clockwise"
518-
onPress={() => webViewRef.current?.reload()}
519-
>
520-
Reload page
521-
</Stack.Toolbar.MenuAction>
522-
<Stack.Toolbar.MenuAction
523-
icon="safari"
524-
onPress={() => Linking.openURL(navState.url || url)}
525-
>
526-
Open in browser&hellip;
527-
</Stack.Toolbar.MenuAction>
528-
<Stack.Toolbar.MenuAction
529-
icon="square.and.arrow.up"
530-
onPress={() => openShare({ url: navState.url || url })}
531-
>
532-
Share&hellip;
533-
</Stack.Toolbar.MenuAction>
534-
</Stack.Toolbar.Menu>
535-
</Stack.Toolbar>
536-
)}
537-
{!isPreview && tabView === 'comments' && (
538-
<Stack.Toolbar placement="right">
539-
<Stack.Toolbar.Menu icon="square.and.arrow.up">
540-
{!settingsInteractions && (
541-
<Stack.Toolbar.MenuAction onPress={() => openBrowser(hnURL)}>
542-
View on HN web site
543-
</Stack.Toolbar.MenuAction>
544-
)}
545-
{settingsInteractions && (
546-
<Stack.Toolbar.MenuAction
547-
icon="arrowtriangle.up.fill"
548-
onPress={() => {
549-
const jsKey = `web-view-${Date.now()}`;
550-
useStore.getState().setRouteInjectedJS(
551-
jsKey,
552-
`
515+
<Stack.Toolbar.Menu
516+
icon={tabView === 'web' ? 'ellipsis' : 'square.and.arrow.up'}
517+
>
518+
{tabView === 'web' ? (
519+
<>
520+
<Stack.Toolbar.MenuAction
521+
icon="arrow.clockwise"
522+
onPress={() => webViewRef.current?.reload()}
523+
>
524+
Reload page
525+
</Stack.Toolbar.MenuAction>
526+
<Stack.Toolbar.MenuAction
527+
icon="safari"
528+
onPress={() => Linking.openURL(navState.url || url)}
529+
>
530+
Open in browser&hellip;
531+
</Stack.Toolbar.MenuAction>
532+
<Stack.Toolbar.MenuAction
533+
icon="square.and.arrow.up"
534+
onPress={() => openShare({ url: navState.url || url })}
535+
>
536+
Share&hellip;
537+
</Stack.Toolbar.MenuAction>
538+
</>
539+
) : (
540+
<>
541+
{!settingsInteractions && (
542+
<Stack.Toolbar.MenuAction onPress={() => openBrowser(hnURL)}>
543+
View on HN web site
544+
</Stack.Toolbar.MenuAction>
545+
)}
546+
{settingsInteractions && (
547+
<Stack.Toolbar.MenuAction
548+
icon="arrowtriangle.up.fill"
549+
onPress={() => {
550+
const jsKey = `web-view-${Date.now()}`;
551+
useStore.getState().setRouteInjectedJS(
552+
jsKey,
553+
`
553554
try {
554555
document.getElementById('up_${id}').click();
555556
} catch (e) {}
556557
true;
557558
`,
558-
);
559-
router.push({
560-
pathname: '/web-view',
561-
params: {
562-
url: hnURL,
563-
jsKey,
564-
},
565-
});
566-
}}
567-
>
568-
Upvote story on HN
569-
</Stack.Toolbar.MenuAction>
570-
)}
571-
{settingsInteractions && (
572-
<Stack.Toolbar.MenuAction
573-
icon="arrowshape.turn.up.left"
574-
onPress={() =>
575-
router.push({
576-
pathname: '/web-view',
577-
params: { url: hnURL },
578-
})
579-
}
580-
>
581-
View or Reply story on HN
582-
</Stack.Toolbar.MenuAction>
559+
);
560+
router.push({
561+
pathname: '/web-view',
562+
params: {
563+
url: hnURL,
564+
jsKey,
565+
},
566+
});
567+
}}
568+
>
569+
Upvote story on HN
570+
</Stack.Toolbar.MenuAction>
571+
)}
572+
{settingsInteractions && (
573+
<Stack.Toolbar.MenuAction
574+
icon="arrowshape.turn.up.left"
575+
onPress={() =>
576+
router.push({
577+
pathname: '/web-view',
578+
params: { url: hnURL },
579+
})
580+
}
581+
>
582+
View or Reply story on HN
583+
</Stack.Toolbar.MenuAction>
584+
)}
585+
<Stack.Toolbar.MenuAction
586+
icon="square.and.arrow.up"
587+
onPress={() => openShare({ url: hnURL })}
588+
>
589+
Share story&hellip;
590+
</Stack.Toolbar.MenuAction>
591+
</>
583592
)}
584-
<Stack.Toolbar.MenuAction
585-
icon="square.and.arrow.up"
586-
onPress={() => openShare({ url: hnURL })}
587-
>
588-
Share story&hellip;
589-
</Stack.Toolbar.MenuAction>
590593
</Stack.Toolbar.Menu>
591594
</Stack.Toolbar>
592595
)}

0 commit comments

Comments
 (0)