Expo Big Battle (37)--expo SDK API Glview,gesturehandler,font,fingerprint,devicemotion,brightness

Source: Internet
Author: User

Brief: This series of articles will be a comprehensive introduction to the Expo, I contact the Expo since June 2017, the study of the Expo intermittent, all the way to nearly 10 months, nonsense not to say, next you see the content, speak all to the official website

I guess go all machine turn + personal modification supplement +demo test form, to the expo to do a big blood! Welcome to join the Expo Interest Learning Exchange Group: 597732981

"Before I wrote some columns about Expo and RN entry configuration for East I west, you can click here to view: from zero learning RN development"

Related articles:

Expo Big Battle (a)--what is the expo, how to install Expo Clinet and xde,xde how to use

Expo Big Battle (ii)--expo life cycle, Expo Community exchanges, Expo learning necessary resources, the development of the use of the expo concerns some issues

Expo Big Battle (iii)--to the development of react native project developers have targeted the introduction of the limitations of Expo,expo, the development of project selection points of attention, etc.

Expo Big Battle (Iv.)--Rapid use of Expo to build a key term in a App,expo

Expo Big Battle (v) configuration information for App.json files in--expo

Expo Big Battle (vi)--EXPO Development mode, Expo in the EXP Command line tool, Expo How to view the debug mode in the log Log,expo

Expo Big Battle (vii)--expo How to use Genymotion simulator

Expo Big Battle (eight)--expo in the Publish and Expo link, to link this piece of things not detailed see, we can come to communicate with me

More >>

Written in chapter 23 after the words, before the translation, no matter how, good and bad, after all, is the end of the expo, but also the basic theory of the things in-depth understanding again, the following Expo big Battle series will mainly introduce the Expo SDK API.

Glview

Expo.glview ()
A view that acts as the OpenGL ES render target. At installation time, an OpenGL ES context is created. Its drawing buffers are displayed for viewing content for each frame.

In addition to the general view support for layout and touch processing, the following props are supported:

Oncontextcreate the function that will be called when the OpenGL ES context is created. The function passes a parameter GL with the Webglrenderingcontext interface.

Msaasamples Glview can enable built-in multi-sampling for iOS. This prop specifies the number of samples to use. By default this is 4. Setting this to 0 turns off multi-sampling. On Android, this is ignored.

Advanced API (high-level APIs)

Because the WebGL API is fairly low-level, it can be helpful to render more advanced graphics APIs using the underlying Glview. The following libraries integrate common graphics APIs:

    • Expo-three for Three.js
    • Expo Treatment for Processing.js

Any WEBGL support library that expects Webglrenderingcontext can be used. There are times when such a library assumes a web JavaScript context (such as a hypothetical document). Typically this is for resource loading or event handling, and the main rendering logic still uses only pure WEBGL. So these libraries are usually still able to use two workarounds. The above-mentioned expo-specific integrations include some solutions for popular class libraries.

WebGL API

Once the component is mounted and the OpenGL ES context is created, the GL object received via Oncontextcreate prop becomes an interface for the OpenGL ES context, providing the WebGL API. It is similar to Webglrenderingcontext in the WebGL 1 specification. There is also a gl.endframeexp () method that notifies the context that the current frame is ready to be rendered. This is similar to the swap buffer API call in other OpenGL platforms.

The following Webglrendercontext methods are not currently implemented:

    • Getframebufferattachmentparameter ()
    • Getrenderbufferparameter ()
    • Compressedteximage2d ()
    • Compressedtexsubimage2d ()
    • Gettexparameter ()
    • Getuniform ()
    • Getvertexattrib ()
    • Getvertexattriboffset ()

The pixel parameter of teximage2d () must be null, arraybuffer with pixel data, or an object in the form {Localuri}, where Localuri is the file://URI of the image in the device file system. So a Expo.asset object can be used once. Downloadasync () has been called (and completed) to obtain resources.

For efficiency reasons, the current implementation of the method does not perform type or bounds checking on their parameters. Therefore, passing invalid parameters can cause a native crash. We plan to update the API to perform parameter checks in the upcoming SDK release. Current error checking has a low priority because the engine usually does not rely on the OpenGL API to perform a parameter check, otherwise the checks performed by the underlying OpenGL ES implementation are usually sufficient.

Gesturehandler

An API for handling complex gestures. From the Readme file for this project:

The library provides an API that provides mobile platform-specific touch and gesture handling and recognition of native functionality. It allows you to define complex gesture processing and recognition logic that runs in 100% on a local thread and is therefore deterministic.

The API is currently available under the Dangerzone namespace because it is based on fast-improving react-native-gesture-handler. We recommend reviewing the Readme document and usage examples on the GitHub repository for your project. Using this API in Expo or Expokit does not require native settings (no native setup is required for using the This API within Expo or Expokit).

Font

Allows fonts to be loaded from the web and used in react native components. See Using the Custom Font guide for more detailed usage information.

Usage
Expo.Font.loadAsync (object)


Expo.Font.loadAsync () A convenient way to load multiple fonts at once.

Parameters
Map (object)-a mapping of a name that needs to be declared in Expo.Font.loadAsync ().

Cases

Expo.Font.loadAsync ({  montserrat:require ('./assets/fonts/montserrat.ttf')  ),  'montserrat-semibold': Require ('./assets/ Fontsmontserrat-semibold.ttf'),});

Return
No content is returned, just waiting for all fonts to be available.

Fingerprint (fingerprint)

Use TouchID (IOS) or fingerprint API (Android) to authenticate users through fingerprint scanning.

Expo.Fingerprint.hasHardwareAsync ()
Determine if the fingerprint scanner is available on the device.

Return
A Boolean value that indicates whether the fingerprint scanner is available on this device.

Expo.Fingerprint.isEnrolledAsync ()
Determine if the device holds the thumbprint used for authentication.

Return
A Boolean value that indicates whether the device holds the thumbprint used for authentication.

Expo.Fingerprint.authenticateAsync ()
An attempt was made to authenticate through a fingerprint. Android-When using the fingerprint module on Android, you need to provide a UI component to prompt the user to scan the fingerprint because the operating system does not have a default alert.

Parameters
(iOS only) promptmessage (string) messages displayed with the TouchID prompt.

Return
Contains the successful object, a Boolean value that indicates whether the validation was successful, and an error that contains the error code in the case of a validation failure.

Expo.Fingerprint.cancelAuthenticate () -(Android only)
Cancels the fingerprint authentication process.

Devicemotion

Access device motion and direction sensors. All data is represented by three axes running on one device. Depending on portrait: X from left to right, y from bottom to top, Z goes vertically through the screen from back to front.

Expo.DangerZone.DeviceMotion.addListener (Listener)
Subscribe to the devicemotion update.

Parameters
Listener (function)-callback that is called when the Devicemotion update is available. When invoked, the listener is provided with a parameter, which is an object containing the following fields:

    • Acceleration (Object)-acceleration of the device on the three axes as an object with X, Y, z keys. expressed in M/S2.
    • Accelerationincludinggravity (object)-When the device accelerates, gravity on the three axes acts as an object with X, Y, z keys. expressed in M/S2.
    • Rotation (object)-the orientation of the device in space as an object with a Alpha,beta,gamma key, where alpha is used to rotate around the z axis, beta for x-axis rotation, and gamma for y-axis rotation.
    • Rotationrate (object)-the rotation rate of the device around each of its axes, as an object with a Alpha,beta,gamma key, where Alpha surrounds the z axis, beta revolves around the x axis, and gamma surrounds the y axis.
    • Orientation (number)-The device orientation based on the screen rotation. Values are 0 (portrait), 90 (right-hand view), 180 (upside-down), 90 (landscape on the left).

Return
A Eventsubscription object that you can call remove () when you want to unsubscribe from the listener.

Expo.DangerZone.DeviceMotion.removeAllListeners ()
Delete all listeners.

Expo.DangerZone.DeviceMotion.setUpdateInterval (Intervalms)
Subscribe to the devicemotion update.

Parameters

Intervalms (number) Devicemotion the expected interval between updates (in milliseconds)

Brightness (brightness)


Gets and sets the screen brightness API.

Expo.Brightness.setBrightnessAsync (Brightnessvalue)

Sets the screen brightness.

Parameters
Brightnessvalue-A number between 0 and 1 that represents the desired screen brightness.

Expo.Brightness.getBrightnessAsync ()

Gets the screen brightness.

Return
The promise, represented by a number between 0 and 1, represents the current screen brightness.

Expo.Brightness.setSystemBrightnessAsync (Brightnessvalue)
Warning: This method is experimental.

Setting the Global System screen brightness requires Write_settings permissions on Android.

Parameters
Brightnessvalue-A number between 0 and 1 that represents the desired screen brightness.

Cases

await Permissions.askasync (permissions.system_brightness); Const await Permissions.getasync (permissions.system_brightness); if ' granted ' ) {  Expo.Brightness.setSystemBrightnessAsync (1);} ...

Expo.Brightness.getSystemBrightnessAsync ()
Warning: This method is experimental.

Gets the global System screen brightness.

Return
A promise with numbers between 0 and 1 that represents the current system screen brightness.

The next one goes on, this article mainly introduces: Expo SDK API Glview,gesturehandler,font,fingerprint,devicemotion,brightness! , you are welcome to pay attention to my public number, this article is approved by everyone, my measure is the public number of fans increase number. Welcome to reprint, but must keep my blog link!

Expo Big Battle (37)--expo SDK API Glview,gesturehandler,font,fingerprint,devicemotion,brightness

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.