From 2f68ceb890527bfafccbfdd602dcc34727e267eb Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 19 Mar 2026 13:26:22 +0200 Subject: [PATCH] delete unused screen --- src/view/com/util/ViewSelector.tsx | 238 ------------------ src/view/screens/Debug.tsx | 387 ----------------------------- 2 files changed, 625 deletions(-) delete mode 100644 src/view/com/util/ViewSelector.tsx delete mode 100644 src/view/screens/Debug.tsx diff --git a/src/view/com/util/ViewSelector.tsx b/src/view/com/util/ViewSelector.tsx deleted file mode 100644 index 98d78a38cd..0000000000 --- a/src/view/com/util/ViewSelector.tsx +++ /dev/null @@ -1,238 +0,0 @@ -import { - forwardRef, - type JSX, - useCallback, - useEffect, - useImperativeHandle, - useMemo, - useRef, - useState, -} from 'react' -import { - type NativeScrollEvent, - type NativeSyntheticEvent, - Pressable, - RefreshControl, - ScrollView, - StyleSheet, - View, -} from 'react-native' - -import {useColorSchemeStyle} from '#/lib/hooks/useColorSchemeStyle' -import {usePalette} from '#/lib/hooks/usePalette' -import {clamp} from '#/lib/numbers' -import {colors, s} from '#/lib/styles' -import {IS_ANDROID} from '#/env' -import {Text} from './text/Text' -import {FlatList_INTERNAL} from './Views' - -const HEADER_ITEM = {_reactKey: '__header__'} -const SELECTOR_ITEM = {_reactKey: '__selector__'} -const STICKY_HEADER_INDICES = [1] - -export type ViewSelectorHandle = { - scrollToTop: () => void -} - -export const ViewSelector = forwardRef< - ViewSelectorHandle, - { - sections: string[] - items: any[] - refreshing?: boolean - swipeEnabled?: boolean - renderHeader?: () => JSX.Element - renderItem: (item: any) => JSX.Element - ListFooterComponent?: - | React.ComponentType - | React.ReactElement - | null - | undefined - onSelectView?: (viewIndex: number) => void - onScroll?: (event: NativeSyntheticEvent) => void - onRefresh?: () => void - onEndReached?: (info: {distanceFromEnd: number}) => void - } ->(function ViewSelectorImpl( - { - sections, - items, - refreshing, - renderHeader, - renderItem, - ListFooterComponent, - onSelectView, - onScroll, - onRefresh, - onEndReached, - }, - ref, -) { - const pal = usePalette('default') - const [selectedIndex, setSelectedIndex] = useState(0) - const flatListRef = useRef(null) - - // events - // = - - const keyExtractor = useCallback((item: any) => item._reactKey, []) - - const onPressSelection = useCallback( - (index: number) => setSelectedIndex(clamp(index, 0, sections.length)), - [setSelectedIndex, sections], - ) - useEffect(() => { - onSelectView?.(selectedIndex) - }, [selectedIndex, onSelectView]) - - useImperativeHandle(ref, () => ({ - scrollToTop: () => { - flatListRef.current?.scrollToOffset({offset: 0}) - }, - })) - - // rendering - // = - - const renderItemInternal = useCallback( - ({item}: {item: any}) => { - if (item === HEADER_ITEM) { - if (renderHeader) { - return renderHeader() - } - return - } else if (item === SELECTOR_ITEM) { - return ( - - ) - } else { - return renderItem(item) - } - }, - [sections, selectedIndex, onPressSelection, renderHeader, renderItem], - ) - - const data = useMemo(() => [HEADER_ITEM, SELECTOR_ITEM, ...items], [items]) - return ( - - } - onEndReachedThreshold={0.6} - contentContainerStyle={s.contentContainer} - removeClippedSubviews={true} - scrollIndicatorInsets={{right: 1}} // fixes a bug where the scroll indicator is on the middle of the screen https://github.com/bluesky-social/social-app/pull/464 - /> - ) -}) - -export function Selector({ - selectedIndex, - items, - onSelect, -}: { - selectedIndex: number - items: string[] - onSelect?: (index: number) => void -}) { - const pal = usePalette('default') - const borderColor = useColorSchemeStyle( - {borderColor: colors.black}, - {borderColor: colors.white}, - ) - - const onPressItem = (index: number) => { - onSelect?.(index) - } - - return ( - - - - {items.map((item, i) => { - const selected = i === selectedIndex - return ( - onPressItem(i)} - accessibilityLabel={item} - accessibilityHint={`Selects ${item}`} - // TODO: Modify the component API such that lint fails - // at the invocation site as well - > - - - {item} - - - - ) - })} - - - - ) -} - -const styles = StyleSheet.create({ - outer: { - flexDirection: 'row', - paddingHorizontal: 14, - }, - item: { - marginRight: 14, - paddingHorizontal: 10, - paddingTop: 8, - paddingBottom: 12, - }, - itemSelected: { - borderBottomWidth: 3, - }, - label: { - fontWeight: '600', - }, - labelSelected: { - fontWeight: '600', - }, - underline: { - position: 'absolute', - height: 4, - bottom: 0, - }, -}) diff --git a/src/view/screens/Debug.tsx b/src/view/screens/Debug.tsx deleted file mode 100644 index 7e79b26ccd..0000000000 --- a/src/view/screens/Debug.tsx +++ /dev/null @@ -1,387 +0,0 @@ -import {useState} from 'react' -import {ScrollView, View} from 'react-native' -import {msg} from '@lingui/core/macro' -import {useLingui} from '@lingui/react' - -import {usePalette} from '#/lib/hooks/usePalette' -import { - type CommonNavigatorParams, - type NativeStackScreenProps, -} from '#/lib/routes/types' -import {s} from '#/lib/styles' -import {type PaletteColorName, ThemeProvider} from '#/lib/ThemeContext' -import {EmptyState} from '#/view/com/util/EmptyState' -import {ErrorMessage} from '#/view/com/util/error/ErrorMessage' -import {ErrorScreen} from '#/view/com/util/error/ErrorScreen' -import {Button} from '#/view/com/util/forms/Button' -import * as LoadingPlaceholder from '#/view/com/util/LoadingPlaceholder' -import {Text} from '#/view/com/util/text/Text' -import {ViewHeader} from '#/view/com/util/ViewHeader' -import {ViewSelector} from '#/view/com/util/ViewSelector' -import {HashtagWide_Stroke1_Corner0_Rounded as HashtagWideIcon} from '#/components/icons/Hashtag' -import * as Layout from '#/components/Layout' -import * as Toast from '#/components/Toast' - -const MAIN_VIEWS = ['Base', 'Controls', 'Error', 'Notifs'] - -export const DebugScreen = ({}: NativeStackScreenProps< - CommonNavigatorParams, - 'Debug' ->) => { - const [colorScheme, setColorScheme] = useState<'light' | 'dark'>('light') - const onToggleColorScheme = () => { - setColorScheme(colorScheme === 'light' ? 'dark' : 'light') - } - return ( - - - - - - ) -} - -function DebugInner({}: { - colorScheme: 'light' | 'dark' - onToggleColorScheme: () => void -}) { - const [currentView, setCurrentView] = useState(0) - const pal = usePalette('default') - const {_} = useLingui() - - const renderItem = (item: any) => { - return ( - - {item.currentView === 3 ? ( - - ) : item.currentView === 2 ? ( - - ) : item.currentView === 1 ? ( - - ) : ( - - )} - - ) - } - - const items = [{currentView}] - - return ( - - - - - ) -} - -function Heading({label}: {label: string}) { - const pal = usePalette('default') - return ( - - - {label} - - - ) -} - -function BaseView() { - return ( - - - - - - - - - - - - - - - - ) -} - -function ControlsView() { - return ( - - - - - - ) -} - -function ErrorView() { - return ( - - - {}} - /> - - - - - - - - - {}} - /> - - - {}} - numberOfLines={1} - /> - - - ) -} - -function NotifsView() { - const triggerPush = () => { - // TODO: implement local notification for testing - } - const triggerToast = () => { - Toast.show('The task has been completed') - } - const triggerToast2 = () => { - Toast.show('The task has been completed successfully and with no problems') - } - return ( - - -