diff --git a/lib/blocs/upload/payment_method/view/upload_payment_method_view.dart b/lib/blocs/upload/payment_method/view/upload_payment_method_view.dart index 2be1dfe339..fc757e1d50 100644 --- a/lib/blocs/upload/payment_method/view/upload_payment_method_view.dart +++ b/lib/blocs/upload/payment_method/view/upload_payment_method_view.dart @@ -14,6 +14,7 @@ class UploadPaymentMethodView extends StatelessWidget { this.onTurboTopupSucess, this.loadingIndicator, this.useNewArDriveUI = false, + this.useDropdown = false, }); final Function(UploadMethod, UploadPaymentMethodInfo, bool) @@ -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) { @@ -44,6 +46,7 @@ class UploadPaymentMethodView extends StatelessWidget { return PaymentMethodSelector( useNewArDriveUI: useNewArDriveUI, uploadMethodInfo: state.paymentMethodInfo, + useDropdown: useDropdown, onArSelect: () { context.read().add( const ChangeUploadPaymentMethod( diff --git a/lib/blocs/upload/upload_cubit.dart b/lib/blocs/upload/upload_cubit.dart index adc96835aa..c6c5ae0114 100644 --- a/lib/blocs/upload/upload_cubit.dart +++ b/lib/blocs/upload/upload_cubit.dart @@ -159,8 +159,6 @@ class UploadCubit extends Cubit { _selectedAntRecord = antRecord; _selectedUndername = undername; - logger.d('Selected undername: $_selectedUndername'); - final readyState = (state as UploadReady).copyWith( params: (state as UploadReady).params.copyWith( arnsUnderName: _getSelectedUndername(), @@ -172,6 +170,11 @@ class UploadCubit extends Cubit { void changeShowArnsNameSelection(bool showArnsNameSelection) { _showArnsNameSelectionCheckBoxValue = showArnsNameSelection; + + if (state is UploadReady) { + final readyState = state as UploadReady; + emit(readyState.copyWith(arnsCheckboxChecked: showArnsNameSelection)); + } } void showArnsNameSelection(UploadReady readyState) { @@ -241,6 +244,7 @@ class UploadCubit extends Cubit { showArnsCheckbox: showArnsCheckbox, showArnsNameSelection: false, loadingArNSNames: true, + arnsCheckboxChecked: _showArnsNameSelectionCheckBoxValue, totalSize: await _getTotalSize(), ), ); @@ -278,6 +282,7 @@ class UploadCubit extends Cubit { isArConnect: (state as UploadReadyToPrepare).isArConnect, showArnsCheckbox: showArnsCheckbox, showArnsNameSelection: false, + arnsCheckboxChecked: _showArnsNameSelectionCheckBoxValue, totalSize: await _getTotalSize(), ), ); @@ -649,8 +654,8 @@ class UploadCubit extends Cubit { Future 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)); diff --git a/lib/blocs/upload/upload_state.dart b/lib/blocs/upload/upload_state.dart index e3a25c566b..9065084714 100644 --- a/lib/blocs/upload/upload_state.dart +++ b/lib/blocs/upload/upload_state.dart @@ -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; @@ -121,6 +122,7 @@ class UploadReady extends UploadState { required this.showArnsNameSelection, this.loadingArNSNames = false, this.loadingArNSNamesError = false, + required this.arnsCheckboxChecked, required this.totalSize, }); @@ -139,6 +141,7 @@ class UploadReady extends UploadState { bool? showArnsNameSelection, bool? loadingArNSNames, bool? loadingArNSNamesError, + bool? arnsCheckboxChecked, int? totalSize, }) { return UploadReady( @@ -155,6 +158,7 @@ class UploadReady extends UploadState { showArnsNameSelection ?? this.showArnsNameSelection, loadingArNSNamesError: loadingArNSNamesError ?? this.loadingArNSNamesError, + arnsCheckboxChecked: arnsCheckboxChecked ?? this.arnsCheckboxChecked, totalSize: totalSize ?? this.totalSize, ); } @@ -167,6 +171,7 @@ class UploadReady extends UploadState { loadingArNSNamesError, loadingArNSNames, showArnsCheckbox, + arnsCheckboxChecked, ]; @override diff --git a/lib/components/fs_entry_license_form.dart b/lib/components/fs_entry_license_form.dart index 6afcd9a741..45b1f4947e 100644 --- a/lib/components/fs_entry_license_form.dart +++ b/lib/components/fs_entry_license_form.dart @@ -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'; @@ -252,7 +251,6 @@ class _FsEntryLicenseFormState extends State { ), ), ), - const LearnAboutLicensing(), const Divider(height: 32), Text( // TODO: Localize diff --git a/lib/components/license/learn_about_licensing.dart b/lib/components/license/learn_about_licensing.dart deleted file mode 100644 index 493a7a9bc5..0000000000 --- a/lib/components/license/learn_about_licensing.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:ardrive/misc/resources.dart'; -import 'package:ardrive/utils/open_url.dart'; -import 'package:ardrive_ui/ardrive_ui.dart'; -import 'package:flutter/material.dart'; - -class LearnAboutLicensing extends StatelessWidget { - const LearnAboutLicensing({super.key}); - - @override - Widget build(BuildContext context) { - return ArDriveClickArea( - child: GestureDetector( - onTap: () { - openUrl( - url: Resources.licenseHelpLink, - ); - }, - child: Text( - 'Learn More about Licensing', - style: ArDriveTypography.body - .buttonNormalRegular() - .copyWith(decoration: TextDecoration.underline), - ), - ), - ); - } -} diff --git a/lib/components/payment_method_selector_widget.dart b/lib/components/payment_method_selector_widget.dart index 86af6409cd..829d301072 100644 --- a/lib/components/payment_method_selector_widget.dart +++ b/lib/components/payment_method_selector_widget.dart @@ -5,12 +5,13 @@ import 'package:ardrive_ui/ardrive_ui.dart'; import 'package:arweave/utils.dart'; import 'package:flutter/material.dart'; -class PaymentMethodSelector extends StatelessWidget { +class PaymentMethodSelector extends StatefulWidget { final UploadPaymentMethodInfo uploadMethodInfo; final void Function() onTurboTopupSucess; final void Function() onArSelect; final void Function() onTurboSelect; final bool useNewArDriveUI; + final bool useDropdown; const PaymentMethodSelector({ super.key, @@ -19,21 +20,169 @@ class PaymentMethodSelector extends StatelessWidget { required this.onArSelect, required this.onTurboSelect, this.useNewArDriveUI = false, + this.useDropdown = false, }); + @override + State createState() => _PaymentMethodSelectorState(); +} + +class _PaymentMethodSelectorState extends State { + late UploadMethod _selectedMethod; + + @override + void initState() { + super.initState(); + _selectedMethod = widget.uploadMethodInfo.uploadMethod; + } + @override Widget build(context) { return Column( children: [ - if (!uploadMethodInfo.isFreeThanksToTurbo) ...[ - _buildContent(context), - const SizedBox(height: 16), - _getInsufficientBalanceMessage(context: context), - ], + if (widget.useDropdown) _buildDropdown(context), + if (!widget.useDropdown) _buildContent(context), + _getInsufficientBalanceMessage(context: context), ], ); } + Widget _buildDropdown(BuildContext context) { + return ArDriveDropdown( + height: 45, + maxHeight: 90, + hasBorder: false, + hasDivider: false, + anchor: const Aligned( + follower: Alignment.centerRight, + target: Alignment.bottomRight, + offset: Offset(0, 10), + ), + items: [ + _buildDropdownItem(context, UploadMethod.ar), + _buildDropdownItem(context, UploadMethod.turbo), + ], + child: ArDriveClickArea( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + children: [ + _buildCoinIcon(), + const SizedBox(width: 16), + _buildSelectedItem(context), + ], + ), + ArDriveIcons.chevronDown(), + ], + ), + ), + ); + } + + ArDriveIcon _buildCoinIcon() { + if (_selectedMethod == UploadMethod.ar) { + return ArDriveIcons.arweaveCoin(); + } else { + return ArDriveIcons.turboCoin( + size: 28, + color: ArDriveTheme.of(context).themeData.colorTokens.containerRed, + ); + } + } + + ArDriveDropdownItem _buildDropdownItem( + BuildContext context, UploadMethod method) { + final typography = ArDriveTypographyNew.of(context); + + String text; + + if (method == UploadMethod.ar) { + text = 'Wallet Balance'; + } else { + text = 'Turbo Balance'; + } + + return ArDriveDropdownItem( + content: SizedBox( + width: 164, + height: 45, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + text, + style: typography.paragraphLarge( + fontWeight: ArFontWeight.semiBold, + ), + ), + if (_selectedMethod == method) + ArDriveIcons.checkmark( + size: 16, + ) + ], + ), + ), + ), + onClick: () { + setState(() { + _selectedMethod = method; + if (method == UploadMethod.ar) { + widget.onArSelect(); + } else { + widget.onTurboSelect(); + } + }); + }, + ); + } + + Widget _buildSelectedItem(BuildContext context) { + final typography = ArDriveTypographyNew.of(context); + final colorTokens = ArDriveTheme.of(context).themeData.colorTokens; + + if (_selectedMethod == UploadMethod.ar) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Cost: ${winstonToAr(widget.uploadMethodInfo.costEstimateAr.totalCost)} AR', + style: typography.paragraphLarge( + fontWeight: ArFontWeight.semiBold, + ), + ), + Text( + 'Payment Method: Wallet Balance: ${widget.uploadMethodInfo.arBalance} AR', + style: typography.paragraphSmall( + color: colorTokens.textLow, + ), + ), + ], + ); + } else { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Cost: ${winstonToAr(widget.uploadMethodInfo.costEstimateTurbo!.totalCost)} Credits', + style: typography.paragraphLarge( + fontWeight: ArFontWeight.semiBold, + ), + ), + Text( + 'Payment Method: Turbo Credits: ${widget.uploadMethodInfo.turboCredits} Credits', + style: typography.paragraphSmall( + color: colorTokens.textLow, + ), + ), + ], + ); + } + } + Widget _buildContent(BuildContext context) { final typography = ArDriveTypographyNew.of(context); final colorTokens = ArDriveTheme.of(context).themeData.colorTokens; @@ -53,13 +202,13 @@ class PaymentMethodSelector extends StatelessWidget { switch (index) { case 0: if (value) { - onArSelect(); + widget.onArSelect(); } break; case 1: if (value) { - onTurboSelect(); + widget.onTurboSelect(); } break; } @@ -67,34 +216,35 @@ class PaymentMethodSelector extends StatelessWidget { options: [ // FIXME: rename to RadioButtonOption RadioButtonOptions( - value: uploadMethodInfo.uploadMethod == UploadMethod.ar, + value: widget.uploadMethodInfo.uploadMethod == UploadMethod.ar, // TODO: Localization text: - 'Cost: ${winstonToAr(uploadMethodInfo.costEstimateAr.totalCost)} AR', - textStyle: useNewArDriveUI + 'Cost: ${winstonToAr(widget.uploadMethodInfo.costEstimateAr.totalCost)} AR', + textStyle: widget.useNewArDriveUI ? typography.paragraphLarge( fontWeight: ArFontWeight.bold, ) : ArDriveTypography.body.buttonLargeBold(), ), - if (uploadMethodInfo.costEstimateTurbo != null && - uploadMethodInfo.isTurboUploadPossible) + if (widget.uploadMethodInfo.costEstimateTurbo != null && + widget.uploadMethodInfo.isTurboUploadPossible) RadioButtonOptions( - value: uploadMethodInfo.uploadMethod == UploadMethod.turbo, + value: + widget.uploadMethodInfo.uploadMethod == UploadMethod.turbo, // TODO: Localization - text: uploadMethodInfo.hasNoTurboBalance + text: widget.uploadMethodInfo.hasNoTurboBalance ? '' - : 'Cost: ${winstonToAr(uploadMethodInfo.costEstimateTurbo!.totalCost)} Credits', - textStyle: useNewArDriveUI + : 'Cost: ${winstonToAr(widget.uploadMethodInfo.costEstimateTurbo!.totalCost)} Credits', + textStyle: widget.useNewArDriveUI ? typography.paragraphLarge( color: colorTokens.textHigh, fontWeight: ArFontWeight.bold) : ArDriveTypography.body.buttonLargeBold(), - content: uploadMethodInfo.hasNoTurboBalance + content: widget.uploadMethodInfo.hasNoTurboBalance ? GestureDetector( onTap: () { showTurboTopupModal(context, onSuccess: () { - onTurboTopupSucess(); + widget.onTurboTopupSucess(); }); }, child: ArDriveClickArea( @@ -104,7 +254,7 @@ class PaymentMethodSelector extends StatelessWidget { // TODO: use text with multiple styles TextSpan( text: 'Use Turbo Credits', // TODO: localize - style: useNewArDriveUI + style: widget.useNewArDriveUI ? typography.paragraphLarge( color: colorTokens.textMid, fontWeight: ArFontWeight.bold, @@ -119,7 +269,7 @@ class PaymentMethodSelector extends StatelessWidget { TextSpan( text: ' for faster uploads.', // TODO: localize - style: useNewArDriveUI + style: widget.useNewArDriveUI ? typography.paragraphLarge( color: colorTokens.textMid, fontWeight: ArFontWeight.bold, @@ -149,9 +299,9 @@ class PaymentMethodSelector extends StatelessWidget { child: Text( index == 0 // TODO: localize - ? 'Wallet Balance: ${uploadMethodInfo.arBalance} AR' - : 'Turbo Balance: ${uploadMethodInfo.turboCredits} Credits', - style: useNewArDriveUI + ? 'Wallet Balance: ${widget.uploadMethodInfo.arBalance} AR' + : 'Turbo Balance: ${widget.uploadMethodInfo.turboCredits} Credits', + style: widget.useNewArDriveUI ? typography.paragraphNormal( color: colorTokens.textLow, fontWeight: ArFontWeight.semiBold, @@ -174,13 +324,13 @@ class PaymentMethodSelector extends StatelessWidget { Widget _getInsufficientBalanceMessage({ required BuildContext context, }) { - if (uploadMethodInfo.uploadMethod == UploadMethod.turbo && - !uploadMethodInfo.sufficentCreditsBalance && - uploadMethodInfo.sufficientArBalance) { + if (widget.uploadMethodInfo.uploadMethod == UploadMethod.turbo && + !widget.uploadMethodInfo.sufficentCreditsBalance && + widget.uploadMethodInfo.sufficientArBalance) { return GestureDetector( onTap: () { showTurboTopupModal(context, onSuccess: () { - onTurboTopupSucess(); + widget.onTurboTopupSucess(); }); }, child: ArDriveClickArea( @@ -217,20 +367,20 @@ class PaymentMethodSelector extends StatelessWidget { ), ), ); - } else if (uploadMethodInfo.uploadMethod == UploadMethod.ar && - !uploadMethodInfo.sufficientArBalance) { + } else if (widget.uploadMethodInfo.uploadMethod == UploadMethod.ar && + !widget.uploadMethodInfo.sufficientArBalance) { return Text( 'Insufficient AR balance for purchase.', style: ArDriveTypography.body.captionBold( color: ArDriveTheme.of(context).themeData.colors.themeErrorDefault, ), ); - } else if (!uploadMethodInfo.sufficentCreditsBalance && - !uploadMethodInfo.sufficientArBalance) { + } else if (!widget.uploadMethodInfo.sufficentCreditsBalance && + !widget.uploadMethodInfo.sufficientArBalance) { return GestureDetector( onTap: () { showTurboTopupModal(context, onSuccess: () { - onTurboTopupSucess(); + widget.onTurboTopupSucess(); }); }, child: ArDriveClickArea( diff --git a/lib/components/upload_form.dart b/lib/components/upload_form.dart index 09a9de97e9..fe7591054e 100644 --- a/lib/components/upload_form.dart +++ b/lib/components/upload_form.dart @@ -15,7 +15,6 @@ import 'package:ardrive/blocs/upload/upload_file_checker.dart'; import 'package:ardrive/blocs/upload/upload_handles/file_v2_upload_handle.dart'; import 'package:ardrive/blocs/upload/upload_handles/upload_handle.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/view_license_definition.dart'; import 'package:ardrive/components/license_details_popover.dart'; @@ -25,6 +24,7 @@ import 'package:ardrive/core/arfs/entities/arfs_entities.dart'; import 'package:ardrive/core/upload/domain/repository/upload_repository.dart'; import 'package:ardrive/core/upload/uploader.dart'; import 'package:ardrive/l11n/validation_messages.dart'; +import 'package:ardrive/misc/resources.dart'; import 'package:ardrive/models/models.dart'; import 'package:ardrive/pages/congestion_warning_wrapper.dart'; import 'package:ardrive/pages/drive_detail/components/hover_widget.dart'; @@ -34,6 +34,7 @@ import 'package:ardrive/theme/theme.dart'; import 'package:ardrive/utils/app_localizations_wrapper.dart'; import 'package:ardrive/utils/filesize.dart'; import 'package:ardrive/utils/logger.dart'; +import 'package:ardrive/utils/open_url.dart'; import 'package:ardrive/utils/plausible_event_tracker/plausible_event_tracker.dart'; import 'package:ardrive/utils/show_general_dialog.dart'; import 'package:ardrive_io/ardrive_io.dart'; @@ -396,7 +397,7 @@ class _StatsScreenState extends State { text: TextSpan( children: [ TextSpan( - text: 'Size: ', + text: 'Total Size: ', style: typography.paragraphNormal( fontWeight: ArFontWeight.semiBold, color: colorTokens.textMid, @@ -417,17 +418,6 @@ class _StatsScreenState extends State { const Divider( height: 20, ), - if (widget.readyState.paymentInfo.isFreeThanksToTurbo) ...[ - const SizedBox(height: 8), - Text( - appLocalizationsOf(context).freeTurboTransaction, - style: typography.paragraphNormal( - color: colorTokens.textMid, - fontWeight: ArFontWeight.bold, - ), - ), - const SizedBox(height: 20), - ], ...widget.children, ], ); @@ -455,21 +445,7 @@ class ConfiguringLicenseScreen extends StatelessWidget { child: ReactiveFormConsumer( builder: (_, form, __) => UploadReadyModalBase( readyState: readyState, - actions: [ - ModalAction( - action: () => { - context.read().configuringLicenseBack(), - }, - title: appLocalizationsOf(context).backEmphasized, - ), - ModalAction( - isEnable: form.valid, - action: () { - context.read().configuringLicenseNext(); - }, - title: appLocalizationsOf(context).nextEmphasized, - ), - ], + actions: getModalActions(context, readyState, form), children: [ Text( headingText, @@ -484,6 +460,36 @@ class ConfiguringLicenseScreen extends StatelessWidget { ), ); } + + List getModalActions( + BuildContext context, UploadReady state, FormGroup form) { + String title; + double? customWidth; + + if (state.arnsCheckboxChecked) { + title = 'Assign Name'; + customWidth = 160; + } else { + title = appLocalizationsOf(context).nextEmphasized; + } + + return [ + ModalAction( + action: () => { + context.read().configuringLicenseBack(), + }, + title: appLocalizationsOf(context).backEmphasized, + ), + ModalAction( + isEnable: form.valid, + customWidth: customWidth, + action: () { + context.read().configuringLicenseNext(); + }, + title: title, + ), + ]; + } } class UploadReadyModalBase extends StatefulWidget { @@ -566,6 +572,8 @@ class LicenseReviewInfo extends StatelessWidget { @override Widget build(BuildContext context) { + final typography = ArDriveTypographyNew.of(context); + return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, @@ -574,8 +582,8 @@ class LicenseReviewInfo extends StatelessWidget { Text( // TODO: Localize 'License', - style: ArDriveTypography.body.smallRegular( - color: ArDriveTheme.of(context).themeData.colors.themeFgSubtle, + style: typography.paragraphLarge( + fontWeight: ArFontWeight.semiBold, ), ), Row( @@ -720,34 +728,13 @@ class _UploadReadyModalState extends State { action: () => Navigator.of(context).pop(false), title: appLocalizationsOf(context).cancelEmphasized, ), - licenseCategory == null - ? ModalAction( - isEnable: state.isNextButtonEnabled, - action: () { - context - .read() - .initialScreenUpload(); - }, - title: - appLocalizationsOf(context).uploadEmphasized, - ) - : ModalAction( - isEnable: state.isNextButtonEnabled, - action: () { - context.read().initialScreenNext( - licenseCategory: licenseCategory, - ); - }, - title: - // TODO: Localize - // appLocalizationsOf(context).configureEmphasized, - 'CONFIGURE', - ), + ...getModalActions(context, state, licenseCategory), ], children: [ RepositoryProvider.value( value: context.read(), child: UploadPaymentMethodView( + useDropdown: true, onError: () { context .read() @@ -1122,8 +1109,6 @@ class _UploadReadyWidget extends StatelessWidget { final DriveDetailCubit driveDetailCubit; @override Widget build(BuildContext context) { - logger.d('UploadReady state: ${state.showArnsNameSelection}'); - if (state.showArnsNameSelection) { return AssignArNSNameModal( driveDetailCubit: driveDetailCubit, @@ -1135,7 +1120,6 @@ class _UploadReadyWidget extends StatelessWidget { }, canClose: false, onEmptySelection: (emptySelection) { - logger.d('Cancelling ARNS name selection'); context.read().cancelArnsNameSelection(); }, ); @@ -1145,196 +1129,216 @@ class _UploadReadyWidget extends StatelessWidget { final colorTokens = ArDriveTheme.of(context).themeData.colorTokens; return ReactiveForm( formGroup: context.watch().licenseCategoryForm, - child: ReactiveFormConsumer(builder: (_, form, __) { - final LicenseCategory? licenseCategory = - form.control('licenseCategory').value; - return StatsScreen( - readyState: state, - // Don't show on first screen? - hasCloseButton: false, - modalActions: [ - ModalAction( - action: () => Navigator.of(context).pop(false), - title: appLocalizationsOf(context).cancelEmphasized, - ), - licenseCategory == null - ? ModalAction( - isEnable: state.isNextButtonEnabled, - action: () { - context.read().initialScreenUpload(); - }, - title: appLocalizationsOf(context).uploadEmphasized, - ) - : ModalAction( - isEnable: state.isNextButtonEnabled, - action: () { - context.read().initialScreenNext( - licenseCategory: licenseCategory, - ); - }, - title: - // TODO: Localize - // appLocalizationsOf(context).configureEmphasized, - 'CONFIGURE', - ), - ], - children: [ - RepositoryProvider.value( - value: context.read(), - child: UploadPaymentMethodView( - onError: () { - context.read().emitErrorFromPreparation(); - }, - onTurboTopupSucess: () { - context.read().startUploadPreparation( - isRetryingToPayWithTurbo: true, - ); - }, - onUploadMethodChanged: (method, info, canUpload) { - context - .read() - .setUploadMethod(method, info, canUpload); - }, - useNewArDriveUI: true, + child: ReactiveFormConsumer( + builder: (_, form, __) { + final LicenseCategory? licenseCategory = + form.control('licenseCategory').value; + return StatsScreen( + readyState: state, + // Don't show on first screen? + hasCloseButton: false, + modalActions: [ + ModalAction( + action: () => Navigator.of(context).pop(false), + title: appLocalizationsOf(context).cancelEmphasized, ), - ), - if (state.params.containsSupportedImageTypeForThumbnailGeneration) - Padding( - padding: const EdgeInsets.symmetric(vertical: 16), - child: Row( - children: [ - ArDriveCheckBox( - title: 'Upload with thumbnails', - checked: - context.read().config.uploadThumbnails, - titleStyle: typography.paragraphLarge( - fontWeight: ArFontWeight.semiBold, + ...getModalActions(context, state, licenseCategory), + ], + children: [ + if (state.params.containsSupportedImageTypeForThumbnailGeneration) + Padding( + padding: const EdgeInsets.only(top: 16), + child: Row( + children: [ + ArDriveCheckBox( + title: 'Upload with thumbnails', + useNewIcons: true, + checked: context + .read() + .config + .uploadThumbnails, + titleStyle: typography.paragraphLarge(), + onChange: (value) { + context + .read() + .changeUploadThumbnailOption(value); + }, ), - onChange: (value) { - context - .read() - .changeUploadThumbnailOption(value); - }, - ), - Padding( - padding: const EdgeInsets.only(left: 8.0), - child: ArDriveIconButton( - icon: ArDriveIcons.info( - color: colorTokens.textMid, + Padding( + padding: const EdgeInsets.only(left: 8.0), + child: ArDriveIconButton( + icon: ArDriveIcons.info( + color: colorTokens.textMid, + ), + tooltip: + 'Uploading with thumbnails is free, but may make your upload take longer.\nYou can always attach a thumbnail later.', ), - tooltip: - 'Uploading with thumbnails is free, but may make your upload take longer.\nYou can always attach a thumbnail later.', - ), - ) - ], + ) + ], + ), ), - ), - if (state.loadingArNSNamesError) - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Row( - children: [ - Text( - 'Error loading ARNS names', - style: typography.paragraphLarge( - fontWeight: ArFontWeight.semiBold, - color: colorTokens.textRed, + if (state.loadingArNSNamesError) + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Row( + children: [ + Text( + 'Error loading ARNS names', + style: typography.paragraphLarge( + fontWeight: ArFontWeight.semiBold, + color: colorTokens.textRed, + ), ), - ), - ], + ], + ), ), - ), - if (state.loadingArNSNames) - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Row( - children: [ - Text( - 'Loading ArNS names...', - style: typography.paragraphLarge( - fontWeight: ArFontWeight.semiBold, + if (state.loadingArNSNames) + Padding( + padding: const EdgeInsets.only(top: 8), + child: Row( + children: [ + Text( + 'Loading ArNS names...', + style: typography.paragraphLarge( + fontWeight: ArFontWeight.semiBold, + ), ), - ), - const SizedBox(width: 8), - const SizedBox( - height: 16, - width: 16, - child: CircularProgressIndicator( - strokeWidth: 2, + const SizedBox(width: 8), + const SizedBox( + height: 16, + width: 16, + child: CircularProgressIndicator( + strokeWidth: 2, + ), + ) + ], + ), + ), + if (state.showArnsCheckbox && !state.loadingArNSNames) + Padding( + padding: const EdgeInsets.only(top: 8, bottom: 8), + child: Row( + children: [ + ArDriveCheckBox( + title: 'Assign an ARNS name', + checked: state.arnsCheckboxChecked, + useNewIcons: true, + titleStyle: typography.paragraphLarge(), + onChange: (value) { + context + .read() + .changeShowArnsNameSelection(value); + }, ), - ) - ], + ], + ), ), - ), - if (state.showArnsCheckbox && !state.loadingArNSNames) Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Row( + padding: const EdgeInsets.only(top: 8), + child: Column( children: [ - ArDriveCheckBox( - title: 'Assign an ARNS name', - checked: state.params.arnsUnderName != null, - titleStyle: typography.paragraphLarge( - fontWeight: ArFontWeight.semiBold, + Row( + children: [ + ArDriveIcons.license1(), + const SizedBox(width: 8), + Text( + 'License', + style: typography.paragraphLarge( + fontWeight: ArFontWeight.semiBold, + ), + ), + const SizedBox(width: 8), + ArDriveClickArea( + tooltip: 'Learn more about licenses', + child: GestureDetector( + onTap: () { + openUrl(url: Resources.licenseHelpLink); + }, + child: ArDriveIcons.question( + color: colorTokens.textLow, + ), + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.only(left: 32.0), + child: ReactiveForm( + formGroup: + context.watch().licenseCategoryForm, + child: ReactiveDropdownField( + alignment: AlignmentDirectional.centerStart, + isExpanded: true, + formControlName: 'licenseCategory', + decoration: InputDecoration( + labelStyle: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + ), + border: InputBorder.none, + focusedBorder: InputBorder.none, + ), + showErrors: (control) => + control.dirty && control.invalid, + validationMessages: + kValidationMessages(appLocalizationsOf(context)), + items: [null, ...LicenseCategory.values].map( + (value) { + return DropdownMenuItem( + value: value, + child: Text( + licenseCategoryNames[value] ?? 'None', + style: typography.paragraphNormal( + fontWeight: ArFontWeight.semiBold, + color: colorTokens.textMid, + ), + ), + ); + }, + ).toList(), + ), ), - onChange: (value) { - context - .read() - .changeShowArnsNameSelection(value); - }, ), ], ), ), - SizedBox( - child: ReactiveForm( - formGroup: context.watch().licenseCategoryForm, - child: ReactiveDropdownField( - alignment: AlignmentDirectional.centerStart, - isExpanded: true, - formControlName: 'licenseCategory', - decoration: InputDecoration( - border: InputBorder.none, - label: Text( - 'License', - // TODO: Localize - // appLocalizationsOf(context).licenseType, - style: ArDriveTheme.of(context) - .themeData - .textFieldTheme - .inputTextStyle - .copyWith( - color: ArDriveTheme.of(context) - .themeData - .colors - .themeFgDisabled, - fontSize: 16, - ), - ), - focusedBorder: InputBorder.none, + const Divider(), + if (state.paymentInfo.isFreeThanksToTurbo) ...[ + const SizedBox(height: 8), + Text( + appLocalizationsOf(context).freeTurboTransaction, + style: typography.paragraphNormal( + color: colorTokens.textMid, + fontWeight: ArFontWeight.bold, ), - showErrors: (control) => control.dirty && control.invalid, - validationMessages: - kValidationMessages(appLocalizationsOf(context)), - items: [null, ...LicenseCategory.values].map( - (value) { - return DropdownMenuItem( - value: value, - child: Text( - licenseCategoryNames[value] ?? 'None', - // TODO: Localize - // appLocalizationsOf(context).none, - ), - ); + ), + const SizedBox(height: 20), + ], + if (!state.paymentInfo.isFreeThanksToTurbo) ...[ + RepositoryProvider.value( + value: context.read(), + child: UploadPaymentMethodView( + useDropdown: true, + onError: () { + context.read().emitErrorFromPreparation(); }, - ).toList(), + onTurboTopupSucess: () { + context.read().startUploadPreparation( + isRetryingToPayWithTurbo: true, + ); + }, + onUploadMethodChanged: (method, info, canUpload) { + context + .read() + .setUploadMethod(method, info, canUpload); + }, + useNewArDriveUI: true, + ), ), - ), - ), - const LearnAboutLicensing(), - ], - ); - }), + ], + ], + ); + }, + ), ); } } @@ -2076,3 +2080,41 @@ class _UploadLoadingFilesSuccessWidget extends StatelessWidget { ); } } + +List getModalActions( + BuildContext context, UploadReady state, LicenseCategory? licenseCategory) { + if (licenseCategory != null) { + return [ + ModalAction( + isEnable: state.isNextButtonEnabled, + action: () { + context.read().initialScreenNext( + licenseCategory: licenseCategory, + ); + }, + title: 'CONFIGURE', + ), + ]; + } else if (state.arnsCheckboxChecked) { + return [ + ModalAction( + isEnable: state.isNextButtonEnabled, + customWidth: 160, + action: () { + context.read().initialScreenUpload(); + }, + title: 'ASSIGN NAME', + ), + ]; + } + + return [ + ModalAction( + isEnable: state.isNextButtonEnabled, + action: () { + context.read().initialScreenUpload(); + }, + title: appLocalizationsOf(context).uploadEmphasized, + ), + ]; +} diff --git a/packages/ardrive_ui/assets/fonts/ArDriveIcons.ttf b/packages/ardrive_ui/assets/fonts/ArDriveIcons.ttf index bfe8e9f76e..6c91bc2d56 100644 Binary files a/packages/ardrive_ui/assets/fonts/ArDriveIcons.ttf and b/packages/ardrive_ui/assets/fonts/ArDriveIcons.ttf differ diff --git a/packages/ardrive_ui/assets/fonts/config.json b/packages/ardrive_ui/assets/fonts/config.json index e8f961e6af..62dad3bc87 100644 --- a/packages/ardrive_ui/assets/fonts/config.json +++ b/packages/ardrive_ui/assets/fonts/config.json @@ -1111,6 +1111,132 @@ "search": [ "add-arns-name" ] + }, + { + "uid": "bef8eef79b616fc41195318d0518d5a2", + "css": "checked", + "code": 59475, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M498.5 83.3H501.5C558.5 83.3 603.3 83.3 639.6 85.8 676.6 88.3 707.7 93.6 736.6 105.5 808.1 135.1 864.9 191.9 894.5 263.4 906.4 292.3 911.7 323.4 914.2 360.4 916.7 396.7 916.7 441.5 916.7 498.5V501.5C916.7 558.5 916.7 603.3 914.2 639.6 911.7 676.6 906.4 707.7 894.5 736.6 864.9 808.1 808.1 864.9 736.6 894.5 707.7 906.4 676.6 911.7 639.6 914.2 603.3 916.7 558.5 916.7 501.5 916.7H498.5C441.5 916.7 396.7 916.7 360.4 914.2 323.4 911.7 292.3 906.4 263.4 894.5 191.9 864.9 135.1 808.1 105.5 736.6 93.6 707.7 88.3 676.6 85.8 639.6 83.3 603.3 83.3 558.5 83.3 501.5V498.5C83.3 441.5 83.3 396.7 85.8 360.4 88.3 323.4 93.6 292.3 105.5 263.4 135.1 191.9 191.9 135.1 263.4 105.5 292.3 93.6 323.4 88.3 360.4 85.8 396.7 83.3 441.5 83.3 498.5 83.3ZM366 168.9C333.3 171.2 312.3 175.5 295.3 182.5 244.2 203.7 203.7 244.2 182.5 295.3 175.5 312.3 171.2 333.3 168.9 366 166.7 399.2 166.7 441.2 166.7 500 166.7 558.8 166.7 600.8 168.9 634 171.2 666.7 175.5 687.7 182.5 704.7 203.7 755.8 244.2 796.3 295.3 817.5 312.3 824.5 333.3 828.8 366 831 399.2 833.3 441.2 833.3 500 833.3 558.8 833.3 600.8 833.3 634 831 666.7 828.8 687.7 824.5 704.7 817.5 755.8 796.3 796.3 755.8 817.5 704.7 824.5 687.7 828.8 666.7 831 634 833.3 600.8 833.3 558.8 833.3 500 833.3 441.2 833.3 399.2 831 366 828.8 333.3 824.5 312.3 817.5 295.3 796.3 244.2 755.8 203.7 704.7 182.5 687.7 175.5 666.7 171.2 634 168.9 600.8 166.7 558.8 166.7 500 166.7 441.2 166.7 399.2 166.7 366 168.9ZM622.3 375.8C641.3 362.9 667.3 367.8 680.2 386.8 693.2 405.8 688.3 431.7 669.3 444.7L665.1 447.5C592.3 497.3 531.7 562.9 487.9 639.5 481.4 650.7 470.1 658.4 457.3 660.1 444.4 661.8 431.5 657.4 422.3 648.3L324.7 550.8C308.4 534.6 308.4 508.2 324.7 491.9 341 475.6 367.3 475.6 383.6 491.9L444.2 552.4C490.8 484.3 549.7 425.4 618.1 378.7L622.3 375.8Z", + "width": 1000 + }, + "search": [ + "checked" + ] + }, + { + "uid": "3705687f93c0a3d09061eae46c8521de", + "css": "advanced-chevron", + "code": 59476, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M258 308.8C271.5 290.2 297.5 286.1 316.2 299.6 380 346 437.3 400.4 486.4 461.5 504.5 484 504.5 516 486.4 538.5 437.3 599.6 380 654 316.2 700.4 297.5 713.9 271.5 709.8 258 691.2 244.4 672.5 248.6 646.5 267.2 633 320.3 594.4 368.3 549.7 410.2 500 368.3 450.3 320.3 405.6 267.2 367 248.6 353.5 244.4 327.5 258 308.8ZM508 308.8C521.5 290.2 547.5 286.1 566.2 299.6 630 346 687.3 400.4 736.4 461.5 754.5 484 754.5 516 736.4 538.5 687.3 599.6 630 654 566.2 700.4 547.5 713.9 521.5 709.8 508 691.2 494.4 672.5 498.6 646.5 517.2 633 570.3 594.4 618.3 549.7 660.2 500 618.3 450.3 570.3 405.6 517.2 367 498.6 353.5 494.4 327.5 508 308.8Z", + "width": 1000 + }, + "search": [ + "advanced-chevron" + ] + }, + { + "uid": "706964788e106085036518e773b6fcb3", + "css": "chevron-up", + "code": 59477, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M500 475.9C549.7 517.7 594.4 565.7 633 618.8 646.5 637.5 672.5 641.6 691.2 628.1 709.8 614.5 713.9 588.5 700.4 569.9 654 506 599.6 448.8 538.5 399.6 516 381.5 484 381.5 461.5 399.6 400.4 448.8 346 506 299.6 569.9 286.1 588.5 290.2 614.5 308.8 628.1 327.5 641.6 353.5 637.5 367 618.8 405.6 565.7 450.3 517.7 500 475.9Z", + "width": 1000 + }, + "search": [ + "chevron-up" + ] + }, + { + "uid": "180aa3890229a0c151830935b2e3be87", + "css": "chevron-down", + "code": 59478, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M308.8 388.8C327.5 375.2 353.5 379.4 367 398 405.6 451.1 450.3 499.1 500 541 549.7 499.1 594.4 451.1 633 398 646.5 379.4 672.5 375.2 691.2 388.8 709.8 402.3 713.9 428.3 700.4 447 654 510.8 599.6 568.1 538.5 617.2 516 635.3 484 635.3 461.5 617.2 400.4 568.1 346 510.8 299.6 447 286.1 428.3 290.2 402.3 308.8 388.8Z", + "width": 1000 + }, + "search": [ + "chevron-down" + ] + }, + { + "uid": "10d5f58e1ba9636e231b874e02e3a5b9", + "css": "pic", + "code": 59472, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M414.8 83.3H585.2C641.9 83.3 687.1 83.3 723.6 86.3 760.9 89.4 792.7 95.7 821.8 110.6 868.9 134.5 907.1 172.8 931.1 219.8 957.2 271.1 958.2 334.4 958.3 427.9 958.3 437.6 958.3 447.8 958.3 458.3V543.5C958.3 600.3 958.3 645.4 955.4 681.9 952.3 719.2 945.9 751 931.1 780.2 907.1 827.2 868.9 865.5 821.8 889.4 792.7 904.3 760.9 910.6 723.6 913.7 687.1 916.7 641.9 916.7 585.2 916.7H416.4C385 916.7 357.3 916.7 333 916.2 268.8 915 220.1 910.8 178.2 889.4 131.1 865.5 92.9 827.2 68.9 780.2 54.1 751 47.7 719.2 44.6 681.9 41.7 645.4 41.7 600.3 41.7 543.5V456.5C41.7 399.7 41.7 354.5 44.6 318.1 47.7 280.8 54.1 249 68.9 219.8 92.9 172.8 131.1 134.5 178.2 110.6 207.3 95.7 239.1 89.4 276.4 86.3 312.9 83.3 358 83.3 414.8 83.3ZM283.2 169.4C251.1 172 231.4 177 216 184.8 184.6 200.8 159.1 226.3 143.2 257.7 135.3 273.1 130.3 292.7 127.7 324.9 125 357.5 125 399.3 125 458.3V541.7C125 600.7 125 642.5 127.7 675.1 130.3 707.3 135.3 726.9 143.2 742.3 159.1 773.7 184.6 799.2 216 815.2 233.8 824.3 256.4 829.2 295.6 831.5 327.3 574.2 546.6 375 812.5 375 833.5 375 854.2 376.2 874.6 378.7 873.4 313.4 869.2 282 856.8 257.7 840.9 226.3 815.4 200.8 784 184.8 768.6 177 748.9 172 716.8 169.4 684.1 166.7 642.4 166.7 583.3 166.7H416.7C357.6 166.7 315.9 166.7 283.2 169.4ZM875 462.8C854.6 459.8 833.7 458.3 812.5 458.3 592.1 458.3 409.8 621.3 379.4 833.3 391.1 833.3 403.5 833.3 416.7 833.3H583.3C642.4 833.3 684.1 833.3 716.8 830.6 748.9 828 768.6 823 784 815.2 815.4 799.2 840.9 773.7 856.8 742.3 864.7 726.9 869.7 707.3 872.3 675.1 875 642.5 875 600.7 875 541.7V462.8ZM208.3 354.2C208.3 296.6 255 250 312.5 250 370 250 416.7 296.6 416.7 354.2 416.7 411.7 370 458.3 312.5 458.3 255 458.3 208.3 411.7 208.3 354.2ZM312.5 333.3C301 333.3 291.7 342.7 291.7 354.2 291.7 365.7 301 375 312.5 375 324 375 333.3 365.7 333.3 354.2 333.3 342.7 324 333.3 312.5 333.3Z", + "width": 1000 + }, + "search": [ + "pic" + ] + }, + { + "uid": "226e2be46a3c7645e3541de57acb894e", + "css": "box", + "code": 59473, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M498.5 83.3H501.5C558.5 83.3 603.3 83.3 639.6 85.8 676.6 88.3 707.7 93.6 736.6 105.5 808.1 135.1 864.9 191.9 894.5 263.4 906.4 292.3 911.7 323.4 914.2 360.4 916.7 396.7 916.7 441.5 916.7 498.5V501.5C916.7 558.5 916.7 603.3 914.2 639.6 911.7 676.6 906.4 707.7 894.5 736.6 864.9 808.1 808.1 864.9 736.6 894.5 707.7 906.4 676.6 911.7 639.6 914.2 603.3 916.7 558.5 916.7 501.5 916.7H498.5C441.5 916.7 396.7 916.7 360.4 914.2 323.4 911.7 292.3 906.4 263.4 894.5 191.9 864.9 135.1 808.1 105.5 736.6 93.6 707.7 88.3 676.6 85.8 639.6 83.3 603.3 83.3 558.5 83.3 501.5V498.5C83.3 441.5 83.3 396.7 85.8 360.4 88.3 323.4 93.6 292.3 105.5 263.4 135.1 191.9 191.9 135.1 263.4 105.5 292.3 93.6 323.4 88.3 360.4 85.8 396.7 83.3 441.5 83.3 498.5 83.3ZM366 168.9C333.3 171.2 312.3 175.5 295.3 182.5 244.2 203.7 203.7 244.2 182.5 295.3 175.5 312.3 171.2 333.3 168.9 366 166.7 399.2 166.7 441.2 166.7 500 166.7 558.8 166.7 600.8 168.9 634 171.2 666.7 175.5 687.7 182.5 704.7 203.7 755.8 244.2 796.3 295.3 817.5 312.3 824.5 333.3 828.8 366 831 399.2 833.3 441.2 833.3 500 833.3 558.8 833.3 600.8 833.3 634 831 666.7 828.8 687.7 824.5 704.7 817.5 755.8 796.3 796.3 755.8 817.5 704.7 824.5 687.7 828.8 666.7 831 634 833.3 600.8 833.3 558.8 833.3 500 833.3 441.2 833.3 399.2 831 366 828.8 333.3 824.5 312.3 817.5 295.3 796.3 244.2 755.8 203.7 704.7 182.5 687.7 175.5 666.7 171.2 634 168.9 600.8 166.7 558.8 166.7 500 166.7 441.2 166.7 399.2 166.7 366 168.9Z", + "width": 1000 + }, + "search": [ + "box" + ] + }, + { + "uid": "28fb2839a66640875ede1bd404024968", + "css": "license-1", + "code": 59471, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M500 125C361.9 125 250 236.9 250 375 250 452.3 285 521.3 340.1 567.2 383.5 603.3 439.2 625 500 625 565.2 625 624.6 600.1 669.1 559.1 718.9 513.4 750 447.9 750 375 750 236.9 638.1 125 500 125ZM166.7 375C166.7 190.9 315.9 41.7 500 41.7 684.1 41.7 833.3 190.9 833.3 375 833.3 463.3 799 543.6 743 603.2L811.5 907.5C815.2 923.9 808.7 940.8 795 950.6 781.4 960.3 763.3 960.9 749 952.2L734.1 943C591.9 855.5 411.9 858.8 273.1 951.3 259.1 960.7 240.8 960.7 226.8 951.3 212.8 941.9 205.8 925 209.1 908.5L268 614.3C205.5 553.8 166.7 468.9 166.7 375ZM342.1 668.6L308.3 837.8C436.2 782.7 581.7 782.3 710.2 837.1L670.7 661.4C620.8 691.2 562.4 708.3 500 708.3 442.9 708.3 389.1 694 342.1 668.6Z", + "width": 1000 + }, + "search": [ + "license" + ] + }, + { + "uid": "6370e638b249eee39121de66c004cc7a", + "css": "turbo-coin", + "code": 59481, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M684.8 440.3H676.5C669.6 440.3 664 434.9 664 428.2V419.8H588.5C586 419.8 584.1 421.7 584.1 424.1 584.1 426.5 586 428.4 588.5 428.4H641.5A168 168 0 0 1 661.1 507.2C661.1 602.9 580.8 680.5 481.9 680.5 382.9 680.5 302.7 602.9 302.7 507.2 302.7 411.9 382.1 334.6 480.4 333.9L481.9 333.9H664V331.6C664 325 669.6 319.5 676.5 319.5H684.8C691.7 319.5 697.3 325 697.3 331.6V428.2C697.3 434.9 691.7 440.3 684.8 440.3ZM481.9 565.9C515.4 565.9 542.6 539.6 542.6 507.2 542.6 474.7 515.4 448.4 481.9 448.4 448.3 448.4 421.2 474.7 421.2 507.2 421.2 539.6 448.3 565.9 481.9 565.9ZM500 69.6C262.7 69.6 69.6 262.7 69.6 500 69.6 737.3 262.7 930.4 500 930.4 737.3 930.4 930.5 737.3 930.5 500 930.5 262.7 737.3 69.6 500 69.6ZM500 138C700.4 138 862 299.7 862 500 862 700.3 700.4 862 500 862 299.7 862 138 700.3 138 500 138 299.7 299.7 138 500 138Z", + "width": 1000 + }, + "search": [ + "turbo-coin-(1)-(2)" + ] + }, + { + "uid": "0981706192e9c5d40d7f7f3ee748901a", + "css": "arweave", + "code": 59480, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M500 114.8C287.3 114.8 114.8 287.3 114.8 500S287.3 885.2 500 885.2C712.7 885.2 885.2 712.7 885.2 500S712.7 114.8 500 114.8ZM43.3 500C43.3 247.8 247.7 43.3 500 43.3S956.8 247.8 956.8 500C956.8 752.3 752.3 956.8 500 956.8S43.3 752.3 43.3 500ZM580.2 651.8C577.3 648.9 577.3 643.2 574.5 637.5 574.5 631.8 571.6 626 571.6 620.3 565.9 626 560.2 628.9 554.4 634.6S540.1 643.2 534.4 646.1C525.8 648.9 520.1 651.8 508.6 654.7 500 657.5 488.6 657.5 480 657.5 462.8 657.5 448.5 654.7 434.2 648.9S408.4 637.5 397 628.9C385.5 620.3 379.8 608.9 374.1 597.4S365.5 571.6 365.5 557.3C365.5 522.9 379.8 494.3 405.6 477.1 431.3 457.1 471.4 448.5 523 448.5H571.7V428.5C571.7 411.3 565.9 399.8 557.3 391.3 545.9 382.7 531.6 376.9 511.5 376.9 494.3 376.9 482.9 379.8 474.3 388.4S462.8 405.6 462.8 417H376.9C376.9 402.7 379.8 388.4 385.5 376.9S399.8 354 414.2 342.6C425.6 334 439.9 325.4 457.1 319.7S494.3 311.1 517.3 311.1C537.3 311.1 554.5 313.9 571.7 319.7S603.2 331.1 617.5 342.6C628.9 351.2 640.4 365.5 646.1 379.8S657.6 411.3 657.6 431.3V574.5C657.6 591.7 657.6 606 660.4 617.5S666.2 640.4 669 646.1V651.8H580.2ZM497.2 591.6C505.8 591.6 514.3 591.6 520.1 588.8 528.7 585.9 534.4 583 540.1 580.2S551.6 574.4 554.4 568.7C557.3 565.8 563 560.1 565.9 557.2V499.9H522.9C508.6 499.9 497.1 499.9 488.5 502.8S471.3 508.5 465.6 514.3C459.9 520 454.2 522.9 451.3 531.5 448.4 537.2 448.4 545.8 448.4 551.5 448.4 563 451.3 571.5 459.9 580.1S482.8 591.6 497.1 591.6ZM508.6 654.6C500 657.5 488.6 657.5 480 657.5 462.8 657.5 448.5 654.6 434.2 648.9S408.4 637.4 397 628.9C385.5 620.3 379.8 608.8 374.1 597.4S365.5 571.6 365.5 557.3C365.5 522.9 379.8 494.3 405.6 477.1 431.3 457.1 471.4 448.5 523 448.5H571.7V428.4C571.7 425.4 571.5 422.5 571.1 419.8 569.5 407.3 564.4 398.3 557.3 391.2 545.9 382.6 531.6 376.9 511.5 376.9 494.3 376.9 482.9 379.8 474.3 388.4S462.8 405.6 462.8 417H376.9C376.9 407.2 378.3 397.3 381 388.4 382.2 384.3 383.8 380.5 385.5 376.9 391.3 365.4 399.8 354 414.2 342.5 425.6 333.9 439.9 325.3 457.1 319.6S494.3 311 517.3 311C537.3 311 554.5 313.9 571.7 319.6S603.2 331.1 617.5 342.5C628.9 351.1 640.4 365.4 646.1 379.8S657.6 411.3 657.6 431.3V574.5C657.6 591.7 657.6 606 660.4 617.4 660.9 619.3 661.4 621.3 661.9 623.2 664.3 632.6 666.7 641.3 669 646.1V651.8H580.2C580 651.5 579.8 651.2 579.5 650.9 578.4 649.3 577.8 647.2 577.1 644.8 576.5 642.5 575.8 640 574.5 637.5 574.5 634.6 573.8 631.8 573.1 628.9S571.7 623.2 571.7 620.3C568.8 623.2 565.9 625.3 563.1 627.4S557.3 631.7 554.5 634.6C553.4 635.6 552.3 636.6 551.1 637.5 549.4 638.7 547.7 639.7 545.9 640.7 543.5 641.9 541.1 643 538.9 644 537.3 644.7 535.8 645.4 534.4 646 531.5 647 529 647.9 526.4 648.9 521.3 650.8 516.3 652.7 508.6 654.6ZM439.8 388.3C443.3 380.6 448.1 374 454 368.1 470.7 351.4 491.7 348.2 511.5 348.2 537.7 348.2 558.1 356 574.5 368.3L576.1 369.5 577.5 370.9C591.6 384.9 600.3 403.7 600.3 428.4V477.1H594.5V556.8L600.3 551.1V619.5C600.3 619.8 600.5 620.5 600.8 621.9 600.8 622.1 600.9 622.2 600.9 622.4 601 622.6 601.1 622.9 601.1 623.1H632.3C628.9 608.5 628.9 591.6 628.9 576.6 628.9 575.8 628.9 575.2 628.9 574.4V431.2C628.9 416.7 624.8 403.5 619.5 390.3 615.8 381.2 607.7 371 600.3 365.4L599.9 365.1 599.6 364.8C589.3 356.6 578.8 352.1 562.6 346.7 548.4 342 534.3 339.6 517.3 339.6 496.7 339.6 479.8 342.2 466.2 346.7 452.8 351.2 441.3 358 431.7 365.1 421.4 373.4 415.6 381.1 411.8 388.3H439.8ZM554.4 568.7L565.9 557.3V500H522.9C508.6 500 497.2 500 488.6 502.8S471.4 508.6 465.7 514.3C464.2 515.8 462.7 517.1 461.3 518.3 457.2 521.9 453.5 525.1 451.3 531.5 448.5 537.2 448.5 545.8 448.5 551.5 448.5 563 451.3 571.5 459.9 580.1S482.8 591.6 497.2 591.6C505.8 591.6 514.3 591.6 520.1 588.7 528.7 585.8 534.4 583 540.1 580.1S551.6 574.4 554.4 568.7ZM530.7 615.4C523.8 618.4 517.1 619.3 512.3 619.8 507 620.3 501.6 620.3 497.7 620.3H497.2C481 620.3 456.7 617.4 439.7 600.4 433 593.8 427.7 586.2 424.3 577.2 420.8 568.3 419.8 559.6 419.8 551.5V551.2C419.8 548.5 419.8 543.7 420.3 538.7 420.8 534.2 421.8 527.5 424.8 520.7 428 512.1 432.7 506.1 437.2 501.6 439.1 499.6 441.1 497.9 442.3 496.8 442.4 496.7 442.5 496.7 442.6 496.6 444 495.3 444.8 494.7 445.4 494 450 489.4 455.3 485.9 460.4 483.2 444.3 487.1 432 492.7 423.1 499.7L422.3 500.3 421.4 500.9C404.6 512.1 394.1 531.2 394.1 557.2 394.1 568.1 396.3 577.9 399.7 584.5 405.7 596.6 408.8 602 414.1 605.9 422.9 612.5 431.8 617.1 444.8 622.3 455.7 626.7 466.4 628.8 480 628.8 489.9 628.8 496.3 628.6 499.6 627.4L500.6 627.1 501.7 626.8C507.9 625.2 510.8 624.2 514.7 622.7 517 621.8 519.7 620.8 523.6 619.4 524.8 618.8 526.1 618.3 527.1 617.8 527.2 617.8 527.3 617.7 527.4 617.7 529.2 616.9 530.4 616.3 531.6 615.7 533.6 614.8 534.2 614.3 534.3 614.2ZM530.7 615.4C532 614.9 533.3 614.5 534.5 614Z", + "width": 1000 + }, + "search": [ + "arweave" + ] } ] } \ No newline at end of file diff --git a/packages/ardrive_ui/lib/src/components/card.dart b/packages/ardrive_ui/lib/src/components/card.dart index 3a7c931fae..63237949ae 100644 --- a/packages/ardrive_ui/lib/src/components/card.dart +++ b/packages/ardrive_ui/lib/src/components/card.dart @@ -46,7 +46,7 @@ class ArDriveCard extends StatelessWidget { ), ), child: ClipRRect( - clipBehavior: Clip.hardEdge, + clipBehavior: Clip.antiAlias, borderRadius: BorderRadius.circular( borderRadius ?? cardDefaultBorderRadius, ), diff --git a/packages/ardrive_ui/lib/src/components/check_box.dart b/packages/ardrive_ui/lib/src/components/check_box.dart index d9f87eafc5..aefe95e22a 100644 --- a/packages/ardrive_ui/lib/src/components/check_box.dart +++ b/packages/ardrive_ui/lib/src/components/check_box.dart @@ -13,6 +13,7 @@ class ArDriveCheckBox extends StatefulWidget { this.titleStyle, this.onChange, this.titleWidget, + this.useNewIcons = true, }); /// Initial state of the checkbox. @@ -29,6 +30,8 @@ class ArDriveCheckBox extends StatefulWidget { final TextStyle? titleStyle; final Function(bool value)? onChange; + final bool useNewIcons; + @override State createState() => ArDriveCheckBoxState(); } @@ -87,47 +90,75 @@ class ArDriveCheckBoxState extends State { } widget.onChange?.call(checked); }, - child: ArDriveClickArea( - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - state == CheckBoxState.indeterminate - ? ArDriveIcon( - icon: ArDriveIconsData.minus_rectangle, - size: 22, - color: ArDriveTheme.of(context) - .themeData - .colors - .themeFgDefault, - ) - : AnimatedContainer( - height: 18.5, - width: 18.5, - margin: const EdgeInsets.fromLTRB(3.25, 3.5, 5, 4), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(checkboxBorderRadius), - border: Border.all( - color: _boxColor(), - width: 2, - ), - color: _backgroundColor(), - ), - duration: const Duration(milliseconds: 300), - child: checked - ? ArDriveIcon( - icon: ArDriveIconsData.checkmark, - size: 12, - color: _checkColor(), - ) - : null, - ), - if (_buildTitle() != null) ...[ - const SizedBox(width: 8.0), - _buildTitle()!, - ] - ], - ), + child: widget.useNewIcons + ? _buildNewIcons() + : ArDriveClickArea( + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + state == CheckBoxState.indeterminate + ? ArDriveIcon( + icon: ArDriveIconsData.minus_rectangle, + size: 22, + color: ArDriveTheme.of(context) + .themeData + .colors + .themeFgDefault, + ) + : AnimatedContainer( + height: 18.5, + width: 18.5, + margin: const EdgeInsets.fromLTRB(3.25, 3.5, 5, 4), + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(checkboxBorderRadius), + border: Border.all( + color: _boxColor(), + width: 2, + ), + color: _backgroundColor(), + ), + duration: const Duration(milliseconds: 300), + child: checked + ? ArDriveIcon( + icon: ArDriveIconsData.checkmark, + size: 12, + color: _checkColor(), + ) + : null, + ), + if (_buildTitle() != null) ...[ + const SizedBox(width: 8.0), + _buildTitle()!, + ] + ], + ), + ), + ); + } + + Widget _buildNewIcons() { + return ArDriveClickArea( + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + state == CheckBoxState.indeterminate + ? ArDriveIcon( + icon: ArDriveIconsData.minus_rectangle, + size: 22, + color: + ArDriveTheme.of(context).themeData.colors.themeFgDefault, + ) + : checked + ? ArDriveIcons.checked() + : ArDriveIcons.box(), + if (_buildTitle() != null) ...[ + const SizedBox(width: 8.0), + _buildTitle()!, + ] + ], ), ); } diff --git a/packages/ardrive_ui/lib/src/components/click_area.dart b/packages/ardrive_ui/lib/src/components/click_area.dart index 0e71e2ac4a..3c5c9ef696 100644 --- a/packages/ardrive_ui/lib/src/components/click_area.dart +++ b/packages/ardrive_ui/lib/src/components/click_area.dart @@ -1,3 +1,4 @@ +import 'package:ardrive_ui/ardrive_ui.dart'; import 'package:flutter/material.dart'; class ArDriveClickArea extends StatelessWidget { @@ -14,7 +15,7 @@ class ArDriveClickArea extends StatelessWidget { @override Widget build(BuildContext context) { - return Tooltip( + return ArDriveTooltip( message: tooltip ?? '', child: MouseRegion( cursor: diff --git a/packages/ardrive_ui/lib/src/components/modal.dart b/packages/ardrive_ui/lib/src/components/modal.dart index e16ad851f7..a323ab1230 100644 --- a/packages/ardrive_ui/lib/src/components/modal.dart +++ b/packages/ardrive_ui/lib/src/components/modal.dart @@ -61,7 +61,13 @@ class ArDriveModalNew extends StatelessWidget { SizedBox( height: 6, child: Container( - color: colorTokens.containerRed, + decoration: BoxDecoration( + color: colorTokens.containerRed, + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(modalBorderRadius), + topRight: Radius.circular(modalBorderRadius), + ), + ), ), ), Padding( diff --git a/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart b/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart index 03919c3646..8ff099fb30 100644 --- a/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart +++ b/packages/ardrive_ui/lib/src/styles/icons/ar_drive_icons_icons.dart @@ -13,9 +13,8 @@ /// /// /// -// ignore_for_file: constant_identifier_names - library; +// ignore_for_file: constant_identifier_names import 'package:flutter/widgets.dart'; @@ -181,6 +180,24 @@ class ArDriveIconsData { IconData(0xe84d, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData add_arns_name = IconData(0xe84e, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData license_1 = + IconData(0xe84f, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData pic = + IconData(0xe850, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData box = + IconData(0xe851, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData checked = + IconData(0xe853, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData advanced_chevron = + IconData(0xe854, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData chevron_up = + IconData(0xe855, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData chevron_down = + IconData(0xe856, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData arweave = + IconData(0xe858, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData turbo_coin = + IconData(0xe859, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData arrow_download = IconData(0xe880, fontFamily: _kFontFam, fontPackage: _kFontPkg); } diff --git a/packages/ardrive_ui/lib/src/styles/icons/icons.dart b/packages/ardrive_ui/lib/src/styles/icons/icons.dart index a3dafe11af..9fec9dfb2b 100644 --- a/packages/ardrive_ui/lib/src/styles/icons/icons.dart +++ b/packages/ardrive_ui/lib/src/styles/icons/icons.dart @@ -484,4 +484,52 @@ class ArDriveIcons { size: size, color: color, ); + + static ArDriveIcon turboCoin({double? size, Color? color}) => ArDriveIcon( + icon: ArDriveIconsData.turbo_coin, + size: size, + color: color, + ); + + static ArDriveIcon arweaveCoin({double? size, Color? color}) => ArDriveIcon( + icon: ArDriveIconsData.arweave, + size: size, + color: color, + ); + + static ArDriveIcon chevronDown({double? size, Color? color}) => ArDriveIcon( + icon: ArDriveIconsData.chevron_down, + size: size, + color: color, + ); + + static ArDriveIcon chevronUp({double? size, Color? color}) => ArDriveIcon( + icon: ArDriveIconsData.chevron_up, + size: size, + color: color, + ); + + static ArDriveIcon arrowDownload({double? size, Color? color}) => ArDriveIcon( + icon: ArDriveIconsData.arrow_download, + size: size, + color: color, + ); + + static ArDriveIcon box({double? size, Color? color}) => ArDriveIcon( + icon: ArDriveIconsData.box, + size: size, + color: color, + ); + + static ArDriveIcon checked({double? size, Color? color}) => ArDriveIcon( + icon: ArDriveIconsData.checked, + size: size, + color: color, + ); + + static ArDriveIcon license1({double? size, Color? color}) => ArDriveIcon( + icon: ArDriveIconsData.license_1, + size: size, + color: color, + ); } diff --git a/packages/ardrive_ui/test/src/components/check_box_test.dart b/packages/ardrive_ui/test/src/components/check_box_test.dart index 69548cbfbe..1e4d17fe61 100644 --- a/packages/ardrive_ui/test/src/components/check_box_test.dart +++ b/packages/ardrive_ui/test/src/components/check_box_test.dart @@ -115,6 +115,7 @@ void main() { const checkbox = ArDriveCheckBox( title: 'Title', key: Key('checkbox'), + useNewIcons: false, ); await tester.pumpWidget( @@ -154,6 +155,7 @@ void main() { title: 'Title', key: Key('checkbox'), isDisabled: true, + useNewIcons: false, ); await tester.pumpWidget( diff --git a/test/blocs/upload_cubit_test.dart b/test/blocs/upload_cubit_test.dart index 6f91b841c9..34a8fb2191 100644 --- a/test/blocs/upload_cubit_test.dart +++ b/test/blocs/upload_cubit_test.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'dart:typed_data'; +import 'package:ardrive/arns/domain/arns_repository.dart'; import 'package:ardrive/authentication/ardrive_auth.dart'; import 'package:ardrive/blocs/profile/profile_cubit.dart'; import 'package:ardrive/blocs/upload/models/upload_file.dart'; @@ -30,7 +31,6 @@ import 'package:mocktail/mocktail.dart'; import 'package:pst/pst.dart'; import '../core/upload/uploader_test.dart'; -import '../manifest/domain/manifest_repository_test.dart'; import '../test_utils/utils.dart'; import 'drives_cubit_test.dart'; @@ -57,6 +57,8 @@ class MockUploadRepository extends Mock implements UploadRepository {} class MockArDriveUploadPreparationManager extends Mock implements ArDriveUploadPreparationManager {} +class MockArnsRepository extends Mock implements ARNSRepository {} + // TODO(thiagocarvalhodev): Test the case of remove files before download when pass ConflictingFileActions.SKIP. // TODO: Test startUpload void main() { @@ -350,12 +352,13 @@ void main() { 'should found the conflicting files correctly and set isAllFilesConflicting to true' ' when all files are conflicting', build: () { + when(() => mockArDriveAuth.getWalletAddress()) + .thenAnswer((invocation) => Future.value(tWalletAddress)); + when(() => mockArnsRepository.getAntRecordsForWallet(tWalletAddress!)) + .thenAnswer((invocation) => Future.value([])); return getUploadCubitInstanceWith(tAllConflictingFiles); }, act: (cubit) async { - when(() => mockArnsRepository.getAntRecordsForWallet(any(), - update: any(named: 'update'))) - .thenAnswer((invocation) => Future.value([])); await cubit.startUploadPreparation(); await cubit.checkConflictingFiles(); },