Dimensions and useWindowDimensions React Native non-consistance - react-native

I'm using Expo and logging Dimensions.get('window').height and useWindowDimensions().height values. And when I reload the app via Expo I notice that there is about a 50% chance that I get 812 (normal behavior) and a 50% chance that I get 70 (weird behavior). Is there any way to get a consistent value of screen height in React Native? Or what should I check to fix Dimensions.get('window').height and useWindowDimensions().height inconsistency? Any advice would be appreciated
UPD: I noticed that it concerns only .height property. All the rest stay ok:
Object {
"fontScale": 1,
"height": 70,
"scale": 3,
"width": 375,
}
Object {
"fontScale": 1,
"height": 812,
"scale": 3,
"width": 375,
}
Any ideas on why can that happen?

Resolved: change Dimensions.get('window') with Dimensions.get('screen'), it works consistent

Related

How to disable full screen in React Native for Windows + MacOs?

I need to set width and height(368px, 592px) and disable full screen in my app on React Native for Windows + MacOs.
I tried to add width and height to app.json but it didn't work.
//app.json
{
"name": "Test",
"displayName": "test",
"width": "368px",
"height": "592px"
}
Thanks!

Adding width and height options in config.json of Rendertron does not change dimension of rendered page

I want rendertron to render pages of particular dimensions.
According to the documentation (https://github.com/GoogleChrome/rendertron#config), I added the width and height properties to my config.json file:
"width": 480,
"height": 600,
"cache": "memory",
"cacheConfig": {
"cacheDurationMinutes": 120,
"cacheMaxEntries": 100
},
"closeBrowser": true,
"port": 3002
}
However, this does not seem to work and rendertron is still using the default value which is 1000x1000.
Has someone faced this issue?
This is what one of the rendered page looks like:

Latest one video uploaded in youtube channel

I need to show the thumbnail of the latest video on my youtube channel on my website and add a link to that video. While using the API parameter date it's showing the first video in that channel. Instead of that, I need the last published video details how to solve this
This is what I used as I require only one last video
https://www.googleapis.com/youtube/v3/search?key=[key]&channelId=[channel-id]&part=snippet,id&order=relevance&maxResults=1
(option 1)
You could try replacing order=relevance with order=date
try:
https://www.googleapis.com/youtube/v3/search?key=[key]&channelId=[channel-id]&part=snippet,id&order=date&maxResults=1
(option 2)
You could also try using publishedAfter command (which takes a year-month-day format).
Example: publishedAfter=2019-03-25T00:00:00Z (because yesterday was March 25th).
try:
https://www.googleapis.com/youtube/v3/search?key=[key]&channelId=[channel-id]&part=snippet,id&publishedAfter=2019-03-25T00:00:00Z&order=date&maxResults=1
(option 3)
Use your programming language to fetch / read the HTML source-code of the channel's uploads page. The first thumbnail listed after gridVideoRenderer is the latest, along with relevant URL.
Example steps:
1) Go to user's uploads page and use "view source" option to see the HTML text (source code).
This text is what your programming language should show you when you http request the link of the channel's uploads.
https://www.youtube.com/user/MARVEL/videos
2) After acquiring (or viewing) the source code
From there find position of the word gridVideoRenderer.
Then starting after position, now find the first occurence of word "url":".
That is the URL. Extract manually by hand or write code to do it automatically.
PS: Replace any unicode in the link, like \u0026 with &.
https://i.ytimg.com/vi/QuP7V2gKgPI/hqdefault.jpg?sqp=-oaymwEZCPYBEIoBSFXyq4qpAwsIARUAAIhCGAFwAQ==&rs=AOn4CLDBeSfAIiCdLDKtA8h2G-AZqk-xhQ
I tried "option 1" with my own Key, and got the correct response as far as which "video" from the "Channel" - NO THUMBNAILs, just references to it/them, code follows:
{
"kind": "youtube#searchListResponse",
"etag": "EymHvUd1w4o13UcSUT0C9YINu3o",
"nextPageToken": "CAEQAA",
"regionCode": "US",
"pageInfo": {
"totalResults": 181,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "23QGL4Y9Du8EXMntX5ZNdr1F7_k",
"id": {
"kind": "youtube#video",
"videoId": "RRQjUvoSuKU"
},
"snippet": {
"publishedAt": "2022-11-13T15:09:07Z",
"channelId": "UCbhMYK2QQXgHjgnMN3zegRQ",
"title": "All Things Closely",
"description": "Luke 1:1-4.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/RRQjUvoSuKU/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/RRQjUvoSuKU/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/RRQjUvoSuKU/hqdefault.jpg",
"width": 480,
"height": 360
}
},
"channelTitle": "Restoration Church Homestead",
"liveBroadcastContent": "none",
"publishTime": "2022-11-13T15:09:07Z"
}
}
]
}
THAT's all that showed on a browser page, no Thumbnails-just code, but could not figure out how to get any code in the string to PLAY that video ...
any ideas?
I would love to just have it as a LINK rather than any other scripts loaded on the server. I'm missing something, probably simple I bet, to get the returned video related to the data to play.

Configuring stylelint for React Native and styled-components

I've been trying to set up stylelint to my React Native repo, which uses a mix of StyleSheet and styled-components.
With the following configuration
{
"processors": [
"stylelint-processor-styled-components"
],
"extends": [
"stylelint-config-styled-components"
],
"plugins": ["stylelint-react-native"],
}
I get errors for lines such as shadowOffset: { width: 0, height: 1 }; in the form of Missed semicolon CssSyntaxError, but I believe my usage of shadowOffset is correct.
Things get weirder when I add these to my configuration:
"rules": {
"react-native/style-property-no-unknown": true,
"react-native/css-property-no-unknown": true
}
Has anyone made stylelint work correctly with React Native and styled-components?
You can use stylelint-config-react-native-styled-components. It's a:
Shareable stylelint config for styled components when using React Native

Titanium Paypal integration for Android

I'm learning Titanium for mobile development. Currently, I am trying to learn Paypal usage through Titanium programming. I have the following test code.
var ppButton = Ti.Paypal.createPaypalButton({
width: 294,
height: 50,
bottom: 50,
appId: "APP_80W294485PS19543T",
buttonStyle: Ti.Paypal.BUTTON_294x43,
paypalEnvironment: Ti.Paypal.PAYPAL_ENV_SANDBOX,
feePaidByReceiver: false,
transactionType: Ti.Paypal.PAYMENT_TYPE_DONATION,
enableShipping: false,
payment: {
amount: 1.50,
tax: 0.00,
shipping: 0.00,
currency: "USD",
recipient: "fname_1343709942_per#gmail.com",
itemDescription: "Donation",
merchantName: "American Red Cross"
}
});
But the application crashes on launching giving force close error.
Can anybody point out the problem and suggest the solution? I'll be thankful.
Please Try This
this is a Module and provided by Appecelerator.
Download This and use this work fine.