GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — opencode-mobile/runtime/shell/haptic-tab.tsx at main · drpr/opencode-mobile

Expand file tree

/

haptic-tab.tsx

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
46 lines (44 loc) · 1.86 KB
/

haptic-tab.tsx

Copy path

File metadata and controls

46 lines (44 loc) · 1.86 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Tabs, usePathname } from 'expo-router';
import * as Haptics from '@/shared/platform/haptics';
import type { ComponentProps } from 'react';
import { Platform, Pressable } from 'react-native';
// Derived from expo-router's own tab screen options. expo-router 57 vendors
// react-navigation and is no longer compatible with the standalone
// @react-navigation packages, so the button is rendered with RN Pressable.
type TabBarButtonProps = Parameters<
NonNullable<
Exclude<
NonNullable<ComponentProps<typeof Tabs.Screen>['options']>,
(...args: never[]) => unknown
>['tabBarButton']
>
>[0];
export function HapticTab({ onPressIn, route, ...props }: TabBarButtonProps & { route: string }) {
const pathname = usePathname();
const selected = route === '/' ? pathname === '/' || pathname.startsWith('/session/') : pathname.startsWith(route);
return (
<Pressable
{...(props as ComponentProps<typeof Pressable>)}
onPress={(event) => {
// Pressable renders the tab's href as an anchor on web. Keep the
// navigation handler in charge instead of also reloading the document.
if (Platform.OS === 'web') event.preventDefault();
props.onPress?.(event);
}}
{...(Platform.OS === 'web' ? { accessibilityState: { ...props.accessibilityState, selected }, 'aria-selected': selected } : {})}
ref={(node) => {
if (Platform.OS === 'web' && node) {
// Expo Router's static web tabs retain the initial route's ARIA state.
(node as unknown as HTMLElement).setAttribute('aria-selected', String(selected));
}
}}
onPressIn={(ev) => {
if (process.env.EXPO_OS === 'ios') {
// Add a soft haptic feedback when pressing down on the tabs.
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
}
onPressIn?.(ev);
}}
/>
);
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.