Skip to content

Commit

Permalink
Merge pull request #23 from Nealyang/master
Browse files Browse the repository at this point in the history
format code
  • Loading branch information
Nealyang authored Jan 11, 2019
2 parents 111fae4 + 1121354 commit 775cb2c
Show file tree
Hide file tree
Showing 122 changed files with 291 additions and 709 deletions.
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
7 changes: 2 additions & 5 deletions lib/common/list_view_item.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 ListViewItem extends StatelessWidget {
final String itemUrl;
Expand All @@ -11,15 +10,13 @@ class ListViewItem extends StatelessWidget {
: super(key: key);

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 {
Application.router.navigateTo(context, "${url}");
}

}

@override
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
21 changes: 15 additions & 6 deletions lib/common/widget_demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,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 @@ -86,10 +85,10 @@ class _WidgetDemoState extends State<WidgetDemo> {
_router = item.routerName;
}
});
if(this.mounted){
if (this.mounted) {
setState(() {
_hasCollected = list.length > 0;
});
_hasCollected = list.length > 0;
});
}
});
}
Expand All @@ -104,7 +103,11 @@ class _WidgetDemoState extends State<WidgetDemo> {
_hasCollected = false;
});
showInSnackBar('已取消收藏');
ApplicationEvent.event.fire(CollectionEvent(widget.title,true));

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

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

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


@override
Widget build(BuildContext context) {
if (_hasCollected) {
Expand Down
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
1 change: 0 additions & 1 deletion lib/components/ListRefresh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* tartget: FlatButton 的示例
*/
import 'package:flutter/material.dart';
import 'dart:math';

class ListRefresh extends StatefulWidget {
final renderItem;
Expand Down
10 changes: 5 additions & 5 deletions lib/components/Pagination.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../model/story.dart';
import 'package:url_launcher/url_launcher.dart';

class Pagination extends StatelessWidget {
static const String routeName = '/material/page-selector';
static final String routeName = '/material/page-selector';
static final List<Icon> icons = <Icon>[
const Icon(Icons.event, semanticLabel: 'Event'),
const Icon(Icons.home, semanticLabel: 'Home'),
Expand All @@ -18,9 +18,9 @@ class Pagination extends StatelessWidget {
const Icon(Icons.language, semanticLabel: 'Language'),
];

List<StoryModel> bannerStories = [];
final List<StoryModel> bannerStories = [];

List<dynamic> arr = [
final List<dynamic> arr = [
{'image': 'https://img.alicdn.com/tfs/TB1W4hMAwHqK1RjSZJnXXbNLpXa-519-260.jpg', 'type': 0, 'id': 9695909, 'url': 'https://www.zhihu.com/question/294145797/answer/551162834', 'title': '为什么阿里巴巴、腾讯和 Google 之类的企业都在使用 Flutter 开发 App?'},
{'image': 'https://img.alicdn.com/tfs/TB1XmFIApzqK1RjSZSgXXcpAVXa-720-338.jpg', 'type': 0, 'id': 9695859, 'url': 'https://zhuanlan.zhihu.com/p/51696594', 'title': 'Flutter 1.0 正式发布: Google 的便携 UI 工具包'},
{'image': 'https://img.alicdn.com/tfs/TB1mClCABLoK1RjSZFuXXXn0XXa-600-362.jpg', 'type': 0, 'id': 96956491409, 'url':'https://zhuanlan.zhihu.com/p/53497167','title': 'Flutter 示范应用现已开源 — 万物起源(The History of Everything)'},
Expand All @@ -35,7 +35,7 @@ class Pagination extends StatelessWidget {
}
}

List<Widget> _PageSelector(BuildContext context) {
List<Widget> _pageSelector(BuildContext context) {
List<Widget> list = [];
/// super.initState();
arr.forEach((item) {
Expand All @@ -57,7 +57,7 @@ class Pagination extends StatelessWidget {
Column(
//physics: AlwaysScrollableScrollPhysics(),
//padding: EdgeInsets.only(),
children: _PageSelector(context)
children: _pageSelector(context)
);
}
}
1 change: 0 additions & 1 deletion lib/components/SearchInput.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ class _MaterialSearchState<T> extends State<MaterialSearch> {
_loading = true;
});

//TODO: debounce widget.results too
var results = await widget.getResults(_criteria);

if (!mounted) {
Expand Down
4 changes: 1 addition & 3 deletions lib/components/markdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ final hightlighter = new HighLight();
class HighLight extends md.SyntaxHighlighter {
@override
TextSpan format(String source) {
// TODO: implement format
final SyntaxHighlighterStyle style = SyntaxHighlighterStyle.lightThemeStyle();
return TextSpan(
style: const TextStyle(fontSize: 10.0),
Expand All @@ -22,11 +21,10 @@ class HighLight extends md.SyntaxHighlighter {


class MarkdownBody extends StatelessWidget {
String data;
final String data;
MarkdownBody(this.data);
@override
Widget build(BuildContext context) {
// TODO: implement build
return md.MarkdownBody(data: data, syntaxHighlighter: new HighLight());
}
}
20 changes: 10 additions & 10 deletions lib/components/widget_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ class WidgetItem extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 30.0, horizontal: 10.0),
height: 150.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
widgetIcon,
SizedBox(
height: 8.0,
),
Text(_widgetName),
],
) ,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
widgetIcon,
SizedBox(
height: 8.0,
),
Text(_widgetName),
],
),
),
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/components/widget_item_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class WidgetItemContainer extends StatelessWidget {
final List<dynamic> categories;
final bool isWidgetPoint;
// 所有的可用demos;
List widgetDemosList = new WidgetDemoList().getDemos();
final List widgetDemosList = new WidgetDemoList().getDemos();

WidgetItemContainer(
{Key key,
Expand Down Expand Up @@ -41,7 +41,7 @@ class WidgetItemContainer extends StatelessWidget {
targetRouter = item.routerName;
}
});
Application.router.navigateTo(context, "${targetRouter}");
Application.router.navigateTo(context, "$targetRouter");
} else {
Application.router
.navigateTo(context, "/category/${item.name}");
Expand Down
3 changes: 2 additions & 1 deletion lib/event/event-model.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class CollectionEvent{
final String widgetName;
final String router;
final bool isRemove;
// token uid...
CollectionEvent(this.widgetName,this.isRemove);
CollectionEvent(this.widgetName,this.router,this.isRemove);
}
18 changes: 8 additions & 10 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:flutter/rendering.dart';

import 'views/FirstPage.dart';
import 'views/widgetPage.dart';
import 'views/ThirdPage.dart';
import 'views/FourthPage.dart';
import 'views/collection_page.dart';
import 'routers/routers.dart';
Expand Down Expand Up @@ -83,7 +82,6 @@ class _MyHomePageState extends State<MyHomePage>

@override
void initState() {
// TODO: implement initState
super.initState();
controller = new TabController(
initialIndex: 0, vsync: this, length: 4); // 这里的length 决定有多少个底导 submenus
Expand Down Expand Up @@ -113,7 +111,7 @@ class _MyHomePageState extends State<MyHomePage>
targetRouter = item.routerName;
}
});
Application.router.navigateTo(context, "${targetRouter}");
Application.router.navigateTo(context, "$targetRouter");
}

Widget buildSearchInput(BuildContext context) {
Expand Down Expand Up @@ -186,11 +184,11 @@ class _MyHomePageState extends State<MyHomePage>
}
}

void _onDataChange(val) {
if (this.mounted) {
setState(() {
data = val;
});
}
}
// void _onDataChange(val) {
// if (this.mounted) {
// setState(() {
// data = val;
// });
// }
// }
}
2 changes: 1 addition & 1 deletion lib/model/base.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:sqflite/sqflite.dart';
import 'dart:async';


class BaseModel{
Database db;
Expand Down
3 changes: 1 addition & 2 deletions lib/model/cat.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'base.dart';

import 'dart:async';
import 'dart:convert';
import '../common/sql.dart';

abstract class CatInterface{
Expand Down
2 changes: 1 addition & 1 deletion lib/model/widget.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'base.dart';

import 'dart:async';
import '../common/sql.dart';
import "package:flutter/material.dart";
Expand Down
1 change: 0 additions & 1 deletion lib/routers/application.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import '../widgets/index.dart';
class Application {
static Router router;
static TabController controller;
Expand Down
1 change: 0 additions & 1 deletion lib/routers/routers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import '../widgets/index.dart';
import '../model/widget.dart';
import './router_handler.dart';

class Routes {
Expand Down
10 changes: 0 additions & 10 deletions lib/views/FirstPage.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_rookie_book/common/list_view_item.dart';
//import 'package:flutter_rookie_book/components/CompList.dart';
import 'package:flutter_rookie_book/components/ListRefresh.dart' as listComp;
import 'package:flutter_rookie_book/components/Pagination.dart';

import './widgetFeature/FirstPageItem.dart';
import '../common/net_utils.dart';

import 'package:flutter_rookie_book/common/iconNames.dart';
import '../common/sql.dart';
import 'dart:async';

import 'package:url_launcher/url_launcher.dart';

class FirstPage extends StatefulWidget {
@override
Expand All @@ -24,12 +16,10 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin


@override
// TODO: implement wantKeepAlive
bool get wantKeepAlive => true;

@override
void initState() {
// TODO: implement initState
super.initState();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/views/FourthPage.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'dart:async';


import 'package:flutter/material.dart';
import '../components/CompList.dart';
Expand Down
Loading

0 comments on commit 775cb2c

Please sign in to comment.