@@ -10,14 +10,15 @@ import { Platform, StyleSheet, View } from "react-native";
1010import { Button , Separator } from "./shared" ;
1111import { spacing } from "../theme" ;
1212import { Spacer } from "./shared/Spacer" ;
13- import { useBreakpoints , useInstanceConfig } from "../hooks" ;
13+ import { useBreakpoints , useInstanceConfig , useShareButton } from "../hooks" ;
1414import { InstanceInfo } from "./InstanceInfo" ;
1515import { Settings } from "./VideoControlsOverlay/components/modals" ;
1616import { useNetInfo } from "@react-native-community/netinfo" ;
1717import { writeToAsyncStorage } from "../utils" ;
1818import useLeaveInstancePermission from "../hooks/useLeaveInstancePermission" ;
1919import { useSafeAreaInsets } from "react-native-safe-area-context" ;
2020import { QrCodeLinkModal } from "./QRCodeLinkModal" ;
21+ import build_info from "../build-info.json" ;
2122
2223const SIDEBAR_ROUTES = [
2324 {
@@ -70,6 +71,7 @@ export const Sidebar: FC<SidebarProps> = ({ backend, ...navigationProps }) => {
7071 const { isLeaveInstanceAllowed } = useLeaveInstancePermission ( navigationProps ) ;
7172 const { primaryBackend } = useAppConfigContext ( ) ;
7273 const safeArea = useSafeAreaInsets ( ) ;
74+ const { handleToggleShareModal } = useShareButton ( ) ;
7375
7476 const isLeaveInstanceShown =
7577 ! primaryBackend && isLeaveInstanceAllowed && ! currentInstanceConfig ?. customizations ?. menuHideLeaveButton ;
@@ -85,20 +87,25 @@ export const Sidebar: FC<SidebarProps> = ({ backend, ...navigationProps }) => {
8587 } ) ;
8688 } ;
8789
90+ const paddingHelperStyle = { ...styles . paddingHHelper , width : shouldExpand ? undefined : 48 } ;
91+
92+ const homeShareLink = `${ build_info . WEB_URL ?. toLowerCase ( ) } /${ ROUTES . HOME } ?backend=${ backend } ` ;
93+
8894 return (
8995 < DrawerContentScrollView
9096 { ...navigationProps }
9197 contentContainerStyle = { {
9298 padding : 0 ,
9399 paddingTop : safeArea . top ,
100+ alignItems : shouldExpand ? undefined : "center" ,
94101 } }
95102 style = { [
96103 styles . container ,
97104 {
98105 backgroundColor : colors . theme50 ,
99106 paddingHorizontal : shouldExpand ? spacing . md : [ "ios" , "android" ] . includes ( Platform . OS ) ? 0 : spacing . sm ,
100107 width : "100%" ,
101- paddingTop : breakpoints . isDesktop ? 18 : undefined ,
108+ paddingTop : shouldExpand ? spacing . lg : spacing . xl ,
102109 } ,
103110 ] }
104111 >
@@ -139,7 +146,7 @@ export const Sidebar: FC<SidebarProps> = ({ backend, ...navigationProps }) => {
139146 justifyContent = "flex-start"
140147 icon = { icon }
141148 text = { shouldExpand ? t ( nameKey ) : undefined }
142- style = { { ...styles . button , ...styles . paddingHHelper } }
149+ style = { { ...styles . button , ...paddingHelperStyle } }
143150 />
144151 </ Link >
145152 ) ;
@@ -149,7 +156,7 @@ export const Sidebar: FC<SidebarProps> = ({ backend, ...navigationProps }) => {
149156 < View style = { styles . separatorContainer } >
150157 < Separator />
151158 </ View >
152- { Number ( currentInstanceConfig ?. customizations ?. menuExternalLinks ?. length ) > 0 && (
159+ { Number ( currentInstanceConfig ?. customizations ?. menuExternalLinks ?. length ) > 0 && shouldExpand && (
153160 < >
154161 { currentInstanceConfig ?. customizations ?. menuExternalLinks ?. map ( ( { label, url } ) => (
155162 < React . Fragment key = { url } >
@@ -162,15 +169,15 @@ export const Sidebar: FC<SidebarProps> = ({ backend, ...navigationProps }) => {
162169 justifyContent = "flex-start"
163170 icon = { "External-Link" }
164171 text = { label }
165- style = { { ...styles . button , ...styles . paddingHHelper , width : "100%" } }
172+ style = { { ...styles . button , ...paddingHelperStyle , width : "100%" } }
166173 />
167174 ) : (
168175 < Link target = "_blank" rel = "noreferrer noopener" href = { url } asChild = { Platform . OS !== "web" } >
169176 < Button
170177 justifyContent = "flex-start"
171178 icon = { "External-Link" }
172179 text = { shouldExpand ? label : undefined }
173- style = { { ...styles . button , ...styles . paddingHHelper , width : "100%" } }
180+ style = { { ...styles . button , ...paddingHelperStyle , width : "100%" } }
174181 />
175182 </ Link >
176183 ) }
@@ -182,19 +189,26 @@ export const Sidebar: FC<SidebarProps> = ({ backend, ...navigationProps }) => {
182189 </ >
183190 ) }
184191 < View style = { styles . routesContainer } >
192+ < Button
193+ justifyContent = "flex-start"
194+ onPress = { ( ) => handleToggleShareModal ( { staticHeaderKey : "shareVideoSite" , staticLink : homeShareLink } ) }
195+ icon = { "Share" }
196+ text = { shouldExpand ? t ( "shareAppURL" ) : undefined }
197+ style = { paddingHelperStyle }
198+ />
185199 < Button
186200 justifyContent = "flex-start"
187201 onPress = { toggleScheme }
188202 icon = { isDarkMode ? "Light-mode" : "Dark-mode" }
189203 text = { shouldExpand ? t ( isDarkMode ? "lightMode" : "darkMode" ) : undefined }
190- style = { styles . paddingHHelper }
204+ style = { paddingHelperStyle }
191205 />
192206 < Button
193207 justifyContent = "flex-start"
194208 onPress = { handleOpenSettings }
195209 icon = "Settings"
196210 text = { shouldExpand ? t ( "settingsPageTitle" ) : undefined }
197- style = { styles . paddingHHelper }
211+ style = { paddingHelperStyle }
198212 />
199213 { isLeaveInstanceShown && (
200214 < Button
@@ -203,7 +217,7 @@ export const Sidebar: FC<SidebarProps> = ({ backend, ...navigationProps }) => {
203217 contrast = "none"
204218 icon = "Exit"
205219 text = { shouldExpand ? t ( "leaveSite" ) : undefined }
206- style = { styles . paddingHHelper }
220+ style = { paddingHelperStyle }
207221 />
208222 ) }
209223 </ View >
@@ -217,6 +231,7 @@ const styles = StyleSheet.create({
217231 paddingVertical : 6 ,
218232 } ,
219233 container : {
234+ paddingBottom : 8 ,
220235 paddingTop : 8 ,
221236 } ,
222237 expandedInstanceInfo : {
@@ -229,8 +244,8 @@ const styles = StyleSheet.create({
229244 } ,
230245 paddingHHelper : {
231246 height : 48 ,
232- paddingHorizontal : [ "ios" , "android" ] . includes ( Platform . OS ) ? 8 : undefined ,
247+ paddingHorizontal : [ "ios" , "android" ] . includes ( Platform . OS ) ? spacing . md : undefined ,
233248 } ,
234249 routesContainer : { gap : 4 } ,
235- separatorContainer : { paddingVertical : spacing . sm } ,
250+ separatorContainer : { paddingVertical : spacing . sm , width : "100%" } ,
236251} ) ;
0 commit comments