Skip to content

Commit

Permalink
Merge pull request #2053 from bitmark-inc/2885/fix-issues-and-feedbac…
Browse files Browse the repository at this point in the history
…ks-round-3

2885/fix issues and feedbacks round 3
  • Loading branch information
hoangbtmrk authored Sep 11, 2024
2 parents dab6183 + ed0ea53 commit 32a9c70
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 90 deletions.
2 changes: 1 addition & 1 deletion assets
2 changes: 1 addition & 1 deletion lib/screen/home/home_navigation_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class HomeNavigationPageState extends State<HomeNavigationPage>
},
),
OptionItem(
title: 'addresses'.tr(),
title: 'wallet'.tr(),
icon: const Icon(
AuIcon.wallet,
),
Expand Down
2 changes: 2 additions & 0 deletions lib/screen/moma_postcard_page/moma_postcard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import 'dart:async';

import 'package:autonomy_flutter/common/environment.dart';
import 'package:autonomy_flutter/common/injector.dart';
import 'package:autonomy_flutter/screen/app_router.dart';
import 'package:autonomy_flutter/screen/detail/artwork_detail_page.dart';
Expand Down Expand Up @@ -50,6 +51,7 @@ class _MoMAPostcardPageState extends State<MoMAPostcardPage> {
nftBloc.add(
GetTokensByOwnerEvent(
pageKey: nextKey,
contractAddress: Environment.postcardContractAddress,
),
);
}
Expand Down
10 changes: 6 additions & 4 deletions lib/screen/new_onboarding_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,9 @@ class _NewOnboardingPageState extends State<NewOnboardingPage> {
price: _getEssentialPrice(subscriptionDetails),
isProcessing: _selectedMembershipCardType ==
MembershipCardType.essential &&
subscriptionDetails?.status ==
IAPProductStatus.pending,
(subscriptionDetails?.status ==
IAPProductStatus.pending ||
subscriptionState.isProcessing),
isEnable: true,
onTap: (type) {
_selectMembershipType(type);
Expand All @@ -221,8 +222,9 @@ class _NewOnboardingPageState extends State<NewOnboardingPage> {
price: _getPremiumPrice(subscriptionDetails),
isProcessing: _selectedMembershipCardType ==
MembershipCardType.premium &&
subscriptionDetails?.status ==
IAPProductStatus.pending,
(subscriptionDetails?.status ==
IAPProductStatus.pending ||
subscriptionState.isProcessing),
isEnable: true,
onTap: (type) async {
_selectMembershipType(type);
Expand Down
9 changes: 3 additions & 6 deletions lib/screen/settings/forget_exist/forget_exist_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,9 @@ class ForgetExistBloc extends AuBloc<ForgetExistEvent, ForgetExistState> {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String? deviceId = await MigrationUtil.getBackupDeviceID();
final requester = '${deviceId}_${packageInfo.packageName}';
try {
await _iapApi.deleteAllProfiles(requester);
await _iapApi.deleteUserData();
} catch (e) {
log.info('Error when delete all profiles: $e');
}

unawaited(_iapApi.deleteAllProfiles(requester));
unawaited(_iapApi.deleteUserData());

final List<Persona> personas =
await _cloudDatabase.personaDao.getPersonas();
Expand Down
4 changes: 2 additions & 2 deletions lib/screen/settings/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ class _SettingsPageState extends State<SettingsPage>
),
addOnlyDivider(),
_settingItem(
title: 'go_premium'.tr(),
icon: const Icon(AuIcon.add),
title: 'membership'.tr(),
icon: SvgPicture.asset('assets/images/icon_membership.svg'),
onTap: () async {
await Navigator.of(context)
.pushNamed(AppRouter.subscriptionPage);
Expand Down
97 changes: 50 additions & 47 deletions lib/screen/settings/subscription/subscription_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ class _SubscriptionPageState extends State<SubscriptionPage>
with AfterLayoutMixin {
final int initialIndex = 0;
final _upgradesBloc = injector.get<UpgradesBloc>();
late bool _isUpgrading;

@override
void initState() {
super.initState();
_isUpgrading = false;
}

@override
Widget build(BuildContext context) {
Expand All @@ -57,7 +50,7 @@ class _SubscriptionPageState extends State<SubscriptionPage>
child: Scaffold(
appBar: getBackAppBar(
context,
title: 'go_premium'.tr(),
title: 'membership'.tr(),
onBack: () {
if (widget.payload?.onBack != null) {
widget.payload?.onBack?.call();
Expand All @@ -66,40 +59,44 @@ class _SubscriptionPageState extends State<SubscriptionPage>
}
},
),
body: SafeArea(
child: BlocBuilder<UpgradesBloc, UpgradeState>(
bloc: _upgradesBloc,
builder: (context, state) {
final subscriptionDetails = state.activeSubscriptionDetails;
final subscriptionStatus = injector<ConfigurationService>()
.getIAPJWT()
?.getSubscriptionStatus();
return Swiper(
itemCount: subscriptionDetails.length,
onIndexChanged: (index) {},
index: initialIndex,
loop: false,
itemBuilder: (context, index) => _subcribeView(
context, subscriptionDetails[index], subscriptionStatus),
pagination: subscriptionDetails.length > 1
? const SwiperPagination(
builder: DotSwiperPaginationBuilder(
color: AppColor.auLightGrey,
activeColor: MomaPallet.lightYellow),
)
: null,
controller: SwiperController(),
);
}),
),
body: BlocBuilder<UpgradesBloc, UpgradeState>(
bloc: _upgradesBloc,
builder: (context, state) {
final subscriptionDetails = state.activeSubscriptionDetails;
final subscriptionStatus = injector<ConfigurationService>()
.getIAPJWT()
?.getSubscriptionStatus();
return Swiper(
itemCount: subscriptionDetails.length,
onIndexChanged: (index) {},
index: initialIndex,
loop: false,
itemBuilder: (context, index) => _subscribeView(
context,
subscriptionDetails[index],
subscriptionStatus,
state.isProcessing,
),
pagination: subscriptionDetails.length > 1
? const SwiperPagination(
builder: DotSwiperPaginationBuilder(
color: AppColor.auLightGrey,
activeColor: MomaPallet.lightYellow),
)
: null,
controller: SwiperController(),
);
}),
),
);
}

Widget _subcribeView(
BuildContext context,
SubscriptionDetails subscriptionDetails,
SubscriptionStatus? subscriptionStatus) =>
Widget _subscribeView(
BuildContext context,
SubscriptionDetails subscriptionDetails,
SubscriptionStatus? subscriptionStatus,
bool? isProcessing,
) =>
Container(
color: AppColor.auGreyBackground,
padding: const EdgeInsets.all(3),
Expand All @@ -120,7 +117,11 @@ class _SubscriptionPageState extends State<SubscriptionPage>
padding:
ResponsiveLayout.pageHorizontalEdgeInsetsWithSubmitButton,
child: _actionSection(
context, subscriptionDetails, subscriptionStatus),
context,
subscriptionDetails,
subscriptionStatus,
isProcessing,
),
),
],
),
Expand Down Expand Up @@ -171,15 +172,18 @@ class _SubscriptionPageState extends State<SubscriptionPage>
case IAPProductStatus.trial:
// we dont support trial now
case IAPProductStatus.loading:
case IAPProductStatus.pending:
return Container(
height: 80,
height: 500,
alignment: Alignment.topCenter,
child: const LoadingWidget(),
child: const LoadingWidget(
backgroundColor: Colors.transparent,
),
);
case IAPProductStatus.expired:
// expired membership: user has membership but it's expired
// in this case, the UI is the same as free user
case IAPProductStatus.pending:
// pending membership: user is purchasing membership
case IAPProductStatus.notPurchased:
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down Expand Up @@ -208,6 +212,7 @@ class _SubscriptionPageState extends State<SubscriptionPage>
BuildContext context,
SubscriptionDetails subscriptionDetails,
SubscriptionStatus? subscriptionStatus,
bool? isProcessing,
) {
final theme = Theme.of(context);
final dateFormater = DateFormat('dd/MM/yyyy');
Expand Down Expand Up @@ -311,20 +316,18 @@ class _SubscriptionPageState extends State<SubscriptionPage>

case IAPProductStatus.trial:
case IAPProductStatus.loading:
case IAPProductStatus.pending:
return const SizedBox();
case IAPProductStatus.expired:
case IAPProductStatus.pending:
case IAPProductStatus.notPurchased:
// when user is essentially a free user
return MembershipCard(
type: MembershipCardType.premium,
price: subscriptionDetails.price,
isProcessing: _isUpgrading,
isProcessing: isProcessing == true ||
subscriptionDetails.status == IAPProductStatus.pending,
isEnable: true,
onTap: (_) {
setState(() {
_isUpgrading = true;
});
_onPressSubscribe(context,
subscriptionDetails: subscriptionDetails);
},
Expand Down
2 changes: 1 addition & 1 deletion lib/screen/wallet/wallet_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class _WalletPageState extends State<WalletPage>

@override
Widget build(BuildContext context) => Scaffold(
appBar: getBackAppBar(context, title: 'addresses'.tr(), onBack: () {
appBar: getBackAppBar(context, title: 'wallet'.tr(), onBack: () {
Navigator.of(context).pop();
},
icon: Semantics(
Expand Down
3 changes: 2 additions & 1 deletion lib/view/cast_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ class _FFCastButtonState extends State<FFCastButton> {
return MembershipCard(
type: MembershipCardType.premium,
price: price,
isProcessing: upgradeState.isProcessing,
isProcessing: upgradeState.isProcessing ||
subscriptionDetail?.status == IAPProductStatus.pending,
isEnable: subscriptionDetail != null,
onTap: (_) {
_onPressSubscribe(subscriptionDetails: subscriptionDetail!);
Expand Down
6 changes: 4 additions & 2 deletions lib/view/loading.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import 'package:gif_view/gif_view.dart';

class LoadingWidget extends StatelessWidget {
final bool invertColors;
const LoadingWidget({super.key, this.invertColors = false});
final Color? backgroundColor;
const LoadingWidget(
{super.key, this.invertColors = false, this.backgroundColor});

@override
Widget build(BuildContext context) {
Expand All @@ -15,7 +17,7 @@ class LoadingWidget extends StatelessWidget {
return Container(
width: double.infinity,
height: double.infinity,
color: AppColor.primaryBlack,
color: backgroundColor ?? AppColor.primaryBlack,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down
1 change: 1 addition & 0 deletions lib/view/membership_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class MembershipCard extends StatelessWidget {
Text(
'auto_renews_unless_cancelled'.tr(),
style: activeTextStyle,
textAlign: TextAlign.center,
),
],
],
Expand Down
Loading

0 comments on commit 32a9c70

Please sign in to comment.