Skip to content

Commit ea0203d

Browse files
authored
added iOS padding (#69)
1 parent b7933ea commit ea0203d

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Version 0.2.1
4+
5+
### Changed
6+
7+
* Added bottom padding for nav bar on iOS devices (#63)
8+
39
## Version 0.2.0
410

511
### Added

components/Navigation.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { browserSettingsAtom } from '@/lib/atoms'
77
import { useEffect, useState } from 'react'
88
import AboutModal from './AboutModal'
99
import { HabitIcon, TaskIcon } from '@/lib/constants'
10+
import { useHelpers } from '@/lib/client-helpers'
1011

1112
type ViewPort = 'main' | 'mobile'
1213

@@ -33,6 +34,7 @@ export default function Navigation({ className, viewPort }: NavigationProps) {
3334
const [isMobileView, setIsMobileView] = useState(false)
3435
const [browserSettings] = useAtom(browserSettingsAtom)
3536
const isTasksView = browserSettings.viewType === 'tasks'
37+
const { isIOS } = useHelpers()
3638

3739
useEffect(() => {
3840
const handleResize = () => {
@@ -52,14 +54,14 @@ export default function Navigation({ className, viewPort }: NavigationProps) {
5254
if (viewPort === 'mobile' && isMobileView) {
5355
return (
5456
<>
55-
<div className="pb-16" /> {/* Add padding at the bottom to prevent content from being hidden */}
56-
<nav className="lg:hidden fixed bottom-0 left-0 right-0 bg-white dark:bg-gray-800 shadow-lg">
57-
<div className="flex justify-around">
57+
<div className={isIOS ? "pb-20" : "pb-16"} /> {/* Add padding at the bottom to prevent content from being hidden */}
58+
<nav className={`lg:hidden fixed bottom-0 left-0 right-0 bg-white dark:bg-gray-800 shadow-lg ${isIOS ? "pb-4" : ""}`}>
59+
<div className="flex justify-around divide-x divide-gray-300/60 dark:divide-gray-600/60">
5860
{[...navItems(isTasksView).filter(item => item.position === 'main'), ...navItems(isTasksView).filter(item => item.position === 'bottom')].map((item) => (
5961
<Link
6062
key={item.label}
6163
href={item.href}
62-
className="flex flex-col items-center py-2 text-gray-600 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400"
64+
className="flex flex-col items-center py-2 px-4 text-gray-600 dark:text-gray-300 hover:text-blue-500 dark:hover:text-blue-400 flex-1"
6365
>
6466
<item.icon className="h-6 w-6" />
6567
<span className="text-xs mt-1">{item.label}</span>

lib/client-helpers.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,27 @@ export function useHelpers() {
1212
const currentUserId = session?.user.id
1313
const [usersData] = useAtom(usersAtom)
1414
const currentUser = usersData.users.find((u) => u.id === currentUserId)
15+
// detect iOS: https://stackoverflow.com/a/9039885
16+
function iOS() {
17+
return [
18+
'iPad Simulator',
19+
'iPhone Simulator',
20+
'iPod Simulator',
21+
'iPad',
22+
'iPhone',
23+
'iPod',
24+
].includes(navigator.platform)
25+
// iPad on iOS 13 detection
26+
|| (navigator.userAgent.includes("Mac") && "ontouchend" in document)
27+
}
1528

1629
return {
1730
currentUserId,
1831
currentUser,
1932
usersData,
2033
status,
2134
hasPermission: (resource: 'habit' | 'wishlist' | 'coins', action: 'write' | 'interact') => currentUser?.isAdmin ||
22-
checkPermission(currentUser?.permissions, resource, action)
35+
checkPermission(currentUser?.permissions, resource, action),
36+
isIOS: iOS(),
2337
}
2438
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "habittrove",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"private": true,
55
"scripts": {
66
"dev": "next dev --turbopack",

0 commit comments

Comments
 (0)