Skip to content

Commit

Permalink
Merge pull request #1525 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-5239: Release v2.28.0
  • Loading branch information
thiagocarvalhodev authored Dec 15, 2023
2 parents 158d137 + 7776c0e commit eac1ef0
Show file tree
Hide file tree
Showing 33 changed files with 1,163 additions and 206 deletions.
3 changes: 3 additions & 0 deletions android/fastlane/metadata/android/en-US/changelogs/84.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Adds browser limit info to Top Up modal
- Removes unneeded upload warning
- Enables sending and redeeming gifted Credits
8 changes: 8 additions & 0 deletions lib/app_shell.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:ardrive/components/profile_card.dart';
import 'package:ardrive/components/side_bar.dart';
import 'package:ardrive/gift/reedem_button.dart';
import 'package:ardrive/pages/drive_detail/components/hover_widget.dart';
import 'package:ardrive/utils/logger/logger.dart';
import 'package:ardrive/utils/size_constants.dart';
Expand Down Expand Up @@ -179,6 +180,7 @@ class AppShellState extends State<AppShell> {
setState(() => _showProfileOverlay = !_showProfileOverlay);
}

// TODO: add the gift icon
class MobileAppBar extends StatelessWidget implements PreferredSizeWidget {
const MobileAppBar({
super.key,
Expand Down Expand Up @@ -223,6 +225,12 @@ class MobileAppBar extends StatelessWidget implements PreferredSizeWidget {
const SizedBox(
width: 24,
),
if (AppPlatform.isMobileWeb()) ...[
const RedeemButton(),
const SizedBox(
width: 24,
),
],
const Padding(
padding: EdgeInsets.only(right: 12.0),
child: ProfileCard(),
Expand Down
2 changes: 2 additions & 0 deletions lib/blocs/pin_file/pin_file_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,10 @@ class PinFileBloc extends Bloc<PinFileEvent, PinFileState> {
}

IdValidationResult validateId(String value) {
// TODO: Replace this with isValidUuidFormat from `ardrive_utils`
const kFileIdRegex =
r'^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$';
// TODO: Implement this method on `ardrive_utils`
const kTransactionIdRegex = r'^[\w-+]{43}$';

final fileIdRegex = RegExp(kFileIdRegex);
Expand Down
4 changes: 0 additions & 4 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ class UploadCubit extends Cubit<UploadState> {
progress: progress,
controller: uploadController,
uploadMethod: _uploadMethod!,
containsLargeTurboUpload: _containsLargeTurboUpload!,
),
);
},
Expand Down Expand Up @@ -674,7 +673,6 @@ class UploadCubit extends Cubit<UploadState> {
controller: uploadController,
equatableBust: UniqueKey(),
uploadMethod: _uploadMethod!,
containsLargeTurboUpload: _containsLargeTurboUpload!,
),
);
},
Expand Down Expand Up @@ -882,7 +880,6 @@ class UploadCubit extends Cubit<UploadState> {
totalProgress: state.totalProgress,
isCanceling: true,
uploadMethod: _uploadMethod!,
containsLargeTurboUpload: state.containsLargeTurboUpload,
),
);

Expand All @@ -896,7 +893,6 @@ class UploadCubit extends Cubit<UploadState> {
totalProgress: state.totalProgress,
isCanceling: false,
uploadMethod: _uploadMethod!,
containsLargeTurboUpload: state.containsLargeTurboUpload,
),
);

Expand Down
2 changes: 0 additions & 2 deletions lib/blocs/upload/upload_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ class UploadInProgressUsingNewUploader extends UploadState {
final bool isCanceling;
final Key? equatableBust;
final UploadMethod uploadMethod;
final bool containsLargeTurboUpload;

UploadInProgressUsingNewUploader({
required this.progress,
Expand All @@ -223,7 +222,6 @@ class UploadInProgressUsingNewUploader extends UploadState {
this.equatableBust,
this.isCanceling = false,
required this.uploadMethod,
required this.containsLargeTurboUpload,
});

@override
Expand Down
3 changes: 3 additions & 0 deletions lib/components/app_top_bar.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// implement a widget that has 145 of height and maximum widget, and has a row as child
import 'package:ardrive/blocs/sync/sync_cubit.dart';
import 'package:ardrive/components/profile_card.dart';
import 'package:ardrive/gift/reedem_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/utils/app_localizations_wrapper.dart';
Expand All @@ -23,6 +24,8 @@ class AppTopBar extends StatelessWidget {
children: [
SyncButton(),
SizedBox(width: 24),
RedeemButton(),
SizedBox(width: 24),
ProfileCard(),
],
),
Expand Down
30 changes: 30 additions & 0 deletions lib/components/top_up_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:ardrive/turbo/utils/utils.dart';
import 'package:ardrive/utils/app_localizations_wrapper.dart';
import 'package:ardrive/utils/file_size_units.dart';
import 'package:ardrive/utils/open_url.dart';
import 'package:ardrive/utils/split_localizations.dart';
import 'package:ardrive_ui/ardrive_ui.dart';
import 'package:arweave/arweave.dart';
import 'package:flutter/gestures.dart';
Expand Down Expand Up @@ -386,6 +387,31 @@ class _PresetAmountSelectorState extends State<PresetAmountSelector> {
),
),
);
final textStyle = ArDriveTypography.body.buttonNormalRegular(
color: ArDriveTheme.of(context).themeData.colors.themeFgDefault,
);
final appLimitsWarning = splitTranslationsWithMultipleStyles(
originalText: appLocalizationsOf(context).turboModalBrowserLimit,
defaultMapper: (text) => TextSpan(
text: text,
style: ArDriveTypography.body.buttonNormalBold(
color: ArDriveTheme.of(context).themeData.colors.themeFgMuted,
),
),
parts: {
appLocalizationsOf(context).turboModalBrowserLimit_link: (text) =>
TextSpan(
text: text,
style: textStyle.copyWith(
decoration: TextDecoration.underline,
),
recognizer: TapGestureRecognizer()
..onTap = () => openUrl(
url: Resources.ardriveAppLimits,
),
)
},
);

return ArDriveForm(
key: _formKey,
Expand All @@ -405,6 +431,10 @@ class _PresetAmountSelectorState extends State<PresetAmountSelector> {
color: ArDriveTheme.of(context).themeData.colors.themeFgMuted,
),
),
const SizedBox(height: 8),
RichText(
text: TextSpan(children: appLimitsWarning),
),
const SizedBox(height: 32),
Text(
appLocalizationsOf(context).amount,
Expand Down
29 changes: 0 additions & 29 deletions lib/components/upload_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1136,35 +1136,6 @@ class _UploadFormState extends State<UploadForm> {
color:
ArDriveTheme.of(context).themeData.colors.themeFgDefault),
),

if (state.containsLargeTurboUpload) ...[
const SizedBox(
height: 8,
),
Align(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'Warning!',
style: ArDriveTypography.body
.buttonLargeBold(
color: ArDriveTheme.of(context)
.themeData
.colors
.themeErrorMuted,
)
.copyWith(
fontWeight: FontWeight.bold,
),
),
Text('Leaving this page may result in a failed upload',
style: ArDriveTypography.body.buttonLargeBold())
],
),
),
],
],
),
);
Expand Down
53 changes: 53 additions & 0 deletions lib/gift/bloc/redeem_gift_bloc.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:ardrive/authentication/ardrive_auth.dart';
import 'package:ardrive/turbo/services/payment_service.dart';
import 'package:ardrive/utils/logger/logger.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

part 'redeem_gift_event.dart';
part 'redeem_gift_state.dart';

class RedeemGiftBloc extends Bloc<RedeemGiftEvent, RedeemGiftState> {
final PaymentService _paymentService;
final ArDriveAuth _auth;

RedeemGiftBloc({
required PaymentService paymentService,
required ArDriveAuth auth,
}) : _auth = auth,
_paymentService = paymentService,
super(RedeemGiftInitial()) {
on<RedeemGiftEvent>((event, emit) async {
if (event is RedeemGiftLoad) {
await _handleRedeemGiftLoad(emit, event);
}
});
}

Future<void> _handleRedeemGiftLoad(
Emitter<RedeemGiftState> emit, RedeemGiftLoad event) async {
try {
logger.d('RedeemGiftLoad');

emit(RedeemGiftLoading());

await _paymentService.redeemGift(
email: event.email,
giftCode: event.giftCode,
destinationAddress: _auth.currentUser.walletAddress,
);

logger.d('RedeemGiftSuccess');

emit(RedeemGiftSuccess());
} catch (e) {
if (e is GiftAlreadyRedeemed) {
logger.e('RedeemGiftAlreadyRedeemed', e);
emit(RedeemGiftAlreadyRedeemed());
return;
}
logger.e('RedeemGiftFailure', e);
emit(RedeemGiftFailure());
}
}
}
21 changes: 21 additions & 0 deletions lib/gift/bloc/redeem_gift_event.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
part of 'redeem_gift_bloc.dart';

sealed class RedeemGiftEvent extends Equatable {
const RedeemGiftEvent();

@override
List<Object> get props => [];
}

class RedeemGiftLoad extends RedeemGiftEvent {
const RedeemGiftLoad({
required this.giftCode,
required this.email,
});

final String giftCode;
final String email;

@override
List<Object> get props => [giftCode];
}
18 changes: 18 additions & 0 deletions lib/gift/bloc/redeem_gift_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
part of 'redeem_gift_bloc.dart';

sealed class RedeemGiftState extends Equatable {
const RedeemGiftState();

@override
List<Object> get props => [];
}

final class RedeemGiftInitial extends RedeemGiftState {}

final class RedeemGiftLoading extends RedeemGiftState {}

final class RedeemGiftSuccess extends RedeemGiftState {}

final class RedeemGiftFailure extends RedeemGiftState {}

final class RedeemGiftAlreadyRedeemed extends RedeemGiftState {}
Loading

0 comments on commit eac1ef0

Please sign in to comment.