Skip to content

Commit

Permalink
Merge pull request #1873 from ardriveapp/PE-6786-change-payment-metho…
Browse files Browse the repository at this point in the history
…d-selector

PE-6786: change payment method selector
  • Loading branch information
thiagocarvalhodev authored Oct 2, 2024
2 parents 3b1fb01 + 95ee158 commit 2cb3ece
Show file tree
Hide file tree
Showing 17 changed files with 753 additions and 343 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class UploadPaymentMethodView extends StatelessWidget {
this.onTurboTopupSucess,
this.loadingIndicator,
this.useNewArDriveUI = false,
this.useDropdown = false,
});

final Function(UploadMethod, UploadPaymentMethodInfo, bool)
Expand All @@ -22,6 +23,7 @@ class UploadPaymentMethodView extends StatelessWidget {
final Function()? onTurboTopupSucess;
final Widget? loadingIndicator;
final bool useNewArDriveUI;
final bool useDropdown;

@override
Widget build(BuildContext context) {
Expand All @@ -44,6 +46,7 @@ class UploadPaymentMethodView extends StatelessWidget {
return PaymentMethodSelector(
useNewArDriveUI: useNewArDriveUI,
uploadMethodInfo: state.paymentMethodInfo,
useDropdown: useDropdown,
onArSelect: () {
context.read<UploadPaymentMethodBloc>().add(
const ChangeUploadPaymentMethod(
Expand Down
13 changes: 9 additions & 4 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ class UploadCubit extends Cubit<UploadState> {
_selectedAntRecord = antRecord;
_selectedUndername = undername;

logger.d('Selected undername: $_selectedUndername');

final readyState = (state as UploadReady).copyWith(
params: (state as UploadReady).params.copyWith(
arnsUnderName: _getSelectedUndername(),
Expand All @@ -172,6 +170,11 @@ class UploadCubit extends Cubit<UploadState> {

void changeShowArnsNameSelection(bool showArnsNameSelection) {
_showArnsNameSelectionCheckBoxValue = showArnsNameSelection;

if (state is UploadReady) {
final readyState = state as UploadReady;
emit(readyState.copyWith(arnsCheckboxChecked: showArnsNameSelection));
}
}

void showArnsNameSelection(UploadReady readyState) {
Expand Down Expand Up @@ -241,6 +244,7 @@ class UploadCubit extends Cubit<UploadState> {
showArnsCheckbox: showArnsCheckbox,
showArnsNameSelection: false,
loadingArNSNames: true,
arnsCheckboxChecked: _showArnsNameSelectionCheckBoxValue,
totalSize: await _getTotalSize(),
),
);
Expand Down Expand Up @@ -278,6 +282,7 @@ class UploadCubit extends Cubit<UploadState> {
isArConnect: (state as UploadReadyToPrepare).isArConnect,
showArnsCheckbox: showArnsCheckbox,
showArnsNameSelection: false,
arnsCheckboxChecked: _showArnsNameSelectionCheckBoxValue,
totalSize: await _getTotalSize(),
),
);
Expand Down Expand Up @@ -649,8 +654,8 @@ class UploadCubit extends Cubit<UploadState> {
Future<void> startUploadPreparation({
bool isRetryingToPayWithTurbo = false,
}) async {
await Future.delayed(const Duration(seconds: 5));
_arnsRepository.getAntRecordsForWallet(_auth.currentUser.walletAddress);
final walletAddress = await _auth.getWalletAddress();
_arnsRepository.getAntRecordsForWallet(walletAddress!);

_files
.removeWhere((file) => filesNamesToExclude.contains(file.ioFile.name));
Expand Down
5 changes: 5 additions & 0 deletions lib/blocs/upload/upload_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class UploadReady extends UploadState {
final bool showArnsNameSelection;
final bool loadingArNSNames;
final bool loadingArNSNamesError;
final bool arnsCheckboxChecked;
final int totalSize;

final bool isArConnect;
Expand All @@ -121,6 +122,7 @@ class UploadReady extends UploadState {
required this.showArnsNameSelection,
this.loadingArNSNames = false,
this.loadingArNSNamesError = false,
required this.arnsCheckboxChecked,
required this.totalSize,
});

Expand All @@ -139,6 +141,7 @@ class UploadReady extends UploadState {
bool? showArnsNameSelection,
bool? loadingArNSNames,
bool? loadingArNSNamesError,
bool? arnsCheckboxChecked,
int? totalSize,
}) {
return UploadReady(
Expand All @@ -155,6 +158,7 @@ class UploadReady extends UploadState {
showArnsNameSelection ?? this.showArnsNameSelection,
loadingArNSNamesError:
loadingArNSNamesError ?? this.loadingArNSNamesError,
arnsCheckboxChecked: arnsCheckboxChecked ?? this.arnsCheckboxChecked,
totalSize: totalSize ?? this.totalSize,
);
}
Expand All @@ -167,6 +171,7 @@ class UploadReady extends UploadState {
loadingArNSNamesError,
loadingArNSNames,
showArnsCheckbox,
arnsCheckboxChecked,
];

@override
Expand Down
2 changes: 0 additions & 2 deletions lib/components/fs_entry_license_form.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:ardrive/blocs/blocs.dart';
import 'package:ardrive/components/license/cc_type_form.dart';
import 'package:ardrive/components/license/learn_about_licensing.dart';
import 'package:ardrive/components/license/udl_params_form.dart';
import 'package:ardrive/components/license_summary.dart';
import 'package:ardrive/core/crypto/crypto.dart';
Expand Down Expand Up @@ -252,7 +251,6 @@ class _FsEntryLicenseFormState extends State<FsEntryLicenseForm> {
),
),
),
const LearnAboutLicensing(),
const Divider(height: 32),
Text(
// TODO: Localize
Expand Down
27 changes: 0 additions & 27 deletions lib/components/license/learn_about_licensing.dart

This file was deleted.

Loading

0 comments on commit 2cb3ece

Please sign in to comment.