mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-08-06 09:01:00 +08:00
feat(为搜索列表加入icon)
This commit is contained in:
@ -18,13 +18,14 @@ class MaterialSearchResult<T> extends StatelessWidget {
|
||||
this.onTap
|
||||
}) : super(key: key);
|
||||
|
||||
final T value;
|
||||
final String value;
|
||||
final VoidCallback onTap;
|
||||
final String text;
|
||||
final IconData icon;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return new InkWell(
|
||||
onTap: this.onTap,
|
||||
child: new Container(
|
||||
@ -32,8 +33,8 @@ class MaterialSearchResult<T> extends StatelessWidget {
|
||||
padding: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 10.0),
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new Container(width: 30.0, child: new Icon(icon)) ?? null,
|
||||
new Expanded(child: new Text(text, style: Theme.of(context).textTheme.subhead)),
|
||||
new Container(width: 30.0, margin: EdgeInsets.only(right: 10), child: new Icon(icon)) ?? null,
|
||||
new Expanded(child: new Text(value, style: Theme.of(context).textTheme.subhead)),
|
||||
new Text(text, style: Theme.of(context).textTheme.subhead)
|
||||
],
|
||||
),
|
||||
|
@ -21,6 +21,7 @@ import '../common/provider.dart';
|
||||
import '../model/widget.dart';
|
||||
import '../widgets/index.dart';
|
||||
import 'package:flutter_go/components/search_input.dart';
|
||||
import '../common/widget_name_to_icon.dart';
|
||||
|
||||
const int ThemeColor = 0xFFC91B3A;
|
||||
|
||||
@ -90,7 +91,8 @@ class _MyHomePageState extends State<AppPage>
|
||||
return list
|
||||
.map((item) => new MaterialSearchResult<String>(
|
||||
value: item.name,
|
||||
text: item.name,
|
||||
icon: WidgetName2Icon.icons[item.name] ?? null,
|
||||
text: 'widget',
|
||||
onTap: () {
|
||||
onWidgetTap(item, context);
|
||||
},
|
||||
|
Reference in New Issue
Block a user