diff --git a/assets/json/widget_list.json b/assets/json/widget_list.json index 3ebb1f1..966994b 100644 --- a/assets/json/widget_list.json +++ b/assets/json/widget_list.json @@ -84,7 +84,7 @@ { "code": 59673, "name": "GridView", - "key": "scrollview_gridview" + "key": "/scrollview_gridview" } ] } diff --git a/docs/widget/scrollview/gridview/code.md b/docs/widget/scrollview/gridview/code.md new file mode 100644 index 0000000..c70cf3d --- /dev/null +++ b/docs/widget/scrollview/gridview/code.md @@ -0,0 +1,40 @@ +``` +import 'package:flutter/material.dart'; +class Example extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('Gridview'), + ), + body: GridView.count( + crossAxisCount: 3, + reverse: false, + scrollDirection: Axis.vertical, + controller: ScrollController( + initialScrollOffset: 0.0, + ), + crossAxisSpacing: 10.0, + mainAxisSpacing: 20.0, + childAspectRatio: 2, + physics: BouncingScrollPhysics(), + primary: false, + children: List.generate(25, (index) { + return Container( + decoration: BoxDecoration( + border: Border.all( + color: Colors.redAccent, + ), + ), + child: Center( + child: Text('Item $index', + style: Theme.of(context).textTheme.headline), + ), + ); + }, growable: false), + ), + ); + } +} + +``` \ No newline at end of file diff --git a/docs/widget/scrollview/gridview/index.md b/docs/widget/scrollview/gridview/index.md new file mode 100644 index 0000000..ac74488 --- /dev/null +++ b/docs/widget/scrollview/gridview/index.md @@ -0,0 +1,80 @@ +## ***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 +}) +``` +### 进阶用法 +``` +GridView.builder // 动态加载,用于分页较多 +GridView.count // 指定数据加载 +GridView.custom +GridView.extent +``` + +### 用例 +* GridView.count +> +crossAxisCount:必填,指定列数 +children: 子组件 +reverse:默认false, 当为true时反转滚动方向,即上到下反转成下到上,左到右反转成右到左 +controller: ScrollController类,能初始化滚动相关的属性,如位置,也能监听滚动变化 +primary: 默认true, 当填充数量调试不足以产生滚动条,滚动组件时,不影响最外层滚动条,即界面不随着手势滚动。 +primary: false, 且controller=null(或者ScrollContorller中的initialScrollOffset属性为0),GridView.count的数量较少不足产生滚动条时,滚动主体为最外层滚动条。 +physics: ScrollPhysics类,影响视图与用户输入交互。 +shrinkWrap: 默认false, 滚动视图内容展开和收缩时不重新计算视图大小,例如外层height=200, 滚动的内容可能增加了expendTile,展开后的内容超过了200高,这时候会报错,此时修改shrinkWrap=true,即滚动视图会重新计算。 +scrollDirection:默认Axis.vertical.,垂直方向,可通过Axis.horizontal修改为水平方向。 +mainAxisSpacing: 主轴方向间距, 主轴方向由scrollDirection确定 +crossAxisSpacing: 副轴方向间距, +childAspectRatio: 子元素中宽高比,宽度由ViewPort/crossAxisCount确定 + +``` +GridView.count( + crossAxisCount: 3, + reverse: false, + scrollDirection: Axis.vertical, + controller: ScrollController( + initialScrollOffset: 0.0, + ), + crossAxisSpacing: 10.0, + mainAxisSpacing: 20.0, + childAspectRatio: 2, + physics: BouncingScrollPhysics(), + primary: false, + children: List.generate(15, (index) { + return Container( + decoration: BoxDecoration( + border: Border.all( + color: Colors.redAccent, + ), + ), + child: Center( + child: Text('Item $index', + style: Theme.of(context).textTheme.headline), + ), + ); + }, growable: false), + ), +); +``` + +>ScrollPhysics类: +* BouncingScrollPhysics,ClampingScrollPhysics,AlwaysScrollableScrollPhysics,NeverScrollableScrollPhysics \ No newline at end of file diff --git a/lib/components/baseComp.dart b/lib/components/baseComp.dart index f07ea41..28bd3a0 100644 --- a/lib/components/baseComp.dart +++ b/lib/components/baseComp.dart @@ -15,7 +15,11 @@ class BaseComp extends StatelessWidget { appBar: AppBar( title: Text(this.title), ), - body: this.child(context, child, model), + body: ListView( + children: [ + this.child(context, child, model) + ], + ), ); } ); diff --git a/lib/components/exampleComp.dart b/lib/components/exampleComp.dart new file mode 100644 index 0000000..9db343b --- /dev/null +++ b/lib/components/exampleComp.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; + +class ExampleComp extends StatelessWidget { + final Widget child; + + ExampleComp({Key key, this.child}):super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + height: 420.0, + margin: EdgeInsets.fromLTRB(50, 40, 50, 40), + decoration: BoxDecoration( + border: Border.all( + color: Colors.deepOrange, + width: 1.0 + ), + ), + child: this.child, + ); + } +} \ No newline at end of file diff --git a/lib/components/webviewComp.dart b/lib/components/webviewComp.dart new file mode 100644 index 0000000..85c911e --- /dev/null +++ b/lib/components/webviewComp.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; + +class WebViewComp extends StatelessWidget { + final String url; + final String title; + WebViewComp({Key key, @required this.url, this.title}) : super(key: key); + + void controller() { + final flutterWebviewPlugin = new FlutterWebviewPlugin(); + flutterWebviewPlugin.onUrlChanged.listen((String url) { + print('url ${url}'); + }); + } + @override + Widget build(BuildContext context) { + return WebviewScaffold( + url: this.url, + appBar: new AppBar( + title: new Text("Webview"), + ), + withZoom: true, + withLocalStorage: true, + hidden: true, + // initialChild: Container( + // child: const Center( + // child: CircularProgressIndicator(), + // ), + // ), + ); + } +} diff --git a/lib/components/widgetComp.dart b/lib/components/widgetComp.dart index ecac97d..7b5275d 100644 --- a/lib/components/widgetComp.dart +++ b/lib/components/widgetComp.dart @@ -2,18 +2,37 @@ import 'package:flutter/material.dart'; import 'package:efox_flutter/store/STORE.dart'; import 'package:efox_flutter/components/markdownComp.dart'; -class WidgetComp extends StatelessWidget { +class WidgetComp extends StatefulWidget { final dynamic modelChild; final String title; - WidgetComp({Key key, this.title, @required this.modelChild}) - : super(key: key); + WidgetComp({ + Key key, + this.title, + @required this.modelChild, + }) : super(key: key); + + @override + _WidgetCompState createState() => _WidgetCompState( + title: this.title, + modelChild: this.modelChild, + ); +} + +class _WidgetCompState extends State { + List _bodyList = []; + final dynamic modelChild; + final String title; + + _WidgetCompState({ + this.title, + @required this.modelChild, + }); @override Widget build(BuildContext context) { return STORE.connect(builder: (context, child, model) { List _list = this.modelChild(context, child, model); - List _bodyList = []; _list.forEach((item) { if (item.runtimeType == String) { _bodyList.add(MarkDownComp(item)); @@ -25,12 +44,16 @@ class WidgetComp extends StatelessWidget { appBar: AppBar( title: Text(this.title), ), - body: ListView( - padding: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0), - shrinkWrap: true, - children: _bodyList, - ), + body: this.renderWidget(), ); }); } + + Widget renderWidget() { + return ListView( + padding: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0), + shrinkWrap: true, + children: this._bodyList, + ); + } } diff --git a/lib/components/widgetLodingComp.dart b/lib/components/widgetLodingComp.dart new file mode 100644 index 0000000..98a69a5 --- /dev/null +++ b/lib/components/widgetLodingComp.dart @@ -0,0 +1,135 @@ +import 'package:flutter/material.dart'; +import 'package:efox_flutter/store/STORE.dart'; +import 'package:efox_flutter/components/markdownComp.dart'; +import 'package:efox_flutter/lang/app_translations.dart'; +import 'package:efox_flutter/components/baseComp.dart'; +import 'package:efox_flutter/components/exampleComp.dart'; +import 'package:efox_flutter/utils/file.dart' as FileUtils; +import 'package:efox_flutter/router/index.dart' show FluroRouter; + +class WidgetComp extends StatelessWidget { + final List _bodyList = []; + final dynamic modelChild; + final List demoChild; + final String codeUrl; + final String mdUrl; + final String name; + final bool loading; + + WidgetComp({ + Key key, + this.name, + @required this.modelChild, + this.demoChild, + this.loading, + this.codeUrl, + this.mdUrl, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return STORE.connect(builder: (context, child, model) { + _bodyList.length = 0; + List _list = this.modelChild(context, child, model); + _list.forEach((item) { + if (item.runtimeType == String) { + _bodyList.add(MarkDownComp(item)); + } else { + _bodyList.add(item); + } + }); + // 增加 + if (this.demoChild != null){ + this.demoChild.forEach((Widget item) { + _bodyList.add(ExampleComp(child: item)); + }); + } + + return Scaffold( + appBar: AppBar( + title: Text(this.name), + actions: [ + IconButton( + icon: Icon( + Icons.favorite_border, + ), + onPressed: () { + FluroRouter.router.navigateTo(context, '/webview?url=${Uri.encodeComponent(this.codeUrl)}'); + }, + ), + IconButton( + icon: Icon( + Icons.code, + ), + onPressed: () async { + String mdStr = await FileUtils.readLocaleFile(this.mdUrl); + Navigator.of(context).push(MaterialPageRoute( + builder: (BuildContext context) { + return BaseComp( + title: this.name, + child: (context, child, model) { + return MarkDownComp(mdStr); + } + ); + } + )); + }, + ), + ], + ), + body: this.renderWidget(context), + ); + }); + } + + Widget renderWidget(BuildContext context) { + var _loading = this.loading; + if (_loading != null && _loading) { + return Center( + child: Stack( + children: [ + // 遮罩 + Opacity( + opacity: .8, + child: ModalBarrier( + color: Colors.black87, + ), + ), + // 居中显示 + Center( + child: Container( + padding: const EdgeInsets.all(20.0), + decoration: BoxDecoration( + color: Colors.black87, + borderRadius: BorderRadius.circular(4.0), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + CircularProgressIndicator(), + Container( + padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 0), + child: Text( + AppTranslations.of(context).t('loading'), + style: + TextStyle(color: Colors.deepOrange, fontSize: 16.0), + ), + ) + ], + ), + ), + ), + ], + ), + ); + } + // 加载完成后返回页面 + return ListView( + padding: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0), + shrinkWrap: true, + children: this._bodyList, + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index 4e43237..b8b55e5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,10 +7,12 @@ import 'package:efox_flutter/lang/app_translations_delegate.dart'; import 'package:efox_flutter/store/store.dart'; //路由 import 'package:efox_flutter/router/index.dart'; - void main() => runApp(MainApp()); class MainApp extends StatefulWidget { + MainApp() { + FluroRouter.initRouter(); + } @override MainAppState createState() => MainAppState(); } @@ -59,8 +61,7 @@ class MainAppState extends State { theme: ThemeData( primarySwatch: Colors.deepOrange, ), - initialRoute: '/', - routes: getRoutesConfig(context), + onGenerateRoute: FluroRouter.router.generator, ), ); } diff --git a/lib/page/tabbar/index.dart b/lib/page/tabbar/index.dart index ba26c08..39cf638 100644 --- a/lib/page/tabbar/index.dart +++ b/lib/page/tabbar/index.dart @@ -1,9 +1,7 @@ import 'package:flutter/material.dart'; import 'package:efox_flutter/lang/app_translations.dart'; -import 'dart:convert'; -import 'package:flutter/services.dart' show rootBundle; -import 'package:efox_flutter/store/objects/widget_list.dart'; import 'package:efox_flutter/router/index.dart'; +import 'package:efox_flutter/widget/index.dart' as WidgetRoot; class ComponentsPage extends StatefulWidget { _ComponentsPageState createState() => _ComponentsPageState(); @@ -16,18 +14,7 @@ class _ComponentsPageState extends State @override initState() { super.initState(); - getWidgetList().then((res) { - setState(() { - mapList = res.list; - }); - }); - } - - getWidgetList() async { - String widgetString = await rootBundle - .loadString('assets/json/widget_list.json', cache: false); - var _tmpMap = new WidgetListInfo.fromJson(json.decode(widgetString)); - return _tmpMap; + this.mapList = WidgetRoot.getAllWidgets(); } /** @@ -75,8 +62,7 @@ class _ComponentsPageState extends State color: Colors.deepOrange, ), onPressed: () { - String _key = _tmpWidgetList[index].key; - Navigator.pushNamed(context, routesMap()['${_key}']); + FluroRouter.router.navigateTo(context, _tmpWidgetList[index].routerName); }, ), Text(_tmpWidgetList[index].name), diff --git a/lib/page/test/test_page_one.dart b/lib/page/test/test_page_one.dart deleted file mode 100644 index 1bafde2..0000000 --- a/lib/page/test/test_page_one.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:flutter/material.dart'; - -class TestPageOne extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text('test page one'), - ), - body: Center( - child: Text('test pahe pne'), - ), - ); - } -} diff --git a/lib/page/test/test_page_two.dart b/lib/page/test/test_page_two.dart deleted file mode 100644 index baab6a2..0000000 --- a/lib/page/test/test_page_two.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:flutter/material.dart'; - -class TestPageTwo extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text('test page two'), - ), - body: Center( - child: Text('test pahe two'), - ), - ); - } -} diff --git a/lib/router/handles.dart b/lib/router/handles.dart new file mode 100644 index 0000000..ba78e20 --- /dev/null +++ b/lib/router/handles.dart @@ -0,0 +1,14 @@ +import 'package:flutter/material.dart'; +import 'package:fluro/fluro.dart'; +import 'package:efox_flutter/components/webviewComp.dart'; + +Handler webviewHandler = Handler( + handlerFunc: (BuildContext context, Map params) { + String url = params["url"]?.first; + String title = params["title"]?.first ?? 'WebView'; + return WebViewComp( + url: url, + title: title + ); + }, +); \ No newline at end of file diff --git a/lib/router/index.dart b/lib/router/index.dart index 224bd1b..14b6227 100644 --- a/lib/router/index.dart +++ b/lib/router/index.dart @@ -1,21 +1,38 @@ import 'package:flutter/widgets.dart'; +import 'package:fluro/fluro.dart'; //首页 import 'package:efox_flutter/page/home.dart'; +import 'package:efox_flutter/widget/index.dart' as WidgetConfig; +import 'handles.dart'; -//测试路由配置 -import 'package:efox_flutter/router/test/index.dart'; -import 'package:efox_flutter/router/scrollview/index.dart'; +class FluroRouter { + static Router router; -Map getRoutesConfig(BuildContext context) { - Map finalMap = {}; - finalMap.addAll({'/': (context) => HomePage()}); - finalMap.addAll(getTestRoutesConfig(context)); - finalMap.addAll(getScrollViewRoutersConfig(context)); - return finalMap; -} + static Router initRouter() { + FluroRouter.router = Router(); + router.define( + '/', + handler: Handler( + handlerFunc: (BuildContext context, Map params) { + return HomePage(); + }, + ), + ); -Map routesMap() { - Map routesMap= {}; - routesMap.addAll(routesMapScrollView); - return routesMap; + router.define('/webview', handler: webviewHandler); + + // 组件 + WidgetConfig.getAllWidgets().forEach((widgetListInfo) { + widgetListInfo.widgetList.forEach((widgetInfo) { + router.define( + widgetInfo.routerName, + handler: Handler( + handlerFunc: (BuildContext context, Map params) { + return widgetInfo.widget; + }), + ); + }); + }); + return router; + } } diff --git a/lib/router/scrollview/index.dart b/lib/router/scrollview/index.dart deleted file mode 100644 index 4e90b7a..0000000 --- a/lib/router/scrollview/index.dart +++ /dev/null @@ -1,20 +0,0 @@ -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 { - routerMaps[gridview] : (context) => GridViewDemo(), - }; -} - -Map routesMapScrollView = { - gridview: routerMaps[gridview], -}; diff --git a/lib/router/test/index.dart b/lib/router/test/index.dart deleted file mode 100644 index f05e746..0000000 --- a/lib/router/test/index.dart +++ /dev/null @@ -1,11 +0,0 @@ -import 'package:flutter/widgets.dart'; - -import 'package:efox_flutter/page/test/test_page_one.dart'; -import 'package:efox_flutter/page/test/test_page_two.dart'; - -Map getTestRoutesConfig(BuildContext context) { - return { - '/test/test_page_one': (context) => TestPageOne(), - '/test/test_page_two': (context) => TestPageTwo() - }; -} diff --git a/lib/store/objects/widget_list.dart b/lib/store/objects/widget_info.dart similarity index 68% rename from lib/store/objects/widget_list.dart rename to lib/store/objects/widget_info.dart index 086dd2d..9fc00f9 100644 --- a/lib/store/objects/widget_list.dart +++ b/lib/store/objects/widget_info.dart @@ -1,12 +1,19 @@ +import 'package:flutter/widgets.dart'; class ItemInfo extends Object { int code; String name; - String key; + String routerName; + Widget widget; + String webviewTitle; + + ItemInfo({this.code, this.name, this.routerName, this.widget, this.webviewTitle}); ItemInfo.fromJson(Map json) { code = json['code']; name = json['name']; - key = json['key']; + widget = json['widget']; + routerName = json['routerName']; + webviewTitle = json['webviewTitle']; } } @@ -15,6 +22,8 @@ class ItemListInfo { int code; List widgetList; + ItemListInfo({ this.typeName, this.code, this.widgetList}); + ItemListInfo.fromJson(Map json) { typeName = json['typeName']; code = json['code']; diff --git a/lib/utils/file.dart b/lib/utils/file.dart new file mode 100644 index 0000000..f9591aa --- /dev/null +++ b/lib/utils/file.dart @@ -0,0 +1,6 @@ +import 'package:flutter/services.dart' show rootBundle; + +Future readLocaleFile (path) async { + String content = await rootBundle.loadString('${path}', cache: false); + return content; +} \ No newline at end of file diff --git a/lib/widget/index.dart b/lib/widget/index.dart new file mode 100644 index 0000000..1fb9a74 --- /dev/null +++ b/lib/widget/index.dart @@ -0,0 +1,7 @@ +import 'scrollview/index.dart' as ScrollView; + +List getAllWidgets() { + List routerMap =[]; + routerMap.addAll(ScrollView.widgetMap); + return routerMap; +} \ No newline at end of file diff --git a/lib/widget/scrollview/GridView/gridview.dart b/lib/widget/scrollview/GridView/gridview.dart deleted file mode 100644 index 88dd9db..0000000 --- a/lib/widget/scrollview/GridView/gridview.dart +++ /dev/null @@ -1,41 +0,0 @@ -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 { - @override - _GridViewDemoState createState() => new _GridViewDemoState(); -} - -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( - title: 'GridViewDemo', - modelChild: (context, child, model) { - return [ - md_01, - mdList, - Container( - color: Colors.teal.shade700, - alignment: Alignment.center, - 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 deleted file mode 100644 index 48f56f6..0000000 --- a/lib/widget/scrollview/GridView/intro.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:flutter/material.dart'; - -const md_01 = """ -### ***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 diff --git a/lib/widget/scrollview/gridview/demo.dart b/lib/widget/scrollview/gridview/demo.dart new file mode 100644 index 0000000..7d1c0a2 --- /dev/null +++ b/lib/widget/scrollview/gridview/demo.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'dart:math'; +class Example extends StatelessWidget { + @override + Widget build(BuildContext context) { + int _value = Random().nextInt(60); + return Scaffold( + appBar: AppBar( + title: Text('Gridview ${_value} items'), + ), + body: GridView.count( + crossAxisCount: 3, + reverse: false, + scrollDirection: Axis.vertical, + controller: ScrollController( + initialScrollOffset: 0.0, + ), + crossAxisSpacing: 10.0, + mainAxisSpacing: 20.0, + childAspectRatio: 2, + physics: BouncingScrollPhysics(), + primary: false, + children: List.generate(_value, (index) { + return Container( + decoration: BoxDecoration( + border: Border.all( + color: Colors.redAccent, + ), + ), + child: Center( + child: Text('Item $index', + style: Theme.of(context).textTheme.headline), + ), + ); + }, growable: false), + ), + ); + } +} diff --git a/lib/widget/scrollview/gridview/index.dart b/lib/widget/scrollview/gridview/index.dart new file mode 100644 index 0000000..c1a99cd --- /dev/null +++ b/lib/widget/scrollview/gridview/index.dart @@ -0,0 +1,54 @@ +import 'package:flutter/material.dart'; +import 'package:efox_flutter/components/widgetLodingComp.dart'; +import 'demo.dart' as Example; +import 'package:efox_flutter/utils/file.dart' as FileUtils; + +String _mdUrl = 'docs/widget/scrollview/gridview/index.md'; + +class Demo extends StatefulWidget { + static String name = 'GridView'; + static String routerName = 'gridview'; + static String originUrl = 'https://flutter.io/docs/cookbook/lists/grid-lists'; + static String codeUrl = 'https://github.com/efoxTeam/flutter-ui/blob/master/docs/widget/scrollview/gridview/code.md'; + static String mdUrl = _mdUrl; + + @override + _DemoState createState() => new _DemoState(); +} + +class _DemoState extends State { + bool loading = true; + String ___MD___ = _mdUrl; + + @override + void initState() { + super.initState(); + this.initMd(); + } + + initMd() async { + String mdStr = await FileUtils.readLocaleFile(___MD___); + setState(() { + this.___MD___ = mdStr; + loading = false; + }); + } + + @override + Widget build(BuildContext context) { + return WidgetComp( + name: Demo.name, + codeUrl: Demo.codeUrl, + mdUrl: Demo.mdUrl, + loading: loading, + modelChild: (context, child, model) { + return [ + ___MD___, + ]; + }, + demoChild: [ + Example.Example(), + ] + ); + } +} diff --git a/lib/widget/scrollview/index.dart b/lib/widget/scrollview/index.dart new file mode 100644 index 0000000..84c3d14 --- /dev/null +++ b/lib/widget/scrollview/index.dart @@ -0,0 +1,21 @@ +import 'package:efox_flutter/store/objects/widget_info.dart'; +import 'gridview/index.dart' as GridView; + +const nameSpaces = '/scrollview_'; + +List widgets = [ + ItemInfo( + routerName: nameSpaces + GridView.Demo.routerName, + widget: GridView.Demo(), + code: 59673, + name: GridView.Demo.name, + ) +]; + +List widgetMap = [ + ItemListInfo( + widgetList: widgets, + typeName: 'ScrollView', + code: 58353, + ) +]; \ No newline at end of file diff --git a/locale/en.json b/locale/en.json index c58d03f..33310e4 100644 --- a/locale/en.json +++ b/locale/en.json @@ -2,5 +2,6 @@ "title": "efox flutter tech app", "widgetType": { "regularLayout": "common layout" - } + }, + "loading": "Loading" } \ No newline at end of file diff --git a/locale/zh.json b/locale/zh.json index 1f1c365..25e966f 100644 --- a/locale/zh.json +++ b/locale/zh.json @@ -2,5 +2,6 @@ "title": "efox flutter教学应用", "widgetType": { "regularLayout": "常规布局" - } + }, + "loading": "加载中" } \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 1801f84..92e6c8e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,6 +30,8 @@ dependencies: cached_network_image: ^0.5.1 intl: ^0.15.7 flutter_markdown: ^0.2.0 + flutter_webview_plugin: ^0.3.0+2 + fluro: ^1.4.0 dev_dependencies: flutter_test: @@ -55,6 +57,7 @@ flutter: - assets/ - assets/json/ - locale/ + - docs/widget/scrollview/gridview/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.io/assets-and-images/#resolution-aware. diff --git a/README.md b/readme.md similarity index 100% rename from README.md rename to readme.md