diff --git a/lib/packages/service/dfx/models/pdf/multi_receipt_dto.dart b/lib/packages/service/dfx/models/pdf/multi_receipt_dto.dart index 43d4bc783..5845a7a0a 100644 --- a/lib/packages/service/dfx/models/pdf/multi_receipt_dto.dart +++ b/lib/packages/service/dfx/models/pdf/multi_receipt_dto.dart @@ -1,18 +1,22 @@ import 'package:realunit_wallet/styles/currency.dart'; +import 'package:realunit_wallet/styles/language.dart'; class MultiReceiptDto { final List txIds; final Currency currency; + final Language? language; const MultiReceiptDto({ required this.txIds, this.currency = Currency.chf, + this.language, }); Map toJson() { return { 'txHashes': txIds, 'currency': currency.code, + if (language != null) 'language': language!.code.toUpperCase(), }; } } diff --git a/lib/packages/service/dfx/models/pdf/single_receipt_dto.dart b/lib/packages/service/dfx/models/pdf/single_receipt_dto.dart index f28bf8b96..05a0d9490 100644 --- a/lib/packages/service/dfx/models/pdf/single_receipt_dto.dart +++ b/lib/packages/service/dfx/models/pdf/single_receipt_dto.dart @@ -1,18 +1,22 @@ import 'package:realunit_wallet/styles/currency.dart'; +import 'package:realunit_wallet/styles/language.dart'; class SingleReceiptDto { final String txId; final Currency currency; + final Language? language; const SingleReceiptDto({ required this.txId, this.currency = Currency.chf, + this.language, }); Map toJson() { return { 'txHash': txId, 'currency': currency.code, + if (language != null) 'language': language!.code.toUpperCase(), }; } } diff --git a/lib/packages/service/dfx/real_unit_pdf_service.dart b/lib/packages/service/dfx/real_unit_pdf_service.dart index 50e4b6a1b..1a2487c47 100644 --- a/lib/packages/service/dfx/real_unit_pdf_service.dart +++ b/lib/packages/service/dfx/real_unit_pdf_service.dart @@ -49,6 +49,7 @@ class RealUnitPdfService extends DFXAuthService { Future getTransactionsReceipt( List ids, { Currency currency = Currency.chf, + Language? language, }) async { final uri = buildUri(host, _transactionsReceiptMultiPath); final response = await authenticatedPost( @@ -56,7 +57,7 @@ class RealUnitPdfService extends DFXAuthService { headers: { 'Content-Type': 'application/json', }, - body: jsonEncode(MultiReceiptDto(txIds: ids, currency: currency)), + body: jsonEncode(MultiReceiptDto(txIds: ids, currency: currency, language: language)), ); if (response.statusCode != 200 && response.statusCode != 201) { @@ -67,14 +68,14 @@ class RealUnitPdfService extends DFXAuthService { return PdfDto.fromJson(jsonDecode(response.body)); } - Future getTransactionReceipt(String id, {Currency currency = Currency.chf}) async { + Future getTransactionReceipt(String id, {Currency currency = Currency.chf, Language? language}) async { final uri = buildUri(host, _transactionsReceiptSinglePath); final response = await authenticatedPost( uri, headers: { 'Content-Type': 'application/json', }, - body: jsonEncode(SingleReceiptDto(txId: id, currency: currency)), + body: jsonEncode(SingleReceiptDto(txId: id, currency: currency, language: language)), ); if (response.statusCode != 200 && response.statusCode != 201) { diff --git a/lib/screens/transaction_history/cubits/multi_receipt/transaction_history_multi_receipt_cubit.dart b/lib/screens/transaction_history/cubits/multi_receipt/transaction_history_multi_receipt_cubit.dart index 82d89af96..248db099b 100644 --- a/lib/screens/transaction_history/cubits/multi_receipt/transaction_history_multi_receipt_cubit.dart +++ b/lib/screens/transaction_history/cubits/multi_receipt/transaction_history_multi_receipt_cubit.dart @@ -7,6 +7,7 @@ import 'package:realunit_wallet/packages/io/documents_directory_port.dart'; import 'package:realunit_wallet/packages/io/path_provider_adapter.dart'; import 'package:realunit_wallet/packages/service/dfx/real_unit_pdf_service.dart'; import 'package:realunit_wallet/styles/currency.dart'; +import 'package:realunit_wallet/styles/language.dart'; part 'transaction_history_multi_receipt_state.dart'; @@ -21,11 +22,11 @@ class TransactionHistoryMultiReceiptCubit extends Cubit generateReceipt(List ids, {Currency currency = Currency.chf}) async { + Future generateReceipt(List ids, {Currency currency = Currency.chf, Language? language}) async { try { emit(const TransactionHistoryMultiReceiptLoading()); - final response = await _pdfService.getTransactionsReceipt(ids, currency: currency); + final response = await _pdfService.getTransactionsReceipt(ids, currency: currency, language: language); if (isClosed) return; final file = await _createFileFromBytes(response.pdfData); if (isClosed) return; diff --git a/lib/screens/transaction_history/cubits/receipt/transaction_history_receipt_cubit.dart b/lib/screens/transaction_history/cubits/receipt/transaction_history_receipt_cubit.dart index 08b6ec609..b4c5777c5 100644 --- a/lib/screens/transaction_history/cubits/receipt/transaction_history_receipt_cubit.dart +++ b/lib/screens/transaction_history/cubits/receipt/transaction_history_receipt_cubit.dart @@ -7,6 +7,7 @@ import 'package:realunit_wallet/packages/io/documents_directory_port.dart'; import 'package:realunit_wallet/packages/io/path_provider_adapter.dart'; import 'package:realunit_wallet/packages/service/dfx/real_unit_pdf_service.dart'; import 'package:realunit_wallet/styles/currency.dart'; +import 'package:realunit_wallet/styles/language.dart'; part 'transaction_history_receipt_state.dart'; @@ -21,11 +22,11 @@ class TransactionHistoryReceiptCubit extends Cubit generateReceipt(String txId, {Currency currency = Currency.chf}) async { + Future generateReceipt(String txId, {Currency currency = Currency.chf, Language? language}) async { try { emit(const TransactionHistoryReceiptLoading()); - final response = await _pdfService.getTransactionReceipt(txId, currency: currency); + final response = await _pdfService.getTransactionReceipt(txId, currency: currency, language: language); if (isClosed) return; final file = await _createFileFromBytes(response.pdfData, txId); if (isClosed) return; diff --git a/lib/screens/transaction_history/widgets/transaction_history_download_button.dart b/lib/screens/transaction_history/widgets/transaction_history_download_button.dart index ab5e078d8..f504e29b1 100644 --- a/lib/screens/transaction_history/widgets/transaction_history_download_button.dart +++ b/lib/screens/transaction_history/widgets/transaction_history_download_button.dart @@ -84,6 +84,7 @@ class TransactionHistoryDownloadButtonView extends StatelessWidget { context.read().generateReceipt( transactionsIds, currency: context.read().state.currency, + language: context.read().state.language, ), child: Container( height: 44, diff --git a/lib/screens/transaction_history/widgets/transaction_history_row.dart b/lib/screens/transaction_history/widgets/transaction_history_row.dart index 0051bbdfa..26517ab6e 100644 --- a/lib/screens/transaction_history/widgets/transaction_history_row.dart +++ b/lib/screens/transaction_history/widgets/transaction_history_row.dart @@ -149,6 +149,7 @@ class TransactionHistoryRowView extends StatelessWidget { context.read().generateReceipt( transaction.txId, currency: context.read().state.currency, + language: context.read().state.language, ); }, child: const Icon(