Skip to content

Commit 1812ab8

Browse files
committed
收录Autocomplete组件
1 parent 4e70593 commit 1812ab8

File tree

12 files changed

+330
-24
lines changed

12 files changed

+330
-24
lines changed

assets/flutter.db

8 KB
Binary file not shown.

lib/widget_system/blocs/category_bloc/category_event.dart

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ class EventLoadCategory extends CategoryEvent{
2020
class EventToggleWidget extends CategoryEvent{
2121
final int widgetId;
2222
final int categoryId;
23-
const EventToggleWidget({required this.widgetId, required this.categoryId});
23+
const EventToggleWidget({
24+
required this.widgetId,
25+
required this.categoryId,
26+
});
2427

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

45-
const EventAddCategory(
46-
{required this.name, required this.info, required this.color});
48+
const EventAddCategory({
49+
required this.name,
50+
required this.info,
51+
required this.color,
52+
});
4753

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

61-
const EventUpdateCategory(
62-
{required this.name,
63-
required this.info,
64-
required this.color,
65-
this.priority,
66-
this.image,
67-
required this.id});
67+
const EventUpdateCategory({
68+
required this.name,
69+
required this.info,
70+
required this.color,
71+
this.priority,
72+
this.image,
73+
required this.id,
74+
});
6875

6976
@override
7077
List<Object?> get props => [name, info, color, priority, image, id];

lib/widget_system/blocs/widget_detail_bloc/widget_detail_state.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ class DetailWithData extends DetailState {
1919
final List<WidgetModel> links;
2020
final List<NodeModel> nodes;
2121

22-
const DetailWithData({required this.widgetModel,required this.nodes,required this.links});
22+
const DetailWithData({
23+
required this.widgetModel,
24+
required this.nodes,
25+
required this.links,
26+
});
2327

2428
@override
2529
List<Object> get props => [widgetModel,nodes];

lib/widget_system/views/search_view/app_search_bar.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class _AppSearchBarState extends State<AppSearchBar> {
2424
height: 35,
2525
child: TextField(
2626
autofocus: true,
27-
//自动聚焦,闪游标
2827
controller: _controller,
2928
maxLines: 1,
3029
decoration: const InputDecoration(
@@ -39,8 +38,8 @@ class _AppSearchBarState extends State<AppSearchBar> {
3938
hintStyle: TextStyle(fontSize: 14)),
4039
onChanged: _doSearch,
4140
onSubmitted: (str) {
42-
//提交后
43-
FocusScope.of(context).requestFocus(FocusNode()); //收起键盘
41+
//提交后,收起键盘
42+
FocusScope.of(context).requestFocus(FocusNode());
4443
},
4544
)),
4645
_buildClearIcon()

lib/widget_system/views/search_view/empty_search_page.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class NotSearchPage extends StatelessWidget {
77
@override
88
Widget build(BuildContext context) {
99
final Color color = Theme.of(context).primaryColor;
10-
1110
return Container(
1211
height: 300,
1312
alignment: Alignment.center,

lib/widget_system/views/widget_home_view/toly_app_bar.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ class _TolyAppBarState extends State<TolyAppBar>
5151
'Other'
5252
];
5353

54+
static const List<String> semantics = [
55+
'无状态组件',
56+
'有状态组件',
57+
'单子组件',
58+
'多子组件',
59+
'滑动组件',
60+
'代理组件',
61+
'其他组件'
62+
];
63+
5464
late AnimationController _controller;
5565
late Animation<double> circleAnim;
5666
late Animation<double> heightAnim;
@@ -113,7 +123,7 @@ class _TolyAppBarState extends State<TolyAppBar>
113123
Widget _buildChild(int color) {
114124
ThemeData themeData = Theme.of(context);
115125
bool isDark = themeData.brightness == Brightness.dark;
116-
126+
int index = colors.indexOf(color);
117127
return Container(
118128
alignment: const Alignment(0, 0.4),
119129
decoration: BoxDecoration(boxShadow: [
@@ -128,8 +138,9 @@ class _TolyAppBarState extends State<TolyAppBar>
128138
height: widget.maxHeight + 20,
129139
width: _width,
130140
child: Text(
131-
info[colors.indexOf(color)],
141+
info[index],
132142
style: _kTabTextStyle,
143+
semanticsLabel: '您当前点击了:${semantics[index]}',
133144
),
134145
);
135146
}

lib/widget_system/widgets/StatefulWidget/CupertinoContextMenu/node1_base.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import 'package:flutter/cupertino.dart';
77
// "widgetId": 143,
88
// "name": 'CupertinoContextMenu基本使用',
99
// "priority": 1,
10-
// "subtitle":
11-
// "【child】 : 子组件 【Widget】\n"
10+
// "subtitle": "【child】 : 子组件 【Widget】\n"
1211
// "【actions】 : 行为组件集 【List<Widget>】\n"
1312
// "【previewBuilder】 : 动画构造器 【ContextMenuPreviewBuilder】",
1413
// }
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import 'dart:async';
2+
3+
import 'package:flutter/material.dart';
4+
/// create by 张风捷特烈 on 2022-04-18
5+
/// contact me by email [email protected]
6+
/// 说明:
7+
// {
8+
// "widgetId": 356,
9+
// "name": 'Autocomplete基本使用',
10+
// "priority": 1,
11+
// "subtitle": "【optionsBuilder】 : 选项构造器 【AutocompleteOptionsBuilder<T>】\n"
12+
// "【onSelected】 : 选择时回调 【AutocompleteOnSelected<T>】",
13+
// }
14+
class AutocompleteDemo extends StatelessWidget {
15+
const AutocompleteDemo({Key? key}) : super(key: key);
16+
17+
@override
18+
Widget build(BuildContext context) {
19+
return Autocomplete<String>(
20+
optionsBuilder: buildOptions,
21+
onSelected: onSelected,
22+
);
23+
}
24+
25+
void onSelected(String selection) {
26+
debugPrint('当前选择了 $selection');
27+
}
28+
29+
Future<Iterable<String>> buildOptions(
30+
TextEditingValue textEditingValue,
31+
) async {
32+
if (textEditingValue.text == '') {
33+
return const Iterable<String>.empty();
34+
}
35+
return searchByArgs(textEditingValue.text);
36+
}
37+
38+
Future<Iterable<String>> searchByArgs(String args) async{
39+
// 模拟网络请求
40+
await Future.delayed(const Duration(milliseconds: 200));
41+
const List<String> data = [
42+
'toly', 'toly49', 'toly42', 'toly56',
43+
'card', 'ls', 'alex', 'fan sha',
44+
];
45+
return data.where((String name) => name.contains(args));
46+
}
47+
}

0 commit comments

Comments
 (0)