Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change _DashboardPageFAB from StatefulWidget to StatelessWidget #1123

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/lib/dashboard/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _DashboardPageState extends State<DashboardPage> {
),
navigationItem: NavigationItem.overview,
body: const DashboardPageBody(),
floatingActionButton: _DashboardPageFAB(),
floatingActionButton: const _DashboardPageFAB(),
);
}
}
Expand Down
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