Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
chore: more clean up (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanwlee authored May 29, 2024
1 parent 84585fb commit eb12dc9
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 55 deletions.
4 changes: 2 additions & 2 deletions lib/features/kcc/kcc_issuance_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class KccIssuanceService {
);
}

// TODO: check for tokenResponse.credential_identifiers before setting format
// TODO(mistermoe): check for tokenResponse.credential_identifiers before setting format
final credentialRequest = CredentialRequest(
format: 'jwt_vc_json',
proof: ProofJwt(jwt: proofJwt),
Expand Down Expand Up @@ -295,7 +295,7 @@ class KccIssuanceService {
);
}

// TODO: Get Issuer metadata to get deferred credential endpoint
// TODO(mistermoe): Get Issuer metadata to get deferred credential endpoint
final deferredCredentialEndpoint = Uri.parse(
'https://example.com/deferred-credential-endpoint',
);
Expand Down
2 changes: 1 addition & 1 deletion lib/features/kcc/kcc_retrieval_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class KccRetrievalPage extends HookConsumerWidget {
bearerDid,
);

// TODO: save credential to shared preferences
// TODO(mistermoe): save credential to shared preferences
credentialResponse.value = AsyncData(value);
} on Exception catch (e, stackTrace) {
credentialResponse.value = AsyncError(e, stackTrace);
Expand Down
5 changes: 3 additions & 2 deletions lib/features/kcc/kcc_webview_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class KccWebviewPage extends HookConsumerWidget {
final idvRequest = useState<AsyncValue<IdvRequest>>(const AsyncLoading());

final settings = InAppWebViewSettings(
isInspectable: kDebugMode, // TODO: only enable for debug builds
isInspectable:
kDebugMode, // TODO(mistermoe): only enable for debug builds
mediaPlaybackRequiresUserGesture: false,
allowsInlineMediaPlayback: true,
iframeAllow: 'camera; microphone',
Expand Down Expand Up @@ -60,7 +61,7 @@ class KccWebviewPage extends HookConsumerWidget {
return InAppWebView(
initialSettings: settings,
onWebViewCreated: (c) {
// TODO: this url needs to be fixed on our PFI side
// TODO(mistermoe): this url needs to be fixed on our PFI side
final fullPath = Uri.parse(data.url)
.replace(port: 5173, scheme: 'https')
.toString();
Expand Down
8 changes: 4 additions & 4 deletions lib/features/payment/payment_amount_page.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import 'package:didpay/features/countries/countries.dart';
import 'package:didpay/features/payin/payin.dart';
import 'package:didpay/features/payment/payment_details_page.dart';
import 'package:didpay/features/payment/payment_fee_details.dart';
import 'package:didpay/features/payment/payment_state.dart';
import 'package:didpay/features/payout/payout.dart';
import 'package:didpay/features/pfis/pfi.dart';
import 'package:didpay/features/pfis/pfis_notifier.dart';
import 'package:didpay/features/tbdex/tbdex_service.dart';
import 'package:didpay/features/transaction/transaction.dart';
import 'package:didpay/l10n/app_localizations.dart';
import 'package:didpay/shared/async_error_widget.dart';
import 'package:didpay/shared/async_loading_widget.dart';
import 'package:didpay/shared/fee_details.dart';
import 'package:didpay/shared/async/async_error_widget.dart';
import 'package:didpay/shared/async/async_loading_widget.dart';
import 'package:didpay/shared/number_pad.dart';
import 'package:didpay/shared/theme/grid.dart';
import 'package:didpay/shared/utils/currency_util.dart';
Expand Down Expand Up @@ -88,7 +88,7 @@ class PaymentAmountPage extends HookConsumerWidget {
offeringsMap: offeringsMap,
),
const SizedBox(height: Grid.xl),
FeeDetails(
PaymentFeeDetails(
transactionType: transactionType,
offering: selectedOffering.value?.data,
),
Expand Down
4 changes: 2 additions & 2 deletions lib/features/payment/payment_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import 'package:didpay/features/payment/payment_types_page.dart';
import 'package:didpay/features/tbdex/tbdex_service.dart';
import 'package:didpay/features/transaction/transaction.dart';
import 'package:didpay/l10n/app_localizations.dart';
import 'package:didpay/shared/async_error_widget.dart';
import 'package:didpay/shared/async_loading_widget.dart';
import 'package:didpay/shared/async/async_error_widget.dart';
import 'package:didpay/shared/async/async_loading_widget.dart';
import 'package:didpay/shared/json_schema_form.dart';
import 'package:didpay/shared/theme/grid.dart';
import 'package:flutter/material.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:tbdex/tbdex.dart';

class FeeDetails extends HookWidget {
class PaymentFeeDetails extends HookWidget {
final TransactionType transactionType;
final OfferingData? offering;
final QuoteData? quote;

const FeeDetails({
const PaymentFeeDetails({
required this.transactionType,
this.offering,
this.quote,
Expand Down Expand Up @@ -130,7 +130,7 @@ extension _PaymentDetailsOperations on Object? {

String? get exchangeRate => this is QuoteData
? CurrencyUtil.formatFromDouble(
FeeDetails.calculateExchangeRate(this as QuoteData?),
PaymentFeeDetails.calculateExchangeRate(this as QuoteData?),
)
: this is OfferingData
? (this as OfferingData?)?.payoutUnitsPerPayinUnit
Expand Down
15 changes: 8 additions & 7 deletions lib/features/payment/payment_review_page.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:didpay/features/account/account_providers.dart';
import 'package:didpay/features/payment/payment_fee_details.dart';
import 'package:didpay/features/payment/payment_state.dart';
import 'package:didpay/features/tbdex/quote_notifier.dart';
import 'package:didpay/features/tbdex/tbdex_service.dart';
import 'package:didpay/features/transaction/transaction.dart';
import 'package:didpay/l10n/app_localizations.dart';
import 'package:didpay/shared/async_error_widget.dart';
import 'package:didpay/shared/async_loading_widget.dart';
import 'package:didpay/shared/fee_details.dart';
import 'package:didpay/shared/success_state.dart';
import 'package:didpay/shared/async/async_data_widget.dart';
import 'package:didpay/shared/async/async_error_widget.dart';
import 'package:didpay/shared/async/async_loading_widget.dart';
import 'package:didpay/shared/theme/grid.dart';
import 'package:didpay/shared/utils/currency_util.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -45,7 +45,8 @@ class PaymentReviewPage extends HookConsumerWidget {
body: SafeArea(
child: sendOrderState.value != null
? sendOrderState.value!.when(
data: (_) => SuccessState(text: Loc.of(context).orderConfirmed),
data: (_) =>
AsyncDataWidget(text: Loc.of(context).orderConfirmed),
loading: () => AsyncLoadingWidget(
text: Loc.of(context).confirmingYourOrder,
),
Expand Down Expand Up @@ -210,7 +211,7 @@ class PaymentReviewPage extends HookConsumerWidget {

Widget _buildFeeDetails(BuildContext context, QuoteData quote) => Padding(
padding: const EdgeInsets.symmetric(vertical: Grid.lg),
child: FeeDetails(
child: PaymentFeeDetails(
transactionType: paymentState.transactionType,
quote: quote,
),
Expand Down Expand Up @@ -255,7 +256,7 @@ class PaymentReviewPage extends HookConsumerWidget {
sendOrderState,
),
child: Text(
'${Loc.of(context).pay} ${FeeDetails.calculateTotalAmount(quote.data)} ${quote.data.payin.currencyCode}',
'${Loc.of(context).pay} ${PaymentFeeDetails.calculateTotalAmount(quote.data)} ${quote.data.payin.currencyCode}',
),
);

Expand Down
8 changes: 4 additions & 4 deletions lib/features/pfis/add_pfi_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import 'package:didpay/features/did_qr/did_qr.dart';
import 'package:didpay/features/pfis/pfi.dart';
import 'package:didpay/features/pfis/pfis_notifier.dart';
import 'package:didpay/l10n/app_localizations.dart';
import 'package:didpay/shared/async_error_widget.dart';
import 'package:didpay/shared/async_loading_widget.dart';
import 'package:didpay/shared/success_state.dart';
import 'package:didpay/shared/async/async_data_widget.dart';
import 'package:didpay/shared/async/async_error_widget.dart';
import 'package:didpay/shared/async/async_loading_widget.dart';
import 'package:didpay/shared/theme/grid.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
Expand Down Expand Up @@ -42,7 +42,7 @@ class AddPfiPage extends HookConsumerWidget {
body: SafeArea(
child: addPfiState.value != null
? addPfiState.value!.when(
data: (pfi) => SuccessState(text: Loc.of(context).pfiAdded),
data: (pfi) => AsyncDataWidget(text: Loc.of(context).pfiAdded),
loading: () =>
AsyncLoadingWidget(text: Loc.of(context).addingPfi),
error: (error, _) => AsyncErrorWidget(
Expand Down
6 changes: 3 additions & 3 deletions lib/features/send/send_confirmation_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:didpay/l10n/app_localizations.dart';
import 'package:didpay/shared/async_loading_widget.dart';
import 'package:didpay/shared/success_state.dart';
import 'package:didpay/shared/async/async_data_widget.dart';
import 'package:didpay/shared/async/async_loading_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

Expand Down Expand Up @@ -31,7 +31,7 @@ class SendConfirmationPage extends HookWidget {
body: SafeArea(
child: response.value == null
? AsyncLoadingWidget(text: Loc.of(context).sendingPayment)
: SuccessState(text: Loc.of(context).yourPaymentWasSent),
: AsyncDataWidget(text: Loc.of(context).yourPaymentWasSent),
),
);
}
Expand Down
9 changes: 3 additions & 6 deletions lib/features/wallets/wallet_selection_page.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import 'package:didpay/features/pfis/pfi.dart';
import 'package:didpay/features/wallets/wallet.dart';
import 'package:didpay/features/wallets/wallets_provider.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

class WalletSelectionPage extends HookConsumerWidget {
Expand All @@ -12,9 +9,9 @@ class WalletSelectionPage extends HookConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final wallets = ref.watch(walletsProvider);
final selectedWallet =
useState<Wallet?>(Wallet(name: 'DidPay', url: 'didpay://'));
// final wallets = ref.watch(walletsProvider);
// final selectedWallet =
// useState<Wallet?>(Wallet(name: 'DidPay', url: 'didpay://'));
return const Scaffold();
// return Scaffold(
// appBar: AppBar(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import 'package:didpay/shared/theme/grid.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

class SuccessState extends HookWidget {
class AsyncDataWidget extends HookWidget {
final String text;
const SuccessState({required this.text, super.key});
const AsyncDataWidget({required this.text, super.key});

@override
Widget build(BuildContext context) => Column(
Expand Down
4 changes: 2 additions & 2 deletions test/features/payment/payment_amount_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import 'dart:convert';

import 'package:didpay/features/payin/payin.dart';
import 'package:didpay/features/payment/payment_amount_page.dart';
import 'package:didpay/features/payment/payment_fee_details.dart';
import 'package:didpay/features/payout/payout.dart';
import 'package:didpay/features/pfis/pfi.dart';
import 'package:didpay/features/pfis/pfis_notifier.dart';
import 'package:didpay/features/tbdex/tbdex_service.dart';
import 'package:didpay/features/transaction/transaction.dart';
import 'package:didpay/shared/fee_details.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
Expand Down Expand Up @@ -68,7 +68,7 @@ void main() {
);
await tester.pumpAndSettle();

expect(find.byType(FeeDetails), findsOneWidget);
expect(find.byType(PaymentFeeDetails), findsOneWidget);
});

testWidgets('should show next button', (tester) async {
Expand Down
4 changes: 2 additions & 2 deletions test/features/payment/review_payment_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import 'dart:convert';

import 'package:auto_size_text/auto_size_text.dart';
import 'package:didpay/features/account/account_providers.dart';
import 'package:didpay/features/payment/payment_fee_details.dart';
import 'package:didpay/features/payment/payment_review_page.dart';
import 'package:didpay/features/payment/payment_state.dart';
import 'package:didpay/features/pfis/pfi.dart';
import 'package:didpay/features/tbdex/quote_notifier.dart';
import 'package:didpay/features/tbdex/tbdex_service.dart';
import 'package:didpay/features/transaction/transaction.dart';
import 'package:didpay/shared/fee_details.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand Down Expand Up @@ -82,7 +82,7 @@ void main() async {
);
await tester.pumpAndSettle();

expect(find.byType(FeeDetails), findsOneWidget);
expect(find.byType(PaymentFeeDetails), findsOneWidget);
expect(find.text('0.5 MXN'), findsOneWidget);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import 'package:didpay/shared/success_state.dart';
import 'package:didpay/shared/async/async_data_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import '../helpers/widget_helpers.dart';
import '../../helpers/widget_helpers.dart';

void main() {
group('SuccessPage', () {
group('AsyncDataWidget', () {
testWidgets('should show request was submitted', (tester) async {
await tester.pumpWidget(
WidgetHelpers.testableWidget(
child: const SuccessState(text: 'Your request was submitted!'),
child: const AsyncDataWidget(text: 'Your request was submitted!'),
),
);

Expand All @@ -20,7 +20,7 @@ void main() {
testWidgets('should show done button', (tester) async {
await tester.pumpWidget(
WidgetHelpers.testableWidget(
child: const SuccessState(
child: const AsyncDataWidget(
text: '',
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'package:didpay/shared/async_loading_widget.dart';
import 'package:didpay/shared/async/async_loading_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import '../helpers/widget_helpers.dart';
import '../../helpers/widget_helpers.dart';

void main() {
group('PendingPage', () {
group('AsyncLoadingWidget', () {
testWidgets('should show request is pending', (tester) async {
await tester.pumpWidget(
WidgetHelpers.testableWidget(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:convert';

import 'package:didpay/features/payment/payment_fee_details.dart';
import 'package:didpay/features/transaction/transaction.dart';
import 'package:didpay/shared/fee_details.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tbdex/tbdex.dart';

Expand All @@ -14,11 +14,11 @@ void main() {
final json = jsonDecode(jsonString);
final offering = Offering.fromJson(json);

group('FeeDetails', () {
group('PaymentFeeDetails', () {
testWidgets('should show est rate label', (tester) async {
await tester.pumpWidget(
WidgetHelpers.testableWidget(
child: FeeDetails(
child: PaymentFeeDetails(
transactionType: TransactionType.deposit,
offering: offering.data,
),
Expand All @@ -31,7 +31,7 @@ void main() {
testWidgets('should show deposit fee label', (tester) async {
await tester.pumpWidget(
WidgetHelpers.testableWidget(
child: FeeDetails(
child: PaymentFeeDetails(
transactionType: TransactionType.deposit,
offering: offering.data,
),
Expand All @@ -44,7 +44,7 @@ void main() {
testWidgets('should show withdraw fee label', (tester) async {
await tester.pumpWidget(
WidgetHelpers.testableWidget(
child: FeeDetails(
child: PaymentFeeDetails(
transactionType: TransactionType.withdraw,
offering: offering.data,
),
Expand All @@ -57,7 +57,7 @@ void main() {
testWidgets('should show send fee label', (tester) async {
await tester.pumpWidget(
WidgetHelpers.testableWidget(
child: FeeDetails(
child: PaymentFeeDetails(
transactionType: TransactionType.send,
offering: offering.data,
),
Expand All @@ -70,7 +70,7 @@ void main() {
testWidgets('should show est rate', (tester) async {
await tester.pumpWidget(
WidgetHelpers.testableWidget(
child: FeeDetails(
child: PaymentFeeDetails(
transactionType: TransactionType.deposit,
offering: offering.data,
),
Expand Down

0 comments on commit eb12dc9

Please sign in to comment.