181 lines
7.4 KiB
Dart
181 lines
7.4 KiB
Dart
// 时间: 2026-03-22
|
||
// 功能: 应用全局常量
|
||
// 介绍: 颜色、路由、文案、布局等集中定义,供各页面复用
|
||
// 最新变化: 新增 tabbedPageToolbarHeight / tabbedPageTabBarHeight,压缩主导航子页标题+Tab 占用高度
|
||
|
||
import 'package:flutter/material.dart';
|
||
|
||
class AppConstants {
|
||
// 应用信息
|
||
static const String appName = '情景诗词';
|
||
static const String appVersion = '1.3.1';
|
||
|
||
// 响应式断点
|
||
static const double mobileBreakpoint = 768.0;
|
||
static const double tabletBreakpoint = 1024.0;
|
||
static const double desktopBreakpoint = 1440.0;
|
||
|
||
// 路由名称
|
||
static const String routeHome = '/home';
|
||
static const String routeSettings = '/settings';
|
||
static const String routeProfile = '/profile';
|
||
static const String routeWidgets = '/widgets';
|
||
static const String routeWidgetsPage = '/widgets_page';
|
||
static const String routeCollectNotes = '/collect_notes';
|
||
|
||
// 颜色常量
|
||
static const Color primaryColor = Color(0xFF6200EE);
|
||
static const Color secondaryColor = Color(0xFF03DAC6);
|
||
static const Color backgroundColor = Color(0xFFFFFFFF);
|
||
static const Color surfaceColor = Color(0xFFFFFFFF);
|
||
static const Color errorColor = Color(0xFFB00020);
|
||
static const Color warningColor = Color(0xFFFF9800);
|
||
static const Color successColor = Color(0xFF4CAF50);
|
||
static const Color infoColor = Color(0xFF2196F3);
|
||
|
||
// 文本常量
|
||
static const String appTitle = 'Poes';
|
||
static const String loadingText = '加载中...';
|
||
static const String errorText = '出错了';
|
||
static const String retryText = '重试';
|
||
static const String cancelText = '取消';
|
||
static const String confirmText = '确认';
|
||
static const String saveText = '保存';
|
||
static const String deleteText = '删除';
|
||
static const String editText = '编辑';
|
||
static const String addText = '添加';
|
||
static const String searchText = '搜索';
|
||
static const String filterText = '筛选';
|
||
static const String sortText = '排序';
|
||
static const String refreshText = '刷新';
|
||
|
||
// 响应式文本常量
|
||
static const String noDataText = '暂无数据';
|
||
static const String networkErrorText = '网络连接失败';
|
||
static const String loadMoreText = '加载更多';
|
||
static const String pullToRefreshText = '下拉刷新';
|
||
static const String releaseToRefreshText = '释放刷新';
|
||
|
||
// 图标常量
|
||
static const IconData homeIcon = Icons.home;
|
||
static const IconData settingsIcon = Icons.settings;
|
||
static const IconData profileIcon = Icons.person;
|
||
static const IconData searchIcon = Icons.search;
|
||
static const IconData filterIcon = Icons.filter_list;
|
||
static const IconData sortIcon = Icons.sort;
|
||
static const IconData refreshIcon = Icons.refresh;
|
||
static const IconData addIcon = Icons.add;
|
||
static const IconData editIcon = Icons.edit;
|
||
static const IconData deleteIcon = Icons.delete;
|
||
static const IconData saveIcon = Icons.save;
|
||
static const IconData cancelIcon = Icons.cancel;
|
||
static const IconData confirmIcon = Icons.check;
|
||
static const IconData backIcon = Icons.arrow_back;
|
||
static const IconData menuIcon = Icons.menu;
|
||
static const IconData closeIcon = Icons.close;
|
||
static const IconData notificationIcon = Icons.notifications;
|
||
static const IconData favoriteIcon = Icons.favorite;
|
||
static const IconData shareIcon = Icons.share;
|
||
static const IconData downloadIcon = Icons.download;
|
||
static const IconData uploadIcon = Icons.upload;
|
||
|
||
// 响应式图标常量
|
||
static const IconData expandIcon = Icons.expand_more;
|
||
static const IconData collapseIcon = Icons.expand_less;
|
||
static const IconData fullscreenIcon = Icons.fullscreen;
|
||
static const IconData fullscreenExitIcon = Icons.fullscreen_exit;
|
||
static const IconData gridIcon = Icons.grid_view;
|
||
static const IconData listIcon = Icons.view_list;
|
||
|
||
// 动画时长
|
||
static const Duration animationDurationShort = Duration(milliseconds: 200);
|
||
static const Duration animationDurationMedium = Duration(milliseconds: 300);
|
||
static const Duration animationDurationLong = Duration(milliseconds: 500);
|
||
|
||
// 网络相关
|
||
static const int httpTimeout = 30000; // 30秒
|
||
static const int maxRetryCount = 3;
|
||
|
||
// 分页相关
|
||
static const int defaultPageSize = 20;
|
||
static const int firstPageIndex = 1;
|
||
|
||
// 响应式分页
|
||
static const int pageSizeMobile = 10;
|
||
static const int pageSizeTablet = 15;
|
||
static const int pageSizeDesktop = 20;
|
||
static const int pageSizeLargeDesktop = 25;
|
||
|
||
// 正则表达式
|
||
static const String emailRegex =
|
||
r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$';
|
||
static const String phoneRegex = r'^1[3-9]\d{9}$';
|
||
static const String passwordRegex =
|
||
r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d@$!%*?&]{8,}$';
|
||
|
||
// 存储键名
|
||
static const String tokenKey = 'auth_token';
|
||
static const String userKey = 'user_info';
|
||
static const String themeKey = 'theme_mode';
|
||
static const String languageKey = 'language_code';
|
||
static const String firstLaunchKey = 'first_launch';
|
||
|
||
// 响应式存储键名
|
||
static const String layoutModeKey = 'layout_mode';
|
||
static const String fontSizeKey = 'font_size';
|
||
static const String gridColumnsKey = 'grid_columns';
|
||
|
||
// 错误消息
|
||
static const String networkError = '网络连接失败,请检查网络设置';
|
||
static const String serverError = '服务器错误,请稍后重试';
|
||
static const String dataError = '数据错误,请重试';
|
||
static const String authError = '认证失败,请重新登录';
|
||
static const String permissionError = '权限不足';
|
||
static const String notFoundError = '未找到相关内容';
|
||
static const String unknownError = '未知错误,请联系客服';
|
||
|
||
// 响应式错误消息
|
||
static const String screenNotSupportedError = '当前屏幕尺寸不支持';
|
||
static const String orientationNotSupportedError = '当前屏幕方向不支持';
|
||
static const String splitScreenNotSupportedError = '分屏模式不支持';
|
||
|
||
// 成功消息
|
||
static const String saveSuccess = '保存成功';
|
||
static const String deleteSuccess = '删除成功';
|
||
static const String updateSuccess = '更新成功';
|
||
static const String loginSuccess = '登录成功';
|
||
static const String logoutSuccess = '退出成功';
|
||
static const String uploadSuccess = '上传成功';
|
||
static const String downloadSuccess = '下载成功';
|
||
|
||
// 响应式成功消息
|
||
static const String layoutChangedSuccess = '布局已切换';
|
||
static const String fontSizeChangedSuccess = '字体大小已调整';
|
||
static const String orientationChangedSuccess = '屏幕方向已调整';
|
||
|
||
// 页面内容区与主导航子页统一的水平内边距(与 TabBar 可滚动标签左侧对齐)
|
||
static const double pageHorizontalPadding = 16.0;
|
||
|
||
/// 主导航子页标题行高度(默认 [kToolbarHeight] 为 56,略压缩以减少顶部留白)
|
||
static const double tabbedPageToolbarHeight = 48.0;
|
||
|
||
/// 主导航子页 Tab 行高度(默认约 48,略压缩;过小易触发指示条溢出)
|
||
static const double tabbedPageTabBarHeight = 46.0;
|
||
|
||
// 布局相关
|
||
static const String gridLayout = 'grid';
|
||
static const String listLayout = 'list';
|
||
static const String compactLayout = 'compact';
|
||
static const String spaciousLayout = 'spacious';
|
||
|
||
// 屏幕方向
|
||
static const String portraitOrientation = 'portrait';
|
||
static const String landscapeOrientation = 'landscape';
|
||
|
||
// 设备类型
|
||
static const String mobileDevice = 'mobile';
|
||
static const String tabletDevice = 'tablet';
|
||
static const String desktopDevice = 'desktop';
|
||
static const String largeDesktopDevice = 'large_desktop';
|
||
}
|