* feat: add file manager module - Complete file manager implementation with UI/UX - Add drive management functionality - Add file upload/download with progress tracking - Add stamp integration and handling - Add bulk operations and context menus Co-authored-by: Roland Seres <roland.seres90@gmail.com> Co-authored-by: nidishk <nidishkrishnan45@gmail.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { createContext, useContext, useState, ReactNode } from 'react'
|
||||
import { ViewType } from '../../modules/filemanager/constants/transfers'
|
||||
|
||||
interface ViewContextProps {
|
||||
view: ViewType
|
||||
setView: (view: ViewType) => void
|
||||
actualItemView?: string
|
||||
setActualItemView?: (view: string) => void
|
||||
}
|
||||
|
||||
const ViewContext = createContext<ViewContextProps | undefined>(undefined)
|
||||
|
||||
export function ViewProvider({ children }: { children: ReactNode }) {
|
||||
const [view, setView] = useState<ViewType>(ViewType.File)
|
||||
const [actualItemView, setActualItemView] = useState<string | undefined>(undefined)
|
||||
|
||||
return (
|
||||
<ViewContext.Provider
|
||||
value={{
|
||||
view,
|
||||
setView,
|
||||
actualItemView,
|
||||
setActualItemView,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</ViewContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function useView() {
|
||||
const context = useContext(ViewContext)
|
||||
|
||||
if (!context) {
|
||||
throw new Error('useView must be used within a ViewProvider')
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
||||
Reference in New Issue
Block a user