diff --git a/assets/flutter.db b/assets/flutter.db index 59308b4..4b63520 100644 Binary files a/assets/flutter.db and b/assets/flutter.db differ diff --git a/lib/.gitignore b/lib/.gitignore index 84ea85a..0d5de89 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1 +1,2 @@ -/tools/ \ No newline at end of file +/tools/ +/single/ \ No newline at end of file diff --git a/lib/components/project/widget_node_panel.dart b/lib/components/project/widget_node_panel.dart index 1b92a5d..147a124 100644 --- a/lib/components/project/widget_node_panel.dart +++ b/lib/components/project/widget_node_panel.dart @@ -144,7 +144,7 @@ class _WidgetNodePanelState extends State { //执行分享 _doCopy() async{ await Clipboard.setData(ClipboardData(text: widget.code)); - Toast.toast(context, '复制成功!',duration: Duration(seconds: 10)); + Toast.toast(context, '复制成功!',duration: Duration(seconds: 1)); // Share.share(widget.code); } diff --git a/lib/views/app/flutter_app.dart b/lib/views/app/flutter_app.dart index 1833f1a..fc60335 100644 --- a/lib/views/app/flutter_app.dart +++ b/lib/views/app/flutter_app.dart @@ -20,6 +20,7 @@ class FlutterApp extends StatelessWidget { debugShowCheckedModeBanner: false, onGenerateRoute: Router.generateRoute, theme: ThemeData( + visualDensity: VisualDensity.adaptivePlatformDensity, primarySwatch: state.themeColor, fontFamily: state.fontFamily, ), diff --git a/lib/views/pages/home/home_page.dart b/lib/views/pages/home/home_page.dart index e0c9fe2..a805c88 100644 --- a/lib/views/pages/home/home_page.dart +++ b/lib/views/pages/home/home_page.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -25,6 +27,7 @@ class _HomePageState extends State { @override void initState() { + print(Directory.current.path); _ctrl = ScrollController()..addListener(_updateAppBarHeight); super.initState(); } diff --git a/lib/views/widgets/MultiChildRenderObjectWidget/CustomMultiChildLayout/node1_base.dart b/lib/views/widgets/MultiChildRenderObjectWidget/CustomMultiChildLayout/node1_base.dart new file mode 100644 index 0000000..10961cb --- /dev/null +++ b/lib/views/widgets/MultiChildRenderObjectWidget/CustomMultiChildLayout/node1_base.dart @@ -0,0 +1,94 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020/6/6 +/// contact me by email 1981462002@qq.com +/// 说明: + +// { +// "widgetId": 341, +// "name": 'CustomMultiChildLayout基本使用', +// "priority": 1, +// "subtitle": +// "【children】 : 子组件集 【List】\n" +// "【delegate】 : 布局代理 【MultiChildLayoutDelegate】", +// } + + +class CustomMultiChildLayoutDemo extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + width: 300, + height: 150, + color: Colors.grey.withAlpha(33), + child: CustomMultiChildLayout( + delegate: CornerCustomMultiChildLayout( + padding:EdgeInsets.only(left: 10,top: 5,right: 10,bottom: 5), + ), + children: [ + LayoutId(id: CornerType.topLeft, child: Box50(Colors.red)), + LayoutId(id: CornerType.topRight, child: Box50(Colors.yellow)), + LayoutId(id: CornerType.bottomLeft, child: Box50(Colors.blue)), + LayoutId(id: CornerType.bottomRight, child: Box50(Colors.green)), + ], + ), + ); + } +} + +// 50 颜射盒 +class Box50 extends StatelessWidget { + final Color color; + Box50(this.color); + + @override + Widget build(BuildContext context) { + return Container( + width: 50, + height: 50, + color: color, + ); + } +} + + +enum CornerType{ + topLeft, + topRight, + bottomLeft, + bottomRight +} + + +class CornerCustomMultiChildLayout extends MultiChildLayoutDelegate{ + final EdgeInsets padding; + + CornerCustomMultiChildLayout({this.padding = EdgeInsets.zero}); + + @override + void performLayout(Size size) { + if (hasChild(CornerType.topLeft)) { + layoutChild(CornerType.topLeft, BoxConstraints.loose(size)); + positionChild(CornerType.topLeft, Offset.zero.translate(padding.left, padding.top)); + } + if (hasChild(CornerType.topRight)) { + var childSize = layoutChild(CornerType.topRight, BoxConstraints.loose(size)); + positionChild(CornerType.topRight, Offset(size.width-childSize.width,0).translate(-padding.right, padding.top)); + } + if (hasChild(CornerType.bottomLeft)) { + var childSize = layoutChild(CornerType.bottomLeft, BoxConstraints.loose(size)); + positionChild(CornerType.bottomLeft, Offset(0,size.height-childSize.height).translate(padding.left, -padding.bottom)); + } + if (hasChild(CornerType.bottomRight)) { + var childSize = layoutChild(CornerType.bottomRight, BoxConstraints.loose(size)); + positionChild(CornerType.bottomRight, Offset(size.width-childSize.width,size.height-childSize.height).translate(-padding.right, -padding.bottom)); + } + } + + @override + bool shouldRelayout(CornerCustomMultiChildLayout oldDelegate) => oldDelegate.padding!=padding; + +} + diff --git a/lib/views/widgets/ProxyWidget/LayoutId/node1_base.dart b/lib/views/widgets/ProxyWidget/LayoutId/node1_base.dart new file mode 100644 index 0000000..b4215aa --- /dev/null +++ b/lib/views/widgets/ProxyWidget/LayoutId/node1_base.dart @@ -0,0 +1,94 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020/6/6 +/// contact me by email 1981462002@qq.com +/// 说明: + +// { +// "widgetId": 315, +// "name": 'LayoutId使用场景', +// "priority": 1, +// "subtitle": +// "【id】 : 标识id 【Object】\n" +// "【child】 : 子组件 【Widget】", +// } + + +class LayoutIdDemo extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + width: 300, + height: 150, + color: Colors.grey.withAlpha(33), + child: CustomMultiChildLayout( + delegate: CornerCustomMultiChildLayout( + padding:EdgeInsets.only(left: 10,top: 5,right: 10,bottom: 5), + ), + children: [ + LayoutId(id: CornerType.topLeft, child: Box50(Colors.red)), + LayoutId(id: CornerType.topRight, child: Box50(Colors.yellow)), + LayoutId(id: CornerType.bottomLeft, child: Box50(Colors.blue)), + LayoutId(id: CornerType.bottomRight, child: Box50(Colors.green)), + ], + ), + ); + } +} + +// 50 颜射盒 +class Box50 extends StatelessWidget { + final Color color; + Box50(this.color); + + @override + Widget build(BuildContext context) { + return Container( + width: 50, + height: 50, + color: color, + ); + } +} + + +enum CornerType{ + topLeft, + topRight, + bottomLeft, + bottomRight +} + + +class CornerCustomMultiChildLayout extends MultiChildLayoutDelegate{ + final EdgeInsets padding; + + CornerCustomMultiChildLayout({this.padding = EdgeInsets.zero}); + + @override + void performLayout(Size size) { + if (hasChild(CornerType.topLeft)) { + layoutChild(CornerType.topLeft, BoxConstraints.loose(size)); + positionChild(CornerType.topLeft, Offset.zero.translate(padding.left, padding.top)); + } + if (hasChild(CornerType.topRight)) { + var childSize = layoutChild(CornerType.topRight, BoxConstraints.loose(size)); + positionChild(CornerType.topRight, Offset(size.width-childSize.width,0).translate(-padding.right, padding.top)); + } + if (hasChild(CornerType.bottomLeft)) { + var childSize = layoutChild(CornerType.bottomLeft, BoxConstraints.loose(size)); + positionChild(CornerType.bottomLeft, Offset(0,size.height-childSize.height).translate(padding.left, -padding.bottom)); + } + if (hasChild(CornerType.bottomRight)) { + var childSize = layoutChild(CornerType.bottomRight, BoxConstraints.loose(size)); + positionChild(CornerType.bottomRight, Offset(size.width-childSize.width,size.height-childSize.height).translate(-padding.right, -padding.bottom)); + } + } + + @override + bool shouldRelayout(CornerCustomMultiChildLayout oldDelegate) => oldDelegate.padding!=padding; + +} + diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/CustomSingleChildLayout/node1_base.dart b/lib/views/widgets/SingleChildRenderObjectWidget/CustomSingleChildLayout/node1_base.dart new file mode 100644 index 0000000..a3daf4a --- /dev/null +++ b/lib/views/widgets/SingleChildRenderObjectWidget/CustomSingleChildLayout/node1_base.dart @@ -0,0 +1,61 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020/6/3 +/// contact me by email 1981462002@qq.com +/// 说明: + +// { +// "widgetId": 285, +// "name": 'CustomSingleChildLayout基本使用', +// "priority": 1, +// "subtitle": +// "【delegate】 : 代理 【SingleChildLayoutDelegate】", +// } + +class CustomSingleChildLayoutDemo extends StatelessWidget { + @override + Widget build(BuildContext context) { + print('-------CustomSingleChildLayoutDemo------'); + return Container( + width: 300, + height: 200, + color: Colors.grey.withAlpha(11), + child: CustomSingleChildLayout( + delegate: _TolySingleChildLayoutDelegate(), + child: Container( + color: Colors.orange, + ), + ), + ); + } +} + +class _TolySingleChildLayoutDelegate extends SingleChildLayoutDelegate { + @override + bool shouldRelayout(SingleChildLayoutDelegate oldDelegate) { + return true; + } + + @override + Size getSize(BoxConstraints constraints) { + print('----getSize:----constraints:$constraints----'); + return super.getSize(constraints); + } + + @override + Offset getPositionForChild(Size size, Size childSize) { + print('----getPositionForChild: size:$size----childSize:$childSize----'); + return Offset(size.width / 2, 0); + } + + @override + BoxConstraints getConstraintsForChild(BoxConstraints constraints) { + print('----getConstraintsForChild:----constraints:$constraints----'); + return BoxConstraints( + maxWidth: constraints.maxWidth / 2, + maxHeight: constraints.maxHeight / 2, + minHeight: constraints.maxHeight / 4, + minWidth: constraints.maxWidth / 4, + ); + } +} \ No newline at end of file diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/CustomSingleChildLayout/node2_offset.dart b/lib/views/widgets/SingleChildRenderObjectWidget/CustomSingleChildLayout/node2_offset.dart new file mode 100644 index 0000000..4b5444c --- /dev/null +++ b/lib/views/widgets/SingleChildRenderObjectWidget/CustomSingleChildLayout/node2_offset.dart @@ -0,0 +1,118 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020/6/3 +/// contact me by email 1981462002@qq.com +/// 说明: + +// { +// "widgetId": 285, +// "name": 'CustomSingleChildLayout的偏移使用', +// "priority": 2, +// "subtitle": +// "可以利用代理的偏移能力,对子组件进行偏移定位。", +// } + +class OffSetWidgetDemo extends StatelessWidget { + final data = [ + { + 'offset': Offset(20, 20), + 'direction': Direction.topLeft, + }, + { + 'offset': Offset(20, -15), + 'direction': Direction.topRight, + }, + { + 'offset': Offset(-15, 20), + 'direction': Direction.bottomLeft, + }, + { + 'offset': Offset(-15, 20), + 'direction': Direction.bottomLeft, + }, + { + 'offset': Offset(15, 20), + 'direction': Direction.bottomLeft, + }, + { + 'offset': Offset(-15, -15), + 'direction': Direction.topRight, + }, + ]; + + @override + Widget build(BuildContext context) { + return Wrap( + spacing: 20, + runSpacing: 20, + children: data + .map((e) => Container( + width: 150, + height: 100, + alignment: Alignment.topRight, + color: Colors.grey.withAlpha(11), + child: OffSetWidget( + offset: e['offset'], + direction: e['direction'], + child: Icon( + Icons.android, + size: 30, + color: Colors.green, + ), + ))) + .toList()); + } +} + +class OffSetWidget extends StatelessWidget { + final Offset offset; + final Widget child; + final Direction direction; + + OffSetWidget( + {this.offset = Offset.zero, + this.child, + this.direction = Direction.topLeft}); + + @override + Widget build(BuildContext context) { + return CustomSingleChildLayout( + delegate: _OffSetDelegate(offset: offset, direction: direction), + child: child, + ); + } +} + +enum Direction { topLeft, topRight, bottomLeft, bottomRight } + +class _OffSetDelegate extends SingleChildLayoutDelegate { + final Offset offset; + final Direction direction; + + _OffSetDelegate( + {this.offset = Offset.zero, this.direction = Direction.topLeft}); + + @override + bool shouldRelayout(_OffSetDelegate oldDelegate) => + offset != oldDelegate.offset; + + @override + Offset getPositionForChild(Size size, Size childSize) { + var w = size.width; + var h = size.height; + var wc = childSize.width; + var hc = childSize.height; + + switch (direction) { + case Direction.topLeft: + return offset; + case Direction.topRight: + return offset.translate(w - wc - offset.dx * 2, 0); + case Direction.bottomLeft: + return offset.translate(0, h - hc - offset.dy * 2); + case Direction.bottomRight: + return offset.translate(w - wc - offset.dx * 2, h - hc - offset.dy * 2); + } + return offset; + } +} diff --git a/lib/views/widgets/Sliver/SliverOverlapAbsorber/node1_base.dart b/lib/views/widgets/Sliver/SliverOverlapAbsorber/node1_base.dart new file mode 100644 index 0000000..8f62261 --- /dev/null +++ b/lib/views/widgets/Sliver/SliverOverlapAbsorber/node1_base.dart @@ -0,0 +1,97 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020/6/16 +/// contact me by email 1981462002@qq.com +/// 说明: + +// { +// "widgetId": 307, +// "name": 'SliverOverlapAbsorber基本使用', +// "priority": 1, +// "subtitle": +// "【sliver】 : 子组件 【Widget】\n" +// "【handle】 : *处理器 【SliverOverlapAbsorberHandle】\n" +// "如果不使用SliverOverlapAbsorber和SliverOverlapInjector组件,NestedScrollView的内容会和头部栏重叠。", +// } + +class SliverOverlapAbsorberDemo extends StatelessWidget { + final _tabs = ['风神传', '封妖志', "幻将录", "永恒传说"]; + + @override + Widget build(BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height - 200, + child: Scaffold( + body: DefaultTabController( + length: _tabs.length, + child: NestedScrollView( + headerSliverBuilder: + (BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverOverlapAbsorber( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), + sliver: SliverAppBar( + title: const Text('旷古奇书'), + pinned: true, + elevation: 6, //影深 + expandedHeight: 220.0, + forceElevated: innerBoxIsScrolled, //为true时展开有阴影 + flexibleSpace: FlexibleSpaceBar( + background: Image.asset( + "assets/images/wy_300x200_filter.jpg", + fit: BoxFit.cover, + ), + ), + bottom: TabBar( + tabs: _tabs + .map((String name) => Tab(text: name,)) + .toList(), + ), + ), + ), + ]; + }, + body: _buildTabBarView(), + ), + ), + )); + } + + Widget _buildTabBarView() { + return TabBarView( + children: _tabs.map((String name) { + return SafeArea( + top: false, + bottom: false, + child: Builder( + builder: (BuildContext context) { + return CustomScrollView( + key: PageStorageKey(name), + slivers: [ + SliverOverlapInjector( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), + ), + SliverPadding( + padding: const EdgeInsets.all(8.0), + sliver: SliverFixedExtentList( + itemExtent: 48.0, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return ListTile( + title: Text('《$name》 第 $index章'), + ); + }, + childCount: 50, + ), + ), + ), + ], + ); + }, + ), + ); + }).toList(), + ); + } +} diff --git a/lib/views/widgets/Sliver/SliverOverlapInjector/node1_base.dart b/lib/views/widgets/Sliver/SliverOverlapInjector/node1_base.dart new file mode 100644 index 0000000..4381e06 --- /dev/null +++ b/lib/views/widgets/Sliver/SliverOverlapInjector/node1_base.dart @@ -0,0 +1,97 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020/6/16 +/// contact me by email 1981462002@qq.com +/// 说明: + +// { +// "widgetId": 308, +// "name": 'SliverOverlapInjector基本使用', +// "priority": 1, +// "subtitle": +// "【sliver】 : 子组件 【Widget】\n" +// "【handle】 : *处理器 【SliverOverlapAbsorberHandle】\n" +// "如果不使用SliverOverlapAbsorber和SliverOverlapInjector组件,NestedScrollView的内容会和头部栏重叠。", +// } + +class SliverOverlapInjectorDemo extends StatelessWidget { + final _tabs = ['风神传', '封妖志', "幻将录", "永恒传说"]; + + @override + Widget build(BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height - 200, + child: Scaffold( + body: DefaultTabController( + length: _tabs.length, + child: NestedScrollView( + headerSliverBuilder: + (BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverOverlapAbsorber( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), + sliver: SliverAppBar( + title: const Text('旷古奇书'), + pinned: true, + elevation: 6, //影深 + expandedHeight: 220.0, + forceElevated: innerBoxIsScrolled, //为true时展开有阴影 + flexibleSpace: FlexibleSpaceBar( + background: Image.asset( + "assets/images/wy_300x200_filter.jpg", + fit: BoxFit.cover, + ), + ), + bottom: TabBar( + tabs: _tabs + .map((String name) => Tab(text: name,)) + .toList(), + ), + ), + ), + ]; + }, + body: _buildTabBarView(), + ), + ), + )); + } + + Widget _buildTabBarView() { + return TabBarView( + children: _tabs.map((String name) { + return SafeArea( + top: false, + bottom: false, + child: Builder( + builder: (BuildContext context) { + return CustomScrollView( + key: PageStorageKey(name), + slivers: [ + SliverOverlapInjector( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), + ), + SliverPadding( + padding: const EdgeInsets.all(8.0), + sliver: SliverFixedExtentList( + itemExtent: 48.0, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return ListTile( + title: Text('《$name》 第 $index章'), + ); + }, + childCount: 50, + ), + ), + ), + ], + ); + }, + ), + ); + }).toList(), + ); + } +} diff --git a/lib/views/widgets/StatefulWidget/CupertinoSegmentedControl/node1_base.dart b/lib/views/widgets/StatefulWidget/CupertinoSegmentedControl/node1_base.dart new file mode 100644 index 0000000..49bc1b2 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/CupertinoSegmentedControl/node1_base.dart @@ -0,0 +1,52 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020/6/30 +/// contact me by email 1981462002@qq.com +/// 说明: +/// +// { +// "widgetId": 262, +// "name": '基本使用', +// "priority": 1, +// "subtitle": +// "【children】 : 组件Map 【Map】\n" +// "【onValueChanged】 : 最小值 【ValueChanged】\n" +// "【groupValue】 : 选中值 【T】\n" +// "【padding】 : 内边距 【EdgeInsetsGeometry】", +// } +class CupertinoSegmentedControlDemo extends StatefulWidget { + @override + _CupertinoSegmentedControlDemoState createState() => + _CupertinoSegmentedControlDemoState(); +} + +class _CupertinoSegmentedControlDemoState + extends State { + var _value = 1; + + @override + Widget build(BuildContext context) { + return Container( + child: CupertinoSegmentedControl( + groupValue: _value, + onValueChanged: _onValueChanged, + padding: EdgeInsets.only(top: 20), + children: { + 1: Padding( + padding: EdgeInsets.only(left: 20, right: 20), + child: Text("混沌战士"), + ), + 2: Text("青眼白龙"), + 3: Text("黑魔术士"), + }, + ), + ); + } + + void _onValueChanged(int value) { + setState(() { + _value=value; + }); + } +} diff --git a/lib/views/widgets/StatefulWidget/CupertinoSegmentedControl/node2_color.dart b/lib/views/widgets/StatefulWidget/CupertinoSegmentedControl/node2_color.dart new file mode 100644 index 0000000..cf71d0a --- /dev/null +++ b/lib/views/widgets/StatefulWidget/CupertinoSegmentedControl/node2_color.dart @@ -0,0 +1,56 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020/6/30 +/// contact me by email 1981462002@qq.com +/// 说明: +/// +// { +// "widgetId": 262, +// "name": 'CupertinoSegmentedControl的颜色', +// "priority": 2, +// "subtitle": +// "【unselectedColor】 : 未选中色 【Color】\n" +// "【selectedColor】 : 选中色 【Color】\n" +// "【pressedColor】 : 按下色 【Color】\n" +// "【borderColor】 : 边线色 【Color】", +// } +class CupertinoSegmentedControlColor extends StatefulWidget { + @override + _CupertinoSegmentedControlColorState createState() => + _CupertinoSegmentedControlColorState(); +} + +class _CupertinoSegmentedControlColorState + extends State { + var _value = 1; + + @override + Widget build(BuildContext context) { + return Container( + child: CupertinoSegmentedControl( + unselectedColor: Colors.yellow, + selectedColor: Colors.green, + pressedColor: Colors.blue, + borderColor: Colors.red, + groupValue: _value, + onValueChanged: _onValueChanged, + padding: EdgeInsets.only(top: 20), + children: { + 1: Padding( + padding: EdgeInsets.only(left: 20, right: 20), + child: Text("混沌战士"), + ), + 2: Text("青眼白龙"), + 3: Text("黑魔术士"), + }, + ), + ); + } + + void _onValueChanged(int value) { + setState(() { + _value=value; + }); + } +} diff --git a/lib/views/widgets/StatefulWidget/NestedScrollView/node1_base.dart b/lib/views/widgets/StatefulWidget/NestedScrollView/node1_base.dart new file mode 100644 index 0000000..1c97db1 --- /dev/null +++ b/lib/views/widgets/StatefulWidget/NestedScrollView/node1_base.dart @@ -0,0 +1,102 @@ +import 'package:flutter/material.dart'; + +/// create by 张风捷特烈 on 2020/6/16 +/// contact me by email 1981462002@qq.com +/// 说明: + +// { +// "widgetId": 251, +// "name": 'NestedScrollView基本用法', +// "priority": 1, +// "subtitle": +// "【controller】 : 滑动控制器 【ScrollController】\n" +// "【scrollDirection】 : 滑动方向 【Axis】\n" +// "【reverse】 : 是否反向 【bool】\n" +// "【physics】 : 滑顶样式 【ScrollPhysics】\n" +// "【dragStartBehavior】 : 开始拖动行为 【DragStartBehavior】\n" +// "【headerSliverBuilder】 : *头部构造器 【NestedScrollViewHeaderSliversBuilder】\n" +// "【body】 : *内容 【Widget】", +// } + +class NestedScrollViewDemo extends StatelessWidget { + final _tabs = ['风神传', '封妖志', "幻将录", "永恒传说"]; + + @override + Widget build(BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height - 200, + child: Scaffold( + body: DefaultTabController( + length: _tabs.length, + child: NestedScrollView( + headerSliverBuilder: + (BuildContext context, bool innerBoxIsScrolled) { + return [ + SliverOverlapAbsorber( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor( + context), + sliver: SliverAppBar( + title: const Text('旷古奇书'), + pinned: true, + elevation: 6, //影深 + expandedHeight: 220.0, + forceElevated: innerBoxIsScrolled, //为true时展开有阴影 + flexibleSpace: FlexibleSpaceBar( + background: Image.asset( + "assets/images/wy_300x200_filter.jpg", + fit: BoxFit.cover, + ), + ), + bottom: TabBar( + tabs: _tabs + .map((String name) => Tab(text: name,)) + .toList(), + ), + ), + ), + ]; + }, + body: _buildTabBarView(), + ), + ), + )); + } + + Widget _buildTabBarView() { + return TabBarView( + children: _tabs.map((String name) { + return SafeArea( + top: false, + bottom: false, + child: Builder( + builder: (BuildContext context) { + return CustomScrollView( + key: PageStorageKey(name), + slivers: [ + SliverOverlapInjector( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), + ), + SliverPadding( + padding: const EdgeInsets.all(8.0), + sliver: SliverFixedExtentList( + itemExtent: 48.0, + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) { + return ListTile( + title: Text('《$name》 第 $index章'), + ); + }, + childCount: 50, + ), + ), + ), + ], + ); + }, + ), + ); + }).toList(), + ); + } +} diff --git a/lib/views/widgets/exp/proxy_unit.dart b/lib/views/widgets/exp/proxy_unit.dart index ee22856..4eb0ab3 100644 --- a/lib/views/widgets/exp/proxy_unit.dart +++ b/lib/views/widgets/exp/proxy_unit.dart @@ -16,4 +16,5 @@ export '../ProxyWidget/DividerTheme/node1_base.dart'; export '../ProxyWidget/IconTheme/node1_base.dart'; export '../ProxyWidget/ScrollConfiguration/node1_base.dart'; export '../ProxyWidget/Expanded/node1_base.dart'; -export '../ProxyWidget/Positioned/node1_base.dart'; \ No newline at end of file +export '../ProxyWidget/Positioned/node1_base.dart'; +export '../ProxyWidget/LayoutId/node1_base.dart'; \ No newline at end of file diff --git a/lib/views/widgets/exp/render_object_unit.dart b/lib/views/widgets/exp/render_object_unit.dart index 1738384..696e797 100644 --- a/lib/views/widgets/exp/render_object_unit.dart +++ b/lib/views/widgets/exp/render_object_unit.dart @@ -21,10 +21,12 @@ export '../MultiChildRenderObjectWidget/Wrap/node5_verticalDirection.dart'; export '../MultiChildRenderObjectWidget/Column/node1_base.dart'; export '../MultiChildRenderObjectWidget/IndexedStack/node1_base.dart'; export '../MultiChildRenderObjectWidget/Row/node1_base.dart'; - +export '../MultiChildRenderObjectWidget/CustomMultiChildLayout/node1_base.dart'; export '../SingleChildRenderObjectWidget/Align/node1_base.dart'; export '../SingleChildRenderObjectWidget/Align/node2_other.dart'; +export '../SingleChildRenderObjectWidget/CustomSingleChildLayout/node1_base.dart'; +export '../SingleChildRenderObjectWidget/CustomSingleChildLayout/node2_offset.dart'; export '../SingleChildRenderObjectWidget/ConstrainedBox/node1_base.dart'; export '../SingleChildRenderObjectWidget/ColorFiltered/node1_base.dart'; diff --git a/lib/views/widgets/exp/sliver_unit.dart b/lib/views/widgets/exp/sliver_unit.dart index e04c9d3..fc7e958 100644 --- a/lib/views/widgets/exp/sliver_unit.dart +++ b/lib/views/widgets/exp/sliver_unit.dart @@ -15,3 +15,5 @@ export '../Sliver/SliverOpacity/node1_base.dart'; export '../Sliver/SliverPadding/node1_base.dart'; export '../Sliver/SliverPersistentHeader/node1_base.dart'; export '../Sliver/SliverToBoxAdapter/node1_base.dart'; +export '../Sliver/SliverOverlapAbsorber/node1_base.dart'; +export '../Sliver/SliverOverlapInjector/node1_base.dart'; diff --git a/lib/views/widgets/exp/stateful_unit.dart b/lib/views/widgets/exp/stateful_unit.dart index cf2ac3d..b257089 100644 --- a/lib/views/widgets/exp/stateful_unit.dart +++ b/lib/views/widgets/exp/stateful_unit.dart @@ -11,7 +11,7 @@ export '../StatefulWidget/SlideTransition/node1_base.dart'; export '../StatefulWidget/MonthPicker/node1_base.dart'; export '../StatefulWidget/YearPicker/node1_base.dart'; export '../StatefulWidget/WillPopScope/node1_base.dart'; - +export '../StatefulWidget/NestedScrollView/node1_base.dart'; export '../StatefulWidget/AppBar/node1_base.dart'; export '../StatefulWidget/AppBar/node2_tab.dart'; export '../StatefulWidget/BottomAppBar/node1_base.dart'; @@ -28,6 +28,8 @@ 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/CupertinoSegmentedControl/node1_base.dart'; +export '../StatefulWidget/CupertinoSegmentedControl/node2_color.dart'; export '../StatefulWidget/Image/node1_base.dart'; export '../StatefulWidget/Image/node2_fit.dart'; diff --git a/lib/views/widgets/widgets_map.dart b/lib/views/widgets/widgets_map.dart index eeb3f45..5d7059a 100644 --- a/lib/views/widgets/widgets_map.dart +++ b/lib/views/widgets/widgets_map.dart @@ -7,8 +7,6 @@ import 'exp/proxy_unit.dart'; import 'exp/other_unit.dart'; import 'exp/sliver_unit.dart'; - - /// create by 张风捷特烈 on 2020-03-04 /// contact me by email 1981462002@qq.com /// 说明: @@ -25,6 +23,11 @@ class WidgetsMap { ContainerTransform(), ContainerConstraints() ]; + case "CupertinoSegmentedControl": + return [ + CupertinoSegmentedControlDemo(), + CupertinoSegmentedControlColor() + ]; case "Text": return [ CustomText(), @@ -168,7 +171,18 @@ class WidgetsMap { ColorToggleButtons(), ProToggleButtons(), ]; - + case "NestedScrollView": + return [ + NestedScrollViewDemo(), + ]; + case "SliverOverlapAbsorber": + return [ + SliverOverlapAbsorberDemo(), + ]; + case "SliverOverlapInjector": + return [ + SliverOverlapInjectorDemo(), + ]; case "Divider": return [ CustomDivider(), @@ -229,6 +243,14 @@ class WidgetsMap { return [ CustomRadio(), ]; + case "CustomMultiChildLayout": + return [ + CustomMultiChildLayoutDemo(), + ]; + case "LayoutId": + return [ + LayoutIdDemo(), + ]; case "CircularProgressIndicator": return [ CustomCircularProgressIndicator(), @@ -655,7 +677,8 @@ class WidgetsMap { case "LicensePage": return [ CustomLicensePage(), - ]; case "Builder": + ]; + case "Builder": return [ BuilderDemo(), ]; @@ -673,7 +696,7 @@ class WidgetsMap { return [ CustomTab(), ]; - case "PreferredSize": + case "PreferredSize": return [ CustomPreferredSize(), AdapterPreferredSize(), @@ -949,6 +972,11 @@ class WidgetsMap { return [ CustomBackdropFilter(), ]; + case "CustomSingleChildLayout": + return [ + CustomSingleChildLayoutDemo(), + OffSetWidgetDemo(), + ]; } } } diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 540eb5c..7218929 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -14,7 +14,7 @@ PODS: - FlutterMacOS DEPENDENCIES: - - FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64-release`) + - FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`) - shared_preferences (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences/macos`) - shared_preferences_macos (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`) - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/macos`) @@ -27,7 +27,7 @@ SPEC REPOS: EXTERNAL SOURCES: FlutterMacOS: - :path: Flutter/ephemeral/.symlinks/flutter/darwin-x64-release + :path: Flutter/ephemeral/.symlinks/flutter/darwin-x64 shared_preferences: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences/macos shared_preferences_macos: diff --git a/test/widget_test.dart b/test/widget_test.dart index 3cefce4..6f9dac4 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -7,8 +7,7 @@ // //import 'package:flutter/material.dart'; //import 'package:flutter_test/flutter_test.dart'; -// -//import 'package:flutter_unit/main.dart'; + // //void main() { // testWidgets('Counter increments smoke test', (WidgetTester tester) async {