From da873017adb0a84ec7c6be0167e22075e5b38dd2 Mon Sep 17 00:00:00 2001 From: toly <1981462002@qq.com> Date: Tue, 28 Apr 2020 12:21:16 +0800 Subject: [PATCH] =?UTF-8?q?:ambulance:=20ios=E7=99=BD=E5=B1=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Podfile.lock | 2 +- ios/Runner.xcodeproj/project.pbxproj | 6 + lib/storage/app_storage.dart | 6 +- .../node1_base.dart} | 0 .../node1_base.dart} | 0 .../node1_base.dart} | 0 .../node1_base.dart} | 61 +---- .../AnimatedCrossFade/node2_curve.dart | 65 +++++ .../node1_base.dart} | 0 .../node1_base.dart} | 0 .../node1_base.dart} | 0 .../node1_base.dart} | 0 .../node1_base.dart} | 0 .../node1_base.dart} | 0 .../node1_base.dart} | 0 .../StatefulWidget/AppBar/node1_base.dart | 49 ++++ .../{AppBar.dart => AppBar/node2_tab.dart} | 49 +--- .../node1_base.dart} | 4 +- .../node1_base.dart} | 103 +------- .../BottomNavigationBar/node2_page.dart | 101 ++++++++ .../node1_base.dart} | 40 +-- .../Checkbox/node2_tristate.dart | 44 ++++ .../node1_base.dart} | 3 + .../node1_base.dart} | 3 + .../node1_base.dart} | 0 .../node1_base.dart} | 4 +- .../node1_base.dart} | 0 .../node1_base.dart} | 0 .../node1_base.dart} | 3 + .../node1_base.dart} | 4 +- .../node1_base.dart} | 4 +- .../node1_base.dart} | 0 .../{node_base.dart => node1_base.dart} | 0 .../node1_base.dart} | 4 +- .../node1_base.dart} | 4 +- .../node1_base.dart} | 88 ------- .../Dismissible/node2_direction.dart | 96 ++++++++ .../node1_base.dart} | 0 .../widgets/StatefulWidget/Draggable.dart | 230 ----------------- .../StatefulWidget/Draggable/node1_base.dart | 41 ++++ .../StatefulWidget/Draggable/node2_data.dart | 108 ++++++++ .../StatefulWidget/Draggable/node3_use.dart | 90 +++++++ .../node1_base.dart} | 55 +---- .../DropdownButton/node2_style.dart | 58 +++++ .../node1_base.dart} | 4 +- .../node1_base.dart} | 0 .../node1_base.dart} | 0 .../{Form.dart => Form/node1_base.dart} | 0 .../node1_base.dart} | 0 .../{Hero.dart => Hero/node1_base.dart} | 8 +- lib/views/widgets/StatefulWidget/Image.dart | 231 ------------------ .../StatefulWidget/Image/node1_base.dart | 46 ++++ .../StatefulWidget/Image/node2_fit.dart | 62 +++++ .../StatefulWidget/Image/node3_alignment.dart | 47 ++++ .../Image/node4_colorBlendMode.dart | 36 +++ .../StatefulWidget/Image/node5_repeat.dart | 34 +++ .../Image/node6_centerSlice.dart | 30 +++ lib/views/widgets/stateful_unit.dart | 102 +++++--- 58 files changed, 1024 insertions(+), 901 deletions(-) rename lib/views/widgets/StatefulWidget/{AlignTransition.dart => AlignTransition/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{AnimatedAlign.dart => AnimatedAlign/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{AnimatedContainer.dart => AnimatedContainer/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{AnimatedCrossFade.dart => AnimatedCrossFade/node1_base.dart} (51%) create mode 100644 lib/views/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart rename lib/views/widgets/StatefulWidget/{AnimatedDefaultTextStyle.dart => AnimatedDefaultTextStyle/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{AnimatedList.dart => AnimatedList/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{AnimatedOpacity.dart => AnimatedOpacity/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{AnimatedPadding.dart => AnimatedPadding/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{AnimatedPositioned.dart => AnimatedPositioned/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{AnimatedPositionedDirectional.dart => AnimatedPositionedDirectional/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{AnimatedSwitcher.dart => AnimatedSwitcher/node1_base.dart} (100%) create mode 100755 lib/views/widgets/StatefulWidget/AppBar/node1_base.dart rename lib/views/widgets/StatefulWidget/{AppBar.dart => AppBar/node2_tab.dart} (64%) rename lib/views/widgets/StatefulWidget/{BottomAppBar.dart => BottomAppBar/node1_base.dart} (97%) rename lib/views/widgets/StatefulWidget/{BottomNavigationBar.dart => BottomNavigationBar/node1_base.dart} (55%) create mode 100755 lib/views/widgets/StatefulWidget/BottomNavigationBar/node2_page.dart rename lib/views/widgets/StatefulWidget/{Checkbox.dart => Checkbox/node1_base.dart} (52%) create mode 100644 lib/views/widgets/StatefulWidget/Checkbox/node2_tristate.dart rename lib/views/widgets/StatefulWidget/{CircularProgressIndicator.dart => CircularProgressIndicator/node1_base.dart} (92%) rename lib/views/widgets/StatefulWidget/{CupertinoActivityIndicator.dart => CupertinoActivityIndicator/node1_base.dart} (88%) rename lib/views/widgets/StatefulWidget/{CupertinoApp.dart => CupertinoApp/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{CupertinoNavigationBar.dart => CupertinoNavigationBar/node1_base.dart} (92%) rename lib/views/widgets/StatefulWidget/{CupertinoPageScaffold.dart => CupertinoPageScaffold/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{CupertinoScrollbar.dart => CupertinoScrollbar/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{CupertinoSlider.dart => CupertinoSlider/node1_base.dart} (94%) rename lib/views/widgets/StatefulWidget/{CupertinoSwitch.dart => CupertinoSwitch/node1_base.dart} (91%) rename lib/views/widgets/StatefulWidget/{CupertinoTabBar.dart => CupertinoTabBar/node1_base.dart} (95%) rename lib/views/widgets/StatefulWidget/{CupertinoTabScaffold.dart => CupertinoTabScaffold/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/CupertinoTimerPicker/{node_base.dart => node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{DecoratedBoxTransition.dart => DecoratedBoxTransition/node1_base.dart} (96%) rename lib/views/widgets/StatefulWidget/{DefaultTextStyleTransition.dart => DefaultTextStyleTransition/node1_base.dart} (95%) rename lib/views/widgets/StatefulWidget/{Dismissible.dart => Dismissible/node1_base.dart} (52%) create mode 100644 lib/views/widgets/StatefulWidget/Dismissible/node2_direction.dart rename lib/views/widgets/StatefulWidget/{DragTarget.dart => DragTarget/node1_base.dart} (100%) delete mode 100644 lib/views/widgets/StatefulWidget/Draggable.dart create mode 100644 lib/views/widgets/StatefulWidget/Draggable/node1_base.dart create mode 100644 lib/views/widgets/StatefulWidget/Draggable/node2_data.dart create mode 100644 lib/views/widgets/StatefulWidget/Draggable/node3_use.dart rename lib/views/widgets/StatefulWidget/{DropdownButton.dart => DropdownButton/node1_base.dart} (52%) create mode 100644 lib/views/widgets/StatefulWidget/DropdownButton/node2_style.dart rename lib/views/widgets/StatefulWidget/{ExpandIcon.dart => ExpandIcon/node1_base.dart} (91%) rename lib/views/widgets/StatefulWidget/{ExpansionPanelList.dart => ExpansionPanelList/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{ExpansionTile.dart => ExpansionTile/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{Form.dart => Form/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{FutureBuilder.dart => FutureBuilder/node1_base.dart} (100%) rename lib/views/widgets/StatefulWidget/{Hero.dart => Hero/node1_base.dart} (92%) delete mode 100644 lib/views/widgets/StatefulWidget/Image.dart create mode 100644 lib/views/widgets/StatefulWidget/Image/node1_base.dart create mode 100644 lib/views/widgets/StatefulWidget/Image/node2_fit.dart create mode 100644 lib/views/widgets/StatefulWidget/Image/node3_alignment.dart create mode 100644 lib/views/widgets/StatefulWidget/Image/node4_colorBlendMode.dart create mode 100644 lib/views/widgets/StatefulWidget/Image/node5_repeat.dart create mode 100644 lib/views/widgets/StatefulWidget/Image/node6_centerSlice.dart diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 35f741e..1249fc9 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -68,6 +68,6 @@ SPEC CHECKSUMS: url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313 url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c -PODFILE CHECKSUM: 1b66dae606f75376c5f2135a8290850eeb09ae83 +PODFILE CHECKSUM: 382d23bfbd130be6de706b064322c21ce8e6a930 COCOAPODS: 1.8.4 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 6f06b1f..031f663 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -10,6 +10,8 @@ 05552E71DDEE1B210A67DBD4 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 70F3B239A93318DF93C8360D /* Pods_Runner.framework */; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 63E91F0C2457E565002C2BE9 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63E91F0B2457E565002C2BE9 /* App.framework */; }; + 63E91F0D2457E565002C2BE9 /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 63E91F0B2457E565002C2BE9 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -25,6 +27,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 63E91F0D2457E565002C2BE9 /* App.framework in Embed Frameworks */, 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, ); name = "Embed Frameworks"; @@ -37,6 +40,7 @@ 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 33DC5F3DBC90F47343297D28 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 63E91F0B2457E565002C2BE9 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 70F3B239A93318DF93C8360D /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -59,6 +63,7 @@ buildActionMask = 2147483647; files = ( 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, + 63E91F0C2457E565002C2BE9 /* App.framework in Frameworks */, 05552E71DDEE1B210A67DBD4 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -69,6 +74,7 @@ 02D8EC7DCA94EAA4A49FE3C6 /* Frameworks */ = { isa = PBXGroup; children = ( + 63E91F0B2457E565002C2BE9 /* App.framework */, 70F3B239A93318DF93C8360D /* Pods_Runner.framework */, ); name = Frameworks; diff --git a/lib/storage/app_storage.dart b/lib/storage/app_storage.dart index 68c1896..3aaa742 100644 --- a/lib/storage/app_storage.dart +++ b/lib/storage/app_storage.dart @@ -51,18 +51,16 @@ class AppStorage { var dbPath = path.join(databasesPath, "flutter.db"); var exists = await databaseExists(dbPath); if (!exists) { - print("Creating new copy from asset"); try { await Directory(path.dirname(dbPath)).create(recursive: true); + print("========= assets ======拷贝完成===="); } catch (_) {} - ByteData data = await rootBundle.load(path.join("assets", "flutter.db")); List bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); await File(dbPath).writeAsBytes(bytes, flush: true); - } else { - print("Opening existing database"); + print("========= 数据库 ======已存在===="); } return await openDatabase(dbPath, readOnly: false); } diff --git a/lib/views/widgets/StatefulWidget/AlignTransition.dart b/lib/views/widgets/StatefulWidget/AlignTransition/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/AlignTransition.dart rename to lib/views/widgets/StatefulWidget/AlignTransition/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/AnimatedAlign.dart b/lib/views/widgets/StatefulWidget/AnimatedAlign/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/AnimatedAlign.dart rename to lib/views/widgets/StatefulWidget/AnimatedAlign/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/AnimatedContainer.dart b/lib/views/widgets/StatefulWidget/AnimatedContainer/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/AnimatedContainer.dart rename to lib/views/widgets/StatefulWidget/AnimatedContainer/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/AnimatedCrossFade.dart b/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node1_base.dart similarity index 51% rename from lib/views/widgets/StatefulWidget/AnimatedCrossFade.dart rename to lib/views/widgets/StatefulWidget/AnimatedCrossFade/node1_base.dart index f1f8a80..5083040 100644 --- a/lib/views/widgets/StatefulWidget/AnimatedCrossFade.dart +++ b/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node1_base.dart @@ -68,63 +68,4 @@ class _CustomAnimatedCrossFadeState extends State { v ? CrossFadeState.showFirst : CrossFadeState.showSecond; }); }); -} -// { -// "widgetId": 100, -// "name": 'AnimatedCrossFade基本使用', -// "priority": 2, -// "subtitle": -// "【firstCurve】 : 第一曲线 【Curve】\n" -// "【secondCurve】 : 第二曲线 【Curve】\n" -// "【sizeCurve】 : 尺寸变化曲线 【CrossFadeState】", -// } -class CurveAnimatedCrossFade extends StatefulWidget { - @override - _CurveAnimatedCrossFadeState createState() => _CurveAnimatedCrossFadeState(); -} - -class _CurveAnimatedCrossFadeState extends State { - var _crossFadeState = CrossFadeState.showFirst; - - bool get isFirst=> _crossFadeState == CrossFadeState.showFirst; - - @override - Widget build(BuildContext context) { - return Wrap( - children: [ - Container( - child: AnimatedCrossFade( - firstCurve: Curves.easeInCirc, - secondCurve: Curves.easeInToLinear, - sizeCurve: Curves.bounceOut, - firstChild: Container( - alignment: Alignment.center, - width: 200, - height: 80, - color: Colors.orange , - child: FlutterLogo(colors: Colors.blue,size: 50,), - ), - secondChild: Container( - width: 200, - height: 150, - alignment: Alignment.center, - color: Colors.blue, - child: FlutterLogo( - textColor: Colors.white, - colors: Colors.orange,size: 100,style: FlutterLogoStyle.stacked,), - ), - duration: Duration(milliseconds: 1000), - crossFadeState: _crossFadeState, - ), - ), - _buildSwitch(), - ], - ); - } - - Widget _buildSwitch() => Switch(value: isFirst, onChanged: (v){ - setState(() { - _crossFadeState= v?CrossFadeState.showFirst:CrossFadeState.showSecond; - }); - }); -} +} \ No newline at end of file diff --git a/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart b/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart new file mode 100644 index 0000000..7522f70 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart @@ -0,0 +1,65 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020-03-20 +/// contact me by email 1981462002@qq.com +/// 说明: + +// { +// "widgetId": 100, +// "name": 'AnimatedCrossFade动画曲线', +// "priority": 2, +// "subtitle": +// "【firstCurve】 : 第一曲线 【Curve】\n" +// "【secondCurve】 : 第二曲线 【Curve】\n" +// "【sizeCurve】 : 尺寸变化曲线 【CrossFadeState】", +// } +class CurveAnimatedCrossFade extends StatefulWidget { + @override + _CurveAnimatedCrossFadeState createState() => _CurveAnimatedCrossFadeState(); +} + +class _CurveAnimatedCrossFadeState extends State { + var _crossFadeState = CrossFadeState.showFirst; + + bool get isFirst=> _crossFadeState == CrossFadeState.showFirst; + + @override + Widget build(BuildContext context) { + return Wrap( + children: [ + Container( + child: AnimatedCrossFade( + firstCurve: Curves.easeInCirc, + secondCurve: Curves.easeInToLinear, + sizeCurve: Curves.bounceOut, + firstChild: Container( + alignment: Alignment.center, + width: 200, + height: 80, + color: Colors.orange , + child: FlutterLogo(colors: Colors.blue,size: 50,), + ), + secondChild: Container( + width: 200, + height: 150, + alignment: Alignment.center, + color: Colors.blue, + child: FlutterLogo( + textColor: Colors.white, + colors: Colors.orange,size: 100,style: FlutterLogoStyle.stacked,), + ), + duration: Duration(milliseconds: 1000), + crossFadeState: _crossFadeState, + ), + ), + _buildSwitch(), + ], + ); + } + + Widget _buildSwitch() => Switch(value: isFirst, onChanged: (v){ + setState(() { + _crossFadeState= v?CrossFadeState.showFirst:CrossFadeState.showSecond; + }); + }); +} diff --git a/lib/views/widgets/StatefulWidget/AnimatedDefaultTextStyle.dart b/lib/views/widgets/StatefulWidget/AnimatedDefaultTextStyle/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/AnimatedDefaultTextStyle.dart rename to lib/views/widgets/StatefulWidget/AnimatedDefaultTextStyle/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/AnimatedList.dart b/lib/views/widgets/StatefulWidget/AnimatedList/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/AnimatedList.dart rename to lib/views/widgets/StatefulWidget/AnimatedList/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/AnimatedOpacity.dart b/lib/views/widgets/StatefulWidget/AnimatedOpacity/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/AnimatedOpacity.dart rename to lib/views/widgets/StatefulWidget/AnimatedOpacity/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/AnimatedPadding.dart b/lib/views/widgets/StatefulWidget/AnimatedPadding/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/AnimatedPadding.dart rename to lib/views/widgets/StatefulWidget/AnimatedPadding/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/AnimatedPositioned.dart b/lib/views/widgets/StatefulWidget/AnimatedPositioned/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/AnimatedPositioned.dart rename to lib/views/widgets/StatefulWidget/AnimatedPositioned/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/AnimatedPositionedDirectional.dart b/lib/views/widgets/StatefulWidget/AnimatedPositionedDirectional/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/AnimatedPositionedDirectional.dart rename to lib/views/widgets/StatefulWidget/AnimatedPositionedDirectional/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/AnimatedSwitcher.dart b/lib/views/widgets/StatefulWidget/AnimatedSwitcher/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/AnimatedSwitcher.dart rename to lib/views/widgets/StatefulWidget/AnimatedSwitcher/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/AppBar/node1_base.dart b/lib/views/widgets/StatefulWidget/AppBar/node1_base.dart new file mode 100755 index 0000000..54f912e --- /dev/null +++ b/lib/views/widgets/StatefulWidget/AppBar/node1_base.dart @@ -0,0 +1,49 @@ +import 'package:flutter/material.dart'; + +import '../PopupMenuButton.dart'; + +/// create by 张风捷特烈 on 2020-03-23 +/// contact me by email 1981462002@qq.com +/// 说明: +// { +// "widgetId": 57, +// "name": 'AppBar基本使用', +// "priority": 1, +// "subtitle": +// "【leading】 : 左侧组件 【Widget】\n" +// "【title】 : 中间组件 【Widget】\n" +// "【actions】 : 右侧组件 【List】\n" +// "【elevation】 : 影深 【double】\n" +// "【shape】 : 形状 【ShapeBorder】\n" +// "【backgroundColor】 : 影深 【背景色】\n" +// "【centerTitle】 : 中间是否居中 【bool】", +// } + +class CustomAppBar extends StatelessWidget { + @override + Widget build(BuildContext context) { + return AppBar( + title: Text('风雅六社'), + leading: BackButton(), + backgroundColor: Colors.amber[500], + elevation: 2, + centerTitle: true, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(20), + bottomRight: Radius.circular(20), + topRight: Radius.circular(5), + bottomLeft: Radius.circular(5), + )), + actions: [ + IconButton( + icon: Icon(Icons.star), + tooltip: 'like', + onPressed: () { + // do nothing + }), + CustomPopupMenuButton() + ], + ); + } +} diff --git a/lib/views/widgets/StatefulWidget/AppBar.dart b/lib/views/widgets/StatefulWidget/AppBar/node2_tab.dart similarity index 64% rename from lib/views/widgets/StatefulWidget/AppBar.dart rename to lib/views/widgets/StatefulWidget/AppBar/node2_tab.dart index 5742ed3..e25564a 100755 --- a/lib/views/widgets/StatefulWidget/AppBar.dart +++ b/lib/views/widgets/StatefulWidget/AppBar/node2_tab.dart @@ -1,49 +1,8 @@ import 'package:flutter/material.dart'; -import 'PopupMenuButton.dart'; - -// { -// "widgetId": 57, -// "name": 'AppBar基本使用', -// "priority": 1, -// "subtitle": -// "【leading】 : 左侧组件 【Widget】\n" -// "【title】 : 中间组件 【Widget】\n" -// "【actions】 : 右侧组件 【List】\n" -// "【elevation】 : 影深 【double】\n" -// "【shape】 : 形状 【ShapeBorder】\n" -// "【backgroundColor】 : 影深 【背景色】\n" -// "【centerTitle】 : 中间是否居中 【bool】", -// } - -class CustomAppBar extends StatelessWidget { - @override - Widget build(BuildContext context) { - return AppBar( - title: Text('风雅六社'), - leading: BackButton(), - backgroundColor: Colors.amber[500], - elevation: 2, - centerTitle: true, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(20), - bottomRight: Radius.circular(20), - topRight: Radius.circular(5), - bottomLeft: Radius.circular(5), - )), - actions: [ - IconButton( - icon: Icon(Icons.star), - tooltip: 'like', - onPressed: () { - // do nothing - }), - CustomPopupMenuButton() - ], - ); - } -} - +import '../PopupMenuButton.dart'; +/// create by 张风捷特烈 on 2020-03-23 +/// contact me by email 1981462002@qq.com +/// 详情: // { // "widgetId": 57, // "name": 'AppBar与TabBar、TabBarView联用', diff --git a/lib/views/widgets/StatefulWidget/BottomAppBar.dart b/lib/views/widgets/StatefulWidget/BottomAppBar/node1_base.dart similarity index 97% rename from lib/views/widgets/StatefulWidget/BottomAppBar.dart rename to lib/views/widgets/StatefulWidget/BottomAppBar/node1_base.dart index d34a3d8..d3b439c 100755 --- a/lib/views/widgets/StatefulWidget/BottomAppBar.dart +++ b/lib/views/widgets/StatefulWidget/BottomAppBar/node1_base.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:flutter_unit/app/utils/pather.dart'; import 'package:flutter_unit/views/dialogs/dialog_about.dart'; +/// create by 张风捷特烈 on 2020-03-23 +/// contact me by email 1981462002@qq.com +/// 详情: // { // "widgetId": 61, // "name": 'BottomAppBar基本用法', diff --git a/lib/views/widgets/StatefulWidget/BottomNavigationBar.dart b/lib/views/widgets/StatefulWidget/BottomNavigationBar/node1_base.dart similarity index 55% rename from lib/views/widgets/StatefulWidget/BottomNavigationBar.dart rename to lib/views/widgets/StatefulWidget/BottomNavigationBar/node1_base.dart index cd84852..aa9822e 100755 --- a/lib/views/widgets/StatefulWidget/BottomNavigationBar.dart +++ b/lib/views/widgets/StatefulWidget/BottomNavigationBar/node1_base.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:flutter_unit/app/res/cons.dart'; - +/// create by 张风捷特烈 on 2020-03-23 +/// contact me by email 1981462002@qq.com +/// 详情: // { // "widgetId": 60, // "name": 'BottomNavigationBar基本使用', @@ -97,101 +98,3 @@ class _CustomBottomNavigationBarState extends State { ); } } - -// { -// "widgetId": 60, -// "name": '可结合PageView进行切页', -// "priority": 2, -// "subtitle": -// "在onTap时进行使用控制器进行切页", -// } -class BottomNavigationBarWithPageView extends StatefulWidget { - @override - _BottomNavigationBarWithPageViewState createState() => - _BottomNavigationBarWithPageViewState(); -} - -class _BottomNavigationBarWithPageViewState - extends State { - var _position = 0; - final iconsMap = { - //底栏图标 - "图鉴": Icons.home, "动态": Icons.toys, - "喜欢": Icons.favorite, "手册": Icons.class_, - "我的": Icons.account_circle, - }; - final _colors = [ - Colors.red, - Colors.yellow, - Colors.blue, - Colors.green, - Colors.purple, - ]; - PageController _controller; //页面控制器,初始0 - - @override - void initState() { - _controller = PageController( - initialPage: _position, - ); - super.initState(); - } - - @override - void dispose() { - _controller.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - Container( - color: Colors.orange.withAlpha(88), - width: MediaQuery.of(context).size.width, - height: 150, - child: PageView( - controller: _controller, - children: iconsMap.keys - .map((e) => Center( - child: Text( - e, - style: TextStyle(color: Colors.white, fontSize: 20), - ), - )) - .toList(), - ), - ), - _buildBottomNavigationBar() - ], - ), - ); - } - - BottomNavigationBar _buildBottomNavigationBar() { - return BottomNavigationBar( - onTap: (position) { - _controller.jumpToPage(position); - setState(() => _position = position); - }, - currentIndex: _position, - elevation: 1, - type: BottomNavigationBarType.shifting, - fixedColor: Colors.white, - iconSize: 25, - selectedLabelStyle: TextStyle(fontWeight: FontWeight.bold), - showUnselectedLabels: false, - showSelectedLabels: true, - items: iconsMap.keys - .map((key) => BottomNavigationBarItem( - title: Text( - key, - ), - icon: Icon(iconsMap[key]), - backgroundColor: _colors[_position])) - .toList(), - ); - } -} diff --git a/lib/views/widgets/StatefulWidget/BottomNavigationBar/node2_page.dart b/lib/views/widgets/StatefulWidget/BottomNavigationBar/node2_page.dart new file mode 100755 index 0000000..72c3f37 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/BottomNavigationBar/node2_page.dart @@ -0,0 +1,101 @@ +import 'package:flutter/material.dart'; +/// create by 张风捷特烈 on 2020-03-23 +/// contact me by email 1981462002@qq.com +/// 详情: +// { +// "widgetId": 60, +// "name": '可结合PageView进行切页', +// "priority": 2, +// "subtitle": +// "在onTap时进行使用控制器进行切页", +// } +class BottomNavigationBarWithPageView extends StatefulWidget { + @override + _BottomNavigationBarWithPageViewState createState() => + _BottomNavigationBarWithPageViewState(); +} + +class _BottomNavigationBarWithPageViewState + extends State { + var _position = 0; + final iconsMap = { + //底栏图标 + "图鉴": Icons.home, "动态": Icons.toys, + "喜欢": Icons.favorite, "手册": Icons.class_, + "我的": Icons.account_circle, + }; + final _colors = [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green, + Colors.purple, + ]; + PageController _controller; //页面控制器,初始0 + + @override + void initState() { + _controller = PageController( + initialPage: _position, + ); + super.initState(); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Container( + child: Column( + children: [ + Container( + color: Colors.orange.withAlpha(88), + width: MediaQuery.of(context).size.width, + height: 150, + child: PageView( + controller: _controller, + children: iconsMap.keys + .map((e) => Center( + child: Text( + e, + style: TextStyle(color: Colors.white, fontSize: 20), + ), + )) + .toList(), + ), + ), + _buildBottomNavigationBar() + ], + ), + ); + } + + BottomNavigationBar _buildBottomNavigationBar() { + return BottomNavigationBar( + onTap: (position) { + _controller.jumpToPage(position); + setState(() => _position = position); + }, + currentIndex: _position, + elevation: 1, + type: BottomNavigationBarType.shifting, + fixedColor: Colors.white, + iconSize: 25, + selectedLabelStyle: TextStyle(fontWeight: FontWeight.bold), + showUnselectedLabels: false, + showSelectedLabels: true, + items: iconsMap.keys + .map((key) => BottomNavigationBarItem( + title: Text( + key, + ), + icon: Icon(iconsMap[key]), + backgroundColor: _colors[_position])) + .toList(), + ); + } +} diff --git a/lib/views/widgets/StatefulWidget/Checkbox.dart b/lib/views/widgets/StatefulWidget/Checkbox/node1_base.dart similarity index 52% rename from lib/views/widgets/StatefulWidget/Checkbox.dart rename to lib/views/widgets/StatefulWidget/Checkbox/node1_base.dart index e3517b5..a6af6ab 100644 --- a/lib/views/widgets/StatefulWidget/Checkbox.dart +++ b/lib/views/widgets/StatefulWidget/Checkbox/node1_base.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; - +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: // { // "widgetId": 39, // "name": 'Checkbox基础用法', @@ -39,39 +41,3 @@ class _CustomCheckboxState extends State { } -/// { -// "widgetId": 39, -// "name": 'Checkbox的三态', -// "priority": 2, -// "subtitle": -// "【tristate】 : 是否是三态 【double】\n" -// " onChanged时,回调true、null、false三种状态" -// } -class TristateCheckBok extends StatefulWidget { - @override - _TristateCheckBokState createState() => _TristateCheckBokState(); -} - -class _TristateCheckBokState extends State { - bool _checked = false; - final colors = [Colors.red, Colors.yellow, Colors.blue, Colors.green]; - @override - Widget build(BuildContext context) { - return Wrap( - spacing: 10, - children: colors - .map((e) => - Checkbox( - value: _checked, - tristate: true, - checkColor: Colors.white, - activeColor: e, - onChanged: (v) { - print(v); - setState(() => _checked = v); - })) - .toList(), - ); - } -} - diff --git a/lib/views/widgets/StatefulWidget/Checkbox/node2_tristate.dart b/lib/views/widgets/StatefulWidget/Checkbox/node2_tristate.dart new file mode 100644 index 0000000..81e6a21 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/Checkbox/node2_tristate.dart @@ -0,0 +1,44 @@ + +import 'package:flutter/material.dart'; +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: +/// { +// "widgetId": 39, +// "name": 'Checkbox的三态', +// "priority": 2, +// "subtitle": +// "【tristate】 : 是否是三态 【double】\n" +// " onChanged时,回调true、null、false三种状态" +// } +class TristateCheckBok extends StatefulWidget { + @override + _TristateCheckBokState createState() => _TristateCheckBokState(); +} + +class _TristateCheckBokState extends State { + bool _checked = false; + final colors = [Colors.red, Colors.yellow, Colors.blue, Colors.green]; + @override + Widget build(BuildContext context) { + return Wrap( + spacing: 10, + children: colors + .map((e) => + Checkbox( + value: _checked, + tristate: true, + checkColor: Colors.white, + activeColor: e, + onChanged: (v) { + print(v); + setState(() => _checked = v); + })) + .toList(), + ); + } +} + diff --git a/lib/views/widgets/StatefulWidget/CircularProgressIndicator.dart b/lib/views/widgets/StatefulWidget/CircularProgressIndicator/node1_base.dart similarity index 92% rename from lib/views/widgets/StatefulWidget/CircularProgressIndicator.dart rename to lib/views/widgets/StatefulWidget/CircularProgressIndicator/node1_base.dart index 8d41385..03b4b49 100644 --- a/lib/views/widgets/StatefulWidget/CircularProgressIndicator.dart +++ b/lib/views/widgets/StatefulWidget/CircularProgressIndicator/node1_base.dart @@ -1,4 +1,7 @@ import 'package:flutter/material.dart'; +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: // { // "widgetId": 46, // "name": 'CircularProgressIndicator基本使用', diff --git a/lib/views/widgets/StatefulWidget/CupertinoActivityIndicator.dart b/lib/views/widgets/StatefulWidget/CupertinoActivityIndicator/node1_base.dart similarity index 88% rename from lib/views/widgets/StatefulWidget/CupertinoActivityIndicator.dart rename to lib/views/widgets/StatefulWidget/CupertinoActivityIndicator/node1_base.dart index 97d576b..0eb3e3a 100644 --- a/lib/views/widgets/StatefulWidget/CupertinoActivityIndicator.dart +++ b/lib/views/widgets/StatefulWidget/CupertinoActivityIndicator/node1_base.dart @@ -1,5 +1,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: // { // "widgetId": 48, // "name": 'CupertinoActivityIndicator基本使用', diff --git a/lib/views/widgets/StatefulWidget/CupertinoApp.dart b/lib/views/widgets/StatefulWidget/CupertinoApp/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/CupertinoApp.dart rename to lib/views/widgets/StatefulWidget/CupertinoApp/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/CupertinoNavigationBar.dart b/lib/views/widgets/StatefulWidget/CupertinoNavigationBar/node1_base.dart similarity index 92% rename from lib/views/widgets/StatefulWidget/CupertinoNavigationBar.dart rename to lib/views/widgets/StatefulWidget/CupertinoNavigationBar/node1_base.dart index d1e287e..786aa02 100755 --- a/lib/views/widgets/StatefulWidget/CupertinoNavigationBar.dart +++ b/lib/views/widgets/StatefulWidget/CupertinoNavigationBar/node1_base.dart @@ -1,6 +1,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - +/// create by 张风捷特烈 on 2020-03-26 +/// contact me by email 1981462002@qq.com +/// 说明: // { // "widgetId": 62, // "name": 'CupertinoNavigationBar基本用法', diff --git a/lib/views/widgets/StatefulWidget/CupertinoPageScaffold.dart b/lib/views/widgets/StatefulWidget/CupertinoPageScaffold/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/CupertinoPageScaffold.dart rename to lib/views/widgets/StatefulWidget/CupertinoPageScaffold/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/CupertinoScrollbar.dart b/lib/views/widgets/StatefulWidget/CupertinoScrollbar/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/CupertinoScrollbar.dart rename to lib/views/widgets/StatefulWidget/CupertinoScrollbar/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/CupertinoSlider.dart b/lib/views/widgets/StatefulWidget/CupertinoSlider/node1_base.dart similarity index 94% rename from lib/views/widgets/StatefulWidget/CupertinoSlider.dart rename to lib/views/widgets/StatefulWidget/CupertinoSlider/node1_base.dart index 44f2a83..2d6f0f6 100644 --- a/lib/views/widgets/StatefulWidget/CupertinoSlider.dart +++ b/lib/views/widgets/StatefulWidget/CupertinoSlider/node1_base.dart @@ -1,5 +1,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +/// create by 张风捷特烈 on 2020-03-31 +/// contact me by email 1981462002@qq.com +/// 说明: // { // "widgetId": 43, // "name": 'CupertinoSlider基本使用', diff --git a/lib/views/widgets/StatefulWidget/CupertinoSwitch.dart b/lib/views/widgets/StatefulWidget/CupertinoSwitch/node1_base.dart similarity index 91% rename from lib/views/widgets/StatefulWidget/CupertinoSwitch.dart rename to lib/views/widgets/StatefulWidget/CupertinoSwitch/node1_base.dart index c560b1a..ec5d4d9 100644 --- a/lib/views/widgets/StatefulWidget/CupertinoSwitch.dart +++ b/lib/views/widgets/StatefulWidget/CupertinoSwitch/node1_base.dart @@ -1,6 +1,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - +/// create by 张风捷特烈 on 2020-03-31 +/// contact me by email 1981462002@qq.com +/// 说明: /// { // "widgetId": 41, // "name": 'CupertinoSwitch基本使用', diff --git a/lib/views/widgets/StatefulWidget/CupertinoTabBar.dart b/lib/views/widgets/StatefulWidget/CupertinoTabBar/node1_base.dart similarity index 95% rename from lib/views/widgets/StatefulWidget/CupertinoTabBar.dart rename to lib/views/widgets/StatefulWidget/CupertinoTabBar/node1_base.dart index dcb75b4..a3c6aeb 100755 --- a/lib/views/widgets/StatefulWidget/CupertinoTabBar.dart +++ b/lib/views/widgets/StatefulWidget/CupertinoTabBar/node1_base.dart @@ -1,6 +1,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - +/// create by 张风捷特烈 on 2020-03-31 +/// contact me by email 1981462002@qq.com +/// 说明: // { // "widgetId": 63, // "name": 'CupertinoNavigationBar基本用法', diff --git a/lib/views/widgets/StatefulWidget/CupertinoTabScaffold.dart b/lib/views/widgets/StatefulWidget/CupertinoTabScaffold/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/CupertinoTabScaffold.dart rename to lib/views/widgets/StatefulWidget/CupertinoTabScaffold/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/CupertinoTimerPicker/node_base.dart b/lib/views/widgets/StatefulWidget/CupertinoTimerPicker/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/CupertinoTimerPicker/node_base.dart rename to lib/views/widgets/StatefulWidget/CupertinoTimerPicker/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/DecoratedBoxTransition.dart b/lib/views/widgets/StatefulWidget/DecoratedBoxTransition/node1_base.dart similarity index 96% rename from lib/views/widgets/StatefulWidget/DecoratedBoxTransition.dart rename to lib/views/widgets/StatefulWidget/DecoratedBoxTransition/node1_base.dart index c3bdae5..e0381e1 100644 --- a/lib/views/widgets/StatefulWidget/DecoratedBoxTransition.dart +++ b/lib/views/widgets/StatefulWidget/DecoratedBoxTransition/node1_base.dart @@ -1,6 +1,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - +/// create by 张风捷特烈 on 2020-03-25 +/// contact me by email 1981462002@qq.com +/// 说明: // { // "widgetId": 113, // "name": 'DecoratedBoxTransition基本使用', diff --git a/lib/views/widgets/StatefulWidget/DefaultTextStyleTransition.dart b/lib/views/widgets/StatefulWidget/DefaultTextStyleTransition/node1_base.dart similarity index 95% rename from lib/views/widgets/StatefulWidget/DefaultTextStyleTransition.dart rename to lib/views/widgets/StatefulWidget/DefaultTextStyleTransition/node1_base.dart index 7c22675..dee90ed 100644 --- a/lib/views/widgets/StatefulWidget/DefaultTextStyleTransition.dart +++ b/lib/views/widgets/StatefulWidget/DefaultTextStyleTransition/node1_base.dart @@ -1,6 +1,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - +/// create by 张风捷特烈 on 2020-03-25 +/// contact me by email 1981462002@qq.com +/// 说明: // { // "widgetId": 113, // "name": 'DefaultTextStyleTransition基本使用', diff --git a/lib/views/widgets/StatefulWidget/Dismissible.dart b/lib/views/widgets/StatefulWidget/Dismissible/node1_base.dart similarity index 52% rename from lib/views/widgets/StatefulWidget/Dismissible.dart rename to lib/views/widgets/StatefulWidget/Dismissible/node1_base.dart index 7546768..dda065e 100644 --- a/lib/views/widgets/StatefulWidget/Dismissible.dart +++ b/lib/views/widgets/StatefulWidget/Dismissible/node1_base.dart @@ -90,94 +90,6 @@ class _CustomDismissibleState extends State { ); } - String colorString(Color color) => - "#${color.value.toRadixString(16).padLeft(8, '0').toUpperCase()}"; -} -// { -// "widgetId": 176, -// "name": 'Dismissible基本使用', -// "priority": 2, -// "subtitle": -// "【direction】 : 方向 【DismissDirection】\n" -// "【crossAxisEndOffset】 : 偏移 【double】\n", -// } -class DirectionDismissible extends StatefulWidget { - @override - _CustomDirectionDismissibleState createState() => _CustomDirectionDismissibleState(); -} - -class _CustomDirectionDismissibleState extends State { - var data = [ - Colors.purple[50], - Colors.purple[100], - Colors.purple[200], - Colors.purple[300], - Colors.purple[400], - Colors.purple[500], - Colors.purple[600], - Colors.purple[700], - Colors.purple[800], - Colors.purple[900], - ]; - - @override - Widget build(BuildContext context) { - return Container( - height: 200, - child: ListView( - scrollDirection: Axis.horizontal, - padding: EdgeInsets.symmetric(horizontal: 5), - children: data.map((color) => _buildItem(color)).toList(), - ), - ); - } - - Widget _buildItem(Color color) { - return Dismissible( - direction: DismissDirection.vertical, - background: Container( - color: Colors.green, - alignment: Alignment( 0,-0.9,), - child: Icon( - Icons.check, - color: Colors.white, - ), - ), - crossAxisEndOffset: 0.5, - secondaryBackground: Container( - alignment: Alignment( 0,0.9,), - child: Icon( - Icons.close, - color: Colors.white, - ), - color: Colors.red, - ), - key: ValueKey(color), - onDismissed: (d) { - data.remove(color); - }, - confirmDismiss: (e) async { - print(e); - if (e == DismissDirection.up) { - return true; - } else { - return false; - } - }, - child: Container( - alignment: Alignment.center, - width: 80, - color: color, - child: Text( - colorString(color), - style: TextStyle(color: Colors.white, shadows: [ - Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) - ]), - ), - ), - ); - } - String colorString(Color color) => "#${color.value.toRadixString(16).padLeft(8, '0').toUpperCase()}"; } \ No newline at end of file diff --git a/lib/views/widgets/StatefulWidget/Dismissible/node2_direction.dart b/lib/views/widgets/StatefulWidget/Dismissible/node2_direction.dart new file mode 100644 index 0000000..87f2d93 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/Dismissible/node2_direction.dart @@ -0,0 +1,96 @@ + +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: + + +// { +// "widgetId": 176, +// "name": 'Dismissible基本使用', +// "priority": 2, +// "subtitle": +// "【direction】 : 方向 【DismissDirection】\n" +// "【crossAxisEndOffset】 : 偏移 【double】\n", +// } +class DirectionDismissible extends StatefulWidget { + @override + _CustomDirectionDismissibleState createState() => _CustomDirectionDismissibleState(); +} + +class _CustomDirectionDismissibleState extends State { + var data = [ + Colors.purple[50], + Colors.purple[100], + Colors.purple[200], + Colors.purple[300], + Colors.purple[400], + Colors.purple[500], + Colors.purple[600], + Colors.purple[700], + Colors.purple[800], + Colors.purple[900], + ]; + + @override + Widget build(BuildContext context) { + return Container( + height: 200, + child: ListView( + scrollDirection: Axis.horizontal, + padding: EdgeInsets.symmetric(horizontal: 5), + children: data.map((color) => _buildItem(color)).toList(), + ), + ); + } + + Widget _buildItem(Color color) { + return Dismissible( + direction: DismissDirection.vertical, + background: Container( + color: Colors.green, + alignment: Alignment( 0,-0.9,), + child: Icon( + Icons.check, + color: Colors.white, + ), + ), + crossAxisEndOffset: 0.5, + secondaryBackground: Container( + alignment: Alignment( 0,0.9,), + child: Icon( + Icons.close, + color: Colors.white, + ), + color: Colors.red, + ), + key: ValueKey(color), + onDismissed: (d) { + data.remove(color); + }, + confirmDismiss: (e) async { + print(e); + if (e == DismissDirection.up) { + return true; + } else { + return false; + } + }, + child: Container( + alignment: Alignment.center, + width: 80, + color: color, + child: Text( + colorString(color), + style: TextStyle(color: Colors.white, shadows: [ + Shadow(color: Colors.black, offset: Offset(.5, .5), blurRadius: 2) + ]), + ), + ), + ); + } + + String colorString(Color color) => + "#${color.value.toRadixString(16).padLeft(8, '0').toUpperCase()}"; +} \ No newline at end of file diff --git a/lib/views/widgets/StatefulWidget/DragTarget.dart b/lib/views/widgets/StatefulWidget/DragTarget/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/DragTarget.dart rename to lib/views/widgets/StatefulWidget/DragTarget/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/Draggable.dart b/lib/views/widgets/StatefulWidget/Draggable.dart deleted file mode 100644 index cf245cb..0000000 --- a/lib/views/widgets/StatefulWidget/Draggable.dart +++ /dev/null @@ -1,230 +0,0 @@ -import 'package:flutter/material.dart'; - -/// create by 张风捷特烈 on 2020-03-22 -/// contact me by email 1981462002@qq.com -/// 说明: -/// -// { -// "widgetId": 103, -// "name": 'Draggable基本使用', -// "priority": 1, -// "subtitle": -// "【child】 : 孩子 【Widget】\n" -// "【feedback】 : 拖拽时的孩子 【Widget】\n" -// "【axis】 : 拖动的轴 【Axis】", -// } -class CustomDraggable extends StatelessWidget { - @override - Widget build(BuildContext context) { - var axis = [null, Axis.vertical, Axis.horizontal]; - return Wrap( - spacing: 30, - children: axis - .map((e) => Draggable( - axis: e, - child: Container( - width: 30, - height: 30, - alignment: Alignment.center, - decoration: BoxDecoration( - color: Colors.blue, shape: BoxShape.circle), - ), - feedback: Container( - width: 30, - height: 30, - decoration: BoxDecoration( - color: Colors.red, shape: BoxShape.circle), - ), - )) - .toList()); - } -} - -// { -// "widgetId": 103, -// "name": 'Draggable与DragTarget联用', -// "priority": 2, -// "subtitle": -// "【data】 : 数据 【T】\n" -// "【onDragStarted】 : 开始拖拽 【Function()】\n" -// "【onDragEnd】 : 结束拖拽 【Function(DraggableDetails)】\n" -// "【onDragCompleted】 : 拖拽完成 【Function()】\n" -// "【onDraggableCanceled】 : 拖拽取消 【Function(Velocity,Offset)】\n" -// "【onChanged】 : 改变时回调 【Function(T)】", -// } - -class DraggablePage extends StatefulWidget { - @override - _DraggablePageState createState() => _DraggablePageState(); -} - -class _DraggablePageState extends State { - Color _color = Colors.grey; - String _info = 'DragTarget'; - - @override - Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - Wrap( - children: _buildColors(), - spacing: 10, - ), - SizedBox( - height: 20, - ), - _buildDragTarget() - ], - ), - ); - } - - List _buildColors() { - var colors = [ - Colors.red, - Colors.yellow, - Colors.blue, - Colors.green, - Colors.orange, - Colors.purple, - Colors.cyanAccent - ]; - return colors - .map( - (e) => Draggable( - onDragStarted: () => setState(() => _info = '开始拖拽'), - onDragEnd: (d) => setState(() => _info = '结束拖拽'), - onDragCompleted: () => _info = '拖拽完成', - onDraggableCanceled: (v, o) => _info = '拖拽取消', - child: Container( - width: 30, - height: 30, - alignment: Alignment.center, - child: Text( - colors.indexOf(e).toString(), - style: TextStyle( - color: Colors.white, fontWeight: FontWeight.bold), - ), - decoration: BoxDecoration(color: e, shape: BoxShape.circle), - ), - data: e, - feedback: Container( - width: 25, - height: 25, - decoration: BoxDecoration(color: e, shape: BoxShape.circle), - )), - ) - .toList(); - } - - Widget _buildDragTarget() { - return DragTarget( - onLeave: (data) => print("onLeave: data = $data "), - onAccept: (data) { - print("onAccept: data = $data "); - setState(() { - _color = data; - }); - }, - onWillAccept: (data) { - print("onWillAccept: data = $data "); - return data != null; - }, - builder: (context, candidateData, rejectedData) => Container( - width: 150.0, - height: 50.0, - color: _color, - child: Center( - child: Text( - _info, - style: TextStyle(color: Colors.white), - ), - ))); - } -} - -// { -// "widgetId": 103, -// "name": 'Draggable其他使用', -// "priority": 3, -// "subtitle": -// "可以根据拖拽来处理一些事件。如删除、查询、弹框等" -// } - -class DeleteDraggable extends StatefulWidget { - @override - _DeleteDraggableState createState() => _DeleteDraggableState(); -} - -class _DeleteDraggableState extends State { - List colors = [ - Colors.red, - Colors.yellow, - Colors.blue, - Colors.green, - Colors.orange, - Colors.purple, - Colors.cyanAccent - ]; - - @override - Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - Wrap( - children: _buildColors(), - spacing: 10, - ), - SizedBox( - height: 20, - ), - _buildDragTarget() - ], - ), - ); - } - - Widget _buildDragTarget() { - return DragTarget( - onAccept: (data) { - setState(() { - colors.removeAt(data); - }); - }, - onWillAccept: (data) => data != null, - builder: (context, candidateData, rejectedData) => Container( - width: 50.0, - height: 50.0, - decoration: - BoxDecoration(color: Colors.red, shape: BoxShape.circle), - child: Center( - child: Icon(Icons.delete_sweep, color: Colors.white), - ))); - } - - List _buildColors() => colors - .map( - (e) => Draggable( - child: Container( - width: 30, - height: 30, - alignment: Alignment.center, - child: Text( - colors.indexOf(e).toString(), - style: - TextStyle(color: Colors.white, fontWeight: FontWeight.bold), - ), - decoration: BoxDecoration(color: e, shape: BoxShape.circle), - ), - data: colors.indexOf(e), - feedback: Container( - width: 25, - height: 25, - decoration: BoxDecoration( - color: e.withAlpha(100), shape: BoxShape.circle), - )), - ) - .toList(); -} diff --git a/lib/views/widgets/StatefulWidget/Draggable/node1_base.dart b/lib/views/widgets/StatefulWidget/Draggable/node1_base.dart new file mode 100644 index 0000000..0742f79 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/Draggable/node1_base.dart @@ -0,0 +1,41 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020-03-22 +/// contact me by email 1981462002@qq.com +/// 说明: +/// +// { +// "widgetId": 103, +// "name": 'Draggable基本使用', +// "priority": 1, +// "subtitle": +// "【child】 : 孩子 【Widget】\n" +// "【feedback】 : 拖拽时的孩子 【Widget】\n" +// "【axis】 : 拖动的轴 【Axis】", +// } +class CustomDraggable extends StatelessWidget { + @override + Widget build(BuildContext context) { + var axis = [null, Axis.vertical, Axis.horizontal]; + return Wrap( + spacing: 30, + children: axis + .map((e) => Draggable( + axis: e, + child: Container( + width: 30, + height: 30, + alignment: Alignment.center, + decoration: BoxDecoration( + color: Colors.blue, shape: BoxShape.circle), + ), + feedback: Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: Colors.red, shape: BoxShape.circle), + ), + )) + .toList()); + } +} \ No newline at end of file diff --git a/lib/views/widgets/StatefulWidget/Draggable/node2_data.dart b/lib/views/widgets/StatefulWidget/Draggable/node2_data.dart new file mode 100644 index 0000000..c9400cd --- /dev/null +++ b/lib/views/widgets/StatefulWidget/Draggable/node2_data.dart @@ -0,0 +1,108 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020-03-22 +/// contact me by email 1981462002@qq.com +/// 说明: +// { +// "widgetId": 103, +// "name": 'Draggable与DragTarget联用', +// "priority": 2, +// "subtitle": +// "【data】 : 数据 【T】\n" +// "【onDragStarted】 : 开始拖拽 【Function()】\n" +// "【onDragEnd】 : 结束拖拽 【Function(DraggableDetails)】\n" +// "【onDragCompleted】 : 拖拽完成 【Function()】\n" +// "【onDraggableCanceled】 : 拖拽取消 【Function(Velocity,Offset)】\n" +// "【onChanged】 : 改变时回调 【Function(T)】", +// } + +class DraggablePage extends StatefulWidget { + @override + _DraggablePageState createState() => _DraggablePageState(); +} + +class _DraggablePageState extends State { + Color _color = Colors.grey; + String _info = 'DragTarget'; + + @override + Widget build(BuildContext context) { + return Container( + child: Column( + children: [ + Wrap( + children: _buildColors(), + spacing: 10, + ), + SizedBox( + height: 20, + ), + _buildDragTarget() + ], + ), + ); + } + + List _buildColors() { + var colors = [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green, + Colors.orange, + Colors.purple, + Colors.cyanAccent + ]; + return colors + .map( + (e) => Draggable( + onDragStarted: () => setState(() => _info = '开始拖拽'), + onDragEnd: (d) => setState(() => _info = '结束拖拽'), + onDragCompleted: () => _info = '拖拽完成', + onDraggableCanceled: (v, o) => _info = '拖拽取消', + child: Container( + width: 30, + height: 30, + alignment: Alignment.center, + child: Text( + colors.indexOf(e).toString(), + style: TextStyle( + color: Colors.white, fontWeight: FontWeight.bold), + ), + decoration: BoxDecoration(color: e, shape: BoxShape.circle), + ), + data: e, + feedback: Container( + width: 25, + height: 25, + decoration: BoxDecoration(color: e, shape: BoxShape.circle), + )), + ) + .toList(); + } + + Widget _buildDragTarget() { + return DragTarget( + onLeave: (data) => print("onLeave: data = $data "), + onAccept: (data) { + print("onAccept: data = $data "); + setState(() { + _color = data; + }); + }, + onWillAccept: (data) { + print("onWillAccept: data = $data "); + return data != null; + }, + builder: (context, candidateData, rejectedData) => Container( + width: 150.0, + height: 50.0, + color: _color, + child: Center( + child: Text( + _info, + style: TextStyle(color: Colors.white), + ), + ))); + } +} diff --git a/lib/views/widgets/StatefulWidget/Draggable/node3_use.dart b/lib/views/widgets/StatefulWidget/Draggable/node3_use.dart new file mode 100644 index 0000000..9fbc041 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/Draggable/node3_use.dart @@ -0,0 +1,90 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020/4/28 +/// contact me by email 1981462002@qq.com +/// 说明: + +// { +// "widgetId": 103, +// "name": 'Draggable其他使用', +// "priority": 3, +// "subtitle": +// "可以根据拖拽来处理一些事件。如删除、查询、弹框等" +// } + +class DeleteDraggable extends StatefulWidget { + @override + _DeleteDraggableState createState() => _DeleteDraggableState(); +} + +class _DeleteDraggableState extends State { + List colors = [ + Colors.red, + Colors.yellow, + Colors.blue, + Colors.green, + Colors.orange, + Colors.purple, + Colors.cyanAccent + ]; + + @override + Widget build(BuildContext context) { + return Container( + child: Column( + children: [ + Wrap( + children: _buildColors(), + spacing: 10, + ), + SizedBox( + height: 20, + ), + _buildDragTarget() + ], + ), + ); + } + + Widget _buildDragTarget() { + return DragTarget( + onAccept: (data) { + setState(() { + colors.removeAt(data); + }); + }, + onWillAccept: (data) => data != null, + builder: (context, candidateData, rejectedData) => Container( + width: 50.0, + height: 50.0, + decoration: + BoxDecoration(color: Colors.red, shape: BoxShape.circle), + child: Center( + child: Icon(Icons.delete_sweep, color: Colors.white), + ))); + } + + List _buildColors() => colors + .map( + (e) => Draggable( + child: Container( + width: 30, + height: 30, + alignment: Alignment.center, + child: Text( + colors.indexOf(e).toString(), + style: + TextStyle(color: Colors.white, fontWeight: FontWeight.bold), + ), + decoration: BoxDecoration(color: e, shape: BoxShape.circle), + ), + data: colors.indexOf(e), + feedback: Container( + width: 25, + height: 25, + decoration: BoxDecoration( + color: e.withAlpha(100), shape: BoxShape.circle), + )), + ) + .toList(); +} diff --git a/lib/views/widgets/StatefulWidget/DropdownButton.dart b/lib/views/widgets/StatefulWidget/DropdownButton/node1_base.dart similarity index 52% rename from lib/views/widgets/StatefulWidget/DropdownButton.dart rename to lib/views/widgets/StatefulWidget/DropdownButton/node1_base.dart index f15c054..560b853 100644 --- a/lib/views/widgets/StatefulWidget/DropdownButton.dart +++ b/lib/views/widgets/StatefulWidget/DropdownButton/node1_base.dart @@ -58,57 +58,4 @@ class _CustomDropDownButtonState extends State { style: TextStyle(color: e), ))) .toList(); -} - -// { -// "widgetId": 55, -// "name": 'DropdownButton基本语法', -// "priority": 2, -// "subtitle": -// "【isDense】 : 是否紧排 【bool】\n" -// "【iconSize】 : 图标大小 【double】\n" -// "【hint】 : 提示组件 【Widget】\n" -// "【iconEnabledColor】 : 图标颜色 【Color】", -// } -class StyleDropDownButton extends StatefulWidget { - @override - _StyleDropDownButtonState createState() => _StyleDropDownButtonState(); -} - -class _StyleDropDownButtonState extends State { - Color _color = Colors.red ; - final _colors = [Colors.red, Colors.yellow, Colors.blue, Colors.green]; - final _info = ["红色", "黄色", "蓝色", "绿色"]; - - @override - Widget build(BuildContext context) { - return Wrap( - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - Container( - margin: EdgeInsets.symmetric(horizontal: 20), - width: 50, - height: 50, - color: _color??Colors.transparent, - ), - DropdownButton( - hint: Text('请选择'), - isDense: true, - iconSize:20, - iconEnabledColor:_color??Colors.orange, - value: _color, - items: _buildItems(), - onChanged: (v) => setState(() => _color = v)), - ], - ); - } - - List> _buildItems() => _colors - .map((e) => DropdownMenuItem( - value: e, - child: Text( - _info[_colors.indexOf(e)], - style: TextStyle(color: e), - ))) - .toList(); -} +} \ No newline at end of file diff --git a/lib/views/widgets/StatefulWidget/DropdownButton/node2_style.dart b/lib/views/widgets/StatefulWidget/DropdownButton/node2_style.dart new file mode 100644 index 0000000..1689416 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/DropdownButton/node2_style.dart @@ -0,0 +1,58 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020-03-16 +/// contact me by email 1981462002@qq.com +/// 说明: +// { +// "widgetId": 55, +// "name": 'DropdownButton的样式指定', +// "priority": 2, +// "subtitle": +// "【isDense】 : 是否紧排 【bool】\n" +// "【iconSize】 : 图标大小 【double】\n" +// "【hint】 : 提示组件 【Widget】\n" +// "【iconEnabledColor】 : 图标颜色 【Color】", +// } + +class StyleDropDownButton extends StatefulWidget { + @override + _StyleDropDownButtonState createState() => _StyleDropDownButtonState(); +} + +class _StyleDropDownButtonState extends State { + Color _color = Colors.red ; + final _colors = [Colors.red, Colors.yellow, Colors.blue, Colors.green]; + final _info = ["红色", "黄色", "蓝色", "绿色"]; + + @override + Widget build(BuildContext context) { + return Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + Container( + margin: EdgeInsets.symmetric(horizontal: 20), + width: 50, + height: 50, + color: _color??Colors.transparent, + ), + DropdownButton( + hint: Text('请选择'), + isDense: true, + iconSize:20, + iconEnabledColor:_color??Colors.orange, + value: _color, + items: _buildItems(), + onChanged: (v) => setState(() => _color = v)), + ], + ); + } + + List> _buildItems() => _colors + .map((e) => DropdownMenuItem( + value: e, + child: Text( + _info[_colors.indexOf(e)], + style: TextStyle(color: e), + ))) + .toList(); +} diff --git a/lib/views/widgets/StatefulWidget/ExpandIcon.dart b/lib/views/widgets/StatefulWidget/ExpandIcon/node1_base.dart similarity index 91% rename from lib/views/widgets/StatefulWidget/ExpandIcon.dart rename to lib/views/widgets/StatefulWidget/ExpandIcon/node1_base.dart index e9ddaff..a3fcb5b 100644 --- a/lib/views/widgets/StatefulWidget/ExpandIcon.dart +++ b/lib/views/widgets/StatefulWidget/ExpandIcon/node1_base.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; - +/// create by 张风捷特烈 on 2020-03-16 +/// contact me by email 1981462002@qq.com +/// 说明: // { // "widgetId": 51, // "name": 'ExpandIcon基本使用', diff --git a/lib/views/widgets/StatefulWidget/ExpansionPanelList.dart b/lib/views/widgets/StatefulWidget/ExpansionPanelList/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/ExpansionPanelList.dart rename to lib/views/widgets/StatefulWidget/ExpansionPanelList/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/ExpansionTile.dart b/lib/views/widgets/StatefulWidget/ExpansionTile/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/ExpansionTile.dart rename to lib/views/widgets/StatefulWidget/ExpansionTile/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/Form.dart b/lib/views/widgets/StatefulWidget/Form/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/Form.dart rename to lib/views/widgets/StatefulWidget/Form/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/FutureBuilder.dart b/lib/views/widgets/StatefulWidget/FutureBuilder/node1_base.dart similarity index 100% rename from lib/views/widgets/StatefulWidget/FutureBuilder.dart rename to lib/views/widgets/StatefulWidget/FutureBuilder/node1_base.dart diff --git a/lib/views/widgets/StatefulWidget/Hero.dart b/lib/views/widgets/StatefulWidget/Hero/node1_base.dart similarity index 92% rename from lib/views/widgets/StatefulWidget/Hero.dart rename to lib/views/widgets/StatefulWidget/Hero/node1_base.dart index 8eb0364..1849a4e 100644 --- a/lib/views/widgets/StatefulWidget/Hero.dart +++ b/lib/views/widgets/StatefulWidget/Hero/node1_base.dart @@ -47,7 +47,7 @@ class CustomHero extends StatelessWidget { child: Card(elevation: 5, child: container), onTap: () => Navigator.push( context, - Bottom2TopRouter(child: TargetPage(), duration_ms: 1000), + Bottom2TopRouter(child: TargetPage(), duration: 1000), ), ); } @@ -98,13 +98,13 @@ class TargetPage extends StatelessWidget { //下--->上 class Bottom2TopRouter extends PageRouteBuilder { final Widget child; - final int duration_ms; + final int duration; final Curve curve; Bottom2TopRouter( - {this.child, this.duration_ms = 500, this.curve = Curves.fastOutSlowIn}) + {this.child, this.duration = 500, this.curve = Curves.fastOutSlowIn}) : super( - transitionDuration: Duration(milliseconds: duration_ms), + transitionDuration: Duration(milliseconds: duration), pageBuilder: (ctx, a1, a2) { return child; }, diff --git a/lib/views/widgets/StatefulWidget/Image.dart b/lib/views/widgets/StatefulWidget/Image.dart deleted file mode 100644 index cd08c70..0000000 --- a/lib/views/widgets/StatefulWidget/Image.dart +++ /dev/null @@ -1,231 +0,0 @@ -import 'dart:io'; - -import 'package:flutter/material.dart'; - -// { -// "widgetId": 38, -// "name": '可从资源文件和网络加载图片', -// "priority": 1, -// "subtitle": -// "Image.asset加载资源图片,指定路径;\n" -// "Image.network加载资源网络图片,指定链接。\n" -// "Image.file加载资源文件图片,指定路径。\n" -// "Image.memory加载内存图片,指定字节数组。\n" -// "【height】 : 宽 【double】\n" -// "【width】: 高 【double】" -// } - -class LoadImage extends StatelessWidget { - final assetsImagePath = "assets/images/icon_head.png"; - final assetsGif = "assets/images/pica.gif"; - final netImageUrl = "https://user-gold-cdn.xitu.io" - "/2019/7/24/16c225e78234ec26?" - "imageView2/1/w/1304/h/734/q/85/format/webp/interlace/1"; - - @override - Widget build(BuildContext context) { - return Wrap( - spacing: 10, - children: [ - _loadFromAssets(), - _loadFromNet(), - ], - ); - } - - Widget _loadFromAssets() => Wrap( - spacing: 10, - children: [ - Image.asset(assetsImagePath, height: 80, width: 80), - Image.asset(assetsGif, height: 80, width: 80), - ], - ); - - Widget _loadFromNet() => Image.network(netImageUrl, height: 80); -} - -// { -// "widgetId": 38, -// "name": '图片的适应模式', -// "priority": 2, -// "subtitle": -// "【fit】 : 适应模式*7 【BoxFit】\n" -// }, - -class FitImage extends StatefulWidget { - @override - _FitImageState createState() => _FitImageState(); -} - -class _FitImageState extends State { - bool _smallImage = false; - - @override - Widget build(BuildContext context) { - var imageLi = BoxFit.values - .toList() - .map((mode) => Column(children: [ - Container( - margin: EdgeInsets.all(5), - width: 100, - height: 80, - color: Colors.grey.withAlpha(88), - child: Image( - image: AssetImage(!_smallImage - ? "assets/images/wy_300x200.jpg" - : "assets/images/wy_30x20.jpg"), - fit: mode)), - Text(mode.toString().split(".")[1]) - ])) - .toList(); - - return Wrap( - children: [...imageLi, _buildSwitch()], - ); - } - - Widget _buildSwitch() { - return Container( - alignment: Alignment.center, - width: 200, - height: 100, - child: Wrap( - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - Text("使用小图"), - Switch( - value: _smallImage, - onChanged: (b) => setState(() => _smallImage = b)), - ], - ), - ); - } -} - -// { -// "widgetId": 38, -// "name": '图片对齐模式', -// "priority": 3, -// "subtitle": -// "【alignment】 : 颜色 【AlignmentGeometry】\n" -// " 常用Alignment类的九个静态常量,但也可定制位置" -// }, - -class AlignmentImage extends StatelessWidget { - @override - Widget build(BuildContext context) { - var alignment = [ - Alignment.center, - Alignment.centerLeft, - Alignment.centerRight, - Alignment.topCenter, - Alignment.topLeft, - Alignment.topRight, - Alignment.bottomCenter, - Alignment.bottomLeft, - Alignment.bottomRight - ]; //测试数组 - var imgLi = alignment - .map((alignment) => //生成子Widget列表 - Column(children: [ - Container( - margin: EdgeInsets.all(5), - width: 90, - height: 60, - color: Colors.grey.withAlpha(88), - child: Image( - image: AssetImage("assets/images/wy_30x20.jpg"), - alignment: alignment, - )), - Text(alignment.toString()) - ])) - .toList(); - var imageAlignment = Wrap(children: imgLi); - return imageAlignment; - } -} - -// { -// "widgetId": 38, -// "name": '图片颜色及混合模式', -// "priority": 4, -// "subtitle": -// "【color】 : 颜色 【Color】\n" -// "【colorBlendMode】: 混合模式*29 【BlendMode】" -// }, - -class BlendModeImage extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Wrap( - children: BlendMode.values - .toList() - .map((mode) => Column(children: [ - Container( - margin: EdgeInsets.all(5), - width: 60, - height: 60, - color: Colors.red, - child: Image( - image: AssetImage("assets/images/icon_head.png"), - color: Colors.blue.withAlpha(88), - colorBlendMode: mode)), - Text(mode.toString().split(".")[1]) - ])) - .toList(), - ); - } -} - -// { -// "widgetId": 38, -// "name": '图片重复模式', -// "priority": 5, -// "subtitle": -// "【repeat】 : 重复模式*4 【ImageRepeat】" -// }, - -class RepeatImage extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Wrap( - children: ImageRepeat.values - .toList() - .map((mode) => Column(children: [ - Container( - margin: EdgeInsets.all(5), - width: 150, - height: 60, - color: Colors.red, - child: Image( - image: AssetImage("assets/images/wy_30x20.jpg"), - repeat: mode)), - Text(mode.toString().split(".")[1]) - ])) - .toList(), - ); - } -} - -// { -// "widgetId": 38, -// "name": '图片实现局部放大', -// "priority": 6, -// "subtitle": -// "【centerSlice】 : 保留的区域 【Rect】" -// }, - -class CenterSliceImage extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Container( - width: 300, - height: 80, - child: Image.asset( - "assets/images/right_chat.png", - centerSlice: Rect.fromLTRB(9, 27, 60, 27 + 1.0), - fit: BoxFit.fill, - ), - ); - } -} diff --git a/lib/views/widgets/StatefulWidget/Image/node1_base.dart b/lib/views/widgets/StatefulWidget/Image/node1_base.dart new file mode 100644 index 0000000..248df53 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/Image/node1_base.dart @@ -0,0 +1,46 @@ + +import 'package:flutter/material.dart'; +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: +// { +// "widgetId": 38, +// "name": '可从资源文件和网络加载图片', +// "priority": 1, +// "subtitle": +// "Image.asset加载资源图片,指定路径;\n" +// "Image.network加载资源网络图片,指定链接。\n" +// "Image.file加载资源文件图片,指定路径。\n" +// "Image.memory加载内存图片,指定字节数组。\n" +// "【height】 : 宽 【double】\n" +// "【width】: 高 【double】" +// } + +class LoadImage extends StatelessWidget { + final assetsImagePath = "assets/images/icon_head.png"; + final assetsGif = "assets/images/pica.gif"; + final netImageUrl = "https://user-gold-cdn.xitu.io" + "/2019/7/24/16c225e78234ec26?" + "imageView2/1/w/1304/h/734/q/85/format/webp/interlace/1"; + + @override + Widget build(BuildContext context) { + return Wrap( + spacing: 10, + children: [ + _loadFromAssets(), + _loadFromNet(), + ], + ); + } + + Widget _loadFromAssets() => Wrap( + spacing: 10, + children: [ + Image.asset(assetsImagePath, height: 80, width: 80), + Image.asset(assetsGif, height: 80, width: 80), + ], + ); + + Widget _loadFromNet() => Image.network(netImageUrl, height: 80); +} diff --git a/lib/views/widgets/StatefulWidget/Image/node2_fit.dart b/lib/views/widgets/StatefulWidget/Image/node2_fit.dart new file mode 100644 index 0000000..31241d4 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/Image/node2_fit.dart @@ -0,0 +1,62 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: +// { +// "widgetId": 38, +// "name": '图片的适应模式', +// "priority": 2, +// "subtitle": +// "【fit】 : 适应模式*7 【BoxFit】\n" +// }, + +class FitImage extends StatefulWidget { + @override + _FitImageState createState() => _FitImageState(); +} + +class _FitImageState extends State { + bool _smallImage = false; + + @override + Widget build(BuildContext context) { + var imageLi = BoxFit.values + .toList() + .map((mode) => Column(children: [ + Container( + margin: EdgeInsets.all(5), + width: 100, + height: 80, + color: Colors.grey.withAlpha(88), + child: Image( + image: AssetImage(!_smallImage + ? "assets/images/wy_300x200.jpg" + : "assets/images/wy_30x20.jpg"), + fit: mode)), + Text(mode.toString().split(".")[1]) + ])) + .toList(); + + return Wrap( + children: [...imageLi, _buildSwitch()], + ); + } + + Widget _buildSwitch() { + return Container( + alignment: Alignment.center, + width: 200, + height: 100, + child: Wrap( + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + Text("使用小图"), + Switch( + value: _smallImage, + onChanged: (b) => setState(() => _smallImage = b)), + ], + ), + ); + } +} diff --git a/lib/views/widgets/StatefulWidget/Image/node3_alignment.dart b/lib/views/widgets/StatefulWidget/Image/node3_alignment.dart new file mode 100644 index 0000000..8511d52 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/Image/node3_alignment.dart @@ -0,0 +1,47 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: +// { +// "widgetId": 38, +// "name": '图片对齐模式', +// "priority": 3, +// "subtitle": +// "【alignment】 : 颜色 【AlignmentGeometry】\n" +// " 常用Alignment类的九个静态常量,但也可定制位置" +// }, + +class AlignmentImage extends StatelessWidget { + @override + Widget build(BuildContext context) { + var alignment = [ + Alignment.center, + Alignment.centerLeft, + Alignment.centerRight, + Alignment.topCenter, + Alignment.topLeft, + Alignment.topRight, + Alignment.bottomCenter, + Alignment.bottomLeft, + Alignment.bottomRight + ]; //测试数组 + var imgLi = alignment + .map((alignment) => //生成子Widget列表 + Column(children: [ + Container( + margin: EdgeInsets.all(5), + width: 90, + height: 60, + color: Colors.grey.withAlpha(88), + child: Image( + image: AssetImage("assets/images/wy_30x20.jpg"), + alignment: alignment, + )), + Text(alignment.toString()) + ])) + .toList(); + var imageAlignment = Wrap(children: imgLi); + return imageAlignment; + } +} \ No newline at end of file diff --git a/lib/views/widgets/StatefulWidget/Image/node4_colorBlendMode.dart b/lib/views/widgets/StatefulWidget/Image/node4_colorBlendMode.dart new file mode 100644 index 0000000..4676df3 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/Image/node4_colorBlendMode.dart @@ -0,0 +1,36 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: +// { +// "widgetId": 38, +// "name": '图片颜色及混合模式', +// "priority": 4, +// "subtitle": +// "【color】 : 颜色 【Color】\n" +// "【colorBlendMode】: 混合模式*29 【BlendMode】" +// }, + +class BlendModeImage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Wrap( + children: BlendMode.values + .toList() + .map((mode) => Column(children: [ + Container( + margin: EdgeInsets.all(5), + width: 60, + height: 60, + color: Colors.red, + child: Image( + image: AssetImage("assets/images/icon_head.png"), + color: Colors.blue.withAlpha(88), + colorBlendMode: mode)), + Text(mode.toString().split(".")[1]) + ])) + .toList(), + ); + } +} \ No newline at end of file diff --git a/lib/views/widgets/StatefulWidget/Image/node5_repeat.dart b/lib/views/widgets/StatefulWidget/Image/node5_repeat.dart new file mode 100644 index 0000000..383a26d --- /dev/null +++ b/lib/views/widgets/StatefulWidget/Image/node5_repeat.dart @@ -0,0 +1,34 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: +// { +// "widgetId": 38, +// "name": '图片重复模式', +// "priority": 5, +// "subtitle": +// "【repeat】 : 重复模式*4 【ImageRepeat】" +// }, + +class RepeatImage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Wrap( + children: ImageRepeat.values + .toList() + .map((mode) => Column(children: [ + Container( + margin: EdgeInsets.all(5), + width: 150, + height: 60, + color: Colors.red, + child: Image( + image: AssetImage("assets/images/wy_30x20.jpg"), + repeat: mode)), + Text(mode.toString().split(".")[1]) + ])) + .toList(), + ); + } +} \ No newline at end of file diff --git a/lib/views/widgets/StatefulWidget/Image/node6_centerSlice.dart b/lib/views/widgets/StatefulWidget/Image/node6_centerSlice.dart new file mode 100644 index 0000000..ee65f00 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/Image/node6_centerSlice.dart @@ -0,0 +1,30 @@ + +import 'package:flutter/material.dart'; + + + +/// create by 张风捷特烈 on 2020-03-29 +/// contact me by email 1981462002@qq.com +/// 说明: +// { +// "widgetId": 38, +// "name": '图片实现局部放大', +// "priority": 6, +// "subtitle": +// "【centerSlice】 : 保留的区域 【Rect】" +// }, + +class CenterSliceImage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + width: 300, + height: 80, + child: Image.asset( + "assets/images/right_chat.png", + centerSlice: Rect.fromLTRB(9, 27, 60, 27 + 1.0), + fit: BoxFit.fill, + ), + ); + } +} diff --git a/lib/views/widgets/stateful_unit.dart b/lib/views/widgets/stateful_unit.dart index cf3b17b..1bb46c2 100644 --- a/lib/views/widgets/stateful_unit.dart +++ b/lib/views/widgets/stateful_unit.dart @@ -6,57 +6,79 @@ export 'StatefulWidget/CupertinoContextMenuAction/node1_base.dart'; export 'StatefulWidget/CupertinoDatePicker/node1_base.dart'; export 'StatefulWidget/CupertinoPicker/node1_base.dart'; -export 'StatefulWidget/CupertinoTimerPicker/node_base.dart'; +export 'StatefulWidget/CupertinoTimerPicker/node1_base.dart'; export 'StatefulWidget/MonthPicker/node1_base.dart'; export 'StatefulWidget/YearPicker/node1_base.dart'; export 'StatefulWidget/WillPopScope/node1_base.dart'; -export 'StatefulWidget/AppBar.dart'; -export 'StatefulWidget/BottomAppBar.dart'; -export 'StatefulWidget/BottomNavigationBar.dart'; -export 'StatefulWidget/Checkbox.dart'; -export 'StatefulWidget/ExpandIcon.dart'; -export 'StatefulWidget/ExpansionTile.dart'; +export 'StatefulWidget/AppBar/node1_base.dart'; +export 'StatefulWidget/AppBar/node2_tab.dart'; +export 'StatefulWidget/BottomAppBar/node1_base.dart'; +export 'StatefulWidget/BottomNavigationBar/node1_base.dart'; +export 'StatefulWidget/BottomNavigationBar/node2_page.dart'; +export 'StatefulWidget/Checkbox/node1_base.dart'; +export 'StatefulWidget/Checkbox/node2_tristate.dart'; +export 'StatefulWidget/ExpandIcon/node1_base.dart'; +export 'StatefulWidget/ExpansionTile/node1_base.dart'; export 'StatefulWidget/Radio.dart'; export 'StatefulWidget/Tooltip.dart'; -export 'StatefulWidget/CircularProgressIndicator.dart'; -export 'StatefulWidget/CupertinoActivityIndicator.dart'; -export 'StatefulWidget/CupertinoSlider.dart'; -export 'StatefulWidget/CupertinoSwitch.dart'; -export 'StatefulWidget/Image.dart'; +export 'StatefulWidget/CircularProgressIndicator/node1_base.dart'; +export 'StatefulWidget/CupertinoActivityIndicator/node1_base.dart'; +export 'StatefulWidget/CupertinoSlider/node1_base.dart'; +export 'StatefulWidget/CupertinoSwitch/node1_base.dart'; + +export 'StatefulWidget/Image/node1_base.dart'; +export 'StatefulWidget/Image/node2_fit.dart'; +export 'StatefulWidget/Image/node3_alignment.dart'; +export 'StatefulWidget/Image/node4_colorBlendMode.dart'; +export 'StatefulWidget/Image/node5_repeat.dart'; +export 'StatefulWidget/Image/node6_centerSlice.dart'; + export 'StatefulWidget/RangerSlider.dart'; export 'StatefulWidget/Slider.dart'; export 'StatefulWidget/Switch.dart'; export 'StatefulWidget/TextField.dart'; export 'StatefulWidget/RefreshIndicator.dart'; export 'StatefulWidget/SelectableText.dart'; -export 'StatefulWidget/CupertinoNavigationBar.dart'; -export 'StatefulWidget/CupertinoTabBar.dart'; -export 'StatefulWidget/DropdownButton.dart'; +export 'StatefulWidget/CupertinoNavigationBar/node1_base.dart'; +export 'StatefulWidget/CupertinoTabBar/node1_base.dart'; -export 'StatefulWidget/AnimatedCrossFade.dart'; -export 'StatefulWidget/AnimatedList.dart'; -export 'StatefulWidget/AnimatedSwitcher.dart'; -export 'StatefulWidget/AlignTransition.dart'; -export 'StatefulWidget/DecoratedBoxTransition.dart'; -export 'StatefulWidget/DefaultTextStyleTransition.dart'; +export 'StatefulWidget/DropdownButton/node1_base.dart'; +export 'StatefulWidget/DropdownButton/node2_style.dart'; + +export 'StatefulWidget/AnimatedCrossFade/node1_base.dart'; +export 'StatefulWidget/AnimatedCrossFade/node2_curve.dart'; + +export 'StatefulWidget/AnimatedList/node1_base.dart'; +export 'StatefulWidget/AnimatedSwitcher/node1_base.dart'; +export 'StatefulWidget/AlignTransition/node1_base.dart'; +export 'StatefulWidget/DecoratedBoxTransition/node1_base.dart'; +export 'StatefulWidget/DefaultTextStyleTransition/node1_base.dart'; export 'StatefulWidget/RelativePositionedTransition.dart'; -export 'StatefulWidget/CupertinoScrollbar.dart'; -export 'StatefulWidget/Dismissible.dart'; -export 'StatefulWidget/DragTarget.dart'; -export 'StatefulWidget/Draggable.dart'; -export 'StatefulWidget/ExpansionPanelList.dart'; -export 'StatefulWidget/Form.dart'; -export 'StatefulWidget/FutureBuilder.dart'; -export 'StatefulWidget/Hero.dart'; -export 'StatefulWidget/AnimatedAlign.dart'; -export 'StatefulWidget/AnimatedContainer.dart'; -export 'StatefulWidget/AnimatedDefaultTextStyle.dart'; -export 'StatefulWidget/AnimatedOpacity.dart'; -export 'StatefulWidget/AnimatedPadding.dart'; -export 'StatefulWidget/AnimatedPositioned.dart'; -export 'StatefulWidget/AnimatedPositionedDirectional.dart'; +export 'StatefulWidget/CupertinoScrollbar/node1_base.dart'; + +export 'StatefulWidget/Dismissible/node1_base.dart'; +export 'StatefulWidget/Dismissible/node2_direction.dart'; + +export 'StatefulWidget/DragTarget/node1_base.dart'; +export 'StatefulWidget/Draggable/node1_base.dart'; +export 'StatefulWidget/Draggable/node2_data.dart'; +export 'StatefulWidget/Draggable/node3_use.dart'; + +export 'StatefulWidget/Form/node1_base.dart'; +export 'StatefulWidget/FutureBuilder/node1_base.dart'; +export 'StatefulWidget/Hero/node1_base.dart'; +export 'StatefulWidget/AnimatedAlign/node1_base.dart'; +export 'StatefulWidget/AnimatedContainer/node1_base.dart'; +export 'StatefulWidget/AnimatedDefaultTextStyle/node1_base.dart'; +export 'StatefulWidget/AnimatedOpacity/node1_base.dart'; +export 'StatefulWidget/AnimatedPadding/node1_base.dart'; +export 'StatefulWidget/AnimatedPositioned/node1_base.dart'; +export 'StatefulWidget/AnimatedPositionedDirectional/node1_base.dart'; + +export 'StatefulWidget/ExpansionPanelList/node1_base.dart'; + export 'StatefulWidget/Ink.dart'; export 'StatefulWidget/InkResponse.dart'; export 'StatefulWidget/InkWell.dart'; @@ -77,9 +99,9 @@ export 'StatefulWidget/StreamBuilder.dart'; export 'StatefulWidget/TableRowInkWell.dart'; export 'StatefulWidget/TextFormField.dart'; export 'StatefulWidget/LinearProgressIndicator.dart'; -export 'StatefulWidget/CupertinoApp.dart'; -export 'StatefulWidget/CupertinoPageScaffold.dart'; -export 'StatefulWidget/CupertinoTabScaffold.dart'; +export 'StatefulWidget/CupertinoApp/node1_base.dart'; +export 'StatefulWidget/CupertinoPageScaffold/node1_base.dart'; +export 'StatefulWidget/CupertinoTabScaffold/node1_base.dart'; export 'StatefulWidget/MaterialApp.dart'; export 'StatefulWidget/Scaffold.dart'; -export 'StatefulWidget/TabBarView.dart'; \ No newline at end of file +export 'StatefulWidget/TabBarView.dart';