forked from cemaden-educacao/WPD-MobileApp
Browse Source
Making some components width/height flexible depending on phone screen
Making some components width/height flexible depending on phone screen
size and a scale arg.master
GabrielTrettel
4 years ago
3 changed files with 105 additions and 91 deletions
-
24src/app/config/dimensions.js
-
36src/app/screens/RainSharingDataScreen.js
-
28src/app/screens/SharingFloodZonesScreen.js
@ -0,0 +1,24 @@ |
|||
import { Dimensions } from "react-native"; |
|||
|
|||
const screen_width = Dimensions.get("window").width; |
|||
|
|||
/* imageScaleToSize (iw, ih, scale_w) |
|||
* function for scaling images dinamically based on screen width |
|||
* |
|||
* iw: actual image width, |
|||
* ih: actual image height, |
|||
* scale_w: scale ratio of the image width. |
|||
* |
|||
* if scale_w is 50, then the returned value for width would |
|||
* be 50% of the screen width |
|||
* |
|||
* returns: |
|||
* |
|||
*/ |
|||
function scaleDimsFromWidth(iw, ih, scale_w) { |
|||
const sw = (scale_w / 100.0) * screen_width; |
|||
const sh = ih * (sw / iw); |
|||
return { width: sw, height: sh }; |
|||
} |
|||
|
|||
export { screen_width, scaleDimsFromWidth }; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue