How to lock screen orientation in Dart - mobile

How to lock screen orientation?
Tried this code, but seems, that I use it wrong... Cause it doesnt work on my android smartphone...
window.screen.orientation.lock(window.screen.orientation.type);

There is currently no way to do that in Dart.
https://github.com/flutter/flutter/issues/6381
The issue also contains links how to do that in platform native code.
You can make such native available to Dart using a plugin https://flutter.io/developing-packages/#plugin

Related

Does LayoutAnimation Work Under Any Circumstances?

LayoutAnimation is a part of React Native that automatically animates components when the view is rendered.
The official documentation is here:
https://reactnative.dev/docs/layoutanimation
However, the examples in the docs do not work. Objects in the examples that are supposed to animate just jump from the starting position to the end position.
Here is an example of one of the Snacks in the documentation that does not appear to animate:
https://snack.expo.io/91MUQd5IH
This would lead one to the conclusion that this API is just not supported or no longer functional.
Is it the case that Layout Animation just does not work? Or if it does work under some circumstances, please share a link containing a working Snack / Gist with an extremely simple but working LayoutAnimation example.
UPDATE: LayoutAnimation possibly does not support web. Does anyone have any knowledge of this or who can refer the reader to an explanation in the docs?
LayoutAnimation is currently not supported properly in react-native-web. You can see that here: https://github.com/necolas/react-native-web#modules and here https://github.com/necolas/react-native-web/issues/1613, https://github.com/necolas/react-native-web/issues/1056. It doesn't seem to be a priority for the project at the moment so I wouldn't count on it being implemented.
On iOS/Android it's a different story. If we look here: https://reactnative.dev/docs/layoutanimation/ you can actually see this working properly by pressing play and selecting iOS for example.
On Android we have support as well but it might not work/crash. If you look over the issues open for react-native, you will see a lot of them mention issues with LayoutAnimation and Android. E.g. it crashes under certain conditions on Android: https://github.com/facebook/react-native/issues/27552 and https://github.com/facebook/react-native/issues/29919.
I don't recommend using LayoutAnimation, especially on Android, as it is highly experimental and might crash on some devices without warning.
If you want to try some more interesting animations with better performance, I recommend you try using the Animated API from ReactNative or the newer react-native-reanimated which is faster, more modern but still in alpha (I'm talking about the current, v2, version).
By my test the given link in the question post works properly:
Also, I test it on my friend's iPhone and it's worked properly too. But many of React Native features don't work properly on Web export. For example animations on RNW (React Native Web) works on Android/iOS exports but not on Web exports.
For such web situations, you should decouple the web component and make a separate file then write the desired animation on it.

File upload in CodenameOne Browser component

The native file chooser dialog doesn't get invoked from within a BrowserComponent. I understand WebView has some limitations but there are ways to overcome this in Android.
Is there a workaround for CodenameOne? Any ideas on how to make it work?
This is a bit problematic because Android overcame it in a non-portable way. That means the workaround worked for older versions of Android, stopped working and then you needed a new workaround all the time.
But it was even more problematic because of permissions that made it really hard to do it well especially with Android 6+ permission types. All users that asked for this so far found a different way to implement file upload e.g. using the multipart class so this never became an issue that required a workaround (which would be non-trivial).

Tools to display React-Native components on web

I have a react-native project that's built using Metro and Native Base and I'm trying normalize the UI by extracting a styleguide out of it. I would like it to be documented so I can share it and work along with the designers.
Cheers!
I already tried Storybook, Docz and React-Styleguidist.
React-Styleguidist: This one I liked the fact that it could be placed outside the project.
Docz: seems to be the easiest but it seems to have a problem with Native-Base
Storybook: Seems to require the you have an emulator running to display any documentation.
Anyway, I couldn't make any of them work. So if you guys have some suggestions regarding these or other tools, I'd be glad to hear them.
The best would be to have a browser based that lifts the documentation from outside the repo and parses something that's browsable and I can share with the designers.
You can use react-native-web package that compiles native components to HTML.
https://github.com/necolas/react-native-web

Undefined is not object(evaluating 'NativeModules.RNSearchBarManager.ComponentHeight')

When i use library search bar in link https://github.com/umhan35/react-native-search-bar => I have met this error, anyone has met this error can help me, solve this problem.
Based on the screenshot you have attached (I moved it from your deleted answer to your question), I believe you are using Android.
I consulted the source code of the library on GitHub, it would seem that this is designed for iOS and doesn't support Android, at least not at the moment.
It seems be getting undefined when evaluating style={{height: NativeModules.RNSearchBarManager.ComponentHeight}}
but that value isn't available when running on Android. There are only iOS native modules in this library at the time being.
The library you are using is only for IOS. Try using this one instead.
react native elements SearchBar

Using libvlc on android with NDK

I am currently messing around a bit with libvlc on android using the NDK.
Well, I understand how to use native C code in an android app.
Now I would like to use the libvlc library to make a simple player which would read data from a socket.
Is it possible to use libvlc at that level? The problem I see is when it comes to set a window handler for libvlc to draw the image on.
Has anyone experienced with this that could give me some feedback?
Thank you.
You might be interested in this - https://bitbucket.org/tewilove/nyan.tv-jni/src
Edit: Looks like the nyan.tv link doesn't exist anymore. A possibly more 'official' sample is here -> https://bitbucket.org/edwardcw/libvlc-android-sample

Resources