Skip to content

Commit

Permalink
💄 Add DApps tab
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed May 20, 2024
1 parent e28e43a commit 7749060
Show file tree
Hide file tree
Showing 19 changed files with 705 additions and 236 deletions.
1 change: 1 addition & 0 deletions devtools_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extensions:
1 change: 0 additions & 1 deletion lib/domain/repositories/features_flags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
class FeatureFlags {
static const messagingActive = false;
static const forceLogout = false;
static const dexActive = true;
}
1 change: 0 additions & 1 deletion lib/infrastructure/repositories/dapps_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class DAppsRepositoryImpl implements DAppsRepositoryInterface {
final dApps = await _getDAppsLocal();
switch (network) {
// aeWallet-DApps-Conf service
// TODO(reddwarf03): Get true addresses
case AvailableNetworks.archethicTestNet:
return _getDAppsFromBlockchain(
'00009087BB05F2D4DDBDFA833486CD303A805C5F73154473E5604BEB1C1512475B42',
Expand Down
10 changes: 8 additions & 2 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@
"bottomMainMenuAddressBook": "Address book",
"bottomMainMenuKeychain": "Keychain",
"bottomMainMenuMain": "Main",
"bottomMainMenuNFT": "NFT",
"bottomMainMenuMessenger": "Messenger",
"youHaveBeenAddedToADiscussion": "You have been added to a discussion",
"leaveDiscussion": "Leave the discussion",
Expand All @@ -522,5 +521,12 @@
"seedHex": "View in Hexadecimal",
"burnAddressLbl": "Burn address",
"webChannelIncompatibilityWarning": "Unsupported operating system",
"webChannelIncompatibilityWarningDesc": "Your operating system Webview does not support required MessageChannel feature."
"webChannelIncompatibilityWarningDesc": "Your operating system Webview does not support required MessageChannel feature.",
"dAppsHeader": "DApps",
"nftHeader": "NFT",
"aeSwapHeader": "aeSwap",
"bottomMainMenuDApps": "DApps",
"dappsTabDescriptionHeader": "Accelerate adoption with native services",
"dappsAESwapDesc": "Swap assets on-chain and access yield farming by adding liquidity",
"dappsNFTDesc": "Create your own no-code NFT"
}
10 changes: 8 additions & 2 deletions lib/l10n/intl_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@
"bottomMainMenuAddressBook": "Contacts",
"bottomMainMenuKeychain": "Porte-clés",
"bottomMainMenuMain": "Accueil",
"bottomMainMenuNFT": "NFT",
"bottomMainMenuMessenger": "Discussions",
"youHaveBeenAddedToADiscussion": "Vous avez été ajouté à une discussion",
"leaveDiscussion": "Quitter la discussion",
Expand All @@ -497,5 +496,12 @@
"seedHex": "Voir en hexadécimal",
"burnAddressLbl": "Burn address",
"webChannelIncompatibilityWarning": "Système non compatible",
"webChannelIncompatibilityWarningDesc": "Votre système ne supporte pas les MessageChannels."
"webChannelIncompatibilityWarningDesc": "Votre système ne supporte pas les MessageChannels.",
"dAppsHeader": "DApps",
"nftHeader": "NFT",
"aeSwapHeader": "aeSwap",
"bottomMainMenuDApps": "DApps",
"dappsTabDescriptionHeader": "Accélérez l'adoption avec des services natifs",
"dappsAESwapDesc": "Échangez des actifs on-chain, ajoutez de la liquidité et accédez au yield farming",
"dappsNFTDesc": "Créez votre propre NFT sans coder"
}
16 changes: 16 additions & 0 deletions lib/model/dapps_info.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// SPDX-License-Identifier: AGPL-3.0-or-later
import 'package:freezed_annotation/freezed_annotation.dart';

part 'dapps_info.freezed.dart';

@freezed
class DAppsInfo with _$DAppsInfo {
const factory DAppsInfo({
String? dAppName,
String? dAppDesc,
String? dAppLink,
String? dAppBackgroundImgCard,
}) = _DAppsInfo;
const DAppsInfo._();
}
199 changes: 199 additions & 0 deletions lib/model/dapps_info.freezed.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark

part of 'dapps_info.dart';

// **************************************************************************
// FreezedGenerator
// **************************************************************************

T _$identity<T>(T value) => value;

final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');

/// @nodoc
mixin _$DAppsInfo {
String? get dAppName => throw _privateConstructorUsedError;
String? get dAppDesc => throw _privateConstructorUsedError;
String? get dAppLink => throw _privateConstructorUsedError;
String? get dAppBackgroundImgCard => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
$DAppsInfoCopyWith<DAppsInfo> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $DAppsInfoCopyWith<$Res> {
factory $DAppsInfoCopyWith(DAppsInfo value, $Res Function(DAppsInfo) then) =
_$DAppsInfoCopyWithImpl<$Res, DAppsInfo>;
@useResult
$Res call(
{String? dAppName,
String? dAppDesc,
String? dAppLink,
String? dAppBackgroundImgCard});
}

/// @nodoc
class _$DAppsInfoCopyWithImpl<$Res, $Val extends DAppsInfo>
implements $DAppsInfoCopyWith<$Res> {
_$DAppsInfoCopyWithImpl(this._value, this._then);

// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;

@pragma('vm:prefer-inline')
@override
$Res call({
Object? dAppName = freezed,
Object? dAppDesc = freezed,
Object? dAppLink = freezed,
Object? dAppBackgroundImgCard = freezed,
}) {
return _then(_value.copyWith(
dAppName: freezed == dAppName
? _value.dAppName
: dAppName // ignore: cast_nullable_to_non_nullable
as String?,
dAppDesc: freezed == dAppDesc
? _value.dAppDesc
: dAppDesc // ignore: cast_nullable_to_non_nullable
as String?,
dAppLink: freezed == dAppLink
? _value.dAppLink
: dAppLink // ignore: cast_nullable_to_non_nullable
as String?,
dAppBackgroundImgCard: freezed == dAppBackgroundImgCard
? _value.dAppBackgroundImgCard
: dAppBackgroundImgCard // ignore: cast_nullable_to_non_nullable
as String?,
) as $Val);
}
}

/// @nodoc
abstract class _$$DAppsInfoImplCopyWith<$Res>
implements $DAppsInfoCopyWith<$Res> {
factory _$$DAppsInfoImplCopyWith(
_$DAppsInfoImpl value, $Res Function(_$DAppsInfoImpl) then) =
__$$DAppsInfoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String? dAppName,
String? dAppDesc,
String? dAppLink,
String? dAppBackgroundImgCard});
}

/// @nodoc
class __$$DAppsInfoImplCopyWithImpl<$Res>
extends _$DAppsInfoCopyWithImpl<$Res, _$DAppsInfoImpl>
implements _$$DAppsInfoImplCopyWith<$Res> {
__$$DAppsInfoImplCopyWithImpl(
_$DAppsInfoImpl _value, $Res Function(_$DAppsInfoImpl) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
@override
$Res call({
Object? dAppName = freezed,
Object? dAppDesc = freezed,
Object? dAppLink = freezed,
Object? dAppBackgroundImgCard = freezed,
}) {
return _then(_$DAppsInfoImpl(
dAppName: freezed == dAppName
? _value.dAppName
: dAppName // ignore: cast_nullable_to_non_nullable
as String?,
dAppDesc: freezed == dAppDesc
? _value.dAppDesc
: dAppDesc // ignore: cast_nullable_to_non_nullable
as String?,
dAppLink: freezed == dAppLink
? _value.dAppLink
: dAppLink // ignore: cast_nullable_to_non_nullable
as String?,
dAppBackgroundImgCard: freezed == dAppBackgroundImgCard
? _value.dAppBackgroundImgCard
: dAppBackgroundImgCard // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}

/// @nodoc
class _$DAppsInfoImpl extends _DAppsInfo {
const _$DAppsInfoImpl(
{this.dAppName, this.dAppDesc, this.dAppLink, this.dAppBackgroundImgCard})
: super._();

@override
final String? dAppName;
@override
final String? dAppDesc;
@override
final String? dAppLink;
@override
final String? dAppBackgroundImgCard;

@override
String toString() {
return 'DAppsInfo(dAppName: $dAppName, dAppDesc: $dAppDesc, dAppLink: $dAppLink, dAppBackgroundImgCard: $dAppBackgroundImgCard)';
}

@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$DAppsInfoImpl &&
(identical(other.dAppName, dAppName) ||
other.dAppName == dAppName) &&
(identical(other.dAppDesc, dAppDesc) ||
other.dAppDesc == dAppDesc) &&
(identical(other.dAppLink, dAppLink) ||
other.dAppLink == dAppLink) &&
(identical(other.dAppBackgroundImgCard, dAppBackgroundImgCard) ||
other.dAppBackgroundImgCard == dAppBackgroundImgCard));
}

@override
int get hashCode => Object.hash(
runtimeType, dAppName, dAppDesc, dAppLink, dAppBackgroundImgCard);

@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$DAppsInfoImplCopyWith<_$DAppsInfoImpl> get copyWith =>
__$$DAppsInfoImplCopyWithImpl<_$DAppsInfoImpl>(this, _$identity);
}

abstract class _DAppsInfo extends DAppsInfo {
const factory _DAppsInfo(
{final String? dAppName,
final String? dAppDesc,
final String? dAppLink,
final String? dAppBackgroundImgCard}) = _$DAppsInfoImpl;
const _DAppsInfo._() : super._();

@override
String? get dAppName;
@override
String? get dAppDesc;
@override
String? get dAppLink;
@override
String? get dAppBackgroundImgCard;
@override
@JsonKey(ignore: true)
_$$DAppsInfoImplCopyWith<_$DAppsInfoImpl> get copyWith =>
throw _privateConstructorUsedError;
}
18 changes: 15 additions & 3 deletions lib/router/router.authenticated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ final _authenticatedRoutes = [
FadeTransition(opacity: animation, child: child),
),
),
GoRoute(
path: NFTTab.routerPage,
pageBuilder: (context, state) => CustomTransitionPage<void>(
transitionDuration: Duration.zero,
reverseTransitionDuration: Duration.zero,
key: state.pageKey,
child: const NFTTab(),
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
FadeTransition(
opacity: animation,
child: child,
),
),
),
GoRoute(
path: NFTListPerCategory.routerPage,
pageBuilder: (context, state) => CustomTransitionPage<void>(
Expand Down Expand Up @@ -210,9 +224,7 @@ final _authenticatedRoutes = [
transitionDuration: Duration.zero,
reverseTransitionDuration: Duration.zero,
key: state.pageKey,
child: DEXSheet(
url: state.extra! as String,
),
child: const DEXSheet(),
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
FadeTransition(opacity: animation, child: child),
),
Expand Down
1 change: 1 addition & 0 deletions lib/router/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'package:aewallet/ui/views/intro/layouts/intro_new_wallet_disclaimer.dart
import 'package:aewallet/ui/views/intro/layouts/intro_new_wallet_get_first_infos.dart';
import 'package:aewallet/ui/views/intro/layouts/intro_welcome.dart';
import 'package:aewallet/ui/views/main/home_page.dart';
import 'package:aewallet/ui/views/main/nft_tab.dart';
import 'package:aewallet/ui/views/messenger/layouts/add_discussion_sheet.dart';
import 'package:aewallet/ui/views/messenger/layouts/create_discussion_sheet.dart';
import 'package:aewallet/ui/views/messenger/layouts/create_discussion_validation_sheet.dart';
Expand Down
55 changes: 0 additions & 55 deletions lib/ui/menu/settings/main_settings_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,6 @@ class MainMenuView extends ConsumerWidget {
ref.watch(AccountProviders.selectedAccount).valueOrNull;
final connectivityStatusProvider = ref.watch(connectivityStatusProviders);

final networkSettings = ref.watch(
SettingsProviders.settings.select((settings) => settings.network),
);

DApp? aeSwapUrl;
if (connectivityStatusProvider == ConnectivityStatus.isConnected &&
FeatureFlags.dexActive &&
DEXSheet.isAvailable) {
ref.watch(DAppsProviders.getDApp(networkSettings.network, 'aeSwap')).map(
data: (data) {
aeSwapUrl = data.value;
},
error: (error) {},
loading: (loading) {},
);
}

if (selectedAccount == null) return const SizedBox();

return DecoratedBox(
Expand Down Expand Up @@ -73,44 +56,6 @@ class MainMenuView extends ConsumerWidget {
),
),
),
if (aeSwapUrl != null)
Column(
children: [
if (connectivityStatusProvider ==
ConnectivityStatus.isConnected &&
FeatureFlags.dexActive &&
DEXSheet.isAvailable)
const _SettingsListItem.spacer(),
if (connectivityStatusProvider ==
ConnectivityStatus.isConnected &&
FeatureFlags.dexActive &&
DEXSheet.isAvailable)
_SettingsListItem.title(
text: localizations.dapp,
),
if (connectivityStatusProvider ==
ConnectivityStatus.isConnected &&
FeatureFlags.dexActive &&
DEXSheet.isAvailable)
const _SettingsListItem.spacer(),
if (connectivityStatusProvider ==
ConnectivityStatus.isConnected &&
FeatureFlags.dexActive &&
DEXSheet.isAvailable)
_SettingsListItem.singleLineWithInfos(
heading: localizations.aeSwapLinkHeader,
info: localizations.aeSwapLinkDesc,
icon: Symbols.swap_horiz_rounded,
onPressed: () async {
await context.push(
DEXSheet.routerPage,
extra: aeSwapUrl!.url,
);
},
background: ArchethicTheme.backgroundAESwap,
),
],
),
const _SettingsListItem.spacer(),
_SettingsListItem.title(text: localizations.information),
const _SettingsListItem.spacer(),
Expand Down
Loading

0 comments on commit 7749060

Please sign in to comment.