Skip to content

Commit

Permalink
merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
DeckeDeng committed Jan 12, 2019
2 parents 876d53b + f22e7a0 commit 741f952
Show file tree
Hide file tree
Showing 148 changed files with 874 additions and 1,068 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ iphone下载地址:

### 背景

#### Flutter 是什么
#### Flutter 是什么?

2018年6月21日Google发布Flutter首个release预览版,作为Google 大力推出的一种全新的响应式,跨平台,高性能的移动开发框架。Flutter是一个跨平台的移动UI框架,旨在帮助开发者使用一套代码开发高性能、高保真的Android和iOS应用。

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.2.0'
}
}

Expand Down
4 changes: 2 additions & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
#Thu Jan 10 15:37:36 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
Binary file added assets/images/nothing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion lib/common/iconNames.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* email: [email protected]
* tartget: FlatButton 的示例
*/
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';


Expand Down
53 changes: 53 additions & 0 deletions lib/common/list_view_item.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class ListViewItem extends StatelessWidget {
final String itemUrl;
final String itemTitle;
final String data;

const ListViewItem({Key key, this.itemUrl, this.itemTitle, this.data})
: super(key: key);

void _launchURL(String url, BuildContext context) async {

if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}

}

@override
Widget build(BuildContext context) {
return Card(
color: Colors.white,
elevation: 4.0,
margin: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
child: ListTile(
onTap: () {
_launchURL(itemUrl, context);
},
title: Padding(
child: Text(
itemTitle,
style: TextStyle(color: Colors.black, fontSize: 15.0),
),
padding: EdgeInsets.only(top: 10.0),
),
subtitle: Row(
children: <Widget>[
Padding(
child: Text(data,
style: TextStyle(color: Colors.black54, fontSize: 10.0)),
padding: EdgeInsets.only(top: 10.0, bottom: 10.0),
)
],
),
trailing:
Icon(Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0),
),
);
}
}
70 changes: 0 additions & 70 deletions lib/common/myListView.dart

This file was deleted.

21 changes: 12 additions & 9 deletions lib/common/provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@ class Provider {
//Get a location using getDatabasesPath
String databasesPath = await getDatabasesPath();
String path = join(databasesPath, 'flutter.db');
List<Map> list;
// try {
// db = await openDatabase(path, readOnly: true);

// } catch (e) {
// print("Error $e");
// }
List<Map> tables;
try {
db = await openDatabase(path);
tables = await db
.rawQuery('SELECT name FROM sqlite_master WHERE type = "table"');
print('${tables.length} 7891');
} catch (e) {
print("Error $e");
}

if (db == null) {
if (tables.length < 3) {
// Delete the database
await deleteDatabase(path);

// 关闭上面打开的db,否则无法执行open
db.close();
ByteData data = await rootBundle.load(join("assets", "app.db"));
List<int> bytes =
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
Expand Down
4 changes: 2 additions & 2 deletions lib/common/sql.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Sql extends BaseModel {
/// @mods [And, Or] default is Or
/// search({'name': "hanxu', 'id': 1};
///
Future<List> search({Map<String, dynamic> conditions, String Mods = 'Or'}) async {
Future<List> search({Map<String, dynamic> conditions, String mods = 'Or'}) async {
if (conditions == null || conditions.isEmpty) {
return this.get();
}
Expand All @@ -88,7 +88,7 @@ class Sql extends BaseModel {
}

if (index >= 0 && index < conditions.length -1) {
stringConditions = '$stringConditions $Mods';
stringConditions = '$stringConditions $mods';
}
index++;
});
Expand Down
1 change: 0 additions & 1 deletion lib/common/widget-demo.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import '../routers/application.dart';

class WidgetDemo extends StatelessWidget {
final Widget child;
Expand Down
90 changes: 61 additions & 29 deletions lib/common/widget_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import '../components/markdown.dart';
import '../model/collection.dart';
import '../widgets/index.dart';
import 'package:fluttertoast/fluttertoast.dart';
import '../event/event-bus.dart';
import '../event/event-model.dart';

class WidgetDemo extends StatefulWidget {
final List<dynamic> contentList;
Expand All @@ -31,7 +33,6 @@ class WidgetDemo extends StatefulWidget {
class _WidgetDemoState extends State<WidgetDemo> {
bool _hasCollected = false;
CollectionControlModel _collectionControl = new CollectionControlModel();
Collection _collection;
Color _collectionColor;
List widgetDemosList = new WidgetDemoList().getDemos();
String _router = '';
Expand Down Expand Up @@ -84,9 +85,11 @@ class _WidgetDemoState extends State<WidgetDemo> {
_router = item.routerName;
}
});
setState(() {
_hasCollected = list.length > 0;
});
if (this.mounted) {
setState(() {
_hasCollected = list.length > 0;
});
}
});
}

Expand All @@ -100,6 +103,11 @@ class _WidgetDemoState extends State<WidgetDemo> {
_hasCollected = false;
});
showInSnackBar('已取消收藏');

if (ApplicationEvent.event != null) {
ApplicationEvent.event
.fire(CollectionEvent(widget.title, _router, true));
}
return;
}
print('删除错误');
Expand All @@ -113,44 +121,77 @@ class _WidgetDemoState extends State<WidgetDemo> {
setState(() {
_hasCollected = true;
});

if (ApplicationEvent.event != null) {
ApplicationEvent.event
.fire(CollectionEvent(widget.title, _router, false));
}

showInSnackBar('收藏成功');
}
});
}
}

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: <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(
tooltip: 'goBack home',
onPressed: () {
Navigator.popUntil(context, ModalRoute.withName('/'));
},
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(
Expand All @@ -165,15 +206,6 @@ class _WidgetDemoState extends State<WidgetDemo> {
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _getCollection,
tooltip: '收藏',
child: Icon(
Icons.star,
color: _collectionColor,
),
backgroundColor: Theme.of(context).primaryColor,
),
);
}
}
3 changes: 2 additions & 1 deletion lib/components/CompList.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'package:flutter/material.dart';
import 'package:flutter_rookie_book/views/Detail.dart';



class CompList extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new ListState();
}
}
Expand Down
Loading

0 comments on commit 741f952

Please sign in to comment.