Skip to content
Snippets Groups Projects
Commit 92ecf463 authored by Daniel Furaev's avatar Daniel Furaev
Browse files

hamburger menu work und logout stuff

parent 8be82ee2
No related branches found
No related tags found
No related merge requests found
......@@ -87,6 +87,18 @@ class Spotify {
}
}
getUser() async {
try {
var response = await http.get(
Uri.parse("https://api.spotify.com/v1/me"),
headers: {HttpHeaders.authorizationHeader: authToken},
);
return response;
} catch (e) {
log(e.toString());
}
}
getUserAlbums() async {
try {
var response = await http.get(
......
// ignore_for_file: prefer_const_constructors
import 'package:ambient/services/spotify.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import '../loginRegister/login.dart';
import '../main.dart';
//Todo Daniel Sidebar
......@@ -11,17 +14,20 @@ class SettingsDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
Spotify spotify = Spotify();
var user = spotify.getUser();
return Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: [
UserAccountsDrawerHeader(
accountName: Text('Name'),
accountEmail: Text("Email"),
accountName: user['display_name'],
accountEmail: user['email'],
currentAccountPicture: CircleAvatar(
child: ClipOval(
child: Image.network(
"https://images.unsplash.com/photo-1438761681033-6461ffad8d80?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8cGVyc29ufGVufDB8fDB8fA%3D%3D&w=1000&q=80",
user['images'][0]['url'],
width: 90,
height: 90,
fit: BoxFit.cover,
......@@ -46,7 +52,10 @@ class SettingsDrawer extends StatelessWidget {
leading: Icon(Icons.exit_to_app),
title: Text('Abmelden'),
onTap: () {
//TODO: Abmelden
FirebaseAuth.instance.signOut().then((value) {
Navigator.push(context, MaterialPageRoute(builder:
(context) => LoginPage()));
});
},
)
],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment