svitak/app/Types.hs

64 lines
1.3 KiB
Haskell

module Types
( EpubEnv(..),
ChapterView(..),
Chapter(..),
AppState(..),
UserAction(..),
EpubAction,
NavItem(..)
)
where
import qualified Data.Text as T
import Codec.Archive.Zip (Archive)
import qualified Codec.Epub.Data.Metadata as DMeta
import qualified Codec.Epub.Data.Manifest as DMan
import Control.Concurrent.Async (Async)
import Control.Monad.Reader (ReaderT)
data EpubEnv = EpubEnv
{ archive :: Archive,
opfXml :: String,
baseDir :: FilePath,
bookPath :: FilePath,
eMetadata :: DMeta.Metadata,
eManifest :: DMan.Manifest
}
data ChapterView = ChapterView
{ viewTitle :: T.Text,
viewHtml :: T.Text,
viewIdx :: Int
}
data Chapter = Chapter
{ chapterTitle :: T.Text,
chapterTags :: T.Text,
chapterIdx :: Int
}
data AppState = AppState
{ cEnv :: EpubEnv,
cIdx :: Int,
zoomlvl :: Double,
cSpine :: [(FilePath, T.Text)],
bTitle :: T.Text,
cAllChapters :: [Chapter],
activeTask :: Maybe (Async ()),
taskVersion :: Integer
}
type EpubAction a = ReaderT EpubEnv IO a
data UserAction
= NextChapter
| PrevChapter
| ZoomIn
| ZoomOut
| LoadSpecific Int
data NavItem = NavItem
{ navLabel :: T.Text,
navPath :: FilePath,
navTypes :: [T.Text]
} deriving (Show)