Skip to content

Commit

Permalink
add debug style
Browse files Browse the repository at this point in the history
  • Loading branch information
huhuanming committed Jun 21, 2024
1 parent a2e1ccf commit c35b084
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useIntl } from 'react-intl';
import type { IStackProps } from '@onekeyhq/components';
import {
Icon,
Input,
Shortcut,
SizableText,
XStack,
Expand Down Expand Up @@ -30,58 +31,67 @@ const mdHeaderStyle = platformEnv.isNative
mt: '$4',
} as IStackProps);

function CustomHeaderTitle({ handleSearchBarPress }: ICustomHeaderTitleProps) {
function CustomHeaderTitle({
handleSearchBarPress,
titleStyle,
textStyle,
}: any) {
const intl = useIntl();
const media = useMedia();
const { activeTabId } = useActiveTabId();
const { tab } = useWebTabDataById(activeTabId ?? '');
const displayUrl = activeTabId && tab?.url;

return (
<XStack
role="button"
alignItems="center"
px="$2"
py="$1.5"
bg="$bgStrong"
borderRadius="$3"
minWidth={platformEnv.isNative ? undefined : '$64'}
$md={mdHeaderStyle}
hoverStyle={{
bg: '$bgHover',
}}
pressStyle={{
bg: '$bgActive',
}}
onPress={() => handleSearchBarPress(tab?.url ?? '')}
borderCurve="continuous"
>
<Icon
name={displayUrl ? 'LockOutline' : 'SearchOutline'}
size="$5"
color="$iconSubdued"
/>
<SizableText
pl="$2"
size="$bodyLg"
color="$textSubdued"
flex={1}
numberOfLines={1}
testID="explore-index-search"
<>
<XStack
role="button"
alignItems="center"
px="$2"
py="$1.5"
bg="$bgStrong"
borderRadius="$3"
minWidth={platformEnv.isNative ? undefined : '$64'}
$md={mdHeaderStyle}
hoverStyle={{
bg: '$bgHover',
}}
pressStyle={{
bg: '$bgActive',
}}
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
onPress={() => handleSearchBarPress(tab?.url ?? '')}
borderCurve="continuous"
{...titleStyle}
>
{displayUrl
? tab?.url
: intl.formatMessage({
id: ETranslations.explore_search_placeholder,
})}
</SizableText>
{media.gtMd ? (
<Shortcut>
<Shortcut.Key></Shortcut.Key>
<Shortcut.Key>T</Shortcut.Key>
</Shortcut>
) : null}
</XStack>
<Icon
name={displayUrl ? 'LockOutline' : 'SearchOutline'}
size="$5"
color="$iconSubdued"
/>
<SizableText
pl="$2"
size="$bodyLg"
color="$textSubdued"
flex={1}
numberOfLines={1}
testID="explore-index-search"
{...textStyle}
>
{displayUrl
? tab?.url
: intl.formatMessage({
id: ETranslations.explore_search_placeholder,
})}
</SizableText>
{media.gtMd ? (
<Shortcut>
<Shortcut.Key></Shortcut.Key>
<Shortcut.Key>T</Shortcut.Key>
</Shortcut>
) : null}
</XStack>
</>
);
}

Expand Down
27 changes: 25 additions & 2 deletions packages/kit/src/views/Discovery/pages/Browser/Browser.native.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';

import { Freeze } from 'react-freeze';
import Animated from 'react-native-reanimated';
Expand All @@ -7,6 +8,7 @@ import {
Icon,
Page,
Stack,
TextArea,
XStack,
useSafeAreaInsets,
} from '@onekeyhq/components';
Expand Down Expand Up @@ -128,25 +130,46 @@ function MobileBrowser() {

const { top } = useSafeAreaInsets();

const [styles, setStyles] = useState<any>();
return (
<Page fullPage>
<Page.Header headerShown={false} />
{/* custom header */}
<XStack
pt={top}
px="$5"
bg="red"
alignItems="center"
my="$1"
mt={platformEnv.isNativeAndroid ? '$3' : undefined}
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
{...styles?.container}
>
{!displayHomePage ? (
<Stack onPress={onCloseCurrentWebTabAndGoHomePage}>
<Icon name="CrossedLargeOutline" mr="$4" />
</Stack>
) : null}
<CustomHeaderTitle handleSearchBarPress={handleSearchBarPress} />
<CustomHeaderTitle
handleSearchBarPress={handleSearchBarPress}
titleStyle={styles?.titleStyle}
textStyle={styles?.textStyle}
/>
<HeaderRightToolBar />
</XStack>

<XStack flex={1} mx="$5">
<TextArea
numberOfLines={10}
px
width="100%"
onChangeText={(text) => {
try {
setStyles(JSON.parse(text));
} catch {}
}}
/>
</XStack>
<Page.Body>
<Stack flex={1} zIndex={3}>
<HandleRebuildBrowserData />
Expand Down

0 comments on commit c35b084

Please sign in to comment.