chore(project): 初始化项目基础配置文件
- 添加 CodeGraph、Android 和通用 gitignore 配置 - 创建项目元数据文件跟踪 Flutter 项目属性 - 添加 Codex AI 指导文档 AGENTS.md 说明项目架构 - 配置代码分析选项 analysis_options.yaml - 设置 Android 应用清单权限和 Kiosk 模式配置 - 实现中英文国际化支持 AppLocalizations - 配置 GoRouter 应用路由导航 - 创建明亮工业控制风格的主题配置 AppTheme
This commit is contained in:
49
lib/shared/utils/responsive_layout.dart
Normal file
49
lib/shared/utils/responsive_layout.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// 响应式布局工具类
|
||||
/// 目标屏幕: 1920x1080
|
||||
class ResponsiveLayout {
|
||||
static const double targetWidth = 1920;
|
||||
static const double targetHeight = 1080;
|
||||
|
||||
/// 获取屏幕宽度比例
|
||||
static double widthPercent(BuildContext context, double percent) {
|
||||
return MediaQuery.of(context).size.width * percent;
|
||||
}
|
||||
|
||||
/// 获取屏幕高度比例
|
||||
static double heightPercent(BuildContext context, double percent) {
|
||||
return MediaQuery.of(context).size.height * percent;
|
||||
}
|
||||
|
||||
/// 基于目标屏幕缩放宽度
|
||||
static double scaleWidth(BuildContext context, double targetValue) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
return targetValue * (screenWidth / targetWidth);
|
||||
}
|
||||
|
||||
/// 基于目标屏幕缩放高度
|
||||
static double scaleHeight(BuildContext context, double targetValue) {
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
return targetValue * (screenHeight / targetHeight);
|
||||
}
|
||||
|
||||
/// 基于目标屏幕缩放字体
|
||||
static double scaleFont(BuildContext context, double targetFontSize) {
|
||||
return scaleWidth(context, targetFontSize);
|
||||
}
|
||||
|
||||
/// 预设布局尺寸
|
||||
static double sidebarWidth(BuildContext context) => widthPercent(context, 0.25); // 480px on 1920
|
||||
static double detailWidth(BuildContext context) => widthPercent(context, 0.21); // 400px on 1920
|
||||
static double navWidth(BuildContext context) => widthPercent(context, 0.15); // 280px on 1920
|
||||
static double cardWidth(BuildContext context) => widthPercent(context, 0.30); // ~576px
|
||||
}
|
||||
|
||||
/// 响应式间距
|
||||
class ResponsiveSpacing {
|
||||
static double small(BuildContext context) => ResponsiveLayout.scaleWidth(context, 8);
|
||||
static double medium(BuildContext context) => ResponsiveLayout.scaleWidth(context, 16);
|
||||
static double large(BuildContext context) => ResponsiveLayout.scaleWidth(context, 24);
|
||||
static double xlarge(BuildContext context) => ResponsiveLayout.scaleWidth(context, 32);
|
||||
}
|
||||
Reference in New Issue
Block a user