Files
monisuo/flutter_monisuo/lib/ui/shared/ui_constants.dart
2026-03-23 00:43:19 +08:00

63 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
/// 应用颜色常量
class AppColors {
AppColors._();
static const Color up = Color(0xFF00C853);
static const Color down = Color(0xFFFF5252);
static const Color deposit = Color(0xFF00C853);
static const Color withdraw = Color(0xFFFF9800);
static const Color trade = Color(0xFF2196F3);
static const List<Color> gradientColors = [
Color(0xFF00D4AA),
Color(0xFF00B894),
];
}
/// 表单验证器
class Validators {
Validators._();
static String? amount(String? value) {
if (value == null || value.isEmpty) {
return '请输入金额';
}
final amount = double.tryParse(value);
if (amount == null || amount <= 0) {
return '请输入有效金额';
}
return null;
}
static String? price(String? value) {
if (value == null || value.isEmpty) {
return '请输入价格';
}
final price = double.tryParse(value);
if (price == null || price <= 0) {
return '请输入有效价格';
}
return null;
}
static String? quantity(String? value) {
if (value == null || value.isEmpty) {
return '请输入数量';
}
final quantity = double.tryParse(value);
if (quantity == null || quantity <= 0) {
return '请输入有效数量';
}
return null;
}
static String? required(String? value, String fieldName) {
if (value == null || value.isEmpty) {
return '请输入$fieldName';
}
return null;
}
}