{-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} module Simplex.Chat.Types.UITheme where import Data.Aeson (FromJSON (..), ToJSON (..)) import qualified Data.Aeson as J import qualified Data.Aeson.Encoding as JE import qualified Data.Aeson.Key as JK import qualified Data.Aeson.TH as JQ import Data.Char (toLower) import Data.Maybe (fromMaybe) import Data.Text (Text) import Simplex.Chat.Options.DB (FromField (..), ToField (..)) import Simplex.Messaging.Agent.Store.DB (fromTextField_) import Simplex.Messaging.Encoding.String import Simplex.Messaging.Parsers (defaultJSON, dropPrefix, enumJSON) import Simplex.Messaging.Util (decodeJSON, encodeJSON) data UITheme = UITheme { UITheme -> Text themeId :: Text, UITheme -> ThemeColorScheme base :: ThemeColorScheme, UITheme -> Maybe ChatWallpaper wallpaper :: Maybe ChatWallpaper, UITheme -> UIColors colors :: UIColors } deriving (UITheme -> UITheme -> Bool (UITheme -> UITheme -> Bool) -> (UITheme -> UITheme -> Bool) -> Eq UITheme forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: UITheme -> UITheme -> Bool == :: UITheme -> UITheme -> Bool $c/= :: UITheme -> UITheme -> Bool /= :: UITheme -> UITheme -> Bool Eq, Int -> UITheme -> ShowS [UITheme] -> ShowS UITheme -> String (Int -> UITheme -> ShowS) -> (UITheme -> String) -> ([UITheme] -> ShowS) -> Show UITheme forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> UITheme -> ShowS showsPrec :: Int -> UITheme -> ShowS $cshow :: UITheme -> String show :: UITheme -> String $cshowList :: [UITheme] -> ShowS showList :: [UITheme] -> ShowS Show) data UIColorMode = UCMLight | UCMDark deriving (UIColorMode -> UIColorMode -> Bool (UIColorMode -> UIColorMode -> Bool) -> (UIColorMode -> UIColorMode -> Bool) -> Eq UIColorMode forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: UIColorMode -> UIColorMode -> Bool == :: UIColorMode -> UIColorMode -> Bool $c/= :: UIColorMode -> UIColorMode -> Bool /= :: UIColorMode -> UIColorMode -> Bool Eq, Int -> UIColorMode -> ShowS [UIColorMode] -> ShowS UIColorMode -> String (Int -> UIColorMode -> ShowS) -> (UIColorMode -> String) -> ([UIColorMode] -> ShowS) -> Show UIColorMode forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> UIColorMode -> ShowS showsPrec :: Int -> UIColorMode -> ShowS $cshow :: UIColorMode -> String show :: UIColorMode -> String $cshowList :: [UIColorMode] -> ShowS showList :: [UIColorMode] -> ShowS Show) data UIThemeEntityOverrides = UIThemeEntityOverrides { UIThemeEntityOverrides -> Maybe UIThemeEntityOverride light :: Maybe UIThemeEntityOverride, UIThemeEntityOverrides -> Maybe UIThemeEntityOverride dark :: Maybe UIThemeEntityOverride } deriving (UIThemeEntityOverrides -> UIThemeEntityOverrides -> Bool (UIThemeEntityOverrides -> UIThemeEntityOverrides -> Bool) -> (UIThemeEntityOverrides -> UIThemeEntityOverrides -> Bool) -> Eq UIThemeEntityOverrides forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: UIThemeEntityOverrides -> UIThemeEntityOverrides -> Bool == :: UIThemeEntityOverrides -> UIThemeEntityOverrides -> Bool $c/= :: UIThemeEntityOverrides -> UIThemeEntityOverrides -> Bool /= :: UIThemeEntityOverrides -> UIThemeEntityOverrides -> Bool Eq, Int -> UIThemeEntityOverrides -> ShowS [UIThemeEntityOverrides] -> ShowS UIThemeEntityOverrides -> String (Int -> UIThemeEntityOverrides -> ShowS) -> (UIThemeEntityOverrides -> String) -> ([UIThemeEntityOverrides] -> ShowS) -> Show UIThemeEntityOverrides forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> UIThemeEntityOverrides -> ShowS showsPrec :: Int -> UIThemeEntityOverrides -> ShowS $cshow :: UIThemeEntityOverrides -> String show :: UIThemeEntityOverrides -> String $cshowList :: [UIThemeEntityOverrides] -> ShowS showList :: [UIThemeEntityOverrides] -> ShowS Show) data UIThemeEntityOverride = UIThemeEntityOverride { UIThemeEntityOverride -> UIColorMode mode :: UIColorMode, UIThemeEntityOverride -> Maybe ChatWallpaper wallpaper :: Maybe ChatWallpaper, UIThemeEntityOverride -> UIColors colors :: UIColors } deriving (UIThemeEntityOverride -> UIThemeEntityOverride -> Bool (UIThemeEntityOverride -> UIThemeEntityOverride -> Bool) -> (UIThemeEntityOverride -> UIThemeEntityOverride -> Bool) -> Eq UIThemeEntityOverride forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: UIThemeEntityOverride -> UIThemeEntityOverride -> Bool == :: UIThemeEntityOverride -> UIThemeEntityOverride -> Bool $c/= :: UIThemeEntityOverride -> UIThemeEntityOverride -> Bool /= :: UIThemeEntityOverride -> UIThemeEntityOverride -> Bool Eq, Int -> UIThemeEntityOverride -> ShowS [UIThemeEntityOverride] -> ShowS UIThemeEntityOverride -> String (Int -> UIThemeEntityOverride -> ShowS) -> (UIThemeEntityOverride -> String) -> ([UIThemeEntityOverride] -> ShowS) -> Show UIThemeEntityOverride forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> UIThemeEntityOverride -> ShowS showsPrec :: Int -> UIThemeEntityOverride -> ShowS $cshow :: UIThemeEntityOverride -> String show :: UIThemeEntityOverride -> String $cshowList :: [UIThemeEntityOverride] -> ShowS showList :: [UIThemeEntityOverride] -> ShowS Show) data DarkColorScheme = DCSDark | DCSBlack | DCSSimplex deriving (DarkColorScheme -> DarkColorScheme -> Bool (DarkColorScheme -> DarkColorScheme -> Bool) -> (DarkColorScheme -> DarkColorScheme -> Bool) -> Eq DarkColorScheme forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: DarkColorScheme -> DarkColorScheme -> Bool == :: DarkColorScheme -> DarkColorScheme -> Bool $c/= :: DarkColorScheme -> DarkColorScheme -> Bool /= :: DarkColorScheme -> DarkColorScheme -> Bool Eq, Eq DarkColorScheme Eq DarkColorScheme => (DarkColorScheme -> DarkColorScheme -> Ordering) -> (DarkColorScheme -> DarkColorScheme -> Bool) -> (DarkColorScheme -> DarkColorScheme -> Bool) -> (DarkColorScheme -> DarkColorScheme -> Bool) -> (DarkColorScheme -> DarkColorScheme -> Bool) -> (DarkColorScheme -> DarkColorScheme -> DarkColorScheme) -> (DarkColorScheme -> DarkColorScheme -> DarkColorScheme) -> Ord DarkColorScheme DarkColorScheme -> DarkColorScheme -> Bool DarkColorScheme -> DarkColorScheme -> Ordering DarkColorScheme -> DarkColorScheme -> DarkColorScheme forall a. Eq a => (a -> a -> Ordering) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> a) -> (a -> a -> a) -> Ord a $ccompare :: DarkColorScheme -> DarkColorScheme -> Ordering compare :: DarkColorScheme -> DarkColorScheme -> Ordering $c< :: DarkColorScheme -> DarkColorScheme -> Bool < :: DarkColorScheme -> DarkColorScheme -> Bool $c<= :: DarkColorScheme -> DarkColorScheme -> Bool <= :: DarkColorScheme -> DarkColorScheme -> Bool $c> :: DarkColorScheme -> DarkColorScheme -> Bool > :: DarkColorScheme -> DarkColorScheme -> Bool $c>= :: DarkColorScheme -> DarkColorScheme -> Bool >= :: DarkColorScheme -> DarkColorScheme -> Bool $cmax :: DarkColorScheme -> DarkColorScheme -> DarkColorScheme max :: DarkColorScheme -> DarkColorScheme -> DarkColorScheme $cmin :: DarkColorScheme -> DarkColorScheme -> DarkColorScheme min :: DarkColorScheme -> DarkColorScheme -> DarkColorScheme Ord, Int -> DarkColorScheme -> ShowS [DarkColorScheme] -> ShowS DarkColorScheme -> String (Int -> DarkColorScheme -> ShowS) -> (DarkColorScheme -> String) -> ([DarkColorScheme] -> ShowS) -> Show DarkColorScheme forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> DarkColorScheme -> ShowS showsPrec :: Int -> DarkColorScheme -> ShowS $cshow :: DarkColorScheme -> String show :: DarkColorScheme -> String $cshowList :: [DarkColorScheme] -> ShowS showList :: [DarkColorScheme] -> ShowS Show) data ThemeColorScheme = TCSLight | TCSDark DarkColorScheme deriving (ThemeColorScheme -> ThemeColorScheme -> Bool (ThemeColorScheme -> ThemeColorScheme -> Bool) -> (ThemeColorScheme -> ThemeColorScheme -> Bool) -> Eq ThemeColorScheme forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: ThemeColorScheme -> ThemeColorScheme -> Bool == :: ThemeColorScheme -> ThemeColorScheme -> Bool $c/= :: ThemeColorScheme -> ThemeColorScheme -> Bool /= :: ThemeColorScheme -> ThemeColorScheme -> Bool Eq, Eq ThemeColorScheme Eq ThemeColorScheme => (ThemeColorScheme -> ThemeColorScheme -> Ordering) -> (ThemeColorScheme -> ThemeColorScheme -> Bool) -> (ThemeColorScheme -> ThemeColorScheme -> Bool) -> (ThemeColorScheme -> ThemeColorScheme -> Bool) -> (ThemeColorScheme -> ThemeColorScheme -> Bool) -> (ThemeColorScheme -> ThemeColorScheme -> ThemeColorScheme) -> (ThemeColorScheme -> ThemeColorScheme -> ThemeColorScheme) -> Ord ThemeColorScheme ThemeColorScheme -> ThemeColorScheme -> Bool ThemeColorScheme -> ThemeColorScheme -> Ordering ThemeColorScheme -> ThemeColorScheme -> ThemeColorScheme forall a. Eq a => (a -> a -> Ordering) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> a) -> (a -> a -> a) -> Ord a $ccompare :: ThemeColorScheme -> ThemeColorScheme -> Ordering compare :: ThemeColorScheme -> ThemeColorScheme -> Ordering $c< :: ThemeColorScheme -> ThemeColorScheme -> Bool < :: ThemeColorScheme -> ThemeColorScheme -> Bool $c<= :: ThemeColorScheme -> ThemeColorScheme -> Bool <= :: ThemeColorScheme -> ThemeColorScheme -> Bool $c> :: ThemeColorScheme -> ThemeColorScheme -> Bool > :: ThemeColorScheme -> ThemeColorScheme -> Bool $c>= :: ThemeColorScheme -> ThemeColorScheme -> Bool >= :: ThemeColorScheme -> ThemeColorScheme -> Bool $cmax :: ThemeColorScheme -> ThemeColorScheme -> ThemeColorScheme max :: ThemeColorScheme -> ThemeColorScheme -> ThemeColorScheme $cmin :: ThemeColorScheme -> ThemeColorScheme -> ThemeColorScheme min :: ThemeColorScheme -> ThemeColorScheme -> ThemeColorScheme Ord, Int -> ThemeColorScheme -> ShowS [ThemeColorScheme] -> ShowS ThemeColorScheme -> String (Int -> ThemeColorScheme -> ShowS) -> (ThemeColorScheme -> String) -> ([ThemeColorScheme] -> ShowS) -> Show ThemeColorScheme forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> ThemeColorScheme -> ShowS showsPrec :: Int -> ThemeColorScheme -> ShowS $cshow :: ThemeColorScheme -> String show :: ThemeColorScheme -> String $cshowList :: [ThemeColorScheme] -> ShowS showList :: [ThemeColorScheme] -> ShowS Show) data UIColorScheme = UCSSystem | UCSFixed ThemeColorScheme deriving (UIColorScheme -> UIColorScheme -> Bool (UIColorScheme -> UIColorScheme -> Bool) -> (UIColorScheme -> UIColorScheme -> Bool) -> Eq UIColorScheme forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: UIColorScheme -> UIColorScheme -> Bool == :: UIColorScheme -> UIColorScheme -> Bool $c/= :: UIColorScheme -> UIColorScheme -> Bool /= :: UIColorScheme -> UIColorScheme -> Bool Eq, Eq UIColorScheme Eq UIColorScheme => (UIColorScheme -> UIColorScheme -> Ordering) -> (UIColorScheme -> UIColorScheme -> Bool) -> (UIColorScheme -> UIColorScheme -> Bool) -> (UIColorScheme -> UIColorScheme -> Bool) -> (UIColorScheme -> UIColorScheme -> Bool) -> (UIColorScheme -> UIColorScheme -> UIColorScheme) -> (UIColorScheme -> UIColorScheme -> UIColorScheme) -> Ord UIColorScheme UIColorScheme -> UIColorScheme -> Bool UIColorScheme -> UIColorScheme -> Ordering UIColorScheme -> UIColorScheme -> UIColorScheme forall a. Eq a => (a -> a -> Ordering) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> a) -> (a -> a -> a) -> Ord a $ccompare :: UIColorScheme -> UIColorScheme -> Ordering compare :: UIColorScheme -> UIColorScheme -> Ordering $c< :: UIColorScheme -> UIColorScheme -> Bool < :: UIColorScheme -> UIColorScheme -> Bool $c<= :: UIColorScheme -> UIColorScheme -> Bool <= :: UIColorScheme -> UIColorScheme -> Bool $c> :: UIColorScheme -> UIColorScheme -> Bool > :: UIColorScheme -> UIColorScheme -> Bool $c>= :: UIColorScheme -> UIColorScheme -> Bool >= :: UIColorScheme -> UIColorScheme -> Bool $cmax :: UIColorScheme -> UIColorScheme -> UIColorScheme max :: UIColorScheme -> UIColorScheme -> UIColorScheme $cmin :: UIColorScheme -> UIColorScheme -> UIColorScheme min :: UIColorScheme -> UIColorScheme -> UIColorScheme Ord, Int -> UIColorScheme -> ShowS [UIColorScheme] -> ShowS UIColorScheme -> String (Int -> UIColorScheme -> ShowS) -> (UIColorScheme -> String) -> ([UIColorScheme] -> ShowS) -> Show UIColorScheme forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> UIColorScheme -> ShowS showsPrec :: Int -> UIColorScheme -> ShowS $cshow :: UIColorScheme -> String show :: UIColorScheme -> String $cshowList :: [UIColorScheme] -> ShowS showList :: [UIColorScheme] -> ShowS Show) instance TextEncoding DarkColorScheme where textEncode :: DarkColorScheme -> Text textEncode = \case DarkColorScheme DCSDark -> Text "DARK" DarkColorScheme DCSBlack -> Text "BLACK" DarkColorScheme DCSSimplex -> Text "SIMPLEX" textDecode :: Text -> Maybe DarkColorScheme textDecode Text s = DarkColorScheme -> Maybe DarkColorScheme forall a. a -> Maybe a Just (DarkColorScheme -> Maybe DarkColorScheme) -> DarkColorScheme -> Maybe DarkColorScheme forall a b. (a -> b) -> a -> b $ case Text s of Text "DARK" -> DarkColorScheme DCSDark Text "BLACK" -> DarkColorScheme DCSBlack Text "SIMPLEX" -> DarkColorScheme DCSSimplex Text _ -> DarkColorScheme DCSDark instance TextEncoding ThemeColorScheme where textEncode :: ThemeColorScheme -> Text textEncode = \case ThemeColorScheme TCSLight -> Text "LIGHT" TCSDark DarkColorScheme s -> DarkColorScheme -> Text forall a. TextEncoding a => a -> Text textEncode DarkColorScheme s textDecode :: Text -> Maybe ThemeColorScheme textDecode = \case Text "LIGHT" -> ThemeColorScheme -> Maybe ThemeColorScheme forall a. a -> Maybe a Just ThemeColorScheme TCSLight Text s -> DarkColorScheme -> ThemeColorScheme TCSDark (DarkColorScheme -> ThemeColorScheme) -> Maybe DarkColorScheme -> Maybe ThemeColorScheme forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Text -> Maybe DarkColorScheme forall a. TextEncoding a => Text -> Maybe a textDecode Text s instance TextEncoding UIColorScheme where textEncode :: UIColorScheme -> Text textEncode = \case UIColorScheme UCSSystem -> Text "SYSTEM" UCSFixed ThemeColorScheme s -> ThemeColorScheme -> Text forall a. TextEncoding a => a -> Text textEncode ThemeColorScheme s textDecode :: Text -> Maybe UIColorScheme textDecode = \case Text "SYSTEM" -> UIColorScheme -> Maybe UIColorScheme forall a. a -> Maybe a Just UIColorScheme UCSSystem Text s -> ThemeColorScheme -> UIColorScheme UCSFixed (ThemeColorScheme -> UIColorScheme) -> Maybe ThemeColorScheme -> Maybe UIColorScheme forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Text -> Maybe ThemeColorScheme forall a. TextEncoding a => Text -> Maybe a textDecode Text s instance FromJSON DarkColorScheme where parseJSON :: Value -> Parser DarkColorScheme parseJSON = String -> Value -> Parser DarkColorScheme forall a. TextEncoding a => String -> Value -> Parser a textParseJSON String "DarkColorScheme" instance ToJSON DarkColorScheme where toJSON :: DarkColorScheme -> Value toJSON = Text -> Value J.String (Text -> Value) -> (DarkColorScheme -> Text) -> DarkColorScheme -> Value forall b c a. (b -> c) -> (a -> b) -> a -> c . DarkColorScheme -> Text forall a. TextEncoding a => a -> Text textEncode toEncoding :: DarkColorScheme -> Encoding toEncoding = Text -> Encoding forall a. Text -> Encoding' a JE.text (Text -> Encoding) -> (DarkColorScheme -> Text) -> DarkColorScheme -> Encoding forall b c a. (b -> c) -> (a -> b) -> a -> c . DarkColorScheme -> Text forall a. TextEncoding a => a -> Text textEncode instance FromJSON ThemeColorScheme where parseJSON :: Value -> Parser ThemeColorScheme parseJSON = String -> Value -> Parser ThemeColorScheme forall a. TextEncoding a => String -> Value -> Parser a textParseJSON String "ThemeColorScheme" instance ToJSON ThemeColorScheme where toJSON :: ThemeColorScheme -> Value toJSON = Text -> Value J.String (Text -> Value) -> (ThemeColorScheme -> Text) -> ThemeColorScheme -> Value forall b c a. (b -> c) -> (a -> b) -> a -> c . ThemeColorScheme -> Text forall a. TextEncoding a => a -> Text textEncode toEncoding :: ThemeColorScheme -> Encoding toEncoding = Text -> Encoding forall a. Text -> Encoding' a JE.text (Text -> Encoding) -> (ThemeColorScheme -> Text) -> ThemeColorScheme -> Encoding forall b c a. (b -> c) -> (a -> b) -> a -> c . ThemeColorScheme -> Text forall a. TextEncoding a => a -> Text textEncode instance FromJSON UIColorScheme where parseJSON :: Value -> Parser UIColorScheme parseJSON = String -> Value -> Parser UIColorScheme forall a. TextEncoding a => String -> Value -> Parser a textParseJSON String "UIColorScheme" instance ToJSON UIColorScheme where toJSON :: UIColorScheme -> Value toJSON = Text -> Value J.String (Text -> Value) -> (UIColorScheme -> Text) -> UIColorScheme -> Value forall b c a. (b -> c) -> (a -> b) -> a -> c . UIColorScheme -> Text forall a. TextEncoding a => a -> Text textEncode toEncoding :: UIColorScheme -> Encoding toEncoding = Text -> Encoding forall a. Text -> Encoding' a JE.text (Text -> Encoding) -> (UIColorScheme -> Text) -> UIColorScheme -> Encoding forall b c a. (b -> c) -> (a -> b) -> a -> c . UIColorScheme -> Text forall a. TextEncoding a => a -> Text textEncode instance J.FromJSONKey ThemeColorScheme where fromJSONKey :: FromJSONKeyFunction ThemeColorScheme fromJSONKey = (Text -> ThemeColorScheme) -> FromJSONKeyFunction ThemeColorScheme forall a. (Text -> a) -> FromJSONKeyFunction a J.FromJSONKeyText ((Text -> ThemeColorScheme) -> FromJSONKeyFunction ThemeColorScheme) -> (Text -> ThemeColorScheme) -> FromJSONKeyFunction ThemeColorScheme forall a b. (a -> b) -> a -> b $ ThemeColorScheme -> Maybe ThemeColorScheme -> ThemeColorScheme forall a. a -> Maybe a -> a fromMaybe (DarkColorScheme -> ThemeColorScheme TCSDark DarkColorScheme DCSDark) (Maybe ThemeColorScheme -> ThemeColorScheme) -> (Text -> Maybe ThemeColorScheme) -> Text -> ThemeColorScheme forall b c a. (b -> c) -> (a -> b) -> a -> c . Text -> Maybe ThemeColorScheme forall a. TextEncoding a => Text -> Maybe a textDecode instance J.ToJSONKey ThemeColorScheme where toJSONKey :: ToJSONKeyFunction ThemeColorScheme toJSONKey = (ThemeColorScheme -> Key) -> (ThemeColorScheme -> Encoding' Key) -> ToJSONKeyFunction ThemeColorScheme forall a. (a -> Key) -> (a -> Encoding' Key) -> ToJSONKeyFunction a J.ToJSONKeyText (Text -> Key JK.fromText (Text -> Key) -> (ThemeColorScheme -> Text) -> ThemeColorScheme -> Key forall b c a. (b -> c) -> (a -> b) -> a -> c . ThemeColorScheme -> Text forall a. TextEncoding a => a -> Text textEncode) (Text -> Encoding' Key forall a. Text -> Encoding' a JE.text (Text -> Encoding' Key) -> (ThemeColorScheme -> Text) -> ThemeColorScheme -> Encoding' Key forall b c a. (b -> c) -> (a -> b) -> a -> c . ThemeColorScheme -> Text forall a. TextEncoding a => a -> Text textEncode) data ChatWallpaper = ChatWallpaper { ChatWallpaper -> Maybe Text preset :: Maybe Text, ChatWallpaper -> Maybe String imageFile :: Maybe FilePath, ChatWallpaper -> Maybe UIColor background :: Maybe UIColor, ChatWallpaper -> Maybe UIColor tint :: Maybe UIColor, ChatWallpaper -> Maybe ChatWallpaperScale scaleType :: Maybe ChatWallpaperScale, ChatWallpaper -> Maybe Double scale :: Maybe Double } deriving (ChatWallpaper -> ChatWallpaper -> Bool (ChatWallpaper -> ChatWallpaper -> Bool) -> (ChatWallpaper -> ChatWallpaper -> Bool) -> Eq ChatWallpaper forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: ChatWallpaper -> ChatWallpaper -> Bool == :: ChatWallpaper -> ChatWallpaper -> Bool $c/= :: ChatWallpaper -> ChatWallpaper -> Bool /= :: ChatWallpaper -> ChatWallpaper -> Bool Eq, Int -> ChatWallpaper -> ShowS [ChatWallpaper] -> ShowS ChatWallpaper -> String (Int -> ChatWallpaper -> ShowS) -> (ChatWallpaper -> String) -> ([ChatWallpaper] -> ShowS) -> Show ChatWallpaper forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> ChatWallpaper -> ShowS showsPrec :: Int -> ChatWallpaper -> ShowS $cshow :: ChatWallpaper -> String show :: ChatWallpaper -> String $cshowList :: [ChatWallpaper] -> ShowS showList :: [ChatWallpaper] -> ShowS Show) data ChatWallpaperScale = CWSFill | CWSFit | CWSRepeat deriving (ChatWallpaperScale -> ChatWallpaperScale -> Bool (ChatWallpaperScale -> ChatWallpaperScale -> Bool) -> (ChatWallpaperScale -> ChatWallpaperScale -> Bool) -> Eq ChatWallpaperScale forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: ChatWallpaperScale -> ChatWallpaperScale -> Bool == :: ChatWallpaperScale -> ChatWallpaperScale -> Bool $c/= :: ChatWallpaperScale -> ChatWallpaperScale -> Bool /= :: ChatWallpaperScale -> ChatWallpaperScale -> Bool Eq, Int -> ChatWallpaperScale -> ShowS [ChatWallpaperScale] -> ShowS ChatWallpaperScale -> String (Int -> ChatWallpaperScale -> ShowS) -> (ChatWallpaperScale -> String) -> ([ChatWallpaperScale] -> ShowS) -> Show ChatWallpaperScale forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> ChatWallpaperScale -> ShowS showsPrec :: Int -> ChatWallpaperScale -> ShowS $cshow :: ChatWallpaperScale -> String show :: ChatWallpaperScale -> String $cshowList :: [ChatWallpaperScale] -> ShowS showList :: [ChatWallpaperScale] -> ShowS Show) data UIColors = UIColors { UIColors -> Maybe UIColor accent :: Maybe UIColor, UIColors -> Maybe UIColor accentVariant :: Maybe UIColor, UIColors -> Maybe UIColor secondary :: Maybe UIColor, UIColors -> Maybe UIColor secondaryVariant :: Maybe UIColor, UIColors -> Maybe UIColor background :: Maybe UIColor, :: Maybe UIColor, UIColors -> Maybe UIColor title :: Maybe UIColor, UIColors -> Maybe UIColor accentVariant2 :: Maybe UIColor, UIColors -> Maybe UIColor sentMessage :: Maybe UIColor, UIColors -> Maybe UIColor sentReply :: Maybe UIColor, UIColors -> Maybe UIColor receivedMessage :: Maybe UIColor, UIColors -> Maybe UIColor receivedReply :: Maybe UIColor } deriving (UIColors -> UIColors -> Bool (UIColors -> UIColors -> Bool) -> (UIColors -> UIColors -> Bool) -> Eq UIColors forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: UIColors -> UIColors -> Bool == :: UIColors -> UIColors -> Bool $c/= :: UIColors -> UIColors -> Bool /= :: UIColors -> UIColors -> Bool Eq, Int -> UIColors -> ShowS [UIColors] -> ShowS UIColors -> String (Int -> UIColors -> ShowS) -> (UIColors -> String) -> ([UIColors] -> ShowS) -> Show UIColors forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> UIColors -> ShowS showsPrec :: Int -> UIColors -> ShowS $cshow :: UIColors -> String show :: UIColors -> String $cshowList :: [UIColors] -> ShowS showList :: [UIColors] -> ShowS Show) defaultUIColors :: UIColors defaultUIColors :: UIColors defaultUIColors = Maybe UIColor -> Maybe UIColor -> Maybe UIColor -> Maybe UIColor -> Maybe UIColor -> Maybe UIColor -> Maybe UIColor -> Maybe UIColor -> Maybe UIColor -> Maybe UIColor -> Maybe UIColor -> Maybe UIColor -> UIColors UIColors Maybe UIColor forall a. Maybe a Nothing Maybe UIColor forall a. Maybe a Nothing Maybe UIColor forall a. Maybe a Nothing Maybe UIColor forall a. Maybe a Nothing Maybe UIColor forall a. Maybe a Nothing Maybe UIColor forall a. Maybe a Nothing Maybe UIColor forall a. Maybe a Nothing Maybe UIColor forall a. Maybe a Nothing Maybe UIColor forall a. Maybe a Nothing Maybe UIColor forall a. Maybe a Nothing Maybe UIColor forall a. Maybe a Nothing Maybe UIColor forall a. Maybe a Nothing newtype UIColor = UIColor String deriving (UIColor -> UIColor -> Bool (UIColor -> UIColor -> Bool) -> (UIColor -> UIColor -> Bool) -> Eq UIColor forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: UIColor -> UIColor -> Bool == :: UIColor -> UIColor -> Bool $c/= :: UIColor -> UIColor -> Bool /= :: UIColor -> UIColor -> Bool Eq, Int -> UIColor -> ShowS [UIColor] -> ShowS UIColor -> String (Int -> UIColor -> ShowS) -> (UIColor -> String) -> ([UIColor] -> ShowS) -> Show UIColor forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> UIColor -> ShowS showsPrec :: Int -> UIColor -> ShowS $cshow :: UIColor -> String show :: UIColor -> String $cshowList :: [UIColor] -> ShowS showList :: [UIColor] -> ShowS Show) instance FromJSON UIColor where parseJSON :: Value -> Parser UIColor parseJSON Value v = String -> Parser UIColor forall {f :: * -> *}. MonadFail f => String -> f UIColor toColor (String -> Parser UIColor) -> Parser String -> Parser UIColor forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b =<< Value -> Parser String forall a. FromJSON a => Value -> Parser a J.parseJSON Value v where toColor :: String -> f UIColor toColor s :: String s@(Char '#' : String cs) | String -> Int forall a. [a] -> Int forall (t :: * -> *) a. Foldable t => t a -> Int length String cs Int -> Int -> Bool forall a. Eq a => a -> a -> Bool == Int 8 Bool -> Bool -> Bool && (Char -> Bool) -> String -> Bool forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool all Char -> Bool hexDigit String cs = UIColor -> f UIColor forall a. a -> f a forall (f :: * -> *) a. Applicative f => a -> f a pure (UIColor -> f UIColor) -> UIColor -> f UIColor forall a b. (a -> b) -> a -> b $ String -> UIColor UIColor String s toColor String _ = String -> f UIColor forall a. String -> f a forall (m :: * -> *) a. MonadFail m => String -> m a fail String "bad UIColor" hexDigit :: Char -> Bool hexDigit Char c = (Char c Char -> Char -> Bool forall a. Ord a => a -> a -> Bool >= Char '0' Bool -> Bool -> Bool && Char c Char -> Char -> Bool forall a. Ord a => a -> a -> Bool <= Char '9') Bool -> Bool -> Bool || (let c' :: Char c' = Char -> Char toLower Char c in Char c' Char -> Char -> Bool forall a. Ord a => a -> a -> Bool >= Char 'a' Bool -> Bool -> Bool && Char c' Char -> Char -> Bool forall a. Ord a => a -> a -> Bool <= Char 'f') instance ToJSON UIColor where toJSON :: UIColor -> Value toJSON (UIColor String t) = String -> Value forall a. ToJSON a => a -> Value J.toJSON String t toEncoding :: UIColor -> Encoding toEncoding (UIColor String t) = String -> Encoding forall a. ToJSON a => a -> Encoding J.toEncoding String t $(JQ.deriveJSON (enumJSON $ dropPrefix "UCM") ''UIColorMode) $(JQ.deriveJSON (enumJSON $ dropPrefix "CWS") ''ChatWallpaperScale) $(JQ.deriveJSON defaultJSON ''ChatWallpaper) $(JQ.deriveJSON defaultJSON ''UIColors) $(JQ.deriveJSON defaultJSON ''UIThemeEntityOverride) $(JQ.deriveJSON defaultJSON ''UIThemeEntityOverrides) $(JQ.deriveJSON defaultJSON ''UITheme) instance ToField UIThemeEntityOverrides where toField :: UIThemeEntityOverrides -> SQLData toField = Text -> SQLData forall a. ToField a => a -> SQLData toField (Text -> SQLData) -> (UIThemeEntityOverrides -> Text) -> UIThemeEntityOverrides -> SQLData forall b c a. (b -> c) -> (a -> b) -> a -> c . UIThemeEntityOverrides -> Text forall a. ToJSON a => a -> Text encodeJSON instance FromField UIThemeEntityOverrides where fromField :: FieldParser UIThemeEntityOverrides fromField = (Text -> Maybe UIThemeEntityOverrides) -> FieldParser UIThemeEntityOverrides forall a. Typeable a => (Text -> Maybe a) -> Field -> Ok a fromTextField_ ((Text -> Maybe UIThemeEntityOverrides) -> FieldParser UIThemeEntityOverrides) -> (Text -> Maybe UIThemeEntityOverrides) -> FieldParser UIThemeEntityOverrides forall a b. (a -> b) -> a -> b $ UIThemeEntityOverrides -> Maybe UIThemeEntityOverrides forall a. a -> Maybe a Just (UIThemeEntityOverrides -> Maybe UIThemeEntityOverrides) -> (Text -> UIThemeEntityOverrides) -> Text -> Maybe UIThemeEntityOverrides forall b c a. (b -> c) -> (a -> b) -> a -> c . UIThemeEntityOverrides -> Maybe UIThemeEntityOverrides -> UIThemeEntityOverrides forall a. a -> Maybe a -> a fromMaybe (Maybe UIThemeEntityOverride -> Maybe UIThemeEntityOverride -> UIThemeEntityOverrides UIThemeEntityOverrides Maybe UIThemeEntityOverride forall a. Maybe a Nothing Maybe UIThemeEntityOverride forall a. Maybe a Nothing) (Maybe UIThemeEntityOverrides -> UIThemeEntityOverrides) -> (Text -> Maybe UIThemeEntityOverrides) -> Text -> UIThemeEntityOverrides forall b c a. (b -> c) -> (a -> b) -> a -> c . Text -> Maybe UIThemeEntityOverrides forall a. FromJSON a => Text -> Maybe a decodeJSON