Edit User profile
This commit is contained in:
+60
-36
@@ -1,9 +1,12 @@
|
||||
import 'package:firebase_auth/firebase_auth.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:le_kiosque_by_gcs/model/magazine.dart';
|
||||
import 'package:le_kiosque_by_gcs/model/user.dart';
|
||||
import 'package:le_kiosque_by_gcs/services/firestore/user_service.dart';
|
||||
import 'package:le_kiosque_by_gcs/ui/custom/item_mag_large.dart';
|
||||
import 'package:le_kiosque_by_gcs/ui/custom/profile_picture.dart';
|
||||
import 'package:le_kiosque_by_gcs/ui/view/edit_profil.dart';
|
||||
import 'package:le_kiosque_by_gcs/ui/view/editprofile/edit_profil.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ProfileView extends StatefulWidget {
|
||||
@override
|
||||
@@ -92,48 +95,69 @@ class _ProfileViewState extends State<ProfileView> {
|
||||
}
|
||||
|
||||
Widget _buildProfileHeader() {
|
||||
final imageUrl = FirebaseAuth.instance.currentUser.photoURL;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: ProfilePicture(imageUrl: imageUrl),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Eric Ampire",
|
||||
style: TextStyle(
|
||||
fontSize: 26,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Icon(
|
||||
Icons.location_on,
|
||||
color: Color(0xFFA5A5A5),
|
||||
size: 17,
|
||||
),
|
||||
final userService = Provider.of<UserService>(context, listen: false);
|
||||
return StreamBuilder<KiosqueUser>(
|
||||
stream: userService.getCurrentUser(FirebaseAuth.instance.currentUser.uid),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Text("Une erreur s'est produite"),
|
||||
),
|
||||
Text(
|
||||
"Lubumbashi",
|
||||
style: TextStyle(color: Colors.grey),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
if (snapshot.hasData) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: ProfilePicture(imageUrl: snapshot.data.profileUrl),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
snapshot.data.displayName,
|
||||
style: TextStyle(
|
||||
fontSize: 26,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Icon(
|
||||
Icons.location_on,
|
||||
color: Color(0xFFA5A5A5),
|
||||
size: 17,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
snapshot.data.city ?? "No location",
|
||||
style: TextStyle(color: Colors.grey),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_showEditProfileView(BuildContext context) {
|
||||
final userService = Provider.of<UserService>(context, listen: false);
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (BuildContext context) => EditProfileView(),
|
||||
builder: (BuildContext context) => EditProfileView(userService: userService),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user