collection

This commit is contained in:
yifeng.yl
2019-01-12 15:34:17 +08:00
parent ea12dcbea5
commit 55b8be17c7

View File

@ -133,32 +133,29 @@ class _WidgetDemoState extends State<WidgetDemo> {
} }
} }
void _selectValue(value){
if(value == 'doc'){
_launchURL(widget.docUrl);
}else if(value =='code'){
_launchURL(Application.github['widgetsURL'] + widget.codeUrl);
}else{
_getCollection();
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (_hasCollected) { if (_hasCollected) {
_collectionColor = Colors.yellow; _collectionColor = Colors.red;
_router='取消收藏';
} else { } else {
_collectionColor = Colors.white; _collectionColor =null;
_router='组件收藏';
} }
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(widget.title), title: Text(widget.title),
actions: <Widget>[ actions: <Widget>[
new IconButton(
tooltip: 'widget doc',
onPressed: () {
_launchURL(widget.docUrl);
},
icon: Icon(Icons.library_books),
),
new IconButton(
tooltip: 'github code',
onPressed: () {
_launchURL(Application.github['widgetsURL'] + widget.codeUrl);
},
icon: Icon(Icons.code),
),
new IconButton( new IconButton(
tooltip: 'goBack home', tooltip: 'goBack home',
onPressed: () { onPressed: () {
@ -166,6 +163,35 @@ class _WidgetDemoState extends State<WidgetDemo> {
}, },
icon: Icon(Icons.home), icon: Icon(Icons.home),
), ),
PopupMenuButton<String>(
onSelected: _selectValue,
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
const PopupMenuItem<String>(
value: 'doc',
child: ListTile(
leading: Icon(Icons.library_books,size: 22.0,),
title: Text('查看文档'),
),
),
const PopupMenuDivider(),
const PopupMenuItem<String>(
value: 'code',
child: ListTile(
leading: Icon(Icons.code,size: 22.0,),
title: Text('查看Demo'),
),
),
const PopupMenuDivider(),
PopupMenuItem<String>(
value: 'collection',
child: ListTile(
leading: Icon(Icons.star,size: 22.0,color: _collectionColor,),
title: Text(_router),
),
),
],
),
], ],
), ),
body: Container( body: Container(
@ -180,16 +206,6 @@ class _WidgetDemoState extends State<WidgetDemo> {
], ],
), ),
), ),
floatingActionButton: FloatingActionButton(
onPressed: _getCollection,
mini: true,
tooltip: '收藏',
child: Icon(
Icons.star,
color: _collectionColor,
),
backgroundColor: Theme.of(context).primaryColor,
),
); );
} }
} }