Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GestureDetector drag down on mobile call (#44) #45

Merged
merged 13 commits into from
Jul 27, 2022
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ All user visible changes to this project will be documented in this file. This p
- Missing avatars in group creation popup ([#15], [#2]).
- Home page:
- Horizontal scroll overlapping with vertical ([#42], [#41]).
- Media panel:
- Mobile minimization gesture being too rapid ([#45], [#44]).

[#2]: /../../issues/2
[#4]: /../../issues/4
Expand All @@ -50,6 +52,8 @@ All user visible changes to this project will be documented in this file. This p
[#34]: /../../pull/34
[#41]: /../../issues/41
[#42]: /../../pull/42
[#44]: /../../issues/44
[#45]: /../../pull/45



Expand Down
27 changes: 24 additions & 3 deletions lib/ui/page/call/widget/minimizable_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class MinimizableView extends StatefulWidget {
Key? key,
this.onInit,
this.onDispose,
this.minimizationDelta = 50,
required this.child,
}) : super(key: key);

Expand All @@ -34,6 +35,10 @@ class MinimizableView extends StatefulWidget {
/// Callback, called when the state of this [MinimizableView] is disposed.
final void Function()? onDispose;

/// Distance to travel in order for the panning to be recognized as a
/// minimization gesture.
final double minimizationDelta;

/// [Widget] to minimize.
final Widget child;

Expand Down Expand Up @@ -78,6 +83,9 @@ class _MinimizableViewState extends State<MinimizableView>
/// View padding of the screen.
EdgeInsets _padding = EdgeInsets.zero;

/// Current panning distance.
double _panningDistance = 0;

/// [DecorationTween] of this view.
final DecorationTween _decorationTween = DecorationTween(
begin: const BoxDecoration(borderRadius: BorderRadius.zero),
Expand Down Expand Up @@ -150,9 +158,18 @@ class _MinimizableViewState extends State<MinimizableView>
}
: null,
onPanUpdate: (d) {
_panningDistance = _panningDistance + d.delta.dy;

if (_panningDistance < widget.minimizationDelta &&
_controller.value == 0) {
return;
}

if (_drag != null && _value != null) {
_controller.value = _value! +
(d.localPosition.dy - _drag!.dy) *
(d.localPosition.dy -
_drag!.dy -
widget.minimizationDelta) *
(1 / constraints.maxHeight);
} else {
setState(() {
Expand All @@ -170,8 +187,12 @@ class _MinimizableViewState extends State<MinimizableView>
setState(() {});
}
: null,
onPanEnd:
_drag != null && _value != null ? _onVerticalDragEnd : null,
onPanEnd: (d) {
if (_drag != null && _value != null) {
_onVerticalDragEnd(d);
}
_panningDistance = 0;
},
child: DecoratedBoxTransition(
key: _key,
decoration: _decorationTween.animate(_controller),
Expand Down
26 changes: 21 additions & 5 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -758,19 +758,35 @@ packages:
image_picker:
dependency: "direct main"
description:
path: "packages/image_picker/image_picker"
ref: main
resolved-ref: "597f9c8a8f34068207e25a0e9bbe13f781c68a2e"
url: "https://github.com/krida2000/image_picker"
path: "."
ref: HEAD
resolved-ref: a9744e87ea76884b6f77e184378007ca2a0db80d
url: "https://github.com/krida2000/image_picker.git"
source: git
version: "0.8.4+11"
version: "0.8.5+3"
image_picker_android:
dependency: transitive
description:
name: image_picker_android
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.5+1"
image_picker_for_web:
dependency: transitive
description:
name: image_picker_for_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.8"
image_picker_ios:
dependency: transitive
description:
path: "."
ref: HEAD
resolved-ref: "7e5052a2c1b050234c150df74c7641c95e441a09"
url: "https://github.com/krida2000/image_picker_ios.git"
source: git
version: "0.8.5+6"
image_picker_platform_interface:
dependency: transitive
description:
Expand Down
4 changes: 1 addition & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ dependencies:
http_parser: ^4.0.0
image_picker:
git:
url: https://github.com/krida2000/image_picker
ref: main
path: packages/image_picker/image_picker/
url: https://github.com/krida2000/image_picker.git
intl: ^0.17.0
js: ^0.6.4
material_floating_search_bar: ^0.3.7
Expand Down