Skip to content

Commit

Permalink
Change _DashboardPageFAB from StatefulWidget to StatelessWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsreichardt committed Oct 11, 2023
1 parent d8b21f1 commit d6ac66b
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions app/lib/dashboard/widgets/dashboard_fab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,10 @@ part of '../dashboard_page.dart';

enum _DashboardFabResult { homework, exam, event, lesson, blackboard }

class _DashboardPageFAB extends StatefulWidget {
@override
_DashboardPageFABState createState() => _DashboardPageFABState();
}

class _DashboardPageFABState extends State<_DashboardPageFAB> {
bool open = false;
class _DashboardPageFAB extends StatelessWidget {
const _DashboardPageFAB();

@override
Widget build(BuildContext context) {
return MatchingTypeOfUserBuilder(
expectedTypeOfUser: TypeOfUser.parent,
matchesTypeOfUserWidget: Container(),
notMatchingWidget: ModalFloatingActionButton(
heroTag: 'sharezone-fab',
tooltip: 'Neue Elemente hinzufügen',
label: 'Hinzufügen',
icon: const Icon(Icons.add),
onPressed: () => openDashboardFabSheet(context),
),
);
}

Future<void> openDashboardFabSheet(BuildContext buildContext) async {
Future<void> openDashboardFabSheet(BuildContext context) async {
final analytics = DashboardAnalytics(Analytics(getBackend()));
analytics.logOpenFabSheet();

Expand Down Expand Up @@ -70,6 +50,21 @@ class _DashboardPageFABState extends State<_DashboardPageFAB> {
break;
}
}

@override
Widget build(BuildContext context) {
return MatchingTypeOfUserBuilder(
expectedTypeOfUser: TypeOfUser.parent,
matchesTypeOfUserWidget: Container(),
notMatchingWidget: ModalFloatingActionButton(
heroTag: 'sharezone-fab',
tooltip: 'Neue Elemente hinzufügen',
label: 'Hinzufügen',
icon: const Icon(Icons.add),
onPressed: () => openDashboardFabSheet(context),
),
);
}
}

class _DashboardFabSheet extends StatelessWidget {
Expand Down

0 comments on commit d6ac66b

Please sign in to comment.