Skip to content
Merged
11 changes: 4 additions & 7 deletions lib/bloc/coins_bloc/coins_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -553,22 +553,19 @@ class CoinsRepo {
if (fiatPrice != null) {
// Use configSymbol to lookup for backwards compatibility with the old,
// string-based price list (and fallback)
double? change24h;
Decimal? change24h;
try {
final change24hDecimal = await _kdfSdk.marketData.priceChange24h(
asset.id,
);
change24h = change24hDecimal?.toDouble();
change24h = await _kdfSdk.marketData.priceChange24h(asset.id);
} catch (e) {
_log.warning('Failed to get 24h change for ${asset.id.id}: $e');
// Continue with null change24h rather than failing the entire price update
// Continue without 24h change data
}

_pricesCache[asset.id.symbol.configSymbol] = CexPrice(
ticker: asset.id.id,
price: fiatPrice.toDouble(),
lastUpdated: DateTime.now(),
change24h: change24h,
change24h: change24h?.toDouble(),
Comment thread
cursor[bot] marked this conversation as resolved.
);
}
} catch (e) {
Expand Down
54 changes: 47 additions & 7 deletions lib/views/dex/simple/form/maker/maker_form_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,33 @@ class _MakerFormLayoutState extends State<MakerFormLayout> {
}
}

class _MakerFormDesktopLayout extends StatelessWidget {
class _MakerFormDesktopLayout extends StatefulWidget {
const _MakerFormDesktopLayout();

@override
State<_MakerFormDesktopLayout> createState() => _MakerFormDesktopLayoutState();
}

class _MakerFormDesktopLayoutState extends State<_MakerFormDesktopLayout> {
late final ScrollController _mainScrollController;
late final ScrollController _orderbookScrollController;

@override
void initState() {
super.initState();
_mainScrollController = ScrollController();
_orderbookScrollController = ScrollController();
}

@override
void dispose() {
_mainScrollController.dispose();
_orderbookScrollController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
final scrollController = ScrollController();
return Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -119,11 +140,11 @@ class _MakerFormDesktopLayout extends StatelessWidget {
Flexible(
flex: 6,
child: DexScrollbar(
scrollController: scrollController,
scrollController: _mainScrollController,
isMobile: isMobile,
child: SingleChildScrollView(
key: const Key('maker-form-layout-scroll'),
controller: scrollController,
controller: _mainScrollController,
child: ConstrainedBox(
constraints:
BoxConstraints(maxWidth: theme.custom.dexFormWidth),
Expand All @@ -144,7 +165,7 @@ class _MakerFormDesktopLayout extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: SingleChildScrollView(
controller: ScrollController(),
controller: _orderbookScrollController,
child: const MakerFormOrderbook(),
),
),
Expand All @@ -154,14 +175,33 @@ class _MakerFormDesktopLayout extends StatelessWidget {
}
}

class _MakerFormMobileLayout extends StatelessWidget {
class _MakerFormMobileLayout extends StatefulWidget {
const _MakerFormMobileLayout();

@override
State<_MakerFormMobileLayout> createState() => _MakerFormMobileLayoutState();
}

class _MakerFormMobileLayoutState extends State<_MakerFormMobileLayout> {
late final ScrollController _scrollController;

@override
void initState() {
super.initState();
_scrollController = ScrollController();
}

@override
void dispose() {
_scrollController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
key: const Key('maker-form-layout-scroll'),
controller: ScrollController(),
controller: _scrollController,
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: theme.custom.dexFormWidth),
child: const Stack(
Expand Down
54 changes: 47 additions & 7 deletions lib/views/market_maker_bot/market_maker_bot_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,33 @@ class MarketMakerBotForm extends StatelessWidget {
}
}

class _MakerFormDesktopLayout extends StatelessWidget {
class _MakerFormDesktopLayout extends StatefulWidget {
const _MakerFormDesktopLayout();

@override
State<_MakerFormDesktopLayout> createState() => _MakerFormDesktopLayoutState();
}

class _MakerFormDesktopLayoutState extends State<_MakerFormDesktopLayout> {
late final ScrollController _mainScrollController;
late final ScrollController _orderbookScrollController;

@override
void initState() {
super.initState();
_mainScrollController = ScrollController();
_orderbookScrollController = ScrollController();
}

@override
void dispose() {
_mainScrollController.dispose();
_orderbookScrollController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
final scrollController = ScrollController();
return Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
Expand All @@ -73,11 +94,11 @@ class _MakerFormDesktopLayout extends StatelessWidget {
Flexible(
flex: 6,
child: DexScrollbar(
scrollController: scrollController,
scrollController: _mainScrollController,
isMobile: isMobile,
child: SingleChildScrollView(
key: const Key('maker-form-layout-scroll'),
controller: scrollController,
controller: _mainScrollController,
child: ConstrainedBox(
constraints:
BoxConstraints(maxWidth: theme.custom.dexFormWidth),
Expand All @@ -101,7 +122,7 @@ class _MakerFormDesktopLayout extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.only(left: 20),
child: SingleChildScrollView(
controller: ScrollController(),
controller: _orderbookScrollController,
child: const MarketMakerBotOrderbook(),
),
),
Expand All @@ -111,14 +132,33 @@ class _MakerFormDesktopLayout extends StatelessWidget {
}
}

class _MakerFormMobileLayout extends StatelessWidget {
class _MakerFormMobileLayout extends StatefulWidget {
const _MakerFormMobileLayout();

@override
State<_MakerFormMobileLayout> createState() => _MakerFormMobileLayoutState();
}

class _MakerFormMobileLayoutState extends State<_MakerFormMobileLayout> {
late final ScrollController _scrollController;

@override
void initState() {
super.initState();
_scrollController = ScrollController();
}

@override
void dispose() {
_scrollController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return SingleChildScrollView(
key: const Key('maker-form-layout-scroll'),
controller: ScrollController(),
controller: _scrollController,
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: theme.custom.dexFormWidth),
child: Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ class CoinDetailsInfoFiat extends StatelessWidget {
padding: isMobile ? null : const EdgeInsets.fromLTRB(0, 6, 4, 0),
child: Flex(
direction: isMobile ? Axis.horizontal : Axis.vertical,
mainAxisAlignment:
isMobile ? MainAxisAlignment.spaceBetween : MainAxisAlignment.end,
crossAxisAlignment:
isMobile ? CrossAxisAlignment.center : CrossAxisAlignment.end,
mainAxisAlignment: isMobile
? MainAxisAlignment.spaceBetween
: MainAxisAlignment.end,
crossAxisAlignment: isMobile
? CrossAxisAlignment.center
: CrossAxisAlignment.end,
mainAxisSize: isMobile ? MainAxisSize.max : MainAxisSize.min,
children: [
if (isMobile) _AssetFiatBalance(isMobile: isMobile, coin: coin),
Expand All @@ -45,10 +47,7 @@ class CoinDetailsInfoFiat extends StatelessWidget {
}

class _AssetFiatPrice extends StatelessWidget {
const _AssetFiatPrice({
required this.coin,
required this.isMobile,
});
const _AssetFiatPrice({required this.coin, required this.isMobile});

final Coin coin;
final bool isMobile;
Expand All @@ -69,13 +68,15 @@ class _AssetFiatPrice extends StatelessWidget {
return Flex(
direction: isMobile ? Axis.vertical : Axis.horizontal,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, // Prevent layout constraint violations
mainAxisSize: MainAxisSize.min,
children: [
Text(LocaleKeys.price.tr(),
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(fontSize: 14, fontWeight: FontWeight.w500)),
Text(
LocaleKeys.price.tr(),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
isMobile ? const SizedBox(height: 3) : const SizedBox(width: 10),
Row(
children: [
Expand Down Expand Up @@ -119,13 +120,16 @@ class _AssetFiatValuePercentageChange extends StatelessWidget {
return Flex(
direction: isMobile ? Axis.vertical : Axis.horizontal,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, // Prevent layout constraint violations
mainAxisSize:
MainAxisSize.min, // Prevent layout constraint violations
children: [
Text(LocaleKeys.change24h.tr(),
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(fontSize: 14, fontWeight: FontWeight.w500)),
Text(
LocaleKeys.change24h.tr(),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
isMobile ? const SizedBox(height: 3) : const SizedBox(width: 10),
TrendPercentageText(
percentage: change24hPercent,
Expand All @@ -146,10 +150,7 @@ class _AssetFiatValuePercentageChange extends StatelessWidget {
}

class _AssetFiatBalance extends StatelessWidget {
const _AssetFiatBalance({
required this.isMobile,
required this.coin,
});
const _AssetFiatBalance({required this.isMobile, required this.coin});

final bool isMobile;
final Coin coin;
Expand All @@ -164,18 +165,15 @@ class _AssetFiatBalance extends StatelessWidget {
Text(
LocaleKeys.fiatBalance.tr(),
style: Theme.of(context).textTheme.titleSmall!.copyWith(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context).textTheme.bodyMedium?.color,
),
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context).textTheme.bodyMedium?.color,
),
),
isMobile ? const SizedBox(height: 3) : const SizedBox(width: 10),
CoinFiatBalance(
coin,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
),
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w700),
),
],
);
Expand Down
Loading