-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sankey_recharts
- Loading branch information
Showing
9 changed files
with
155 additions
and
51 deletions.
There are no files selected for viewing
Binary file modified
BIN
+565 Bytes
(100%)
...s-snapshots/Mobile-checks-that-settings-page-can-be-opened-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.5 KB
(100%)
...s-snapshots/Mobile-checks-that-settings-page-can-be-opened-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+22 Bytes
(100%)
...apshots/Mobile-loads-the-budget-page-with-budgeted-amounts-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-188 Bytes
(99%)
...ots/Mobile-opens-the-accounts-page-and-asserts-on-balances-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React, { | ||
type ReactNode, | ||
createContext, | ||
useState, | ||
useContext, | ||
useEffect, | ||
} from 'react'; | ||
|
||
import debounce from 'debounce'; | ||
|
||
type IScrollContext = { | ||
scrollY: number | undefined; | ||
isBottomReached: boolean; | ||
}; | ||
|
||
const ScrollContext = createContext<IScrollContext | undefined>(undefined); | ||
|
||
type ScrollProviderProps = { | ||
children?: ReactNode; | ||
}; | ||
|
||
export default function ScrollProvider({ children }: ScrollProviderProps) { | ||
const [scrollY, setScrollY] = useState(undefined); | ||
const [isBottomReached, setIsBottomReached] = useState(false); | ||
|
||
useEffect(() => { | ||
const listenToScroll = debounce(e => { | ||
setScrollY(e.target?.scrollTop || 0); | ||
setIsBottomReached( | ||
e.target?.scrollHeight - e.target?.scrollTop <= e.target?.clientHeight, | ||
); | ||
}, 20); | ||
|
||
window.addEventListener('scroll', listenToScroll, { | ||
capture: true, | ||
passive: true, | ||
}); | ||
return () => | ||
window.removeEventListener('scroll', listenToScroll, { | ||
capture: true, | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<ScrollContext.Provider | ||
value={{ scrollY, isBottomReached }} | ||
children={children} | ||
/> | ||
); | ||
} | ||
|
||
export function useScroll(): IScrollContext { | ||
return useContext(ScrollContext); | ||
} |
82 changes: 82 additions & 0 deletions
82
packages/desktop-client/src/components/mobile/MobileNavTabs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import React, { type ComponentType, useMemo } from 'react'; | ||
import { NavLink } from 'react-router-dom'; | ||
|
||
import usePrevious from '../../hooks/usePrevious'; | ||
import Add from '../../icons/v1/Add'; | ||
import Cog from '../../icons/v1/Cog'; | ||
import PiggyBank from '../../icons/v1/PiggyBank'; | ||
import Wallet from '../../icons/v1/Wallet'; | ||
import { useResponsive } from '../../ResponsiveProvider'; | ||
import { theme, styles } from '../../style'; | ||
import { useScroll } from '../ScrollProvider'; | ||
|
||
const height = 70; | ||
|
||
export default function MobileNavTabs() { | ||
const { isNarrowWidth } = useResponsive(); | ||
const { scrollY, isBottomReached } = useScroll(); | ||
const previousScrollY = usePrevious(scrollY); | ||
|
||
const isVisible = useMemo( | ||
() => | ||
previousScrollY === undefined || | ||
(!isBottomReached && previousScrollY > scrollY) || | ||
previousScrollY < 0, | ||
[scrollY], | ||
); | ||
|
||
return ( | ||
<div | ||
style={{ | ||
backgroundColor: theme.mobileNavBackground, | ||
borderTop: `1px solid ${theme.menuBorder}`, | ||
...styles.shadow, | ||
display: isNarrowWidth ? 'flex' : 'none', | ||
height, | ||
justifyContent: 'space-around', | ||
paddingTop: 10, | ||
paddingBottom: 10, | ||
width: '100%', | ||
position: 'fixed', | ||
zIndex: 100, | ||
bottom: isVisible ? 0 : -height, | ||
transition: 'bottom 0.2s ease-out', | ||
}} | ||
> | ||
<NavTab name="Budget" path="/budget" icon={Wallet} /> | ||
<NavTab name="Accounts" path="/accounts" icon={PiggyBank} /> | ||
<NavTab name="Transaction" path="/transactions/new" icon={Add} /> | ||
<NavTab name="Settings" path="/settings" icon={Cog} /> | ||
</div> | ||
); | ||
} | ||
|
||
type NavTabIconProps = { | ||
width: number; | ||
height: number; | ||
}; | ||
|
||
type NavTabProps = { | ||
name: string; | ||
path: string; | ||
icon: ComponentType<NavTabIconProps>; | ||
}; | ||
|
||
function NavTab({ icon: TabIcon, name, path }: NavTabProps) { | ||
return ( | ||
<NavLink | ||
to={path} | ||
style={({ isActive }) => ({ | ||
...styles.noTapHighlight, | ||
alignItems: 'center', | ||
color: isActive ? theme.mobileNavItemSelected : theme.mobileNavItem, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
textDecoration: 'none', | ||
})} | ||
> | ||
<TabIcon width={22} height={22} /> | ||
{name} | ||
</NavLink> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: Enhancements | ||
authors: [joel-jeremy,MatissJanis] | ||
--- | ||
|
||
Hide mobile nav bar when scrolling |