Google sign in and hourglass improved

This commit is contained in:
Sewmina
2022-03-24 05:05:18 +05:30
parent 9f976b1e33
commit 2fe29dcbb8
13 changed files with 560 additions and 307 deletions

View File

@@ -51,7 +51,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.Xperience.TaskTracker" applicationId "com.Xperience.TaskTracker"
//minSdkVersion flutter.minSdkVersion //minSdkVersion flutter.minSdkVersion
minSdkVersion 19 minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion targetSdkVersion flutter.targetSdkVersion
multiDexEnabled true multiDexEnabled true
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()

View File

@@ -1,20 +1,28 @@
{ {
"project_info": { "project_info": {
"project_number": "584018031136", "project_number": "467872790335",
"project_id": "timetracker-a8929", "project_id": "tasktracker-7410e",
"storage_bucket": "timetracker-a8929.appspot.com" "storage_bucket": "tasktracker-7410e.appspot.com"
}, },
"client": [ "client": [
{ {
"client_info": { "client_info": {
"mobilesdk_app_id": "1:584018031136:android:26bd0f616e44f68e24c245", "mobilesdk_app_id": "1:467872790335:android:6c8bd5c0f686020ce3458a",
"android_client_info": { "android_client_info": {
"package_name": "com.Xperience.TaskTracker" "package_name": "com.Xperience.TaskTracker"
} }
}, },
"oauth_client": [ "oauth_client": [
{ {
"client_id": "584018031136-nb4gih6j5qhfgffgatac4ti0v7093u0l.apps.googleusercontent.com", "client_id": "467872790335-bcau5rdl2g0ak05s0pmn3i348c4v8jkq.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.Xperience.TaskTracker",
"certificate_hash": "2eac2630fe23e5bf4e73555ba8323897e43fe174"
}
},
{
"client_id": "467872790335-tp7h910ii82ms2ejrkpipihdvka66keg.apps.googleusercontent.com",
"client_type": 1, "client_type": 1,
"android_info": { "android_info": {
"package_name": "com.Xperience.TaskTracker", "package_name": "com.Xperience.TaskTracker",
@@ -22,28 +30,20 @@
} }
}, },
{ {
"client_id": "584018031136-qcbe59kej60t3tua14ou979nokjp1ant.apps.googleusercontent.com", "client_id": "467872790335-s2ebnuf2m0ihq3008oob5c2q6fh14lob.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.Xperience.TaskTracker",
"certificate_hash": "a616913ffe4e775a7db60d095f0de447def5ced7"
}
},
{
"client_id": "584018031136-95qsgo6ps7afapsjivnd7dohvbj6dl7k.apps.googleusercontent.com",
"client_type": 3 "client_type": 3
} }
], ],
"api_key": [ "api_key": [
{ {
"current_key": "AIzaSyBM3WEkuPJLS7mUN3TgAlPRJAHlburepBA" "current_key": "AIzaSyAp0V5OPWGMG3tCX2teZQL6Zd2RcS9ubIg"
} }
], ],
"services": { "services": {
"appinvite_service": { "appinvite_service": {
"other_platform_oauth_client": [ "other_platform_oauth_client": [
{ {
"client_id": "584018031136-95qsgo6ps7afapsjivnd7dohvbj6dl7k.apps.googleusercontent.com", "client_id": "467872790335-s2ebnuf2m0ihq3008oob5c2q6fh14lob.apps.googleusercontent.com",
"client_type": 3 "client_type": 3
} }
] ]

View File

@@ -69,7 +69,7 @@ class HourglassPainter extends CustomPainter{
topContent.close(); topContent.close();
final bottomContent = Path(); final bottomContent = Path();
double bottomStartHeight = size.height-hourglassInset; double bottomStartHeight = size.height-12;
double bottomEndHeight = size.height * (0.95 - (fillAmount * 0.32)); double bottomEndHeight = size.height * (0.95 - (fillAmount * 0.32));
double bottomContentStartWidthOffset = getBottomContentWidthOffset(size.width, bottomStartHeight, hourglassHalfHeight, hourglassInset); double bottomContentStartWidthOffset = getBottomContentWidthOffset(size.width, bottomStartHeight, hourglassHalfHeight, hourglassInset);
double bottomContentEndWidthOffset = getBottomContentWidthOffset(size.width, bottomEndHeight, hourglassHalfHeight, hourglassInset); double bottomContentEndWidthOffset = getBottomContentWidthOffset(size.width, bottomEndHeight, hourglassHalfHeight, hourglassInset);
@@ -92,16 +92,18 @@ class HourglassPainter extends CustomPainter{
fallingSand.close(); fallingSand.close();
final gradient = ui.Gradient.linear( final gradient = ui.Gradient.linear(
Offset(size.width/2, size.height * 0.9), Offset(size.width/2, bottomStartHeight - 1),
Offset(size.width/2, bottomEndHeight + size.height *0.07), Offset(size.width/2, bottomEndHeight),
colors, colors,
colorStops); colorStops,
TileMode.clamp);
final bottomContentPainter = Paint() final bottomContentPainter = Paint()
..shader=gradient ..shader=gradient
..style=PaintingStyle.fill ..style=PaintingStyle.fill
..strokeCap=StrokeCap.round ..strokeCap=StrokeCap.round
..strokeWidth=1; ..strokeWidth=1;
print('bottom: $bottomStartHeight, top: $bottomEndHeight');
canvas.drawPath(fallingSand, contentPainter); canvas.drawPath(fallingSand, contentPainter);
canvas.drawPath(topContent, contentPainter); canvas.drawPath(topContent, contentPainter);

View File

@@ -55,7 +55,7 @@ class _NewProjectState extends State<NewProject> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text('New Project')), appBar: AppBar(title: Text('${(editing) ? 'Edit' : 'New'} Project')),
body: Container( body: Container(
height: MediaQuery.of(context).size.height, height: MediaQuery.of(context).size.height,
child: Column(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ child: Column(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
@@ -501,7 +501,7 @@ class _NewProject2State extends State<NewProject2> {
onPressed: () { onPressed: () {
OnClickAdd(); OnClickAdd();
}, },
child: Text('Next', style: TextStyle(fontSize: 20))))), child: Text((editing) ? 'Apply' : 'Add', style: TextStyle(fontSize: 20))))),
], ],
)) ))
]))); ])));

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:tasktracker/NewCategory.dart';
import 'User.dart' as User; import 'User.dart' as User;
DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss"); DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss");
@@ -15,6 +16,7 @@ class NewTask extends StatefulWidget {
List<String> getCategoryNames(){ List<String> getCategoryNames(){
List<String> _cats = []; List<String> _cats = [];
_cats.add('+Add New Category');
User.categories.forEach((element) { User.categories.forEach((element) {
String name = element.name; String name = element.name;
_cats.add(name); _cats.add(name);
@@ -84,8 +86,15 @@ class _NewTaskState extends State<NewTask> {
); );
}).toList(), }).toList(),
onChanged: (String? _value) { onChanged: (String? _value) {
if(_value != null) {
if (_value.contains("+Add New Category")) {
Navigator.of(context).push(MaterialPageRoute(builder: (context)=>NewCategory()));
}else{
selectedCat = _value!;
}
}
setState(() { setState(() {
selectedCat = _value!;
}); });
})), })),
Container( Container(

View File

@@ -0,0 +1,67 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tasktracker/Data.dart';
import 'package:tasktracker/googleSignIn.dart';
import 'package:restart_app/restart_app.dart';
class AccountSettings extends StatefulWidget {
const AccountSettings({Key? key}) : super(key: key);
@override
_AccountSettingsState createState() => _AccountSettingsState();
}
class _AccountSettingsState extends State<AccountSettings> {
@override void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (context)=>GoogleSignInProvider(),
builder: (context, snapshot) {
return Scaffold(
appBar: AppBar(title: Row(
children: [
FaIcon(FontAwesomeIcons.user),
SizedBox(width: 15,),
Text("Account Settings"),
],
)),
body: SafeArea(
child: Column(
children: [
SizedBox(
height: 10,
),
ListTile(
leading: FaIcon(FontAwesomeIcons.signOut),
title: Text("Log out",style:TextStyle(color: Colors.red)),
subtitle: Row(
children: [
Text("Good-bye"),
],
),
onTap: () async{
final provider = Provider.of<GoogleSignInProvider>(context, listen:false);
provider.logout();
final prefs = await SharedPreferences.getInstance();
await prefs.clear();
Restart.restartApp(webOrigin: '/splash');
},
),
],
),
),
);
}
);
}
}

View File

@@ -1,8 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:tasktracker/Settings/AccountSettings.dart';
import 'package:tasktracker/Settings/AppearanceSettings.dart'; import 'package:tasktracker/Settings/AppearanceSettings.dart';
import 'package:tasktracker/Settings/NotificationSettings.dart'; import 'package:tasktracker/Settings/NotificationSettings.dart';
import 'package:tasktracker/Settings/BehaviourSettings.dart'; import 'package:tasktracker/Settings/BehaviourSettings.dart';
import 'package:tasktracker/main.dart'; import 'package:tasktracker/main.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class SettingsPage extends StatefulWidget { class SettingsPage extends StatefulWidget {
const SettingsPage({Key? key}) : super(key: key); const SettingsPage({Key? key}) : super(key: key);
@@ -15,33 +18,51 @@ class _SettingsPageState extends State<SettingsPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text('Settings')), appBar: AppBar(title: Row(
children: [
FaIcon(FontAwesomeIcons.cog),
SizedBox(width: 15,),
Text('Settings'),
],
)),
body: Column( body: Column(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: [ children: [
ListTile( ListTile(
leading: FaIcon(FontAwesomeIcons.paintbrush),
title: Text('Appearance'), title: Text('Appearance'),
subtitle: Text('Just the looks and feels'), subtitle: Text('Just the looks and feels'),
trailing: Icon(Icons.arrow_forward_ios), // trailing: Icon(Icons.arrow_forward_ios),
onTap: (){ onTap: (){
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const AppearanceSettings())); Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const AppearanceSettings()));
}, },
), ),
ListTile( ListTile(
leading: FaIcon(FontAwesomeIcons.bell),
title: Text('Notifications'), title: Text('Notifications'),
subtitle: Text("Don't worry, We won't let you forget"), subtitle: Text("Don't worry, We won't let you forget"),
trailing: Icon(Icons.arrow_forward_ios), // trailing: Icon(Icons.arrow_forward_ios),
onTap: (){ onTap: (){
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const NotificationSettings())); Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const NotificationSettings()));
}, },
), ),
ListTile( ListTile(
leading: FaIcon(FontAwesomeIcons.cogs),
title:Text("General Behaviour"), title:Text("General Behaviour"),
subtitle: Text("Wanna change how the app works? Go ahead!"), subtitle: Text("Wanna change how the app works? Go ahead!"),
trailing: Icon(Icons.arrow_forward_ios), // trailing: Icon(Icons.arrow_forward_ios),
onTap: (){ onTap: (){
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const BehaviourSettings())); Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const BehaviourSettings()));
}, },
),
ListTile(
leading: FaIcon(FontAwesomeIcons.user),
title:Text("Account Settings"),
subtitle: Text("Login preferences"),
// trailing: Icon(Icons.arrow_forward_ios),
onTap: (){
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const AccountSettings()));
},
) )
// SettingItem('Appearance', ()=>Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const AppearanceSettings()))), // SettingItem('Appearance', ()=>Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const AppearanceSettings()))),
// Divider(), // Divider(),

View File

@@ -1,7 +1,9 @@
import 'dart:ui'; import 'dart:ui';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:tasktracker/googleSignIn.dart';
import 'User.dart' as Users; import 'User.dart' as Users;
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
class WelcomePage extends StatefulWidget { class WelcomePage extends StatefulWidget {
@@ -85,71 +87,71 @@ class SignInPage extends StatefulWidget {
class _SignInPageState extends State<SignInPage> { class _SignInPageState extends State<SignInPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SafeArea( return SafeArea(
child: Scaffold( child: Scaffold(
body: Container( body: Container(
color: Colors.deepPurpleAccent, color: Colors.deepPurpleAccent,
child: Flex( child: Flex(
direction: Axis.vertical, direction: Axis.vertical,
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Expanded( Expanded(
flex: 2, flex: 2,
child: Container( child: Container(
padding: EdgeInsets.fromLTRB(0, 100, 0, 0), padding: EdgeInsets.fromLTRB(0, 100, 0, 0),
height: 400, height: 400,
child: child:
Image(image: AssetImage('images/signin.png'))), Image(image: AssetImage('images/signin.png'))),
), ),
Expanded( Expanded(
flex:1, flex:1,
child: Padding( child: Padding(
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text("Sign in to stay connected", Text("Sign in to stay connected",
style: TextStyle( style: TextStyle(
fontSize: 30, fontSize: 30,
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold)),
Divider(), Divider(),
Text( Text(
"Sign in and enjoy the flawless connection between all your devices. You can track your day from any device and keep it together.") "Sign in and enjoy the flawless connection between all your devices. You can track your day from any device and keep it together.")
], ],
), ),
)), )),
Container( Container(
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: Row( child: Row(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
ElevatedButton( ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: Colors.red), primary: Colors.red),
onPressed: () { onPressed: () {
Navigator.of(context).push( Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
builder: (context) => builder: (context) =>
const offlineLoginPage())); const offlineLoginPage()));
}, },
child: Text('Use Offline', child: Text('Use Offline',
style: TextStyle(fontSize: 20))), style: TextStyle(fontSize: 20))),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
Navigator.of(context).push( Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
builder: (context) => builder: (context) =>
const onlineLoginPage())); const onlineLoginPage()));
}, },
child: Text('Next', child: Text('Next',
style: TextStyle(fontSize: 20))) style: TextStyle(fontSize: 20)))
], ],
)) ))
])))); ]))));
} }
} }
@@ -174,224 +176,238 @@ class _onlineLoginPageState extends State<onlineLoginPage>
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) => ChangeNotifierProvider(
return SafeArea( create:(context)=>GoogleSignInProvider(),
child: Scaffold( builder: (context, snapshot) {
body: Container( return SafeArea(
color: Colors.purpleAccent, child: Scaffold(
child: Flex( body: Container(
direction: Axis.vertical, color: Colors.purpleAccent,
mainAxisSize: MainAxisSize.max, child: Flex(
mainAxisAlignment: MainAxisAlignment.spaceBetween, direction: Axis.vertical,
children: [ mainAxisSize: MainAxisSize.max,
// Container( mainAxisAlignment: MainAxisAlignment.spaceBetween,
// padding: EdgeInsets.all(20), children: [
// alignment: Alignment.centerLeft, // Container(
// child: Text( // padding: EdgeInsets.all(20),
// 'Sign in online', // alignment: Alignment.centerLeft,
// style: TextStyle( // child: Text(
// fontSize: 40, fontWeight: FontWeight.bold), // 'Sign in online',
// textAlign: TextAlign.left, // style: TextStyle(
// ), // fontSize: 40, fontWeight: FontWeight.bold),
// ), // textAlign: TextAlign.left,
Expanded( // ),
// ),
Expanded(
child: Container( child: Container(
child: child:
Image(image: AssetImage('images/signin.png'))), Image(image: AssetImage('images/signin.png'))),
), ),
Container( Container(
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: Column(children: [ child: Column(children: [
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
color: Colors.purple), color: Colors.purple),
child: Padding( child: Padding(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
child: TabBar( child: TabBar(
controller: _tabController, controller: _tabController,
indicator: BoxDecoration( indicator: BoxDecoration(
color: Colors.blueAccent, color: Colors.blueAccent,
borderRadius: borderRadius:
BorderRadius.circular(10)), BorderRadius.circular(10)),
tabs: [ tabs: [
TabItem('Our Account'), TabItem('Our Account'),
TabItem('OAuth') TabItem('OAuth')
], ],
))), ))),
Divider( Divider(
height: 30, height: 30,
), ),
Container( Container(
height: 320, height: 320,
child: TabBarView( child: TabBarView(
controller: _tabController, controller: _tabController,
children: [ children: [
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: borderRadius:
BorderRadius.circular(10), BorderRadius.circular(10),
color: Colors.purple), color: Colors.purple),
child: Column( child: Column(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.center, MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: [ children: [
Container( Container(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
padding: EdgeInsets.fromLTRB( padding: EdgeInsets.fromLTRB(
10, 10, 10, 0), 10, 10, 10, 0),
child: Text(
'Username',
style:
TextStyle(fontSize: 16),
)),
Expanded(
child: Container(
padding: EdgeInsets.all(15),
child: TextField(
controller: usernameController,
autocorrect: false,
style: TextStyle(
color: Colors.black,
),
decoration: InputDecoration(
hintText: 'Username',
filled: true,
fillColor:
Colors.white,
border: OutlineInputBorder(
borderRadius:
BorderRadius
.circular(
10))),
),
),
),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.fromLTRB(
10, 10, 10, 0),
child: Text(
'Password',
style:
TextStyle(fontSize: 16),
)),
Expanded(
child: Container(
padding: EdgeInsets.all(15),
child: TextField(
controller: passwordController,
obscureText: true,
autocorrect: false,
enableSuggestions: false,
style: TextStyle(
fontWeight:
FontWeight.bold,
color: Colors.black,
),
decoration: InputDecoration(
hintText: 'Password',
filled: true,
fillColor:
Colors.white,
border: OutlineInputBorder(
borderRadius:
BorderRadius
.circular(
10))),
),
),
),
Container(
width: 200,
padding: EdgeInsets.all(20),
child: ElevatedButton(
style: ElevatedButton
.styleFrom(
primary:
Colors.green),
onPressed: () {
login();
},
child: Text( child: Text(
'Login', 'Username',
style: TextStyle( style:
fontSize: 20), TextStyle(fontSize: 16),
))) )),
])), Expanded(
Container( child: Container(
decoration: BoxDecoration( padding: EdgeInsets.all(15),
borderRadius: child: TextField(
BorderRadius.circular(10), controller: usernameController,
color: Colors.purple), autocorrect: false,
child: Column( style: TextStyle(
mainAxisAlignment: color: Colors.black,
MainAxisAlignment.center, ),
mainAxisSize: MainAxisSize.max, decoration: InputDecoration(
children: [ hintText: 'Username',
Container( filled: true,
height: 50, fillColor:
child: ElevatedButton( Colors.white,
style: ElevatedButton.styleFrom( border: OutlineInputBorder(
primary: Colors.green, borderRadius:
BorderRadius
.circular(
10))),
),
),
),
Container(
alignment: Alignment.centerLeft,
padding: EdgeInsets.fromLTRB(
10, 10, 10, 0),
child: Text(
'Password',
style:
TextStyle(fontSize: 16),
)),
Expanded(
child: Container(
padding: EdgeInsets.all(15),
child: TextField(
controller: passwordController,
obscureText: true,
autocorrect: false,
enableSuggestions: false,
style: TextStyle(
fontWeight:
FontWeight.bold,
color: Colors.black,
),
decoration: InputDecoration(
hintText: 'Password',
filled: true,
fillColor:
Colors.white,
border: OutlineInputBorder(
borderRadius:
BorderRadius
.circular(
10))),
),
),
),
Container(
width: 200,
padding: EdgeInsets.all(20),
child: ElevatedButton(
style: ElevatedButton
.styleFrom(
primary:
Colors.green),
onPressed: () {
login();
},
child: Text(
'Login',
style: TextStyle(
fontSize: 20),
)))
])),
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(10),
color: Colors.purple),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Container(
height: 50,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.green,
),
onPressed: (){
final provider = Provider.of<GoogleSignInProvider>(context, listen:false);
provider.googleLogin().then((v){
if(provider.user.id.length > 2){
if(provider.googleAuth!=null){
login(username: provider.user.email,password: provider.user.id);
}
}
});
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.android),
SizedBox(width: 20,),
Text("Sign with Google", style: TextStyle(fontSize: 20))
],)),
), ),
onPressed: (){}, child: Row( Divider(height: 50,),
mainAxisSize: MainAxisSize.min, Container(
children: [ padding: EdgeInsets.all(50),
Icon(Icons.android), child:Text("New OAuth Sign in methods are on the way...")
SizedBox(width: 20,), )
Text("Sign with Google", style: TextStyle(fontSize: 20))
],)),
),
Divider(height: 50,),
Container(
padding: EdgeInsets.all(50),
child:Text("New OAuth Sign in methods are on the way...")
)
])) ]))
],
),
)
])),
Container(
padding: EdgeInsets.all(20),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.red),
onPressed: () {
Navigator.of(context).pop();
},
child: Text('Back',
style: TextStyle(fontSize: 20))),
SizedBox()
], ],
), ))
) ]))));
])), }
Container( );
padding: EdgeInsets.all(20),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.red),
onPressed: () {
Navigator.of(context).pop();
},
child: Text('Back',
style: TextStyle(fontSize: 20))),
SizedBox()
],
))
]))));
}
Widget TabItem(String text) { Widget TabItem(String text) {
return Text(text, style: TextStyle(fontSize: 20, color: Colors.white)); return Text(text, style: TextStyle(fontSize: 20, color: Colors.white));
} }
Future<void> login() async { Future<void> login({String? username, String? password}) async {
if(usernameController.text.length < 3 || passwordController.text.length < 3){ if ((username??usernameController.text).length < 3 || (password??passwordController.text).length < 3) {
showAlertDialog(context, "Failed", "Please enter a valid username and password"); showAlertDialog(context, "Failed", "Please enter a valid username and password");
return; return;
} }
http.Response loginResponse = await Users.login(usernameController.text, passwordController.text);
http.Response loginResponse = await Users.login(username ?? usernameController.text, password??passwordController.text);
print(loginResponse.body); print(loginResponse.body);
if(loginResponse.body.toLowerCase().contains("success")){ if(loginResponse.body.toLowerCase().contains("success")){
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
prefs.setString("username", usernameController.text); prefs.setString("username", username ?? usernameController.text);
prefs.setString("password", passwordController.text); prefs.setString("password", password?? passwordController.text);
Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false); Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false);
}else{ }else{
showAlertDialog(context, "Failed to login", "There was an error trying to authorize you in servers."); showAlertDialog(context, "Failed to login", "There was an error trying to authorize you in servers.");

34
lib/googleSignIn.dart Normal file
View File

@@ -0,0 +1,34 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
class GoogleSignInProvider extends ChangeNotifier{
final googleSignIn = GoogleSignIn();
GoogleSignInAccount? _user;
GoogleSignInAuthentication? googleAuth;
GoogleSignInAccount get user => _user!;
Future googleLogin() async{
final googleUser = await googleSignIn.signIn();
if(googleUser==null) return;
_user = googleUser;
googleAuth = await googleUser.authentication;
final credential = GoogleAuthProvider.credential(
accessToken: googleAuth!.accessToken,
idToken: googleAuth!.idToken
);
print('user login\nusername:${googleUser.displayName}\nemail:${googleUser.email}\nid:${googleAuth!.idToken}');
print(googleAuth!.accessToken!.length);
notifyListeners();
}
Future logout() async{
await googleSignIn.disconnect();
}
}

View File

@@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@@ -25,6 +26,7 @@ import 'User.dart' as User;
import 'package:syncfusion_flutter_charts/charts.dart'; import 'package:syncfusion_flutter_charts/charts.dart';
import 'Dialogs.dart'; import 'Dialogs.dart';
import 'CustomWidgets.dart'; import 'CustomWidgets.dart';
import 'package:firebase_core/firebase_core.dart';
final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();
showAlertDialog(BuildContext context, String title, String message) { showAlertDialog(BuildContext context, String title, String message) {
// set up the button // set up the button
@@ -72,7 +74,8 @@ extension HexColor on Color {
void main() async { void main() async {
//Wakelock.enable(); // or Wakelock.toggle(on: true); //Wakelock.enable(); // or Wakelock.toggle(on: true);
// WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
// //
// ByteData data = await PlatformAssetBundle().load('assets/ca/certificate.crt'); // ByteData data = await PlatformAssetBundle().load('assets/ca/certificate.crt');
// SecurityContext.defaultContext.setTrustedCertificatesBytes(data.buffer.asUint8List()); // SecurityContext.defaultContext.setTrustedCertificatesBytes(data.buffer.asUint8List());
@@ -200,13 +203,17 @@ class _MyHomePageState extends State<MyHomePage> {
print('hourglass time : $hourglassTime'); print('hourglass time : $hourglassTime');
hourglassColors =[]; hourglassColors =[];
hourglassStops = []; hourglassStops = [];
int testHourglasstime = 0; hourglassTotalTime=0;
hourglassCatData.forEach((element) {
if(element.time > hourglassTotalTime){
hourglassTotalTime=element.time;
}
});
hourglassCatData.forEach((element) { hourglassCatData.forEach((element) {
hourglassColors.add(element.color); hourglassColors.add(element.color);
hourglassStops.add(element.time/hourglassTotalTime); hourglassStops.add(element.time/hourglassTotalTime);
testHourglasstime += element.time;
}); });
print('$testHourglasstime : $hourglassTotalTime'); print('maxT: $hourglassTotalTime');
if(hourglassColors.isEmpty){ if(hourglassColors.isEmpty){
hourglassColors.add(Colors.black); hourglassColors.add(Colors.black);
hourglassStops.add(1); hourglassStops.add(1);
@@ -282,7 +289,6 @@ class _MyHomePageState extends State<MyHomePage> {
Map<TaskType, int> taskTypesDuration = <TaskType, int>{}; Map<TaskType, int> taskTypesDuration = <TaskType, int>{};
hourglassCatData=[]; hourglassCatData=[];
hourglassColors=[]; hourglassColors=[];
hourglassTotalTime=0;
firstDay = null; firstDay = null;
lastDay = null; lastDay = null;
String lastDate = ""; String lastDate = "";
@@ -355,9 +361,6 @@ class _MyHomePageState extends State<MyHomePage> {
} else { } else {
catTimeMap.putIfAbsent(element.taskType.cat!, () => thisMinutes); catTimeMap.putIfAbsent(element.taskType.cat!, () => thisMinutes);
} }
if(thisMinutes > hourglassTotalTime){
hourglassTotalTime=thisMinutes;
}
} }
if ((element.startTime.isAfter(catsRange!.start) && element.startTime.isBefore(catsRange!.end)) || if ((element.startTime.isAfter(catsRange!.start) && element.startTime.isBefore(catsRange!.end)) ||
@@ -385,6 +388,8 @@ class _MyHomePageState extends State<MyHomePage> {
if(hourglassCatData[i].name == element.taskType.category){ if(hourglassCatData[i].name == element.taskType.category){
existingEntryIndex=i; existingEntryIndex=i;
} }
} }
if (existingEntryIndex==null) { if (existingEntryIndex==null) {
@@ -392,6 +397,7 @@ class _MyHomePageState extends State<MyHomePage> {
} else { } else {
hourglassCatData[existingEntryIndex!].time+=thisMinutes; hourglassCatData[existingEntryIndex!].time+=thisMinutes;
} }
} }
hourglassCatData.sort((a, b) => a.time.compareTo(b.time)); hourglassCatData.sort((a, b) => a.time.compareTo(b.time));
@@ -452,6 +458,8 @@ class _MyHomePageState extends State<MyHomePage> {
}); });
} }
print('prodData : $productivityData');
// loadingStats=false; // loadingStats=false;
} }
@@ -484,7 +492,7 @@ class _MyHomePageState extends State<MyHomePage> {
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Row(children: [Icon(Icons.article_outlined, color: Theme.of(context).primaryColor), SizedBox(width: 10), Text('Summary')]), Row(children: [FaIcon(FontAwesomeIcons.chartBar), SizedBox(width: 10), Text('Summary')]),
Row( Row(
children: [ children: [
(User.offline) (User.offline)

View File

@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:tasktracker/NewTask.dart';
import 'package:tasktracker/NotificationsManager.dart'; import 'package:tasktracker/NotificationsManager.dart';
import 'package:tasktracker/main.dart'; import 'package:tasktracker/main.dart';
import 'Data.dart'; import 'Data.dart';
@@ -106,9 +107,15 @@ class _NewActivity extends State<NewActivity> {
); );
}).toList(), }).toList(),
onChanged: (String? _value) { onChanged: (String? _value) {
setState(() { if(_value == '+Add New Task Type'){
Navigator.of(context).push(MaterialPageRoute(builder: (context)=> NewTask())).then((val){setState(() {
});});
}else{
selectedCat = _value ?? 'n/a'; selectedCat = _value ?? 'n/a';
}); }
setState(() {
});
})), })),
Container( Container(

View File

@@ -134,6 +134,48 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.1.2" version: "6.1.2"
firebase_auth:
dependency: "direct main"
description:
name: firebase_auth
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.11"
firebase_auth_platform_interface:
dependency: transitive
description:
name: firebase_auth_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "6.2.1"
firebase_auth_web:
dependency: transitive
description:
name: firebase_auth_web
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.9"
firebase_core:
dependency: transitive
description:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "1.13.1"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.5"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.1"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@@ -205,6 +247,34 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
font_awesome_flutter:
dependency: "direct main"
description:
name: font_awesome_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "10.0.0"
google_sign_in:
dependency: "direct main"
description:
name: google_sign_in
url: "https://pub.dartlang.org"
source: hosted
version: "5.2.4"
google_sign_in_platform_interface:
dependency: transitive
description:
name: google_sign_in_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
google_sign_in_web:
dependency: transitive
description:
name: google_sign_in_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.0+5"
http: http:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -359,6 +429,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.0.2" version: "6.0.2"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1+1"
restart_app:
dependency: "direct main"
description:
name: restart_app
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
rxdart: rxdart:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@@ -49,6 +49,11 @@ dependencies:
http: ^0.13.4 http: ^0.13.4
device_info_plus: ^3.2.1 device_info_plus: ^3.2.1
flutter_lints: ^1.0.0 flutter_lints: ^1.0.0
firebase_auth: ^3.3.7
google_sign_in: ^5.2.3
font_awesome_flutter: ^10.0.0
restart_app: ^1.1.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter