Skip to content

Commit e29baf2

Browse files
committed
style: format
1 parent 63b767f commit e29baf2

File tree

3 files changed

+79
-81
lines changed

3 files changed

+79
-81
lines changed

lib/account/bloc/in_app_notification_center_bloc.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'dart:async';
22

3-
import 'package:bloc_concurrency/bloc_concurrency.dart';
43
import 'package:bloc/bloc.dart';
4+
import 'package:bloc_concurrency/bloc_concurrency.dart';
55
import 'package:collection/collection.dart';
66
import 'package:core/core.dart';
77
import 'package:data_repository/data_repository.dart';
@@ -22,13 +22,8 @@ part 'in_app_notification_center_state.dart';
2222
/// {@endtemplate}
2323
class InAppNotificationCenterBloc
2424
extends Bloc<InAppNotificationCenterEvent, InAppNotificationCenterState> {
25-
/// The number of notifications to fetch per page.
26-
static const _notificationsFetchLimit = 10;
27-
2825
/// {@macro in_app_notification_center_bloc}
2926
InAppNotificationCenterBloc({
30-
// The BLoC should not be responsible for creating its own dependencies.
31-
// They should be provided from the outside.
3227
required DataRepository<InAppNotification> inAppNotificationRepository,
3328
required AppBloc appBloc,
3429
required Logger logger,
@@ -50,6 +45,9 @@ class InAppNotificationCenterBloc
5045
);
5146
}
5247

48+
/// The number of notifications to fetch per page.
49+
static const _notificationsFetchLimit = 10;
50+
5351
final DataRepository<InAppNotification> _inAppNotificationRepository;
5452
final AppBloc _appBloc;
5553
final Logger _logger;

lib/account/bloc/in_app_notification_center_state.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,12 @@ class InAppNotificationCenterState extends Equatable {
107107
digestNotifications: digestNotifications ?? this.digestNotifications,
108108
breakingNewsHasMore: breakingNewsHasMore ?? this.breakingNewsHasMore,
109109
breakingNewsCursor: breakingNewsCursor == null
110-
? this
111-
.breakingNewsCursor // No change
112-
: breakingNewsCursor as String?, // New value
110+
? this.breakingNewsCursor
111+
: breakingNewsCursor as String?,
113112
digestHasMore: digestHasMore ?? this.digestHasMore,
114113
digestCursor: digestCursor == null
115-
? this
116-
.digestCursor // No change
117-
: digestCursor as String?, // New value
114+
? this.digestCursor
115+
: digestCursor as String?,
118116
);
119117
}
120118
}

lib/account/view/in_app_notification_center_page.dart

Lines changed: 71 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class _InAppNotificationCenterPageState
3636
..addListener(() {
3737
if (!_tabController.indexIsChanging) {
3838
context.read<InAppNotificationCenterBloc>().add(
39-
InAppNotificationCenterTabChanged(_tabController.index),
40-
);
39+
InAppNotificationCenterTabChanged(_tabController.index),
40+
);
4141
}
4242
});
4343
}
@@ -56,16 +56,18 @@ class _InAppNotificationCenterPageState
5656
appBar: AppBar(
5757
title: Text(l10n.notificationCenterPageTitle),
5858
actions: [
59-
BlocBuilder<InAppNotificationCenterBloc,
60-
InAppNotificationCenterState>(
59+
BlocBuilder<
60+
InAppNotificationCenterBloc,
61+
InAppNotificationCenterState
62+
>(
6163
builder: (context, state) {
6264
final hasUnread = state.notifications.any((n) => !n.isRead);
6365
return IconButton(
6466
onPressed: hasUnread
6567
? () {
6668
context.read<InAppNotificationCenterBloc>().add(
67-
const InAppNotificationCenterMarkAllAsRead(),
68-
);
69+
const InAppNotificationCenterMarkAllAsRead(),
70+
);
6971
}
7072
: null,
7173
icon: const Icon(Icons.done_all),
@@ -81,65 +83,69 @@ class _InAppNotificationCenterPageState
8183
],
8284
),
8385
),
84-
body: BlocConsumer<InAppNotificationCenterBloc,
85-
InAppNotificationCenterState>(
86-
listener: (context, state) {
87-
if (state.status == InAppNotificationCenterStatus.failure &&
88-
state.error != null) {
89-
ScaffoldMessenger.of(context)
90-
..hideCurrentSnackBar()
91-
..showSnackBar(
92-
SnackBar(
93-
content: Text(state.error!.message),
94-
backgroundColor: Theme.of(context).colorScheme.error,
95-
),
96-
);
97-
}
98-
},
99-
builder: (context, state) {
100-
if (state.status == InAppNotificationCenterStatus.loading &&
101-
state.breakingNewsNotifications.isEmpty &&
102-
state.digestNotifications.isEmpty) {
103-
return LoadingStateWidget(
104-
icon: Icons.notifications_none_outlined,
105-
headline: l10n.notificationCenterLoadingHeadline,
106-
subheadline: l10n.notificationCenterLoadingSubheadline,
107-
);
108-
}
86+
body:
87+
BlocConsumer<
88+
InAppNotificationCenterBloc,
89+
InAppNotificationCenterState
90+
>(
91+
listener: (context, state) {
92+
if (state.status == InAppNotificationCenterStatus.failure &&
93+
state.error != null) {
94+
ScaffoldMessenger.of(context)
95+
..hideCurrentSnackBar()
96+
..showSnackBar(
97+
SnackBar(
98+
content: Text(state.error!.message),
99+
backgroundColor: Theme.of(context).colorScheme.error,
100+
),
101+
);
102+
}
103+
},
104+
builder: (context, state) {
105+
if (state.status == InAppNotificationCenterStatus.loading &&
106+
state.breakingNewsNotifications.isEmpty &&
107+
state.digestNotifications.isEmpty) {
108+
return LoadingStateWidget(
109+
icon: Icons.notifications_none_outlined,
110+
headline: l10n.notificationCenterLoadingHeadline,
111+
subheadline: l10n.notificationCenterLoadingSubheadline,
112+
);
113+
}
109114

110-
if (state.status == InAppNotificationCenterStatus.failure &&
111-
state.breakingNewsNotifications.isEmpty &&
112-
state.digestNotifications.isEmpty) {
113-
return FailureStateWidget(
114-
exception: state.error ??
115-
OperationFailedException(
116-
l10n.notificationCenterFailureHeadline,
117-
),
118-
onRetry: () {
119-
context.read<InAppNotificationCenterBloc>().add(
115+
if (state.status == InAppNotificationCenterStatus.failure &&
116+
state.breakingNewsNotifications.isEmpty &&
117+
state.digestNotifications.isEmpty) {
118+
return FailureStateWidget(
119+
exception:
120+
state.error ??
121+
OperationFailedException(
122+
l10n.notificationCenterFailureHeadline,
123+
),
124+
onRetry: () {
125+
context.read<InAppNotificationCenterBloc>().add(
120126
const InAppNotificationCenterSubscriptionRequested(),
121127
);
122-
},
123-
);
124-
}
128+
},
129+
);
130+
}
125131

126-
return TabBarView(
127-
controller: _tabController,
128-
children: [
129-
_NotificationList(
130-
status: state.status,
131-
notifications: state.breakingNewsNotifications,
132-
hasMore: state.breakingNewsHasMore,
133-
),
134-
_NotificationList(
135-
status: state.status,
136-
notifications: state.digestNotifications,
137-
hasMore: state.digestHasMore,
138-
),
139-
],
140-
);
141-
},
142-
),
132+
return TabBarView(
133+
controller: _tabController,
134+
children: [
135+
_NotificationList(
136+
status: state.status,
137+
notifications: state.breakingNewsNotifications,
138+
hasMore: state.breakingNewsHasMore,
139+
),
140+
_NotificationList(
141+
status: state.status,
142+
notifications: state.digestNotifications,
143+
hasMore: state.digestHasMore,
144+
),
145+
],
146+
);
147+
},
148+
),
143149
);
144150
}
145151
}
@@ -216,12 +222,8 @@ class _NotificationListState extends State<_NotificationList> {
216222
if (index >= widget.notifications.length) {
217223
return widget.status == InAppNotificationCenterStatus.loadingMore
218224
? const Padding(
219-
padding: EdgeInsets.symmetric(
220-
vertical: AppSpacing.lg,
221-
),
222-
child: Center(
223-
child: CircularProgressIndicator(),
224-
),
225+
padding: EdgeInsets.symmetric(vertical: AppSpacing.lg),
226+
child: Center(child: CircularProgressIndicator()),
225227
)
226228
: const SizedBox.shrink();
227229
}
@@ -230,8 +232,8 @@ class _NotificationListState extends State<_NotificationList> {
230232
notification: notification,
231233
onTap: () async {
232234
context.read<InAppNotificationCenterBloc>().add(
233-
InAppNotificationCenterMarkedAsRead(notification.id),
234-
);
235+
InAppNotificationCenterMarkedAsRead(notification.id),
236+
);
235237

236238
final payload = notification.payload;
237239
final contentType = payload.data['contentType'] as String?;

0 commit comments

Comments
 (0)