-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move logout to settings Co-authored-by: Alisa Vynohradova <[email protected]> * Style NavigationRail in Settings Co-authored-by: Alisa Vynohradova <[email protected]> * Add settings for regular users Co-authored-by: Alisa Vynohradova <[email protected]> * Fix logout for mobile Co-authored-by: Alisa Vynohradova <[email protected]> * Extract logout button Co-authored-by: Alisa Vynohradova <[email protected]> * Fix tests --------- Co-authored-by: Alisa Vynohradova <[email protected]>
- Loading branch information
1 parent
cef1450
commit 6a1edfa
Showing
4 changed files
with
136 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:firebase_auth/firebase_auth.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class LogoutButton extends StatelessWidget { | ||
final bool popOnSuccess; | ||
final bool iconOnly; | ||
const LogoutButton({super.key, this.popOnSuccess = false, this.iconOnly = false}); | ||
|
||
void _handleSignOut(BuildContext context) async { | ||
final auth = context.read<FirebaseAuth>(); | ||
await auth.signOut(); | ||
if (popOnSuccess) { | ||
Navigator.pop(context); | ||
} | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (iconOnly) { | ||
return IconButton( | ||
onPressed: () => _handleSignOut(context), | ||
icon: const Icon(Icons.logout), | ||
); | ||
} | ||
|
||
return ElevatedButton.icon( | ||
label: Text('Logout'), | ||
onPressed: () => _handleSignOut(context), | ||
icon: const Icon(Icons.logout), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters