forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[camera_platform_interface] Add platform interface methods for lockin…
…g capture orientation. (flutter#3389) * Expand platform interface to support reporting device orientation * Switch to flutter DeviceOrientation enum * Add interface methods for (un)locking the capture orientation. * Update capture orientation interfaces and add unit tests. * Made device orientation mandatory for locking capture orientation in the platform interface. * Update comment * Update comment. * Update changelog and pubspec version * Update packages/camera/camera_platform_interface/lib/src/events/device_event.dart Co-authored-by: Maurits van Beusekom <[email protected]> * Update packages/camera/camera_platform_interface/lib/src/events/device_event.dart Co-authored-by: Maurits van Beusekom <[email protected]> * Update packages/camera/camera_platform_interface/lib/src/events/device_event.dart Co-authored-by: Maurits van Beusekom <[email protected]> * Update packages/camera/camera_platform_interface/lib/src/events/device_event.dart Co-authored-by: Maurits van Beusekom <[email protected]> * Update packages/camera/camera_platform_interface/lib/src/method_channel/method_channel_camera.dart Co-authored-by: Maurits van Beusekom <[email protected]> * Update packages/camera/camera_platform_interface/lib/src/method_channel/method_channel_camera.dart Co-authored-by: Maurits van Beusekom <[email protected]> Co-authored-by: Maurits van Beusekom <[email protected]> Co-authored-by: Maurits van Beusekom <[email protected]>
- Loading branch information
1 parent
892af68
commit 3af7078
Showing
12 changed files
with
384 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
52 changes: 52 additions & 0 deletions
52
packages/camera/camera_platform_interface/lib/src/events/device_event.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:camera_platform_interface/src/utils/utils.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
/// Generic Event coming from the native side of Camera, | ||
/// not related to a specific camera module. | ||
/// | ||
/// This class is used as a base class for all the events that might be | ||
/// triggered from a device, but it is never used directly as an event type. | ||
/// | ||
/// Do NOT instantiate new events like `DeviceEvent()` directly, | ||
/// use a specific class instead: | ||
/// | ||
/// Do `class NewEvent extend DeviceEvent` when creating your own events. | ||
/// See below for examples: `DeviceOrientationChangedEvent`... | ||
/// These events are more semantic and more pleasant to use than raw generics. | ||
/// They can be (and in fact, are) filtered by the `instanceof`-operator. | ||
abstract class DeviceEvent {} | ||
|
||
/// The [DeviceOrientationChangedEvent] is fired every time the user changes the | ||
/// physical orientation of the device. | ||
class DeviceOrientationChangedEvent extends DeviceEvent { | ||
/// The new orientation of the device | ||
final DeviceOrientation orientation; | ||
|
||
/// Build a new orientation changed event. | ||
DeviceOrientationChangedEvent(this.orientation); | ||
|
||
/// Converts the supplied [Map] to an instance of the [DeviceOrientationChangedEvent] | ||
/// class. | ||
DeviceOrientationChangedEvent.fromJson(Map<String, dynamic> json) | ||
: orientation = deserializeDeviceOrientation(json['orientation']); | ||
|
||
/// Converts the [DeviceOrientationChangedEvent] instance into a [Map] instance that | ||
/// can be serialized to JSON. | ||
Map<String, dynamic> toJson() => { | ||
'orientation': serializeDeviceOrientation(orientation), | ||
}; | ||
|
||
@override | ||
bool operator ==(Object other) => | ||
identical(this, other) || | ||
other is DeviceOrientationChangedEvent && | ||
runtimeType == other.runtimeType && | ||
orientation == other.orientation; | ||
|
||
@override | ||
int get hashCode => orientation.hashCode; | ||
} |
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
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
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
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
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
Oops, something went wrong.