From 3501aed0c9fee20d31e32d586c8435c197bf3d64 Mon Sep 17 00:00:00 2001 From: Micah Morrison Date: Mon, 24 Jul 2023 00:48:53 -0400 Subject: [PATCH] Minor dismissible tweak --- lib/community/widgets/post_card.dart | 152 +++++++++++++-------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/lib/community/widgets/post_card.dart b/lib/community/widgets/post_card.dart index ca5d65b49..c8a1f7847 100644 --- a/lib/community/widgets/post_card.dart +++ b/lib/community/widgets/post_card.dart @@ -103,83 +103,83 @@ class _PostCardState extends State { } }, onPointerCancel: (event) => {}, - child: Dismissible( - direction: state.enablePostGestures == false ? DismissDirection.none : determinePostSwipeDirection(isUserLoggedIn, state), - key: ObjectKey(widget.postViewMedia.postView.post.id), - resizeDuration: Duration.zero, - dismissThresholds: const {DismissDirection.endToStart: 1, DismissDirection.startToEnd: 1}, - confirmDismiss: (DismissDirection direction) async { - return false; - }, - onUpdate: (DismissUpdateDetails details) { - SwipeAction? updatedSwipeAction; + child: Column( + children: [ + Divider( + height: 1.0, + thickness: 4.0, + color: ElevationOverlay.applySurfaceTint( + Theme.of(context).colorScheme.surface, + Theme.of(context).colorScheme.surfaceTint, + 10, + ), + ), + Dismissible( + direction: state.enablePostGestures == false ? DismissDirection.none : determinePostSwipeDirection(isUserLoggedIn, state), + key: ObjectKey(widget.postViewMedia.postView.post.id), + resizeDuration: Duration.zero, + dismissThresholds: const {DismissDirection.endToStart: 1, DismissDirection.startToEnd: 1}, + confirmDismiss: (DismissDirection direction) async { + return false; + }, + onUpdate: (DismissUpdateDetails details) { + SwipeAction? updatedSwipeAction; - if (details.progress > firstActionThreshold && details.progress < secondActionThreshold && details.direction == DismissDirection.startToEnd) { - updatedSwipeAction = state.leftPrimaryPostGesture; - if (updatedSwipeAction != swipeAction) HapticFeedback.mediumImpact(); - } else if (details.progress > secondActionThreshold && details.direction == DismissDirection.startToEnd) { - if (state.leftSecondaryPostGesture != SwipeAction.none) { - updatedSwipeAction = state.leftSecondaryPostGesture; - } else { - updatedSwipeAction = state.leftPrimaryPostGesture; - } - if (updatedSwipeAction != swipeAction) HapticFeedback.mediumImpact(); - } else if (details.progress > firstActionThreshold && details.progress < secondActionThreshold && details.direction == DismissDirection.endToStart) { - updatedSwipeAction = state.rightPrimaryPostGesture; - if (updatedSwipeAction != swipeAction) HapticFeedback.mediumImpact(); - } else if (details.progress > secondActionThreshold && details.direction == DismissDirection.endToStart) { - if (state.rightSecondaryPostGesture != SwipeAction.none) { - updatedSwipeAction = state.rightSecondaryPostGesture; - } else { - updatedSwipeAction = state.rightPrimaryPostGesture; - } + if (details.progress > firstActionThreshold && details.progress < secondActionThreshold && details.direction == DismissDirection.startToEnd) { + updatedSwipeAction = state.leftPrimaryPostGesture; + if (updatedSwipeAction != swipeAction) HapticFeedback.mediumImpact(); + } else if (details.progress > secondActionThreshold && details.direction == DismissDirection.startToEnd) { + if (state.leftSecondaryPostGesture != SwipeAction.none) { + updatedSwipeAction = state.leftSecondaryPostGesture; + } else { + updatedSwipeAction = state.leftPrimaryPostGesture; + } + if (updatedSwipeAction != swipeAction) HapticFeedback.mediumImpact(); + } else if (details.progress > firstActionThreshold && details.progress < secondActionThreshold && details.direction == DismissDirection.endToStart) { + updatedSwipeAction = state.rightPrimaryPostGesture; + if (updatedSwipeAction != swipeAction) HapticFeedback.mediumImpact(); + } else if (details.progress > secondActionThreshold && details.direction == DismissDirection.endToStart) { + if (state.rightSecondaryPostGesture != SwipeAction.none) { + updatedSwipeAction = state.rightSecondaryPostGesture; + } else { + updatedSwipeAction = state.rightPrimaryPostGesture; + } - if (updatedSwipeAction != swipeAction) HapticFeedback.mediumImpact(); - } else { - updatedSwipeAction = null; - } + if (updatedSwipeAction != swipeAction) HapticFeedback.mediumImpact(); + } else { + updatedSwipeAction = null; + } - setState(() { - dismissThreshold = details.progress; - dismissDirection = details.direction; - swipeAction = updatedSwipeAction; - }); - }, - background: dismissDirection == DismissDirection.startToEnd - ? AnimatedContainer( - alignment: Alignment.centerLeft, - color: swipeAction == null - ? getSwipeActionColor(state.leftPrimaryPostGesture).withOpacity(dismissThreshold / firstActionThreshold) - : getSwipeActionColor(swipeAction ?? SwipeAction.none), - duration: const Duration(milliseconds: 200), - child: SizedBox( - width: MediaQuery.of(context).size.width * (state.tabletMode ? 0.5 : 1) * dismissThreshold, - child: swipeAction == null ? Container() : Icon(getSwipeActionIcon(swipeAction ?? SwipeAction.none, read: read)), - ), - ) - : AnimatedContainer( - alignment: Alignment.centerRight, - color: swipeAction == null - ? getSwipeActionColor(state.rightPrimaryPostGesture).withOpacity(dismissThreshold / firstActionThreshold) - : getSwipeActionColor(swipeAction ?? SwipeAction.none), - duration: const Duration(milliseconds: 200), - child: SizedBox( - width: (MediaQuery.of(context).size.width * (state.tabletMode ? 0.5 : 1)) * dismissThreshold, - child: swipeAction == null ? Container() : Icon(getSwipeActionIcon(swipeAction ?? SwipeAction.none, read: read)), - ), - ), - child: Column( - children: [ - Divider( - height: 1.0, - thickness: 4.0, - color: ElevationOverlay.applySurfaceTint( - Theme.of(context).colorScheme.surface, - Theme.of(context).colorScheme.surfaceTint, - 10, - ), - ), - InkWell( + setState(() { + dismissThreshold = details.progress; + dismissDirection = details.direction; + swipeAction = updatedSwipeAction; + }); + }, + background: dismissDirection == DismissDirection.startToEnd + ? AnimatedContainer( + alignment: Alignment.centerLeft, + color: swipeAction == null + ? getSwipeActionColor(state.leftPrimaryPostGesture).withOpacity(dismissThreshold / firstActionThreshold) + : getSwipeActionColor(swipeAction ?? SwipeAction.none), + duration: const Duration(milliseconds: 200), + child: SizedBox( + width: MediaQuery.of(context).size.width * (state.tabletMode ? 0.5 : 1) * dismissThreshold, + child: swipeAction == null ? Container() : Icon(getSwipeActionIcon(swipeAction ?? SwipeAction.none, read: read)), + ), + ) + : AnimatedContainer( + alignment: Alignment.centerRight, + color: swipeAction == null + ? getSwipeActionColor(state.rightPrimaryPostGesture).withOpacity(dismissThreshold / firstActionThreshold) + : getSwipeActionColor(swipeAction ?? SwipeAction.none), + duration: const Duration(milliseconds: 200), + child: SizedBox( + width: (MediaQuery.of(context).size.width * (state.tabletMode ? 0.5 : 1)) * dismissThreshold, + child: swipeAction == null ? Container() : Icon(getSwipeActionIcon(swipeAction ?? SwipeAction.none, read: read)), + ), + ), + child: InkWell( child: state.useCompactView ? PostCardViewCompact( postViewMedia: widget.postViewMedia, @@ -261,8 +261,8 @@ class _PostCardState extends State { if (context.mounted) context.read().add(ForceRefreshEvent()); }, ), - ], - ), + ), + ], ), ), );