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
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,18 @@ class MaterialTreeGroupComponent<T> extends MaterialTreeNode<T?>
padding += checkboxWidth;
}
}

return '${padding}px';
}

String getLastIndent(OptionGroup group) {
if (group.isNotEmpty) {
return getIndent(group.last);
}

return '0px';
}

void handleExpansion(Event e, Object option) {
toggleExpansion(option as T);
e.stopPropagation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</li>
<li *ngIf="viewMoreLinkVisible">
<div class="view-more-link-item"
[style.padding-left]="getIndent(visibleGroup.last)">
[style.padding-left]="getLastIndent(visibleGroup)">
<div class="material-tree-shift"
[style.padding-left]="fixedPadding">
<a class="view-more-link"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ class MaterialTreeNode<T> {
MaterialTreeNode(this._root, this._changeDetector,
{IsExpandable<T>? isExpandable}) {
_group = _EMPTY_OPTION_GROUP;

if (!_root.supportsHierarchy) {
_isExpandable = (_) => false;
_parent = _NotAParent();
} else {
_isExpandable = isExpandable ?? hasChildren;

// TODO: Type not match
_parent = _root.options as Parent<T, Iterable<OptionGroup<T>>>;
_parent = _root.options as Parent<T, List<OptionGroup<T>>>;
}
// TODO(google).
final Object? options = _root.options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ final SelectionOptions filterableNestedOptions =

/// An example implementation of [SelectionOptions] with [Parent].
class _NestedSelectionOptions<T> extends SelectionOptions<T>
implements Parent<T, List<OptionGroup<T>>?> {
implements Parent<T, List<OptionGroup<T>>> {
final Map<T, List<OptionGroup<T>>> _children;

_NestedSelectionOptions(List<OptionGroup<T>> options, this._children)
Expand All @@ -89,8 +89,9 @@ class _NestedSelectionOptions<T> extends SelectionOptions<T>
bool hasChildren(T item) => _children.containsKey(item);

@override
DisposableFuture<List<OptionGroup<T>>?> childrenOf(T parent, [_]) {
return DisposableFuture<List<OptionGroup<T>>?>.fromValue(_children[parent]);
DisposableFuture<List<OptionGroup<T>>> childrenOf(T parent, [_]) {
return DisposableFuture<List<OptionGroup<T>>>.fromValue(
_children[parent] ?? []);
}
}

Expand All @@ -102,7 +103,7 @@ class _NestedFilterableSelectionOptions<T extends String>
@override
String? currentQuery;

List<OptionGroup<T>>? _unfilteredOptionGroups;
List<OptionGroup<T>> _unfilteredOptionGroups = [];

_NestedFilterableSelectionOptions(
List<OptionGroup<T>> options, Map<T, List<OptionGroup<T>>> children)
Expand All @@ -113,7 +114,7 @@ class _NestedFilterableSelectionOptions<T extends String>
@override
DisposableFuture<bool> filter(Object? filterQuery, {int? limit = -1}) {
var filteredResults = <OptionGroup<T>>[];
for (var optionGroup in _unfilteredOptionGroups!) {
for (var optionGroup in _unfilteredOptionGroups) {
var resultOptionGroup = _filterGroup(filterQuery as String?, optionGroup);
if (resultOptionGroup != null) {
filteredResults.add(resultOptionGroup);
Expand All @@ -139,7 +140,7 @@ class _NestedFilterableSelectionOptions<T extends String>
if (currentQuery != null) {
filter(currentQuery, limit: currentLimit);
} else {
super.optionGroups = _unfilteredOptionGroups!;
super.optionGroups = _unfilteredOptionGroups;
}
}
}
Expand Down