Skip to content

Commit

Permalink
Account page setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Des-cloud committed Apr 23, 2021
1 parent b1bede2 commit f082df6
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 10 deletions.
42 changes: 32 additions & 10 deletions lib/app/account/account_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:time_tracker/services/Authentication.dart';
import 'package:time_tracker/widgets/alertDialog.dart';
import 'package:time_tracker/widgets/avatar.dart';

class AccountPage extends StatelessWidget {

Expand All @@ -23,25 +25,45 @@ class AccountPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
final auth= Provider.of<AuthBaseClass>(context, listen: false);
User user= auth.currentUser;
return Scaffold(
appBar: AppBar(
title: Text("Account"),
centerTitle: true,
elevation: 2.0,
actions: [
TextButton(
onPressed: ()=>confirmSignOut(context),
child: Text(
"Logout",
style: TextStyle(
fontSize: 18.0,
color: Colors.white,
fontWeight: FontWeight.w500,
letterSpacing: 1.5,
Padding(
padding: EdgeInsets.only(right: 10),
child: IconButton(
icon: Icon(
Icons.logout,
color: Colors.white,
size: 30.0,
semanticLabel: "Logout",
),
onPressed: ()=>confirmSignOut(context),
),
),
),
],
bottom: PreferredSize(
preferredSize: Size.fromHeight(130),
child: Column(
children: [
Avatar(
photoUrl: user.photoURL,
radius: 50.0,
),
SizedBox(height: 10.0,),
if(user.displayName!=null)
Text(
user.displayName,
style: TextStyle(color: Colors.white, fontSize: 20.0),
),
SizedBox(height: 8,),
],
),
),
),
body: _buildBody(context),
// floatingActionButton: FloatingActionButton(
Expand Down
29 changes: 29 additions & 0 deletions lib/widgets/avatar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:flutter/material.dart';

class Avatar extends StatelessWidget {
Avatar({this.photoUrl, @required this.radius});

final String photoUrl;
final double radius;

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.white54,
width: 3.0,
)
),
child: CircleAvatar(
radius: radius,
backgroundColor: Colors.black12,
backgroundImage: photoUrl != null ? NetworkImage(photoUrl): null,
child: photoUrl == null? Icon(
Icons.camera_alt,
): null,
),
);
}
}

0 comments on commit f082df6

Please sign in to comment.