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

Add gestureRecognizers to ModelViewer. #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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: 16 additions & 1 deletion lib/src/model_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'dart:io'
show File, HttpRequest, HttpServer, HttpStatus, InternetAddress, Platform;
import 'dart:typed_data' show Uint8List;

import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:flutter_android/android_content.dart' as android_content;
Expand All @@ -28,7 +30,8 @@ class ModelViewer extends StatefulWidget {
this.autoRotateDelay,
this.autoPlay,
this.cameraControls,
this.iosSrc})
this.iosSrc,
this.gestureRecognizers})
: super(key: key);

/// The background color for the model viewer.
Expand Down Expand Up @@ -84,6 +87,17 @@ class ModelViewer extends StatefulWidget {
/// The URL to a USDZ model which will be used on supported iOS 12+ devices
/// via AR Quick Look.
final String iosSrc;

/// Which gestures should be consumed by the web view.
///
/// It is possible for other gesture recognizers to be competing with the web view on pointer
/// events, e.g if the web view is inside a [ListView] the [ListView] will want to handle
/// vertical drags. The web view will claim gestures that are recognized by any of the
/// recognizers on this list.
///
/// When this set is empty or null, the web view will only handle pointer events for gestures that
/// were not claimed by any other gesture recognizer.
final Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers;

@override
State<ModelViewer> createState() => _ModelViewerState();
Expand Down Expand Up @@ -122,6 +136,7 @@ class _ModelViewerState extends State<ModelViewer> {
initialUrl: null,
javascriptMode: JavascriptMode.unrestricted,
initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow,
gestureRecognizers: widget.gestureRecognizers,
onWebViewCreated: (final WebViewController webViewController) async {
_controller.complete(webViewController);
final host = _proxy.address.address;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
sdk: flutter
dogma: ^0.0.1
flutter_android: ^0.8.0
webview_flutter: ^0.3.22
webview_flutter: ^2.3.0
dev_dependencies:
flutter_test:
sdk: flutter
Expand Down