Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab visibility #2213

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions package/lib/src/controls/tabs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class _TabsControlState extends State<TabsControl>
Widget build(BuildContext context) {
debugPrint("TabsControl build: ${widget.control.id}");

// keep only visible tabs
widget.children.retainWhere((c) => c.isVisible);

var tabs = StoreConnector<AppState, ControlsViewModel>(
distinct: true,
converter: (store) => ControlsViewModel.fromStore(
Expand Down Expand Up @@ -121,12 +124,12 @@ class _TabsControlState extends State<TabsControl>

var indicatorBorderRadius =
parseBorderRadius(widget.control, "indicatorBorderRadius");
var inidicatorBorderSide = parseBorderSide(
Theme.of(context), widget.control, "inidicatorBorderSide");
var indicatorBorderSide = parseBorderSide(
Theme.of(context), widget.control, "indicatorBorderSide");
var indicatorPadding =
parseEdgeInsets(widget.control, "indicatorPadding");

var inidicatorColor = HexColor.fromString(Theme.of(context),
var indicatorColor = HexColor.fromString(Theme.of(context),
widget.control.attrString("indicatorColor", "")!) ??
TabBarTheme.of(context).indicatorColor ??
Theme.of(context).colorScheme.primary;
Expand All @@ -148,25 +151,25 @@ class _TabsControlState extends State<TabsControl>
: TabBarIndicatorSize.label)
: TabBarTheme.of(context).indicatorSize,
indicator: indicatorBorderRadius != null ||
inidicatorBorderSide != null ||
indicatorBorderSide != null ||
indicatorPadding != null
? UnderlineTabIndicator(
borderRadius: indicatorBorderRadius ??
themeIndicator?.borderRadius ??
const BorderRadius.only(
topLeft: Radius.circular(2),
topRight: Radius.circular(2)),
borderSide: inidicatorBorderSide ??
borderSide: indicatorBorderSide ??
themeIndicator?.borderSide ??
BorderSide(
width: themeIndicator?.borderSide.width ?? 2,
color: themeIndicator?.borderSide.color ??
inidicatorColor),
indicatorColor),
insets: indicatorPadding ??
themeIndicator?.insets ??
EdgeInsets.zero)
: TabBarTheme.of(context).indicator,
indicatorColor: inidicatorColor,
indicatorColor: indicatorColor,
labelColor: HexColor.fromString(Theme.of(context), widget.control.attrString("labelColor", "")!) ??
TabBarTheme.of(context).labelColor ??
Theme.of(context).colorScheme.primary,
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/packages/flet-core/src/flet_core/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ def __init__(
tab_content: Optional[Control] = None,
ref: Optional[Ref] = None,
icon: Optional[str] = None,
visible: Optional[bool] = None,
):
Control.__init__(self, ref=ref)
Control.__init__(self, ref=ref, visible=visible)
self.text = text
self.icon = icon
self.__content: Optional[Control] = None
Expand Down