@@ -2,12 +2,11 @@ import 'package:easy_localization/easy_localization.dart';
2
2
import 'package:flutter/material.dart' ;
3
3
import 'package:flutter_bloc/flutter_bloc.dart' ;
4
4
import 'package:web_dex/app_config/app_config.dart' ;
5
+ import 'package:komodo_ui_kit/komodo_ui_kit.dart' ;
5
6
import 'package:web_dex/bloc/auth_bloc/auth_bloc.dart' ;
6
- import 'package:web_dex/bloc/auth_bloc/auth_bloc_event.dart' ;
7
- import 'package:web_dex/blocs/blocs.dart' ;
7
+ import 'package:web_dex/bloc/coins_bloc/coins_bloc.dart' ;
8
8
import 'package:web_dex/generated/codegen_loader.g.dart' ;
9
9
import 'package:web_dex/model/wallet.dart' ;
10
- import 'package:komodo_ui_kit/komodo_ui_kit.dart' ;
11
10
12
11
class LogOutPopup extends StatelessWidget {
13
12
const LogOutPopup ({
@@ -20,56 +19,65 @@ class LogOutPopup extends StatelessWidget {
20
19
21
20
@override
22
21
Widget build (BuildContext context) {
23
- return Container (
24
- constraints: const BoxConstraints (maxWidth: 300 ),
25
- child: Column (
26
- crossAxisAlignment: CrossAxisAlignment .center,
27
- mainAxisSize: MainAxisSize .min,
28
- children: [
29
- SelectableText (
30
- LocaleKeys .logoutPopupTitle.tr (),
31
- style: const TextStyle (
32
- fontSize: 18 ,
33
- fontWeight: FontWeight .w700,
34
- ),
35
- ),
36
- const SizedBox (height: 12 ),
37
- if (currentWalletBloc.wallet? .config.type == WalletType .iguana)
38
- SelectableText (
39
- kIsWalletOnly
40
- ? LocaleKeys .logoutPopupDescriptionWalletOnly.tr ()
41
- : LocaleKeys .logoutPopupDescription.tr (),
42
- style: const TextStyle (
43
- fontSize: 14 ,
44
- fontWeight: FontWeight .w500,
45
- ),
46
- ),
47
- const SizedBox (height: 25 ),
48
- Row (
22
+ return BlocBuilder <AuthBloc , AuthBlocState >(
23
+ builder: (context, state) {
24
+ final currentWallet = state.currentUser? .wallet;
25
+ return Container (
26
+ constraints: const BoxConstraints (maxWidth: 300 ),
27
+ child: Column (
28
+ crossAxisAlignment: CrossAxisAlignment .center,
49
29
mainAxisSize: MainAxisSize .min,
50
30
children: [
51
- UiUnderlineTextButton (
52
- key : const Key ( 'popup-cancel-logout-button' ),
53
- width : 120 ,
54
- height : 36 ,
55
- text : LocaleKeys .cancel. tr () ,
56
- onPressed : onCancel ,
31
+ SelectableText (
32
+ LocaleKeys .logoutPopupTitle. tr ( ),
33
+ style : const TextStyle (
34
+ fontSize : 18 ,
35
+ fontWeight : FontWeight .w700 ,
36
+ ) ,
57
37
),
58
- const SizedBox (width: 12 ),
59
- UiPrimaryButton (
60
- key: const Key ('popup-confirm-logout-button' ),
61
- width: 120 ,
62
- height: 36 ,
63
- text: LocaleKeys .logOut.tr (),
64
- onPressed: () {
65
- context.read <AuthBloc >().add (const AuthLogOutEvent ());
66
- onConfirm ();
67
- },
38
+ const SizedBox (height: 12 ),
39
+ if (currentWallet? .config.type == WalletType .iguana)
40
+ SelectableText (
41
+ kIsWalletOnly
42
+ ? LocaleKeys .logoutPopupDescriptionWalletOnly.tr ()
43
+ : LocaleKeys .logoutPopupDescription.tr (),
44
+ style: const TextStyle (
45
+ fontSize: 14 ,
46
+ fontWeight: FontWeight .w500,
47
+ ),
48
+ ),
49
+ const SizedBox (height: 25 ),
50
+ Row (
51
+ mainAxisSize: MainAxisSize .min,
52
+ children: [
53
+ UiUnderlineTextButton (
54
+ key: const Key ('popup-cancel-logout-button' ),
55
+ width: 120 ,
56
+ height: 36 ,
57
+ text: LocaleKeys .cancel.tr (),
58
+ onPressed: onCancel,
59
+ ),
60
+ const SizedBox (width: 12 ),
61
+ UiPrimaryButton (
62
+ key: const Key ('popup-confirm-logout-button' ),
63
+ width: 120 ,
64
+ height: 36 ,
65
+ text: LocaleKeys .logOut.tr (),
66
+ onPressed: () => _onConfirmLogout (context),
67
+ ),
68
+ ],
68
69
),
69
70
],
70
71
),
71
- ],
72
- ) ,
72
+ );
73
+ } ,
73
74
);
74
75
}
76
+
77
+ void _onConfirmLogout (BuildContext context) {
78
+ // stop listening to balance updates before logging out
79
+ context.read <CoinsBloc >().add (CoinsSessionEnded ());
80
+ context.read <AuthBloc >().add (const AuthSignOutRequested ());
81
+ onConfirm ();
82
+ }
75
83
}
0 commit comments