Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

refactor/migrate to fluent_ui 3.7.0 #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
Binary file modified assets/images/fluent-ui_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 26 additions & 101 deletions lib/windows_search_delegate.dart
Original file line number Diff line number Diff line change
@@ -1,121 +1,46 @@
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: () {},
),
return fluent.ScaffoldPage(
content: fluent.NavigationView(
appBar: fluent.NavigationAppBar(
title: Text("Search", style: TextStyle(fontSize: 22, fontWeight: fluent.FontWeight.bold)),
),
items: [
NavigationPanelSectionHeader(
header: fluent.AutoSuggestBox<PlatformItem>(
onSelected: (PlatformItem item) => print(item.name),
pane: fluent.NavigationPane(
displayMode: fluent.PaneDisplayMode.compact,
header: SizedBox.expand(),
autoSuggestBoxReplacement: fluent.Icon(fluent.FluentIcons.search),
autoSuggestBox: fluent.AutoSuggestBox(
key: _autoSuggestBoxKey,
placeholder: 'Search',
onSelected: (item) => print(item),
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)),
),
),
)),
],
items: _kPlatformNames,
),
),
content: Container(
color: fluent.Colors.white,
),
),
body: Container(),
);
}
}
36 changes: 25 additions & 11 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.8.2"
boolean_selector:
dependency: transitive
description:
Expand All @@ -21,14 +21,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -63,7 +63,7 @@ packages:
name: fluent_ui
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "3.7.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -87,21 +87,35 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10"
version: "0.12.11"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
recase:
dependency: transitive
description:
name: recase
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
scroll_pos:
dependency: transitive
description:
name: scroll_pos
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -113,7 +127,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -148,7 +162,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
version: "0.4.3"
typed_data:
dependency: transitive
description:
Expand All @@ -162,7 +176,7 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.1"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0"
dart: ">=2.15.0 <3.0.0"
flutter: ">=2.8.0"
7 changes: 4 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
version: 1.0.3+3

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=2.14.4 <3.0.0"
flutter: ">=2.8.0"

dependencies:
fluent_ui: ^1.8.1
fluent_ui: ^3.7.0
flutter:
sdk: flutter

Expand Down