Skip to content

Commit

Permalink
[Presentation] Removed not needed code
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Jun 4, 2021
1 parent 77d7865 commit 42985de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 46 deletions.
Expand Up @@ -21,7 +21,6 @@ class CalculatorSessionsPage extends StatefulWidget {
}

class _CalculatorSessionsPageState extends State<CalculatorSessionsPage> with SingleTickerProviderStateMixin, AppFabMixin {
int _numberOfItems = 0;
@override
bool get isInitiallyVisible => true;

Expand All @@ -31,18 +30,7 @@ class _CalculatorSessionsPageState extends State<CalculatorSessionsPage> with Si
@override
Widget build(BuildContext context) {
final s = S.of(context);
return BlocConsumer<CalculatorAscMaterialsSessionsBloc, CalculatorAscMaterialsSessionsState>(
listener: (ctx, state) {
state.maybeMap(
loaded: (state) {
if (_numberOfItems != state.sessions.length) {
hideFabAnimController.forward();
}
_numberOfItems = state.sessions.length;
},
orElse: () {},
);
},
return BlocBuilder<CalculatorAscMaterialsSessionsBloc, CalculatorAscMaterialsSessionsState>(
builder: (ctx, state) => Scaffold(
appBar: state.map(
loading: (_) => null,
Expand Down
42 changes: 9 additions & 33 deletions lib/presentation/notifications/notifications_page.dart
Expand Up @@ -6,8 +6,8 @@ import 'package:genshindb/domain/models/models.dart' as models;
import 'package:genshindb/generated/l10n.dart';
import 'package:genshindb/presentation/shared/app_fab.dart';
import 'package:genshindb/presentation/shared/extensions/i18n_extensions.dart';
import 'package:genshindb/presentation/shared/extensions/scroll_controller_extensions.dart';
import 'package:genshindb/presentation/shared/info_dialog.dart';
import 'package:genshindb/presentation/shared/mixins/app_fab_mixin.dart';
import 'package:genshindb/presentation/shared/nothing_found_column.dart';
import 'package:genshindb/presentation/shared/styles.dart';
import 'package:grouped_list/grouped_list.dart';
Expand All @@ -23,23 +23,12 @@ class NotificationsPage extends StatefulWidget {
_NotificationsPageState createState() => _NotificationsPageState();
}

class _NotificationsPageState extends State<NotificationsPage> with SingleTickerProviderStateMixin {
ScrollController _scrollController;
AnimationController _hideFabAnimController;
int _numberOfItems = 0;

class _NotificationsPageState extends State<NotificationsPage> with SingleTickerProviderStateMixin, AppFabMixin {
@override
void initState() {
super.initState();
bool get isInitiallyVisible => true;

_scrollController = ScrollController();
_hideFabAnimController = AnimationController(
vsync: this,
duration: kThemeAnimationDuration,
value: 1, // initially visible
);
_scrollController.addListener(() => _scrollController.handleScrollForFab(_hideFabAnimController, hideOnTop: false));
}
@override
bool get hideOnTop => false;

@override
Widget build(BuildContext context) {
Expand All @@ -57,13 +46,7 @@ class _NotificationsPageState extends State<NotificationsPage> with SingleTicker
],
),
body: SafeArea(
child: BlocConsumer<NotificationsBloc, NotificationsState>(
listener: (ctx, state) {
if (_numberOfItems != state.notifications.length) {
_hideFabAnimController.forward();
}
_numberOfItems = state.notifications.length;
},
child: BlocBuilder<NotificationsBloc, NotificationsState>(
builder: (ctx, state) => state.map(
initial: (state) {
if (state.notifications.isEmpty) {
Expand All @@ -72,7 +55,7 @@ class _NotificationsPageState extends State<NotificationsPage> with SingleTicker

return GroupedListView<models.NotificationItem, String>(
elements: state.notifications,
controller: _scrollController,
controller: scrollController,
groupBy: (item) => s.translateAppNotificationType(item.type),
itemBuilder: (context, element) => _buildNotificationItem(state.useTwentyFourHoursFormat, element),
groupSeparatorBuilder: (type) => Container(
Expand All @@ -88,20 +71,13 @@ class _NotificationsPageState extends State<NotificationsPage> with SingleTicker
floatingActionButton: AppFab(
onPressed: () => _showAddModal(context),
icon: const Icon(Icons.add),
hideFabAnimController: _hideFabAnimController,
scrollController: _scrollController,
hideFabAnimController: hideFabAnimController,
scrollController: scrollController,
mini: false,
),
);
}

@override
void dispose() {
_scrollController.dispose();
_hideFabAnimController.dispose();
super.dispose();
}

Widget _buildNotificationItem(bool useTwentyFourHoursFormat, models.NotificationItem element) {
Widget subtitle;
switch (element.type) {
Expand Down

0 comments on commit 42985de

Please sign in to comment.