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

Add support for reserved footer area #1137

Merged
merged 4 commits into from
Nov 18, 2024
Merged

Conversation

diluculo
Copy link
Contributor

This PR resolves #1106 by adding support for a guaranteed minimum space between tabs and footer in TabView. This is particularly critical when using TabView in TitleBar to ensure there's always enough space for DragToMoveArea, regardless of the number of tabs.

Changes:

  1. Add reservedStripWidth property to TabView.
  2. Modify tab width calculation to consider reserved space:
preferredTabWidth = ((width - 
   (widget.showNewButton ? _kButtonWidth : 0) - 
   (widget.reservedStripWidth ?? 0)) / widget.tabs.length)
   .clamp(widget.minTabWidth, widget.maxTabWidth);
  1. Add reserved space in strip layout after new tab button:
// In strip children
if (widget.reservedStripWidth != null)
  SizedBox(width: widget.reservedStripWidth),

Example usage:

TabView(
  footer: const WindowButtons(),
  reservedStripWidth: 100.0,
  stripBuilder: (context, strip) {
    return DragToMoveArea(child: strip);
  },
  // ... other properties
)

Pre-launch Checklist

  • I have updated CHANGELOG.md with my changes
  • I have run "dart format ." on the project
  • I have added/updated relevant documentation

@diluculo
Copy link
Contributor Author

image

@WinXaito
Copy link
Collaborator

WinXaito commented Nov 18, 2024

I didn't really understand the goal of this PR, but

to ensure there's always enough space for DragToMoveArea, regardless of the number of tabs.

make total sense with the issue linked.


Otherwise LGTM (I didn't test, only take a look at the code). I approved the checks to run.

I let @bdlukaa do the final validation.

@diluculo
Copy link
Contributor Author

@WinXaito, Thanks for the review! Yes, the main purpose is exactly that - ensuring drag area is preserved regardless of tab count.

CHANGELOG.md Outdated Show resolved Hide resolved
lib/src/controls/navigation/tab_view.dart Outdated Show resolved Hide resolved
@bdlukaa bdlukaa merged commit f327a58 into bdlukaa:master Nov 18, 2024
@diluculo diluculo deleted the tabview branch November 18, 2024 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to manipulate the TabView strip
3 participants