Improve naming of list/dropdown combinators

This commit is contained in:
Francisco Vallarino 2020-10-27 14:45:46 -03:00
parent bdd9896450
commit a3d291223e
5 changed files with 38 additions and 45 deletions

View File

@ -179,24 +179,22 @@ class FgColor t where
class HlColor t where
hlColor :: Color -> t
class HighlightedColor t where
highlightedColor :: Color -> t
class ListStyle t s | t -> s where
listStyle :: s -> t
class NormalStyle t s | t -> s where
normalStyle :: s -> t
class HoverStyle t s | t -> s where
hoverStyle :: s -> t
class SelectedStyle t s | t -> s where
selectedStyle :: s -> t
class Transparency t where
transparency :: Double -> t
-- Item List
class ItemListStyle t s | t -> s where
itemListStyle :: s -> t
class ItemNormalStyle t s | t -> s where
itemNormalStyle :: s -> t
class ItemHoverStyle t s | t -> s where
itemHoverStyle :: s -> t
class ItemSelectedStyle t s | t -> s where
itemSelectedStyle :: s -> t
-- Align
class AlignLeft t where
alignLeft :: t

View File

@ -38,11 +38,12 @@ titleFont = def
listViewItemStyle :: StyleState
listViewItemStyle = def
& L.text ?~ normalFont
& L.text . non def . L.alignH ?~ ALeft
& L.padding ?~ paddingH 10
listViewItemSelectedStyle :: StyleState
listViewItemSelectedStyle = def
listViewItemSelectedStyle = listViewItemStyle
& L.bgColor ?~ darkGray
& L.text ?~ normalFont
darkBasic :: ThemeState
darkBasic = def
@ -72,9 +73,8 @@ darkBasic = def
& L.dropdownItemStyle .~ listViewItemStyle
& L.dropdownItemSelectedStyle .~ listViewItemSelectedStyle
& L.labelStyle . L.text ?~ normalFont
& L.listViewItemStyle . L.text ?~ normalFont
& L.listViewItemSelectedStyle . L.bgColor ?~ darkGray
& L.listViewItemSelectedStyle . L.text ?~ normalFont
& L.listViewItemStyle .~ listViewItemStyle
& L.listViewItemSelectedStyle .~ listViewItemSelectedStyle
& L.radioWidth .~ 25
& L.radioStyle . L.fgColor ?~ gray
& L.scrollBarColor .~ (gray & L.a .~ 0.2)
@ -91,6 +91,7 @@ darkHover = darkBasic
& L.btnMainStyle . L.cursorIcon ?~ CursorHand
& L.checkboxStyle . L.fgColor ?~ white
& L.checkboxStyle . L.cursorIcon ?~ CursorHand
& L.dropdownItemStyle . L.bgColor ?~ gray
& L.listViewItemStyle . L.bgColor ?~ gray
& L.radioStyle . L.fgColor ?~ white
& L.radioStyle . L.cursorIcon ?~ CursorHand
@ -98,9 +99,11 @@ darkHover = darkBasic
darkFocus :: ThemeState
darkFocus = darkBasic
& L.checkboxStyle . L.fgColor ?~ white
& L.radioStyle . L.fgColor ?~ white
& L.dropdownItemStyle . L.bgColor ?~ lightGray
& L.dropdownItemSelectedStyle . L.bgColor ?~ gray
& L.listViewItemStyle . L.bgColor ?~ lightGray
& L.listViewItemSelectedStyle . L.bgColor ?~ gray
& L.radioStyle . L.fgColor ?~ white
darkDisabled :: ThemeState
darkDisabled = darkBasic

View File

@ -34,7 +34,6 @@ data DropdownCfg s e a = DropdownCfg {
_ddcListStyle :: Maybe Style,
_ddcItemStyle :: Maybe Style,
_ddcItemSelectedStyle :: Maybe Style,
_ddcHighlightedColor :: Maybe Color,
_ddcOnChange :: [a -> e],
_ddcOnChangeReq :: [WidgetRequest s],
_ddcOnChangeIdx :: [Int -> a -> e],
@ -47,7 +46,6 @@ instance Default (DropdownCfg s e a) where
_ddcListStyle = Nothing,
_ddcItemStyle = Nothing,
_ddcItemSelectedStyle = Nothing,
_ddcHighlightedColor = Nothing,
_ddcOnChange = [],
_ddcOnChangeReq = [],
_ddcOnChangeIdx = [],
@ -60,7 +58,6 @@ instance Semigroup (DropdownCfg s e a) where
_ddcListStyle = _ddcListStyle t2 <|> _ddcListStyle t1,
_ddcItemStyle = _ddcItemStyle t2 <|> _ddcItemStyle t1,
_ddcItemSelectedStyle = _ddcItemSelectedStyle t2 <|> _ddcItemSelectedStyle t1,
_ddcHighlightedColor = _ddcHighlightedColor t2 <|> _ddcHighlightedColor t1,
_ddcOnChange = _ddcOnChange t1 <> _ddcOnChange t2,
_ddcOnChangeReq = _ddcOnChangeReq t1 <> _ddcOnChangeReq t2,
_ddcOnChangeIdx = _ddcOnChangeIdx t1 <> _ddcOnChangeIdx t2,
@ -95,18 +92,18 @@ instance MaxHeight (DropdownCfg s e a) where
_ddcMaxHeight = Just h
}
instance ListStyle (DropdownCfg s e a) Style where
listStyle style = def {
instance ItemListStyle (DropdownCfg s e a) Style where
itemListStyle style = def {
_ddcListStyle = Just style
}
instance NormalStyle (DropdownCfg s e a) Style where
normalStyle style = def {
instance ItemNormalStyle (DropdownCfg s e a) Style where
itemNormalStyle style = def {
_ddcItemStyle = Just style
}
instance SelectedStyle (DropdownCfg s e a) Style where
selectedStyle style = def {
instance ItemSelectedStyle (DropdownCfg s e a) Style where
itemSelectedStyle style = def {
_ddcItemSelectedStyle = Just style
}
@ -345,15 +342,15 @@ makeListView
-> Path
-> WidgetInstance s e
makeListView wenv value items makeRow config path = listViewInst where
normalTheme = collectTheme wenv L.listViewItemStyle
selectedTheme = collectTheme wenv L.listViewItemSelectedStyle
normalTheme = collectTheme wenv L.dropdownItemStyle
selectedTheme = collectTheme wenv L.dropdownItemSelectedStyle
itemStyle = fromJust (Just normalTheme <> _ddcItemStyle config)
itemSelStyle = fromJust (Just selectedTheme <> _ddcItemSelectedStyle config)
lvConfig = [
selectOnBlur True,
onChangeIdxReq (SendMessage path . OnChangeMessage),
normalStyle itemStyle,
selectedStyle itemSelStyle
itemNormalStyle itemStyle,
itemSelectedStyle itemSelStyle
]
lvStyle = collectTheme wenv L.dropdownListStyle
listViewInst = listViewD_ value items makeRow lvConfig & L.style .~ lvStyle

View File

@ -121,13 +121,13 @@ instance SelectOnBlur (ListViewCfg s e a) where
_lvcSelectOnBlur = Just select
}
instance NormalStyle (ListViewCfg s e a) Style where
normalStyle style = def {
instance ItemNormalStyle (ListViewCfg s e a) Style where
itemNormalStyle style = def {
_lvcItemStyle = Just style
}
instance SelectedStyle (ListViewCfg s e a) Style where
selectedStyle style = def {
instance ItemSelectedStyle (ListViewCfg s e a) Style where
itemSelectedStyle style = def {
_lvcItemSelectedStyle = Just style
}

View File

@ -34,10 +34,7 @@ themeDialogButtons :: WidgetEnv s e -> Style
themeDialogButtons wenv = collectTheme wenv L.dialogButtonsStyle
collectThemeField
:: WidgetEnv s e
-> Lens' StyleState (Maybe t)
-> Lens' ThemeState t
-> Style
:: WidgetEnv s e -> Lens' StyleState (Maybe t) -> Lens' ThemeState t -> Style
collectThemeField wenv fieldS fieldT = style where
base = def :: Style
basic = Just $ base ^. L.basic . non def
@ -50,9 +47,7 @@ collectThemeField wenv fieldS fieldT = style where
& fieldS ?~ wenv ^. L.theme . L.disabled . fieldT
style = Style basic hover focus disabled
collectTheme
:: WidgetEnv s e -> Lens' ThemeState StyleState
-> Style
collectTheme :: WidgetEnv s e -> Lens' ThemeState StyleState -> Style
collectTheme wenv fieldT = style where
basic = Just $ wenv ^. L.theme . L.basic . fieldT
hover = Just $ wenv ^. L.theme . L.hover . fieldT