fix:UI对齐demo

This commit is contained in:
jingyun
2026-06-18 18:08:29 +08:00
parent f42ad566e0
commit 2d7523f901
14 changed files with 1613 additions and 355 deletions
@@ -4,6 +4,8 @@ import 'package:shadcn_ui/shadcn_ui.dart';
import '../../../common/domain/metal_type.dart';
import '../../../common/widgets/prototype_ui.dart';
import '../../profile/application/price_color_theme.dart';
import '../../profile/application/profile_settings_controller.dart';
import '../data/mock_market_repository.dart';
import '../data/market_models.dart';
@@ -21,6 +23,9 @@ class MarketKlinePage extends ConsumerWidget {
final quote = repo.quoteFor(metal);
final points = repo.chartFor(metal, period);
final cs = ShadTheme.of(context).colorScheme;
final palette = priceColorPalette(
ref.watch(profileSettingsControllerProvider).priceColorMode,
);
return Scaffold(
backgroundColor: const Color(0xFFFBFAF7),
@@ -74,7 +79,13 @@ class MarketKlinePage extends ConsumerWidget {
const SizedBox(width: 4),
const Padding(
padding: EdgeInsets.only(top: 8),
child: Text('元/克', style: TextStyle(fontSize: 12, color: Color(0xFF8A8780))),
child: Text(
'元/克',
style: TextStyle(
fontSize: 12,
color: Color(0xFF8A8780),
),
),
),
],
),
@@ -83,8 +94,8 @@ class MarketKlinePage extends ConsumerWidget {
'${quote.changeAmount >= 0 ? '+' : ''}${quote.changeAmount.toStringAsFixed(2)} · ${quote.changePercent.toStringAsFixed(2)}%',
style: TextStyle(
color: quote.changeAmount >= 0
? const Color(0xFFC0392B)
: const Color(0xFF2E8B6F),
? Color(palette.up)
: Color(palette.down),
fontSize: 13,
fontWeight: FontWeight.w600,
),
@@ -98,14 +109,15 @@ class MarketKlinePage extends ConsumerWidget {
PrototypePill(
label: p.label,
selected: p == period,
onTap: () => Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (_) => MarketKlinePage(
metalId: metal.id,
periodId: p.id,
onTap: () =>
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (_) => MarketKlinePage(
metalId: metal.id,
periodId: p.id,
),
),
),
),
),
),
],
),
@@ -114,9 +126,19 @@ class MarketKlinePage extends ConsumerWidget {
children: [
_Ohlc('', points.first.open),
const SizedBox(width: 18),
_Ohlc('', points.map((e) => e.high).reduce((a, b) => a > b ? a : b)),
_Ohlc(
'',
points
.map((e) => e.high)
.reduce((a, b) => a > b ? a : b),
),
const SizedBox(width: 18),
_Ohlc('', points.map((e) => e.low).reduce((a, b) => a < b ? a : b)),
_Ohlc(
'',
points
.map((e) => e.low)
.reduce((a, b) => a < b ? a : b),
),
const SizedBox(width: 18),
_Ohlc('', points.last.close),
],
@@ -127,7 +149,9 @@ class MarketKlinePage extends ConsumerWidget {
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: PrototypeLineChart(
values: points.map((p) => p.close).toList(growable: false),
values: points
.map((p) => p.close)
.toList(growable: false),
),
),
),
@@ -135,7 +159,10 @@ class MarketKlinePage extends ConsumerWidget {
Text(
'${quote.basisLabel} · ${_timeLabel(quote.updatedAt)}',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 11, color: cs.mutedForeground),
style: TextStyle(
fontSize: 11,
color: cs.mutedForeground,
),
),
],
),
@@ -161,9 +188,15 @@ class _Ohlc extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(label, style: const TextStyle(fontSize: 12, color: Color(0xFF8A8780))),
Text(
label,
style: const TextStyle(fontSize: 12, color: Color(0xFF8A8780)),
),
const SizedBox(height: 2),
Text(value.toStringAsFixed(2), style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600)),
Text(
value.toStringAsFixed(2),
style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600),
),
],
);
}