-
-
Save MarcinusX/45236d93303d11405e3d97b4062014fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
@override | |
Widget build(BuildContext context) { | |
return GestureDetector( | |
behavior: HitTestBehavior.translucent, | |
onTapDown: _onTapDown, | |
child: Stack( | |
children: <Widget>[ | |
_drawPersonImage(), | |
_drawSlider(), | |
_drawLabels(), | |
], | |
), | |
); | |
} | |
_onTapDown(TapDownDetails tapDownDetails) { | |
int height = _globalOffsetToHeight(tapDownDetails.globalPosition); | |
widget.onChange(_normalizeHeight(height)); | |
} | |
int _normalizeHeight(int height) { | |
return math.max(widget.minHeight, math.min(widget.maxHeight, height)); | |
} | |
int _globalOffsetToHeight(Offset globalOffset) { | |
RenderBox getBox = context.findRenderObject(); | |
Offset localPosition = getBox.globalToLocal(globalOffset); | |
double dy = localPosition.dy; | |
dy = dy - marginTopAdapted(context) - labelsFontSize / 2; | |
int height = widget.maxHeight - (dy ~/ _pixelsPerUnit); | |
return height; | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment