diff --git a/android/app/build.gradle b/android/app/build.gradle index 697a7ee..2d0c885 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -51,7 +51,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.Xperience.TaskTracker" //minSdkVersion flutter.minSdkVersion - minSdkVersion 19 + minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion multiDexEnabled true versionCode flutterVersionCode.toInteger() diff --git a/android/app/google-services.json b/android/app/google-services.json index ec8acf9..8384836 100644 --- a/android/app/google-services.json +++ b/android/app/google-services.json @@ -1,20 +1,28 @@ { "project_info": { - "project_number": "584018031136", - "project_id": "timetracker-a8929", - "storage_bucket": "timetracker-a8929.appspot.com" + "project_number": "467872790335", + "project_id": "tasktracker-7410e", + "storage_bucket": "tasktracker-7410e.appspot.com" }, "client": [ { "client_info": { - "mobilesdk_app_id": "1:584018031136:android:26bd0f616e44f68e24c245", + "mobilesdk_app_id": "1:467872790335:android:6c8bd5c0f686020ce3458a", "android_client_info": { "package_name": "com.Xperience.TaskTracker" } }, "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, "android_info": { "package_name": "com.Xperience.TaskTracker", @@ -22,28 +30,20 @@ } }, { - "client_id": "584018031136-qcbe59kej60t3tua14ou979nokjp1ant.apps.googleusercontent.com", - "client_type": 1, - "android_info": { - "package_name": "com.Xperience.TaskTracker", - "certificate_hash": "a616913ffe4e775a7db60d095f0de447def5ced7" - } - }, - { - "client_id": "584018031136-95qsgo6ps7afapsjivnd7dohvbj6dl7k.apps.googleusercontent.com", + "client_id": "467872790335-s2ebnuf2m0ihq3008oob5c2q6fh14lob.apps.googleusercontent.com", "client_type": 3 } ], "api_key": [ { - "current_key": "AIzaSyBM3WEkuPJLS7mUN3TgAlPRJAHlburepBA" + "current_key": "AIzaSyAp0V5OPWGMG3tCX2teZQL6Zd2RcS9ubIg" } ], "services": { "appinvite_service": { "other_platform_oauth_client": [ { - "client_id": "584018031136-95qsgo6ps7afapsjivnd7dohvbj6dl7k.apps.googleusercontent.com", + "client_id": "467872790335-s2ebnuf2m0ihq3008oob5c2q6fh14lob.apps.googleusercontent.com", "client_type": 3 } ] diff --git a/lib/CustomWidgets.dart b/lib/CustomWidgets.dart index 1159fb6..7369947 100644 --- a/lib/CustomWidgets.dart +++ b/lib/CustomWidgets.dart @@ -69,7 +69,7 @@ class HourglassPainter extends CustomPainter{ topContent.close(); final bottomContent = Path(); - double bottomStartHeight = size.height-hourglassInset; + double bottomStartHeight = size.height-12; double bottomEndHeight = size.height * (0.95 - (fillAmount * 0.32)); double bottomContentStartWidthOffset = getBottomContentWidthOffset(size.width, bottomStartHeight, hourglassHalfHeight, hourglassInset); double bottomContentEndWidthOffset = getBottomContentWidthOffset(size.width, bottomEndHeight, hourglassHalfHeight, hourglassInset); @@ -92,16 +92,18 @@ class HourglassPainter extends CustomPainter{ fallingSand.close(); final gradient = ui.Gradient.linear( - Offset(size.width/2, size.height * 0.9), - Offset(size.width/2, bottomEndHeight + size.height *0.07), + Offset(size.width/2, bottomStartHeight - 1), + Offset(size.width/2, bottomEndHeight), colors, - colorStops); + colorStops, + TileMode.clamp); final bottomContentPainter = Paint() ..shader=gradient ..style=PaintingStyle.fill ..strokeCap=StrokeCap.round ..strokeWidth=1; + print('bottom: $bottomStartHeight, top: $bottomEndHeight'); canvas.drawPath(fallingSand, contentPainter); canvas.drawPath(topContent, contentPainter); diff --git a/lib/NewProject.dart b/lib/NewProject.dart index 88c1cfd..f08f315 100644 --- a/lib/NewProject.dart +++ b/lib/NewProject.dart @@ -55,7 +55,7 @@ class _NewProjectState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('New Project')), + appBar: AppBar(title: Text('${(editing) ? 'Edit' : 'New'} Project')), body: Container( height: MediaQuery.of(context).size.height, child: Column(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -501,7 +501,7 @@ class _NewProject2State extends State { onPressed: () { OnClickAdd(); }, - child: Text('Next', style: TextStyle(fontSize: 20))))), + child: Text((editing) ? 'Apply' : 'Add', style: TextStyle(fontSize: 20))))), ], )) ]))); diff --git a/lib/NewTask.dart b/lib/NewTask.dart index 1acf0a3..df705ee 100644 --- a/lib/NewTask.dart +++ b/lib/NewTask.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; import 'package:intl/intl.dart'; +import 'package:tasktracker/NewCategory.dart'; import 'User.dart' as User; DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm:ss"); @@ -15,6 +16,7 @@ class NewTask extends StatefulWidget { List getCategoryNames(){ List _cats = []; + _cats.add('+Add New Category'); User.categories.forEach((element) { String name = element.name; _cats.add(name); @@ -84,8 +86,15 @@ class _NewTaskState extends State { ); }).toList(), onChanged: (String? _value) { + if(_value != null) { + if (_value.contains("+Add New Category")) { + Navigator.of(context).push(MaterialPageRoute(builder: (context)=>NewCategory())); + }else{ + selectedCat = _value!; + } + } setState(() { - selectedCat = _value!; + }); })), Container( diff --git a/lib/Settings/AccountSettings.dart b/lib/Settings/AccountSettings.dart new file mode 100644 index 0000000..0acdcfe --- /dev/null +++ b/lib/Settings/AccountSettings.dart @@ -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 { + + @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(context, listen:false); + provider.logout(); + final prefs = await SharedPreferences.getInstance(); + await prefs.clear(); + Restart.restartApp(webOrigin: '/splash'); + }, + ), + + ], + ), + ), + ); + } + ); + } +} diff --git a/lib/Settings/Settings.dart b/lib/Settings/Settings.dart index 1edcf77..0012172 100644 --- a/lib/Settings/Settings.dart +++ b/lib/Settings/Settings.dart @@ -1,8 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:tasktracker/Settings/AccountSettings.dart'; import 'package:tasktracker/Settings/AppearanceSettings.dart'; import 'package:tasktracker/Settings/NotificationSettings.dart'; import 'package:tasktracker/Settings/BehaviourSettings.dart'; import 'package:tasktracker/main.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + class SettingsPage extends StatefulWidget { const SettingsPage({Key? key}) : super(key: key); @@ -15,33 +18,51 @@ class _SettingsPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Settings')), + appBar: AppBar(title: Row( + children: [ + FaIcon(FontAwesomeIcons.cog), + SizedBox(width: 15,), + Text('Settings'), + ], + )), body: Column( mainAxisSize: MainAxisSize.max, children: [ ListTile( + leading: FaIcon(FontAwesomeIcons.paintbrush), title: Text('Appearance'), subtitle: Text('Just the looks and feels'), - trailing: Icon(Icons.arrow_forward_ios), + // trailing: Icon(Icons.arrow_forward_ios), onTap: (){ Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const AppearanceSettings())); }, ), ListTile( + leading: FaIcon(FontAwesomeIcons.bell), title: Text('Notifications'), subtitle: Text("Don't worry, We won't let you forget"), - trailing: Icon(Icons.arrow_forward_ios), + // trailing: Icon(Icons.arrow_forward_ios), onTap: (){ Navigator.of(context).push(MaterialPageRoute(builder: (context)=> const NotificationSettings())); }, ), ListTile( + leading: FaIcon(FontAwesomeIcons.cogs), title:Text("General Behaviour"), subtitle: Text("Wanna change how the app works? Go ahead!"), - trailing: Icon(Icons.arrow_forward_ios), + // trailing: Icon(Icons.arrow_forward_ios), onTap: (){ 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()))), // Divider(), diff --git a/lib/Welcome.dart b/lib/Welcome.dart index d1674b4..c60f2b0 100644 --- a/lib/Welcome.dart +++ b/lib/Welcome.dart @@ -1,7 +1,9 @@ import 'dart:ui'; +import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; +import 'package:tasktracker/googleSignIn.dart'; import 'User.dart' as Users; import 'package:http/http.dart' as http; class WelcomePage extends StatefulWidget { @@ -85,71 +87,71 @@ class SignInPage extends StatefulWidget { class _SignInPageState extends State { @override Widget build(BuildContext context) { - return SafeArea( - child: Scaffold( - body: Container( - color: Colors.deepPurpleAccent, - child: Flex( - direction: Axis.vertical, - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 2, - child: Container( - padding: EdgeInsets.fromLTRB(0, 100, 0, 0), - height: 400, - child: - Image(image: AssetImage('images/signin.png'))), - ), - Expanded( + return SafeArea( + child: Scaffold( + body: Container( + color: Colors.deepPurpleAccent, + child: Flex( + direction: Axis.vertical, + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 2, + child: Container( + padding: EdgeInsets.fromLTRB(0, 100, 0, 0), + height: 400, + child: + Image(image: AssetImage('images/signin.png'))), + ), + Expanded( - flex:1, - child: Padding( - padding: const EdgeInsets.all(10.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("Sign in to stay connected", - style: TextStyle( - fontSize: 30, - fontWeight: FontWeight.bold)), - Divider(), - Text( - "Sign in and enjoy the flawless connection between all your devices. You can track your day from any device and keep it together.") - ], - ), - )), - 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).push( - MaterialPageRoute( - builder: (context) => - const offlineLoginPage())); - }, - child: Text('Use Offline', - style: TextStyle(fontSize: 20))), - ElevatedButton( - onPressed: () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => - const onlineLoginPage())); - }, - child: Text('Next', - style: TextStyle(fontSize: 20))) - ], - )) - ])))); + flex:1, + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("Sign in to stay connected", + style: TextStyle( + fontSize: 30, + fontWeight: FontWeight.bold)), + Divider(), + Text( + "Sign in and enjoy the flawless connection between all your devices. You can track your day from any device and keep it together.") + ], + ), + )), + 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).push( + MaterialPageRoute( + builder: (context) => + const offlineLoginPage())); + }, + child: Text('Use Offline', + style: TextStyle(fontSize: 20))), + ElevatedButton( + onPressed: () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => + const onlineLoginPage())); + }, + child: Text('Next', + style: TextStyle(fontSize: 20))) + ], + )) + ])))); } } @@ -174,224 +176,238 @@ class _onlineLoginPageState extends State } @override - Widget build(BuildContext context) { - return SafeArea( - child: Scaffold( - body: Container( - color: Colors.purpleAccent, - child: Flex( - direction: Axis.vertical, - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - // Container( - // padding: EdgeInsets.all(20), - // alignment: Alignment.centerLeft, - // child: Text( - // 'Sign in online', - // style: TextStyle( - // fontSize: 40, fontWeight: FontWeight.bold), - // textAlign: TextAlign.left, - // ), - // ), - Expanded( + Widget build(BuildContext context) => ChangeNotifierProvider( + create:(context)=>GoogleSignInProvider(), + builder: (context, snapshot) { + return SafeArea( + child: Scaffold( + body: Container( + color: Colors.purpleAccent, + child: Flex( + direction: Axis.vertical, + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + // Container( + // padding: EdgeInsets.all(20), + // alignment: Alignment.centerLeft, + // child: Text( + // 'Sign in online', + // style: TextStyle( + // fontSize: 40, fontWeight: FontWeight.bold), + // textAlign: TextAlign.left, + // ), + // ), + Expanded( - child: Container( - child: - Image(image: AssetImage('images/signin.png'))), - ), - Container( - padding: EdgeInsets.all(20), - child: Column(children: [ - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: Colors.purple), - child: Padding( - padding: EdgeInsets.all(10), - child: TabBar( - controller: _tabController, - indicator: BoxDecoration( - color: Colors.blueAccent, - borderRadius: - BorderRadius.circular(10)), - tabs: [ - TabItem('Our Account'), - TabItem('OAuth') - ], - ))), - Divider( - height: 30, - ), - Container( - height: 320, - child: TabBarView( - controller: _tabController, - children: [ - Container( - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(10), - color: Colors.purple), - child: Column( - mainAxisAlignment: - MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - Container( - alignment: Alignment.centerLeft, - padding: EdgeInsets.fromLTRB( - 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: Container( + child: + Image(image: AssetImage('images/signin.png'))), + ), + Container( + padding: EdgeInsets.all(20), + child: Column(children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: Colors.purple), + child: Padding( + padding: EdgeInsets.all(10), + child: TabBar( + controller: _tabController, + indicator: BoxDecoration( + color: Colors.blueAccent, + borderRadius: + BorderRadius.circular(10)), + tabs: [ + TabItem('Our Account'), + TabItem('OAuth') + ], + ))), + Divider( + height: 30, + ), + Container( + height: 320, + child: TabBarView( + controller: _tabController, + children: [ + Container( + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(10), + color: Colors.purple), + child: Column( + mainAxisAlignment: + MainAxisAlignment.center, + mainAxisSize: MainAxisSize.max, + children: [ + Container( + alignment: Alignment.centerLeft, + padding: EdgeInsets.fromLTRB( + 10, 10, 10, 0), 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, + '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( + '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(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( - mainAxisSize: MainAxisSize.min, - children: [ - Icon(Icons.android), - 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...") - ) + 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) { return Text(text, style: TextStyle(fontSize: 20, color: Colors.white)); } - Future login() async { - if(usernameController.text.length < 3 || passwordController.text.length < 3){ - showAlertDialog(context, "Failed", "Please enter a valid username and password"); - return; - } + Future login({String? username, String? password}) async { + if ((username??usernameController.text).length < 3 || (password??passwordController.text).length < 3) { + showAlertDialog(context, "Failed", "Please enter a valid username and password"); + 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); if(loginResponse.body.toLowerCase().contains("success")){ final prefs = await SharedPreferences.getInstance(); - prefs.setString("username", usernameController.text); - prefs.setString("password", passwordController.text); + prefs.setString("username", username ?? usernameController.text); + prefs.setString("password", password?? passwordController.text); Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false); }else{ showAlertDialog(context, "Failed to login", "There was an error trying to authorize you in servers."); diff --git a/lib/googleSignIn.dart b/lib/googleSignIn.dart new file mode 100644 index 0000000..f2d97d8 --- /dev/null +++ b/lib/googleSignIn.dart @@ -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(); + } +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index f3a7395..8cb1322 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.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 'Dialogs.dart'; import 'CustomWidgets.dart'; +import 'package:firebase_core/firebase_core.dart'; final GlobalKey navigatorKey = new GlobalKey(); showAlertDialog(BuildContext context, String title, String message) { // set up the button @@ -72,7 +74,8 @@ extension HexColor on Color { void main() async { //Wakelock.enable(); // or Wakelock.toggle(on: true); - // WidgetsFlutterBinding.ensureInitialized(); + WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp(); // // ByteData data = await PlatformAssetBundle().load('assets/ca/certificate.crt'); // SecurityContext.defaultContext.setTrustedCertificatesBytes(data.buffer.asUint8List()); @@ -200,13 +203,17 @@ class _MyHomePageState extends State { print('hourglass time : $hourglassTime'); hourglassColors =[]; hourglassStops = []; - int testHourglasstime = 0; + hourglassTotalTime=0; + hourglassCatData.forEach((element) { + if(element.time > hourglassTotalTime){ + hourglassTotalTime=element.time; + } + }); hourglassCatData.forEach((element) { hourglassColors.add(element.color); hourglassStops.add(element.time/hourglassTotalTime); - testHourglasstime += element.time; }); - print('$testHourglasstime : $hourglassTotalTime'); + print('maxT: $hourglassTotalTime'); if(hourglassColors.isEmpty){ hourglassColors.add(Colors.black); hourglassStops.add(1); @@ -282,7 +289,6 @@ class _MyHomePageState extends State { Map taskTypesDuration = {}; hourglassCatData=[]; hourglassColors=[]; - hourglassTotalTime=0; firstDay = null; lastDay = null; String lastDate = ""; @@ -355,9 +361,6 @@ class _MyHomePageState extends State { } else { catTimeMap.putIfAbsent(element.taskType.cat!, () => thisMinutes); } - if(thisMinutes > hourglassTotalTime){ - hourglassTotalTime=thisMinutes; - } } if ((element.startTime.isAfter(catsRange!.start) && element.startTime.isBefore(catsRange!.end)) || @@ -385,6 +388,8 @@ class _MyHomePageState extends State { if(hourglassCatData[i].name == element.taskType.category){ existingEntryIndex=i; } + + } if (existingEntryIndex==null) { @@ -392,6 +397,7 @@ class _MyHomePageState extends State { } else { hourglassCatData[existingEntryIndex!].time+=thisMinutes; } + } hourglassCatData.sort((a, b) => a.time.compareTo(b.time)); @@ -452,6 +458,8 @@ class _MyHomePageState extends State { }); } + + print('prodData : $productivityData'); // loadingStats=false; } @@ -484,7 +492,7 @@ class _MyHomePageState extends State { mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, 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( children: [ (User.offline) diff --git a/lib/newActivity.dart b/lib/newActivity.dart index b19f2c1..aa51853 100644 --- a/lib/newActivity.dart +++ b/lib/newActivity.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; import 'package:intl/intl.dart'; +import 'package:tasktracker/NewTask.dart'; import 'package:tasktracker/NotificationsManager.dart'; import 'package:tasktracker/main.dart'; import 'Data.dart'; @@ -106,9 +107,15 @@ class _NewActivity extends State { ); }).toList(), 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'; - }); + } + setState(() { + }); })), Container( diff --git a/pubspec.lock b/pubspec.lock index 4bad332..2edffc3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -134,6 +134,48 @@ packages: url: "https://pub.dartlang.org" source: hosted 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: dependency: "direct main" description: flutter @@ -205,6 +247,34 @@ packages: description: flutter source: sdk 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: dependency: "direct main" description: @@ -359,6 +429,20 @@ packages: url: "https://pub.dartlang.org" source: hosted 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: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 33b5583..893cc9c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,6 +49,11 @@ dependencies: http: ^0.13.4 device_info_plus: ^3.2.1 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: flutter_test: sdk: flutter