From 55b8be17c78b8aa536d446b7f3b1d7a937ae44b2 Mon Sep 17 00:00:00 2001 From: "yifeng.yl" Date: Sat, 12 Jan 2019 15:34:17 +0800 Subject: [PATCH] collection --- lib/common/widget_demo.dart | 68 +++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/lib/common/widget_demo.dart b/lib/common/widget_demo.dart index f5e92f58..34aaaec2 100644 --- a/lib/common/widget_demo.dart +++ b/lib/common/widget_demo.dart @@ -133,32 +133,29 @@ class _WidgetDemoState extends State { } } + void _selectValue(value){ + if(value == 'doc'){ + _launchURL(widget.docUrl); + }else if(value =='code'){ + _launchURL(Application.github['widgetsURL'] + widget.codeUrl); + }else{ + _getCollection(); + } + } @override Widget build(BuildContext context) { if (_hasCollected) { - _collectionColor = Colors.yellow; + _collectionColor = Colors.red; + _router='取消收藏'; } else { - _collectionColor = Colors.white; + _collectionColor =null; + _router='组件收藏'; } return Scaffold( appBar: AppBar( title: Text(widget.title), actions: [ - 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( tooltip: 'goBack home', onPressed: () { @@ -166,6 +163,35 @@ class _WidgetDemoState extends State { }, icon: Icon(Icons.home), ), + PopupMenuButton( + onSelected: _selectValue, + itemBuilder: (BuildContext context) => >[ + const PopupMenuItem( + value: 'doc', + child: ListTile( + leading: Icon(Icons.library_books,size: 22.0,), + title: Text('查看文档'), + ), + ), + const PopupMenuDivider(), + const PopupMenuItem( + value: 'code', + child: ListTile( + leading: Icon(Icons.code,size: 22.0,), + title: Text('查看Demo'), + ), + ), + const PopupMenuDivider(), + PopupMenuItem( + value: 'collection', + child: ListTile( + leading: Icon(Icons.star,size: 22.0,color: _collectionColor,), + title: Text(_router), + + ), + ), + ], + ), ], ), body: Container( @@ -180,16 +206,6 @@ class _WidgetDemoState extends State { ], ), ), - floatingActionButton: FloatingActionButton( - onPressed: _getCollection, - mini: true, - tooltip: '收藏', - child: Icon( - Icons.star, - color: _collectionColor, - ), - backgroundColor: Theme.of(context).primaryColor, - ), ); } }