Skip to content

Commit

Permalink
Merge pull request #1833 from ardriveapp/PE-6654-new-upload-UI
Browse files Browse the repository at this point in the history
PE-6708: new upload UI
  • Loading branch information
thiagocarvalhodev authored Sep 11, 2024
2 parents 7825292 + ff0dba9 commit 58f3378
Show file tree
Hide file tree
Showing 8 changed files with 444 additions and 366 deletions.
16 changes: 11 additions & 5 deletions lib/arns/presentation/assign_name_modal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ class __NameSelectorDropdownState<T> extends State<_NameSelectorDropdown<T>> {
final colorTokens = ArDriveTheme.of(context).themeData.colorTokens;

double maxHeight;

double maxWidth = 500;
if (48 * widget.names.length.toDouble() > 240) {
maxHeight = 240;
} else if (widget.names.isEmpty) {
Expand All @@ -399,6 +399,10 @@ class __NameSelectorDropdownState<T> extends State<_NameSelectorDropdown<T>> {
maxHeight = 48 * widget.names.length.toDouble();
}

if (maxWidth >= MediaQuery.of(context).size.width) {
maxWidth = MediaQuery.of(context).size.width - 32;
}

return ArDriveDropdown(
hasBorder: false,
hasDivider: false,
Expand All @@ -409,7 +413,7 @@ class __NameSelectorDropdownState<T> extends State<_NameSelectorDropdown<T>> {
),
showScrollbars: true,
maxHeight: maxHeight,
items: _buildList(widget.names),
items: _buildList(widget.names, maxWidth),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down Expand Up @@ -439,7 +443,7 @@ class __NameSelectorDropdownState<T> extends State<_NameSelectorDropdown<T>> {
),
],
),
width: 500,
width: maxWidth,
height: 56,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
Expand Down Expand Up @@ -480,7 +484,7 @@ class __NameSelectorDropdownState<T> extends State<_NameSelectorDropdown<T>> {
return name;
}

List<ArDriveDropdownItem> _buildList(List<T> items) {
List<ArDriveDropdownItem> _buildList(List<T> items, double maxWidth) {
List<ArDriveDropdownItem> list = [];

for (var item in items) {
Expand All @@ -494,13 +498,15 @@ class __NameSelectorDropdownState<T> extends State<_NameSelectorDropdown<T>> {
},
content: Container(
alignment: Alignment.centerLeft,
width: 500,
width: maxWidth,
height: 48,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
_getName(item),
style: ArDriveTypographyNew.of(context).paragraphLarge(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
Expand Down
45 changes: 32 additions & 13 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ class UploadCubit extends Cubit<UploadState> {
showArnsNameSelectionCheckBoxValue = showArnsNameSelection;
}

void showArnsNameSelection() {
emit((state as UploadReady).copyWith(showArnsNameSelection: true));
void showArnsNameSelection(UploadReady readyState) {
emit(readyState.copyWith(showArnsNameSelection: true));
}

void hideArnsNameSelection() {
emit((state as UploadReady).copyWith(showArnsNameSelection: false));
void hideArnsNameSelection(UploadReady readyState) {
emit(readyState.copyWith(showArnsNameSelection: false));
}

void setUploadMethod(
Expand Down Expand Up @@ -118,7 +118,8 @@ class UploadCubit extends Cubit<UploadState> {
isDragNDrop: isDragNDrop,
isNextButtonEnabled: canUpload,
isArConnect: (state as UploadReadyToPrepare).isArConnect,
showArnsCheckbox: hasUndernames && files.length == 1,
showArnsCheckbox:
hasUndernames && files.length == 1 && _targetDrive.isPublic,
showArnsNameSelection: false,
),
);
Expand All @@ -128,7 +129,7 @@ class UploadCubit extends Cubit<UploadState> {
void initialScreenUpload() {
if (state is UploadReady) {
if (showArnsNameSelectionCheckBoxValue) {
showArnsNameSelection();
showArnsNameSelection(state as UploadReady);
} else {
final readyState = state as UploadReady;
startUpload(
Expand Down Expand Up @@ -201,6 +202,13 @@ class UploadCubit extends Cubit<UploadState> {
licenseCategory: licenseCategory,
);
emit(prevState);
} else if (state is UploadReviewWithArnsName) {
final reviewWithArnsName = state as UploadReviewWithArnsName;
final readyState = reviewWithArnsName.readyState.copyWith(
showArnsNameSelection: false,
);

emit(readyState);
}
}

Expand All @@ -214,6 +222,8 @@ class UploadCubit extends Cubit<UploadState> {
reviewWithLicense.readyState.paymentInfo.uploadPlanForTurbo,
licenseStateConfigured: reviewWithLicense.licenseState,
);
} else if (state is UploadReviewWithArnsName) {
startUploadWithArnsName();
}
}

Expand Down Expand Up @@ -575,15 +585,23 @@ class UploadCubit extends Cubit<UploadState> {

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

final readyState = state as UploadReady;
final readyState = (state as UploadReady).copyWith(
params: (state as UploadReady).params.copyWith(
arnsUnderName: getSelectedUndername(),
),
);

emit(readyState.copyWith(
showArnsNameSelection: false,
));
emit(UploadReviewWithArnsName(readyState: readyState));
}

void startUploadWithArnsName() {
final reviewWithArnsName = state as UploadReviewWithArnsName;

startUpload(
uploadPlanForAr: readyState.paymentInfo.uploadPlanForAR!,
uploadPlanForTurbo: readyState.paymentInfo.uploadPlanForTurbo,
uploadPlanForAr:
reviewWithArnsName.readyState.paymentInfo.uploadPlanForAR!,
uploadPlanForTurbo:
reviewWithArnsName.readyState.paymentInfo.uploadPlanForTurbo,
);
}

Expand Down Expand Up @@ -927,13 +945,14 @@ class UploadCubit extends Cubit<UploadState> {
(tasks) async {
if (tasks.length == 1) {
final task = tasks.first;
if (task is FileUploadTask) {
if (task is FileUploadTask && task.status != UploadStatus.canceled) {
final metadata = task.metadata;
if (_selectedAntRecord != null || _selectedUndername != null) {
final updatedTask = task.copyWith(
status: UploadStatus.assigningUndername,
);

/// Emits
emit(
UploadInProgressUsingNewUploader(
progress: UploadProgress(
Expand Down
6 changes: 6 additions & 0 deletions lib/blocs/upload/upload_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ class UploadConfiguringLicense extends UploadState {
'UploadConfiguringLicense { paymentInfo: ${readyState.paymentInfo} }';
}

class UploadReviewWithArnsName extends UploadState {
final UploadReady readyState;

UploadReviewWithArnsName({required this.readyState});
}

/// [UploadReviewWithLicense] means that the upload + license is being reviewed by the user and awaiting confirmation to begin upload.
class UploadReviewWithLicense extends UploadState {
final UploadReady readyState;
Expand Down
Loading

0 comments on commit 58f3378

Please sign in to comment.