Skip to content
New issue

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

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

Already on GitHub? # to your account

Indicator hotfix #273

Merged
merged 4 commits into from
Apr 6, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Date format: DD/MM/YYYY
## [3.x.x]

- Fix overflow behavior for `TreeViewItem` ([#270](https://github.com/bdlukaa/fluent_ui/pull/270))
- Do not animate sticky indicators when parent is updated ([#273](https://github.com/bdlukaa/fluent_ui/pull/273))

## [3.10.0] - Localization, Indicators, CommandBar and Flyouts - [02/04/2022]

Expand Down
22 changes: 22 additions & 0 deletions lib/src/controls/navigation/navigation_view/body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,25 @@ class InheritedNavigationView extends InheritedWidget {
oldWidget.itemIndex != oldWidget.itemIndex;
}
}

/// Makes the [GlobalKey]s for [PaneItem]s accesible on the scope.
class _PaneItemKeys extends InheritedWidget {
const _PaneItemKeys({
Key? key,
required Widget child,
required this.keys,
}) : super(key: key, child: child);

final Map<int, GlobalKey> keys;

static GlobalKey of(int index, BuildContext context) {
final reference =
context.dependOnInheritedWidgetOfExactType<_PaneItemKeys>()!;
return reference.keys[index]!;
}

@override
bool updateShouldNotify(_PaneItemKeys oldWidget) {
return keys != oldWidget.keys;
}
}
16 changes: 10 additions & 6 deletions lib/src/controls/navigation/navigation_view/pane.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ enum PaneDisplayMode {
/// ![Minimal Display Mode](https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/images/displaymode-leftminimal.png)
minimal,

/// Let the [NavigationPane] decide what display mode should be used
/// based on the width. This is used by default on [NavigationPanel].
/// In Auto mode, the [NavigationPane] adapts between [minimal] when
/// the window is narrow, to [compact], and then [open] as the window
/// gets wider.
/// Let the [NavigationPane] decide what display mode should be used based on
/// the width. This is used by default on [NavigationPane]. In Auto mode, the
/// [NavigationPane] adapts between [minimal] when the window is narrow, to
/// [compact], and then [open] as the window gets wider.
///
/// ![Automatic Display Mode](https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/images/displaymode-auto.png)
/// - An expanded left pane on large window widths (1008px or greater).
/// - A left, icon-only, nav pane (LeftCompact) on medium window widths
/// (641px to 1007px).
/// - Only a menu button (LeftMinimal) on small window widths (640px or less).
///
/// ![Automatic Display Mode](https://docs.microsoft.com/en-us/windows/apps/design/controls/images/adaptive-behavior-minimal.png)
auto,
}

Expand Down
8 changes: 7 additions & 1 deletion lib/src/controls/navigation/navigation_view/pane_items.dart
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ class PaneItem extends NavigationPaneItem {
}
}();

final GlobalKey? key = () {
if (index != null && !index.isNegative) {
return _PaneItemKeys.of(index, context);
}
}();

return Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: () {
Expand All @@ -377,7 +383,7 @@ class PaneItem extends NavigationPaneItem {
child: InheritedNavigationView.merge(
itemIndex: index,
child: KeyedSubtree(
key: index != null ? ValueKey<int>(index) : null,
key: index != null ? key : null,
child: maybeBody!.pane!.indicator!,
),
),
Expand Down
Loading