You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_QLine/lib/views/view_helpers/size_config.dart

100 lines
2.7 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:hmg_qline/constants/app_constants.dart';
class SizeConfig {
static double _blockWidth = 0;
static double _blockHeight = 0;
static double realScreenWidth = 0.0;
static double realScreenHeight = 0.0;
static double screenWidth = 0.0;
static double screenHeight = 0.0;
static double? textMultiplier;
static double? imageSizeMultiplier;
static double? heightMultiplier;
static bool isPortrait = true;
static double? widthMultiplier;
static bool isMobilePortrait = false;
static bool isMobile = false;
static bool isHeightShort = false;
static bool isHeightVeryShort = false;
static bool isHeightMiddle = false;
static bool isHeightLarge = false;
static bool isWidthLarge = false;
void init(BoxConstraints constraints, Orientation orientation) {
realScreenHeight = constraints.maxHeight;
realScreenWidth = constraints.maxWidth;
if (constraints.maxWidth <= AppConstants.maxSmallScreen) {
isMobile = true;
}
if (constraints.maxHeight < 600) {
isHeightVeryShort = true;
} else if (constraints.maxHeight < 800) {
isHeightShort = true;
} else if (constraints.maxHeight < 1000) {
isHeightMiddle = true;
} else {
isHeightLarge = true;
}
if (constraints.maxWidth > 600) {
isWidthLarge = true;
}
if (orientation == Orientation.portrait) {
isPortrait = true;
if (realScreenWidth < 450) {
isMobilePortrait = true;
}
// textMultiplier = _blockHeight;
// imageSizeMultiplier = _blockWidth;
screenHeight = realScreenHeight;
screenWidth = realScreenWidth;
} else {
isPortrait = false;
isMobilePortrait = false;
// textMultiplier = _blockWidth;
// imageSizeMultiplier = _blockHeight;
screenHeight = realScreenWidth;
screenWidth = realScreenHeight;
}
_blockWidth = screenWidth / 100;
_blockHeight = screenHeight / 100;
textMultiplier = _blockHeight;
imageSizeMultiplier = _blockWidth;
heightMultiplier = _blockHeight;
widthMultiplier = _blockWidth;
}
static getTextMultiplierBasedOnWidth({required double width}) {
// TODO handel LandScape case
return width / 100;
}
static getWidthMultiplier({double? width}) {
// TODO handel LandScape case
if (width != null) {
return width / 100;
}
return widthMultiplier;
}
static getHeightMultiplier({double? height}) {
// TODO handel LandScape case
if (height != null) {
return height / 100;
}
return heightMultiplier! * 8;
}
static double getTextMultiplier({double? height}) {
// TODO handel LandScape case
if (height != null) {
return height / 100;
}
return textMultiplier!;
}
}