From 52aa4ab9f86fbc7e8bc39eb49aa4de83b3dfb1c3 Mon Sep 17 00:00:00 2001 From: Nealyang Date: Thu, 10 Jan 2019 14:50:53 +0800 Subject: [PATCH 1/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71413008..b45a6651 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ iphone下载地址: #### Flutter 是什么 -2018年6月21日Google发布Flutter首个release预览版,作为Google baba大力推出的一种全新的响应式,跨平台,高性能的移动开发框架。Flutter是一个跨平台的移动UI框架,旨在帮助开发者使用一套代码开发高性能、高保真的Android和iOS应用。 +2018年6月21日Google发布Flutter首个release预览版,作为Google 大力推出的一种全新的响应式,跨平台,高性能的移动开发框架。Flutter是一个跨平台的移动UI框架,旨在帮助开发者使用一套代码开发高性能、高保真的Android和iOS应用。 flutter优点主要包括: - 跨平台 From 0b4dd561f681d93781b9326f040aeaf47513c719 Mon Sep 17 00:00:00 2001 From: "xiaojia22326@163.com" Date: Thu, 10 Jan 2019 16:13:28 +0800 Subject: [PATCH 2/2] update myListView --- lib/common/myListView.dart | 73 +++++++++++++++----------------------- lib/views/FirstPage.dart | 2 +- 2 files changed, 30 insertions(+), 45 deletions(-) diff --git a/lib/common/myListView.dart b/lib/common/myListView.dart index ac50f3d2..457c4023 100644 --- a/lib/common/myListView.dart +++ b/lib/common/myListView.dart @@ -1,70 +1,55 @@ - import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; -class MyListView extends StatelessWidget { +class ListViewItem extends StatelessWidget { + final String itemUrl; + final String itemTitle; + final String data; -final String currCodeUrl; -final String currTitle; -final String developer; - -const MyListView({ Key key,this.currCodeUrl, this.currTitle, this.developer}): -super(key:key); + const ListViewItem({Key key, this.itemUrl, this.itemTitle, this.data}) + : super(key: key); - void _launchURL(String url) async { - if (await canLaunch(url)) { - await launch(url); - } else { - throw 'Could not launch $url'; + void _launchURL(String url,BuildContext context) async { + if (url.contains("https") || url.contains("http")) { + if (await canLaunch(url)) { + await launch(url); + } else { + throw 'Could not launch $url'; + } + }else{ + Navigator.of(context).pushNamed(url); } } + @override Widget build(BuildContext context) { return Card( - //color: Colors.primaries[index % Colors.primaries.length], color: Colors.white, elevation: 4.0, margin: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0), - child:ListTile( - onTap:(){ - print('codeUrl:${currCodeUrl}'); - _launchURL(currCodeUrl); + child: ListTile( + onTap: () { + _launchURL(itemUrl,context); }, - // contentPadding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 1.0), - // leading: Container( - // padding: EdgeInsets.only(right: 12.0), - // decoration: new BoxDecoration( - // border: new Border( - // right: new BorderSide(width: 1.0, color: Colors.grey))), - // child: Icon(smallParts_icon, color: smallParts_Color), - // ), title: Padding( child: Text( - - currTitle, - style: TextStyle(color: Colors.black,fontSize:15.0), - + itemTitle, + style: TextStyle(color: Colors.black, fontSize: 15.0), + ), + padding: EdgeInsets.only(top: 10.0), ), - padding: EdgeInsets.only(top: 10.0), - ), - // subtitle: Text("Intermediate", style: TextStyle(color: Colors.white)), - subtitle: Row( - children: [ Padding( - child: Text( developer, style: TextStyle(color: Colors.black54,fontSize:10.0) - ), - padding:EdgeInsets.only(top: 10.0,bottom: 10.0), + child: Text(data, + style: TextStyle(color: Colors.black54, fontSize: 10.0)), + padding: EdgeInsets.only(top: 10.0, bottom: 10.0), ) - //Icon(Icons.linear_scale, color: smallParts_Color), - ], ), - trailing: Icon(Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0) - ) - ); + trailing: Icon(Icons.keyboard_arrow_right, + color: Colors.grey, size: 30.0))); } -} \ No newline at end of file +} diff --git a/lib/views/FirstPage.dart b/lib/views/FirstPage.dart index 75fb6438..0cf6f1ea 100644 --- a/lib/views/FirstPage.dart +++ b/lib/views/FirstPage.dart @@ -63,7 +63,7 @@ class FirstPageState extends State { var myUsername = '${'👲'}: ${item.username} '; var codeUrl = '${item.detailUrl}'; - return new MyListView(currCodeUrl:codeUrl,currTitle: myTitle,developer: myUsername,); + return new ListViewItem(itemUrl:codeUrl,itemTitle: myTitle,data: myUsername,); } @override