Skip to content
Merged
3 changes: 2 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,6 @@
"more": "More",
"start": "Start",
"connecting": "Connecting",
"accountNotFound": "Account not found"
"accountNotFound": "Account not found",
"sendTip": "Send Tip"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,6 @@
"more": "Más",
"start": "Iniciar",
"connecting": "Conectando",
"accountNotFound": "Cuenta no encontrada"
"accountNotFound": "Cuenta no encontrada",
"sendTip": "Enviar propina"
}
3 changes: 2 additions & 1 deletion lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,6 @@
"close": "Fermer",
"start": "Commencer",
"connecting": "Connexion",
"accountNotFound": "Compte non trouvé"
"accountNotFound": "Compte non trouvé",
"sendTip": "Envoyer un pourboire"
}
6 changes: 6 additions & 0 deletions lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,12 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Learn More'**
String get learnMore;

/// No description provided for @sendTip.
///
/// In en, this message translates to:
/// **'Send Tip'**
String get sendTip;
}

class _AppLocalizationsDelegate
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -676,4 +676,7 @@ class AppLocalizationsEn extends AppLocalizations {

@override
String get learnMore => 'Learn More';

@override
String get sendTip => 'Send Tip';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -680,4 +680,7 @@ class AppLocalizationsEs extends AppLocalizations {

@override
String get learnMore => 'Más información';

@override
String get sendTip => 'Enviar propina';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -681,4 +681,7 @@ class AppLocalizationsFr extends AppLocalizations {

@override
String get learnMore => 'En savoir plus';

@override
String get sendTip => 'Envoyer un pourboire';
}
3 changes: 3 additions & 0 deletions lib/l10n/app_localizations_nl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -683,4 +683,7 @@ class AppLocalizationsNl extends AppLocalizations {

@override
String get learnMore => 'Meer informatie';

@override
String get sendTip => 'Fooi versturen';
}
3 changes: 2 additions & 1 deletion lib/l10n/app_nl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,6 @@
"close": "Sluiten",
"start": "Start",
"connecting": "Verbinding maken",
"accountNotFound": "Account niet gevonden"
"accountNotFound": "Account niet gevonden",
"sendTip": "Fooi versturen"
}
40 changes: 0 additions & 40 deletions lib/models/send_transaction.dart

This file was deleted.

21 changes: 17 additions & 4 deletions lib/router/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ GoRouter createRouter(
sendToParams +=
'&description=${uri.queryParameters['description']}';
}
if (uri.queryParameters['tipAmount'] != null) {
sendToParams +=
'&tipAmount=${uri.queryParameters['tipAmount']}';
}
if (uri.queryParameters['tipDescription'] != null) {
sendToParams +=
'&tipDescription=${uri.queryParameters['tipDescription']}';
}
} else if (eip681 != null) {
sendToParams =
encodeParams(uri.toString().replaceFirst('/?', ''));
Expand Down Expand Up @@ -181,6 +189,9 @@ GoRouter createRouter(
final tipTo = state.uri.queryParameters['tipTo'];
final amount = state.uri.queryParameters['amount'];
final description = state.uri.queryParameters['description'];
final tipAmount = state.uri.queryParameters['tipAmount'];
final tipDescription =
state.uri.queryParameters['tipDescription'];
if (sendTo != null) {
String params = 'sendto=$sendTo';
if (tipTo != null) {
Expand All @@ -192,6 +203,12 @@ GoRouter createRouter(
if (description != null) {
params += '&description=$description';
}
if (tipAmount != null) {
params += '&tipAmount=$tipAmount';
}
if (tipDescription != null) {
params += '&tipDescription=$tipDescription';
}
sendToURL = 'https://app.citizenwallet.xyz/?$params';
}
}
Expand Down Expand Up @@ -259,7 +276,6 @@ GoRouter createRouter(
voucherLogic: extra['voucherLogic'],
isMinting: extra['isMinting'] ?? false,
sendToURL: extra['sendToURL'],
sendTransaction: extra['sendTransaction'],
);
},
),
Expand Down Expand Up @@ -316,7 +332,6 @@ GoRouter createRouter(
walletLogic: extra['walletLogic'],
profilesLogic: extra['profilesLogic'],
isMinting: extra['isMinting'] ?? false,
sendTransaction: extra['sendTransaction'],
);
},
),
Expand Down Expand Up @@ -347,7 +362,6 @@ GoRouter createRouter(
to: state.pathParameters['to'],
isMinting: extra?['isMinting'] ?? false,
profilesLogic: extra?['profilesLogic'],
sendTransaction: extra?['sendTransaction'],
walletLogic: extra?['walletLogic'],
);
},
Expand Down Expand Up @@ -544,7 +558,6 @@ GoRouter createWebRouter(
}
}


return WebLandingScreen(
voucher: state.uri.queryParameters['voucher'],
voucherParams: state.uri.queryParameters['params'],
Expand Down
16 changes: 5 additions & 11 deletions lib/screens/send/send_details.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// import 'package:citizenwallet/l10n/app_localizations.dart';
import 'package:citizenwallet/models/send_transaction.dart';
import 'package:citizenwallet/services/config/config.dart';
import 'package:citizenwallet/services/wallet/utils.dart';
import 'package:citizenwallet/state/profiles/logic.dart';
Expand Down Expand Up @@ -230,17 +229,13 @@ class _SendDetailsScreenState extends State<SendDetailsScreen> {

final toAccount =
selectedAddress ?? walletLogic.addressController.value.text;

final sendTransaction = SendTransaction(
amount: walletLogic.amountController.value.text,
to: toAccount,
description: walletLogic.messageController.value.text.trim(),
);
final amount = walletLogic.amountController.value.text;
final description = walletLogic.messageController.value.text.trim();

walletLogic.sendTransaction(
sendTransaction.amount!,
sendTransaction.to!,
message: sendTransaction.description!,
amount,
toAccount,
message: description,
);

await Future.delayed(const Duration(milliseconds: 50));
Expand All @@ -253,7 +248,6 @@ class _SendDetailsScreenState extends State<SendDetailsScreen> {
'isMinting': widget.isMinting,
'walletLogic': walletLogic,
'profilesLogic': widget.profilesLogic,
'sendTransaction': sendTransaction,
});

walletLogic.clearInProgressTransaction();
Expand Down
31 changes: 18 additions & 13 deletions lib/screens/send/send_progress.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// import 'package:citizenwallet/l10n/app_localizations.dart';
import 'dart:async';
import 'package:citizenwallet/models/send_transaction.dart';
import 'package:citizenwallet/models/transaction.dart';
import 'package:citizenwallet/services/wallet/utils.dart';
import 'package:citizenwallet/state/profiles/logic.dart';
import 'package:citizenwallet/state/profiles/state.dart';
import 'package:citizenwallet/state/wallet/logic.dart';
import 'package:citizenwallet/state/wallet/state.dart';
import 'package:citizenwallet/theme/provider.dart';
import 'package:citizenwallet/utils/send.dart';
import 'package:citizenwallet/widgets/button.dart';
import 'package:citizenwallet/widgets/coin_logo.dart';
import 'package:citizenwallet/widgets/loaders/progress_circle.dart';
Expand All @@ -23,15 +23,13 @@ class SendProgress extends StatefulWidget {
final bool isMinting;
final WalletLogic? walletLogic;
final ProfilesLogic? profilesLogic;
final SendTransaction? sendTransaction;

const SendProgress({
super.key,
this.to,
this.isMinting = false,
this.walletLogic,
this.profilesLogic,
this.sendTransaction,
});

@override
Expand Down Expand Up @@ -76,23 +74,24 @@ class _SendProgressState extends State<SendProgress> {
});
}

Future<void> handleSendTip(BuildContext context) async {
Future<void> handleSendTip(
BuildContext context,
SendDestination tipping,
) async {
if (!context.mounted) {
return;
}

final navigator = GoRouter.of(context);

final toAccount = widget.sendTransaction?.to ??
widget.walletLogic?.addressController.value.text;
final toAccount = tipping.to;

await navigator.push(
'/wallet/${widget.walletLogic?.account}/send/$toAccount/tip',
extra: {
'walletLogic': widget.walletLogic,
'profilesLogic': widget.profilesLogic,
'isMinting': widget.isMinting,
'sendTransaction': widget.sendTransaction,
},
);
}
Expand All @@ -118,9 +117,12 @@ class _SendProgressState extends State<SendProgress> {
(WalletState state) => state.inProgressTransactionError,
);

final tipping = context.select((WalletState state) => state.tipping);

if (inProgressTransaction.state == TransactionState.success &&
_previousState != TransactionState.success) {
final hasTip = context.read<WalletState>().hasTip;
final hasTip =
context.select((WalletState state) => state.tipping) != null;
if (!hasTip) {
handleStartCloseScreenTimer(context);
}
Expand All @@ -135,7 +137,8 @@ class _SendProgressState extends State<SendProgress> {
if (inProgressTransaction.state == TransactionState.fail &&
_previousState != TransactionState.fail &&
!_isClosing) {
final hasTip = context.read<WalletState>().hasTip;
final hasTip =
context.select((WalletState state) => state.tipping) != null;
if (!hasTip) {
handleStartCloseScreenTimer(context);
}
Expand Down Expand Up @@ -359,12 +362,11 @@ class _SendProgressState extends State<SendProgress> {
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
context.select((WalletState state) => state.hasTip)
tipping != null
? Column(
children: [
Button(
text:
"${AppLocalizations.of(context)!.send} Tip",
text: AppLocalizations.of(context)!.sendTip,
color: Theme.of(context)
.colors
.primary
Expand All @@ -373,7 +375,8 @@ class _SendProgressState extends State<SendProgress> {
.colors
.white
.resolveFrom(context),
onPressed: () => handleSendTip(context),
onPressed: () =>
handleSendTip(context, tipping),
minWidth: 200,
maxWidth: width - 60,
),
Expand All @@ -384,6 +387,8 @@ class _SendProgressState extends State<SendProgress> {
onPressed: () {
final navigator = GoRouter.of(context);

widget.walletLogic?.clearTipping();

navigator.go(
'/wallet/${widget.walletLogic?.account}');
},
Expand Down
4 changes: 0 additions & 4 deletions lib/screens/send/send_to.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// import 'package:citizenwallet/l10n/app_localizations.dart';
import 'package:citizenwallet/models/send_transaction.dart';
import 'package:citizenwallet/services/wallet/contracts/profile.dart';
import 'package:citizenwallet/services/wallet/utils.dart';
import 'package:citizenwallet/state/profiles/logic.dart';
Expand Down Expand Up @@ -34,7 +33,6 @@ class SendToScreen extends StatefulWidget {
final ProfilesLogic profilesLogic;
final VoucherLogic? voucherLogic;
final String? sendToURL;
final SendTransaction? sendTransaction;

final bool isMinting;

Expand All @@ -45,7 +43,6 @@ class SendToScreen extends StatefulWidget {
this.voucherLogic,
this.isMinting = false,
this.sendToURL,
this.sendTransaction,
});

@override
Expand All @@ -57,7 +54,6 @@ class _SendToScreenState extends State<SendToScreen> {
final ScanLogic _scanLogic = ScanLogic();
String? _currentSendToURL;
final _scrollController = ScrollController();
// late SendTransaction _sendTransaction;

late void Function() debouncedAddressUpdate;

Expand Down
Loading