Skip to content

Commit

Permalink
Merge pull request #122 from archethic-foundation/121-responsive
Browse files Browse the repository at this point in the history
💄 Adapt responsive UI
  • Loading branch information
redDwarf03 authored Mar 15, 2024
2 parents 06f67a8 + 440d360 commit e72ed06
Show file tree
Hide file tree
Showing 63 changed files with 2,673 additions and 735 deletions.
2 changes: 1 addition & 1 deletion lib/application/pool/dex_pool.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions lib/application/session/provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:async';
import 'package:aedex/application/dex_token.dart';
import 'package:aedex/application/pool/dex_pool.dart';
import 'package:aedex/application/session/state.dart';
import 'package:aedex/infrastructure/hive/pools_list.hive.dart';
import 'package:aedex/infrastructure/hive/preferences.hive.dart';
import 'package:aedex/util/browser_util_desktop.dart'
if (dart.library.js) 'package:aedex/util/browser_util_web.dart';
Expand Down Expand Up @@ -67,7 +68,6 @@ class _SessionNotifier extends Notifier<Session> {
state = state.copyWith(
isConnected: false,
error: '',
endpoint: '',
genesisAddress: '',
nameAccount: '',
);
Expand All @@ -89,6 +89,12 @@ class _SessionNotifier extends Notifier<Session> {
_handleConnectionFailure(isBrave);
},
success: (result) async {
if (state.endpoint != result.endpointUrl) {
final poolsListDatasource =
await HivePoolsListDatasource.getInstance();
await poolsListDatasource.clearAll();
}

state = state.copyWith(
endpoint: result.endpointUrl,
isConnected: true,
Expand Down Expand Up @@ -175,7 +181,7 @@ class _SessionNotifier extends Notifier<Session> {
},
);
} catch (e) {
if (forceConnection == false) {
if (forceConnection == true) {
_handleConnectionFailure(isBrave);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/application/session/provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/application/session/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ part 'state.freezed.dart';
@freezed
class Session with _$Session {
const factory Session({
// TODO(reddwarf03): MAINNET
//@Default('mainnet') String envSelected,
@Default('testnet') String envSelected,
@Default('') String endpoint,
@Default('') String nameAccount,
Expand Down
7 changes: 6 additions & 1 deletion lib/application/session/state.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ final _privateConstructorUsedError = UnsupportedError(

/// @nodoc
mixin _$Session {
// TODO(reddwarf03): MAINNET
//@Default('mainnet') String envSelected,
String get envSelected => throw _privateConstructorUsedError;
String get endpoint => throw _privateConstructorUsedError;
String get nameAccount => throw _privateConstructorUsedError;
Expand Down Expand Up @@ -225,6 +227,8 @@ class _$SessionImpl extends _Session {
this.accountStreamSub})
: super._();

// TODO(reddwarf03): MAINNET
//@Default('mainnet') String envSelected,
@override
@JsonKey()
final String envSelected;
Expand Down Expand Up @@ -313,7 +317,8 @@ abstract class _Session extends Session {
final StreamSubscription<Account>? accountStreamSub}) = _$SessionImpl;
const _Session._() : super._();

@override
@override // TODO(reddwarf03): MAINNET
//@Default('mainnet') String envSelected,
String get envSelected;
@override
String get endpoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,16 @@ class FarmClaimConfirmInfos extends ConsumerWidget {
children: [
TextSpan(
text: 'Please confirm the claim of ',
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
fontSize:
aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
TextSpan(
text: farmClaim.dexFarmUserInfo!.rewardAmount
Expand All @@ -65,15 +74,38 @@ class FarmClaimConfirmInfos extends ConsumerWidget {
.bodyLarge!
.copyWith(
color: aedappfm.AppThemeBase.secondaryColor,
fontSize:
aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
TextSpan(
text: ' ${farmClaim.rewardToken!.symbol}',
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
fontSize:
aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
TextSpan(
text: ' ${snapshot.data} ',
style: Theme.of(context).textTheme.bodyMedium,
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
fontSize:
aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyMedium!,
),
),
),
],
),
Expand All @@ -99,11 +131,21 @@ class FarmClaimConfirmInfos extends ConsumerWidget {
children: [
SelectableText(
AppLocalizations.of(context)!.confirmBeforeLbl,
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
SelectableText(
AppLocalizations.of(context)!.confirmAfterLbl,
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:aedex/ui/views/farm_list/farm_list_sheet.dart';
import 'package:aedex/ui/views/util/components/failure_message.dart';

import 'package:aedex/ui/views/util/components/fiat_value.dart';

import 'package:archethic_dapp_framework_flutter/archethic_dapp_framework_flutter.dart'
as aedappfm;
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -90,22 +91,59 @@ class FarmClaimFormSheet extends ConsumerWidget {
.copyWith(
color: aedappfm
.AppThemeBase.secondaryColor,
fontSize: aedappfm.Responsive
.fontSizeFromTextStyle(
context,
Theme.of(context)
.textTheme
.bodyLarge!,
),
),
),
TextSpan(
text: ' ${farmClaim.rewardToken!.symbol}',
style:
Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
fontSize: aedappfm.Responsive
.fontSizeFromTextStyle(
context,
Theme.of(context)
.textTheme
.bodyLarge!,
),
),
),
TextSpan(
text: ' ${snapshot.data} ',
style:
Theme.of(context).textTheme.bodyMedium,
style: Theme.of(context)
.textTheme
.bodyMedium!
.copyWith(
fontSize: aedappfm.Responsive
.fontSizeFromTextStyle(
context,
Theme.of(context)
.textTheme
.bodyMedium!,
),
),
),
TextSpan(
text: 'are available for claiming.',
style:
Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
fontSize: aedappfm.Responsive
.fontSizeFromTextStyle(
context,
Theme.of(context)
.textTheme
.bodyLarge!,
),
),
),
],
),
Expand All @@ -130,6 +168,10 @@ class FarmClaimFormSheet extends ConsumerWidget {
Expanded(
child: aedappfm.ButtonValidate(
controlOk: farmClaim.isControlsOk,
fontSize: aedappfm.Responsive.fontSizeFromValue(
context,
desktopValue: 16,
),
labelBtn:
AppLocalizations.of(context)!.btn_farm_claim,
onPressed: () => ref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,32 @@ class FarmDepositConfirmInfos extends ConsumerWidget {
children: [
TextSpan(
text: 'Please confirm the deposit of ',
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
TextSpan(
text: farmDeposit.amount.formatNumber(precision: 8),
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
color: aedappfm.AppThemeBase.secondaryColor,
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
TextSpan(
text:
' ${farmDeposit.amount > 1 ? 'LP Tokens' : 'LP Token'}',
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
],
),
Expand All @@ -68,7 +82,12 @@ class FarmDepositConfirmInfos extends ConsumerWidget {
children: [
SelectableText(
'Your balance',
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
const SizedBox(
width: 5,
Expand All @@ -88,11 +107,21 @@ class FarmDepositConfirmInfos extends ConsumerWidget {
children: [
SelectableText(
AppLocalizations.of(context)!.confirmBeforeLbl,
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
SelectableText(
AppLocalizations.of(context)!.confirmAfterLbl,
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
],
),
Expand Down Expand Up @@ -126,7 +155,12 @@ class FarmDepositConfirmInfos extends ConsumerWidget {
children: [
SelectableText(
"Farm's balance",
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
const SizedBox(
width: 5,
Expand All @@ -146,11 +180,21 @@ class FarmDepositConfirmInfos extends ConsumerWidget {
children: [
SelectableText(
AppLocalizations.of(context)!.confirmBeforeLbl,
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
SelectableText(
AppLocalizations.of(context)!.confirmAfterLbl,
style: Theme.of(context).textTheme.bodyLarge,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyLarge!,
),
),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class FarmDepositFormSheet extends ConsumerWidget {
Expanded(
child: aedappfm.ButtonValidate(
controlOk: farmDeposit.isControlsOk,
fontSize: aedappfm.Responsive.fontSizeFromValue(
context,
desktopValue: 16,
),
labelBtn: AppLocalizations.of(context)!
.btn_farm_deposit,
onPressed: () => ref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,12 @@ class _FarmDepositToken1AmountState extends ConsumerState<FarmDepositAmount> {
),
style: Theme.of(
context,
).textTheme.bodyMedium,
).textTheme.bodyMedium!.copyWith(
fontSize: aedappfm.Responsive.fontSizeFromTextStyle(
context,
Theme.of(context).textTheme.bodyMedium!,
),
),
),
],
),
Expand Down
Loading

0 comments on commit e72ed06

Please sign in to comment.