navigationBar method Null safety
Creates a navigation bar that contains a title
, if there should be a
goBack
button or not and if there should be a logout
button or not.
Returns a Center
widget.
Implementation
static Center navigationBar(String title, bool goBack, bool logout, BuildContext context){
SizedBox logoutButton = SizedBox(
width: Sizes.getPixelSizeWidth(0.2430724356, context),
);
SizedBox goBackButton = SizedBox(
width: Sizes.getPixelSizeWidth(0.2430724356, context),
);
if(logout){
logoutButton = SizedBox(
height: Sizes.getPixelSize(0.0576435324, context),
width: Sizes.getPixelSizeWidth(0.2430724356, context),
child: GestureDetector(
onTap: () async {
FirebaseAuth authInstance = FirebaseAuth.instance;
authInstance.signOut();
Navigator.push(context, MaterialPageRoute(builder: (context) {
return const LoginPage(title: 'Login');
}));},
child: Image(image: const AssetImage('assets/icons/logoutIcon.png'), width: Sizes.getPixelSizeWidth(0.2430724356, context), height: Sizes.getPixelSize(0.0576435324, context)),
)
);
}
if(goBack){
goBackButton = SizedBox(
height: Sizes.getPixelSize(0.0576435324, context),
width: Sizes.getPixelSizeWidth(0.2430724356, context),
child: GestureDetector(
onTap: () {Navigator.push(context, MaterialPageRoute(builder: (context) {
return const MainMenuPage(title: 'MainMenu');
}));},
child: Image(image: const AssetImage('assets/icons/goBackIcon.png'), width: Sizes.getPixelSizeWidth(0.1215362178, context), height: Sizes.getPixelSize(0.0576435324, context)),
)
);
}
return Center(
child: Column(
children: [
SizedBox(
height: Sizes.getPixelSize(0.0576435324, context),
),
Row(
children: [
goBackButton,
Expanded(child: Center(child: SizedBox(
height: Sizes.getPixelSize(0.0576435324, context),
child: Text(title, style: (Sizes.getScreenSize(context).width > 400) ? Theme.of(context).textTheme.headline6: Texts.getStyle("headline6")),
))),
logoutButton
],
),
SizedBox(
height: Sizes.getPixelSize(0.02305741296, context),
),
SizedBox(
height: 1,
width: Sizes.getScreenSize(context).width * 0.8,
child: const DecoratedBox(
decoration: BoxDecoration(
color: Colors.white
),
),
)
]
),
);
}