#679 day view without sidebar on mobile - look only

This commit is contained in:
lethemanh
2026-04-06 09:34:43 +07:00
parent fbb31e4a80
commit aa96a39b28
21 changed files with 664 additions and 117 deletions
+14 -19
View File
@@ -12,7 +12,7 @@ import CalendarApp from './Calendar'
import { CALENDAR_VIEWS } from './utils/constants'
import { setView } from '@/features/Settings/SettingsSlice'
export default function CalendarLayout() {
export default function CalendarLayout(): JSX.Element {
const calendarRef = useRef<CalendarApi | null>(null)
const dispatch = useAppDispatch()
const error = useAppSelector(state => state.calendars.error)
@@ -20,33 +20,28 @@ export default function CalendarLayout() {
const tempcalendars = useAppSelector(state => state.calendars.templist)
const view = useAppSelector(state => state.settings.view)
const { isTablet } = useScreenSizeDetection()
const { isTablet, isTooSmall: isMobile } = useScreenSizeDetection()
const [openSidebar, setOpenSideBar] = useState(false)
const [currentDate, setCurrentDate] = useState<Date>(new Date())
const [currentView, setCurrentView] = useState<string>(
isTablet ? CALENDAR_VIEWS.timeGridDay : CALENDAR_VIEWS.timeGridWeek
isTablet || isMobile
? CALENDAR_VIEWS.timeGridDay
: CALENDAR_VIEWS.timeGridWeek
)
useEffect(() => {
const setView = () =>
setCurrentView(prev => {
if (
prev !== CALENDAR_VIEWS.timeGridDay &&
prev !== CALENDAR_VIEWS.timeGridWeek
) {
return prev
}
return isTablet
const setView = (): void =>
setCurrentView(
isTablet || isMobile
? CALENDAR_VIEWS.timeGridDay
: CALENDAR_VIEWS.timeGridWeek
})
)
setView()
}, [isTablet])
}, [isTablet, isMobile])
const isInIframe = useMemo(() => new CozyBridge().isInIframe(), [])
const handleRefresh = async () => {
const handleRefresh = async (): Promise<void> => {
// Get current calendar range
if (calendarRef.current) {
const view = calendarRef.current.view
@@ -69,7 +64,7 @@ export default function CalendarLayout() {
}
}
const handleDateChange = (date: Date) => {
const handleDateChange = (date: Date): void => {
setCurrentDate(date)
}
@@ -96,14 +91,14 @@ export default function CalendarLayout() {
}
// Cleanup on unmount
return () => {
return (): void => {
document.body.classList.remove('fullscreen-view')
}
}, [view])
const menubarProps: MenubarProps = {
calendarRef,
onRefresh: handleRefresh,
onRefresh: () => void handleRefresh(),
currentDate,
onDateChange: handleDateChange,
currentView,