Skip to content

Commit

Permalink
MTabs. MTabsIconLeftAlign. Fixed icon location.
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaFil committed May 6, 2019
1 parent 3e2cf2d commit 1460533
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
18 changes: 10 additions & 8 deletions lib/material/internal/material_tabs.flow
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,19 @@ MDynamicTabs2T(manager : MaterialManager, parent : MFocusGroup, m : MDynamicTabs
else
TEmpty()
)
|> TSetMinWidth2(const(tabMinWidth))
|> (if (leftAlignIcon) idfn else TSetMinWidth2(const(tabMinWidth)))
|> (\t -> eitherMap(tabIcon, \ti ->
TLines2(
m2t(ti.icon, p2)
|> (\t2 -> if (leftAlignIcon) t2 else TCenterX(t2))
|> (\t2 -> TBorder(0., 2., 0., 2., t2)),
t
), t
|> (if (leftAlignIcon)
TBorderLeftRight(2.)
else
\t2 -> TCenterX(t2) |> TBorderTopBottom(2.)
)
|> (\t2 -> if (leftAlignIcon) TCols2(t2, t) else TLines2(t2, t)),
t
))
|> (\t -> TBorder(bordersGap / 2., 0., bordersGap / 2., 0., t))
|> (\t -> if (leftAlignIcon) t else TCenter(t))
|> (if (leftAlignIcon) TCenterY else TCenter)
|> (\t ->
MComponent2T(
manager,
Expand Down Expand Up @@ -307,7 +309,7 @@ MDynamicTabs2T(manager : MaterialManager, parent : MFocusGroup, m : MDynamicTabs
next(tabsWidths, map(tabsWidthsD, getValue));
}),

\ -> fconnectSelect(isAnyIcon, tabsHeight, \b -> max(getValue(tabsHeight), if (b) tabsPanelHeightWithIcons else tabsPanelHeight))
\ -> fconnectSelect(isAnyIcon, tabsHeight, \b -> max(getValue(tabsHeight), if (b && !leftAlignIcon) tabsPanelHeightWithIcons else tabsPanelHeight))
],
t
)
Expand Down
15 changes: 13 additions & 2 deletions lib/material/tests/mtabs_size.flow
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@ import material/material2tropic;
main () {
manager = makeMaterialManager([]);

makeTabs = \ -> {map(["tab text 1", "tab text 2", "tab text 3", "tab text 4", "tab text 5"], \t -> MTab(TText(t, [Fill(black), FontSize(16.), FontFamily("Roboto")]), const(t), []))};
makeTabs = \ -> {
map(
["tab text 1", "tab text 2", "tab text 3", "tab text 4", "tab text 5"],
\t ->
MTab(
TText(t, [Fill(black), FontSize(16.), FontFamily("Roboto")]),
const(t), [
MTabIcon(MIcon("android", []))
]
)
)
};

form = MLines([
MTabs(makeTabs(), make(0), [MNoScroll()]),
MTabs(makeTabs(), make(0), [MNoScroll(), MTabsIconLeftAlign()]),
TText("text below MTab", [Fill(red), FontSize(16.), FontFamily("Roboto")]),
]);

Expand Down

0 comments on commit 1460533

Please sign in to comment.