Skip to content

Commit

Permalink
💄 Fix responsive behavior in Farm and Pool cards
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed May 27, 2024
1 parent 765dfe8 commit 224ef89
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,92 +33,81 @@ class FarmDetailsInfoYourAvailableLP extends ConsumerWidget {
}

return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SelectableText(
AppLocalizations.of(context)!.farmDetailsInfoYourAvailableLP,
style: AppTextStyles.bodyLarge(context),
),
Wrap(
children: [
if (balance == null)
const Padding(
padding: EdgeInsets.only(top: 5),
child: SizedBox(
height: 10,
width: 10,
child: CircularProgressIndicator(strokeWidth: 1),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
SelectableText(
balance == null
? ''
: '${balance!.formatNumber()} ${balance! > 1 ? AppLocalizations.of(context)!.lpTokens : AppLocalizations.of(context)!.lpToken}',
style: AppTextStyles.bodyLarge(context),
),
SelectableText(
balance == null
? ''
: DEXLPTokenFiatValue().display(
ref,
farm.lpTokenPair!.token1,
farm.lpTokenPair!.token2,
balance!,
farm.poolAddress,
),
style: AppTextStyles.bodyMedium(context),
),
if (balance != null && balance! > 0)
FutureBuilder<Map<String, dynamic>?>(
future: PoolFactoryRepositoryImpl(
farm.poolAddress,
aedappfm.sl.get<ApiService>(),
).getRemoveAmounts(
balance!,
),
builder: (
context,
snapshotAmounts,
) {
if (snapshotAmounts.hasData &&
snapshotAmounts.data != null) {
final amountToken1 =
snapshotAmounts.data!['token1'] == null
? 0.0
: snapshotAmounts.data!['token1'] as double;
final amountToken2 =
snapshotAmounts.data!['token2'] == null
? 0.0
: snapshotAmounts.data!['token2'] as double;

return SelectableText(
'${AppLocalizations.of(context)!.poolDetailsInfoDepositedEquivalent} ${amountToken1.formatNumber(precision: amountToken1 > 1 ? 2 : 8)} ${farm.lpTokenPair!.token1.symbol.reduceSymbol()} / ${amountToken2.formatNumber(precision: amountToken2 > 1 ? 2 : 8)} ${farm.lpTokenPair!.token2.symbol.reduceSymbol()}',
style: AppTextStyles.bodyMedium(context),
);
}
return SelectableText(
' ',
style: AppTextStyles.bodyMedium(context),
);
},
)
else
SelectableText(
' ',
style: AppTextStyles.bodyMedium(context),
),
],
if (balance == null)
const Padding(
padding: EdgeInsets.only(top: 5),
child: SizedBox(
height: 10,
width: 10,
child: CircularProgressIndicator(strokeWidth: 1),
),
],
),
)
else
SelectableText(
balance == null
? ''
: '${balance!.formatNumber()} ${balance! > 1 ? AppLocalizations.of(context)!.lpTokens : AppLocalizations.of(context)!.lpToken}',
style: AppTextStyles.bodyLarge(context),
),
],
),
SelectableText(
balance == null
? ''
: DEXLPTokenFiatValue().display(
ref,
farm.lpTokenPair!.token1,
farm.lpTokenPair!.token2,
balance!,
farm.poolAddress,
),
style: AppTextStyles.bodyMedium(context),
),
if (balance != null && balance! > 0)
FutureBuilder<Map<String, dynamic>?>(
future: PoolFactoryRepositoryImpl(
farm.poolAddress,
aedappfm.sl.get<ApiService>(),
).getRemoveAmounts(
balance!,
),
builder: (
context,
snapshotAmounts,
) {
if (snapshotAmounts.hasData && snapshotAmounts.data != null) {
final amountToken1 = snapshotAmounts.data!['token1'] == null
? 0.0
: snapshotAmounts.data!['token1'] as double;
final amountToken2 = snapshotAmounts.data!['token2'] == null
? 0.0
: snapshotAmounts.data!['token2'] as double;

return SelectableText(
'${AppLocalizations.of(context)!.poolDetailsInfoDepositedEquivalent} ${amountToken1.formatNumber(precision: amountToken1 > 1 ? 2 : 8)} ${farm.lpTokenPair!.token1.symbol.reduceSymbol()} / ${amountToken2.formatNumber(precision: amountToken2 > 1 ? 2 : 8)} ${farm.lpTokenPair!.token2.symbol.reduceSymbol()}',
style: AppTextStyles.bodyMedium(context),
);
}
return SelectableText(
' ',
style: AppTextStyles.bodyMedium(context),
);
},
)
else
SelectableText(
' ',
style: AppTextStyles.bodyMedium(context),
),
const SizedBox(
height: 40,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ class FarmDetailsInfoYourDepositedAmount extends ConsumerWidget {
BuildContext context,
WidgetRef ref,
) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: SelectableText(
AppLocalizations.of(context)!.farmDetailsInfoYourDepositedAmount,
style: AppTextStyles.bodyLarge(context),
),
),
Wrap(
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SelectableText(
AppLocalizations.of(context)!.farmDetailsInfoYourDepositedAmount,
style: AppTextStyles.bodyLarge(context),
),
if (farm.depositedAmount == null)
const Padding(
padding: EdgeInsets.only(top: 5),
Expand All @@ -42,71 +40,64 @@ class FarmDetailsInfoYourDepositedAmount extends ConsumerWidget {
width: 10,
child: CircularProgressIndicator(strokeWidth: 1),
),
)
else
SelectableText(
farm.depositedAmount == null
? ''
: '${farm.depositedAmount!.formatNumber()} ${farm.depositedAmount! > 1 ? AppLocalizations.of(context)!.lpTokens : AppLocalizations.of(context)!.lpToken}',
style: AppTextStyles.bodyLarge(context),
),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
SelectableText(
farm.depositedAmount == null
? ''
: '${farm.depositedAmount!.formatNumber()} ${farm.depositedAmount! > 1 ? AppLocalizations.of(context)!.lpTokens : AppLocalizations.of(context)!.lpToken}',
style: AppTextStyles.bodyLarge(context),
),
SelectableText(
farm.depositedAmount == null
? ''
: DEXLPTokenFiatValue().display(
ref,
farm.lpTokenPair!.token1,
farm.lpTokenPair!.token2,
farm.depositedAmount!,
farm.poolAddress,
),
style: AppTextStyles.bodyMedium(context),
),
if (farm.depositedAmount != null && farm.depositedAmount! > 0)
FutureBuilder<Map<String, dynamic>?>(
future: PoolFactoryRepositoryImpl(
farm.poolAddress,
aedappfm.sl.get<ApiService>(),
).getRemoveAmounts(
farm.depositedAmount!,
),
builder: (
context,
snapshotAmounts,
) {
if (snapshotAmounts.hasData &&
snapshotAmounts.data != null) {
final amountToken1 =
snapshotAmounts.data!['token1'] == null
? 0.0
: snapshotAmounts.data!['token1'] as double;
final amountToken2 =
snapshotAmounts.data!['token2'] == null
? 0.0
: snapshotAmounts.data!['token2'] as double;

return SelectableText(
'${AppLocalizations.of(context)!.poolDetailsInfoDepositedEquivalent} ${amountToken1.formatNumber(precision: amountToken1 > 1 ? 2 : 8)} ${farm.lpTokenPair!.token1.symbol.reduceSymbol()} / ${amountToken2.formatNumber(precision: amountToken2 > 1 ? 2 : 8)} ${farm.lpTokenPair!.token2.symbol.reduceSymbol()}',
style: AppTextStyles.bodyMedium(context),
);
}
return SelectableText(
' ',
style: AppTextStyles.bodyMedium(context),
);
},
)
else
SelectableText(
' ',
style: AppTextStyles.bodyMedium(context),
),
],
),
],
),
SelectableText(
farm.depositedAmount == null
? ''
: DEXLPTokenFiatValue().display(
ref,
farm.lpTokenPair!.token1,
farm.lpTokenPair!.token2,
farm.depositedAmount!,
farm.poolAddress,
),
style: AppTextStyles.bodyMedium(context),
),
if (farm.depositedAmount != null && farm.depositedAmount! > 0)
FutureBuilder<Map<String, dynamic>?>(
future: PoolFactoryRepositoryImpl(
farm.poolAddress,
aedappfm.sl.get<ApiService>(),
).getRemoveAmounts(
farm.depositedAmount!,
),
builder: (
context,
snapshotAmounts,
) {
if (snapshotAmounts.hasData && snapshotAmounts.data != null) {
final amountToken1 = snapshotAmounts.data!['token1'] == null
? 0.0
: snapshotAmounts.data!['token1'] as double;
final amountToken2 = snapshotAmounts.data!['token2'] == null
? 0.0
: snapshotAmounts.data!['token2'] as double;

return SelectableText(
'${AppLocalizations.of(context)!.poolDetailsInfoDepositedEquivalent} ${amountToken1.formatNumber(precision: amountToken1 > 1 ? 2 : 8)} ${farm.lpTokenPair!.token1.symbol.reduceSymbol()} / ${amountToken2.formatNumber(precision: amountToken2 > 1 ? 2 : 8)} ${farm.lpTokenPair!.token2.symbol.reduceSymbol()}',
style: AppTextStyles.bodyMedium(context),
);
}
return SelectableText(
' ',
style: AppTextStyles.bodyMedium(context),
);
},
)
else
SelectableText(
' ',
style: AppTextStyles.bodyMedium(context),
),
],
);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/ui/views/farm_list/farm_list_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ Widget _body(BuildContext context, WidgetRef ref) {
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: MediaQuery.of(context).size.width >= 1500
? 3
: aedappfm.Responsive.isDesktop(context) ||
aedappfm.Responsive.isTablet(context)
: aedappfm.Responsive.isDesktop(context)
? 2
: 1,
mainAxisExtent: 640,
Expand Down
3 changes: 1 addition & 2 deletions lib/ui/views/pool_list/pool_list_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ Widget _body(BuildContext context, WidgetRef ref, PoolsListTab tab) {
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: MediaQuery.of(context).size.width >= 1500
? 3
: aedappfm.Responsive.isDesktop(context) ||
aedappfm.Responsive.isTablet(context)
: aedappfm.Responsive.isDesktop(context)
? 2
: 1,
mainAxisExtent: 550,
Expand Down

0 comments on commit 224ef89

Please sign in to comment.