Skip to content

Commit

Permalink
modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Rider21 committed Mar 5, 2024
1 parent ba4cade commit 2a876cb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"react-native-shimmer-placeholder": "^2.0.9",
"react-native-tab-view": "^3.5.2",
"react-native-vector-icons": "^9.0.0",
"react-native-webview": "^13.8.1",
"react-native-webview": "^13.2.2",
"sanitize-html": "^2.12.1",
"urlencode": "^2.0.0"
},
Expand Down
38 changes: 27 additions & 11 deletions src/screens/WebviewScreen/components/Appbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Share, View, Text, TouchableOpacity } from 'react-native';
import { Modal, Share, View, Text, TouchableOpacity } from 'react-native';
import { IconButton } from 'react-native-paper';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { WebView } from 'react-native-webview';
Expand Down Expand Up @@ -54,7 +54,6 @@ const Appbar: React.FC<AppbarProps> = ({
backgroundColor: theme.surface2,
color: theme.onSurface,
onPress: () => {
setMenuVisible(false);
webView.current?.reload();
},
},
Expand All @@ -63,7 +62,6 @@ const Appbar: React.FC<AppbarProps> = ({
backgroundColor: theme.surface2,
color: theme.onSurface,
onPress: () => {
setMenuVisible(false);
Share.share({ message: currentUrl });
},
},
Expand All @@ -72,7 +70,6 @@ const Appbar: React.FC<AppbarProps> = ({
backgroundColor: theme.surface2,
color: theme.onSurface,
onPress: () => {
setMenuVisible(false);
Linking.openURL(currentUrl);
},
},
Expand All @@ -81,7 +78,6 @@ const Appbar: React.FC<AppbarProps> = ({
backgroundColor: theme.surface2,
color: theme.onSurface,
onPress: () => {
setMenuVisible(false);
webView.current?.clearCache?.(true);
webView.current?.reload();
showToast(getString('webview.dataDeleted'));
Expand Down Expand Up @@ -138,12 +134,32 @@ const Appbar: React.FC<AppbarProps> = ({
onPress={() => setMenuVisible(true)}
theme={{ colors: { ...theme } }}
/>
{menuVisible && (
<CustomMenu
options={menuOptions}
onSelect={index => menuOptions[index].onPress()}
/>
)}
<Modal
animationType="fade"
transparent={true}
visible={menuVisible}
onRequestClose={() => {
setModalVisible(false);
}}
>
<Pressable
onPress={() => setMenuVisible(false)}
style={{
flex: 1,
width: '100%',
height: '100%',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'rgba(0,0,0,0.62)',
}}
>
<CustomMenu
options={menuOptions}
onSelect={index => menuOptions[index].onPress()}
/>
</Pressable>
</Modal>
</View>
</View>
);
Expand Down

0 comments on commit 2a876cb

Please sign in to comment.