Skip to content

Commit 96a194c

Browse files
authored
Merge pull request #1971 from SatoshiPortal/develop
Update support features
2 parents 424e70d + 0321cfc commit 96a194c

39 files changed

Lines changed: 1675 additions & 417 deletions
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import 'package:bb_mobile/core/themes/app_theme.dart';
2+
import 'package:bb_mobile/core/utils/build_context_x.dart';
3+
import 'package:bb_mobile/core/widgets/bottom_sheet/x.dart';
4+
import 'package:bb_mobile/core/widgets/buttons/button.dart';
5+
import 'package:bb_mobile/core/widgets/text/text.dart';
6+
import 'package:flutter/material.dart';
7+
8+
class DeleteAccountConfirmationBottomSheet extends StatelessWidget {
9+
final Future<void> Function() onConfirm;
10+
11+
const DeleteAccountConfirmationBottomSheet({
12+
super.key,
13+
required this.onConfirm,
14+
});
15+
16+
static Future<void> show(
17+
BuildContext context, {
18+
required Future<void> Function() onConfirm,
19+
}) {
20+
return BlurredBottomSheet.show(
21+
context: context,
22+
child: DeleteAccountConfirmationBottomSheet(onConfirm: onConfirm),
23+
);
24+
}
25+
26+
@override
27+
Widget build(BuildContext context) {
28+
return Container(
29+
decoration: const BoxDecoration(
30+
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
31+
),
32+
child: SafeArea(
33+
child: Padding(
34+
padding: const EdgeInsets.all(24),
35+
child: Column(
36+
mainAxisSize: MainAxisSize.min,
37+
children: [
38+
Container(
39+
width: 40,
40+
height: 4,
41+
decoration: BoxDecoration(
42+
color: context.appColors.outline.withValues(alpha: 0.3),
43+
borderRadius: BorderRadius.circular(2),
44+
),
45+
),
46+
const SizedBox(height: 24),
47+
Icon(
48+
Icons.delete_forever,
49+
size: 48,
50+
color: context.appColors.primary,
51+
),
52+
const SizedBox(height: 16),
53+
BBText(
54+
context.loc.deleteAccountConfirmationTitle,
55+
style: context.font.headlineSmall?.copyWith(fontWeight: .bold),
56+
textAlign: .center,
57+
),
58+
const SizedBox(height: 8),
59+
BBText(
60+
context.loc.deleteAccountConfirmationDescription,
61+
style: context.font.bodyMedium?.copyWith(
62+
color: context.appColors.secondary.withValues(alpha: 0.7),
63+
),
64+
textAlign: .center,
65+
maxLines: 5,
66+
overflow: .ellipsis,
67+
),
68+
const SizedBox(height: 24),
69+
Row(
70+
children: [
71+
Expanded(
72+
child: BBButton.small(
73+
label: context.loc.deleteAccountConfirmationCancel,
74+
onPressed: () => Navigator.of(context).pop(),
75+
outlined: true,
76+
bgColor: Colors.transparent,
77+
textColor: context.appColors.secondary,
78+
borderColor: context.appColors.outline,
79+
),
80+
),
81+
const SizedBox(width: 12),
82+
Expanded(
83+
child: BBButton.small(
84+
label: context.loc.deleteAccountConfirmationDelete,
85+
onPressed: () async {
86+
Navigator.of(context).pop();
87+
await onConfirm();
88+
},
89+
bgColor: context.appColors.secondary,
90+
textColor: context.appColors.onSecondary,
91+
),
92+
),
93+
],
94+
),
95+
],
96+
),
97+
),
98+
),
99+
);
100+
}
101+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import 'package:bb_mobile/core/themes/app_theme.dart';
2+
import 'package:bb_mobile/core/utils/build_context_x.dart';
3+
import 'package:bb_mobile/core/widgets/bottom_sheet/x.dart';
4+
import 'package:bb_mobile/core/widgets/buttons/button.dart';
5+
import 'package:bb_mobile/core/widgets/text/text.dart';
6+
import 'package:flutter/material.dart';
7+
8+
class DeleteAccountSuccessBottomSheet extends StatelessWidget {
9+
const DeleteAccountSuccessBottomSheet({super.key});
10+
11+
static Future<void> show(BuildContext context) {
12+
return BlurredBottomSheet.show(
13+
context: context,
14+
isDismissible: false,
15+
child: const DeleteAccountSuccessBottomSheet(),
16+
);
17+
}
18+
19+
@override
20+
Widget build(BuildContext context) {
21+
return Container(
22+
decoration: const BoxDecoration(
23+
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
24+
),
25+
child: SafeArea(
26+
child: Padding(
27+
padding: const EdgeInsets.all(24),
28+
child: Column(
29+
mainAxisSize: MainAxisSize.min,
30+
children: [
31+
Container(
32+
width: 40,
33+
height: 4,
34+
decoration: BoxDecoration(
35+
color: context.appColors.outline.withValues(alpha: 0.3),
36+
borderRadius: BorderRadius.circular(2),
37+
),
38+
),
39+
const SizedBox(height: 24),
40+
Icon(
41+
Icons.check_circle_outline,
42+
size: 48,
43+
color: context.appColors.primary,
44+
),
45+
const SizedBox(height: 16),
46+
BBText(
47+
context.loc.deleteAccountSuccessTitle,
48+
style: context.font.headlineSmall?.copyWith(fontWeight: .bold),
49+
textAlign: .center,
50+
),
51+
const SizedBox(height: 8),
52+
BBText(
53+
context.loc.deleteAccountSuccessDescription,
54+
style: context.font.bodyMedium?.copyWith(
55+
color: context.appColors.secondary.withValues(alpha: 0.7),
56+
),
57+
textAlign: .center,
58+
maxLines: 5,
59+
overflow: .ellipsis,
60+
),
61+
const SizedBox(height: 24),
62+
SizedBox(
63+
width: double.infinity,
64+
child: BBButton.small(
65+
label: context.loc.deleteAccountSuccessClose,
66+
onPressed: () => Navigator.of(context).pop(),
67+
bgColor: context.appColors.secondary,
68+
textColor: context.appColors.onSecondary,
69+
),
70+
),
71+
],
72+
),
73+
),
74+
),
75+
);
76+
}
77+
}

lib/features/exchange/exchange_locator.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:bb_mobile/core/exchange/domain/usecases/get_announcements_usecas
44
import 'package:bb_mobile/core/exchange/domain/usecases/get_exchange_user_summary_usecase.dart';
55
import 'package:bb_mobile/core/exchange/domain/usecases/save_exchange_api_key_usecase.dart';
66
import 'package:bb_mobile/core/exchange/domain/usecases/save_user_preferences_usecase.dart';
7+
import 'package:bb_mobile/core/exchange/domain/usecases/send_support_chat_message_usecase.dart';
78
import 'package:bb_mobile/features/exchange/presentation/exchange_cubit.dart';
89
import 'package:get_it/get_it.dart';
910

@@ -22,6 +23,8 @@ class ExchangeLocator {
2223
deleteExchangeApiKeyUsecase: locator.get<DeleteExchangeApiKeyUsecase>(),
2324
getAnnouncementsUsecase: locator.get<GetAnnouncementsUsecase>(),
2425
exchangeNotificationService: locator.get<ExchangeNotificationService>(),
26+
sendSupportChatMessageUsecase:
27+
locator.get<SendSupportChatMessageUsecase>(),
2528
),
2629
);
2730
}

lib/features/exchange/presentation/exchange_cubit.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:bb_mobile/core/exchange/domain/usecases/get_announcements_usecas
88
import 'package:bb_mobile/core/exchange/domain/usecases/get_exchange_user_summary_usecase.dart';
99
import 'package:bb_mobile/core/exchange/domain/usecases/save_exchange_api_key_usecase.dart';
1010
import 'package:bb_mobile/core/exchange/domain/usecases/save_user_preferences_usecase.dart';
11+
import 'package:bb_mobile/core/exchange/domain/usecases/send_support_chat_message_usecase.dart';
1112
import 'package:bb_mobile/core/utils/logger.dart';
1213
import 'package:bb_mobile/features/exchange/presentation/exchange_state.dart';
1314
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -21,12 +22,14 @@ class ExchangeCubit extends Cubit<ExchangeState> {
2122
required DeleteExchangeApiKeyUsecase deleteExchangeApiKeyUsecase,
2223
required GetAnnouncementsUsecase getAnnouncementsUsecase,
2324
required ExchangeNotificationService exchangeNotificationService,
25+
required SendSupportChatMessageUsecase sendSupportChatMessageUsecase,
2426
}) : _getExchangeUserSummaryUsecase = getExchangeUserSummaryUsecase,
2527
_saveExchangeApiKeyUsecase = saveExchangeApiKeyUsecase,
2628
_saveUserPreferencesUsecase = saveUserPreferencesUsecase,
2729
_deleteExchangeApiKeyUsecase = deleteExchangeApiKeyUsecase,
2830
_getAnnouncementsUsecase = getAnnouncementsUsecase,
2931
_exchangeNotificationService = exchangeNotificationService,
32+
_sendSupportChatMessageUsecase = sendSupportChatMessageUsecase,
3033
super(const ExchangeState()) {
3134
_notificationSubscription = _exchangeNotificationService.messageStream
3235
.where(
@@ -44,6 +47,7 @@ class ExchangeCubit extends Cubit<ExchangeState> {
4447
final DeleteExchangeApiKeyUsecase _deleteExchangeApiKeyUsecase;
4548
final GetAnnouncementsUsecase _getAnnouncementsUsecase;
4649
final ExchangeNotificationService _exchangeNotificationService;
50+
final SendSupportChatMessageUsecase _sendSupportChatMessageUsecase;
4751
StreamSubscription<NotificationMessage>? _notificationSubscription;
4852

4953
Future<void> connectWebSocket() async {
@@ -193,6 +197,13 @@ class ExchangeCubit extends Cubit<ExchangeState> {
193197
}
194198
}
195199

200+
Future<void> deleteAccount() async {
201+
await _sendSupportChatMessageUsecase.execute(
202+
text: 'I want to delete my account',
203+
);
204+
await logout();
205+
}
206+
196207
void loadAnnouncements() async {
197208
emit(
198209
state.copyWith(loadingAnnouncements: true, errLoadingAnnouncements: null),

lib/features/exchange/ui/exchange_router.dart

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:bb_mobile/features/exchange/ui/screens/exchange_landing_screen_v
1010
import 'package:bb_mobile/features/exchange/ui/screens/exchange_support_login_screen.dart';
1111
import 'package:bb_mobile/features/exchange_support_chat/ui/exchange_support_chat_router.dart';
1212
import 'package:bb_mobile/features/settings/presentation/bloc/settings_cubit.dart';
13+
import 'package:bb_mobile/features/wallet/ui/wallet_router.dart';
1314
import 'package:flutter/material.dart';
1415
import 'package:flutter_bloc/flutter_bloc.dart';
1516
import 'package:go_router/go_router.dart';
@@ -36,6 +37,11 @@ class ExchangeRouter {
3637
if (notLoggedIn) {
3738
return ExchangeRoute.exchangeLanding.path;
3839
}
40+
final isSuperuser =
41+
context.read<SettingsCubit>().state.isSuperuser ?? false;
42+
if (Platform.isIOS && !isSuperuser) {
43+
return WalletRoute.walletHome.path;
44+
}
3945
return null;
4046
},
4147
pageBuilder: (context, state) {
@@ -52,7 +58,6 @@ class ExchangeRouter {
5258
return const ExchangeKycScreen();
5359
},
5460
),
55-
ExchangeSupportChatRouter.route,
5661
],
5762
),
5863
GoRoute(
@@ -80,30 +85,41 @@ class ExchangeRouter {
8085
name: ExchangeRoute.exchangeLoginForSupport.name,
8186
path: ExchangeRoute.exchangeLoginForSupport.path,
8287
pageBuilder: (context, state) {
83-
Widget screen;
84-
if (Platform.isIOS) {
85-
final isSuperuser =
86-
context.read<SettingsCubit>().state.isSuperuser ?? false;
87-
screen = isSuperuser
88-
? const ExchangeLandingScreen()
89-
: const ExchangeSupportLoginScreen();
90-
} else {
91-
screen = const ExchangeLandingScreen();
92-
}
93-
return NoTransitionPage(key: state.pageKey, child: screen);
88+
return NoTransitionPage(
89+
key: state.pageKey,
90+
child: const ExchangeSupportLoginScreen(),
91+
);
9492
},
9593
),
94+
ExchangeSupportChatRouter.route,
9695
GoRoute(
9796
name: ExchangeRoute.exchangeAuth.name,
9897
path: ExchangeRoute.exchangeAuth.path,
9998
pageBuilder: (context, state) {
99+
final fromSupport =
100+
state.uri.queryParameters['from'] == 'support';
100101
return NoTransitionPage(
101102
key: state.pageKey,
102103
child: BlocListener<ExchangeCubit, ExchangeState>(
103104
listenWhen: (previous, current) =>
104105
previous.notLoggedIn && !current.notLoggedIn,
105-
listener: (context, state) {
106-
// Redirect to home screen if the API key becomes valid
106+
listener: (context, exchangeState) {
107+
if (fromSupport) {
108+
final isIOSNonSuperuser = Platform.isIOS &&
109+
!(context.read<SettingsCubit>().state.isSuperuser ?? false);
110+
context.goNamed(
111+
ExchangeSupportChatRoute.supportChat.name,
112+
queryParameters:
113+
isIOSNonSuperuser ? {} : {'from': 'exchange'},
114+
);
115+
return;
116+
}
117+
final isSuperuser =
118+
context.read<SettingsCubit>().state.isSuperuser ?? false;
119+
if (Platform.isIOS && !isSuperuser) {
120+
context.goNamed(WalletRoute.walletHome.name);
121+
return;
122+
}
107123
context.goNamed(ExchangeRoute.exchangeHome.name);
108124
},
109125
child: const ExchangeAuthScreen(),

0 commit comments

Comments
 (0)