Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

feat Decreased double tap acceptance #138

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions lib/features/dapps/subfeatures/open_dapp/open_dapp_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class OpenAppPage extends HookConsumerWidget {
AllowMultipleHorizontalDrag>(
() => AllowMultipleHorizontalDrag(),
(AllowMultipleHorizontalDrag instance) {
instance.onDown =
(details) => presenter.detectDoubleTap();
instance.onEnd = (details) async {
final webViewController = state.webviewController!;
if (details.primaryVelocity! <
Expand All @@ -64,14 +66,6 @@ class OpenAppPage extends HookConsumerWidget {
};
},
),
AllowMultipleDoubleTap: GestureRecognizerFactoryWithHandlers<
AllowMultipleDoubleTap>(
() => AllowMultipleDoubleTap(),
(AllowMultipleDoubleTap instance) {
instance.onDoubleTap =
() => state.webviewController!.reload();
},
)
},
child: DragDownPanel(
child: InAppWebViewEIP1193(
Expand Down Expand Up @@ -169,12 +163,15 @@ class OpenAppPage extends HookConsumerWidget {
},
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
useShouldOverrideUrlLoading: true,
mediaPlaybackRequiresUserGesture: false),
useShouldOverrideUrlLoading: true,
mediaPlaybackRequiresUserGesture: false,
),
android: AndroidInAppWebViewOptions(
useWideViewPort: true,
geolocationEnabled: true,
useHybridComposition: true,
overScrollMode: AndroidOverScrollMode
.OVER_SCROLL_IF_CONTENT_SCROLLS,
),
ios: IOSInAppWebViewOptions(
allowsInlineMediaPlayback: true,
Expand Down
21 changes: 15 additions & 6 deletions lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {

final double maxPanelHeight = 100.0;

final cancelDuration = const Duration(milliseconds: 300);
final cancelDuration = const Duration(milliseconds: 400);
final settleDuration = const Duration(milliseconds: 400);

void handleScroll(double scroll) {
Expand All @@ -569,10 +569,6 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
1.0,
duration: settleDuration,
);
// await Future.delayed(
// const Duration(seconds: 5),
// () => hidePanel(),
// );
}
}

Expand All @@ -583,7 +579,7 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
await state.animationController!.animateTo(
0.0,
duration: cancelDuration,
curve: Curves.ease,
curve: Curves.easeInExpo,
);
}
}
Expand All @@ -602,4 +598,17 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
void showNetworkDetailsBottomSheet() {
showNetworkDetailsDialog(context!, network: state.network!);
}

void detectDoubleTap() {
final now = DateTime.now();
final difference = now.difference(doubleTapTime);

if (difference.inMilliseconds > Config.dAppDoubleTapLowerBound &&
difference.inMilliseconds < Config.dAppDoubleTapUpperBound) {
state.webviewController!.reload();
resetDoubleTapTime();
} else {
resetDoubleTapTime();
}
}
}
2 changes: 1 addition & 1 deletion packages/shared
Loading