1
This commit is contained in:
22
lib/config/app_context.dart
Normal file
22
lib/config/app_context.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppContext {
|
||||
static late BuildContext _context;
|
||||
|
||||
AppContext._();
|
||||
|
||||
///私有构造函数,防止外部实例化
|
||||
static void setContent(BuildContext context) {
|
||||
_context = context;
|
||||
}
|
||||
|
||||
///获取全局上下文
|
||||
static BuildContext get context => _context;
|
||||
|
||||
///获取主题
|
||||
static TextTheme get textTheme => Theme.of(_context).textTheme;
|
||||
static ColorScheme get colorScheme => Theme.of(_context).colorScheme;
|
||||
|
||||
///页面内间距
|
||||
static double get pagePadding => 15;
|
||||
}
|
||||
19
lib/config/env.dart
Normal file
19
lib/config/env.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
///环境配置
|
||||
class Config {
|
||||
Config._();
|
||||
|
||||
///获取环境
|
||||
static String getEnv() {
|
||||
const env = String.fromEnvironment('ENV', defaultValue: 'dev');
|
||||
return env;
|
||||
}
|
||||
|
||||
///获取接口地址
|
||||
static String baseUrl() {
|
||||
if (getEnv() == 'dev') {
|
||||
return 'https://skin-api.curain.ai/api';
|
||||
} else {
|
||||
return 'https://skin-api.curain.ai/api';
|
||||
}
|
||||
}
|
||||
}
|
||||
13
lib/config/theme/custom_colors.dart
Normal file
13
lib/config/theme/custom_colors.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
///扩展颜色
|
||||
extension CustomColors on ColorScheme {
|
||||
Color get success => const Color(0xff57be80);
|
||||
|
||||
Color get warning => const Color(0xffff9800);
|
||||
|
||||
Color get info => const Color(0xff909399);
|
||||
|
||||
Color get danger => const Color(0xfff44545);
|
||||
}
|
||||
28
lib/config/theme/theme.dart
Normal file
28
lib/config/theme/theme.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
///颜色
|
||||
final scheme = ColorScheme.fromSeed(
|
||||
primary: Color(0xff107870),
|
||||
seedColor: Color(0xff107870),
|
||||
brightness: Brightness.light,
|
||||
//卡片色
|
||||
surface: Colors.white,
|
||||
surfaceContainerLow: Color(0xFFF4F8FB),
|
||||
surfaceContainer: Color(0xFFE9ECF3),
|
||||
surfaceContainerHigh: Color(0xFFDDE2EA),
|
||||
//颜色
|
||||
onSurfaceVariant:Color(0xFF828282)
|
||||
);
|
||||
|
||||
///字体
|
||||
final textTheme = TextTheme(
|
||||
titleLarge: TextStyle(fontSize: 24, fontWeight: FontWeight.w700, color: scheme.onSurface),
|
||||
titleMedium: TextStyle(fontSize: 20, fontWeight: FontWeight.w700, color: scheme.onSurface),
|
||||
titleSmall: TextStyle(fontSize: 16, fontWeight: FontWeight.w700, color: scheme.onSurface),
|
||||
bodyLarge: TextStyle(fontSize: 18),
|
||||
bodyMedium: TextStyle(fontSize: 16),
|
||||
bodySmall: TextStyle(fontSize: 14),
|
||||
labelLarge: TextStyle(fontSize: 16, color: scheme.onSurfaceVariant),
|
||||
labelMedium: TextStyle(fontSize: 14, color: scheme.onSurfaceVariant),
|
||||
labelSmall: TextStyle(fontSize: 12, color: scheme.onSurfaceVariant),
|
||||
);
|
||||
Reference in New Issue
Block a user