Skip to content

Commit

Permalink
support system.remark on account manage page (#1698)
Browse files Browse the repository at this point in the history
* support system.remark on account manage page

* minor mod

* fix review comments

* make account manage page scrollable

* prevent listView scrolling within scrollable page

* fix CI

* add AI translations

* add AI translations

* fix lints

* [send_tx] fix: use correct notification text and remove needless onFinish callback

---------

Co-authored-by: clangenb <37865735+clangenb@users.noreply.github.com>
  • Loading branch information
brenzi and clangenb authored Sep 18, 2024
1 parent 0d032ac commit a6e4ba1
Show file tree
Hide file tree
Showing 10 changed files with 262 additions and 93 deletions.
7 changes: 7 additions & 0 deletions app/lib/l10n/arb/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@
"registerUntil": "Registriere dich vor dem",
"remainingNewbieTicketsAsBootStrapper": "Verbleibende Newbie Tickets als Bootstrapper:",
"remainingNewbieTicketsAsReputable": "Verbleibende Newbie Tickets als Reputable:",
"remarkNotificationTitle": "Notiz eingereicht",
"remarkNotificationBody": "Sie haben eine Notiz eingereicht.",
"remarks": "Onchain Notizen",
"remarksButton": "öffentliche Notiz einreichen",
"remarksExplain": "Sie können eine Notiz an das Netzwerk senden. Diese Notiz wird öffentlich und unveränderlich sein. Sie kann von jemensch gelesen und authentifiziert werden, da sie digital von Dir signiert wird.",
"remarksNote": "Notiz",
"remarksSubmit": "Notiz einreichen",
"reputableContent": "Du hast deine Reputation genutzt um einen garantierten Platz zu erhalten. Achtung: Solltest Du dich anmelden, aber nicht zur Versammlung erscheinen, wirst du wieder ein Newbie.",
"reputableTitle": "Als Reputable registriert. Dein Platz ist garantiert",
"reputationAlreadyCommittedTitle": "Reputation bereits benutzt",
Expand Down
7 changes: 7 additions & 0 deletions app/lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@
"registerUntil": "Register before",
"remainingNewbieTicketsAsBootStrapper": "Remaining newbie tickets as bootsrapper:",
"remainingNewbieTicketsAsReputable": "Remaining newbie tickets as reputable:",
"remarkNotificationBody": "You have submitted a note.",
"remarkNotificationTitle": "note submitted",
"remarks": "Onchain Remarks",
"remarksButton": "submit public note",
"remarksExplain": "You can submit a note to the network. This note will be public and immutable. It can be read and authenticated by everyone as it will be digitally signed by you.",
"remarksNote": "Note",
"remarksSubmit": "Submit note",
"reputableContent": "You used your reputation to get a guaranteed seat. Caution: Should you register, but not show up at the cycle, you become a newbie again.",
"reputableTitle": "Registered as reputable - your seat is guaranteed",
"reputationAlreadyCommittedTitle": "Reputation already used",
Expand Down
7 changes: 7 additions & 0 deletions app/lib/l10n/arb/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@
"registerUntil": "Inscrive-toi avant le",
"remainingNewbieTicketsAsBootStrapper": "Novice-Tickets restants en tant que bootstrapper",
"remainingNewbieTicketsAsReputable": "Comme Reputable les billets pour Novice restants:",
"remarkNotificationTitle": "Note soumise",
"remarkNotificationBody": "Vous avez soumis une note.",
"remarks": "Remarques en chaine",
"remarksButton": "soumettre une note publique",
"remarksExplain": "Vous pouvez soumettre une note au réseau. Cette note sera publique et immuable. Elle peut être lue et authentifiée par tout le monde car elle sera signée numériquement par toi.",
"remarksNote": "Note",
"remarksSubmit": "Soumettre la note",
"reputableContent": "\"Tu as utilisé ta réputation pour obtenir une place garantie. Attention : si tu t'enregistres, mais que tu ne te présentes pas à la réunion, tu redeviens un Novice\".",
"reputableTitle": "Enregistré en tant que Reputable. Ta place est garantie",
"reputationAlreadyCommittedTitle": "Réputation déjà utilisée",
Expand Down
7 changes: 7 additions & 0 deletions app/lib/l10n/arb/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,13 @@
"registerUntil": "Зарегистрируйтесь до",
"remainingNewbieTicketsAsBootStrapper": "Оставшиеся билеты для новичков Бутстреппера:",
"remainingNewbieTicketsAsReputable": "Оставшиеся билеты для новичков Уважаемого:",
"remarkNotificationBody": "Вы отправили заметку.",
"remarkNotificationTitle": "заметка отправлена",
"remarks": "Замечания в блокчейне",
"remarksButton": "отправить публичную заметку",
"remarksExplain": "Вы можете отправить заметку в сеть. Эта заметка будет публичной и неизменяемой. Её могут прочитать и аутентифицировать все, так как она будет цифрово подписана вами.",
"remarksNote": "Заметка",
"remarksSubmit": "Отправить заметку",
"reputableContent": "Вы воспользовались своей репутаций для получения гарантированного места. Внимание: Если вы зарегистрируетесь, но не явитесь на цикл, вы снова станете новичком.",
"reputableTitle": "Зарегистрирован в качестве Уважаемого - ваше место гарантировано.",
"reputationAlreadyCommittedTitle": "Репутация уже использована",
Expand Down
7 changes: 7 additions & 0 deletions app/lib/l10n/arb/app_sw.arb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@
"registerUntil": "Jisajili kabla",
"remainingNewbieTicketsAsBootStrapper": "Tiketi za wanachama wapya/wageni zilizobaki kama mwanachama anzilishi:",
"remainingNewbieTicketsAsReputable": "Tiketi za wanachama wageni zilizobaki kama mwanachama hai:",
"remarkNotificationBody": "Umetuma kumbuka.",
"remarkNotificationTitle": "kumbuka imetumwa",
"remarks": "Maoni ya Onchain",
"remarksButton": "tuma kumbuka ya umma",
"remarksExplain": "Unaweza kutuma kumbuka kwenye mtandao. Kumbuka hii itakuwa ya umma na isiyobadilika. Inaweza kusomwa na kuthibitishwa na kila mtu kwani itasainiwa kidijitali na wewe.",
"remarksNote": "Kumbuka",
"remarksSubmit": "Tuma kumbuka",
"reputableContent": "Umetumia sifa yako kupata kiti kilicho hakikishiwa. Tahadhari: Ikiwa utajiandikisha lakini usijitokeze katika mzunguko, utarudi kuwa mwanachama mpya/mgeni tena..",
"reputableTitle": "Umejisajili kama mwenye mwanachama hai - kiti chako kimehakikishiwa",
"reputationAlreadyCommittedTitle": "Hadhi yako imetumika",
Expand Down
202 changes: 109 additions & 93 deletions app/lib/page/profile/account/account_manage_page.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:encointer_wallet/page/profile/account/remark.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
Expand Down Expand Up @@ -169,7 +170,6 @@ class _AccountManagePageState extends State<AccountManagePage> {
_nameCtrl = TextEditingController(text: accountToBeEdited.name);
_nameCtrl!.selection = TextSelection.fromPosition(TextPosition(offset: _nameCtrl!.text.length));

// Not an ideal practice, but we only release a dev-version of the faucet, and cleanup can be later.
Widget benefits() {
if (faucets == null) {
return appConfig.isIntegrationTest ? const SizedBox.shrink() : const CupertinoActivityIndicator();
Expand All @@ -192,6 +192,16 @@ class _AccountManagePageState extends State<AccountManagePage> {
);
}

Widget remarks() {
return Remarks(
store,
userAddress: Address(
pubkey: AddressUtils.pubKeyHexToPubKey(accountToBeEditedPubKey),
prefix: store.settings.currentNetwork.ss58(),
),
);
}

return Observer(
builder: (_) => Scaffold(
appBar: AppBar(
Expand Down Expand Up @@ -232,54 +242,63 @@ class _AccountManagePageState extends State<AccountManagePage> {
],
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: <Widget>[
const SizedBox(height: 20),
if (!isKeyboard)
AddressIcon(
addressSS58,
accountToBeEditedPubKey,
size: 130,
),
Text(
addressSS58,
key: const Key(EWTestKeys.accountPublicKey),
// Text only read `addressSS58` for integration test
style: const TextStyle(fontSize: 2, color: Colors.transparent),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
Fmt.address(addressSS58)!,
style: const TextStyle(fontSize: 20),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
IconButton(
icon: const Icon(Iconsax.copy),
color: context.colorScheme.secondary,
onPressed: () => UI.copyAndNotify(context, addressSS58),
),
],
),
Text(l10n.communities, style: h3Grey, textAlign: TextAlign.left),
ListView.builder(
shrinkWrap: true,
itemCount: store.encointer.accountStores!.containsKey(addressSS58)
? store.encointer.accountStores![addressSS58]?.balanceEntries.length ?? 0
: 0,
itemBuilder: (BuildContext context, int index) => _getBalanceEntryListTile(
index,
addressSS58,
child: Column(
children: [
Expanded(
child: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
children: <Widget>[
const SizedBox(height: 20),
if (!isKeyboard)
AddressIcon(
addressSS58,
accountToBeEditedPubKey,
size: 130,
),
Text(
addressSS58,
key: const Key(EWTestKeys.accountPublicKey),
style: const TextStyle(fontSize: 2, color: Colors.transparent),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
Fmt.address(addressSS58)!,
style: const TextStyle(fontSize: 20),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
IconButton(
icon: const Icon(Iconsax.copy),
color: context.colorScheme.secondary,
onPressed: () => UI.copyAndNotify(context, addressSS58),
),
],
),
Text(l10n.communities, style: h3Grey, textAlign: TextAlign.left),
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: store.encointer.accountStores!.containsKey(addressSS58)
? store.encointer.accountStores![addressSS58]?.balanceEntries.length ?? 0
: 0,
itemBuilder: (BuildContext context, int index) => _getBalanceEntryListTile(
index,
addressSS58,
),
),
benefits(),
remarks(),
const SizedBox(height: 20),
],
),
),
benefits(),
const Spacer(),
DecoratedBox(
// width: double.infinity,
),
Padding(
padding: const EdgeInsets.all(16),
child: DecoratedBox(
decoration: BoxDecoration(
gradient: AppColors.primaryGradient(context),
borderRadius: BorderRadius.circular(20),
Expand All @@ -289,7 +308,7 @@ class _AccountManagePageState extends State<AccountManagePage> {
ElevatedButton(
key: const Key(EWTestKeys.goToAccountShare),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.all(16), // make splash animation as high as the container
padding: const EdgeInsets.all(16),
backgroundColor: Colors.transparent,
foregroundColor: Colors.white,
shadowColor: Colors.transparent,
Expand All @@ -310,55 +329,52 @@ class _AccountManagePageState extends State<AccountManagePage> {
),
const Spacer(),
PopupMenuButton<AccountAction>(
offset: const Offset(-10, -150),
icon: const Icon(
Iconsax.more,
key: Key(EWTestKeys.popupMenuAccountTrashExport),
color: Colors.white,
),
color: context.colorScheme.background,
padding: const EdgeInsets.all(20),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
onSelected: (AccountAction accountAction) {
return switch (accountAction) {
AccountAction.delete => _onDeleteAccount(context, accountToBeEdited),
AccountAction.export => _showPasswordDialog(context, accountToBeEdited),
};
},
itemBuilder: (BuildContext context) => [
AccountActionItemData(
accountAction: AccountAction.delete,
icon: Iconsax.trash,
title: l10n.deleteAccount,
),
AccountActionItemData(
accountAction: AccountAction.export,
icon: Iconsax.export,
title: l10n.exportAccount),
]
.map((AccountActionItemData data) => PopupMenuItem<AccountAction>(
key: Key(data.accountAction.name),
value: data.accountAction,
// https://github.com/flutter/flutter/issues/31247 as soon as we use a newer flutter version we might be able to add this to our theme.dart
child: ListTileTheme(
textColor: context.colorScheme.secondary,
iconColor: context.colorScheme.secondary,
child: ListTile(
minLeadingWidth: 0,
title: Text(data.title),
leading: Icon(data.icon),
),
),
))
.toList() //<PopupMenuEntry<AccountAction>>,
offset: const Offset(-10, -150),
icon: const Icon(
Iconsax.more,
key: Key(EWTestKeys.popupMenuAccountTrashExport),
color: Colors.white,
),
color: context.colorScheme.background,
padding: const EdgeInsets.all(20),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
onSelected: (AccountAction accountAction) {
return switch (accountAction) {
AccountAction.delete => _onDeleteAccount(context, accountToBeEdited),
AccountAction.export => _showPasswordDialog(context, accountToBeEdited),
};
},
itemBuilder: (BuildContext context) => [
AccountActionItemData(
accountAction: AccountAction.delete,
icon: Iconsax.trash,
title: l10n.deleteAccount,
),
AccountActionItemData(
accountAction: AccountAction.export, icon: Iconsax.export, title: l10n.exportAccount),
]
.map((AccountActionItemData data) => PopupMenuItem<AccountAction>(
key: Key(data.accountAction.name),
value: data.accountAction,
child: ListTileTheme(
textColor: context.colorScheme.secondary,
iconColor: context.colorScheme.secondary,
child: ListTile(
minLeadingWidth: 0,
title: Text(data.title),
leading: Icon(data.icon),
),
),
))
.toList(),
),
],
),
),
],
),
),
],
),
),
),
Expand Down
1 change: 1 addition & 0 deletions app/lib/page/profile/account/benefits.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Benefits extends StatelessWidget {
),
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: faucets.length,
itemBuilder: (BuildContext context, int index) {
final faucetPubKeyHex = faucets.keys.elementAt(index);
Expand Down
Loading

0 comments on commit a6e4ba1

Please sign in to comment.