-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: upgrade fluent_ui usage to 3.6.0 because on Flutter >= 2.8 old f…
…luent_ui 1.8.1 didn't work anymore
- Loading branch information
Maxeem
committed
Jan 20, 2022
1 parent
1d6a8e5
commit 8821665
Showing
3 changed files
with
50 additions
and
115 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,121 +1,41 @@ | ||
import 'package:fluent_ui/fluent_ui.dart' as fluent; | ||
import 'package:fluent_ui/fluent_ui.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_search_bar/main.dart'; | ||
import 'package:flutter_search_bar/platform_search.dart'; | ||
|
||
final _kPlatformNames = [...platforms.map((element) => element.name)]; // map cuz AutoSuggestBox works with Strings | ||
|
||
final _autoSuggestBoxKey = GlobalKey(); // use the key to keep the state of the AutoSuggestBox | ||
|
||
class WindowsSearchDelegate extends AbstractPlatformSearchDelegate { | ||
final List<PlatformItem> Function(String text) search; | ||
|
||
WindowsSearchDelegate(this.search); | ||
|
||
Widget buildResults(BuildContext context) { | ||
return ListView.builder( | ||
itemCount: 10, | ||
itemBuilder: (context, index) { | ||
return Row( | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Text('Item $index'), | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
@override | ||
Widget buildResults(BuildContext context) => throw UnimplementedError(); | ||
|
||
@override | ||
Widget buildSuggestions(BuildContext context) { | ||
return ListView.builder( | ||
itemCount: 10, | ||
itemBuilder: (context, index) { | ||
return Row( | ||
children: [ | ||
Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Text('Item $index'), | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
Widget buildSuggestions(BuildContext context) => throw UnimplementedError(); | ||
|
||
@override | ||
Widget buildScaffold(Widget? body, BuildContext context) { | ||
const BorderSide _kDefaultRoundedBorderSide = BorderSide( | ||
style: BorderStyle.solid, | ||
width: 0.8, | ||
); | ||
return fluent.Scaffold( | ||
left: NavigationPanel( | ||
currentIndex: 2, | ||
menu: NavigationPanelMenuItem( | ||
icon: IconButton( | ||
icon: fluent.Icon(Icons.menu), | ||
onPressed: () {}, | ||
), | ||
), | ||
items: [ | ||
NavigationPanelSectionHeader( | ||
header: fluent.AutoSuggestBox<PlatformItem>( | ||
onSelected: (PlatformItem item) => print(item.name), | ||
controller: queryTextController, | ||
sorter: (String text, List items) => search.call(text), | ||
items: platforms, | ||
noResultsFound: (context) => ListTile( | ||
title: DefaultTextStyle( | ||
style: TextStyle( | ||
fontWeight: FontWeight.normal, color: Colors.black), | ||
child: Text('No results found'), | ||
), | ||
), | ||
itemBuilder: (context, item) { | ||
return PlatformItemWidget( | ||
item, | ||
small: true, | ||
); | ||
}, | ||
textBoxBuilder: (context, controller, fn, key) => TextBox( | ||
key: key, | ||
controller: controller, | ||
focusNode: fn, | ||
suffixMode: OverlayVisibilityMode.always, | ||
suffix: fluent.Row( | ||
children: [ | ||
controller.text.isNotEmpty | ||
? IconButton( | ||
icon: fluent.Icon(Icons.close), | ||
onPressed: () { | ||
controller.clear(); | ||
fn.unfocus(); | ||
}, | ||
) | ||
: fluent.SizedBox.shrink(), | ||
IconButton( | ||
icon: fluent.Icon(Icons.search), | ||
onPressed: () {}, | ||
), | ||
], | ||
), | ||
placeholder: searchFieldLabel, | ||
decoration: BoxDecoration( | ||
color: Colors.white, | ||
border: Border( | ||
top: _kDefaultRoundedBorderSide, | ||
bottom: _kDefaultRoundedBorderSide, | ||
left: _kDefaultRoundedBorderSide, | ||
right: _kDefaultRoundedBorderSide, | ||
), | ||
borderRadius: fn.hasFocus | ||
? BorderRadius.vertical(top: Radius.circular(3.0)) | ||
: BorderRadius.all(Radius.circular(3.0)), | ||
), | ||
return fluent.ScaffoldPage( | ||
content: Padding( | ||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 32), | ||
child: Column( | ||
children: [ | ||
fluent.AutoSuggestBox<String>( | ||
key: _autoSuggestBoxKey, | ||
placeholder: 'Search', | ||
onSelected: (item) => print(item), | ||
controller: queryTextController, | ||
items: _kPlatformNames, | ||
), | ||
)), | ||
], | ||
Spacer(), | ||
], | ||
), | ||
), | ||
body: Container(), | ||
); | ||
} | ||
} |
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