111
This commit is contained in:
@@ -117,8 +117,7 @@ class PriceCard extends StatelessWidget {
|
||||
String _fmt(double? v) {
|
||||
if (v == null) return '--';
|
||||
if (v >= 1000) return v.toStringAsFixed(2);
|
||||
if (v >= 1) return v.toStringAsFixed(4);
|
||||
return v.toStringAsFixed(6);
|
||||
return v.toStringAsFixed(4);
|
||||
}
|
||||
|
||||
String _fmtVol(double? v) {
|
||||
|
||||
@@ -55,6 +55,15 @@ class SplitTradeForm extends StatefulWidget {
|
||||
class _SplitTradeFormState extends State<SplitTradeForm>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
double _currentPercent = 0.0;
|
||||
|
||||
String _fmtAvailable(String raw) {
|
||||
final v = double.tryParse(raw);
|
||||
if (v == null || v == 0) return '0';
|
||||
if (v >= 1) return v.toStringAsFixed(2);
|
||||
if (v >= 0.01) return v.toStringAsFixed(4);
|
||||
return v.toStringAsFixed(6);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -256,11 +265,21 @@ class _SplitTradeFormState extends State<SplitTradeForm>
|
||||
),
|
||||
const SizedBox(height: AppSpacing.xs),
|
||||
|
||||
// 可用余额
|
||||
Text(
|
||||
'可用: $available ${_isBuy ? 'USDT' : (widget.coin?.code ?? '')}',
|
||||
style: AppTextStyles.bodySmall(context)
|
||||
.copyWith(color: context.colors.onSurfaceVariant),
|
||||
// 可用余额 + 手续费
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'可用: ${_fmtAvailable(available)} ${_isBuy ? 'USDT' : (widget.coin?.code ?? '')}',
|
||||
style: AppTextStyles.bodySmall(context)
|
||||
.copyWith(color: context.colors.onSurfaceVariant),
|
||||
),
|
||||
Text(
|
||||
'手续费: 0%',
|
||||
style: AppTextStyles.bodySmall(context)
|
||||
.copyWith(color: context.colors.onSurfaceVariant),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: AppSpacing.sm),
|
||||
|
||||
@@ -276,7 +295,29 @@ class _SplitTradeFormState extends State<SplitTradeForm>
|
||||
_pctBtn(context, '100%', 1.0, onFillPercent),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: AppSpacing.sm),
|
||||
const SizedBox(height: 2),
|
||||
|
||||
// 滑块选择仓位
|
||||
SliderTheme(
|
||||
data: SliderThemeData(
|
||||
trackHeight: 3,
|
||||
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 6),
|
||||
overlayShape: const RoundSliderOverlayShape(overlayRadius: 12),
|
||||
activeTrackColor: accentColor,
|
||||
inactiveTrackColor: context.colors.surfaceContainerHighest,
|
||||
thumbColor: accentColor,
|
||||
),
|
||||
child: Slider(
|
||||
value: _currentPercent.clamp(0.0, 1.0),
|
||||
onChanged: (v) {
|
||||
setState(() => _currentPercent = v);
|
||||
onFillPercent(v);
|
||||
},
|
||||
min: 0.0,
|
||||
max: 1.0,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: AppSpacing.xs),
|
||||
|
||||
// 提交按钮
|
||||
SizedBox(
|
||||
@@ -296,7 +337,7 @@ class _SplitTradeFormState extends State<SplitTradeForm>
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: Text(
|
||||
'${_isBuy ? '买入' : '卖出'} ${widget.coin?.code ?? ''}',
|
||||
'${_isBuy ? '買入' : '賣出'} ${widget.coin?.code ?? ''}',
|
||||
style: AppTextStyles.labelLarge(context)
|
||||
.copyWith(color: Colors.white, fontWeight: FontWeight.w700),
|
||||
),
|
||||
@@ -308,20 +349,26 @@ class _SplitTradeFormState extends State<SplitTradeForm>
|
||||
}
|
||||
|
||||
Widget _pctBtn(BuildContext context, String label, double pct, ValueChanged<double> onTap) {
|
||||
final isActive = (_currentPercent - pct).abs() < 0.01;
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => onTap(pct),
|
||||
onTap: () {
|
||||
setState(() => _currentPercent = pct);
|
||||
onTap(pct);
|
||||
},
|
||||
child: Container(
|
||||
height: 28,
|
||||
height: 26,
|
||||
decoration: BoxDecoration(
|
||||
color: context.colors.surfaceContainerHighest.withValues(alpha: 0.4),
|
||||
color: isActive
|
||||
? context.colors.primary.withValues(alpha: 0.15)
|
||||
: context.colors.surfaceContainerHighest.withValues(alpha: 0.4),
|
||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(label,
|
||||
style: AppTextStyles.bodySmall(context).copyWith(
|
||||
color: context.colors.onSurfaceVariant,
|
||||
fontWeight: FontWeight.w500)),
|
||||
color: isActive ? context.colors.primary : context.colors.onSurfaceVariant,
|
||||
fontWeight: isActive ? FontWeight.w600 : FontWeight.w500)),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user