From 99021f2668a30599842760d4e35ecbb268e222b4 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Thu, 9 Feb 2023 12:29:22 +0100 Subject: [PATCH] fix(ui): Fix sizing of the grid items --- lib/src/ui/widgets/grid_item.dart | 16 ++++++++++++---- pubspec.yaml | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/src/ui/widgets/grid_item.dart b/lib/src/ui/widgets/grid_item.dart index 91e5e65..0985292 100644 --- a/lib/src/ui/widgets/grid_item.dart +++ b/lib/src/ui/widgets/grid_item.dart @@ -20,6 +20,7 @@ class GridItem extends StatefulWidget { class GridItemState extends State { double _offset = 0; + double _translationX = 0; @override Widget build(BuildContext context) { @@ -27,17 +28,21 @@ class GridItemState extends State { onHorizontalDragUpdate: (details) { setState(() { _offset += details.delta.dx; + _translationX = 160 / (1 + exp(-1 * (1/30) * _offset)) - 80; }); }, onHorizontalDragEnd: (_) { - if (_offset <= 50) { + if (_translationX <= -60) { widget.plusCallback(); - } else if (_offset >= -50) { + } else if (_translationX >= 60) { widget.minusCallback(); } // Reset the view - setState(() => _offset = 0); + setState(() { + _offset = 0; + _translationX = 0; + }); }, child: Stack( children: [ @@ -62,7 +67,10 @@ class GridItemState extends State { ), ), Positioned( - left: 160 / (1 + exp(-1 * (1/30) * _offset)) - 80, + left: _translationX, + right: -1 * _translationX, + bottom: 0, + top: 0, child: widget.child, ), ], diff --git a/pubspec.yaml b/pubspec.yaml index c5c2c44..5cf6f41 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: anitrack description: An anime and manga tracker publish_to: 'none' -version: 0.1.0+4 +version: 0.1.0+5 environment: sdk: '>=2.18.4 <3.0.0'