fixed some enum types mapping in parent toMap methods, added getCameraCaptureState, setCameraCaptureState, getMicrophoneCaptureState, setMicrophoneCaptureState WebView controller methods for iOS
This commit is contained in:
parent
fef47e7930
commit
060fb00368
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
- Deprecated old classes/properties/methods to make them eventually compatible with other Platforms and WebView engines.
|
- Deprecated old classes/properties/methods to make them eventually compatible with other Platforms and WebView engines.
|
||||||
- Added Web support
|
- Added Web support
|
||||||
- Added `pauseAllMediaPlayback`, `setAllMediaPlaybackSuspended`, `closeAllMediaPresentations`, `requestMediaPlaybackState`, `isInFullscreen` WebView controller methods
|
- Added `pauseAllMediaPlayback`, `setAllMediaPlaybackSuspended`, `closeAllMediaPresentations`, `requestMediaPlaybackState`, `isInFullscreen`, `getCameraCaptureState`, `setCameraCaptureState`, `getMicrophoneCaptureState`, `setMicrophoneCaptureState` WebView controller methods
|
||||||
- Added `underPageBackgroundColor`, `isTextInteractionEnabled`, `isSiteSpecificQuirksModeEnabled`, `upgradeKnownHostsToHTTPS` WebView settings
|
- Added `underPageBackgroundColor`, `isTextInteractionEnabled`, `isSiteSpecificQuirksModeEnabled`, `upgradeKnownHostsToHTTPS` WebView settings
|
||||||
- Added support for `onPermissionRequest` event on iOS 15.0+
|
- Added support for `onPermissionRequest` event on iOS 15.0+
|
||||||
- Updated `getMetaThemeColor` on iOS 15.0+
|
- Updated `getMetaThemeColor` on iOS 15.0+
|
||||||
|
@ -114,7 +114,7 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
|
|||||||
InAppWebView(
|
InAppWebView(
|
||||||
key: webViewKey,
|
key: webViewKey,
|
||||||
initialUrlRequest:
|
initialUrlRequest:
|
||||||
URLRequest(url: Uri.parse('https://flutter.dev')),
|
URLRequest(url: Uri.parse('https://www.onlinemictest.com/')),
|
||||||
// initialUrlRequest:
|
// initialUrlRequest:
|
||||||
// URLRequest(url: Uri.parse(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')),
|
// URLRequest(url: Uri.parse(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')),
|
||||||
// initialFile: "assets/index.html",
|
// initialFile: "assets/index.html",
|
||||||
|
@ -603,6 +603,40 @@ public class InAppWebViewMethodHandler: FlutterMethodCallDelegate {
|
|||||||
result(false)
|
result(false)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
case "getCameraCaptureState":
|
||||||
|
if let webView = webView, #available(iOS 15.0, *) {
|
||||||
|
result(webView.cameraCaptureState.rawValue)
|
||||||
|
} else {
|
||||||
|
result(nil)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case "setCameraCaptureState":
|
||||||
|
if let webView = webView, #available(iOS 15.0, *) {
|
||||||
|
let state = WKMediaCaptureState.init(rawValue: arguments!["state"] as! Int) ?? WKMediaCaptureState.none
|
||||||
|
webView.setCameraCaptureState(state) {
|
||||||
|
result(true)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result(false)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case "getMicrophoneCaptureState":
|
||||||
|
if let webView = webView, #available(iOS 15.0, *) {
|
||||||
|
result(webView.microphoneCaptureState.rawValue)
|
||||||
|
} else {
|
||||||
|
result(nil)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case "setMicrophoneCaptureState":
|
||||||
|
if let webView = webView, #available(iOS 15.0, *) {
|
||||||
|
let state = WKMediaCaptureState.init(rawValue: arguments!["state"] as! Int) ?? WKMediaCaptureState.none
|
||||||
|
webView.setMicrophoneCaptureState(state) {
|
||||||
|
result(true)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result(false)
|
||||||
|
}
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
result(FlutterMethodNotImplemented)
|
result(FlutterMethodNotImplemented)
|
||||||
break
|
break
|
||||||
|
@ -3244,6 +3244,56 @@ class InAppWebViewController {
|
|||||||
return await _channel.invokeMethod('isInFullscreen', args);
|
return await _channel.invokeMethod('isInFullscreen', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///Returns a [MediaCaptureState] that indicates whether the webpage is using the camera to capture images or video.
|
||||||
|
///
|
||||||
|
///**NOTE for iOS**: available on iOS 15.0+.
|
||||||
|
///
|
||||||
|
///**Supported Platforms/Implementations**:
|
||||||
|
///- iOS ([Official API - WKWebView.cameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate)).
|
||||||
|
Future<MediaCaptureState?> getCameraCaptureState() async {
|
||||||
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
return MediaCaptureState.fromValue(
|
||||||
|
await _channel.invokeMethod('getCameraCaptureState', args));
|
||||||
|
}
|
||||||
|
|
||||||
|
///Changes whether the webpage is using the camera to capture images or video.
|
||||||
|
///
|
||||||
|
///**NOTE for iOS**: available on iOS 15.0+.
|
||||||
|
///
|
||||||
|
///**Supported Platforms/Implementations**:
|
||||||
|
///- iOS ([Official API - WKWebView.setCameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate)).
|
||||||
|
Future<void> setCameraCaptureState(
|
||||||
|
{required MediaCaptureState state}) async {
|
||||||
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('state', () => state.toValue());
|
||||||
|
await _channel.invokeMethod('setCameraCaptureState', args);
|
||||||
|
}
|
||||||
|
|
||||||
|
///Returns a [MediaCaptureState] that indicates whether the webpage is using the microphone to capture audio.
|
||||||
|
///
|
||||||
|
///**NOTE for iOS**: available on iOS 15.0+.
|
||||||
|
///
|
||||||
|
///**Supported Platforms/Implementations**:
|
||||||
|
///- iOS ([Official API - WKWebView.microphoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate)).
|
||||||
|
Future<MediaCaptureState?> getMicrophoneCaptureState() async {
|
||||||
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
return MediaCaptureState.fromValue(
|
||||||
|
await _channel.invokeMethod('getMicrophoneCaptureState', args));
|
||||||
|
}
|
||||||
|
|
||||||
|
///Changes whether the webpage is using the microphone to capture audio.
|
||||||
|
///
|
||||||
|
///**NOTE for iOS**: available on iOS 15.0+.
|
||||||
|
///
|
||||||
|
///**Supported Platforms/Implementations**:
|
||||||
|
///- iOS ([Official API - WKWebView.setMicrophoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate)).
|
||||||
|
Future<void> setMicrophoneCaptureState(
|
||||||
|
{required MediaCaptureState state}) async {
|
||||||
|
Map<String, dynamic> args = <String, dynamic>{};
|
||||||
|
args.putIfAbsent('state', () => state.toValue());
|
||||||
|
await _channel.invokeMethod('setMicrophoneCaptureState', args);
|
||||||
|
}
|
||||||
|
|
||||||
///Returns the iframe `id` attribute used on the Web platform.
|
///Returns the iframe `id` attribute used on the Web platform.
|
||||||
///
|
///
|
||||||
///**Supported Platforms/Implementations**:
|
///**Supported Platforms/Implementations**:
|
||||||
|
@ -143,4 +143,5 @@ export 'webview_package_info.dart';
|
|||||||
export 'webview_render_process_action.dart';
|
export 'webview_render_process_action.dart';
|
||||||
export 'window_features.dart';
|
export 'window_features.dart';
|
||||||
export 'web_resource_error.dart';
|
export 'web_resource_error.dart';
|
||||||
export 'web_resource_error_type.dart';
|
export 'web_resource_error_type.dart';
|
||||||
|
export 'media_capture_state.dart';
|
56
lib/src/types/media_capture_state.dart
Normal file
56
lib/src/types/media_capture_state.dart
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
///Class that describes whether a media device, like a camera or microphone, is currently capturing audio or video.
|
||||||
|
class MediaCaptureState {
|
||||||
|
final int _value;
|
||||||
|
|
||||||
|
const MediaCaptureState._internal(this._value);
|
||||||
|
|
||||||
|
///Set of all values of [MediaCaptureState].
|
||||||
|
static final Set<MediaCaptureState> values = [
|
||||||
|
MediaCaptureState.NONE,
|
||||||
|
MediaCaptureState.ACTIVE,
|
||||||
|
MediaCaptureState.MUTED,
|
||||||
|
].toSet();
|
||||||
|
|
||||||
|
///Gets a possible [MediaCaptureState] instance from an [int] value.
|
||||||
|
static MediaCaptureState? fromValue(int? value) {
|
||||||
|
if (value != null) {
|
||||||
|
try {
|
||||||
|
return MediaCaptureState.values
|
||||||
|
.firstWhere((element) => element.toValue() == value);
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
///Gets [int] value.
|
||||||
|
int toValue() => _value;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
switch (_value) {
|
||||||
|
case 1:
|
||||||
|
return "ACTIVE";
|
||||||
|
case 2:
|
||||||
|
return "MUTED";
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
return "NONE";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///The media device is off.
|
||||||
|
static const NONE = const MediaCaptureState._internal(0);
|
||||||
|
|
||||||
|
///The media device is actively capturing audio or video.
|
||||||
|
static const ACTIVE = const MediaCaptureState._internal(1);
|
||||||
|
|
||||||
|
///The media device is muted, and not actively capturing audio or video.
|
||||||
|
static const MUTED = const MediaCaptureState._internal(2);
|
||||||
|
|
||||||
|
bool operator ==(value) => value == _value;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => _value.hashCode;
|
||||||
|
}
|
@ -46,7 +46,7 @@ class PermissionRequest {
|
|||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
"origin": origin.toString(),
|
"origin": origin.toString(),
|
||||||
"resources": resources.map((e) => e.toValue()).toList(),
|
"resources": resources.map((e) => e.toNativeValue()).toList(),
|
||||||
"frame": frame?.toMap()
|
"frame": frame?.toMap()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ class PermissionResponse {
|
|||||||
///Converts instance to a map.
|
///Converts instance to a map.
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
"resources": resources.map((e) => e.toValue()).toList(),
|
"resources": resources.map((e) => e.toNativeValue()).toList(),
|
||||||
"action": action?.toValue()
|
"action": action?.toValue()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -47,11 +47,11 @@ class SslError {
|
|||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
return {
|
return {
|
||||||
// ignore: deprecated_member_use_from_same_package
|
// ignore: deprecated_member_use_from_same_package
|
||||||
"androidError": code?.toValue() ?? androidError?.toValue(),
|
"androidError": code?.toNativeValue() ?? androidError?.toValue(),
|
||||||
// ignore: deprecated_member_use_from_same_package
|
// ignore: deprecated_member_use_from_same_package
|
||||||
"iosError": code?.toValue() ?? iosError?.toValue(),
|
"iosError": code?.toNativeValue() ?? iosError?.toValue(),
|
||||||
// ignore: deprecated_member_use_from_same_package
|
// ignore: deprecated_member_use_from_same_package
|
||||||
"code": code?.toValue() ?? androidError?.toValue() ?? iosError?.toValue(),
|
"code": code?.toNativeValue() ?? androidError?.toValue() ?? iosError?.toValue(),
|
||||||
"message": message,
|
"message": message,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user