package com.example.base.extensions

import android.content.Context
import android.util.TypedValue
import com.example.base.utils.Utils

fun Float.dp2px(): Float {

    return this * Utils.getApp().resources.displayMetrics.density
}

fun Float.dp2px(context: Context): Float {

    return this * context.resources.displayMetrics.density
}

fun Float.sp2px(): Float {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, this, Utils.getApp().resources.displayMetrics)
}

fun Float.sp2px(context: Context): Float {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, this, context.resources.displayMetrics)
}

fun Float.getTwoFormat(): String {
    return if (this < 10) "0$this" else "$this"
}

