Coder Social home page Coder Social logo

capawesome-team / capacitor-screen-orientation Goto Github PK

View Code? Open in Web Editor NEW
28.0 2.0 6.0 815 KB

⚡️ Capacitor plugin to lock/unlock the screen orientation.

Home Page: https://capawesome.io/plugins/screen-orientation/

License: MIT License

Ruby 4.07% Java 29.18% Swift 43.02% Objective-C 3.75% JavaScript 2.00% TypeScript 17.96%
capacitor android ios pwa web capacitor-community capacitor-plugin capawesome capacitor-android capacitor-ios

capacitor-screen-orientation's People

Contributors

dependabot[bot] avatar emiliedebra avatar robingenz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

capacitor-screen-orientation's Issues

bug:

Plugin version:
2.0.2

Platform(s):
iOS Build

Current behavior:
Build errors:

node_modules/@capawesome/capacitor-screen-orientation/ios/Plugin/ScreenOrientation.swift:62:57: value of type 'UIViewController' has no member 'setNeedsUpdateOfSupportedInterfaceOrientations'
windowScene?.keyWindow?.rootViewController?.setNeedsUpdateOfSupportedInterfaceOrientations()

node_modules/@capawesome/capacitor-screen-orientation/ios/Plugin/ScreenOrientation.swift:63:26: value of type 'UIWindowScene' has no member 'requestGeometryUpdate'
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientationMask))

node_modules/@capawesome/capacitor-screen-orientation/ios/Plugin/ScreenOrientation.swift:63:49: cannot infer contextual base in reference to member 'iOS'
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientationMask)) 

Expected behavior:
Build successfull

Other information:
Reverting to 2.0.1 builds fine

Capacitor doctor:

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 4.7.0
  @capacitor/core: 4.7.0
  @capacitor/android: 4.7.0
  @capacitor/ios: 4.7.0

Installed Dependencies:

  @capacitor/cli: 4.6.3
  @capacitor/core: 4.6.3
  @capacitor/android: 4.6.3
  @capacitor/ios: 4.6.3

[success] iOS looking great! 👌
[success] Android looking great! 👌

bug: difference in plugin behavior on iPhone and Android

Current behavior:
Plugin work perfectly on Android, but I cant get it worked on my iPhone.

No errors, just nothing happening. Promise returns empty.

AppDelegate.swift

import UIKit
import Capacitor
import RobingenzCapacitorScreenOrientation

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    return true
  }

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
    return ScreenOrientation.getSupportedInterfaceOrientations()
  }

  func applicationWillResignActive(_ application: UIApplication) {
  }

...

my.component.ts

import { ScreenOrientation, OrientationType } from '@robingenz/capacitor-screen-orientation';

...

test_lock(){
    ScreenOrientation.lock({ type: OrientationType.LANDSCAPE }).then(result=>{
      this.toastService.show({message: JSON.stringify(result)}); // <- empty
    }).catch(error=>{
      this.toastService.show({message: JSON.stringify(error), color:'danger'});
    });
}

test_unlock(){
    ScreenOrientation.unlock().then(result=>{
      this.toastService.show({message: JSON.stringify(result)}); // <- empty
    }).catch(error=>{
      this.toastService.show({message: JSON.stringify(error), color:'danger'});
    });
}

...

Capacitor doctor:

Latest Dependencies:

  @capacitor/cli: 3.1.1
  @capacitor/core: 3.1.1
  @capacitor/android: 3.1.1
  @capacitor/ios: 3.1.1

Installed Dependencies:

  @capacitor/cli: 3.0.0
  @capacitor/core: 3.0.0
  @capacitor/android: 3.0.0
  @capacitor/ios: 3.0.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

Thank you!

bug(ios): `getConfigValue` is deprecated

Platform(s):

  • iOS

Current behavior:

XCode Warning:

'getConfigValue' is deprecated: use getConfig() and access config values using the methods available depending on the type.

Expected behavior:

No warning.

Steps to reproduce:

  1. Build the plugin in XCode.

bug: faecup and facedown in ios send portrait event

Plugin version:
latest

Platform(s):
ios

Current behavior:
when listen to change horientation and phone is put horizontally on table from landscape mode, it should stay in landscape but instead the faceup event is fired .
And this is transformed to default event portrait

Expected behavior:
No event should be fired when faceup facedown or optionally

Steps to reproduce:
Add this code to one app, and then move the phone into landscape and put it horizontally on table. you will see portrait-primary in the logs

      ScreenOrientation.addListener('screenOrientationChange', async () => {
        console.log(await ScreenOrientation.getCurrentOrientation())
      })

Related code:
The issue come from this line https://github.com/robingenz/capacitor-screen-orientation/blob/a5d08ea371ca14523a56949d7cf3fcdc4d3829e7/ios/Plugin/ScreenOrientation.swift#L89

Other information:
here is the Apple doc

bug: after unlocking on iOS does not return to mode, which is relevant for the actual orientation of the device

Plugin version:
1.1.2

Capacitor 3.3.2
Ionic-Angular 5.9.3

Platform(s):
iOS

Current behavior:
On Android: The screen locks in landscape orientation, then, after unlocking, returns to portrait mode, which is relevant for the actual orientation of the device. Please look video here: https://youtu.be/RjBMZq-t48U

But on iOS, after unlocking, screen does not return to the mode that is relevant for the actual orientation of the device. Please look video here: https://youtu.be/nEbDn-zd3zA

Expected behavior:
When unlocking, screen orientation must return to the mode that is relevant for the actual orientation of the device.

Steps to reproduce:

  1. Keep your iPhone upright at all steps;
  2. Lock screen orientation to Landscape mode:

ScreenOrientation.lock({ type: OrientationType.LANDSCAPE })

  1. Unlock screen orientation:

ScreenOrientation.unlock();

Capacitor doctor:

Latest Dependencies:

  @capacitor/cli: 3.3.4
  @capacitor/core: 3.3.4
  @capacitor/android: 3.3.4
  @capacitor/ios: 3.3.4

Installed Dependencies:

  @capacitor/ios: 3.3.4
  @capacitor/cli: 3.3.4
  @capacitor/core: 3.3.4
  @capacitor/android: 3.3.4

[success] iOS looking great! 👌
[success] Android looking great! 👌

feat: add `screenOrientationChange` listener

Is your feature request related to a problem? Please describe:

Currently there is no way to get notified about an orientation change.

Describe the solution you'd like:

Add screenOrientationChange listener.

bug: iOS 16.2 bug in client of UIKIT

Plugin version:

2.0.1

Platform(s):

iOS 16.2

Current behavior:

Plugin is working but throws the following error message:

[Orientation] BUG IN CLIENT OF UIKIT: Setting UIDevice.orientation is not supported. Please use UIWindowScene.requestGeometryUpdate(_:)

Expected behavior:

No error thrown by plugin

Steps to reproduce:

Any Capacitor iOS app will do, just call ScreenOrientation.lock(...)

Related code:

None

Other information:

None

Capacitor doctor:

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 4.6.1
@capacitor/core: 4.6.1
@capacitor/android: 4.6.1
@capacitor/ios: 4.6.1

Installed Dependencies:

@capacitor/cli: 4.3.0
@capacitor/android: 4.3.0
@capacitor/core: 4.3.0
@capacitor/ios: 4.3.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

bug: `statusBarOrientation` is deprecated in iOS 13

Plugin version:
2.0.0

Platform(s):
ios

Current behavior:
The following deprecation notice is logged:

/node_modules/@capawesome/capacitor-screen-orientation/ios/Plugin/ScreenOrientation.swift:137:51: 
'statusBarOrientation' was deprecated in iOS 13.0: Use the interfaceOrientation property of the window scene instead.

Expected behavior:
The plugin should use the interfaceOrientation property instead

Steps to reproduce:
Simply install the plugin following the README instructions, and build the project for iOS 13.

Capacitor doctor:

💊   Capacitor Doctor  💊

Latest Dependencies:

  @capacitor/cli: 4.0.1
  @capacitor/core: 4.0.1
  @capacitor/android: 4.0.1
  @capacitor/ios: 4.0.1

Installed Dependencies:

  @capacitor/cli: 4.0.1
  @capacitor/core: 4.0.1
  @capacitor/android: 4.0.1
  @capacitor/ios: 4.0.1

[success] iOS looking great! 👌
[success] Android looking great! 👌

bug: wrong event emit when lock

Plugin version:
1.1.4

Platform(s):
ios

Current behavior:
when listen to screenOrientationChange and then lock in landscape, i receive portrait-primary

Expected behavior:
when locking, i should receive the orientation locked

Steps to reproduce:
use the code below in your app to see it happen

Screenshot 2022-04-13 at 16 36 28

Related code:

      ScreenOrientation.addListener('screenOrientationChange', async (res) => {
        const current = await ScreenOrientation.getCurrentOrientation()
        console.log('orientation', current, res)
      })
     ScreenOrientation.lock({ type: OrientationType.LANDSCAPE })

Other information:

Capacitor doctor:

💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 3.4.3
  @capacitor/core: 3.4.3
  @capacitor/android: 3.4.3
  @capacitor/ios: 3.4.3

Installed Dependencies:

  @capacitor/core: 3.4.3
  @capacitor/android: 3.4.3
  @capacitor/cli: 3.4.3
  @capacitor/ios: 3.4.3

[success] iOS looking great! 👌
[success] Android looking great! 👌

bug: `UI API called on a background thread`

XCode error:

2022-01-07 21:36:58.872551+0100 DEMO[358:7568] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication statusBarOrientation]
PID: 358, TID: 7568, Thread name: (none), Queue name: bridge, QoS: 0
Backtrace:
4   RobingenzCapacitorScreenOrientation 0x0000000103941cdc $s35RobingenzCapacitorScreenOrientation0cD0C07convertD11ValueToType025_574E905BD720A3E6515D11D7N6D58C20LLySSSiFTf4nd_n + 156
5   RobingenzCapacitorScreenOrientation 0x0000000103942ac4 $s35RobingenzCapacitorScreenOrientation0cD6PluginC010getCurrentD0yySo13CAPPluginCallCFTf4nd_n + 96
6   RobingenzCapacitorScreenOrientation 0x00000001039422e8 $s35RobingenzCapacitorScreenOrientation0cD6PluginC010getCurrentD0yySo13CAPPluginCallCFTo + 40
7   Capacitor                           0x0000000102f33810 $s9Capacitor0A6BridgeC12handleJSCall4callyAA0D0V_tFyycfU_ + 552
8   Capacitor                           0x0000000102f3c418 $sIeg_IeyB_TR + 20
9   libdispatch.dylib                   0x0000000103c74a20 _dispatch_call_block_and_release + 32
10  libdispatch.dylib                   0x0000000103c76700 _dispatch_client_callout + 20
11  libdispatch.dylib                   0x0000000103c7e83c _dispatch_lane_serial_drain + 952
12  libdispatch.dylib                   0x0000000103c7f558 _dispatch_lane_invoke + 428
13  libdispatch.dylib                   0x0000000103c8bfa0 _dispatch_workloop_worker_thread + 916
14  libsystem_pthread.dylib             0x00000001f1f491b0 _pthread_wqthread + 288
15  libsystem_pthread.dylib             0x00000001f1f48f50 start_wqthread + 8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.