Skip to content

Commit

Permalink
Merge pull request #1798 from ardriveapp/PE-6399-account-menu-updates
Browse files Browse the repository at this point in the history
PE-6399: account menu updates
  • Loading branch information
thiagocarvalhodev authored Aug 6, 2024
2 parents ef9406b + a6f9269 commit d2f3369
Show file tree
Hide file tree
Showing 51 changed files with 730 additions and 781 deletions.
4 changes: 4 additions & 0 deletions android/fastlane/metadata/android/en-US/changelogs/143.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Revamped account menu with additional customization options
- Added option to enable/disable automatic sync
- Introduced setting to enable/disable sync from snapshots
- New feature to enable/disable upload with thumbnails
10 changes: 2 additions & 8 deletions assets/config/dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
"defaultTurboUploadUrl": "https://upload.ardrive.dev",
"defaultTurboPaymentUrl": "https://payment.ardrive.dev",
"allowedDataItemSizeForTurbo": 100000,
"enableQuickSyncAuthoring": true,
"enableMultipleFileDownload": true,
"enableVideoPreview": true,
"enableAudioPreview": true,
"stripePublishableKey": "pk_test_51JUAtwC8apPOWkDLh2FPZkQkiKZEkTo6wqgLCtQoClL6S4l2jlbbc5MgOdwOUdU9Tn93NNvqAGbu115lkJChMikG00XUfTmo2z",
"enablePins": true,
"useNewUploader": true,
"enableMetamaskLogin": true,
"enableSearch": true
"uploadThumbnails": true,
"autoSync": false
}
10 changes: 2 additions & 8 deletions assets/config/prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
"defaultTurboUploadUrl": "https://upload.ardrive.io",
"defaultTurboPaymentUrl": "https://payment.ardrive.io",
"allowedDataItemSizeForTurbo": 100000,
"enableQuickSyncAuthoring": true,
"enableMultipleFileDownload": true,
"enableVideoPreview": true,
"enableAudioPreview": true,
"stripePublishableKey": "pk_live_51JUAtwC8apPOWkDLMQqNF9sPpfneNSPnwX8YZ8y1FNDl6v94hZIwzgFSYl27bWE4Oos8CLquunUswKrKcaDhDO6m002Yj9AeKj",
"enablePins": true,
"useNewUploader": true,
"enableMetamaskLogin": true,
"enableSearch": true
"uploadThumbnails": true,
"autoSync": false
}
10 changes: 2 additions & 8 deletions assets/config/staging.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
"defaultTurboUploadUrl": "https://upload.ardrive.io",
"defaultTurboPaymentUrl": "https://payment.ardrive.io",
"allowedDataItemSizeForTurbo": 100000,
"enableQuickSyncAuthoring": true,
"enableMultipleFileDownload": true,
"enableVideoPreview": true,
"enableAudioPreview": true,
"stripePublishableKey": "pk_live_51JUAtwC8apPOWkDLMQqNF9sPpfneNSPnwX8YZ8y1FNDl6v94hZIwzgFSYl27bWE4Oos8CLquunUswKrKcaDhDO6m002Yj9AeKj",
"enablePins": true,
"useNewUploader": true,
"enableMetamaskLogin": true,
"enableSearch": true
"uploadThumbnails": true,
"autoSync": false
}
3 changes: 1 addition & 2 deletions lib/app_shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:ardrive/blocs/prompt_to_snapshot/prompt_to_snapshot_event.dart';
import 'package:ardrive/components/profile_card.dart';
import 'package:ardrive/components/side_bar.dart';
import 'package:ardrive/drive_explorer/multi_thumbnail_creation/multi_thumbnail_creation_warn_modal.dart';
import 'package:ardrive/gift/reedem_button.dart';
import 'package:ardrive/misc/misc.dart';
import 'package:ardrive/pages/drive_detail/components/hover_widget.dart';
import 'package:ardrive/shared/blocs/banner/app_banner_bloc.dart';
Expand Down Expand Up @@ -362,7 +361,7 @@ class MobileAppBar extends StatelessWidget implements PreferredSizeWidget {
width: 24,
),
if (AppPlatform.isMobileWeb()) ...[
const RedeemButton(),
const HelpButton(),
const SizedBox(
width: 24,
),
Expand Down
8 changes: 1 addition & 7 deletions lib/authentication/login/blocs/login_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:ardrive/entities/profile_types.dart';
import 'package:ardrive/services/arconnect/arconnect.dart';
import 'package:ardrive/services/arconnect/arconnect_wallet.dart';
import 'package:ardrive/services/arweave/arweave_service.dart';
import 'package:ardrive/services/config/config_service.dart';
import 'package:ardrive/services/ethereum/ethereum_wallet.dart';
import 'package:ardrive/services/ethereum/provider/ethereum_provider.dart';
import 'package:ardrive/services/ethereum/provider/ethereum_provider_wallet.dart';
Expand Down Expand Up @@ -40,7 +39,6 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
final TurboUploadService _turboUploadService;
final ArweaveService _arweaveService;
final DownloadService _downloadService;
final ConfigService _configService;
final ProfileCubit _profileCubit;

bool ignoreNextWaletSwitch = false;
Expand All @@ -62,15 +60,13 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
required ArweaveService arweaveService,
required DownloadService downloadService,
required UserRepository userRepository,
required ConfigService configService,
required ProfileCubit profileCubit,
}) : _arDriveAuth = arDriveAuth,
_arConnectService = arConnectService,
_ethereumProviderService = ethereumProviderService,
_arweaveService = arweaveService,
_turboUploadService = turboUploadService,
_downloadService = downloadService,
_configService = configService,
_profileCubit = profileCubit,
super(LoginLoading()) {
on<LoginEvent>(_onLoginEvent);
Expand All @@ -79,9 +75,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {

get isArConnectAvailable => _arConnectService.isExtensionPresent();

get isMetamaskAvailable =>
_configService.config.enableMetamaskLogin &&
_ethereumProviderService.isExtensionPresent();
get isMetamaskAvailable => _ethereumProviderService.isExtensionPresent();

Future<void> _onLoginEvent(LoginEvent event, Emitter<LoginState> emit) async {
if (event is SelectLoginFlow) {
Expand Down
2 changes: 0 additions & 2 deletions lib/authentication/login/views/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import 'package:ardrive/services/arconnect/arconnect.dart';
import 'package:ardrive/services/arweave/arweave_service.dart';
import 'package:ardrive/services/authentication/biometric_authentication.dart';
import 'package:ardrive/services/authentication/biometric_permission_dialog.dart';
import 'package:ardrive/services/config/config_service.dart';
import 'package:ardrive/services/ethereum/provider/ethereum_provider.dart';
import 'package:ardrive/turbo/services/upload_service.dart';
import 'package:ardrive/user/repositories/user_repository.dart';
Expand Down Expand Up @@ -71,7 +70,6 @@ class _LoginPageState extends State<LoginPage> {
downloadService: downloadService,
arDriveAuth: context.read<ArDriveAuth>(),
userRepository: context.read<UserRepository>(),
configService: context.read<ConfigService>(),
profileCubit: context.read<ProfileCubit>(),
)..add(
CheckIfUserIsLoggedIn(
Expand Down
23 changes: 9 additions & 14 deletions lib/blocs/create_snapshot/create_snapshot_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -425,16 +425,14 @@ class CreateSnapshotCubit extends Cubit<CreateSnapshotState> {
final profileState = _profileCubit.state as ProfileLoggedIn;
final wallet = profileState.wallet;

final BigInt? fakeTurboCredits = appConfig.fakeTurboCredits;

/// necessary to wait for backend update the balance
await Future.delayed(const Duration(seconds: 2));

final BigInt turboBalance = fakeTurboCredits ??
final BigInt turboBalance =
await turboBalanceRetriever.getBalance(wallet).catchError((e) {
logger.e('Error while retrieving turbo balance', e);
return BigInt.zero;
});
logger.e('Error while retrieving turbo balance', e);
return BigInt.zero;
});

logger.d('Balance after topping up: $turboBalance');

Expand Down Expand Up @@ -472,13 +470,11 @@ class CreateSnapshotCubit extends Cubit<CreateSnapshotState> {
final ProfileLoggedIn profileState = _profileCubit.state as ProfileLoggedIn;
final Wallet wallet = profileState.wallet;

final BigInt? fakeTurboCredits = appConfig.fakeTurboCredits;

final BigInt turboBalance = fakeTurboCredits ??
final BigInt turboBalance =
await turboBalanceRetriever.getBalance(wallet).catchError((e) {
logger.e('Error while retrieving turbo balance', e);
return BigInt.zero;
});
logger.e('Error while retrieving turbo balance', e);
return BigInt.zero;
});

logger.d('Balance before topping up: $turboBalance');

Expand Down Expand Up @@ -507,10 +503,9 @@ class CreateSnapshotCubit extends Cubit<CreateSnapshotState> {

void _computeIsFreeThanksToTurbo() {
final allowedDataItemSizeForTurbo = appConfig.allowedDataItemSizeForTurbo;
final forceNoFreeThanksToTurbo = appConfig.forceNoFreeThanksToTurbo;
final isFreeThanksToTurbo =
_snapshotEntity!.data!.length <= allowedDataItemSizeForTurbo;
_isFreeThanksToTurbo = isFreeThanksToTurbo && !forceNoFreeThanksToTurbo;
_isFreeThanksToTurbo = isFreeThanksToTurbo;
}

void setUploadMethod(UploadMethod method) {
Expand Down
32 changes: 12 additions & 20 deletions lib/blocs/fs_entry_preview/fs_entry_preview_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -330,36 +330,28 @@ class FsEntryPreviewCubit extends Cubit<FsEntryPreviewState> {

void _previewAudio(
bool isPrivate, FileDataTableItem selectedItem, previewUrl) {
if (_configService.config.enableAudioPreview) {
if (isPrivate) {
emit(FsEntryPreviewUnavailable());
return;
}

emit(FsEntryPreviewAudio(
filename: selectedItem.name, previewUrl: previewUrl));

if (isPrivate) {
emit(FsEntryPreviewUnavailable());
return;
}

emit(FsEntryPreviewUnavailable());
emit(FsEntryPreviewAudio(
filename: selectedItem.name, previewUrl: previewUrl));

return;
}

void _previewVideo(
bool isPrivate, FileDataTableItem selectedItem, previewUrl) {
if (_configService.config.enableVideoPreview) {
if (isPrivate) {
emit(FsEntryPreviewUnavailable());
return;
}

emit(FsEntryPreviewVideo(
filename: selectedItem.name, previewUrl: previewUrl));

if (isPrivate) {
emit(FsEntryPreviewUnavailable());
return;
}

emit(FsEntryPreviewUnavailable());
emit(FsEntryPreviewVideo(
filename: selectedItem.name, previewUrl: previewUrl));

return;
}

Future<Uint8List?> _getBytesFromCache({
Expand Down
17 changes: 11 additions & 6 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import 'package:ardrive/core/activity_tracker.dart';
import 'package:ardrive/core/upload/uploader.dart';
import 'package:ardrive/entities/file_entity.dart';
import 'package:ardrive/entities/folder_entity.dart';
import 'package:ardrive/main.dart';
import 'package:ardrive/models/forms/cc.dart';
import 'package:ardrive/models/forms/udl.dart';
import 'package:ardrive/models/models.dart';
import 'package:ardrive/services/config/config.dart';
import 'package:ardrive/services/config/config_service.dart';
import 'package:ardrive/services/license/license.dart';
import 'package:ardrive/turbo/services/upload_service.dart';
import 'package:ardrive/utils/logger.dart';
Expand Down Expand Up @@ -49,12 +50,13 @@ class UploadCubit extends Cubit<UploadState> {
final ArDriveAuth _auth;
final ActivityTracker _activityTracker;
final LicenseService _licenseService;
final ConfigService _configService;

late bool uploadFolders;
late Drive _targetDrive;
late FolderEntry _targetFolder;
UploadMethod? _uploadMethod;
bool _uploadThumbnail = true;
bool _uploadThumbnail;

void changeUploadThumbnailOption(bool uploadThumbnail) {
_uploadThumbnail = uploadThumbnail;
Expand Down Expand Up @@ -204,6 +206,7 @@ class UploadCubit extends Cubit<UploadState> {
required ArDriveUploadPreparationManager arDriveUploadManager,
required ActivityTracker activityTracker,
required LicenseService licenseService,
required ConfigService configService,
this.folder,
this.uploadFolders = false,
this.isDragNDrop = false,
Expand All @@ -214,6 +217,8 @@ class UploadCubit extends Cubit<UploadState> {
_auth = auth,
_activityTracker = activityTracker,
_licenseService = licenseService,
_configService = configService,
_uploadThumbnail = configService.config.uploadThumbnails,
super(UploadPreparationInProgress());

Future<void> startUploadPreparation({
Expand Down Expand Up @@ -533,14 +538,14 @@ class UploadCubit extends Cubit<UploadState> {
LicenseState? licenseStateConfigured,
}) async {
final ardriveUploader = ArDriveUploader(
turboUploadUri: Uri.parse(configService.config.defaultTurboUploadUrl!),
turboUploadUri: Uri.parse(_configService.config.defaultTurboUploadUrl!),
metadataGenerator: ARFSUploadMetadataGenerator(
tagsGenerator: ARFSTagsGenetator(
appInfoServices: AppInfoServices(),
),
),
arweave: Arweave(
gatewayUrl: Uri.parse(configService.config.defaultArweaveGatewayUrl!),
gatewayUrl: Uri.parse(_configService.config.defaultArweaveGatewayUrl!),
),
pstService: _pst,
);
Expand Down Expand Up @@ -666,14 +671,14 @@ class UploadCubit extends Cubit<UploadState> {
LicenseState? licenseStateConfigured,
}) async {
final ardriveUploader = ArDriveUploader(
turboUploadUri: Uri.parse(configService.config.defaultTurboUploadUrl!),
turboUploadUri: Uri.parse(_configService.config.defaultTurboUploadUrl!),
metadataGenerator: ARFSUploadMetadataGenerator(
tagsGenerator: ARFSTagsGenetator(
appInfoServices: AppInfoServices(),
),
),
arweave: Arweave(
gatewayUrl: Uri.parse(configService.config.defaultArweaveGatewayUrl!),
gatewayUrl: Uri.parse(_configService.config.defaultArweaveGatewayUrl!),
),
pstService: _pst,
);
Expand Down
38 changes: 17 additions & 21 deletions lib/components/app_top_bar.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import 'package:ardrive/blocs/drive_detail/drive_detail_cubit.dart';
import 'package:ardrive/components/profile_card.dart';
import 'package:ardrive/gift/reedem_button.dart';
import 'package:ardrive/components/topbar/help_button.dart';
import 'package:ardrive/pages/drive_detail/components/dropdown_item.dart';
import 'package:ardrive/pages/drive_detail/components/hover_widget.dart';
import 'package:ardrive/search/search_modal.dart';
import 'package:ardrive/search/search_text_field.dart';
import 'package:ardrive/services/config/config.dart';
import 'package:ardrive/sync/domain/cubit/sync_cubit.dart';
import 'package:ardrive/utils/app_localizations_wrapper.dart';
import 'package:ardrive/utils/plausible_event_tracker/plausible_custom_event_properties.dart';
Expand All @@ -19,7 +18,6 @@ class AppTopBar extends StatelessWidget {

@override
Widget build(BuildContext context) {
final enableSearch = context.read<ConfigService>().config.enableSearch;
final controller = TextEditingController();

return SizedBox(
Expand All @@ -31,28 +29,26 @@ class AppTopBar extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (enableSearch) ...[
Expanded(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 400),
child: SearchTextField(
controller: controller,
onFieldSubmitted: (query) {
showSearchModalDesktop(
context: context,
driveDetailCubit: context.read<DriveDetailCubit>(),
controller: controller,
);
},
),
Expanded(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 400),
child: SearchTextField(
controller: controller,
onFieldSubmitted: (query) {
showSearchModalDesktop(
context: context,
driveDetailCubit: context.read<DriveDetailCubit>(),
controller: controller,
);
},
),
),
const SizedBox(width: 24),
],
),
const SizedBox(width: 24),
const Spacer(),
const SyncButton(),
const SizedBox(width: 24),
const RedeemButton(),
const SizedBox(width: 8),
const HelpButtonTopBar(),
const SizedBox(width: 24),
const ProfileCard(),
],
Expand Down
Loading

0 comments on commit d2f3369

Please sign in to comment.