module TD.Data.BuiltInTheme
  (BuiltInTheme(..)) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Describes a built-in theme of an official app
data BuiltInTheme
  = BuiltInThemeClassic -- ^ Classic light theme
  | BuiltInThemeDay -- ^ Regular light theme
  | BuiltInThemeNight -- ^ Regular dark theme
  | BuiltInThemeTinted -- ^ Tinted dark theme
  | BuiltInThemeArctic -- ^ Arctic light theme
  deriving (BuiltInTheme -> BuiltInTheme -> Bool
(BuiltInTheme -> BuiltInTheme -> Bool)
-> (BuiltInTheme -> BuiltInTheme -> Bool) -> Eq BuiltInTheme
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BuiltInTheme -> BuiltInTheme -> Bool
== :: BuiltInTheme -> BuiltInTheme -> Bool
$c/= :: BuiltInTheme -> BuiltInTheme -> Bool
/= :: BuiltInTheme -> BuiltInTheme -> Bool
Eq, Int -> BuiltInTheme -> ShowS
[BuiltInTheme] -> ShowS
BuiltInTheme -> String
(Int -> BuiltInTheme -> ShowS)
-> (BuiltInTheme -> String)
-> ([BuiltInTheme] -> ShowS)
-> Show BuiltInTheme
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BuiltInTheme -> ShowS
showsPrec :: Int -> BuiltInTheme -> ShowS
$cshow :: BuiltInTheme -> String
show :: BuiltInTheme -> String
$cshowList :: [BuiltInTheme] -> ShowS
showList :: [BuiltInTheme] -> ShowS
Show)

instance I.ShortShow BuiltInTheme where
  shortShow :: BuiltInTheme -> String
shortShow BuiltInTheme
BuiltInThemeClassic
      = String
"BuiltInThemeClassic"
  shortShow BuiltInTheme
BuiltInThemeDay
      = String
"BuiltInThemeDay"
  shortShow BuiltInTheme
BuiltInThemeNight
      = String
"BuiltInThemeNight"
  shortShow BuiltInTheme
BuiltInThemeTinted
      = String
"BuiltInThemeTinted"
  shortShow BuiltInTheme
BuiltInThemeArctic
      = String
"BuiltInThemeArctic"

instance AT.FromJSON BuiltInTheme where
  parseJSON :: Value -> Parser BuiltInTheme
parseJSON (AT.Object Object
obj) = do
    String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String

    case String
t of
      String
"builtInThemeClassic" -> BuiltInTheme -> Parser BuiltInTheme
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BuiltInTheme
BuiltInThemeClassic
      String
"builtInThemeDay"     -> BuiltInTheme -> Parser BuiltInTheme
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BuiltInTheme
BuiltInThemeDay
      String
"builtInThemeNight"   -> BuiltInTheme -> Parser BuiltInTheme
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BuiltInTheme
BuiltInThemeNight
      String
"builtInThemeTinted"  -> BuiltInTheme -> Parser BuiltInTheme
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BuiltInTheme
BuiltInThemeTinted
      String
"builtInThemeArctic"  -> BuiltInTheme -> Parser BuiltInTheme
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BuiltInTheme
BuiltInThemeArctic
      String
_                     -> Parser BuiltInTheme
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser BuiltInTheme
forall a. Monoid a => a
mempty