Skip to content

Commit

Permalink
收录Autocomplete组件
Browse files Browse the repository at this point in the history
  • Loading branch information
toly1994328 committed Apr 18, 2022
1 parent 4e70593 commit 1812ab8
Show file tree
Hide file tree
Showing 12 changed files with 330 additions and 24 deletions.
Binary file modified assets/flutter.db
Binary file not shown.
27 changes: 17 additions & 10 deletions lib/widget_system/blocs/category_bloc/category_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ class EventLoadCategory extends CategoryEvent{
class EventToggleWidget extends CategoryEvent{
final int widgetId;
final int categoryId;
const EventToggleWidget({required this.widgetId, required this.categoryId});
const EventToggleWidget({
required this.widgetId,
required this.categoryId,
});

@override
List<Object> get props => [widgetId,categoryId];
Expand All @@ -42,8 +45,11 @@ class EventAddCategory extends CategoryEvent{
final String? info;
final String? color;

const EventAddCategory(
{required this.name, required this.info, required this.color});
const EventAddCategory({
required this.name,
required this.info,
required this.color,
});

@override
List<Object?> get props => [name, info, color];
Expand All @@ -58,13 +64,14 @@ class EventUpdateCategory extends CategoryEvent {
final int? priority;
final String? image;

const EventUpdateCategory(
{required this.name,
required this.info,
required this.color,
this.priority,
this.image,
required this.id});
const EventUpdateCategory({
required this.name,
required this.info,
required this.color,
this.priority,
this.image,
required this.id,
});

@override
List<Object?> get props => [name, info, color, priority, image, id];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ class DetailWithData extends DetailState {
final List<WidgetModel> links;
final List<NodeModel> nodes;

const DetailWithData({required this.widgetModel,required this.nodes,required this.links});
const DetailWithData({
required this.widgetModel,
required this.nodes,
required this.links,
});

@override
List<Object> get props => [widgetModel,nodes];
Expand Down
5 changes: 2 additions & 3 deletions lib/widget_system/views/search_view/app_search_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class _AppSearchBarState extends State<AppSearchBar> {
height: 35,
child: TextField(
autofocus: true,
//自动聚焦,闪游标
controller: _controller,
maxLines: 1,
decoration: const InputDecoration(
Expand All @@ -39,8 +38,8 @@ class _AppSearchBarState extends State<AppSearchBar> {
hintStyle: TextStyle(fontSize: 14)),
onChanged: _doSearch,
onSubmitted: (str) {
//提交后
FocusScope.of(context).requestFocus(FocusNode()); //收起键盘
//提交后,收起键盘
FocusScope.of(context).requestFocus(FocusNode());
},
)),
_buildClearIcon()
Expand Down
1 change: 0 additions & 1 deletion lib/widget_system/views/search_view/empty_search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class NotSearchPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final Color color = Theme.of(context).primaryColor;

return Container(
height: 300,
alignment: Alignment.center,
Expand Down
15 changes: 13 additions & 2 deletions lib/widget_system/views/widget_home_view/toly_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ class _TolyAppBarState extends State<TolyAppBar>
'Other'
];

static const List<String> semantics = [
'无状态组件',
'有状态组件',
'单子组件',
'多子组件',
'滑动组件',
'代理组件',
'其他组件'
];

late AnimationController _controller;
late Animation<double> circleAnim;
late Animation<double> heightAnim;
Expand Down Expand Up @@ -113,7 +123,7 @@ class _TolyAppBarState extends State<TolyAppBar>
Widget _buildChild(int color) {
ThemeData themeData = Theme.of(context);
bool isDark = themeData.brightness == Brightness.dark;

int index = colors.indexOf(color);
return Container(
alignment: const Alignment(0, 0.4),
decoration: BoxDecoration(boxShadow: [
Expand All @@ -128,8 +138,9 @@ class _TolyAppBarState extends State<TolyAppBar>
height: widget.maxHeight + 20,
width: _width,
child: Text(
info[colors.indexOf(color)],
info[index],
style: _kTabTextStyle,
semanticsLabel: '您当前点击了:${semantics[index]}',
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import 'package:flutter/cupertino.dart';
// "widgetId": 143,
// "name": 'CupertinoContextMenu基本使用',
// "priority": 1,
// "subtitle":
// "【child】 : 子组件 【Widget】\n"
// "subtitle": "【child】 : 子组件 【Widget】\n"
// "【actions】 : 行为组件集 【List<Widget>】\n"
// "【previewBuilder】 : 动画构造器 【ContextMenuPreviewBuilder】",
// }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'dart:async';

import 'package:flutter/material.dart';
/// create by 张风捷特烈 on 2022-04-18
/// contact me by email 1981462002@qq.com
/// 说明:
// {
// "widgetId": 356,
// "name": 'Autocomplete基本使用',
// "priority": 1,
// "subtitle": "【optionsBuilder】 : 选项构造器 【AutocompleteOptionsBuilder<T>】\n"
// "【onSelected】 : 选择时回调 【AutocompleteOnSelected<T>】",
// }
class AutocompleteDemo extends StatelessWidget {
const AutocompleteDemo({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Autocomplete<String>(
optionsBuilder: buildOptions,
onSelected: onSelected,
);
}

void onSelected(String selection) {
debugPrint('当前选择了 $selection');
}

Future<Iterable<String>> buildOptions(
TextEditingValue textEditingValue,
) async {
if (textEditingValue.text == '') {
return const Iterable<String>.empty();
}
return searchByArgs(textEditingValue.text);
}

Future<Iterable<String>> searchByArgs(String args) async{
// 模拟网络请求
await Future.delayed(const Duration(milliseconds: 200));
const List<String> data = [
'toly', 'toly49', 'toly42', 'toly56',
'card', 'ls', 'alex', 'fan sha',
];
return data.where((String name) => name.contains(args));
}
}
Loading

0 comments on commit 1812ab8

Please sign in to comment.