Skip to content
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## next
## (future)

- Fix assertion in `NavigationViewState` if no pane was currently selected ([#678](https://github.com/bdlukaa/fluent_ui/issues/678))
- Make `NavigationView.paneBodyBuilder` responsible for state management of the widget it returns, allowing `paneBodyBuilder` to return an `IndexedStack` (common use case) ([#679](https://github.com/bdlukaa/fluent_ui/issues/679))
- Add `AutoSuggestBox.maxPopupHeight` ([#677](https://github.com/bdlukaa/fluent_ui/issues/677))

## 4.1.4
Expand Down
54 changes: 33 additions & 21 deletions lib/src/controls/navigation/navigation_view/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,27 +140,39 @@ class _NavigationBodyState extends State<_NavigationBody> {
child: child,
);
},
child: KeyedSubtree(
key: widget.itemKey,
child: PageView.builder(
key: _pageKey,
physics: const NeverScrollableScrollPhysics(),
controller: pageController,
itemCount: view.pane!.effectiveItems.length,
itemBuilder: (context, index) {
final isSelected = view.pane!.selected == index;
final item = view.pane!.effectiveItems[index];

return ExcludeFocus(
key: item.bodyKey,
excluding: !isSelected,
child: FocusTraversalGroup(
child: widget.paneBodyBuilder?.call(item.body) ?? item.body,
),
);
},
),
),
child: () {
final paneBodyBuilder = widget.paneBodyBuilder;
if (paneBodyBuilder != null) {
return FocusTraversalGroup(
key: widget.itemKey,
child: paneBodyBuilder.call(view.pane?.selected != null
? view.pane?.selectedItem.body
: null),
);
Comment thread
bdlukaa marked this conversation as resolved.
} else {
return KeyedSubtree(
key: widget.itemKey,
child: PageView.builder(
key: _pageKey,
physics: const NeverScrollableScrollPhysics(),
controller: pageController,
itemCount: view.pane!.effectiveItems.length,
itemBuilder: (context, index) {
final isSelected = view.pane!.selected == index;
final item = view.pane!.effectiveItems[index];

return ExcludeFocus(
key: item.bodyKey,
excluding: !isSelected,
child: FocusTraversalGroup(
child: item.body,
),
);
},
),
);
}
}(),
),
);
}
Expand Down
8 changes: 7 additions & 1 deletion lib/src/controls/navigation/navigation_view/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class NavigationView extends StatefulWidget {
/// and the body of the navigation pane is dynamically determined or
/// affected by the current route rather than just by the currently
/// selected pane.
///
/// If this is not null then this builder will be responsible for state
/// management of the child widget. One way to accomplish this is to
/// use an [IndexedStack].
final NavigationContentBuilder? paneBodyBuilder;

/// The navigation pane, that can be displayed either on the
Expand Down Expand Up @@ -214,7 +218,9 @@ class NavigationViewState extends State<NavigationView> {
if (oldWidget.pane?.selected != widget.pane?.selected) {
_oldIndex = oldWidget.pane?.selected ?? -1;

final item = widget.pane?.selectedItem.itemKey.currentContext;
final item = widget.pane?.selected == null
? null
: widget.pane?.selectedItem.itemKey.currentContext;

if (item != null) {
final atEnd =
Expand Down