import 'package:flutter/material.dart';
import 'package:tm_app/core/utils/breakpoints.dart';

class SizeConfig {
  static double screenWidth = 0.0;
  static double screenHeight = 0.0;
  static late TextScaler textScaler;

  static void init(BuildContext context) {
    screenWidth = MediaQuery.sizeOf(context).width;
    screenHeight = MediaQuery.sizeOf(context).height;
    textScaler = MediaQuery.of(context).textScaler;
  }
}

extension SizeDoubleExt on double {
  double h() {
    final displaySize =
        Size(SizeConfig.screenWidth, SizeConfig.screenHeight).displaySize;
    final double screenHeight = SizeConfig.screenHeight;
    final double res = (this / 917.0) * screenHeight;
    if (displaySize == DisplaySize.extraSmall
    // displaySize == DisplaySize.small
    ) {
      return res;
    } else {
      return this;
    }
  }

  double w() {
    final displaySize =
        Size(SizeConfig.screenWidth, SizeConfig.screenHeight).displaySize;
    final double screenWidth = SizeConfig.screenWidth;
    final double res = (this / 412.0) * screenWidth;
    if (displaySize == DisplaySize.extraSmall
    // ||
    // displaySize == DisplaySize.small
    ) {
      return res;
    } else {
      return this;
    }
  }

  double sp() {
    return h();
  }
}
