feat(theme): migrate to new theme system with static color methods
- Convert instance methods to static methods in AppColorScheme for getChangeColor and getChangeBackgroundColor - Update main.dart to use ShadThemeData with AppColorScheme color schemes instead of createLight/DarkShadTheme functions - Add app_theme.dart import to main.dart - Refactor asset_card.dart and coin_card.dart to call static methods via AppColorScheme class - Add app_spacing.dart import to action_buttons_row.dart - Replace SizedBox with proper spacing constants in action buttons row
This commit is contained in:
@@ -426,14 +426,14 @@ class AppColorScheme {
|
||||
|
||||
/// 获取买入按钮渐变(主题感知)- 用于盈利展示
|
||||
|
||||
/// 获取涨跌颜色(明暗通用)
|
||||
Color getChangeColor(bool isUp) => isUp ? AppColorScheme.up : AppColorScheme.down;
|
||||
/// 获取涨跌颜色(明暗通用)
|
||||
static Color getChangeColor(bool isUp) => isUp ? AppColorScheme.up : AppColorScheme.down;
|
||||
|
||||
/// 获取涨跌背景色(带透明度)
|
||||
Color getChangeBackgroundColor(bool isUp, {double opacity = 0.15}) {
|
||||
return isUp
|
||||
? AppColorScheme.up.withValues(alpha: opacity)
|
||||
: AppColorScheme.down.withValues(alpha: opacity);
|
||||
}
|
||||
/// 获取涨跌背景色(带透明度)
|
||||
static Color getChangeBackgroundColor(bool isUp, {double opacity = 0.15}) {
|
||||
return isUp
|
||||
? AppColorScheme.up.withValues(alpha: opacity)
|
||||
: AppColorScheme.down.withValues(alpha: opacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'core/network/dio_client.dart';
|
||||
import 'core/storage/local_storage.dart';
|
||||
import 'core/theme/app_color_scheme.dart';
|
||||
import 'core/theme/app_theme.dart';
|
||||
import 'core/event/app_event_bus.dart';
|
||||
import 'data/services/user_service.dart';
|
||||
import 'data/services/market_service.dart';
|
||||
@@ -68,8 +69,14 @@ class MyApp extends StatelessWidget {
|
||||
builder: (context, themeProvider, _) {
|
||||
return ShadApp.custom(
|
||||
themeMode: themeProvider.themeMode,
|
||||
theme: createLightShadTheme(),
|
||||
darkTheme: createDarkShadTheme(),
|
||||
theme: ShadThemeData(
|
||||
colorScheme: AppColorScheme.lightShad,
|
||||
brightness: Brightness.light,
|
||||
),
|
||||
darkTheme: ShadThemeData(
|
||||
colorScheme: AppColorScheme.darkShad,
|
||||
brightness: Brightness.dark,
|
||||
),
|
||||
appBuilder: _buildMaterialApp,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -227,13 +227,13 @@ class AssetCardCompact extends StatelessWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: getChangeBackgroundColor(isValueUp),
|
||||
color: AppColorScheme.getChangeBackgroundColor(isValueUp),
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
),
|
||||
child: Text(
|
||||
change!,
|
||||
style: TextStyle(
|
||||
color: getChangeColor(isValueUp),
|
||||
color: AppColorScheme.getChangeColor(isValueUp),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -81,13 +81,13 @@ class CoinCard extends StatelessWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: getChangeBackgroundColor(isUp),
|
||||
color: AppColorScheme.getChangeBackgroundColor(isUp),
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
),
|
||||
child: Text(
|
||||
change,
|
||||
style: TextStyle(
|
||||
color: getChangeColor(isUp),
|
||||
color: AppColorScheme.getChangeColor(isUp),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
||||
import '../../../../core/theme/app_spacing.dart';
|
||||
import '../../../../core/theme/app_theme.dart';
|
||||
|
||||
/// 操作按钮行 — .pen node pIpHe
|
||||
@@ -35,7 +36,7 @@ class ActionButtonsRow extends StatelessWidget {
|
||||
bgColor: bgColor,
|
||||
onTap: onDeposit,
|
||||
),
|
||||
const SizedBox(width: AppSpacing.sm + AppSpacing.xs),
|
||||
const SizedBox(width: 12),
|
||||
ActionButton(
|
||||
icon: LucideIcons.arrowDownLeft,
|
||||
label: '提现',
|
||||
@@ -43,7 +44,7 @@ class ActionButtonsRow extends StatelessWidget {
|
||||
bgColor: bgColor,
|
||||
onTap: onWithdraw,
|
||||
),
|
||||
const SizedBox(width: AppSpacing.sm + AppSpacing.xs),
|
||||
const SizedBox(width: 12),
|
||||
ActionButton(
|
||||
icon: LucideIcons.repeat,
|
||||
label: '划转',
|
||||
@@ -96,7 +97,7 @@ class ActionButton extends StatelessWidget {
|
||||
color: accentColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.xs + 2),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
label,
|
||||
style: AppTextStyles.labelLarge(context).copyWith(
|
||||
|
||||
@@ -320,7 +320,7 @@ class _MiniBarChart extends StatelessWidget {
|
||||
height: h,
|
||||
decoration: BoxDecoration(
|
||||
color: barColor,
|
||||
borderRadius: BorderRadius.circular(AppRadius.xs),
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import '../../../../core/theme/app_color_scheme.dart';
|
||||
import '../../../../core/theme/app_spacing.dart';
|
||||
import '../../../../core/theme/app_theme.dart';
|
||||
|
||||
/// 退出登录按钮
|
||||
class LogoutButton extends StatelessWidget {
|
||||
|
||||
@@ -23,7 +23,7 @@ class ProfileCard extends StatelessWidget {
|
||||
: colorScheme.surfaceContainerHigh,
|
||||
borderRadius: BorderRadius.circular(AppRadius.lg),
|
||||
border: Border.all(
|
||||
color: colorScheme.outlineVariant.withOpacity(0.15),
|
||||
color: colorScheme.outlineVariant.withValues(alpha: 0.15),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
@@ -47,10 +47,8 @@ class ProfileCard extends StatelessWidget {
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'普通用户',
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 10,
|
||||
style: AppTextStyles.bodyMedium(context).copyWith(
|
||||
fontWeight: FontWeight.normal,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -49,14 +49,14 @@ class ConfirmDialog extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: AppSpacing.lg),
|
||||
_dialogRow('交易对', '$coinCode/USDT', colorScheme),
|
||||
_dialogRow(context, '交易对', '$coinCode/USDT', colorScheme),
|
||||
SizedBox(height: AppSpacing.sm),
|
||||
_dialogRow('委托价格', '$price USDT', colorScheme),
|
||||
_dialogRow(context, '委托价格', '$price USDT', colorScheme),
|
||||
SizedBox(height: AppSpacing.sm),
|
||||
_dialogRow('交易金额', '$amount USDT', colorScheme,
|
||||
_dialogRow(context, '交易金额', '$amount USDT', colorScheme,
|
||||
valueColor: actionColor),
|
||||
SizedBox(height: AppSpacing.sm),
|
||||
_dialogRow('交易数量', '$quantity $coinCode', colorScheme),
|
||||
_dialogRow(context, '交易数量', '$quantity $coinCode', colorScheme),
|
||||
SizedBox(height: AppSpacing.lg),
|
||||
Row(
|
||||
children: [
|
||||
@@ -87,7 +87,7 @@ class ConfirmDialog extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _dialogRow(String label, String value, ColorScheme colorScheme,
|
||||
Widget _dialogRow(BuildContext context, String label, String value, ColorScheme colorScheme,
|
||||
{Color? valueColor}) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
|
||||
@@ -172,13 +172,13 @@ class TradeFormCard extends StatelessWidget {
|
||||
// 设计稿:gap:8,圆角sm,bg-tertiary,高32
|
||||
Row(
|
||||
children: [
|
||||
_buildPctButton('25%', 0.25, colorScheme),
|
||||
_buildPctButton(context, '25%', 0.25, colorScheme),
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
_buildPctButton('50%', 0.5, colorScheme),
|
||||
_buildPctButton(context, '50%', 0.5, colorScheme),
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
_buildPctButton('75%', 0.75, colorScheme),
|
||||
_buildPctButton(context, '75%', 0.75, colorScheme),
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
_buildPctButton('100%', 1.0, colorScheme),
|
||||
_buildPctButton(context, '100%', 1.0, colorScheme),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: AppSpacing.md + AppSpacing.sm),
|
||||
@@ -203,7 +203,7 @@ class TradeFormCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// 百分比按钮 - 设计稿:圆角sm,bg-tertiary,高32
|
||||
Widget _buildPctButton(String label, double pct, ColorScheme colorScheme) {
|
||||
Widget _buildPctButton(BuildContext context, String label, double pct, ColorScheme colorScheme) {
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => onFillPercent(pct),
|
||||
|
||||
Reference in New Issue
Block a user