Skip to content

Commit

Permalink
Fixed Mindinventory#21: when using SafeArea subpage gets hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
devershidave committed Mar 14, 2024
1 parent ae378f8 commit 73e68ad
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 82 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.2

* Fixed #21: when using SafeArea subpage gets hidden

## 1.0.1
* add functionality to change icon size and bottom corner radius
* user can give gradiant color to the notch button
Expand Down
159 changes: 78 additions & 81 deletions lib/src/notch_bottom_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,90 +136,87 @@ class _AnimatedNotchBottomBarState extends State<AnimatedNotchBottomBar> with Si

return widget.bottomBarItems.length > maxCount
? Container()
: Align(
alignment: Alignment.bottomCenter,
child: AnimatedBuilder(
animation: _animationController,
builder: (BuildContext _, Widget? __) {
///to set any initial page
double scrollPosition = widget.notchBottomBarController.index.toDouble();
int? currentIndex = widget.notchBottomBarController.index;
if (widget.notchBottomBarController.oldIndex != null) {
_isInitial = false;
scrollPosition = Tween<double>(
begin: widget.notchBottomBarController.oldIndex!.toDouble(), end: widget.notchBottomBarController.index.toDouble())
// ignore: invalid_use_of_protected_member
.lerp(_animationController.value);
currentIndex = widget.notchBottomBarController.index;
} else {
scrollPosition = widget.notchBottomBarController.index.toDouble();
currentIndex = widget.notchBottomBarController.index;
}

return ClipRRect(
child: Padding(
padding: EdgeInsets.only(top: widget.removeMargins ? 22.0 : 8),
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
BackdropFilter(
filter: ImageFilter.blur(
sigmaX: widget.showBlurBottomBar ? widget.blurFilterX : 0.0,
sigmaY: widget.showBlurBottomBar ? widget.blurFilterY : 0.0,
: AnimatedBuilder(
animation: _animationController,
builder: (BuildContext _, Widget? __) {
///to set any initial page
double scrollPosition = widget.notchBottomBarController.index.toDouble();
int? currentIndex = widget.notchBottomBarController.index;
if (widget.notchBottomBarController.oldIndex != null) {
_isInitial = false;
scrollPosition = Tween<double>(
begin: widget.notchBottomBarController.oldIndex!.toDouble(), end: widget.notchBottomBarController.index.toDouble())
// ignore: invalid_use_of_protected_member
.lerp(_animationController.value);
currentIndex = widget.notchBottomBarController.index;
} else {
scrollPosition = widget.notchBottomBarController.index.toDouble();
currentIndex = widget.notchBottomBarController.index;
}

return ClipRRect(
child: Padding(
padding: EdgeInsets.only(top: widget.removeMargins ? 22.0 : 8),
child: Stack(
clipBehavior: Clip.none,
children: <Widget>[
BackdropFilter(
filter: ImageFilter.blur(
sigmaX: widget.showBlurBottomBar ? widget.blurFilterX : 0.0,
sigmaY: widget.showBlurBottomBar ? widget.blurFilterY : 0.0,
),
child: Opacity(
opacity: widget.showBlurBottomBar ? widget.blurOpacity : 1,
child: CustomPaint(
size: Size(_screenWidth, height),
painter: BottomBarPainter(
position: _itemPosByScrollPosition(scrollPosition),
color: widget.color,
showShadow: widget.showShadow,
notchColor: widget.notchColor,
shader: widget.notchShader,
shadowElevation: widget.shadowElevation,
kBottomRadius: widget.kBottomRadius),
),
),
),
for (var i = 0; i < widget.bottomBarItems.length; i++) ...[
if (i == currentIndex && (_animationController.value == 1.0 || _isInitial))
Positioned(
top: widget.removeMargins ? -kCircleMargin / 2 : kTopMargin,
left: kCircleRadius - kCircleMargin / 2 + _itemPosByScrollPosition(scrollPosition),
child: BottomBarActiveItem(
i,
itemWidget: widget.bottomBarItems[i].activeItem,
scrollPosition: scrollPosition,
onTap: widget.onTap,
kIconSize: widget.kIconSize,
),
child: Opacity(
opacity: widget.showBlurBottomBar ? widget.blurOpacity : 1,
child: CustomPaint(
size: Size(_screenWidth, height),
painter: BottomBarPainter(
position: _itemPosByScrollPosition(scrollPosition),
color: widget.color,
showShadow: widget.showShadow,
notchColor: widget.notchColor,
shader: widget.notchShader,
shadowElevation: widget.shadowElevation,
kBottomRadius: widget.kBottomRadius),
),
),
if (i != currentIndex)
Positioned(
top: kMargin + (kHeight - kCircleRadius * 2) / 2,
left: kCircleMargin + _itemPosByIndex(i),
child: BottomBarInActiveItem(
i,
itemWidget: widget.bottomBarItems[i].inActiveItem,
label: widget.bottomBarItems[i].itemLabel,
onTap: (selectedIndex) {
widget.notchBottomBarController.jumpTo(selectedIndex);
widget.onTap.call(selectedIndex);
},
showLabel: widget.showLabel,
labelStyle: widget.itemLabelStyle,
kIconSize: widget.kIconSize,
),
),
for (var i = 0; i < widget.bottomBarItems.length; i++) ...[
if (i == currentIndex && (_animationController.value == 1.0 || _isInitial))
Positioned(
top: widget.removeMargins ? -kCircleMargin / 2 : kTopMargin,
left: kCircleRadius - kCircleMargin / 2 + _itemPosByScrollPosition(scrollPosition),
child: BottomBarActiveItem(
i,
itemWidget: widget.bottomBarItems[i].activeItem,
scrollPosition: scrollPosition,
onTap: widget.onTap,
kIconSize: widget.kIconSize,
),
),
if (i != currentIndex)
Positioned(
top: kMargin + (kHeight - kCircleRadius * 2) / 2,
left: kCircleMargin + _itemPosByIndex(i),
child: BottomBarInActiveItem(
i,
itemWidget: widget.bottomBarItems[i].inActiveItem,
label: widget.bottomBarItems[i].itemLabel,
onTap: (selectedIndex) {
widget.notchBottomBarController.jumpTo(selectedIndex);
widget.onTap.call(selectedIndex);
},
showLabel: widget.showLabel,
labelStyle: widget.itemLabelStyle,
kIconSize: widget.kIconSize,
),
),
],
],
),
),
);
},
),
);
],
],
),
),
);
},
);
}

double _firstItemPosition(double spaceParameter) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: animated_notch_bottom_bar
description: This package helps you to achieve animated notch bottom navigation bar with any widget as children.
version: 1.0.1
version: 1.0.2
repository : https://github.com/Mindinventory/animated_notch_bottom_bar
issue_tracker: https://github.com/Mindinventory/animated_notch_bottom_bar/issues

Expand Down

0 comments on commit 73e68ad

Please sign in to comment.