Skip to content

Commit

Permalink
Close top bar space selection on outside click (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-radhika-s authored Jan 3, 2025
1 parent 62be4ae commit c5f1384
Showing 1 changed file with 15 additions and 36 deletions.
51 changes: 15 additions & 36 deletions app/lib/ui/flow/home/components/home_top_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class _HomeTopBarState extends State<HomeTopBar> with TickerProviderStateMixin {

late AnimationController _animationController;
late Animation<double> _animation;
late AnimationController _buttonController;

@override
void initState() {
Expand All @@ -54,12 +53,6 @@ class _HomeTopBarState extends State<HomeTopBar> with TickerProviderStateMixin {
duration: const Duration(milliseconds: 150),
);

_buttonController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 300),
upperBound: 0.5,
);

_animation = CurvedAnimation(
parent: _animationController,
curve: Curves.easeInOut,
Expand All @@ -69,7 +62,6 @@ class _HomeTopBarState extends State<HomeTopBar> with TickerProviderStateMixin {
@override
void dispose() {
_animationController.dispose();
_buttonController.dispose();
super.dispose();
}

Expand All @@ -81,21 +73,16 @@ class _HomeTopBarState extends State<HomeTopBar> with TickerProviderStateMixin {
}
}

void performArrowButtonAnimation() {
if (expand) {
_buttonController.reverse(from: 0.5);
} else {
_buttonController.forward(from: 0.0);
}
}

@override
Widget build(BuildContext context) {
return _body(context);
}

Widget _body(BuildContext context) {
return _topBar(context);
return TapRegion(
onTapOutside: (tap) {
setState(() {
expand = false;
performAnimation();
});
},
child: _topBar(context));
}

Widget _topBar(BuildContext context) {
Expand Down Expand Up @@ -185,7 +172,6 @@ class _HomeTopBarState extends State<HomeTopBar> with TickerProviderStateMixin {
setState(() {
expand = !expand;
performAnimation();
performArrowButtonAnimation();
});
},
child: Container(
Expand Down Expand Up @@ -217,9 +203,8 @@ class _HomeTopBarState extends State<HomeTopBar> with TickerProviderStateMixin {
const AppProgressIndicator(
size: AppProgressIndicatorSize.small)
] else ...[
RotationTransition(
turns:
Tween(begin: 0.0, end: 1.0).animate(_buttonController),
Transform.rotate(
angle: expand ? 0 : 3.14,
child: Icon(
Icons.keyboard_arrow_up_rounded,
color: context.colorScheme.textPrimary,
Expand Down Expand Up @@ -272,16 +257,11 @@ class _HomeTopBarState extends State<HomeTopBar> with TickerProviderStateMixin {
final space = entry.value;
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: GestureDetector(
onTap: () {
widget.onSpaceItemTap(space);
},
child: _spaceListItem(
context,
space,
index,
widget.selectedSpace?.space.id == space.space.id,
),
child: _spaceListItem(
context,
space,
index,
widget.selectedSpace?.space.id == space.space.id,
),
);
}).toList(),
Expand All @@ -308,7 +288,6 @@ class _HomeTopBarState extends State<HomeTopBar> with TickerProviderStateMixin {
widget.onSpaceItemTap(space);
expand = false;
performAnimation();
performArrowButtonAnimation();
});
},
child: Container(
Expand Down

0 comments on commit c5f1384

Please sign in to comment.