From d8fdc0371835936791575b5b3d5afdd3927b4116 Mon Sep 17 00:00:00 2001 From: Hanna Sabu Mampallil Date: Tue, 28 Dec 2021 15:42:42 +0530 Subject: [PATCH 1/9] version changes --- android/app/build.gradle | 2 +- lib/screens/auth/SignIn.dart | 22 ++++---- lib/screens/auth/auth.dart | 2 +- lib/screens/auth/home.dart | 8 +-- lib/screens/auth/profile.dart | 4 +- lib/screens/auth/register.dart | 21 ++++--- lib/screens/auth/shared_auth.dart | 7 ++- pubspec.lock | 92 +++++++++++++++---------------- pubspec.yaml | 2 +- 9 files changed, 82 insertions(+), 78 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 9ded6ba..102e6a0 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -39,7 +39,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.login_ui" - minSdkVersion 16 + minSdkVersion 19 targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/lib/screens/auth/SignIn.dart b/lib/screens/auth/SignIn.dart index 013b7cc..90b9bd5 100644 --- a/lib/screens/auth/SignIn.dart +++ b/lib/screens/auth/SignIn.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:flutter/material.dart'; -import 'package:fluttertoast/fluttertoast.dart'; +// import 'package:fluttertoast/fluttertoast.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:login_ui/config/database_helper.dart'; import 'package:login_ui/config/palette.dart'; @@ -132,13 +132,13 @@ class _SignInState extends State { }; var res = await http.post(url, body: data); if (jsonDecode(res.body) == "dont have account") { - Fluttertoast.showToast( - msg: "Dont have Account, Please register", - toastLength: Toast.LENGTH_LONG); + // Fluttertoast.showToast( + // msg: "Dont have Account, Please register", + // toastLength: Toast.LENGTH_LONG); } else { if (jsonDecode(res.body) == "false") { - Fluttertoast.showToast( - msg: "Incorrect Password", toastLength: Toast.LENGTH_SHORT); + // Fluttertoast.showToast( + // msg: "Incorrect Password", toastLength: Toast.LENGTH_SHORT); } else { List> query = await DatabaseHelper.instance.queryAll(); @@ -158,11 +158,11 @@ class _SignInState extends State { Widget _RoundContinueButton(isLoading) { return RawMaterialButton( onPressed: () { - (emailctrl.text == '' || passctrl.text == '') - ? Fluttertoast.showToast( - msg: 'Please Enter Email And password', - toastLength: Toast.LENGTH_LONG) - : LoginUser(); + // (emailctrl.text == '' || passctrl.text == '') + // ? Fluttertoast.showToast( + // msg: 'Please Enter Email And password', + // toastLength: Toast.LENGTH_LONG) + // : LoginUser(); }, elevation: 0.0, fillColor: Palette.darkBlue, diff --git a/lib/screens/auth/auth.dart b/lib/screens/auth/auth.dart index 060e806..6e28475 100644 --- a/lib/screens/auth/auth.dart +++ b/lib/screens/auth/auth.dart @@ -31,7 +31,7 @@ class _AuthScreenState extends State Widget build(BuildContext context) { return Scaffold( - resizeToAvoidBottomPadding: true, + // resizeToAvoidBottomPadding: true, body: Stack( children: [ SizedBox.expand( diff --git a/lib/screens/auth/home.dart b/lib/screens/auth/home.dart index 4628ed4..dbc74a7 100644 --- a/lib/screens/auth/home.dart +++ b/lib/screens/auth/home.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; -import 'package:fluttertoast/fluttertoast.dart'; +// import 'package:fluttertoast/fluttertoast.dart'; import 'package:login_ui/config/database_helper.dart'; import 'package:login_ui/screens/auth/share.dart'; import 'package:share/share.dart'; @@ -187,9 +187,9 @@ class _HomeState extends State { children: [ InkWell( onTap: () { - Fluttertoast.showToast( - msg: "you Are already at Home", - toastLength: Toast.LENGTH_SHORT); + // Fluttertoast.showToast( + // msg: "you Are already at Home", + // toastLength: Toast.LENGTH_SHORT); }, child: Container( child: Column( diff --git a/lib/screens/auth/profile.dart b/lib/screens/auth/profile.dart index ad00533..44d42da 100644 --- a/lib/screens/auth/profile.dart +++ b/lib/screens/auth/profile.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:fluttertoast/fluttertoast.dart'; +// import 'package:fluttertoast/fluttertoast.dart'; import '../../main.dart'; import 'package:http/http.dart'as http; @@ -124,7 +124,7 @@ class _ProfileState extends State { companyname1 = await getCompanyName(); number1 = await getNumber(); bool result = await UpdateUserTable(); - result ? Fluttertoast.showToast(msg: 'Changes saved successfully',toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.CENTER ): Fluttertoast.showToast(msg: 'Something Went Wrong, try again',toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.CENTER );; + // result ? Fluttertoast.showToast(msg: 'Changes saved successfully',toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.CENTER ): Fluttertoast.showToast(msg: 'Something Went Wrong, try again',toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.CENTER );; Navigator.pop(context); }, child: Container( diff --git a/lib/screens/auth/register.dart b/lib/screens/auth/register.dart index 407d0a1..70569d5 100644 --- a/lib/screens/auth/register.dart +++ b/lib/screens/auth/register.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:flutter/material.dart'; -import 'package:fluttertoast/fluttertoast.dart'; +// import 'package:fluttertoast/fluttertoast.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:login_ui/config/database_helper.dart'; import 'package:login_ui/config/palette.dart'; @@ -153,13 +153,15 @@ class _RegisterState extends State { var res = await http.post(url, body: data); if (jsonDecode(res.body) == "Account already exists") { - Fluttertoast.showToast( - msg: 'Account already exists, Please login', - toastLength: Toast.LENGTH_LONG); + print('Account already exists, Please login'); + // Fluttertoast.showToast( + // msg: 'Account already exists, Please login', + // toastLength: Toast.LENGTH_LONG); } else { if (jsonDecode(res.body) == "true") { - Fluttertoast.showToast( - msg: "Account Created", toastLength: Toast.LENGTH_SHORT); + print('Account Created'); + // Fluttertoast.showToast( + // msg: "Account Created", toastLength: Toast.LENGTH_SHORT); List> query = await DatabaseHelper.instance.queryAll(); int Take = await DatabaseHelper.instance.TotalToTake(); @@ -170,8 +172,8 @@ class _RegisterState extends State { Navigator.push(context, MaterialPageRoute(builder: (context) => Home(query, Give, Take))); } else { - Fluttertoast.showToast( - msg: "Error, Try Again later", toastLength: Toast.LENGTH_LONG); + // Fluttertoast.showToast( + // msg: "Error, Try Again later", toastLength: Toast.LENGTH_LONG); } } setState(() { @@ -181,7 +183,8 @@ class _RegisterState extends State { Widget _RoundContinueButton(isLoading) { return RawMaterialButton( - onPressed: () => (namectrl.text == '' || emailctrl.text == '' || passctrl.text == '') ? Fluttertoast.showToast(msg: 'Please Enter Name, Email And password',toastLength: Toast.LENGTH_LONG) : registerUser(), + onPressed: () {}, + // => (namectrl.text == '' || emailctrl.text == '' || passctrl.text == '') ? Fluttertoast.showToast(msg: 'Please Enter Name, Email And password',toastLength: Toast.LENGTH_LONG) : registerUser(), elevation: 0.0, fillColor: Palette.darkBlue, splashColor: Palette.darkOrange, diff --git a/lib/screens/auth/shared_auth.dart b/lib/screens/auth/shared_auth.dart index 009be7f..5cc8dec 100644 --- a/lib/screens/auth/shared_auth.dart +++ b/lib/screens/auth/shared_auth.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:fluttertoast/fluttertoast.dart'; +// import 'package:fluttertoast/fluttertoast.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:login_ui/config/database_helper.dart'; import 'package:login_ui/config/palette.dart'; @@ -139,7 +139,7 @@ class _SharedAuthState extends State Navigator.push(context, MaterialPageRoute(builder: (context) => Home(query, Give, Take))); }else{ - Fluttertoast.showToast(msg: 'Incorrect Password',toastLength: Toast.LENGTH_LONG); + // Fluttertoast.showToast(msg: 'Incorrect Password',toastLength: Toast.LENGTH_LONG); } setState((){ isLoading = false; @@ -148,7 +148,8 @@ class _SharedAuthState extends State Widget _RoundContinueButton(isLoading) { return RawMaterialButton( - onPressed: () => (passctrl.text == '') ? Fluttertoast.showToast(msg: 'Please Enter Your password',toastLength: Toast.LENGTH_LONG) : verify(), + onPressed: () {}, + // => (passctrl.text == '') ? Fluttertoast.showToast(msg: 'Please Enter Your password',toastLength: Toast.LENGTH_LONG) : verify(), elevation: 0.0, fillColor: Palette.darkBlue, splashColor: Palette.darkOrange, diff --git a/pubspec.lock b/pubspec.lock index 004c4a4..d56ef3e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.8.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.3.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.15.0" connectivity: dependency: "direct main" description: @@ -84,21 +84,21 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" ffi: dependency: transitive description: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "1.1.2" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "5.2.1" + version: "6.1.2" flutter: dependency: "direct main" description: flutter @@ -110,7 +110,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "1.0.11" + version: "2.0.5" flutter_slidable: dependency: "direct main" description: @@ -135,20 +135,13 @@ packages: description: flutter source: sdk version: "0.0.0" - fluttertoast: - dependency: "direct main" - description: - name: fluttertoast - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.1" font_awesome_flutter: dependency: "direct main" description: name: font_awesome_flutter url: "https://pub.dartlang.org" source: hosted - version: "8.11.0" + version: "8.12.0" http: dependency: "direct main" description: @@ -169,49 +162,56 @@ packages: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "0.17.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" local_auth: dependency: "direct main" description: name: local_auth url: "https://pub.dartlang.org" source: hosted - version: "0.6.3+4" + version: "1.1.8" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.7.0" mime: dependency: transitive description: name: mime url: "https://pub.dartlang.org" source: hosted - version: "0.9.7" + version: "1.0.1" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0" path_provider: dependency: "direct main" description: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "1.6.27" + version: "1.6.28" path_provider_linux: dependency: transitive description: @@ -239,21 +239,21 @@ packages: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "0.0.4+3" + version: "0.0.5" pedantic: dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.0" + version: "1.11.1" platform: dependency: transitive description: name: platform url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "3.0.2" plugin_platform_interface: dependency: transitive description: @@ -267,14 +267,14 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "3.0.13" + version: "4.2.4" share: dependency: "direct main" description: name: share url: "https://pub.dartlang.org" source: hosted - version: "0.6.5+4" + version: "2.0.4" shared_preferences: dependency: "direct main" description: @@ -328,7 +328,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.1" splashscreen: dependency: "direct main" description: @@ -342,35 +342,35 @@ packages: name: sqflite url: "https://pub.dartlang.org" source: hosted - version: "1.3.1+2" + version: "1.3.2+4" sqflite_common: dependency: transitive description: name: sqflite_common url: "https://pub.dartlang.org" source: hosted - version: "1.0.3+1" + version: "1.0.3+3" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0" synchronized: dependency: transitive description: @@ -384,56 +384,56 @@ packages: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.4.2" toggle_switch: dependency: "direct main" description: name: toggle_switch url: "https://pub.dartlang.org" source: hosted - version: "0.1.8" + version: "0.1.9" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0" webview_flutter: dependency: "direct main" description: name: webview_flutter url: "https://pub.dartlang.org" source: hosted - version: "0.3.24" + version: "2.0.14" win32: dependency: transitive description: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "1.7.4+1" + version: "2.3.1" xdg_directories: dependency: transitive description: name: xdg_directories url: "https://pub.dartlang.org" source: hosted - version: "0.1.0" + version: "0.1.2" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" - flutter: ">=1.12.13+hotfix.5 <2.0.0" + dart: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" diff --git a/pubspec.yaml b/pubspec.yaml index 92e7ba5..63f1a36 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,7 +34,7 @@ dependencies: path_provider: ^1.6.18 sqflite: ^1.3.1+1 http: ^0.12.0+4 - fluttertoast: ^4.0.1 + shared_preferences: ^0.5.12+4 share: any webview_flutter: From fe80795b8b03118a92acfcfdb44ab1cac3a1dd3e Mon Sep 17 00:00:00 2001 From: Hanna Sabu Mampallil Date: Tue, 28 Dec 2021 20:08:42 +0530 Subject: [PATCH 2/9] desciption ui --- lib/screens/auth/add.dart | 39 ++++++++++++++++++++++++++++++++++ lib/screens/auth/register.dart | 5 +++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/screens/auth/add.dart b/lib/screens/auth/add.dart index 9528438..c39469c 100644 --- a/lib/screens/auth/add.dart +++ b/lib/screens/auth/add.dart @@ -20,6 +20,10 @@ class _AddState extends State { TextEditingController _controller4 = new TextEditingController(); bool toggleValue = false; int Take = 0, Give = 0; + List selected=[false,false,false,false]; + String label='food'; + int index=0; + int selectedIndex; @override Widget build(BuildContext context) { return Scaffold( @@ -108,6 +112,14 @@ class _AddState extends State { fontSize: 23, ), ), + Row( + children: [ + option('Food',0), + option('Food',1), + option('Food',2), + option('Food',3), + ], + ), TextField( decoration: InputDecoration(fillColor: Colors.white24, filled: true), @@ -221,6 +233,27 @@ class _AddState extends State { ) ); } + + Padding option(String label,int index) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: ChoiceChip( + label: Text( + label, + style: TextStyle(color: Colors.black), + ), + selectedColor: Colors.grey, + selected: selected[index], + onSelected:(value){ + setState(() { + clearAll(); + selected[index]=!selected[index]; + selectedIndex=index; + }); + }, + ), + ); + } closePopup() async{ List> query = await DatabaseHelper.instance.queryAll(); @@ -228,4 +261,10 @@ class _AddState extends State { int Give1 = await DatabaseHelper.instance.TotalToGive(); Navigator.push(context, MaterialPageRoute(builder: (context)=> Home(query,Give1,Take1))); } + + void clearAll(){ + selected=[false,false,false,false]; + } } + + diff --git a/lib/screens/auth/register.dart b/lib/screens/auth/register.dart index 70569d5..c43d5cc 100644 --- a/lib/screens/auth/register.dart +++ b/lib/screens/auth/register.dart @@ -183,8 +183,9 @@ class _RegisterState extends State { Widget _RoundContinueButton(isLoading) { return RawMaterialButton( - onPressed: () {}, - // => (namectrl.text == '' || emailctrl.text == '' || passctrl.text == '') ? Fluttertoast.showToast(msg: 'Please Enter Name, Email And password',toastLength: Toast.LENGTH_LONG) : registerUser(), + onPressed: () { + (namectrl.text == '' || emailctrl.text == '' || passctrl.text == '') ? print('not done') : registerUser(); + }, elevation: 0.0, fillColor: Palette.darkBlue, splashColor: Palette.darkOrange, From 51c30e6c9d28f8d6209ac504b62d1dea651b90d4 Mon Sep 17 00:00:00 2001 From: Hanna Sabu Mampallil Date: Sat, 1 Jan 2022 12:57:44 +0530 Subject: [PATCH 3/9] change password ui --- lib/config/database_helper.dart | 4 +- lib/config/icon.dart | 7 ++ lib/screens/auth/SignIn.dart | 35 +++--- lib/screens/auth/add.dart | 55 +++++++-- lib/screens/auth/change_password.dart | 154 ++++++++++++++++++++++++++ lib/screens/auth/edit.dart | 76 ++++++++++++- lib/screens/auth/home.dart | 22 ++-- lib/screens/auth/more.dart | 14 ++- lib/screens/auth/pin.dart | 12 +- lib/screens/auth/profile.dart | 6 +- lib/screens/auth/register.dart | 16 +-- lib/screens/auth/settings.dart | 12 +- lib/screens/auth/share.dart | 5 +- lib/screens/auth/shared_auth.dart | 15 ++- pubspec.lock | 7 ++ pubspec.yaml | 2 +- 16 files changed, 378 insertions(+), 64 deletions(-) create mode 100644 lib/config/icon.dart create mode 100644 lib/screens/auth/change_password.dart diff --git a/lib/config/database_helper.dart b/lib/config/database_helper.dart index 9d324c5..08b2d1c 100644 --- a/lib/config/database_helper.dart +++ b/lib/config/database_helper.dart @@ -15,6 +15,7 @@ class DatabaseHelper { static final columnAmount = 'amount'; static final columnCondition = 'condition'; static final columnDescription = 'description'; + static final columnIcon = 'icon'; //making it a singleton class DatabaseHelper._privateConstructor(); @@ -49,7 +50,8 @@ class DatabaseHelper { $columnPhone TEXT, $columnAmount INTEGER, $columnCondition TEXT, - $columnDescription TEXT + $columnDescription TEXT, + $columnIcon INTEGER ) ''' ); diff --git a/lib/config/icon.dart b/lib/config/icon.dart new file mode 100644 index 0000000..468dfdc --- /dev/null +++ b/lib/config/icon.dart @@ -0,0 +1,7 @@ +Map iconNumber={ + 0:'🍔', + 1:'🛒', + 2:'💊', + 3:'⚫' +}; + diff --git a/lib/screens/auth/SignIn.dart b/lib/screens/auth/SignIn.dart index 90b9bd5..5199643 100644 --- a/lib/screens/auth/SignIn.dart +++ b/lib/screens/auth/SignIn.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:flutter/material.dart'; -// import 'package:fluttertoast/fluttertoast.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:login_ui/config/database_helper.dart'; import 'package:login_ui/config/palette.dart'; @@ -131,14 +131,20 @@ class _SignInState extends State { "pass": passctrl.text, }; var res = await http.post(url, body: data); - if (jsonDecode(res.body) == "dont have account") { - // Fluttertoast.showToast( - // msg: "Dont have Account, Please register", - // toastLength: Toast.LENGTH_LONG); + var body=jsonDecode(res.body); + print(body); + if (body['result'] == "dont have account") { + print("if"); + Fluttertoast.showToast( + msg: "Dont have Account, Please register", + toastLength: Toast.LENGTH_LONG); + print("Dont have Account, Please register"); } else { - if (jsonDecode(res.body) == "false") { - // Fluttertoast.showToast( - // msg: "Incorrect Password", toastLength: Toast.LENGTH_SHORT); + print("else"); + if (body['result'] =="false") { + Fluttertoast.showToast( + msg: "Incorrect Password", toastLength: Toast.LENGTH_SHORT); + print('Incorrect Password'); } else { List> query = await DatabaseHelper.instance.queryAll(); @@ -146,6 +152,9 @@ class _SignInState extends State { int Give = await DatabaseHelper.instance.TotalToGive(); addEmailToSF(emailctrl.text); addPassToSF(passctrl.text); + addNameToSF(body['name']); + addCompanyNameToSF(body['company']); + addNumberToSF(body['phone']); Navigator.push(context, MaterialPageRoute(builder: (context) => Home(query, Give, Take))); } @@ -158,11 +167,11 @@ class _SignInState extends State { Widget _RoundContinueButton(isLoading) { return RawMaterialButton( onPressed: () { - // (emailctrl.text == '' || passctrl.text == '') - // ? Fluttertoast.showToast( - // msg: 'Please Enter Email And password', - // toastLength: Toast.LENGTH_LONG) - // : LoginUser(); + (emailctrl.text == '' || passctrl.text == '') + ? Fluttertoast.showToast( + msg: 'Please Enter Email And password', + toastLength: Toast.LENGTH_LONG) + : LoginUser(); }, elevation: 0.0, fillColor: Palette.darkBlue, diff --git a/lib/screens/auth/add.dart b/lib/screens/auth/add.dart index c39469c..e638c85 100644 --- a/lib/screens/auth/add.dart +++ b/lib/screens/auth/add.dart @@ -18,12 +18,11 @@ class _AddState extends State { int _controller2; TextEditingController _controller3 = new TextEditingController(); TextEditingController _controller4 = new TextEditingController(); - bool toggleValue = false; + bool toggleValue = true; int Take = 0, Give = 0; List selected=[false,false,false,false]; - String label='food'; int index=0; - int selectedIndex; + int selectedIndex=3; @override Widget build(BuildContext context) { return Scaffold( @@ -114,10 +113,35 @@ class _AddState extends State { ), Row( children: [ - option('Food',0), - option('Food',1), - option('Food',2), - option('Food',3), + Expanded( + child: SizedBox( + height: 50, + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + option('Food',0), + option('Shopping',1), + option('Medical',2), + option('Others',3), + // option('Vacation',4), + // option('Entertainment',5), + // option('',6), + // option('Food',7), + ], + ), + ), + ), + InkWell( + child: Icon(Icons.cancel, + ), + onTap: (){ + setState(() { + clearAll(); + selectedIndex=null; + }); + + }, + ) ], ), TextField( @@ -143,6 +167,7 @@ class _AddState extends State { labels: ['Take', 'Give'], activeBgColors: [Colors.green, Color(0xfff96060)], onToggle: (index) { + print(toggleValue); if(index == 0){ toggleValue = true; }else{ @@ -164,6 +189,7 @@ class _AddState extends State { Center( child: InkWell( onTap: () async { + print(toggleValue); int i = await DatabaseHelper.instance.insert({ DatabaseHelper.columnName: @@ -176,7 +202,8 @@ class _AddState extends State { (toggleValue == false) ? 'Give' : 'Take', - DatabaseHelper.columnDescription: _controller4.text + DatabaseHelper.columnDescription: _controller4.text, + DatabaseHelper.columnIcon: selectedIndex }); List> query = await DatabaseHelper.instance @@ -254,6 +281,14 @@ class _AddState extends State { ), ); } + + + void clearAll(){ + + selected=[false,false,false,false]; + + } + closePopup() async{ List> query = await DatabaseHelper.instance.queryAll(); @@ -261,10 +296,6 @@ class _AddState extends State { int Give1 = await DatabaseHelper.instance.TotalToGive(); Navigator.push(context, MaterialPageRoute(builder: (context)=> Home(query,Give1,Take1))); } - - void clearAll(){ - selected=[false,false,false,false]; - } } diff --git a/lib/screens/auth/change_password.dart b/lib/screens/auth/change_password.dart new file mode 100644 index 0000000..726a78f --- /dev/null +++ b/lib/screens/auth/change_password.dart @@ -0,0 +1,154 @@ +import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:login_ui/config/database_helper.dart'; +import 'package:login_ui/config/palette.dart'; +import 'package:login_ui/screens/auth/change_password.dart'; +import '../../main.dart'; +import '../background_paint.dart'; +import 'home.dart'; +import 'change_password.dart'; + +class ChangePass extends StatefulWidget { + + @override + _ChangePassState createState() => _ChangePassState(); +} + +class _ChangePassState extends State with SingleTickerProviderStateMixin { + AnimationController _controller; + TextEditingController passctrl,cpassctrl; + bool pass = true,cpass=true; + bool isLoading = false; + @override + void initState() { + _controller = + AnimationController(vsync: this, duration: Duration(seconds: 4)); + passctrl = new TextEditingController(); + super.initState(); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + @override + Widget build(BuildContext context) { + return Scaffold( + resizeToAvoidBottomInset: false, + body: Stack(children: [ + SizedBox.expand( + child: CustomPaint( + painter: BackgroundPainter( + animation: _controller.view, + ), + ), + ), + Padding( + padding: const EdgeInsets.all(32), + child: Column( + children: [ + Expanded( + flex: 4, + child: Align( + alignment: Alignment.centerLeft, + child: Text( + 'Enter new Password', + style: TextStyle( + color: Colors.white, + fontSize: 30, + fontWeight: FontWeight.w500), + ), + ), + ), + Expanded( + flex: 5, + child: ListView( + children: [ + Padding( + padding: EdgeInsets.symmetric(vertical: 16), + child: TextField( + controller: passctrl, + obscureText: pass, + decoration: InputDecoration( + hintText: 'New Password', + hintStyle: TextStyle(color: Colors.black54, fontSize: 20), + prefixIcon: Icon( + Icons.vpn_key, + color: Colors.black54, + size: 25, + ), + suffixIcon: IconButton( + onPressed: () { + setState(() { + pass = !pass; + }); + }, + icon: Icon( + Icons.remove_red_eye, + color: Colors.black, + size: 25, + ), + )), + ), + ), + Padding( + padding: EdgeInsets.symmetric(vertical: 16), + child: TextField( + controller: cpassctrl, + obscureText: cpass, + decoration: InputDecoration( + hintText: ' Confirm New Password', + hintStyle: TextStyle(color: Colors.black54, fontSize: 20), + prefixIcon: Icon( + Icons.vpn_key, + color: Colors.black54, + size: 25, + ), + suffixIcon: IconButton( + onPressed: () { + setState(() { + cpass = !cpass; + }); + }, + icon: Icon( + Icons.remove_red_eye, + color: Colors.black, + size: 25, + ), + )), + ), + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Change Password', + style: const TextStyle( + fontWeight: FontWeight.w800, + color: Palette.darkBlue, + fontSize: 24, + ), + ), + Expanded( + child: Center( + // child: _LoadingIndicator(isLoading), + ), + ), + // _RoundContinueButton(isLoading), + ], + ), + ), + ], + ), + ), + ], + ), + ), + ]), + ); + } +} \ No newline at end of file diff --git a/lib/screens/auth/edit.dart b/lib/screens/auth/edit.dart index f421c1f..c9894ff 100644 --- a/lib/screens/auth/edit.dart +++ b/lib/screens/auth/edit.dart @@ -8,8 +8,8 @@ class Edit extends StatefulWidget { String Name; int id; String number,desc; - int Amount; - Edit(this.id,this.Name, this.Amount,this.number,this.desc); + int Amount,icon; + Edit(this.id,this.Name, this.Amount,this.number,this.desc,this.icon); @override _EditState createState() => _EditState(); } @@ -17,10 +17,17 @@ class Edit extends StatefulWidget { class _EditState extends State { String _controller1,_controller3,_controller4; int amount,_controller2=0; + List selected=[false,false,false,false,false,false,false,false]; + + String label='food'; + int index=0; + int selectedIndex; @override void initState() { amount = widget.Amount; - setState((){}); + setState((){ + selected[widget.icon]=true; + }); super.initState(); } @override @@ -103,6 +110,7 @@ class _EditState extends State { _controller3 = value; }, ), + Text( 'Description', style: TextStyle( @@ -111,6 +119,39 @@ class _EditState extends State { ), ), SizedBox(height: 12,), + Row( + children: [ + Expanded( + child: SizedBox( + height: 50, + child: ListView( + scrollDirection: Axis.horizontal, + children: [ + option('Food',0), + option('Shopping',1), + option('Medical',2), + option('Others',3), + // option('Vacation',4), + // option('Entertainment',5), + // option('',6), + // option('Food',7), + ], + ), + ), + ), + InkWell( + child: Icon(Icons.cancel, + ), + onTap: (){ + setState(() { + clearAll(); + selectedIndex=null; + }); + + }, + ) + ], + ), TextFormField( initialValue: widget.desc, onChanged: (value){ @@ -133,6 +174,7 @@ class _EditState extends State { DatabaseHelper.columnAmount: (_controller2 == 0)? widget.Amount : _controller2, DatabaseHelper.columnPhone: (_controller3 == null) ? widget.number : _controller3, DatabaseHelper.columnDescription: (_controller4 == null) ? widget.desc : _controller4, + DatabaseHelper.columnIcon: (selectedIndex==null) ? widget.icon : selectedIndex }); List> query = await DatabaseHelper.instance.queryAll(); int Take = await DatabaseHelper.instance.TotalToTake(); @@ -190,4 +232,32 @@ class _EditState extends State { ), ); } + + Padding option(String label,int index) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: ChoiceChip( + label: Text( + label, + style: TextStyle(color: Colors.black), + ), + selectedColor: Colors.grey, + selected: selected[index], + onSelected:(value){ + setState(() { + clearAll(); + selected[index]=!selected[index]; + selectedIndex=index; + }); + }, + ), + ); + } + + + void clearAll(){ + + selected=[false,false,false,false,false,false,false,false]; + + } } diff --git a/lib/screens/auth/home.dart b/lib/screens/auth/home.dart index dbc74a7..126b254 100644 --- a/lib/screens/auth/home.dart +++ b/lib/screens/auth/home.dart @@ -2,13 +2,14 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_slidable/flutter_slidable.dart'; -// import 'package:fluttertoast/fluttertoast.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:login_ui/config/database_helper.dart'; import 'package:login_ui/screens/auth/share.dart'; import 'package:share/share.dart'; import 'add.dart'; import 'edit.dart'; import 'more.dart'; +import '../../config/icon.dart'; class Home extends StatefulWidget { List> query; @@ -166,7 +167,8 @@ class _HomeState extends State { widget.query[index]['_id'], widget.query[index]['number'], widget.query[index]['condition'], - widget.query[index]['description']); + widget.query[index]['description'], + widget.query[index]['icon']); }), ), ), @@ -187,9 +189,9 @@ class _HomeState extends State { children: [ InkWell( onTap: () { - // Fluttertoast.showToast( - // msg: "you Are already at Home", - // toastLength: Toast.LENGTH_SHORT); + Fluttertoast.showToast( + msg: "you Are already at Home", + toastLength: Toast.LENGTH_SHORT); }, child: Container( child: Column( @@ -302,7 +304,7 @@ class _HomeState extends State { } Slidable taskWidget(Color color, String name, int amount, int id, - String number, String condition, String desc) { + String number, String condition, String desc, int icon) { return Slidable( actionPane: SlidableDrawerActionPane(), actionExtentRatio: 0.3, @@ -339,7 +341,7 @@ class _HomeState extends State { ), ), Text( - '$condition ₹$amount', + '${iconNumber[(icon)]} $condition ₹$amount', style: TextStyle(color: Colors.grey, fontSize: 18), ) ], @@ -365,7 +367,7 @@ class _HomeState extends State { context, MaterialPageRoute( builder: (context) => - Edit(id, name, amount, number, desc))); + Edit(id, name, amount, number, desc, icon))); }, ), IconSlideAction( @@ -429,11 +431,11 @@ class _HomeState extends State { icon: Icons.share, onTap: () { if (condition == 'Take') { - Navigator.push(context, MaterialPageRoute(builder: (context)=> Reminder('! Reminder ! \n$name you have to Give me ₹$amount Rupees for $desc.'))); + Navigator.push(context, MaterialPageRoute(builder: (context)=> Reminder('! Reminder ! \n$name you have to Give me ₹$amount Rupees for $desc.',false))); // Share.share( // "! *Reminder* ! \n$name you have to Give me ₹$amount Rupees"); } else { - Navigator.push(context, MaterialPageRoute(builder: (context)=> Reminder('! Reminder ! \n$name you have to Take Rupees ₹$amount from me which you had Paid for $desc.'))); + Navigator.push(context, MaterialPageRoute(builder: (context)=> Reminder('! Reminder ! \n$name you have to Take Rupees ₹$amount from me which you had Paid for $desc.',false))); // Share.share( // "! *Reminder* ! \n$name you have to Take Rupees ₹$amount from me"); } diff --git a/lib/screens/auth/more.dart b/lib/screens/auth/more.dart index fa98859..768e101 100644 --- a/lib/screens/auth/more.dart +++ b/lib/screens/auth/more.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:login_ui/screens/auth/profile.dart'; +import 'package:login_ui/screens/auth/share.dart'; import '../../main.dart'; import 'about_us.dart'; +import 'settings.dart'; class More extends StatefulWidget { @@ -34,7 +36,7 @@ class _MoreState extends State { String companyname = await getCompanyName(); int number = await getNumber(); Navigator.push(context, MaterialPageRoute(builder: (context)=>Profile(Name,email,number,companyname)));},child: Bar(Icons.person, 'Profile')), -// GestureDetector(onTap: (){Navigator.push(context, MaterialPageRoute(builder: (context) => Setting()));},child: Bar(Icons.settings, 'Settings')), + GestureDetector(onTap: (){Navigator.push(context, MaterialPageRoute(builder: (context) => Setting()));},child: Bar(Icons.settings, 'Settings')), GestureDetector( onTap: (){ setState(() { @@ -48,7 +50,15 @@ class _MoreState extends State { }, child: Bar(Icons.info_outline, 'About Us')), Bar(Icons.help_outline, 'Help & Support'), - Bar(Icons.share, 'Invite Friends'), + GestureDetector( + child: Bar( + Icons.share, 'Invite Friends' + ), + onTap:(){ + Navigator.push(context, MaterialPageRoute(builder: (context)=> Reminder('Hey check out this app!!',true))); + + }, + ), SizedBox(height: 20,), Center(child: Text('V 1.0.0',style: TextStyle(color: Colors.grey,fontSize:13),),), SizedBox(height: 10,), diff --git a/lib/screens/auth/pin.dart b/lib/screens/auth/pin.dart index 5e5d360..7a36d30 100644 --- a/lib/screens/auth/pin.dart +++ b/lib/screens/auth/pin.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:local_auth/local_auth.dart'; // ignore: unused_import import 'package:login_ui/config/database_helper.dart'; @@ -38,12 +39,13 @@ class _PinState extends State with SingleTickerProviderStateMixin { return GestureDetector( onTap: ()async{ bool check = await bioAuth(); + // bool check = false; List> query = await DatabaseHelper.instance.queryAll(); int Take = await DatabaseHelper.instance.TotalToTake(); int Give = await DatabaseHelper.instance.TotalToGive(); String name = await getName(); setState(() { - check ? Navigator.push(context, MaterialPageRoute(builder: (context) => Home(query,Give,Take))) : Navigator.push(context, MaterialPageRoute(builder: (context) => SharedAuth(name))); + check ? Navigator.push(context, MaterialPageRoute(builder: (context) => Home(query,Give,Take))) : Navigator.push(context, MaterialPageRoute(builder: (context) => SharedAuth(name,false))); }); }, child: Scaffold( @@ -113,6 +115,7 @@ class _PinState extends State with SingleTickerProviderStateMixin { List list = List(); try { list = await localAuthentication.getAvailableBiometrics(); + print("no..."+list[0].toString()); bool auth = false; if (list.length > 0) { if (list.contains(BiometricType.fingerprint)) { @@ -143,7 +146,12 @@ class _PinState extends State with SingleTickerProviderStateMixin { return false; } } catch (e) { - print(e.toString()); + print("------------"+e.toString()); + return false; + Fluttertoast.showToast( + msg: 'Please add a Bio-metric lock', + toastLength: Toast.LENGTH_LONG + ); } } } diff --git a/lib/screens/auth/profile.dart b/lib/screens/auth/profile.dart index 44d42da..8fdcd47 100644 --- a/lib/screens/auth/profile.dart +++ b/lib/screens/auth/profile.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -// import 'package:fluttertoast/fluttertoast.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import '../../main.dart'; import 'package:http/http.dart'as http; @@ -42,7 +42,7 @@ class _ProfileState extends State { children: [ CircleAvatar( child: Text( - 'AC', style: TextStyle(color: Colors.white, fontSize: 25),), + widget.email[0].toUpperCase(), style: TextStyle(color: Colors.white, fontSize: 30,fontWeight: FontWeight.bold),), backgroundColor: Color(0xfff96060), radius: 50, ), @@ -124,7 +124,7 @@ class _ProfileState extends State { companyname1 = await getCompanyName(); number1 = await getNumber(); bool result = await UpdateUserTable(); - // result ? Fluttertoast.showToast(msg: 'Changes saved successfully',toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.CENTER ): Fluttertoast.showToast(msg: 'Something Went Wrong, try again',toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.CENTER );; + result ? Fluttertoast.showToast(msg: 'Changes saved successfully',toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.CENTER ): Fluttertoast.showToast(msg: 'Something Went Wrong, try again',toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.CENTER );; Navigator.pop(context); }, child: Container( diff --git a/lib/screens/auth/register.dart b/lib/screens/auth/register.dart index c43d5cc..26719df 100644 --- a/lib/screens/auth/register.dart +++ b/lib/screens/auth/register.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:flutter/material.dart'; -// import 'package:fluttertoast/fluttertoast.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:login_ui/config/database_helper.dart'; import 'package:login_ui/config/palette.dart'; @@ -154,14 +154,14 @@ class _RegisterState extends State { if (jsonDecode(res.body) == "Account already exists") { print('Account already exists, Please login'); - // Fluttertoast.showToast( - // msg: 'Account already exists, Please login', - // toastLength: Toast.LENGTH_LONG); + Fluttertoast.showToast( + msg: 'Account already exists, Please login', + toastLength: Toast.LENGTH_LONG); } else { if (jsonDecode(res.body) == "true") { print('Account Created'); - // Fluttertoast.showToast( - // msg: "Account Created", toastLength: Toast.LENGTH_SHORT); + Fluttertoast.showToast( + msg: "Account Created", toastLength: Toast.LENGTH_SHORT); List> query = await DatabaseHelper.instance.queryAll(); int Take = await DatabaseHelper.instance.TotalToTake(); @@ -172,8 +172,8 @@ class _RegisterState extends State { Navigator.push(context, MaterialPageRoute(builder: (context) => Home(query, Give, Take))); } else { - // Fluttertoast.showToast( - // msg: "Error, Try Again later", toastLength: Toast.LENGTH_LONG); + Fluttertoast.showToast( + msg: "Error, Try Again later", toastLength: Toast.LENGTH_LONG); } } setState(() { diff --git a/lib/screens/auth/settings.dart b/lib/screens/auth/settings.dart index 8cb4786..66d13eb 100644 --- a/lib/screens/auth/settings.dart +++ b/lib/screens/auth/settings.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:login_ui/screens/auth/shared_auth.dart'; import '../../main.dart'; @@ -23,7 +24,16 @@ class _SettingState extends State { ), body: Column( children: [ - Bar(Icons.person, 'Change Password'), + GestureDetector( + onTap: ()async{ + String name = await getName(); + Navigator.push(context, MaterialPageRoute(builder: (context) => SharedAuth(name, true))); + }, + child: Bar( + Icons.person, + 'Change Password' + ) + ), GestureDetector( onTap: (){ setState(() { diff --git a/lib/screens/auth/share.dart b/lib/screens/auth/share.dart index 4dd2a98..4029ccc 100644 --- a/lib/screens/auth/share.dart +++ b/lib/screens/auth/share.dart @@ -3,7 +3,8 @@ import 'package:share/share.dart'; class Reminder extends StatefulWidget { String defaultMsg; - Reminder(this.defaultMsg); + bool invite; + Reminder(this.defaultMsg,this.invite); @override _ReminderState createState() => _ReminderState(); } @@ -29,7 +30,7 @@ class _ReminderState extends State { children: [ SizedBox(height: 20,), Text( - 'Customize your Message', + widget.invite?'Invite a friend':'Customize your Message', style: TextStyle( color: Colors.black, fontSize: 23, diff --git a/lib/screens/auth/shared_auth.dart b/lib/screens/auth/shared_auth.dart index 5cc8dec..d2fcb4d 100644 --- a/lib/screens/auth/shared_auth.dart +++ b/lib/screens/auth/shared_auth.dart @@ -1,15 +1,18 @@ import 'package:flutter/material.dart'; -// import 'package:fluttertoast/fluttertoast.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:login_ui/config/database_helper.dart'; import 'package:login_ui/config/palette.dart'; +import 'package:login_ui/screens/auth/change_password.dart'; import '../../main.dart'; import '../background_paint.dart'; import 'home.dart'; +import 'change_password.dart'; class SharedAuth extends StatefulWidget { String name; - SharedAuth(this.name); + bool changePass; + SharedAuth(this.name,this.changePass); @override _SharedAuthState createState() => _SharedAuthState(); } @@ -136,10 +139,11 @@ class _SharedAuthState extends State await DatabaseHelper.instance.queryAll(); int Take = await DatabaseHelper.instance.TotalToTake(); int Give = await DatabaseHelper.instance.TotalToGive(); - Navigator.push(context, + widget.changePass?Navigator.push(context, MaterialPageRoute(builder: (context)=>ChangePass())):Navigator.push(context, MaterialPageRoute(builder: (context) => Home(query, Give, Take))); + }else{ - // Fluttertoast.showToast(msg: 'Incorrect Password',toastLength: Toast.LENGTH_LONG); + Fluttertoast.showToast(msg: 'Incorrect Password',toastLength: Toast.LENGTH_LONG); } setState((){ isLoading = false; @@ -148,8 +152,7 @@ class _SharedAuthState extends State Widget _RoundContinueButton(isLoading) { return RawMaterialButton( - onPressed: () {}, - // => (passctrl.text == '') ? Fluttertoast.showToast(msg: 'Please Enter Your password',toastLength: Toast.LENGTH_LONG) : verify(), + onPressed: () => (passctrl.text == '') ? Fluttertoast.showToast(msg: 'Please Enter Your password',toastLength: Toast.LENGTH_LONG) : verify(), elevation: 0.0, fillColor: Palette.darkBlue, splashColor: Palette.darkOrange, diff --git a/pubspec.lock b/pubspec.lock index d56ef3e..09dab88 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -135,6 +135,13 @@ packages: description: flutter source: sdk version: "0.0.0" + fluttertoast: + dependency: "direct main" + description: + name: fluttertoast + url: "https://pub.dartlang.org" + source: hosted + version: "8.0.8" font_awesome_flutter: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 63f1a36..2ed0b85 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,7 +34,7 @@ dependencies: path_provider: ^1.6.18 sqflite: ^1.3.1+1 http: ^0.12.0+4 - + fluttertoast: ^8.0.8 shared_preferences: ^0.5.12+4 share: any webview_flutter: From 38d89712758e05391035204703fe5dbb622b00a2 Mon Sep 17 00:00:00 2001 From: Hanna Sabu Mampallil Date: Sat, 1 Jan 2022 15:13:07 +0530 Subject: [PATCH 4/9] change password --- lib/screens/auth/change_password.dart | 116 ++++++++++++++++++++------ lib/screens/auth/shared_auth.dart | 4 +- 2 files changed, 94 insertions(+), 26 deletions(-) diff --git a/lib/screens/auth/change_password.dart b/lib/screens/auth/change_password.dart index 726a78f..4661ad2 100644 --- a/lib/screens/auth/change_password.dart +++ b/lib/screens/auth/change_password.dart @@ -8,6 +8,8 @@ import '../../main.dart'; import '../background_paint.dart'; import 'home.dart'; import 'change_password.dart'; +import 'package:http/http.dart'as http; +import 'dart:convert'; class ChangePass extends StatefulWidget { @@ -18,6 +20,7 @@ class ChangePass extends StatefulWidget { class _ChangePassState extends State with SingleTickerProviderStateMixin { AnimationController _controller; TextEditingController passctrl,cpassctrl; + String cpass_; bool pass = true,cpass=true; bool isLoading = false; @override @@ -70,6 +73,7 @@ class _ChangePassState extends State with SingleTickerProviderStateM padding: EdgeInsets.symmetric(vertical: 16), child: TextField( controller: passctrl, + obscureText: pass, decoration: InputDecoration( hintText: 'New Password', @@ -96,10 +100,13 @@ class _ChangePassState extends State with SingleTickerProviderStateM Padding( padding: EdgeInsets.symmetric(vertical: 16), child: TextField( - controller: cpassctrl, + // controller: cpassctrl, + onChanged: (val){ + cpass_=val; + }, obscureText: cpass, decoration: InputDecoration( - hintText: ' Confirm New Password', + hintText: 'Confirm New Password', hintStyle: TextStyle(color: Colors.black54, fontSize: 20), prefixIcon: Icon( Icons.vpn_key, @@ -120,28 +127,68 @@ class _ChangePassState extends State with SingleTickerProviderStateM )), ), ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 16.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Change Password', - style: const TextStyle( - fontWeight: FontWeight.w800, - color: Palette.darkBlue, - fontSize: 24, - ), - ), - Expanded( - child: Center( - // child: _LoadingIndicator(isLoading), - ), - ), - // _RoundContinueButton(isLoading), - ], - ), - ), + + Center( + child: InkWell( + onTap: () async { + String message=""; + bool result; + if(passctrl.text.length<6) + setState(() { + message="Enter the password(max 6)"; + }); + else if(cpass_==null) + setState(() { + message="Please confirm new password"; + }); + else if(cpass_!=passctrl.text){ + setState(() { + message="Password should match"; + }); + + } + else{ + result = await UpdateUserTable(); + setState(() { + if(result){ + message="Password updated successfull"; + addPassToSF(cpass_); + } + + else + message="Something Went Wrong, try again"; + }); + } + Fluttertoast.showToast(msg: message,toastLength: Toast.LENGTH_SHORT ); + if(result){ + Navigator.pop(context); + Navigator.pop(context); + Navigator.pop(context); + } + + // (namectrl == null) ? addNameToSF(widget.name) : addNameToSF(namectrl); + // (number == null) ? addNumberToSF(widget.number) : addNumberToSF(number); + // (companyname == null) ? addCompanyNameToSF(widget.companyname) : addCompanyNameToSF(companyname); + // name1 = await getName(); + // email1 = await getEmail(); + // companyname1 = await getCompanyName(); + // number1 = await getNumber(); + // bool result = await UpdateUserTable(); + // result ? Fluttertoast.showToast(msg: 'Changes saved successfully',toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.CENTER ): Fluttertoast.showToast(msg: 'Something Went Wrong, try again',toastLength: Toast.LENGTH_SHORT,gravity: ToastGravity.CENTER ); + + }, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 85, vertical: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(8)), + color: Color(0xfff96060), + ), + child: Text('Change Password', + style: TextStyle(fontSize: 18, color: Colors.white), + ), + ), + ), + ), ], ), ), @@ -150,5 +197,26 @@ class _ChangePassState extends State with SingleTickerProviderStateM ), ]), ); + + } + Future UpdateUserTable()async { + var url = "https://355668.xyz/Authentication/update_info.php"; + String email=await getEmail(); + String name=await getName(); + String shop=await getCompanyName(); + int number=await getNumber(); + var data = { + "email" : email??'', + "name": name??'', + "ShopName": shop??'', + "number": number??'', + "pass":cpass_ + }; + var res = await http.post(url, body: data); + if(jsonDecode(res.body) == "true"){ + return true; + }else{ + return false; + } } } \ No newline at end of file diff --git a/lib/screens/auth/shared_auth.dart b/lib/screens/auth/shared_auth.dart index d2fcb4d..57deca1 100644 --- a/lib/screens/auth/shared_auth.dart +++ b/lib/screens/auth/shared_auth.dart @@ -76,7 +76,7 @@ class _SharedAuthState extends State controller: passctrl, obscureText: pass, decoration: InputDecoration( - hintText: 'Password', + hintText: widget.changePass?'Current Password':'Password', hintStyle: TextStyle(color: Colors.black54, fontSize: 20), prefixIcon: Icon( Icons.vpn_key, @@ -103,7 +103,7 @@ class _SharedAuthState extends State mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - 'Verify', + widget.changePass?'Change Password':'Log In', style: const TextStyle( fontWeight: FontWeight.w800, color: Palette.darkBlue, From 1dc086d4f2eb3672d39d41c3404c5a4b1d6a92a2 Mon Sep 17 00:00:00 2001 From: Hanna Sabu Mampallil Date: Sun, 2 Jan 2022 08:54:28 +0530 Subject: [PATCH 5/9] forgot password --- lib/screens/auth/SignIn.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/screens/auth/SignIn.dart b/lib/screens/auth/SignIn.dart index 5199643..a5b5811 100644 --- a/lib/screens/auth/SignIn.dart +++ b/lib/screens/auth/SignIn.dart @@ -6,6 +6,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:login_ui/config/database_helper.dart'; import 'package:login_ui/config/palette.dart'; import 'package:login_ui/main.dart'; +import 'package:login_ui/screens/auth/change_password.dart'; import 'home.dart'; class SignIn extends StatefulWidget { @@ -19,7 +20,7 @@ class _SignInState extends State { bool isLoading = false; @override void initState() { - // TODO: implement initState + super.initState(); emailctrl = new TextEditingController(); passctrl = new TextEditingController(); @@ -91,6 +92,20 @@ class _SignInState extends State { )), ), ), + InkWell( + onTap: (){ + Navigator.push(context, MaterialPageRoute(builder: (context)=>ChangePass())); + }, + child: Align( + alignment: Alignment.topRight, + child: Text( + 'Forgot password', + style: TextStyle( + decoration: TextDecoration.underline + ), + ), + ), + ), Padding( padding: const EdgeInsets.symmetric(vertical: 16.0), child: Row( From 78b650f94df1d8a244f87713430bc8a53a9c652e Mon Sep 17 00:00:00 2001 From: Hanna Sabu Mampallil Date: Sun, 2 Jan 2022 09:18:31 +0530 Subject: [PATCH 6/9] change name --- android/app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 6a3274e..3c16d68 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ FlutterApplication and put your custom class here. --> Date: Sun, 2 Jan 2022 17:20:13 +0530 Subject: [PATCH 7/9] adding necessary conditions --- lib/screens/auth/add.dart | 72 ++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/lib/screens/auth/add.dart b/lib/screens/auth/add.dart index e638c85..2e17612 100644 --- a/lib/screens/auth/add.dart +++ b/lib/screens/auth/add.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:login_ui/config/database_helper.dart'; import 'package:toggle_switch/toggle_switch.dart'; @@ -189,37 +190,46 @@ class _AddState extends State { Center( child: InkWell( onTap: () async { - print(toggleValue); - int i = - await DatabaseHelper.instance.insert({ - DatabaseHelper.columnName: - _controller1.text, - DatabaseHelper.columnAmount: - _controller2, - DatabaseHelper.columnPhone: - _controller3.text, - DatabaseHelper.columnCondition: - (toggleValue == false) - ? 'Give' - : 'Take', - DatabaseHelper.columnDescription: _controller4.text, - DatabaseHelper.columnIcon: selectedIndex - }); - List> query = - await DatabaseHelper.instance - .queryAll(); - Take = await DatabaseHelper.instance.TotalToTake(); - Give = await DatabaseHelper.instance.TotalToGive(); - widget.Take = Take; - widget.Give = Give; - closePopup(); - setState(() { - _controller1.text = ''; - _controller3.text = ''; - _controller2 = 0; - widget.query = query; - toggleValue = false; - }); + if(_controller1.text=='') + { + Fluttertoast.showToast(msg: 'Please enter name'); + } + else if(_controller2==null) + { + Fluttertoast.showToast(msg: 'Please enter amount'); + } + else{ + int i = + await DatabaseHelper.instance.insert({ + DatabaseHelper.columnName: + _controller1.text, + DatabaseHelper.columnAmount: + _controller2, + DatabaseHelper.columnPhone: + _controller3.text, + DatabaseHelper.columnCondition: + (toggleValue == false) + ? 'Give' + : 'Take', + DatabaseHelper.columnDescription: _controller4.text, + DatabaseHelper.columnIcon: selectedIndex + }); + List> query = + await DatabaseHelper.instance + .queryAll(); + Take = await DatabaseHelper.instance.TotalToTake(); + Give = await DatabaseHelper.instance.TotalToGive(); + widget.Take = Take; + widget.Give = Give; + closePopup(); + setState(() { + _controller1.text = ''; + _controller3.text = ''; + _controller2 = 0; + widget.query = query; + toggleValue = false; + }); + } }, child: Container( padding: EdgeInsets.symmetric( From 56335863346acef818a5f20cbbfe0b40a6541aa0 Mon Sep 17 00:00:00 2001 From: Hanna Sabu Mampallil <68439953+hanna2001@users.noreply.github.com> Date: Sun, 2 Jan 2022 17:31:55 +0530 Subject: [PATCH 8/9] Update README.md --- README.md | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d71bc75..71c7d7f 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,3 @@ -# login_ui +# RECORD KEEPER -A new Flutter application. - -## Getting Started - -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +A flutter application which contains all our money records. From 99742857e294e241d1dc99fce42722309cb3d0f2 Mon Sep 17 00:00:00 2001 From: Hanna Sabu Mampallil Date: Fri, 7 Jan 2022 23:52:41 +0530 Subject: [PATCH 9/9] forgot password --- lib/main.dart | 4 +- lib/screens/auth/SignIn.dart | 3 +- lib/screens/auth/change_password.dart | 18 +-- lib/screens/auth/forgotpass_email.dart | 208 +++++++++++++++++++++++++ 4 files changed, 221 insertions(+), 12 deletions(-) create mode 100644 lib/screens/auth/forgotpass_email.dart diff --git a/lib/main.dart b/lib/main.dart index dff980f..5b59bfe 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -80,4 +80,6 @@ Logout() async { prefs.remove('Number'); prefs.remove('companyName'); exit(0); -} \ No newline at end of file +} + + diff --git a/lib/screens/auth/SignIn.dart b/lib/screens/auth/SignIn.dart index a5b5811..66232ec 100644 --- a/lib/screens/auth/SignIn.dart +++ b/lib/screens/auth/SignIn.dart @@ -7,6 +7,7 @@ import 'package:login_ui/config/database_helper.dart'; import 'package:login_ui/config/palette.dart'; import 'package:login_ui/main.dart'; import 'package:login_ui/screens/auth/change_password.dart'; +import 'package:login_ui/screens/auth/forgotpass_email.dart'; import 'home.dart'; class SignIn extends StatefulWidget { @@ -94,7 +95,7 @@ class _SignInState extends State { ), InkWell( onTap: (){ - Navigator.push(context, MaterialPageRoute(builder: (context)=>ChangePass())); + Navigator.push(context, MaterialPageRoute(builder: (context)=>EnterEmail())); }, child: Align( alignment: Alignment.topRight, diff --git a/lib/screens/auth/change_password.dart b/lib/screens/auth/change_password.dart index 4661ad2..a3218a8 100644 --- a/lib/screens/auth/change_password.dart +++ b/lib/screens/auth/change_password.dart @@ -12,12 +12,15 @@ import 'package:http/http.dart'as http; import 'dart:convert'; class ChangePass extends StatefulWidget { - + String email; + bool forgot; + ChangePass({this.email,this.forgot}); @override _ChangePassState createState() => _ChangePassState(); } class _ChangePassState extends State with SingleTickerProviderStateMixin { + AnimationController _controller; TextEditingController passctrl,cpassctrl; String cpass_; @@ -163,7 +166,8 @@ class _ChangePassState extends State with SingleTickerProviderStateM if(result){ Navigator.pop(context); Navigator.pop(context); - Navigator.pop(context); + if(widget.forgot==null) + Navigator.pop(context); } // (namectrl == null) ? addNameToSF(widget.name) : addNameToSF(namectrl); @@ -200,16 +204,10 @@ class _ChangePassState extends State with SingleTickerProviderStateM } Future UpdateUserTable()async { - var url = "https://355668.xyz/Authentication/update_info.php"; + var url = "https://355668.xyz/Authentication/forgot_pass.php"; String email=await getEmail(); - String name=await getName(); - String shop=await getCompanyName(); - int number=await getNumber(); var data = { - "email" : email??'', - "name": name??'', - "ShopName": shop??'', - "number": number??'', + "email" : widget.email??email, "pass":cpass_ }; var res = await http.post(url, body: data); diff --git a/lib/screens/auth/forgotpass_email.dart b/lib/screens/auth/forgotpass_email.dart new file mode 100644 index 0000000..ac42683 --- /dev/null +++ b/lib/screens/auth/forgotpass_email.dart @@ -0,0 +1,208 @@ +import 'dart:isolate'; + +import 'package:flutter/material.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +import 'package:login_ui/config/database_helper.dart'; +import 'package:login_ui/config/palette.dart'; +import 'package:login_ui/screens/auth/change_password.dart'; +import '../../main.dart'; +import '../background_paint.dart'; +import 'home.dart'; +import 'change_password.dart'; +import 'package:http/http.dart'as http; +import 'dart:convert'; + +class EnterEmail extends StatefulWidget { + + @override + _EnterEmailState createState() => _EnterEmailState(); +} + +class _EnterEmailState extends State with SingleTickerProviderStateMixin { + + AnimationController _controller; + bool isLoading = false; + String email='',sec_ans=''; + @override + void initState() { + _controller = + AnimationController(vsync: this, duration: Duration(seconds: 4)); + + super.initState(); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + @override + Widget build(BuildContext context) { + return Scaffold( + resizeToAvoidBottomInset: false, + body: Stack(children: [ + SizedBox.expand( + child: CustomPaint( + painter: BackgroundPainter( + animation: _controller.view, + ), + ), + ), + Padding( + padding: const EdgeInsets.all(32), + child: Column( + children: [ + Expanded( + flex: 4, + child: Align( + alignment: Alignment.centerLeft, + child: Text( + 'Forgot Password', + style: TextStyle( + color: Colors.white, + fontSize: 30, + fontWeight: FontWeight.w500), + ), + ), + ), + Expanded( + flex: 5, + child: ListView( + children: [ + Padding( + padding: EdgeInsets.symmetric(vertical: 16), + child: TextField( + onChanged: (value){ + email=value; + }, + decoration: InputDecoration( + hintText: 'Enter email', + hintStyle: TextStyle(color: Colors.black54, fontSize: 20), + prefixIcon: Icon( + Icons.email, + color: Colors.black54, + size: 25, + ), + ), + ), + ), + + Padding( + padding: const EdgeInsets.symmetric(vertical: 16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'Change Password', + style: const TextStyle( + fontWeight: FontWeight.w800, + color: Palette.darkBlue, + fontSize: 24, + ), + ), + Expanded( + child: Center( + child: _LoadingIndicator(isLoading), + ), + ), + _RoundContinueButton(isLoading), + ], + ), + ), + ], + ), + ), + ], + ), + ), + ]), + ); + } + + // void verify() async{ + // setState((){ + // isLoading = true; + // }); + // String pass = await getPass(); + // if(passctrl.text == pass){ + // List> query = + // await DatabaseHelper.instance.queryAll(); + // int Take = await DatabaseHelper.instance.TotalToTake(); + // int Give = await DatabaseHelper.instance.TotalToGive(); + // widget.changePass?Navigator.push(context, MaterialPageRoute(builder: (context)=>ChangePass())):Navigator.push(context, + // MaterialPageRoute(builder: (context) => Home(query, Give, Take))); + + // }else{ + // Fluttertoast.showToast(msg: 'Incorrect Password',toastLength: Toast.LENGTH_LONG); + // } + // setState((){ + // isLoading = false; + // }); + // } + + Widget _RoundContinueButton(isLoading) { + return RawMaterialButton( + onPressed: ()async{ + + if(email=='') + { + Fluttertoast.showToast(msg: 'Please Enter Your Email',toastLength: Toast.LENGTH_LONG); + } + else{ + print("yes"); + checkEmail(); + + } + + + }, + // onPressed: () => (passctrl.text == '') ? Fluttertoast.showToast(msg: 'Please Enter Your password',toastLength: Toast.LENGTH_LONG) : verify(), + elevation: 0.0, + fillColor: Palette.darkBlue, + splashColor: Palette.darkOrange, + padding: const EdgeInsets.all(22.0), + shape: const CircleBorder(), + child: const Icon( + FontAwesomeIcons.longArrowAltRight, + color: Colors.white, + size: 24.0, + ), + ); + } + void checkEmail() async{ + setState(() { + isLoading = true; + }); + var url = "https://355668.xyz/Authentication/forgot_pass_email.php"; + var data = { + "email": email, + // "sec_ans":sec_ans + + }; + var res = await http.post(url, body: data); + var body=jsonDecode(res.body); + print(body); + if(body['result'] == "dont have account") + Fluttertoast.showToast(msg: 'No account Please Register',toastLength: Toast.LENGTH_LONG); + else{ + Navigator.push(context, MaterialPageRoute(builder: (context)=>ChangePass(email: email,forgot: true,))); + } + + setState(() { + isLoading = false; + }); + } + + Widget _LoadingIndicator(bool isLoading) { + return ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 100), + child: Visibility( + visible: isLoading, + child: const LinearProgressIndicator( + backgroundColor: Palette.darkBlue, + ), + ), + ); + } +} \ No newline at end of file