module TD.Data.ThemeParameters
( ThemeParameters(..)
, defaultThemeParameters
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data ThemeParameters
= ThemeParameters
{ ThemeParameters -> Maybe Int
background_color :: Maybe Int
, ThemeParameters -> Maybe Int
secondary_background_color :: Maybe Int
, :: Maybe Int
, ThemeParameters -> Maybe Int
bottom_bar_background_color :: Maybe Int
, ThemeParameters -> Maybe Int
section_background_color :: Maybe Int
, ThemeParameters -> Maybe Int
section_separator_color :: Maybe Int
, ThemeParameters -> Maybe Int
text_color :: Maybe Int
, ThemeParameters -> Maybe Int
accent_text_color :: Maybe Int
, :: Maybe Int
, ThemeParameters -> Maybe Int
subtitle_text_color :: Maybe Int
, ThemeParameters -> Maybe Int
destructive_text_color :: Maybe Int
, ThemeParameters -> Maybe Int
hint_color :: Maybe Int
, ThemeParameters -> Maybe Int
link_color :: Maybe Int
, ThemeParameters -> Maybe Int
button_color :: Maybe Int
, ThemeParameters -> Maybe Int
button_text_color :: Maybe Int
}
deriving (ThemeParameters -> ThemeParameters -> Bool
(ThemeParameters -> ThemeParameters -> Bool)
-> (ThemeParameters -> ThemeParameters -> Bool)
-> Eq ThemeParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ThemeParameters -> ThemeParameters -> Bool
== :: ThemeParameters -> ThemeParameters -> Bool
$c/= :: ThemeParameters -> ThemeParameters -> Bool
/= :: ThemeParameters -> ThemeParameters -> Bool
Eq, Int -> ThemeParameters -> ShowS
[ThemeParameters] -> ShowS
ThemeParameters -> String
(Int -> ThemeParameters -> ShowS)
-> (ThemeParameters -> String)
-> ([ThemeParameters] -> ShowS)
-> Show ThemeParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ThemeParameters -> ShowS
showsPrec :: Int -> ThemeParameters -> ShowS
$cshow :: ThemeParameters -> String
show :: ThemeParameters -> String
$cshowList :: [ThemeParameters] -> ShowS
showList :: [ThemeParameters] -> ShowS
Show)
instance I.ShortShow ThemeParameters where
shortShow :: ThemeParameters -> String
shortShow ThemeParameters
{ background_color :: ThemeParameters -> Maybe Int
background_color = Maybe Int
background_color_
, secondary_background_color :: ThemeParameters -> Maybe Int
secondary_background_color = Maybe Int
secondary_background_color_
, header_background_color :: ThemeParameters -> Maybe Int
header_background_color = Maybe Int
header_background_color_
, bottom_bar_background_color :: ThemeParameters -> Maybe Int
bottom_bar_background_color = Maybe Int
bottom_bar_background_color_
, section_background_color :: ThemeParameters -> Maybe Int
section_background_color = Maybe Int
section_background_color_
, section_separator_color :: ThemeParameters -> Maybe Int
section_separator_color = Maybe Int
section_separator_color_
, text_color :: ThemeParameters -> Maybe Int
text_color = Maybe Int
text_color_
, accent_text_color :: ThemeParameters -> Maybe Int
accent_text_color = Maybe Int
accent_text_color_
, section_header_text_color :: ThemeParameters -> Maybe Int
section_header_text_color = Maybe Int
section_header_text_color_
, subtitle_text_color :: ThemeParameters -> Maybe Int
subtitle_text_color = Maybe Int
subtitle_text_color_
, destructive_text_color :: ThemeParameters -> Maybe Int
destructive_text_color = Maybe Int
destructive_text_color_
, hint_color :: ThemeParameters -> Maybe Int
hint_color = Maybe Int
hint_color_
, link_color :: ThemeParameters -> Maybe Int
link_color = Maybe Int
link_color_
, button_color :: ThemeParameters -> Maybe Int
button_color = Maybe Int
button_color_
, button_text_color :: ThemeParameters -> Maybe Int
button_text_color = Maybe Int
button_text_color_
}
= String
"ThemeParameters"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"background_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
background_color_
, String
"secondary_background_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
secondary_background_color_
, String
"header_background_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
header_background_color_
, String
"bottom_bar_background_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
bottom_bar_background_color_
, String
"section_background_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
section_background_color_
, String
"section_separator_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
section_separator_color_
, String
"text_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
text_color_
, String
"accent_text_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
accent_text_color_
, String
"section_header_text_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
section_header_text_color_
, String
"subtitle_text_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
subtitle_text_color_
, String
"destructive_text_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
destructive_text_color_
, String
"hint_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
hint_color_
, String
"link_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
link_color_
, String
"button_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
button_color_
, String
"button_text_color" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
button_text_color_
]
instance AT.FromJSON ThemeParameters where
parseJSON :: Value -> Parser ThemeParameters
parseJSON v :: Value
v@(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
"themeParameters" -> Value -> Parser ThemeParameters
parseThemeParameters Value
v
String
_ -> Parser ThemeParameters
forall a. Monoid a => a
mempty
where
parseThemeParameters :: A.Value -> AT.Parser ThemeParameters
parseThemeParameters :: Value -> Parser ThemeParameters
parseThemeParameters = String
-> (Object -> Parser ThemeParameters)
-> Value
-> Parser ThemeParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ThemeParameters" ((Object -> Parser ThemeParameters)
-> Value -> Parser ThemeParameters)
-> (Object -> Parser ThemeParameters)
-> Value
-> Parser ThemeParameters
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
background_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"background_color"
Maybe Int
secondary_background_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"secondary_background_color"
Maybe Int
header_background_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"header_background_color"
Maybe Int
bottom_bar_background_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"bottom_bar_background_color"
Maybe Int
section_background_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"section_background_color"
Maybe Int
section_separator_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"section_separator_color"
Maybe Int
text_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"text_color"
Maybe Int
accent_text_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"accent_text_color"
Maybe Int
section_header_text_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"section_header_text_color"
Maybe Int
subtitle_text_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"subtitle_text_color"
Maybe Int
destructive_text_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"destructive_text_color"
Maybe Int
hint_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"hint_color"
Maybe Int
link_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"link_color"
Maybe Int
button_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"button_color"
Maybe Int
button_text_color_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"button_text_color"
ThemeParameters -> Parser ThemeParameters
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ThemeParameters -> Parser ThemeParameters)
-> ThemeParameters -> Parser ThemeParameters
forall a b. (a -> b) -> a -> b
$ ThemeParameters
{ background_color :: Maybe Int
background_color = Maybe Int
background_color_
, secondary_background_color :: Maybe Int
secondary_background_color = Maybe Int
secondary_background_color_
, header_background_color :: Maybe Int
header_background_color = Maybe Int
header_background_color_
, bottom_bar_background_color :: Maybe Int
bottom_bar_background_color = Maybe Int
bottom_bar_background_color_
, section_background_color :: Maybe Int
section_background_color = Maybe Int
section_background_color_
, section_separator_color :: Maybe Int
section_separator_color = Maybe Int
section_separator_color_
, text_color :: Maybe Int
text_color = Maybe Int
text_color_
, accent_text_color :: Maybe Int
accent_text_color = Maybe Int
accent_text_color_
, section_header_text_color :: Maybe Int
section_header_text_color = Maybe Int
section_header_text_color_
, subtitle_text_color :: Maybe Int
subtitle_text_color = Maybe Int
subtitle_text_color_
, destructive_text_color :: Maybe Int
destructive_text_color = Maybe Int
destructive_text_color_
, hint_color :: Maybe Int
hint_color = Maybe Int
hint_color_
, link_color :: Maybe Int
link_color = Maybe Int
link_color_
, button_color :: Maybe Int
button_color = Maybe Int
button_color_
, button_text_color :: Maybe Int
button_text_color = Maybe Int
button_text_color_
}
parseJSON Value
_ = Parser ThemeParameters
forall a. Monoid a => a
mempty
instance AT.ToJSON ThemeParameters where
toJSON :: ThemeParameters -> Value
toJSON ThemeParameters
{ background_color :: ThemeParameters -> Maybe Int
background_color = Maybe Int
background_color_
, secondary_background_color :: ThemeParameters -> Maybe Int
secondary_background_color = Maybe Int
secondary_background_color_
, header_background_color :: ThemeParameters -> Maybe Int
header_background_color = Maybe Int
header_background_color_
, bottom_bar_background_color :: ThemeParameters -> Maybe Int
bottom_bar_background_color = Maybe Int
bottom_bar_background_color_
, section_background_color :: ThemeParameters -> Maybe Int
section_background_color = Maybe Int
section_background_color_
, section_separator_color :: ThemeParameters -> Maybe Int
section_separator_color = Maybe Int
section_separator_color_
, text_color :: ThemeParameters -> Maybe Int
text_color = Maybe Int
text_color_
, accent_text_color :: ThemeParameters -> Maybe Int
accent_text_color = Maybe Int
accent_text_color_
, section_header_text_color :: ThemeParameters -> Maybe Int
section_header_text_color = Maybe Int
section_header_text_color_
, subtitle_text_color :: ThemeParameters -> Maybe Int
subtitle_text_color = Maybe Int
subtitle_text_color_
, destructive_text_color :: ThemeParameters -> Maybe Int
destructive_text_color = Maybe Int
destructive_text_color_
, hint_color :: ThemeParameters -> Maybe Int
hint_color = Maybe Int
hint_color_
, link_color :: ThemeParameters -> Maybe Int
link_color = Maybe Int
link_color_
, button_color :: ThemeParameters -> Maybe Int
button_color = Maybe Int
button_color_
, button_text_color :: ThemeParameters -> Maybe Int
button_text_color = Maybe Int
button_text_color_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"themeParameters"
, Key
"background_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
background_color_
, Key
"secondary_background_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
secondary_background_color_
, Key
"header_background_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
header_background_color_
, Key
"bottom_bar_background_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
bottom_bar_background_color_
, Key
"section_background_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
section_background_color_
, Key
"section_separator_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
section_separator_color_
, Key
"text_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
text_color_
, Key
"accent_text_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
accent_text_color_
, Key
"section_header_text_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
section_header_text_color_
, Key
"subtitle_text_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
subtitle_text_color_
, Key
"destructive_text_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
destructive_text_color_
, Key
"hint_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
hint_color_
, Key
"link_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
link_color_
, Key
"button_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
button_color_
, Key
"button_text_color" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
button_text_color_
]
defaultThemeParameters :: ThemeParameters
defaultThemeParameters :: ThemeParameters
defaultThemeParameters =
ThemeParameters
{ background_color :: Maybe Int
background_color = Maybe Int
forall a. Maybe a
Nothing
, secondary_background_color :: Maybe Int
secondary_background_color = Maybe Int
forall a. Maybe a
Nothing
, header_background_color :: Maybe Int
header_background_color = Maybe Int
forall a. Maybe a
Nothing
, bottom_bar_background_color :: Maybe Int
bottom_bar_background_color = Maybe Int
forall a. Maybe a
Nothing
, section_background_color :: Maybe Int
section_background_color = Maybe Int
forall a. Maybe a
Nothing
, section_separator_color :: Maybe Int
section_separator_color = Maybe Int
forall a. Maybe a
Nothing
, text_color :: Maybe Int
text_color = Maybe Int
forall a. Maybe a
Nothing
, accent_text_color :: Maybe Int
accent_text_color = Maybe Int
forall a. Maybe a
Nothing
, section_header_text_color :: Maybe Int
section_header_text_color = Maybe Int
forall a. Maybe a
Nothing
, subtitle_text_color :: Maybe Int
subtitle_text_color = Maybe Int
forall a. Maybe a
Nothing
, destructive_text_color :: Maybe Int
destructive_text_color = Maybe Int
forall a. Maybe a
Nothing
, hint_color :: Maybe Int
hint_color = Maybe Int
forall a. Maybe a
Nothing
, link_color :: Maybe Int
link_color = Maybe Int
forall a. Maybe a
Nothing
, button_color :: Maybe Int
button_color = Maybe Int
forall a. Maybe a
Nothing
, button_text_color :: Maybe Int
button_text_color = Maybe Int
forall a. Maybe a
Nothing
}