{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.QuickSight.Types.TileLayoutStyle
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QuickSight.Types.TileLayoutStyle where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types.GutterStyle
import Amazonka.QuickSight.Types.MarginStyle

-- | The display options for the layout of tiles on a sheet.
--
-- /See:/ 'newTileLayoutStyle' smart constructor.
data TileLayoutStyle = TileLayoutStyle'
  { -- | The margin settings that apply around the outside edge of sheets.
    TileLayoutStyle -> Maybe MarginStyle
margin :: Prelude.Maybe MarginStyle,
    -- | The gutter settings that apply between tiles.
    TileLayoutStyle -> Maybe GutterStyle
gutter :: Prelude.Maybe GutterStyle
  }
  deriving (TileLayoutStyle -> TileLayoutStyle -> Bool
(TileLayoutStyle -> TileLayoutStyle -> Bool)
-> (TileLayoutStyle -> TileLayoutStyle -> Bool)
-> Eq TileLayoutStyle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TileLayoutStyle -> TileLayoutStyle -> Bool
$c/= :: TileLayoutStyle -> TileLayoutStyle -> Bool
== :: TileLayoutStyle -> TileLayoutStyle -> Bool
$c== :: TileLayoutStyle -> TileLayoutStyle -> Bool
Prelude.Eq, ReadPrec [TileLayoutStyle]
ReadPrec TileLayoutStyle
Int -> ReadS TileLayoutStyle
ReadS [TileLayoutStyle]
(Int -> ReadS TileLayoutStyle)
-> ReadS [TileLayoutStyle]
-> ReadPrec TileLayoutStyle
-> ReadPrec [TileLayoutStyle]
-> Read TileLayoutStyle
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TileLayoutStyle]
$creadListPrec :: ReadPrec [TileLayoutStyle]
readPrec :: ReadPrec TileLayoutStyle
$creadPrec :: ReadPrec TileLayoutStyle
readList :: ReadS [TileLayoutStyle]
$creadList :: ReadS [TileLayoutStyle]
readsPrec :: Int -> ReadS TileLayoutStyle
$creadsPrec :: Int -> ReadS TileLayoutStyle
Prelude.Read, Int -> TileLayoutStyle -> ShowS
[TileLayoutStyle] -> ShowS
TileLayoutStyle -> String
(Int -> TileLayoutStyle -> ShowS)
-> (TileLayoutStyle -> String)
-> ([TileLayoutStyle] -> ShowS)
-> Show TileLayoutStyle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TileLayoutStyle] -> ShowS
$cshowList :: [TileLayoutStyle] -> ShowS
show :: TileLayoutStyle -> String
$cshow :: TileLayoutStyle -> String
showsPrec :: Int -> TileLayoutStyle -> ShowS
$cshowsPrec :: Int -> TileLayoutStyle -> ShowS
Prelude.Show, (forall x. TileLayoutStyle -> Rep TileLayoutStyle x)
-> (forall x. Rep TileLayoutStyle x -> TileLayoutStyle)
-> Generic TileLayoutStyle
forall x. Rep TileLayoutStyle x -> TileLayoutStyle
forall x. TileLayoutStyle -> Rep TileLayoutStyle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TileLayoutStyle x -> TileLayoutStyle
$cfrom :: forall x. TileLayoutStyle -> Rep TileLayoutStyle x
Prelude.Generic)

-- |
-- Create a value of 'TileLayoutStyle' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'margin', 'tileLayoutStyle_margin' - The margin settings that apply around the outside edge of sheets.
--
-- 'gutter', 'tileLayoutStyle_gutter' - The gutter settings that apply between tiles.
newTileLayoutStyle ::
  TileLayoutStyle
newTileLayoutStyle :: TileLayoutStyle
newTileLayoutStyle =
  TileLayoutStyle' :: Maybe MarginStyle -> Maybe GutterStyle -> TileLayoutStyle
TileLayoutStyle'
    { $sel:margin:TileLayoutStyle' :: Maybe MarginStyle
margin = Maybe MarginStyle
forall a. Maybe a
Prelude.Nothing,
      $sel:gutter:TileLayoutStyle' :: Maybe GutterStyle
gutter = Maybe GutterStyle
forall a. Maybe a
Prelude.Nothing
    }

-- | The margin settings that apply around the outside edge of sheets.
tileLayoutStyle_margin :: Lens.Lens' TileLayoutStyle (Prelude.Maybe MarginStyle)
tileLayoutStyle_margin :: (Maybe MarginStyle -> f (Maybe MarginStyle))
-> TileLayoutStyle -> f TileLayoutStyle
tileLayoutStyle_margin = (TileLayoutStyle -> Maybe MarginStyle)
-> (TileLayoutStyle -> Maybe MarginStyle -> TileLayoutStyle)
-> Lens
     TileLayoutStyle
     TileLayoutStyle
     (Maybe MarginStyle)
     (Maybe MarginStyle)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TileLayoutStyle' {Maybe MarginStyle
margin :: Maybe MarginStyle
$sel:margin:TileLayoutStyle' :: TileLayoutStyle -> Maybe MarginStyle
margin} -> Maybe MarginStyle
margin) (\s :: TileLayoutStyle
s@TileLayoutStyle' {} Maybe MarginStyle
a -> TileLayoutStyle
s {$sel:margin:TileLayoutStyle' :: Maybe MarginStyle
margin = Maybe MarginStyle
a} :: TileLayoutStyle)

-- | The gutter settings that apply between tiles.
tileLayoutStyle_gutter :: Lens.Lens' TileLayoutStyle (Prelude.Maybe GutterStyle)
tileLayoutStyle_gutter :: (Maybe GutterStyle -> f (Maybe GutterStyle))
-> TileLayoutStyle -> f TileLayoutStyle
tileLayoutStyle_gutter = (TileLayoutStyle -> Maybe GutterStyle)
-> (TileLayoutStyle -> Maybe GutterStyle -> TileLayoutStyle)
-> Lens
     TileLayoutStyle
     TileLayoutStyle
     (Maybe GutterStyle)
     (Maybe GutterStyle)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TileLayoutStyle' {Maybe GutterStyle
gutter :: Maybe GutterStyle
$sel:gutter:TileLayoutStyle' :: TileLayoutStyle -> Maybe GutterStyle
gutter} -> Maybe GutterStyle
gutter) (\s :: TileLayoutStyle
s@TileLayoutStyle' {} Maybe GutterStyle
a -> TileLayoutStyle
s {$sel:gutter:TileLayoutStyle' :: Maybe GutterStyle
gutter = Maybe GutterStyle
a} :: TileLayoutStyle)

instance Core.FromJSON TileLayoutStyle where
  parseJSON :: Value -> Parser TileLayoutStyle
parseJSON =
    String
-> (Object -> Parser TileLayoutStyle)
-> Value
-> Parser TileLayoutStyle
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TileLayoutStyle"
      ( \Object
x ->
          Maybe MarginStyle -> Maybe GutterStyle -> TileLayoutStyle
TileLayoutStyle'
            (Maybe MarginStyle -> Maybe GutterStyle -> TileLayoutStyle)
-> Parser (Maybe MarginStyle)
-> Parser (Maybe GutterStyle -> TileLayoutStyle)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe MarginStyle)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Margin")
            Parser (Maybe GutterStyle -> TileLayoutStyle)
-> Parser (Maybe GutterStyle) -> Parser TileLayoutStyle
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe GutterStyle)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Gutter")
      )

instance Prelude.Hashable TileLayoutStyle

instance Prelude.NFData TileLayoutStyle

instance Core.ToJSON TileLayoutStyle where
  toJSON :: TileLayoutStyle -> Value
toJSON TileLayoutStyle' {Maybe GutterStyle
Maybe MarginStyle
gutter :: Maybe GutterStyle
margin :: Maybe MarginStyle
$sel:gutter:TileLayoutStyle' :: TileLayoutStyle -> Maybe GutterStyle
$sel:margin:TileLayoutStyle' :: TileLayoutStyle -> Maybe MarginStyle
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Margin" Text -> MarginStyle -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (MarginStyle -> Pair) -> Maybe MarginStyle -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MarginStyle
margin,
            (Text
"Gutter" Text -> GutterStyle -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (GutterStyle -> Pair) -> Maybe GutterStyle -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GutterStyle
gutter
          ]
      )