fix(ui): Fix sizing of the grid items
This commit is contained in:
parent
0b25c1daf3
commit
99021f2668
@ -20,6 +20,7 @@ class GridItem extends StatefulWidget {
|
|||||||
|
|
||||||
class GridItemState extends State<GridItem> {
|
class GridItemState extends State<GridItem> {
|
||||||
double _offset = 0;
|
double _offset = 0;
|
||||||
|
double _translationX = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -27,17 +28,21 @@ class GridItemState extends State<GridItem> {
|
|||||||
onHorizontalDragUpdate: (details) {
|
onHorizontalDragUpdate: (details) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_offset += details.delta.dx;
|
_offset += details.delta.dx;
|
||||||
|
_translationX = 160 / (1 + exp(-1 * (1/30) * _offset)) - 80;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onHorizontalDragEnd: (_) {
|
onHorizontalDragEnd: (_) {
|
||||||
if (_offset <= 50) {
|
if (_translationX <= -60) {
|
||||||
widget.plusCallback();
|
widget.plusCallback();
|
||||||
} else if (_offset >= -50) {
|
} else if (_translationX >= 60) {
|
||||||
widget.minusCallback();
|
widget.minusCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the view
|
// Reset the view
|
||||||
setState(() => _offset = 0);
|
setState(() {
|
||||||
|
_offset = 0;
|
||||||
|
_translationX = 0;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
@ -62,7 +67,10 @@ class GridItemState extends State<GridItem> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 160 / (1 + exp(-1 * (1/30) * _offset)) - 80,
|
left: _translationX,
|
||||||
|
right: -1 * _translationX,
|
||||||
|
bottom: 0,
|
||||||
|
top: 0,
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -2,7 +2,7 @@ name: anitrack
|
|||||||
description: An anime and manga tracker
|
description: An anime and manga tracker
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 0.1.0+4
|
version: 0.1.0+5
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.18.4 <3.0.0'
|
sdk: '>=2.18.4 <3.0.0'
|
||||||
|
Loading…
Reference in New Issue
Block a user