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

Implement TreeView #120

Merged
merged 3 commits into from
Dec 25, 2021
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 @@ -2,6 +2,7 @@ Date format: DD/MM/YYYY

## [3.5.3] - [DD/MM/YYYY]

- Implement `TreeView`
- Fix scroll buttons when there are too many tabs in `TabView` ([#92](https://github.com/bdlukaa/fluent_ui/issues/92))
- Fix button style on tab in `TabView` ([#90](https://github.com/bdlukaa/fluent_ui/issues/90))
- Fix `Slider` and `RatingBar` ([#116](https://github.com/bdlukaa/fluent_ui/issues/116))
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Unofficial implementation of Fluent UI for [Flutter](flutter.dev). It's written
- [Scrollbar](#scrollbar)
- [List Tile](#list-tile)
- [Info Header](#info-header)
- [TreeView](#treeview)
- [Mobile Widgets](#mobile-widgets)
- [Chip](#chip)
- [Pill Button Bar](#pill-button-bar)
Expand Down Expand Up @@ -1459,6 +1460,53 @@ ComboBox(

This will produce the same as the image above.

## TreeView

The `TreeView` control enables a hierarchical list with expanding and collapsing nodes that contain nested items. It can be used to illustrate a folder structure or nested relationships in your UI. [Learn More](https://docs.microsoft.com/en-us/windows/apps/design/controls/tree-view)

The tree view uses a combination of indentation and icons to represent the nested relationship between parent nodes and child nodes. Collapsed nodes use a chevron pointing to the right, and expanded nodes use a chevron pointing down.

![TreeView Simple](https://docs.microsoft.com/en-us/windows/apps/design/controls/images/treeview-simple.png)

You can include an icon in the tree view item data template to represent nodes. For example, if you show a file system hierarchy, you could use folder icons for the parent notes and file icons for the leaf nodes.

![TreeView Icons](https://docs.microsoft.com/en-us/windows/apps/design/controls/images/treeview-icons.png)

Here's an example of how to create a tree view:

```dart
TreeView(
items: [
TreeViewItem(
content: const Text('Work Documents'),
children: [
TreeViewItem(content: const Text('XYZ Functional Spec')),
TreeViewItem(content: const Text('Feature Schedule')),
TreeViewItem(content: const Text('Overall Project Plan')),
TreeViewItem(content: const Text('Feature Resources Allocation')),
],
),
TreeViewItem(
content: const Text('Personal Documents'),
children: [
TreeViewItem(
content: const Text('Home Remodel'),
children: [
TreeViewItem(content: const Text('Contractor Contact Info')),
TreeViewItem(content: const Text('Paint Color Scheme')),
TreeViewItem(content: const Text('Flooring weedgrain type')),
TreeViewItem(content: const Text('Kitchen cabinet style')),
],
),
],
),
],
onItemInvoked: (item) => debugPrint(item), // (optional)
// (optional). Can be TreeViewSelectionMode.single or TreeViewSelectionMode.multiple
selectionMode: TreeViewSelectionMode.none,
),
```

# Mobile Widgets

Widgets with focus on mobile. Based on the official documentation and source code for [iOS](https://developer.microsoft.com/pt-br/fluentui#/controls/ios) and [Android](https://developer.microsoft.com/pt-br/fluentui#/controls/android). Most of the widgets above can adapt to small screens, and will fit on all your devices.
Expand Down
79 changes: 79 additions & 0 deletions example/lib/screens/others.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,32 @@ class _OthersState extends State<Others> {

bool checked = false;

final items = [
TreeViewItem(
content: const Text('Work Documents'),
children: [
TreeViewItem(content: const Text('XYZ Functional Spec')),
TreeViewItem(content: const Text('Feature Schedule')),
TreeViewItem(content: const Text('Overall Project Plan')),
TreeViewItem(content: const Text('Feature Resources Allocation')),
],
),
TreeViewItem(
content: const Text('Personal Documents'),
children: [
TreeViewItem(
content: const Text('Home Remodel'),
children: [
TreeViewItem(content: const Text('Contractor Contact Info')),
TreeViewItem(content: const Text('Paint Color Scheme')),
TreeViewItem(content: const Text('Flooring weedgrain type')),
TreeViewItem(content: const Text('Kitchen cabinet style')),
],
),
],
),
];

@override
void dispose() {
flyoutController.dispose();
Expand Down Expand Up @@ -254,6 +280,59 @@ class _OthersState extends State<Others> {
),
),
),
const SizedBox(height: 20.0),
SizedBox(
height: 380.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: [
Container(
constraints: const BoxConstraints(
maxHeight: 380,
minHeight: 380,
maxWidth: 350,
),
decoration: BoxDecoration(
border: Border.all(
color: FluentTheme.of(context).inactiveColor),
),
child: TreeView(items: items),
),
Container(
constraints: const BoxConstraints(
maxHeight: 380,
minHeight: 380,
maxWidth: 350,
),
decoration: BoxDecoration(
border: Border.all(
color: FluentTheme.of(context).inactiveColor),
),
child: TreeView(
selectionMode: TreeViewSelectionMode.single,
items: items,
onItemInvoked: (item) => debugPrint('$item'),
),
),
Container(
constraints: const BoxConstraints(
maxHeight: 380,
minHeight: 380,
maxWidth: 350,
),
decoration: BoxDecoration(
border: Border.all(
color: FluentTheme.of(context).inactiveColor),
),
child: TreeView(
selectionMode: TreeViewSelectionMode.multiple,
items: items,
onItemInvoked: (item) => debugPrint('$item'),
),
),
],
),
),
],
),
);
Expand Down
1 change: 1 addition & 0 deletions lib/fluent_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export 'src/controls/inputs/slider.dart';

export 'src/controls/navigation/navigation_view/view.dart';
export 'src/controls/navigation/tab_view.dart';
export 'src/controls/navigation/tree_view.dart';

export 'src/controls/surfaces/calendar/calendar_view.dart';
export 'src/controls/surfaces/bottom_sheet.dart';
Expand Down
Loading