forked from macosui/macos_ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: refactor dir structure * feat: Sidebar top & updated default control color * feat(example): search results in top * chore: bump version, changelog * chore: run flutter pub upgrade * Update CHANGELOG.md * Update lib/src/layout/sidebar/sidebar.dart Co-authored-by: Minas Giannekas <[email protected]>
- Loading branch information
1 parent
9aa0205
commit 6e3aa4c
Showing
13 changed files
with
232 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,8 @@ class _DemoState extends State<Demo> { | |
|
||
int pageIndex = 0; | ||
|
||
late final searchFieldController = TextEditingController(); | ||
|
||
final List<Widget> pages = [ | ||
CupertinoTabView( | ||
builder: (_) => const ButtonsPage(), | ||
|
@@ -80,6 +82,67 @@ class _DemoState extends State<Demo> { | |
// title: Text('macOS App Name'), | ||
// ), | ||
sidebar: Sidebar( | ||
top: MacosSearchField( | ||
placeholder: 'Search', | ||
controller: searchFieldController, | ||
onResultSelected: (result) { | ||
switch (result.searchKey) { | ||
case 'Buttons': | ||
setState(() { | ||
pageIndex = 0; | ||
searchFieldController.clear(); | ||
}); | ||
break; | ||
case 'Indicators': | ||
setState(() { | ||
pageIndex = 1; | ||
searchFieldController.clear(); | ||
}); | ||
break; | ||
case 'Fields': | ||
setState(() { | ||
pageIndex = 2; | ||
searchFieldController.clear(); | ||
}); | ||
break; | ||
case 'Colors': | ||
setState(() { | ||
pageIndex = 3; | ||
searchFieldController.clear(); | ||
}); | ||
break; | ||
case 'Dialogs and Sheets': | ||
setState(() { | ||
pageIndex = 5; | ||
searchFieldController.clear(); | ||
}); | ||
break; | ||
case 'Toolbar': | ||
setState(() { | ||
pageIndex = 6; | ||
searchFieldController.clear(); | ||
}); | ||
break; | ||
case 'Selectors': | ||
setState(() { | ||
pageIndex = 7; | ||
searchFieldController.clear(); | ||
}); | ||
break; | ||
default: | ||
searchFieldController.clear(); | ||
} | ||
}, | ||
results: const [ | ||
SearchResultItem('Buttons'), | ||
SearchResultItem('Indicators'), | ||
SearchResultItem('Fields'), | ||
SearchResultItem('Colors'), | ||
SearchResultItem('Dialogs and Sheets'), | ||
SearchResultItem('Toolbar'), | ||
SearchResultItem('Selectors'), | ||
], | ||
), | ||
minWidth: 200, | ||
builder: (context, controller) { | ||
return SidebarItems( | ||
|
@@ -127,13 +190,10 @@ class _DemoState extends State<Demo> { | |
], | ||
); | ||
}, | ||
bottom: const Padding( | ||
padding: EdgeInsets.all(16.0), | ||
child: MacosListTile( | ||
leading: MacosIcon(CupertinoIcons.profile_circled), | ||
title: Text('Tim Apple'), | ||
subtitle: Text('[email protected]'), | ||
), | ||
bottom: const MacosListTile( | ||
leading: MacosIcon(CupertinoIcons.profile_circled), | ||
title: Text('Tim Apple'), | ||
subtitle: Text('[email protected]'), | ||
), | ||
), | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ SPEC CHECKSUMS: | |
|
||
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c | ||
|
||
COCOAPODS: 1.10.2 | ||
COCOAPODS: 1.11.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:macos_ui/macos_ui.dart'; | ||
import 'package:macos_ui/src/library.dart'; | ||
|
||
/// A macOS style navigation-list item intended for use in a [Sidebar] | ||
/// | ||
/// See also: | ||
/// | ||
/// * [Sidebar], a side bar used alongside [MacosScaffold] | ||
/// * [SidebarItems], the widget that displays [SidebarItem]s vertically | ||
class SidebarItem with Diagnosticable { | ||
/// Creates a sidebar item. | ||
const SidebarItem({ | ||
this.leading, | ||
required this.label, | ||
this.selectedColor, | ||
this.unselectedColor, | ||
this.shape, | ||
this.focusNode, | ||
this.semanticLabel, | ||
this.disclosureItems, | ||
}); | ||
|
||
/// The widget before [label]. | ||
/// | ||
/// Typically an [Icon] | ||
final Widget? leading; | ||
|
||
/// Indicates what content this widget represents. | ||
/// | ||
/// Typically a [Text] | ||
final Widget label; | ||
|
||
/// The color to paint this widget as when selected. | ||
/// | ||
/// If null, [MacosThemeData.primaryColor] is used. | ||
final Color? selectedColor; | ||
|
||
/// The color to paint this widget as when unselected. | ||
/// | ||
/// Defaults to transparent. | ||
final Color? unselectedColor; | ||
|
||
/// The [shape] property specifies the outline (border) of the | ||
/// decoration. The shape must not be null. It's used alonside | ||
/// [selectedColor]. | ||
final ShapeBorder? shape; | ||
|
||
/// The focus node used by this item. | ||
final FocusNode? focusNode; | ||
|
||
/// The semantic label used by screen readers. | ||
final String? semanticLabel; | ||
|
||
/// The disclosure items. If null, there will be no disclosure items. | ||
/// | ||
/// If non-null and [leading] is null, a local animated icon is created | ||
final List<SidebarItem>? disclosureItems; | ||
|
||
@override | ||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | ||
super.debugFillProperties(properties); | ||
properties.add(ColorProperty('selectedColor', selectedColor)); | ||
properties.add(ColorProperty('unselectedColor', unselectedColor)); | ||
properties.add(StringProperty('semanticLabel', semanticLabel)); | ||
properties.add(DiagnosticsProperty<ShapeBorder>('shape', shape)); | ||
properties.add(DiagnosticsProperty<FocusNode>('focusNode', focusNode)); | ||
properties.add(IterableProperty<SidebarItem>( | ||
'disclosure items', | ||
disclosureItems, | ||
)); | ||
} | ||
} |
Oops, something went wrong.