57 lines
1.1 KiB
Haskell
57 lines
1.1 KiB
Haskell
module Types
|
|
( EpubEnv(..),
|
|
ChapterView(..),
|
|
Chapter(..),
|
|
AppState(..),
|
|
UserAction(..),
|
|
EpubAction
|
|
)
|
|
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
|