Skip to content

Commit

Permalink
✨ Add genesis address in main screen & contact sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed Jun 13, 2024
1 parent a815a1a commit b350487
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 133 deletions.
1 change: 1 addition & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
"refresh": "Refresh",
"chart": "Chart",
"share": "Share",
"display": "Display",
"chartOptionLabel1h": "1h",
"chartOptionLabel14d": "14d",
"chartOptionLabel1y": "1y",
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/intl_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
"refresh": "Actualiser",
"chart": "Cours",
"share": "Partager",
"display": "Afficher",
"chartOptionLabel1h": "1h",
"chartOptionLabel14d": "14j",
"chartOptionLabel1y": "1a",
Expand Down
63 changes: 55 additions & 8 deletions lib/ui/views/accounts/layouts/components/account_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import 'package:aewallet/model/data/contact.dart';
import 'package:aewallet/model/primary_currency.dart';
import 'package:aewallet/ui/themes/archethic_theme.dart';
import 'package:aewallet/ui/themes/styles.dart';
import 'package:aewallet/ui/util/address_formatters.dart';
import 'package:aewallet/ui/util/service_type_formatters.dart';
import 'package:aewallet/ui/util/ui_util.dart';
import 'package:aewallet/ui/views/accounts/layouts/components/account_list_item_token_info.dart';
Expand All @@ -35,6 +36,7 @@ import 'package:archethic_lib_dart/archethic_lib_dart.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:event_taxi/event_taxi.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart';
Expand All @@ -52,8 +54,11 @@ class AccountListItem extends ConsumerStatefulWidget {
ConsumerState<AccountListItem> createState() => _AccountListItemState();
}

class _AccountListItemState extends ConsumerState<AccountListItem> {
class _AccountListItemState extends ConsumerState<AccountListItem>
with AutomaticKeepAliveClientMixin {
StreamSubscription<TransactionSendEvent>? _sendTxSub;
@override
bool get wantKeepAlive => true;

void _registerBus() {
_sendTxSub = EventTaxiImpl.singleton()
Expand Down Expand Up @@ -144,6 +149,8 @@ class _AccountListItemState extends ConsumerState<AccountListItem> {

@override
Widget build(BuildContext context) {
super.build(context);

final preferences = ref.watch(SettingsProviders.settings);
final localizations = AppLocalizations.of(context)!;

Expand Down Expand Up @@ -251,7 +258,7 @@ class _AccountListItemState extends ConsumerState<AccountListItem> {
? ArchethicTheme.backgroundAccountsListCardSelected
: ArchethicTheme.backgroundAccountsListCard,
),
height: 100,
height: 120,
padding: const EdgeInsets.symmetric(
vertical: 10,
horizontal: 20,
Expand All @@ -263,14 +270,57 @@ class _AccountListItemState extends ConsumerState<AccountListItem> {
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 17,
child: AutoSizeText(
widget.account.nameDisplayed,
style:
ArchethicThemeStyles.textStyleSize12W100Primary,
style: ArchethicThemeStyles.textStyleSize12W600Primary
.copyWith(
color: aedappfm.AppThemeBase.secondaryColor,
),
),
),
InkWell(
onTap: () {
sl.get<HapticUtil>().feedback(
FeedbackType.light,
preferences.activeVibrations,
);
Clipboard.setData(
ClipboardData(
text: widget.account.genesisAddress.toLowerCase(),
),
);
UIUtil.showSnackbar(
'${localizations.addressCopied}\n${widget.account.genesisAddress.toLowerCase()}',
context,
ref,
ArchethicTheme.text,
ArchethicTheme.snackBarShadow,
icon: Symbols.info,
);
},
child: Row(
children: [
Text(
AddressFormatters(
widget.account.genesisAddress,
).getShortString4().toLowerCase(),
style: ArchethicThemeStyles
.textStyleSize12W100Primary,
),
const SizedBox(
width: 5,
),
const Icon(
Symbols.content_copy,
weight: IconSize.weightM,
opticalSize: IconSize.opticalSizeM,
grade: IconSize.gradeM,
size: 16,
),
],
),
),
if (widget.account.serviceType != null)
Expand Down Expand Up @@ -437,7 +487,6 @@ class _AccountListItemState extends ConsumerState<AccountListItem> {
AvailablePrimaryCurrencyEnum.native
? Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 17,
Expand Down Expand Up @@ -465,7 +514,6 @@ class _AccountListItemState extends ConsumerState<AccountListItem> {
)
: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
AutoSizeText(
fiatAmountString,
Expand All @@ -487,7 +535,6 @@ class _AccountListItemState extends ConsumerState<AccountListItem> {
)
else
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
AutoSizeText(
Expand Down
66 changes: 49 additions & 17 deletions lib/ui/views/contacts/layouts/contact_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:aewallet/model/data/contact.dart';
import 'package:aewallet/model/public_key.dart';
import 'package:aewallet/ui/themes/archethic_theme.dart';
import 'package:aewallet/ui/themes/styles.dart';
import 'package:aewallet/ui/util/address_formatters.dart';
import 'package:aewallet/ui/util/contact_formatters.dart';
import 'package:aewallet/ui/util/ui_util.dart';
import 'package:aewallet/ui/views/contacts/layouts/components/contact_detail_tab.dart';
Expand All @@ -21,6 +22,8 @@ import 'package:aewallet/ui/widgets/components/sheet_skeleton.dart';
import 'package:aewallet/ui/widgets/components/sheet_skeleton_interface.dart';
import 'package:aewallet/util/get_it_instance.dart';
import 'package:aewallet/util/haptic_util.dart';
import 'package:archethic_dapp_framework_flutter/archethic_dapp_framework_flutter.dart'
as aedappfm;
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down Expand Up @@ -86,6 +89,12 @@ class ContactDetail extends ConsumerWidget implements SheetSkeletonInterface {

return SheetAppBar(
title: contact.format,
widgetAfterTitle: Text(
AddressFormatters(
contactAddress,
).getShortString4().toLowerCase(),
style: ArchethicThemeStyles.textStyleSize14W600Primary,
),
widgetRight: Padding(
padding: const EdgeInsets.only(right: 10, top: 10),
child: _ContactDetailBalance(contactAddress: contactAddress),
Expand Down Expand Up @@ -362,24 +371,47 @@ class _ContactDetailActions extends ConsumerWidget {
],
),
),
IconButton(
key: const Key('viewExplorer'),
onPressed: () {
UIUtil.showWebview(
context,
'${ref.read(SettingsProviders.settings).network.getLink()}/explorer/chain?address=${contact.genesisAddress}',
'',
);
},
icon: Column(
children: [
const Icon(Symbols.open_in_new),
const SizedBox(
height: 4,
_btnExplorer(context, ref),
],
);
}

Widget _btnExplorer(BuildContext context, WidgetRef ref) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
InkWell(
child: Container(
height: 40,
width: 40,
alignment: Alignment.center,
decoration: BoxDecoration(
gradient: aedappfm.AppThemeBase.gradientBtn,
shape: BoxShape.circle,
),
child: const Icon(
Symbols.open_in_new,
size: 20,
),
),
Text(localizations.explorer),
],
),
onTap: () {
UIUtil.showWebview(
context,
'${ref.read(SettingsProviders.settings).network.getLink()}/explorer/chain?address=${contact.genesisAddress}',
'',
);
},
),
const SizedBox(
height: 5,
),
Text(
AppLocalizations.of(context)!.explorer,
style: const TextStyle(fontSize: 10),
),
],
),
],
);
Expand Down
59 changes: 56 additions & 3 deletions lib/ui/views/main/components/main_appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import 'package:aewallet/application/settings/settings.dart';
import 'package:aewallet/ui/menu/settings/settings_sheet.dart';
import 'package:aewallet/ui/themes/archethic_theme.dart';
import 'package:aewallet/ui/themes/styles.dart';
import 'package:aewallet/ui/util/address_formatters.dart';
import 'package:aewallet/ui/util/ui_util.dart';
import 'package:aewallet/ui/views/messenger/layouts/create_discussion_sheet.dart';
import 'package:aewallet/ui/views/nft/layouts/configure_category_list.dart';
import 'package:aewallet/ui/widgets/components/icon_network_warning.dart';
import 'package:aewallet/util/get_it_instance.dart';
import 'package:aewallet/util/haptic_util.dart';
import 'package:archethic_dapp_framework_flutter/archethic_dapp_framework_flutter.dart'
as aedappfm;
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -166,9 +169,59 @@ class MainAppBar extends ConsumerWidget implements PreferredSizeWidget {
: preferences.mainScreenCurrentPage == 2
? FittedBox(
fit: BoxFit.fitWidth,
child: Text(
selectedAccount?.nameDisplayed ?? ' ',
style: ArchethicThemeStyles.textStyleSize24W700Primary,
child: InkWell(
onTap: () {
sl.get<HapticUtil>().feedback(
FeedbackType.light,
preferences.activeVibrations,
);
Clipboard.setData(
ClipboardData(
text: selectedAccount?.genesisAddress.toLowerCase() ??
'',
),
);
UIUtil.showSnackbar(
'${localizations.addressCopied}\n${selectedAccount?.genesisAddress.toLowerCase()}',
context,
ref,
ArchethicTheme.text,
ArchethicTheme.snackBarShadow,
icon: Symbols.info,
);
},
child: Column(
children: [
Text(
selectedAccount?.nameDisplayed ?? ' ',
style: ArchethicThemeStyles.textStyleSize24W700Primary
.copyWith(
color: aedappfm.AppThemeBase.secondaryColor,
),
),
Row(
children: [
Text(
AddressFormatters(
selectedAccount?.genesisAddress ?? '',
).getShortString4().toLowerCase(),
style: ArchethicThemeStyles
.textStyleSize14W600Primary,
),
const SizedBox(
width: 5,
),
const Icon(
Symbols.content_copy,
weight: IconSize.weightM,
opticalSize: IconSize.opticalSizeM,
grade: IconSize.gradeM,
size: 16,
),
],
),
],
),
),
).animate().fade(duration: const Duration(milliseconds: 300))
: preferences.mainScreenCurrentPage == 3
Expand Down
12 changes: 9 additions & 3 deletions lib/ui/views/main/components/sheet_appbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,15 @@ class SheetAppBar extends ConsumerWidget implements PreferredSizeWidget {
],
title: FittedBox(
fit: BoxFit.fitWidth,
child: AutoSizeText(
title,
style: styleTitle ?? ArchethicThemeStyles.textStyleSize24W700Primary,
child: Column(
children: [
AutoSizeText(
title,
style:
styleTitle ?? ArchethicThemeStyles.textStyleSize24W700Primary,
),
if (widgetAfterTitle != null) widgetAfterTitle!,
],
),
).animate().fade(duration: const Duration(milliseconds: 300)),
backgroundColor: Colors.transparent,
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/widgets/components/paste_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PasteIcon extends TextFieldButton {
final preferences = ref.watch(SettingsProviders.settings);

return TextFieldButton(
icon: Symbols.content_paste,
icon: Symbols.content_copy,
onPressed: () {
sl.get<HapticUtil>().feedback(
FeedbackType.light,
Expand Down
Loading

0 comments on commit b350487

Please sign in to comment.