Skip to content

Commit

Permalink
Account menu popup
Browse files Browse the repository at this point in the history
  • Loading branch information
william-herring committed Jan 8, 2022
1 parent 6b619cc commit 56e4072
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions client/lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ class HomeScreen extends StatelessWidget {
HomeScreen({Key? key}) : super(key: key);
Future<String> username = fetchUsername();

void _showUserMenu(context) async {
await showMenu(
context: context,
position: const RelativeRect.fromLTRB(double.infinity, double.negativeInfinity, 100, 100),
items: [
PopupMenuItem<String>(
child: Text('Settings', style: GoogleFonts.ubuntu()), value: 'Details'),
PopupMenuItem<String>(
child: Text('Log out', style: GoogleFonts.ubuntu()), value: 'Log out'),
],
elevation: 8.0,
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -41,14 +55,20 @@ class HomeScreen extends StatelessWidget {
future: username,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Row(
children: [
const Icon(Icons.account_circle_sharp, size: 30.0,),
Padding(
padding: const EdgeInsets.only(right: 16.0, left: 8.0),
child: Text(snapshot.data!.toString(), style: GoogleFonts.ubuntu(fontSize: 16))
),
],
return InkWell(
hoverColor: Colors.white.withOpacity(0),
onTap: () {
_showUserMenu(context);
},
child: Row(
children: [
const Icon(Icons.account_circle_sharp, size: 30.0,),
Padding(
padding: const EdgeInsets.only(right: 16.0, left: 8.0),
child: Text(snapshot.data!.toString(), style: GoogleFonts.ubuntu(fontSize: 16))
),
],
),
);
}
return const CircularProgressIndicator(color: Colors.deepPurpleAccent);
Expand Down

0 comments on commit 56e4072

Please sign in to comment.