-
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.
Add avatar with pertaining account info and signout functionality
- Loading branch information
1 parent
6aed752
commit 89b0908
Showing
4 changed files
with
306 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:memoree_client/app/services/firebase_auth.dart'; | ||
import 'package:memoree_client/app_scaffold.dart'; | ||
|
||
class LoginPage extends StatefulWidget { | ||
@override | ||
_LoginPageState createState() => _LoginPageState(); | ||
} | ||
|
||
class _LoginPageState extends State<LoginPage> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: SafeArea( | ||
child: Container( | ||
child: Center( | ||
child: Column( | ||
mainAxisSize: MainAxisSize.max, | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
FlutterLogo(size: 150), | ||
SizedBox(height: 50,), | ||
OutlineButton( | ||
splashColor: Colors.grey, | ||
onPressed: () { | ||
FirebaseAuthService().signInWithGoogle().then((user) { | ||
if (user != null) { | ||
Navigator.of(context).pop(); | ||
Navigator.of(context).push(MaterialPageRoute( | ||
builder: (context) { | ||
return AppScaffold(page: 'videos'); | ||
}, | ||
),); | ||
} | ||
}); | ||
}, | ||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)), | ||
highlightElevation: 0, | ||
borderSide: BorderSide(color: Colors.grey), | ||
child: Padding( | ||
padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), | ||
child: Row( | ||
mainAxisSize: MainAxisSize.min, | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
Image(image: AssetImage("logos/google_logo.png"), height: 30.0), | ||
Padding( | ||
padding: const EdgeInsets.only(left: 10.0), | ||
child: Text("Sign in with Google") | ||
), | ||
], | ||
), | ||
), | ||
), | ||
] | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
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,103 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:memoree_client/app/services/firebase_auth.dart'; | ||
import 'package:memoree_client/app_scaffold.dart'; | ||
import 'package:memoree_client/pages/login.dart'; | ||
|
||
class AccountInfo extends StatefulWidget { | ||
@override | ||
_AccountInfoState createState() => _AccountInfoState(); | ||
} | ||
|
||
class _AccountInfoState extends State<AccountInfo> { | ||
@override | ||
Widget build(BuildContext context) { | ||
// return Container( | ||
// child: Center( | ||
// child: Column( | ||
// mainAxisSize: MainAxisSize.min, | ||
// children: <Widget>[ | ||
// CircleAvatar( | ||
// radius: 30, | ||
// child: ClipOval( | ||
// child: Image.network(widget.photoUrl, fit: BoxFit.cover), | ||
// ), | ||
// ) | ||
// ], | ||
// ) | ||
// ), | ||
// ); | ||
|
||
return FutureBuilder( | ||
future: FirebaseAuthService().currentUser(), | ||
builder: (context, snapshot) { | ||
switch (snapshot.connectionState) { | ||
case ConnectionState.none: | ||
case ConnectionState.waiting: | ||
return Padding( | ||
padding: const EdgeInsets.all(20.0), | ||
child: Center(child: CircularProgressIndicator()), | ||
); | ||
break; | ||
case ConnectionState.active: | ||
case ConnectionState.done: | ||
return Padding( | ||
padding: const EdgeInsets.all(20.0), | ||
child: Column( | ||
mainAxisSize: MainAxisSize.min, | ||
children: <Widget>[ | ||
CircleAvatar( | ||
radius: 35, | ||
child: ClipOval( | ||
child: Image.network(snapshot.data.photoUrl, fit: BoxFit.cover) | ||
), | ||
), | ||
SizedBox(height: 20,), | ||
Text(snapshot.data.displayName, textScaleFactor: 1.25), | ||
Text(snapshot.data.email, style: TextStyle(color: Colors.black54,)), | ||
SizedBox(height: 20,), | ||
Divider(thickness: 1,), | ||
SizedBox(height: 15,), | ||
OutlineButton( | ||
// padding: const EdgeInsets.only(top: 20.0), | ||
splashColor: Colors.grey, | ||
onPressed: () async { | ||
await FirebaseAuthService().signOut(); | ||
Navigator.of(context).pop(); | ||
Navigator.of(context).push(MaterialPageRoute( | ||
builder: (context) { | ||
return LoginPage(); | ||
})); | ||
}, | ||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)), | ||
highlightElevation: 0, | ||
borderSide: BorderSide(color: Colors.grey), | ||
child: Padding( | ||
padding: const EdgeInsets.all(10), | ||
child: Text("Sign out", textScaleFactor: 1.1,) | ||
), | ||
// child: Padding( | ||
// padding: const EdgeInsets.only(top: 10.0, bottom: 10.0), | ||
// child: Row( | ||
// mainAxisSize: MainAxisSize.min, | ||
// mainAxisAlignment: MainAxisAlignment.center, | ||
// children: <Widget>[ | ||
// Image(image: AssetImage("logos/google_logo.png"), height: 30.0), | ||
// Padding( | ||
// padding: const EdgeInsets.only(left: 10.0), | ||
// child: Text("Sign in with Google") | ||
// ), | ||
// ], | ||
// ), | ||
// ), | ||
), | ||
], | ||
), | ||
); | ||
break; | ||
} | ||
return Center(); | ||
} | ||
); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,75 +1,139 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:memoree_client/constants.dart'; | ||
import 'package:memoree_client/search.dart'; | ||
|
||
class CustomAppBar extends StatefulWidget with PreferredSizeWidget { | ||
final bool isMobile, isTablet; | ||
|
||
CustomAppBar({Key key, @required this.isMobile, @required this.isTablet}) : super(key : key); | ||
|
||
@override | ||
_CustomAppBarState createState() => _CustomAppBarState(); | ||
|
||
@override | ||
Size get preferredSize => Size.fromHeight(kToolbarHeight); | ||
} | ||
|
||
class _CustomAppBarState extends State<CustomAppBar> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return AppBar( | ||
toolbarHeight: 65, | ||
elevation: 1, | ||
// automaticallyImplyLeading: false, | ||
flexibleSpace: Container(), | ||
centerTitle: true, | ||
title: Row( | ||
children: <Widget>[ | ||
Text(PageTitles.appName), | ||
if(!widget.isTablet) | ||
Flexible( | ||
flex: 5, | ||
child: Container( | ||
constraints: BoxConstraints(minWidth: 100, maxWidth: 900), | ||
padding: const EdgeInsets.all(100.0), | ||
child: SearchWidget(), | ||
) | ||
), | ||
// Expanded(flex: 2, child: Container()) | ||
], | ||
), | ||
actions: <Widget>[ | ||
if(widget.isTablet) | ||
Container( | ||
padding: const EdgeInsets.only(right: 10.0, left: 10.0), | ||
child: IconButton( | ||
icon: const Icon(Icons.search_outlined), | ||
tooltip: ActionNames.search, | ||
splashRadius: 25, | ||
onPressed: () => {}, | ||
) | ||
), | ||
Container( | ||
padding: const EdgeInsets.only(right: 10.0, left: 10.0), | ||
child: IconButton( | ||
icon: const Icon(Icons.cloud_upload_outlined), | ||
tooltip: ActionNames.upload, | ||
splashRadius: 25, | ||
onPressed: () => {} | ||
), | ||
), | ||
if(!widget.isMobile) | ||
Container( | ||
padding: const EdgeInsets.only(right: 10.0, left: 10.0), | ||
child: IconButton( | ||
icon: const Icon(Icons.settings_outlined), | ||
tooltip: ActionNames.settings, | ||
splashRadius: 25, | ||
onPressed: () => {} | ||
), | ||
), | ||
Container(padding: const EdgeInsets.all(5.0)), | ||
] | ||
); | ||
} | ||
} | ||
import 'package:flutter/material.dart'; | ||
import 'package:memoree_client/app/services/firebase_auth.dart'; | ||
import 'package:memoree_client/constants.dart'; | ||
import 'package:memoree_client/search.dart'; | ||
import 'package:memoree_client/widgets/account_info.dart'; | ||
|
||
class CustomAppBar extends StatefulWidget with PreferredSizeWidget { | ||
final bool isMobile, isTablet; | ||
|
||
CustomAppBar({Key key, @required this.isMobile, @required this.isTablet}) | ||
: super(key: key); | ||
|
||
@override | ||
_CustomAppBarState createState() => _CustomAppBarState(); | ||
|
||
@override | ||
Size get preferredSize => Size.fromHeight(kToolbarHeight); | ||
} | ||
|
||
class _CustomAppBarState extends State<CustomAppBar> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return AppBar( | ||
toolbarHeight: 65, | ||
elevation: 1, | ||
// automaticallyImplyLeading: false, | ||
flexibleSpace: Container(), | ||
centerTitle: true, | ||
title: Row( | ||
children: <Widget>[ | ||
Text(PageTitles.appName), | ||
if (!widget.isTablet) | ||
Flexible( | ||
flex: 5, | ||
child: Container( | ||
constraints: BoxConstraints(minWidth: 100, maxWidth: 900), | ||
padding: const EdgeInsets.all(100.0), | ||
child: SearchWidget(), | ||
)), | ||
// Expanded(flex: 2, child: Container()) | ||
], | ||
), | ||
actions: <Widget>[ | ||
if (widget.isTablet) | ||
Container( | ||
padding: const EdgeInsets.only(right: 10.0, left: 10.0), | ||
child: IconButton( | ||
icon: const Icon(Icons.search_outlined), | ||
tooltip: ActionNames.search, | ||
splashRadius: 25, | ||
onPressed: () => {}, | ||
)), | ||
Container( | ||
padding: const EdgeInsets.only(right: 10.0, left: 10.0), | ||
child: IconButton( | ||
icon: const Icon(Icons.cloud_upload_outlined), | ||
tooltip: ActionNames.upload, | ||
splashRadius: 25, | ||
onPressed: () => {}), | ||
), | ||
if (!widget.isMobile) | ||
Container( | ||
padding: const EdgeInsets.only(right: 10.0, left: 10.0), | ||
child: IconButton( | ||
icon: const Icon(Icons.settings_outlined), | ||
tooltip: ActionNames.settings, | ||
splashRadius: 25, | ||
onPressed: () => {}), | ||
), | ||
if (!widget.isMobile) | ||
Container( | ||
padding: const EdgeInsets.only(right: 10.0, left: 10.0), | ||
decoration: BoxDecoration( | ||
shape: BoxShape.circle, | ||
), | ||
child: FutureBuilder( | ||
future: FirebaseAuthService().currentUser(), | ||
builder: (context, snapshot) { | ||
switch (snapshot.connectionState) { | ||
case ConnectionState.none: | ||
case ConnectionState.waiting: | ||
return Center(child: CircularProgressIndicator()); | ||
break; | ||
case ConnectionState.active: | ||
case ConnectionState.done: | ||
return Material( | ||
color: Colors.transparent, | ||
child: InkWell( | ||
onTap: () { | ||
showDialog( | ||
context: context, | ||
barrierColor: Colors.transparent, | ||
barrierDismissible: true, | ||
builder: (context) { | ||
return Align( | ||
alignment: Alignment(0.98, -0.84), | ||
child: Material( | ||
shape: | ||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)), | ||
child: Container( | ||
width: 300, | ||
decoration: BoxDecoration( | ||
color: Colors.white, | ||
borderRadius: BorderRadius.circular(5.0), | ||
boxShadow: [ | ||
BoxShadow(blurRadius: 1.0), | ||
] | ||
), | ||
child: AccountInfo(), | ||
), | ||
), | ||
); | ||
} | ||
); | ||
}, | ||
splashColor: Colors.grey, | ||
customBorder: CircleBorder(), | ||
child: Tooltip( | ||
message: "Google Account\n" + snapshot.data.displayName + "\n" + snapshot.data.email, | ||
padding: const EdgeInsets.all(2.0), | ||
child: CircleAvatar( | ||
radius: 15, | ||
child: ClipOval( | ||
child: Image.network(snapshot.data.photoUrl, fit: BoxFit.cover), | ||
), | ||
), | ||
), | ||
) | ||
); | ||
break; | ||
} | ||
return Container(); | ||
}, | ||
), | ||
), | ||
Container(padding: const EdgeInsets.all(5.0)), | ||
]); | ||
} | ||
} |