Skip to content

Commit

Permalink
refactor: Simplify navigation button and parent link interactions by …
Browse files Browse the repository at this point in the history
…removing unnecessary cancellation logic
  • Loading branch information
Losses committed Dec 22, 2024
1 parent e26250b commit 617eb18
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 64 deletions.
30 changes: 9 additions & 21 deletions lib/widgets/navigation_bar/navigation_back_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class NavigationBackButton extends StatefulWidget {
class _NavigationBackButtonState extends State<NavigationBackButton> {
final FocusNode _focusNode = FocusNode(debugLabel: 'Back Button');

bool _cancelled = false;

@override
void dispose() {
_focusNode.dispose();
Expand All @@ -39,25 +37,15 @@ class _NavigationBackButtonState extends State<NavigationBackButton> {
return AxPressure(
child: HoverOpacity(
child: Listener(
onPointerUp: (_) {
if (_cancelled) {
_cancelled = false;
return;
}

navigateBackwardWithPop();
},
child: GestureDetector(
onPanStart: (_) => _cancelled = true,
child: FocusableActionDetector(
focusNode: _focusNode,
child: SvgPicture.asset(
'assets/arrow-circle-left-solid.svg',
width: 56,
colorFilter: ColorFilter.mode(
FluentTheme.of(context).inactiveColor,
BlendMode.srcIn,
),
onPointerUp: (_) => navigateBackwardWithPop(),
child: FocusableActionDetector(
focusNode: _focusNode,
child: SvgPicture.asset(
'assets/arrow-circle-left-solid.svg',
width: 56,
colorFilter: ColorFilter.mode(
FluentTheme.of(context).inactiveColor,
BlendMode.srcIn,
),
),
),
Expand Down
52 changes: 20 additions & 32 deletions lib/widgets/navigation_bar/parent_link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class ParentLinkState extends State<ParentLink> {
double _alpha = 80;
bool _isFocus = false;

bool _cancelled = false;

final FocusNode _focusNode = FocusNode(debugLabel: 'Parent Link');

@override
Expand Down Expand Up @@ -52,36 +50,26 @@ class ParentLinkState extends State<ParentLink> {
return Padding(
padding: const EdgeInsets.only(right: 12),
child: Listener(
onPointerUp: (_) {
if (_cancelled) {
_cancelled = false;
return;
}

widget.onPressed();
},
child: GestureDetector(
onPanStart: (_) => _cancelled = true,
child: FocusableActionDetector(
focusNode: _focusNode,
onShowFocusHighlight: _handleFocusHighlight,
onShowHoverHighlight: _handleHoverHighlight,
actions: {
ActivateIntent: ActivateLinkAction(context, widget.onPressed),
},
child: SizedBox(
height: 80,
width: 320,
child: FlipText(
key: Key(widget.titleFlipKey),
flipKey: widget.titleFlipKey,
text: widget.text,
scale: 5,
alpha: _isFocus ? 255 : _alpha,
color: _isFocus ? accentColor : null,
glowColor: accentColor,
glowRadius: _isFocus ? 10 : 0,
),
onPointerUp: (_) => widget.onPressed(),
child: FocusableActionDetector(
focusNode: _focusNode,
onShowFocusHighlight: _handleFocusHighlight,
onShowHoverHighlight: _handleHoverHighlight,
actions: {
ActivateIntent: ActivateLinkAction(context, widget.onPressed),
},
child: SizedBox(
height: 80,
width: 320,
child: FlipText(
key: Key(widget.titleFlipKey),
flipKey: widget.titleFlipKey,
text: widget.text,
scale: 5,
alpha: _isFocus ? 255 : _alpha,
color: _isFocus ? accentColor : null,
glowColor: accentColor,
glowRadius: _isFocus ? 10 : 0,
),
),
),
Expand Down
21 changes: 10 additions & 11 deletions lib/widgets/title_bar/drag_move_window_area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class DragMoveWindowArea extends StatelessWidget {
final Widget? child;
final bool isEnabledDoubleTap;

const DragMoveWindowArea({super.key, this.child, this.isEnabledDoubleTap = true});
const DragMoveWindowArea(
{super.key, this.child, this.isEnabledDoubleTap = true});

@override
Widget build(BuildContext context) {
Expand All @@ -29,16 +30,14 @@ class DragMoveWindowArea extends StatelessWidget {

return Listener(
onPointerUp: (_) => isEnabledDoubleTap ? handleTap() : null,
child: GestureDetector(
onPanStart: (_) => appWindow.startDragging(),
child: SizedBox(
width: double.infinity,
height: double.infinity,
child: SizedBox.expand(
child: Container(
color: Colors.transparent,
child: child,
),
onPointerMove: (_) => appWindow.startDragging(),
child: SizedBox(
width: double.infinity,
height: double.infinity,
child: SizedBox.expand(
child: Container(
color: Colors.transparent,
child: child,
),
),
),
Expand Down

0 comments on commit 617eb18

Please sign in to comment.