|
|
@@ -12,6 +12,8 @@ class MineNavDelegate extends SliverPersistentHeaderDelegate { |
|
|
|
Color _color; |
|
|
|
|
|
|
|
List<Widget> _icons = List(); |
|
|
|
double marginTop; |
|
|
|
double marginLeftRight; |
|
|
|
|
|
|
|
MineNavDelegate(this.data) : super() { |
|
|
|
_height = MediaQueryData.fromWindow(window).padding.top + 44; |
|
|
@@ -29,13 +31,20 @@ class MineNavDelegate extends SliverPersistentHeaderDelegate { |
|
|
|
return MineNavIcon(icon['icon'], model); |
|
|
|
}).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 |
|
|
|
Widget build( |
|
|
|
BuildContext context, double shrinkOffset, bool overlapsContent) { |
|
|
|
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { |
|
|
|
double percent = shrinkOffset / _height; |
|
|
|
return MineNav(_color.withOpacity(percent), _icons); |
|
|
|
return MineNav(_color.withOpacity(percent), _icons, marginTop, marginLeftRight); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
@@ -45,19 +54,21 @@ class MineNavDelegate extends SliverPersistentHeaderDelegate { |
|
|
|
double get minExtent => _height; |
|
|
|
|
|
|
|
@override |
|
|
|
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => |
|
|
|
false; // 如果内容需要更新,设置为true |
|
|
|
bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) => false; // 如果内容需要更新,设置为true |
|
|
|
} |
|
|
|
|
|
|
|
class MineNav extends StatelessWidget { |
|
|
|
final Color color; |
|
|
|
final List<Widget> widgets; |
|
|
|
double marginLeftRight; |
|
|
|
double marginTop; |
|
|
|
|
|
|
|
MineNav(this.color, this.widgets); |
|
|
|
MineNav(this.color, this.widgets, this.marginTop, this.marginLeftRight); |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return Container( |
|
|
|
margin: EdgeInsets.only(top: marginTop, left: marginLeftRight, right: marginLeftRight), |
|
|
|
padding: EdgeInsets.only(left: 12, right: 12), |
|
|
|
color: color, |
|
|
|
child: Column( |
|
|
@@ -78,23 +89,23 @@ class MineNav 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); |
|
|
|
|
|
|
|
@override |
|
|
|
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); |
|
|
|
}); |
|
|
|
} |
|
|
|