mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00
Split AppBar Menu button into its own widget
Saves us the need to the GlobalKey as well.
This commit is contained in:
25
lib/widgets/app_bar_menu_button.dart
Normal file
25
lib/widgets/app_bar_menu_button.dart
Normal file
@ -0,0 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:badges/badges.dart';
|
||||
|
||||
import 'package:gitjournal/state_container.dart';
|
||||
|
||||
class GJAppBarMenuButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final container = StateContainer.of(context);
|
||||
final appState = container.appState;
|
||||
|
||||
bool shouldShowBadge =
|
||||
!appState.remoteGitRepoConfigured && appState.hasJournalEntries;
|
||||
var appBarMenuButton = BadgeIconButton(
|
||||
key: const ValueKey("DrawerButton"),
|
||||
icon: const Icon(Icons.menu),
|
||||
itemCount: shouldShowBadge ? 1 : 0,
|
||||
onPressed: () {
|
||||
Scaffold.of(context).openDrawer();
|
||||
},
|
||||
);
|
||||
|
||||
return appBarMenuButton;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user