@@ -37,27 +37,23 @@ class Profile extends StatelessWidget {
37
37
38
38
@override
39
39
Widget build (BuildContext context) {
40
- return BlocListener <ProfileCubit , ProfileState >(
41
- listenWhen: (_, current) => current.action.isLogOut,
42
- listener: (_, __) => context.read <AppCubit >().logOut (),
43
- child: Scaffold (
44
- appBar: AppBar (
45
- backgroundColor: QuizColors .deepOrange,
46
- title: const DisplayName (),
47
- ),
48
- body: Column (
49
- mainAxisAlignment: MainAxisAlignment .spaceEvenly,
50
- children: const [
51
- SizedBox (height: 50 ),
52
- ProfilePhoto (),
53
- EmailAddress (),
54
- Spacer (),
55
- TotalCompletedQuizzes (),
56
- Spacer (),
57
- LogOutButton (),
58
- Spacer (),
59
- ],
60
- ),
40
+ return Scaffold (
41
+ appBar: AppBar (
42
+ backgroundColor: QuizColors .deepOrange,
43
+ title: const DisplayName (),
44
+ ),
45
+ body: Column (
46
+ mainAxisAlignment: MainAxisAlignment .spaceEvenly,
47
+ children: const [
48
+ SizedBox (height: 50 ),
49
+ ProfilePhoto (),
50
+ EmailAddress (),
51
+ Spacer (),
52
+ TotalCompletedQuizzes (),
53
+ Spacer (),
54
+ LogOutButton (),
55
+ Spacer (),
56
+ ],
61
57
),
62
58
);
63
59
}
@@ -69,7 +65,7 @@ class DisplayName extends StatelessWidget {
69
65
@override
70
66
Widget build (BuildContext context) {
71
67
final displayName =
72
- context.select ((ProfileCubit cubit) => cubit.state.user. displayName);
68
+ context.select ((ProfileCubit cubit) => cubit.state.displayName);
73
69
return Text (displayName.isNotEmpty
74
70
? displayName
75
71
: context.l10n.guestProfileDisplayName);
@@ -84,7 +80,7 @@ class ProfilePhoto extends StatelessWidget {
84
80
@override
85
81
Widget build (BuildContext context) {
86
82
final photoURL =
87
- context.select ((ProfileCubit cubit) => cubit.state.user. photoURL);
83
+ context.select ((ProfileCubit cubit) => cubit.state.photoURL);
88
84
return photoURL.isNotEmpty
89
85
? Stack (
90
86
alignment: AlignmentDirectional .center,
@@ -119,8 +115,7 @@ class EmailAddress extends StatelessWidget {
119
115
120
116
@override
121
117
Widget build (BuildContext context) {
122
- final email =
123
- context.select ((ProfileCubit cubit) => cubit.state.user.email);
118
+ final email = context.select ((ProfileCubit cubit) => cubit.state.email);
124
119
return Text (email, style: context.textTheme.headline5);
125
120
}
126
121
}
@@ -131,7 +126,7 @@ class TotalCompletedQuizzes extends StatelessWidget {
131
126
@override
132
127
Widget build (BuildContext context) {
133
128
final totalCompletedQuizzes = context
134
- .select ((ProfileCubit cubit) => cubit.state.user. totalCompletedQuizzes);
129
+ .select ((ProfileCubit cubit) => cubit.state.totalCompletedQuizzes);
135
130
return Column (
136
131
mainAxisSize: MainAxisSize .min,
137
132
children: [
@@ -154,7 +149,7 @@ class LogOutButton extends StatelessWidget {
154
149
@override
155
150
Widget build (BuildContext context) {
156
151
return ActionButton (
157
- onPressed: context.read <ProfileCubit >().logOut,
152
+ onPressed: context.read <AppCubit >().logOut,
158
153
backgroundColor: QuizColors .red,
159
154
label: Text (context.l10n.logOutButtonLabel),
160
155
);
0 commit comments