Skip to content

Commit

Permalink
Dapp Browser: close tab button (#5532)
Browse files Browse the repository at this point in the history
* some progress on dapp listings ui

* progress

* dapp listings ui complete

* rebase fix

* tweak

* android fixes

* fallback gradient

* fix scrolling on empty tab

* close button
  • Loading branch information
benisgold authored Mar 19, 2024
1 parent 2689b40 commit 0e50972
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/components/DappBrowser/BrowserTab.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Box, globalColors, useColorMode, Text } from '@/design-system';
import { Page } from '@/components/layout';
import { Box, globalColors, useColorMode, TextIcon } from '@/design-system';
import { useAccountAccentColor, useAccountSettings, useDimensions } from '@/hooks';
import { AnimatePresence, MotiView } from 'moti';
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
Expand All @@ -22,6 +21,7 @@ import { IS_ANDROID, IS_IOS } from '@/env';
import { DappBrowserShadows } from './DappBrowserShadows';
import { WebViewBorder } from './WebViewBorder';
import Homepage from './Homepage';
import { ButtonPressAnimation } from '../animations';

interface BrowserTabProps {
tabIndex: number;
Expand Down Expand Up @@ -81,6 +81,7 @@ const getWebsiteBackgroundColor = `
export const BrowserTab = React.memo(function BrowserTab({ tabIndex, injectedJS }: BrowserTabProps) {
const {
activeTabIndex,
closeTab,
scrollViewOffset,
setActiveTabIndex,
tabStates,
Expand Down Expand Up @@ -417,7 +418,7 @@ export const BrowserTab = React.memo(function BrowserTab({ tabIndex, injectedJS
return (
<>
<DappBrowserShadows type="webview">
<TouchableWithoutFeedback onPress={handlePress}>
<TouchableWithoutFeedback disabled={isOnHomepage && !tabViewVisible} onPress={handlePress}>
<Animated.View style={[styles.webViewContainer, webViewStyle]}>
<ViewShot options={{ format: 'jpg' }} ref={viewShotRef}>
<View
Expand Down Expand Up @@ -475,6 +476,20 @@ export const BrowserTab = React.memo(function BrowserTab({ tabIndex, injectedJS
<WebViewBorder enabled={IS_IOS && isDarkMode && !isOnHomepage} isActiveTab={isActiveTab} />
</Animated.View>
</TouchableWithoutFeedback>
{tabViewVisible && tabStates.length > 1 && (
<Box
as={ButtonPressAnimation}
onPress={() => closeTab(tabIndex)}
position="absolute"
top={{ custom: safeAreaInsetValues.top + Math.floor(tabIndex / 2) * TAB_VIEW_ROW_HEIGHT + 8 }}
left={{ custom: ((tabIndex % 2) + 1) * TAB_VIEW_COLUMN_WIDTH + (tabIndex % 2) * 20 - 8 }}
style={{ zIndex: 99999999999 }}
>
<TextIcon align="center" size="17pt" weight="bold" color="labelSecondary" containerSize={20} hitSlop={10}>
􀀳
</TextIcon>
</Box>
)}
</DappBrowserShadows>
{isActiveTab && !tabViewVisible && (
<Box as={Animated.View} style={[styles.progressBar, progressBarStyle, { backgroundColor: accentColor }]} />
Expand Down

0 comments on commit 0e50972

Please sign in to comment.