From 56cda0ee93f32631ed3f70a170dbfbbe88a510de Mon Sep 17 00:00:00 2001 From: yangshangzhi Date: Mon, 18 Feb 2019 10:22:50 +0800 Subject: [PATCH 1/4] update readme.md --- README.md | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0c9deff..f3ff6e8 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,11 @@ # Flutter UI v1.0 -A new Flutter project. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook) - -For help getting started with Flutter, view our -[online documentation](https://flutter.io/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +# 目录 +``` +__lib + __lang + __page + __router + __store + __widget +``` From ab942092a52fe090ef5377c4780ec19b238673d6 Mon Sep 17 00:00:00 2001 From: wanwusangzhi1992 Date: Mon, 18 Feb 2019 23:43:32 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/json/widget_list.json | 71 ++++++++++++++------ lib/{page => components}/baseComp.dart | 0 lib/components/widgetComp.dart | 31 +++++++++ lib/page/tabbar/index.dart | 4 +- lib/page/widgets_demo/index.dart | 0 lib/router/scrollview/index.dart | 8 +-- lib/store/objects/widget_list.dart | 2 + lib/widget/scrollview/GridView/gridview.dart | 54 +++++++++++++++ lib/widget/scrollview/GridView/intro.dart | 1 + lib/widget/scrollview/gridview.dart | 26 ------- 10 files changed, 145 insertions(+), 52 deletions(-) rename lib/{page => components}/baseComp.dart (100%) create mode 100644 lib/components/widgetComp.dart delete mode 100644 lib/page/widgets_demo/index.dart create mode 100644 lib/widget/scrollview/GridView/gridview.dart create mode 100644 lib/widget/scrollview/GridView/intro.dart delete mode 100644 lib/widget/scrollview/gridview.dart diff --git a/assets/json/widget_list.json b/assets/json/widget_list.json index 1e6bf62..1eff4ff 100644 --- a/assets/json/widget_list.json +++ b/assets/json/widget_list.json @@ -7,35 +7,43 @@ "widgetList": [ { "code": 59101, - "name": "Row" + "name": "Row", + "key": "Row" }, { "code": 59103, - "name": "Column" + "name": "Column", + "key": "Column" }, { "code": 59105, - "name": "Container" + "name": "Container", + "key": "Container" }, { "code": 57897, - "name": "Center" + "name": "Center", + "key": "Center" }, { "code": 59497, - "name": "Padding" + "name": "Padding", + "key": "Padding" }, { "code": 59497, - "name": "Stack" + "name": "Stack", + "key": "Stack" }, { "code": 59497, - "name": "Expanded" + "name": "Expanded", + "key": "Expanded" }, { "code": 59497, - "name": "Align" + "name": "Align", + "key": "Align" } ] }, @@ -44,22 +52,28 @@ "code": 58353, "widgetList": [ { - "name": "FittedBox" + "name": "FittedBox", + "key": "FittedBox" }, { - "name": "ConstrainedBox" + "name": "ConstrainedBox", + "key": "ConstrainedBox" }, { - "name": "DecoratedBox" + "name": "DecoratedBox", + "key": "DecoratedBox" }, { - "name": "LimitedBox" + "name": "LimitedBox", + "key": "LimitedBox" }, { - "name": "RotatedBox" + "name": "RotatedBox", + "key": "RotatedBox" }, { - "name": "Table" + "name": "Table", + "key": "Table" } ] }, @@ -68,22 +82,39 @@ "code": 58353, "widgetList": [ { - "name": "FittedBox" + "name": "FittedBox", + "key": "FittedBox" }, { - "name": "ConstrainedBox" + "name": "ConstrainedBox", + "key": "ConstrainedBox" }, { - "name": "DecoratedBox" + "name": "DecoratedBox", + "key": "DecoratedBox" }, { - "name": "LimitedBox" + "name": "LimitedBox", + "key": "LimitedBox" }, { - "name": "RotatedBox" + "name": "RotatedBox", + "key": "RotatedBox" }, { - "name": "Table" + "name": "Table", + "key": "Table" + } + ] + }, + { + "typeName": "scrollview", + "code": 58353, + "widgetList": [ + { + "code": 59673, + "name": "GridView", + "key": "scrollview_gridview" } ] } diff --git a/lib/page/baseComp.dart b/lib/components/baseComp.dart similarity index 100% rename from lib/page/baseComp.dart rename to lib/components/baseComp.dart diff --git a/lib/components/widgetComp.dart b/lib/components/widgetComp.dart new file mode 100644 index 0000000..d0a5a8b --- /dev/null +++ b/lib/components/widgetComp.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'package:efox_flutter/store/STORE.dart'; + +class WidgetComp extends StatelessWidget { + final dynamic modelChild; + final String title; + + WidgetComp({Key key, this.title, @required this.modelChild}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return STORE.connect(builder: (context, child, model) { + List _list = this.modelChild(context, child, model); + List _bodyList = []; + _list.forEach((item) { + _bodyList.add(item); + }); + return Scaffold( + appBar: AppBar( + title: Text(this.title), + ), + body: ListView( + padding: EdgeInsets.all(20.0), + shrinkWrap: true, + children: _bodyList, + ), + ); + }); + } +} diff --git a/lib/page/tabbar/index.dart b/lib/page/tabbar/index.dart index 071cee3..7b3a057 100644 --- a/lib/page/tabbar/index.dart +++ b/lib/page/tabbar/index.dart @@ -70,8 +70,8 @@ class _ComponentsPageState extends State color: Colors.deepOrange, ), onPressed: () { - print('idndex, $index ${routesMap()['ScrollViewGridView']}'); - Navigator.pushNamed(context, routesMap()['ScrollViewGridView']); + String _key = _tmpWidgetList[index].key; + Navigator.pushNamed(context, routesMap()['${_key}']); }, ), Text(_tmpWidgetList[index].name), diff --git a/lib/page/widgets_demo/index.dart b/lib/page/widgets_demo/index.dart deleted file mode 100644 index e69de29..0000000 diff --git a/lib/router/scrollview/index.dart b/lib/router/scrollview/index.dart index ca3a788..050d895 100644 --- a/lib/router/scrollview/index.dart +++ b/lib/router/scrollview/index.dart @@ -1,14 +1,14 @@ import 'package:flutter/widgets.dart'; -import 'package:efox_flutter/widget/scrollview/gridview.dart'; +import 'package:efox_flutter/widget/scrollview/GridView/gridview.dart'; Map getScrollViewRoutersConfig(BuildContext context) { return { - '/widget/scrollview/gridview': (context) => GridViewDemo(), + '/widget/scrollview/GridView/gridview': (context) => GridViewDemo(), }; } -const nameSpaces = 'ScrollView'; +const nameSpaces = 'scrollview_'; Map routesMapScrollView = { - nameSpaces + 'GridView': '/widget/scrollview/gridview', + nameSpaces + 'gridview': '/widget/scrollview/GridView/gridview', }; diff --git a/lib/store/objects/widget_list.dart b/lib/store/objects/widget_list.dart index 18997e6..086dd2d 100644 --- a/lib/store/objects/widget_list.dart +++ b/lib/store/objects/widget_list.dart @@ -1,10 +1,12 @@ class ItemInfo extends Object { int code; String name; + String key; ItemInfo.fromJson(Map json) { code = json['code']; name = json['name']; + key = json['key']; } } diff --git a/lib/widget/scrollview/GridView/gridview.dart b/lib/widget/scrollview/GridView/gridview.dart new file mode 100644 index 0000000..831039e --- /dev/null +++ b/lib/widget/scrollview/GridView/gridview.dart @@ -0,0 +1,54 @@ +import 'package:flutter/material.dart'; +import 'package:efox_flutter/components/widgetComp.dart'; + +class GridViewDemo extends StatefulWidget { + @override + _GridViewDemoState createState() => new _GridViewDemoState(); +} + +class _GridViewDemoState extends State { + @override + Widget build(BuildContext context) { + return WidgetComp( + title: 'GridViewDemo', + modelChild: (context, child, model) { + return [ + + Container( + constraints: BoxConstraints.expand( + height: Theme.of(context).textTheme.display1.fontSize * 1.1 + 200.0, + ), + padding: const EdgeInsets.all(8.0), + color: Colors.teal.shade700, + alignment: Alignment.center, + child: Text('Hello World', style: Theme.of(context).textTheme.display1.copyWith(color: Colors.white)), + foregroundDecoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage('https://www.example.com/images/frame.png'), + centerSlice: Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0), + ), + ), + transform: Matrix4.rotationZ(0.1), + ), + Container( + constraints: BoxConstraints.expand( + height: Theme.of(context).textTheme.display1.fontSize * 1.1 + 200.0, + ), + padding: const EdgeInsets.all(8.0), + color: Colors.teal.shade700, + alignment: Alignment.center, + child: Text('Hello World', style: Theme.of(context).textTheme.display1.copyWith(color: Colors.white)), + foregroundDecoration: BoxDecoration( + image: DecorationImage( + image: NetworkImage('https://www.example.com/images/frame.png'), + centerSlice: Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0), + ), + ), + transform: Matrix4.rotationZ(0.1), + ), + + ]; + }, + ); + } +} diff --git a/lib/widget/scrollview/GridView/intro.dart b/lib/widget/scrollview/GridView/intro.dart new file mode 100644 index 0000000..9b490c8 --- /dev/null +++ b/lib/widget/scrollview/GridView/intro.dart @@ -0,0 +1 @@ +const text01 = "f"; \ No newline at end of file diff --git a/lib/widget/scrollview/gridview.dart b/lib/widget/scrollview/gridview.dart deleted file mode 100644 index 9b64782..0000000 --- a/lib/widget/scrollview/gridview.dart +++ /dev/null @@ -1,26 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:efox_flutter/page/baseComp.dart'; - -class GridViewDemo extends StatefulWidget { - @override - _GridViewDemoState createState() => new _GridViewDemoState(); -} - -class _GridViewDemoState extends State { - @override - Widget build(BuildContext context) { - return BaseComp( - title: 'GridViewDemo', - child: (context, child, model) { - return Center( - child: Text( - 'Griview', - style: TextStyle( - fontSize: 22.0, - ), - ), - ); - }, - ); - } -} From 9c4828844baeabc7a2d35b248bc46eceabf3caf7 Mon Sep 17 00:00:00 2001 From: yangshangzhi Date: Tue, 19 Feb 2019 11:01:43 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/json/widget_list.json | 30 -------------------- lib/components/markdownComp.dart | 12 ++++++++ lib/components/widgetComp.dart | 7 ++++- lib/router/scrollview/index.dart | 12 ++++++-- lib/widget/e_image.dart | 1 - lib/widget/scrollview/GridView/gridview.dart | 16 ++--------- lib/widget/scrollview/GridView/intro.dart | 5 +++- pubspec.yaml | 1 + 8 files changed, 34 insertions(+), 50 deletions(-) create mode 100644 lib/components/markdownComp.dart delete mode 100644 lib/widget/e_image.dart diff --git a/assets/json/widget_list.json b/assets/json/widget_list.json index 1eff4ff..3ebb1f1 100644 --- a/assets/json/widget_list.json +++ b/assets/json/widget_list.json @@ -77,36 +77,6 @@ } ] }, - { - "typeName": "form", - "code": 58353, - "widgetList": [ - { - "name": "FittedBox", - "key": "FittedBox" - }, - { - "name": "ConstrainedBox", - "key": "ConstrainedBox" - }, - { - "name": "DecoratedBox", - "key": "DecoratedBox" - }, - { - "name": "LimitedBox", - "key": "LimitedBox" - }, - { - "name": "RotatedBox", - "key": "RotatedBox" - }, - { - "name": "Table", - "key": "Table" - } - ] - }, { "typeName": "scrollview", "code": 58353, diff --git a/lib/components/markdownComp.dart b/lib/components/markdownComp.dart new file mode 100644 index 0000000..e360176 --- /dev/null +++ b/lib/components/markdownComp.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_markdown/flutter_markdown.dart' as md; + +class MarkDownComp extends StatelessWidget { + final String data; + MarkDownComp(this.data); + + @override + Widget build(BuildContext build ) { + return md.MarkdownBody(data: this.data); + } +} \ No newline at end of file diff --git a/lib/components/widgetComp.dart b/lib/components/widgetComp.dart index d0a5a8b..740d25f 100644 --- a/lib/components/widgetComp.dart +++ b/lib/components/widgetComp.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:efox_flutter/store/STORE.dart'; +import 'package:efox_flutter/components/markdownComp.dart'; class WidgetComp extends StatelessWidget { final dynamic modelChild; @@ -14,7 +15,11 @@ class WidgetComp extends StatelessWidget { List _list = this.modelChild(context, child, model); List _bodyList = []; _list.forEach((item) { - _bodyList.add(item); + if (item.runtimeType == String) { + _bodyList.add(MarkDownComp(item)); + } else { + _bodyList.add(item); + } }); return Scaffold( appBar: AppBar( diff --git a/lib/router/scrollview/index.dart b/lib/router/scrollview/index.dart index 050d895..4e90b7a 100644 --- a/lib/router/scrollview/index.dart +++ b/lib/router/scrollview/index.dart @@ -2,13 +2,19 @@ import 'package:flutter/widgets.dart'; import 'package:efox_flutter/widget/scrollview/GridView/gridview.dart'; +const nameSpaces = 'scrollview_'; +const gridview = nameSpaces + 'gridview'; + +const routerMaps = { + gridview: '/widget/scrollview/GridView/gridview', +}; + Map getScrollViewRoutersConfig(BuildContext context) { return { - '/widget/scrollview/GridView/gridview': (context) => GridViewDemo(), + routerMaps[gridview] : (context) => GridViewDemo(), }; } -const nameSpaces = 'scrollview_'; Map routesMapScrollView = { - nameSpaces + 'gridview': '/widget/scrollview/GridView/gridview', + gridview: routerMaps[gridview], }; diff --git a/lib/widget/e_image.dart b/lib/widget/e_image.dart deleted file mode 100644 index fcbc7cd..0000000 --- a/lib/widget/e_image.dart +++ /dev/null @@ -1 +0,0 @@ -//图片组件 diff --git a/lib/widget/scrollview/GridView/gridview.dart b/lib/widget/scrollview/GridView/gridview.dart index 831039e..8414a5b 100644 --- a/lib/widget/scrollview/GridView/gridview.dart +++ b/lib/widget/scrollview/GridView/gridview.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:efox_flutter/components/widgetComp.dart'; +import 'intro.dart'; class GridViewDemo extends StatefulWidget { @override @@ -13,7 +14,7 @@ class _GridViewDemoState extends State { title: 'GridViewDemo', modelChild: (context, child, model) { return [ - + md_01, Container( constraints: BoxConstraints.expand( height: Theme.of(context).textTheme.display1.fontSize * 1.1 + 200.0, @@ -22,12 +23,6 @@ class _GridViewDemoState extends State { color: Colors.teal.shade700, alignment: Alignment.center, child: Text('Hello World', style: Theme.of(context).textTheme.display1.copyWith(color: Colors.white)), - foregroundDecoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage('https://www.example.com/images/frame.png'), - centerSlice: Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0), - ), - ), transform: Matrix4.rotationZ(0.1), ), Container( @@ -38,15 +33,8 @@ class _GridViewDemoState extends State { color: Colors.teal.shade700, alignment: Alignment.center, child: Text('Hello World', style: Theme.of(context).textTheme.display1.copyWith(color: Colors.white)), - foregroundDecoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage('https://www.example.com/images/frame.png'), - centerSlice: Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0), - ), - ), transform: Matrix4.rotationZ(0.1), ), - ]; }, ); diff --git a/lib/widget/scrollview/GridView/intro.dart b/lib/widget/scrollview/GridView/intro.dart index 9b490c8..503e459 100644 --- a/lib/widget/scrollview/GridView/intro.dart +++ b/lib/widget/scrollview/GridView/intro.dart @@ -1 +1,4 @@ -const text01 = "f"; \ No newline at end of file +const md_01 = """ +### ***GridView介绍*** + +"""; \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 499bfc2..1801f84 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -29,6 +29,7 @@ dependencies: dio: ^1.0.12 cached_network_image: ^0.5.1 intl: ^0.15.7 + flutter_markdown: ^0.2.0 dev_dependencies: flutter_test: From 0a4dc4c8ac1fe77500551fc7aae239c0f92c9744 Mon Sep 17 00:00:00 2001 From: yangshangzhi Date: Tue, 19 Feb 2019 18:00:08 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0http=E8=AF=B7=E6=B1=82=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0md=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/components/widgetComp.dart | 2 +- lib/page/tabbar/index.dart | 7 +++- lib/store/http.dart | 43 ++++++++++++++++++++ lib/widget/scrollview/GridView/gridview.dart | 31 +++++++------- lib/widget/scrollview/GridView/intro.dart | 26 +++++++++++- 5 files changed, 90 insertions(+), 19 deletions(-) create mode 100644 lib/store/http.dart diff --git a/lib/components/widgetComp.dart b/lib/components/widgetComp.dart index 740d25f..ecac97d 100644 --- a/lib/components/widgetComp.dart +++ b/lib/components/widgetComp.dart @@ -26,7 +26,7 @@ class WidgetComp extends StatelessWidget { title: Text(this.title), ), body: ListView( - padding: EdgeInsets.all(20.0), + padding: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0), shrinkWrap: true, children: _bodyList, ), diff --git a/lib/page/tabbar/index.dart b/lib/page/tabbar/index.dart index 7b3a057..ba26c08 100644 --- a/lib/page/tabbar/index.dart +++ b/lib/page/tabbar/index.dart @@ -56,7 +56,12 @@ class _ComponentsPageState extends State (index) { return Container( decoration: BoxDecoration( - border: Border.all(color: Colors.deepOrange, width: 0.4), + border: Border( + bottom: BorderSide( + width: .1, + color: Colors.orange.shade300, + ) + ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/store/http.dart b/lib/store/http.dart new file mode 100644 index 0000000..d6e746a --- /dev/null +++ b/lib/store/http.dart @@ -0,0 +1,43 @@ +import 'package:dio/dio.dart'; +import 'dart:io'; + +class RestApi { + RestApi(); + static Dio _dio; + static getDio([options]) { + if (RestApi._dio != null) { + return RestApi._dio; + } + Dio dio = new Dio(options); + // proxy + dio.onHttpClientCreate = (HttpClient client) { + // client.findProxy = (uri) { + // print(Index.proxyUrl); + // return Index.proxyUrl; + // }; + }; + RestApi._dio = dio; + return dio; + } + + static request({method, url, data}) async { + Response response; + if (method == 'get') { + response = await RestApi.getDio().get(url, data: data); + } else { + response = await RestApi.getDio().post(url, data: data); + } + return response.data; + } + + // dio.post('/test', data: {id:'123'}) + static post(url, [data]) async{ + return await RestApi.getDio().post(url, data: data); + } + + // dio.get('/test', {data: {}}) + // dio.get('/test?id=123') + static get(url, [data]) async { + return await RestApi.getDio().get(url, data: data); + } +} diff --git a/lib/widget/scrollview/GridView/gridview.dart b/lib/widget/scrollview/GridView/gridview.dart index 8414a5b..88dd9db 100644 --- a/lib/widget/scrollview/GridView/gridview.dart +++ b/lib/widget/scrollview/GridView/gridview.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:efox_flutter/components/widgetComp.dart'; +import 'package:efox_flutter/store/http.dart'; import 'intro.dart'; class GridViewDemo extends StatefulWidget { @@ -8,6 +9,18 @@ class GridViewDemo extends StatefulWidget { } class _GridViewDemoState extends State { + String mdList = ''; + @override + void initState() { + super.initState(); + this.initMd (); + } + initMd () async { + dynamic res = await RestApi.get('https://wanwusangzhi.github.io/WebStudy/readme.md'); + setState(() { + this.mdList = res.toString(); + }); + } @override Widget build(BuildContext context) { return WidgetComp( @@ -15,25 +28,11 @@ class _GridViewDemoState extends State { modelChild: (context, child, model) { return [ md_01, + mdList, Container( - constraints: BoxConstraints.expand( - height: Theme.of(context).textTheme.display1.fontSize * 1.1 + 200.0, - ), - padding: const EdgeInsets.all(8.0), - color: Colors.teal.shade700, - alignment: Alignment.center, - child: Text('Hello World', style: Theme.of(context).textTheme.display1.copyWith(color: Colors.white)), - transform: Matrix4.rotationZ(0.1), - ), - Container( - constraints: BoxConstraints.expand( - height: Theme.of(context).textTheme.display1.fontSize * 1.1 + 200.0, - ), - padding: const EdgeInsets.all(8.0), color: Colors.teal.shade700, alignment: Alignment.center, - child: Text('Hello World', style: Theme.of(context).textTheme.display1.copyWith(color: Colors.white)), - transform: Matrix4.rotationZ(0.1), + child: Text('Hello WorldHello WorldHello WorldHello WorldHello World', style: Theme.of(context).textTheme.display1.copyWith(color: Colors.white)), ), ]; }, diff --git a/lib/widget/scrollview/GridView/intro.dart b/lib/widget/scrollview/GridView/intro.dart index 503e459..48f56f6 100644 --- a/lib/widget/scrollview/GridView/intro.dart +++ b/lib/widget/scrollview/GridView/intro.dart @@ -1,4 +1,28 @@ +import 'package:flutter/material.dart'; + const md_01 = """ -### ***GridView介绍*** +### ***GridView*** + +> GridView可创建一个二维的网格布局 +``` + + GridView({ + Key key, + Axis scrollDirection: Axis.vertical, + bool reverse: false, + ScrollController controller, + bool primary, + ScrollPhysics physics, + bool shrinkWrap: false, + EdgeInsetsGeometry padding, + @required SliverGridDelegate gridDelegate, + bool addAutomaticKeepAlives: true, + bool addRepaintBoundaries: true, + bool addSemanticIndexes: true, + double cacheExtent, + List children: const [], + int semanticChildCount +}) +``` """; \ No newline at end of file