forked from cemaden-educacao/WPD-MobileApp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
626 B
24 lines
626 B
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 };
|