Reinício do projeto: Estado atual completo das páginas

This commit is contained in:
2026-03-18 01:36:30 +00:00
parent ec5bdc4867
commit ed4cff34f6
2 changed files with 24 additions and 5 deletions

View File

@@ -3,9 +3,29 @@ import 'dart:math' as math;
extension SizeExtension on BuildContext {
double get sf {
final double wScreen = MediaQuery.of(this).size.width;
final double hScreen = MediaQuery.of(this).size.height;
// Ajusta a escala baseada no ecrã (muda os valores 1150/720 conforme a tua calibração)
return math.min(wScreen / 1150, hScreen / 720);
final Size size = MediaQuery.of(this).size;
// 1. Definimos os valores base do design (geralmente feitos no Figma/Adobe XD)
const double baseWidth = 375;
const double baseHeight = 812;
// 2. Calculamos o rácio de largura e altura
double scaleW = size.width / baseWidth;
double scaleH = size.height / baseHeight;
// 3. Usamos a média ou o menor valor para manter a proporção
// O 'min' evita que o texto estique demasiado se o ecrã for muito alto ou largo
double scale = math.min(scaleW, scaleH);
// 4. Segurança (Clamping): Não deixa as coisas ficarem minúsculas
// nem exageradamente grandes em tablets.
return scale.clamp(0.8, 1.4);
}
// Atalhos úteis para facilitar o código
double get screenWidth => MediaQuery.of(this).size.width;
double get screenHeight => MediaQuery.of(this).size.height;
// Verifica se é Tablet (opcional)
bool get isTablet => screenWidth > 600;
}