Skip to content

Commit

Permalink
Add option to view past events for Sharezone Plus users (#1042)
Browse files Browse the repository at this point in the history
## Description

This PR adds the feature to view the past events.

I haven't added lazy loading to avoid complexity. If this feature is
actually used, we can add lazy later.

## Demo

Unlocked:


https://github.com/SharezoneApp/sharezone-app/assets/24459435/8db4c9e4-e26b-4150-be42-96cfd32bf8e9

Not unlocked:

<img width="754" alt="image"
src="https://github.com/SharezoneApp/sharezone-app/assets/24459435/32133a70-2ed4-4429-a2e0-5f761d3248a1">

## Related Tickets

Closes #242
Closes #891
  • Loading branch information
nilsreichardt authored Sep 24, 2023
1 parent 4986f68 commit 460dba4
Show file tree
Hide file tree
Showing 35 changed files with 1,486 additions and 4 deletions.
14 changes: 13 additions & 1 deletion app/lib/blocs/sharezone_bloc_providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ import 'package:sharezone/blocs/bloc_dependencies.dart';
import 'package:sharezone/blocs/settings/change_data_bloc.dart';
import 'package:sharezone/blocs/settings/notifications_bloc_factory.dart';
import 'package:sharezone/calendrical_events/analytics/calendrical_events_page_analytics.dart';
import 'package:sharezone/calendrical_events/analytics/past_calendrical_events_page_analytics.dart';
import 'package:sharezone/calendrical_events/bloc/calendrical_events_page_bloc_factory.dart';
import 'package:sharezone/calendrical_events/bloc/calendrical_events_page_cache.dart';
import 'package:sharezone/calendrical_events/provider/past_calendrical_events_page_controller_factory.dart';
import 'package:sharezone/comments/comment_view_factory.dart';
import 'package:sharezone/comments/comments_analytics.dart';
import 'package:sharezone/comments/comments_bloc_factory.dart';
Expand Down Expand Up @@ -83,7 +85,6 @@ import 'package:sharezone/pages/settings/changelog/changelog_gateway.dart';
import 'package:sharezone/pages/settings/src/subpages/imprint/analytics/imprint_analytics.dart';
import 'package:sharezone/pages/settings/src/subpages/imprint/bloc/imprint_bloc_factory.dart';
import 'package:sharezone/pages/settings/src/subpages/imprint/gateway/imprint_gateway.dart';
import 'package:sharezone/support/support_page_controller.dart';
import 'package:sharezone/pages/settings/timetable_settings/bloc/timetable_settings_bloc_factory.dart';
import 'package:sharezone/pages/settings/timetable_settings/time_picker_settings_cache.dart';
import 'package:sharezone/report/report_factory.dart';
Expand All @@ -94,6 +95,7 @@ import 'package:sharezone/sharezone_plus/page/sharezone_plus_page_controller.dar
import 'package:sharezone/sharezone_plus/subscription_service/revenue_cat_sharezone_plus_service.dart';
import 'package:sharezone/sharezone_plus/subscription_service/subscription_flag.dart';
import 'package:sharezone/sharezone_plus/subscription_service/subscription_service.dart';
import 'package:sharezone/support/support_page_controller.dart';
import 'package:sharezone/timetable/src/bloc/timetable_bloc.dart';
import 'package:sharezone/timetable/src/models/lesson_length/lesson_length_cache.dart';
import 'package:sharezone/timetable/timetable_add/bloc/timetable_add_bloc_dependencies.dart';
Expand Down Expand Up @@ -349,6 +351,16 @@ class _SharezoneBlocProvidersState extends State<SharezoneBlocProviders> {
value: typeOfUserStream,
initialData: null,
),
Provider(
create: (context) => PastCalendricalEventsPageControllerFactory(
clock: clock,
subscriptionService: subscriptionService,
timetableGateway: api.timetable,
courseGateway: api.course,
schoolClassGateway: api.schoolClassGateway,
analytics: PastCalendricalEventsPageAnalytics(analytics),
),
),
];

final mainBlocProviders = <BlocProvider>[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class CalendricalEventsPageAnalytics {
),
);
}

void logPastEventsPageOpened() {
analytics.log(
const CalendricalEventsPageAnalyticsEvent('past_events_page_opened'),
);
}
}

class CalendricalEventsPageAnalyticsEvent extends AnalyticsEvent {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) 2023 Sharezone UG (haftungsbeschränkt)
// Licensed under the EUPL-1.2-or-later.
//
// You may obtain a copy of the Licence at:
// https://joinup.ec.europa.eu/software/page/eupl
//
// SPDX-License-Identifier: EUPL-1.2

import 'package:analytics/analytics.dart';
import 'package:sharezone/calendrical_events/provider/past_calendrical_events_page_controller.dart';

class PastCalendricalEventsPageAnalytics {
final Analytics analytics;

const PastCalendricalEventsPageAnalytics(this.analytics);

void logChangedOrder(EventsSortingOrder order) {
analytics.log(
PastCalendricalEventsPageAnalyticsEvent(
'changed_order',
data: {'order': order.name},
),
);
}
}

class PastCalendricalEventsPageAnalyticsEvent extends AnalyticsEvent {
const PastCalendricalEventsPageAnalyticsEvent(
String name, {
Map<String, dynamic>? data,
}) : super('past_events_page_$name', data: data);
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class CalendricalEventsPageBloc extends BlocBase {
cache.setLayout(layout);
}

void logPastEventsPageOpened() {
analytics.logPastEventsPageOpened();
}

@override
void dispose() {
_layoutSubject.close();
Expand Down
36 changes: 35 additions & 1 deletion app/lib/calendrical_events/page/calendrical_events_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

import 'package:bloc_provider/bloc_provider.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:sharezone/calendrical_events/bloc/calendrical_events_page_bloc.dart';
import 'package:sharezone/calendrical_events/bloc/calendrical_events_page_bloc_factory.dart';
import 'package:sharezone/calendrical_events/page/past_calendrical_events_page.dart';
import 'package:sharezone/calendrical_events/models/calendrical_events_layout.dart';
import 'package:sharezone/navigation/logic/navigation_bloc.dart';
import 'package:sharezone/navigation/models/navigation_item.dart';
import 'package:sharezone/navigation/scaffold/app_bar_configuration.dart';
import 'package:sharezone/navigation/scaffold/sharezone_main_scaffold.dart';
import 'package:sharezone/sharezone_plus/subscription_service/subscription_flag.dart';
import 'package:sharezone/timetable/src/widgets/events/calender_event_card.dart';
import 'package:sharezone/timetable/src/widgets/events/event_view.dart';
import 'package:sharezone/timetable/timetable_page/timetable_page.dart';
Expand Down Expand Up @@ -49,7 +52,10 @@ class _CalendricalEventsPageState extends State<CalendricalEventsPage> {
bloc: bloc,
child: SharezoneMainScaffold(
appBarConfiguration: const AppBarConfiguration(
actions: [_LayoutIconButton()],
actions: [
_PastEventsIconButton(),
_LayoutIconButton(),
],
),
body: const _CalendricalEventsPageBody(),
floatingActionButton: _EventListFAB(),
Expand All @@ -60,6 +66,34 @@ class _CalendricalEventsPageState extends State<CalendricalEventsPage> {
}
}

class _PastEventsIconButton extends StatelessWidget {
const _PastEventsIconButton();

void logAnalytics(BuildContext context) {
final bloc = BlocProvider.of<CalendricalEventsPageBloc>(context);
bloc.logPastEventsPageOpened();
}

@override
Widget build(BuildContext context) {
final isSharezonePlusEnabled =
context.watch<SubscriptionEnabledFlag>().isEnabled;

if (!isSharezonePlusEnabled) {
return const SizedBox();
}

return IconButton(
tooltip: 'Vergangene Termine',
onPressed: () {
logAnalytics(context);
Navigator.pushNamed(context, PastCalendricalEventsPage.tag);
},
icon: const Icon(Icons.history),
);
}
}

class _LayoutIconButton extends StatefulWidget {
const _LayoutIconButton();

Expand Down
Loading

0 comments on commit 460dba4

Please sign in to comment.