Files
ux/darwin/Camera/DeviceOrientation.swift
agra d68a2978eb ux: bulk WIP — UxPlugin→XPlugin rename + new anim/core/navi/reactive packages
Catch-all commit for outstanding pre-existing local changes. Mixes
several themes that would normally be split:

- Rename: UxPlugin → XPlugin across iOS, macOS, Android registrants.
- New top-level packages under lib/src/: anim/ (animated values,
  panes, sheets, dock, measured), core/ (Emitter, ReactiveBuilder
  scaffolding, presenter/widget/value/dispose primitives), navi/
  (Screen/ScreenStack/Router/hero/transitions), reactive/.
- Edits across existing plugins (clipboard, crash, file, gallery,
  keyboard, scanner, sensor, url) to align with the new core.
- Test updates and CHANGELOG/README touches accompanying the above.
2026-05-21 08:58:07 +03:00

38 lines
1.6 KiB
Swift

import AVFoundation
/// Mirrors Flutter's `DeviceOrientation` the four cardinal values
/// that travel over the `ux/camera` channel as wire strings. `public`
/// so the host app's XCTest target can verify the
/// `DeviceOrientationFlutter` / `AVCaptureVideoOrientation` mapping
/// without `@testable import`.
///
/// The enum is platform-shared; the listener that turns physical
/// rotation into a stream of these values is platform-specific
/// see `ios/Classes/Camera/DeviceOrientationBridge.swift` for the
/// iOS implementation and `macos/Classes/Camera/DeviceOrientationBridge.swift`
/// for the macOS one (no-op; desktops don't rotate).
public enum DeviceOrientationFlutter: String {
case portraitUp
case landscapeLeft
case portraitDown
case landscapeRight
/// Parse a wire string. Returns `.portraitUp` for unknown inputs
/// (matches the Dart-side fallback in `MethodChannelXCameraBackend`).
public static func parse(_ raw: String?) -> DeviceOrientationFlutter {
return DeviceOrientationFlutter(rawValue: raw ?? "") ?? .portraitUp
}
/// AVFoundation video orientation. Translates Flutter's portrait-
/// relative convention to AVFoundation's hardware-relative one.
/// Used to drive `AVCaptureConnection.videoOrientation`.
public var avVideoOrientation: AVCaptureVideoOrientation {
switch self {
case .portraitUp: return .portrait
case .portraitDown: return .portraitUpsideDown
case .landscapeLeft: return .landscapeRight
case .landscapeRight: return .landscapeLeft
}
}
}