Giter Site home page Giter Site logo

kkjdaniel / react-native-device-display Goto Github PK

View Code? Open in Web Editor NEW
108.0 11.0 26.0 42 KB

๐Ÿ“ฒ Create dynamic views through device, display and orientation detection (DEPRECATED)

License: BSD 2-Clause "Simplified" License

JavaScript 57.56% Objective-C 42.44%
orientation-changes universal-apps react-native device-detection

react-native-device-display's People

Contributors

albertwchang avatar dsibiski avatar eliagrady avatar jdeal avatar kkjdaniel avatar natorojr 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-device-display's Issues

NPM Updates on Dimensions import issue

Hi, when i do npm install on react-native-device-display, i still get the old codes:

var { NativeModules } = require('react-native');

var DeviceUtil = NativeModules.DisplayDeviceUtil;
var Dimensions = require('Dimensions');
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');

Which displays the Module not found error. But i can see that this is fixed on Github copy but i'm not getting the update whenever i npm install.

FIX Code:


var {
Dimensions,
RCTDeviceEventEmitter,
NativeModules
} = require('react-native');

var DeviceUtil = NativeModules.DisplayDeviceUtil;

Thanks.

Is orientation worked for a build product-apk

Hi all
I tried the same thing for a react-native android application. Its took the value of the screen width, height using Dimension when I reload the js otherwise this orientation (width, height changing) not worked. Can you help me to fix this issue

Thank you

Support newest versions of React Native

I've seen your last commit, but while using React Native 0.7.1 & 0..8.0.rc.2 are giving me errors installing your module. Could you alter your peerDepedencies less strict, while now I cannot use (without hassle) your module in the new updates of React Native. Could you update like react-native-icons has done for example:

"peerdependencies" : {
    "react-native": ">=0.6.0 <1.0.0"
}

Thanks!

Submitting a pull request

Forgive me if this question is stupid, but I am wondering how I can update my forked version to the current version of this repo. My fork is currently @1.0.0, and I want to create a pull request from my base , and submit it to kkdaniel's master branch.

Please advise. Thanks. -Albert

Missing tag for master

currently the tag for the master is missing and if you follow the documentation and run

npm install react-native-device-display

You will get a different version from the latest release.

P.S: temporary solution for those who are facing this issue:
Use following in your package.json
"react-native-device-display": "kkjdaniel/react-native-device-display#master",

Potential bug in the JS orientation predicates

The Display class will return false from both isPortrait and isLandscape in case the application frame is square (i.e. width == height).
Although application frame can not be square today, who know what new split-screen modes Apple is planning for future iOS releases.

Suggested solution: either isPortrait or isLandscape should change the condition to <=.

Flipping Around Breaks This

This doesn't appear to work.

I start in portrait > 667 x 375

I rotate to landscape > 667 x375

I keep going in circle (rotate same way) to portrait > 375 x 667

I rotate again to landscape > 667 x 375

It is not reporting the proper values.

[UIScreen applicationFrame] is deprecated on iOS 9.0

Beside that using the screen dimensions is no longer proper to determine the application frame size since on iPad the app might be in split-screen mode. In order to determine the application frame one should get the frame of the application's key window.

React Native Android Support

Add support for React Native Android:

  • Percentage
  • isTablet
  • isPhone
  • isPortrait
  • isLandscape
  • onOrientationDidChange Event
  • Width & Height Properties

Seems to be incompatible with React Native 0.14.x and 0.13.x

I recently upgraded my app to React Native 0.14.x and react-native-device-display is causing the following errors to show up in the console:

2015-11-16 23:40:17.179 [error][tid:main][RCTBatchedBridge.m:436] Error while loading: Unable to resolve module Dimensions from /Users/XXX/XXX/XXX/node_modules/react-native-device-display/display.js: Invalid directory /Users/node_modules/Dimensions

screen shot 2015-11-16 at 11 40 25 pm

Fixed Bugs and Made Changes

Hey, I know there is some official means of doing this but I'm not familiar with git really...

Anyway I made some changes I think are pretty good including the bug fix mentioned in previous

   UIDeviceOrientation deviceOrientation = [[UIDevice currentDevice] orientation];
   NSDictionary *dimensions = @{ @"width": @(frameSize.width), @"height": @(frameSize.height),      @"orientation": @(deviceOrientation) };
   NSLog(@"%@", dimensions);
   [_bridge.eventDispatcher sendDeviceEventWithName:@"orientationDidChange" body:dimensions];

I now include the actual device orientation in the dictionary. I also fixed the issue with sending the wrong width / height (it was flipped around).

Then I receive the orientation in the event receiver and parse it. I also send the new data in the handler.

 onOrientationDidChange(handler) {
     var main = this;
     return RCTDeviceEventEmitter.addListener(
       'orientationDidChange',
       function(newDimensions) {
         main.updateProps(newDimensions.width, newDimensions.height);
         var orientation = main.updateOrientation(newDimensions.orientation);
         handler(newDimensions.width, newDimensions.height, orientation);
       }
     );
   }

I parse the orientation to return easier to work with object:

 updateOrientation(orientation) {
     var o = {};
     switch (orientation) {
       case 1:
         o = {
           current: 'portrait',
           idle: false,
           facing: ''
         };
         break;
       case 2:
         o = {
           current: 'portrait',
           idle: false,
           facing: ''
         };
        break;
       case 3:
         o = {
           current: 'landscape',
           idle: false,
           facing: ''
         };
         break;
       case 4:
         o = {
           current: 'landscape',
            idle: false,
           facing: ''
         };
         break;
       case 5:
         o = {
           current: this.orientation.current,
           idle: true,
           facing: 'up'
         };
         break;
       case 6:
         o = {
           current: this.orientation.current,
           idle: true,
           facing: 'down'
         };
         break;
     }
     console.log('Orientation Updated');
     console.log(o);
     this.orientation = o;
     return o;
   }

And now my handler receives:
NEW ORIENTATION DISCOVERED!
index.ios.js:22 Height: 716
index.ios.js:23 Width: 414
index.ios.js:24 Orientation:
index.ios.js:25 Object {current: "portrait", idle: true, facing: "up"}

GPL - Incompatible with iOS App Store

The GPL is incompatible with the iOS App Store and proprietary software development. I'm not sure how many people are looking to build a GPL app and not distribute it on the App Store.

I would hazard to guess that the 500 users who have downloaded this library, the majority of them will be breaking the terms of your licence and putting themselves at risk of legal action.

I would suggest a less restrictive license like MIT, Apache or BSD.

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.