From 055fadac008ce2afd4d6b5820024f9e56c9bab4c Mon Sep 17 00:00:00 2001 From: Shreyash <142shreyash.shreyash@gmail.com> Date: Sun, 22 Mar 2020 11:18:09 +0530 Subject: [PATCH] added final display page --- main.py | 5 ++ .../lib/Contractor/Contractor_register.dart | 9 +- rozgaar/lib/Contractor/contractor_login.dart | 8 +- .../Contractor/contractor_reqirenments.dart | 52 +++++------ rozgaar/lib/Contractor/resultDisplay.dart | 78 ++++++++++------- rozgaar/lib/Labour/labour.dart | 58 +++++++------ rozgaar/lib/Labour/labour_home.dart | 87 ------------------- rozgaar/lib/Labour/labour_login.dart | 9 +- rozgaar/pubspec.lock | 2 +- rozgaar/pubspec.yaml | 3 +- 10 files changed, 119 insertions(+), 192 deletions(-) delete mode 100644 rozgaar/lib/Labour/labour_home.dart diff --git a/main.py b/main.py index dcb1a98..2b7ad97 100644 --- a/main.py +++ b/main.py @@ -54,6 +54,11 @@ def get_details_from_database(): jsondata = json.dumps(jsondata) print(jsondata) + json_data={ + 'prediction':{ + + } + } return jsondata diff --git a/rozgaar/lib/Contractor/Contractor_register.dart b/rozgaar/lib/Contractor/Contractor_register.dart index 67aa317..e89250f 100644 --- a/rozgaar/lib/Contractor/Contractor_register.dart +++ b/rozgaar/lib/Contractor/Contractor_register.dart @@ -4,8 +4,7 @@ import 'package:http/http.dart'; class ContractorRegistration extends StatefulWidget { @override - _ContractorRegistrationState createState() => - _ContractorRegistrationState(); + _ContractorRegistrationState createState() => _ContractorRegistrationState(); } class _ContractorRegistrationState extends State { @@ -56,11 +55,9 @@ class _ContractorRegistrationState extends State { _phone = val; }, ), - SizedBox( height: 10.0, ), - RaisedButton( textColor: Colors.white, color: Colors.lightBlue, @@ -68,9 +65,7 @@ class _ContractorRegistrationState extends State { splashColor: Colors.grey, child: Text( 'Submit', - style: TextStyle( - fontSize: 18.0 - ), + style: TextStyle(fontSize: 18.0), ), onPressed: () async { if (_formKey.currentState.validate()) { diff --git a/rozgaar/lib/Contractor/contractor_login.dart b/rozgaar/lib/Contractor/contractor_login.dart index 6eb9e72..0f838fa 100644 --- a/rozgaar/lib/Contractor/contractor_login.dart +++ b/rozgaar/lib/Contractor/contractor_login.dart @@ -63,9 +63,7 @@ class _ContractorLoginState extends State { splashColor: Colors.grey, child: Text( 'Login', - style: TextStyle( - fontSize: 18.0 - ), + style: TextStyle(fontSize: 18.0), ), onPressed: () async { formKey.currentState.save(); @@ -99,9 +97,7 @@ class _ContractorLoginState extends State { splashColor: Colors.grey, child: Text( 'Register', - style: TextStyle( - fontSize: 18.0 - ), + style: TextStyle(fontSize: 18.0), ), onPressed: () { Navigator.push( diff --git a/rozgaar/lib/Contractor/contractor_reqirenments.dart b/rozgaar/lib/Contractor/contractor_reqirenments.dart index 4b2c60a..70d05c8 100644 --- a/rozgaar/lib/Contractor/contractor_reqirenments.dart +++ b/rozgaar/lib/Contractor/contractor_reqirenments.dart @@ -48,6 +48,7 @@ class _ContractorRequirenmentState extends State { appBar: new AppBar( title: Text("Requirements"), ), + resizeToAvoidBottomPadding: false, body: Container( padding: EdgeInsets.all(10.0), child: Form( @@ -68,28 +69,6 @@ class _ContractorRequirenmentState extends State { _numberOfLabours = val; }, ), - TextFormField( - decoration: InputDecoration( - border: UnderlineInputBorder(), - filled: true, - hintText: "INR", - labelText: "Wage per day", - ), - onSaved: (val) { - _wage = val; - }, - ), - TextFormField( - decoration: InputDecoration( - border: UnderlineInputBorder(), - filled: true, - hintText: "Hours", - labelText: "Work hours required", - ), - onSaved: (val) { - _workHours = val; - }, - ), ListTile( title: Text('Skill required:'), trailing: DropdownButton( @@ -103,7 +82,6 @@ class _ContractorRequirenmentState extends State { items: _dropDownMenuItems, ), ), - SizedBox(height: 15,), Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -121,7 +99,7 @@ class _ContractorRequirenmentState extends State { child: Text( 'Get location', ), - onPressed: (){ + onPressed: () { FetchLocation().returnLocation().then((result) { print(result); setState(() { @@ -138,7 +116,28 @@ class _ContractorRequirenmentState extends State { SizedBox( height: 10.0, ), - + TextFormField( + decoration: InputDecoration( + border: UnderlineInputBorder(), + filled: true, + hintText: "INR", + labelText: "Wage per day", + ), + onSaved: (val) { + _wage = val; + }, + ), + TextFormField( + decoration: InputDecoration( + border: UnderlineInputBorder(), + filled: true, + hintText: "Hours", + labelText: "Work hours required", + ), + onSaved: (val) { + _workHours = val; + }, + ), RaisedButton( textColor: Colors.white, color: Colors.lightBlue, @@ -171,7 +170,8 @@ class _ContractorRequirenmentState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => ResultDisplay(response))); + builder: (context) => + ResultDisplay(json.decode(response.body)))); }) ], ))), diff --git a/rozgaar/lib/Contractor/resultDisplay.dart b/rozgaar/lib/Contractor/resultDisplay.dart index 0d78358..5c96fc0 100644 --- a/rozgaar/lib/Contractor/resultDisplay.dart +++ b/rozgaar/lib/Contractor/resultDisplay.dart @@ -1,52 +1,64 @@ import 'package:flutter/material.dart'; +import 'package:http/http.dart'; +import 'dart:convert'; class ResultDisplay extends StatefulWidget { var response; ResultDisplay(this.response); @override - _ResultDisplayState createState() => _ResultDisplayState(); + _ResultDisplayState createState() => _ResultDisplayState(this.response); } class _ResultDisplayState extends State { var response; - resultDisplay(var x) { - this.response = x; - } + _ResultDisplayState(this.response); + + // var notesJson = json.decode(response); @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: Text("Best results for your search!"), - ), - body: ListView.builder( - itemBuilder: (context, index) { - return Card( - child: Padding( - padding: const EdgeInsets.only(top: 32.0, bottom: 32.0, left: 16.0, right: 16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - response[index].title, - style: TextStyle( - fontSize: 22, - fontWeight: FontWeight.bold + appBar: AppBar( + title: Text("responses"), + ), + body: ListView.builder( + itemBuilder: (context, index) { + return Card( + child: Padding( + padding: const EdgeInsets.only( + top: 32.0, bottom: 32.0, left: 16.0, right: 16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + response[index]["name"].toString(), + style: + TextStyle(fontSize: 22, fontWeight: FontWeight.bold), + ), + Text( + "age: " + response[index]["age"].toString(), + style: TextStyle(color: Colors.grey.shade600), + ), + Text( + "gender: " + response[index]["gender"].toString(), + style: TextStyle(color: Colors.grey.shade600), + ), + Text( + "distance: " + + response[index]["distance"].toString() + + " km", + style: TextStyle(color: Colors.grey.shade600), ), - ), - Text( - response[index].text, - style: TextStyle( - color: Colors.grey.shade600 + Text( + "contact no. " + response[index]["contact"].toString(), + style: TextStyle(color: Colors.grey.shade600), ), - ), - ], + ], + ), ), - ), - ); - }, - itemCount: response.length, - ) - ); + ); + }, + itemCount: response.length, + )); } } diff --git a/rozgaar/lib/Labour/labour.dart b/rozgaar/lib/Labour/labour.dart index 53f41c8..69183fd 100644 --- a/rozgaar/lib/Labour/labour.dart +++ b/rozgaar/lib/Labour/labour.dart @@ -6,7 +6,7 @@ class Labour extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - child: Scaffold( + child: Scaffold( appBar: new AppBar( title: Text("Home"), actions: [ @@ -15,33 +15,39 @@ class Labour extends StatelessWidget { ), body: new Container( child: new Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - ButtonBar( - alignment: MainAxisAlignment.spaceAround, - - children: [ - RaisedButton( - textColor: Colors.white, - color: Colors.lightBlue, - padding: EdgeInsets.fromLTRB(9, 9, 9, 9), - splashColor: Colors.grey, - child: Text( - 'Register', - style: TextStyle( - fontSize: 18.0, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Card( + color: Color.fromARGB(250, 35, 63, 126), + margin: EdgeInsets.all(20.0), + elevation: 0.0, + child: Container( + height: 100.0, + child: InkWell( + splashColor: Colors.black45, + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => LabourRegister()), + ); + }, + child: Row( + children: [ + Expanded( + child: Text( + 'Register', + style: TextStyle(fontSize: 40, color: Colors.white), + textAlign: TextAlign.center, + ), ), - ), - onPressed: () { - Navigator.push( - context, MaterialPageRoute(builder: (context) => LabourRegister())); - }, + ], ), - ], + ), ), - ]), + ), + ], + ), ), - ) - ); + )); } -} \ No newline at end of file +} diff --git a/rozgaar/lib/Labour/labour_home.dart b/rozgaar/lib/Labour/labour_home.dart deleted file mode 100644 index 6c55dc3..0000000 --- a/rozgaar/lib/Labour/labour_home.dart +++ /dev/null @@ -1,87 +0,0 @@ -import 'dart:convert'; -import 'package:flutter/material.dart'; -import 'package:http/http.dart'; - -class LabourHome extends StatefulWidget { - - Response data; - LabourHome(this.data); - - @override - _LabourHomeState createState() => _LabourHomeState(this.data); -} - -class _LabourHomeState extends State { - - Response data; - _LabourHomeState(this.data); - bool hasWork = false; - bool hasDenied = false; - bool hasAccepted = false; - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text( - 'Labour Home' - ), - actions: [ - IconButton(icon: Icon(Icons.refresh), onPressed: () async { - Response response = await get( - 'http://httpbin.org/json', //api endpoint for getting json response from server - ); - print(response.body); - setState(() { - // If response contains info that work is alloted, then set hasWork to true - data = response; - print(data.body); - }); - }), - ], - ), - body: Container( - padding: EdgeInsets.all(10.0), - child: Column( - children: [ - Text( - '${jsonDecode(data.body)}' //Show the allotted work if any here, also the location in text field below - ), - SizedBox(height: 10.0), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - RaisedButton( - child: Text('Accept'), - onPressed: hasDenied || hasAccepted ? null : (){ - // print(jsonDecode(data.body)['json']['email']); - // send request to server to accept database in form of json - setState(() { - // Accept when previously not accepted - hasAccepted = true; - }); - }, - ), - SizedBox( - width: 5.0, - ), - RaisedButton( - child: Text('Deny'), - onPressed: hasDenied ? null : () { - // print(jsonDecode(data.body)['json']['email']); - // send request to server to update database in form of json - setState(() { - // Deny when previously not denied - hasDenied = true; - hasAccepted = false; - }); - }, - ), - ], - ), - ], - ), - ), - ); - } -} \ No newline at end of file diff --git a/rozgaar/lib/Labour/labour_login.dart b/rozgaar/lib/Labour/labour_login.dart index ac23554..61e4576 100644 --- a/rozgaar/lib/Labour/labour_login.dart +++ b/rozgaar/lib/Labour/labour_login.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'package:rozgaar/Labour/labour_home.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart'; @@ -81,10 +80,10 @@ class _LabourLoginState extends State { ); print(response.body); print(response.statusCode); - Navigator.push( - context, - MaterialPageRoute(builder: (context) => LabourHome(response)), - ); + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) => LabourHome(response)), + // ); } }, ) diff --git a/rozgaar/pubspec.lock b/rozgaar/pubspec.lock index 92198d3..5c8434f 100644 --- a/rozgaar/pubspec.lock +++ b/rozgaar/pubspec.lock @@ -44,7 +44,7 @@ packages: source: hosted version: "1.14.11" convert: - dependency: transitive + dependency: "direct main" description: name: convert url: "https://pub.dartlang.org" diff --git a/rozgaar/pubspec.yaml b/rozgaar/pubspec.yaml index 1279518..2658bdf 100644 --- a/rozgaar/pubspec.yaml +++ b/rozgaar/pubspec.yaml @@ -19,8 +19,9 @@ environment: dependencies: flutter: sdk: flutter - http: + http: ^0.12.0 location: ^2.3.5 + convert: ^2.1.1 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.