|
@@ -12,6 +12,8 @@ class MineNavDelegate extends SliverPersistentHeaderDelegate { |
|
|
Color _color; |
|
|
Color _color; |
|
|
|
|
|
|
|
|
List<Widget> _icons = List(); |
|
|
List<Widget> _icons = List(); |
|
|
|
|
|
double marginTop; |
|
|
|
|
|
double marginLeftRight; |
|
|
|
|
|
|
|
|
MineNavDelegate(this.data) : super() { |
|
|
MineNavDelegate(this.data) : super() { |
|
|
_height = MediaQueryData.fromWindow(window).padding.top + 44; |
|
|
_height = MediaQueryData.fromWindow(window).padding.top + 44; |
|
@@ -29,13 +31,20 @@ class MineNavDelegate extends SliverPersistentHeaderDelegate { |
|
|
return MineNavIcon(icon['icon'], model); |
|
|
return MineNavIcon(icon['icon'], model); |
|
|
}).toList(); |
|
|
}).toList(); |
|
|
} |
|
|
} |
|
|
|
|
|
marginTop = 0; |
|
|
|
|
|
if (json.containsKey("is_top_margin") && json.containsKey("top_margin")) { |
|
|
|
|
|
marginTop = json['is_top_margin'] == "1" ? double.parse(json['top_margin']) : 0; |
|
|
|
|
|
} |
|
|
|
|
|
marginLeftRight = 0; |
|
|
|
|
|
if (json.containsKey("is_left_right_margin") && json.containsKey("left_right_margin")) { |
|
|
|
|
|
marginLeftRight = json['is_left_right_margin'] == "1" ? double.parse(json['left_right_margin']) : 0; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
Widget build( |
|
|
|
|
|
BuildContext context, double shrinkOffset, bool overlapsContent) { |
|
|
|
|
|
|
|
|
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { |
|
|
double percent = shrinkOffset / _height; |
|
|
double percent = shrinkOffset / _height; |
|
|
return MineNav(_color.withOpacity(percent), _icons); |
|
|
|
|
|
|
|
|
return MineNav(_color.withOpacity(percent), _icons, marginTop, marginLeftRight); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
@@ -45,19 +54,21 @@ class MineNavDelegate extends SliverPersistentHeaderDelegate { |
|
|
double get minExtent => _height; |
|
|
double get minExtent => _height; |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => |
|
|
|
|
|
false; // 如果内容需要更新,设置为true |
|
|
|
|
|
|
|
|
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => false; // 如果内容需要更新,设置为true |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class MineNav extends StatelessWidget { |
|
|
class MineNav extends StatelessWidget { |
|
|
final Color color; |
|
|
final Color color; |
|
|
final List<Widget> widgets; |
|
|
final List<Widget> widgets; |
|
|
|
|
|
double marginLeftRight; |
|
|
|
|
|
double marginTop; |
|
|
|
|
|
|
|
|
MineNav(this.color, this.widgets); |
|
|
|
|
|
|
|
|
MineNav(this.color, this.widgets, this.marginTop, this.marginLeftRight); |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
Widget build(BuildContext context) { |
|
|
Widget build(BuildContext context) { |
|
|
return Container( |
|
|
return Container( |
|
|
|
|
|
margin: EdgeInsets.only(top: marginTop, left: marginLeftRight, right: marginLeftRight), |
|
|
padding: EdgeInsets.only(left: 12, right: 12), |
|
|
padding: EdgeInsets.only(left: 12, right: 12), |
|
|
color: color, |
|
|
color: color, |
|
|
child: Column( |
|
|
child: Column( |
|
@@ -78,23 +89,23 @@ class MineNav extends StatelessWidget { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class MineNavIcon extends StatelessWidget { |
|
|
class MineNavIcon extends StatelessWidget { |
|
|
final String imgUrl; |
|
|
|
|
|
final SkipModel skipModel; |
|
|
|
|
|
|
|
|
final String imgUrl; |
|
|
|
|
|
final SkipModel skipModel; |
|
|
|
|
|
|
|
|
const MineNavIcon(this.imgUrl, this.skipModel, {Key key}) : super(key: key); |
|
|
const MineNavIcon(this.imgUrl, this.skipModel, {Key key}) : super(key: key); |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
Widget build(BuildContext context) { |
|
|
Widget build(BuildContext context) { |
|
|
return GestureDetector(child: Container( |
|
|
|
|
|
width: 24, |
|
|
|
|
|
height: 24, |
|
|
|
|
|
margin: EdgeInsets.only(left: 6), |
|
|
|
|
|
child: CachedNetworkImage( |
|
|
|
|
|
imageUrl: imgUrl, |
|
|
|
|
|
), |
|
|
|
|
|
|
|
|
|
|
|
), |
|
|
|
|
|
onTap:() { |
|
|
|
|
|
|
|
|
return GestureDetector( |
|
|
|
|
|
child: Container( |
|
|
|
|
|
width: 24, |
|
|
|
|
|
height: 24, |
|
|
|
|
|
margin: EdgeInsets.only(left: 6), |
|
|
|
|
|
child: CachedNetworkImage( |
|
|
|
|
|
imageUrl: imgUrl, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
onTap: () { |
|
|
RouterUtil.route(skipModel, skipModel.toJson(), context); |
|
|
RouterUtil.route(skipModel, skipModel.toJson(), context); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|