diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..61e1d02 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "BloodBank", + "request": "launch", + "type": "dart" + } + ] +} \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index f26c58a..c0e0e57 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -23,6 +23,7 @@ if (flutterVersionName == null) { apply plugin: 'com.android.application' apply plugin: 'kotlin-android' +apply plugin: 'com.google.gms.google-services' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { @@ -56,4 +57,5 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation platform('com.google.firebase:firebase-bom:27.0.0') } diff --git a/android/app/google-services.json b/android/app/google-services.json new file mode 100644 index 0000000..47a1178 --- /dev/null +++ b/android/app/google-services.json @@ -0,0 +1,40 @@ +{ + "project_info": { + "project_number": "631408157440", + "firebase_url": "https://bankblood-101-default-rtdb.firebaseio.com", + "project_id": "bankblood-101", + "storage_bucket": "bankblood-101.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:631408157440:android:580785dcc965a11d6949e5", + "android_client_info": { + "package_name": "com.example.blood_bank_app" + } + }, + "oauth_client": [ + { + "client_id": "631408157440-3u9bcqab7lejkver054rnagtfm81s0ah.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyC8YFH1eYQffjhBHDvffHXA5aBvKiJtO60" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "631408157440-3u9bcqab7lejkver054rnagtfm81s0ah.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index c505a86..2c6d077 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -8,6 +8,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.google.gms:google-services:4.3.5' } } diff --git a/lib/main.dart b/lib/main.dart deleted file mode 100644 index 370c3de..0000000 --- a/lib/main.dart +++ /dev/null @@ -1,203 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; - -void main() => runApp(MyApp()); - -class MyApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return new MaterialApp( - debugShowCheckedModeBanner: false, - home: MyHomePage(), - ); - } -} - -class MyHomePage extends StatelessWidget { - @override - Widget build(BuildContext context) { - Size size = MediaQuery.of(context).size; - return Scaffold( - body: SingleChildScrollView( - child: Container( - width: size.width, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Stack( - children: [ - ClipPath( - clipper: DrawClip(), - child: Container( - height: size.height / 2.4, - width: double.infinity, - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Color(0xffff5f6d), Color(0xffffc371)], - begin: Alignment.topLeft, - end: Alignment.bottomRight)), - ), - ), - Container( - height: size.height / 2.4, - width: double.infinity, - child: Image.network( - 'https://i.postimg.cc/WbyG2BVk/blood-bank-1.png'), - ) - ], - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: size.width * 0.1), - child: Text( - "SIGN IN", - style: GoogleFonts.mukta( - color: Color(0xffff5f6d), - fontSize: 30, - fontWeight: FontWeight.bold), - ), - ), - Padding( - padding: EdgeInsets.symmetric( - horizontal: size.width * 0.1, vertical: 10), - child: TextFormField( - decoration: InputDecoration( - border: UnderlineInputBorder(borderSide: BorderSide.none), - fillColor: Colors.grey[200], - hintText: 'Email Address', - filled: true), - ), - ), - Padding( - padding: EdgeInsets.symmetric( - horizontal: size.width * 0.1, vertical: 10), - child: TextFormField( - decoration: InputDecoration( - border: UnderlineInputBorder(borderSide: BorderSide.none), - fillColor: Colors.grey[200], - hintText: 'Password', - suffixIcon: Icon(Icons.remove_red_eye), - contentPadding: - EdgeInsets.symmetric(vertical: 15, horizontal: 10), - filled: true), - ), - ), - Padding( - padding: const EdgeInsets.only(left: 210), - child: Text( - "Forgot Password?", - style: GoogleFonts.mukta( - color: Colors.grey[500], - fontSize: 18, - fontWeight: FontWeight.bold), - ), - ), - Padding( - padding: EdgeInsets.symmetric( - horizontal: size.width * 0.1, vertical: 10), - child: FlatButton( - onPressed: null, - child: Material( - elevation: 10, - borderRadius: BorderRadius.circular(8), - child: Container( - decoration: BoxDecoration( - color: Color(0xffff5f6d), - borderRadius: BorderRadius.circular(8)), - height: 50, - child: Center( - child: Text( - "SIGN IN", - style: GoogleFonts.mukta( - color: Colors.white, fontWeight: FontWeight.bold), - )), - ), - ), - ), - ), - SizedBox( - height: 10, - ), - Center( - child: Text( - "OR", - style: GoogleFonts.mukta( - color: Colors.grey, - fontSize: 18, - fontWeight: FontWeight.bold), - ), - ), - SizedBox( - height: 10, - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: size.width * 0.1), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - social('https://i.postimg.cc/kgYNSMjg/search.png'), - social('https://i.postimg.cc/D0wRxwKY/facebook.png'), - ], - ), - ), - SizedBox( - height: 30, - ), - Center( - child: Text( - "Don,t have an account?", - style: GoogleFonts.mukta( - fontSize: 18, - color: Colors.grey, - fontWeight: FontWeight.w500), - ), - ), - Center( - child: Text( - "Sign Up", - style: GoogleFonts.mukta( - fontSize: 18, - color: Color(0xffff5f6d), - fontWeight: FontWeight.bold), - ), - ), - ], - ), - ), - ), - ); - } -} - -Widget social(String url) { - return Material( - borderRadius: BorderRadius.circular(8), - elevation: 10, - child: Padding( - padding: EdgeInsets.all(8), - child: Image.network( - url, - height: 28, - width: 28, - ), - ), - ); -} - -class DrawClip extends CustomClipper { - @override - Path getClip(Size size) { - //TODO: implement getClip - Path path = Path(); - path.lineTo(0, size.height); - path.lineTo(size.width * 0.1, size.height - 50); - path.lineTo(size.width * 0.9, size.height - 50); - path.lineTo(size.width, size.height - 100); - path.lineTo(size.width, 0); - return path; - } - - @override - bool shouldReclip(covariant CustomClipper oldCliper) { - return true; - } -} diff --git a/lib/views/data.dart b/lib/views/data.dart new file mode 100644 index 0000000..a32dd0c --- /dev/null +++ b/lib/views/data.dart @@ -0,0 +1,172 @@ +import 'package:blood_bank_app/views/userData.dart'; +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; + +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return new MaterialApp( + debugShowCheckedModeBanner: false, + home: MyHomePage(), + ); + } +} + +class MyHomePage extends StatelessWidget { + @override + Widget build(BuildContext context) { + Size size = MediaQuery.of(context).size; + return SafeArea( + child: Scaffold( + body: SingleChildScrollView( + child: Container( + width: size.width, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + ClipPath( + clipper: DrawClip(), + child: Container( + height: size.height / 3, + width: double.infinity, + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xffff5f6d), Color(0xffffc371)], + begin: Alignment.topLeft, + end: Alignment.bottomRight)), + ), + ), + Container( + height: size.height / 3, + width: double.infinity, + child: Image( + image: AssetImage('assets/lottie/blood-bank.png'), + ), + ) + ], + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: size.width * 0.1), + child: Text( + "SIGN IN", + style: GoogleFonts.mukta( + color: Color(0xffff5f6d), + fontSize: 30, + fontWeight: FontWeight.bold), + ), + ), + Padding( + padding: EdgeInsets.symmetric( + horizontal: size.width * 0.1, vertical: 10), + child: TextFormField( + decoration: InputDecoration( + border: + UnderlineInputBorder(borderSide: BorderSide.none), + fillColor: Colors.grey[200], + hintText: 'Email Address', + filled: true), + ), + ), + Padding( + padding: EdgeInsets.symmetric( + horizontal: size.width * 0.1, vertical: 10), + child: TextFormField( + decoration: InputDecoration( + border: + UnderlineInputBorder(borderSide: BorderSide.none), + fillColor: Colors.grey[200], + hintText: 'Password', + suffixIcon: Icon(Icons.remove_red_eye), + contentPadding: + EdgeInsets.symmetric(vertical: 15, horizontal: 10), + filled: true), + ), + ), + Padding( + padding: const EdgeInsets.only(left: 210), + child: Text( + "Forgot Password?", + style: GoogleFonts.mukta( + color: Colors.grey[500], + fontSize: 18, + fontWeight: FontWeight.bold), + ), + ), + Padding( + padding: EdgeInsets.symmetric( + horizontal: size.width * 0.1, vertical: 10), + child: TextButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => userData()), + ); + }, + child: Material( + elevation: 10, + borderRadius: BorderRadius.circular(8), + child: Container( + decoration: BoxDecoration( + color: Color(0xffff5f6d), + borderRadius: BorderRadius.circular(8)), + height: 50, + child: Center( + child: Text( + "SIGN IN", + style: GoogleFonts.mukta( + color: Colors.white, fontWeight: FontWeight.bold), + )), + ), + ), + ), + ), + SizedBox( + height: 10, + ), + Center( + child: Text( + "Don,t have an account?", + style: GoogleFonts.mukta( + fontSize: 18, + color: Colors.grey, + fontWeight: FontWeight.w500), + ), + ), + Center( + child: Text( + "Sign Up", + style: GoogleFonts.mukta( + fontSize: 18, + color: Color(0xffff5f6d), + fontWeight: FontWeight.bold), + ), + ), + ], + ), + ), + ), + ), + ); + } +} + +class DrawClip extends CustomClipper { + @override + Path getClip(Size size) { + //TODO: implement getClip + Path path = Path(); + path.lineTo(0, size.height); + path.lineTo(size.width * 0.1, size.height - 50); + path.lineTo(size.width * 0.9, size.height - 50); + path.lineTo(size.width, size.height - 100); + path.lineTo(size.width, 0); + return path; + } + + @override + bool shouldReclip(covariant CustomClipper oldCliper) { + return true; + } +} diff --git a/lib/views/generated_plugin_registrant.dart b/lib/views/generated_plugin_registrant.dart new file mode 100644 index 0000000..498eb89 --- /dev/null +++ b/lib/views/generated_plugin_registrant.dart @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// ignore_for_file: lines_longer_than_80_chars + +import 'package:firebase_core_web/firebase_core_web.dart'; + +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; + +// ignore: public_member_api_docs +void registerPlugins(Registrar registrar) { + FirebaseCoreWeb.registerWith(registrar); + registrar.registerMessageHandler(); +} diff --git a/lib/views/main.dart b/lib/views/main.dart new file mode 100644 index 0000000..62530d2 --- /dev/null +++ b/lib/views/main.dart @@ -0,0 +1,4 @@ +import 'package:blood_bank_app/views/data.dart'; +import 'package:flutter/material.dart'; + +void main() => runApp(MyApp()); diff --git a/lib/views/userData.dart b/lib/views/userData.dart new file mode 100644 index 0000000..2bedd93 --- /dev/null +++ b/lib/views/userData.dart @@ -0,0 +1,113 @@ +import 'package:flutter/material.dart'; +import 'package:firebase_database/firebase_database.dart'; +import 'package:firebase_core/firebase_core.dart'; + +class userData extends StatefulWidget { + @override + _userDataState createState() => _userDataState(); +} + +class _userDataState extends State { + final databaseRef = FirebaseDatabase.instance.reference(); + + void addData(String data) { + databaseRef.push().set({'name': data, 'comment': 'A good season'}); + } + + void printFirebase() { + databaseRef.once().then( + (DataSnapshot snapshot) { + //ynamic snapshot.exportVal(); + + print('Data : ${snapshot.value}'); + print('TestData : ${snapshot.value["users"]}'); + //print('KeyValue': ${snapshot.getKey()}); + }, + ); + } + + @override + Widget build(BuildContext context) { + printFirebase(); + return SafeArea( + child: Scaffold( + body: StreamBuilder( + stream: databaseRef.child("users").onValue, + builder: (context, AsyncSnapshot dataSnap) { + if (dataSnap.connectionState == ConnectionState.active) { + if (dataSnap.hasError) { + return Text(dataSnap.error.toString()); + } else if (dataSnap.hasData) { + Map dataMap = dataSnap.data.snapshot.value; + return ListView.builder( + itemCount: dataMap.keys.toList().length, + itemBuilder: (BuildContext context, int index) { + return Card( + color: Colors.redAccent, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + dataMap.keys.toList()[index], + style: TextStyle( + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.bold), + ), + ], + ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Blood: ${dataMap.values.toList()[index]["blood"].toString()}", + style: TextStyle( + color: Colors.white, + fontSize: 15, + ), + ), + Text( + "Email: ${dataMap.values.toList()[index]["email"].toString()}", + style: TextStyle( + color: Colors.white, + fontSize: 15, + ), + ), + ], + ), + ], + ), + ), + ); + }, + ); + } else { + return Text("No Data."); + } + } else if (dataSnap.connectionState != ConnectionState.active) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Center( + child: CircularProgressIndicator(), + ), + SizedBox( + height: 10, + ), + Text("Loading."), + ], + ); + } else { + return Text("Error loading application."); + } + }, + ), + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index ea31e15..7900451 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -43,27 +43,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" - cloud_firestore: - dependency: "direct main" - description: - name: cloud_firestore - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" - cloud_firestore_platform_interface: - dependency: transitive - description: - name: cloud_firestore_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.0" - cloud_firestore_web: - dependency: transitive - description: - name: cloud_firestore_web - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" collection: dependency: transitive description: @@ -77,7 +56,7 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" cupertino_icons: dependency: "direct main" description: @@ -106,41 +85,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "6.1.0" - firebase: - dependency: "direct main" - description: - name: firebase - url: "https://pub.dartlang.org" - source: hosted - version: "9.0.1" - firebase_auth: - dependency: "direct main" - description: - name: firebase_auth - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - firebase_auth_platform_interface: - dependency: transitive - description: - name: firebase_auth_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "4.0.0" - firebase_auth_web: - dependency: transitive - description: - name: firebase_auth_web - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" firebase_core: - dependency: transitive + dependency: "direct main" description: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" firebase_core_platform_interface: dependency: transitive description: @@ -155,6 +106,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.2" + firebase_database: + dependency: "direct main" + description: + name: firebase_database + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" flutter: dependency: "direct main" description: flutter @@ -191,13 +149,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.0" - intl: - dependency: transitive - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.17.0" js: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 38104cc..b5bed03 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -23,17 +23,18 @@ environment: dependencies: flutter: sdk: flutter - lottie: ^1.0.1 - firebase: ^9.0.1 - firebase_auth: ^1.0.1 - cloud_firestore: ^1.0.3 + lottie: + # firebase: + # firebase_auth: + firebase_database: + firebase_core: outline_material_icons: ^0.1.1 google_fonts: ^2.0.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 - + dev_dependencies: flutter_test: @@ -53,6 +54,7 @@ flutter: # To add assets to your application, add an assets section, like this: assets: - assets/lottie/lurkingcat.json + - assets/lottie/blood-bank.png # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware.