diff --git a/lib/design_course/popular_course_list_view.dart b/lib/design_course/popular_course_list_view.dart index 2a59541..35d6490 100644 --- a/lib/design_course/popular_course_list_view.dart +++ b/lib/design_course/popular_course_list_view.dart @@ -1,9 +1,12 @@ import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; import 'package:navft/questionnaire/screens/home_screen.dart'; import '../main.dart'; import 'design_course_app_theme.dart'; import 'models/category.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; + class PopularCourseListView extends StatefulWidget { const PopularCourseListView({Key key, this.callBack}) : super(key: key); @@ -16,6 +19,7 @@ class PopularCourseListView extends StatefulWidget { class _PopularCourseListViewState extends State with TickerProviderStateMixin { AnimationController animationController; + @override void initState() { animationController = AnimationController( @@ -80,18 +84,18 @@ class _PopularCourseListViewState extends State } class CategoryView extends StatelessWidget { - const CategoryView( - {Key key, - this.category, - this.animationController, - this.animation, - this.callback}) + const CategoryView({Key key, + this.category, + this.animationController, + this.animation, + this.callback}) : super(key: key); final VoidCallback callback; final Category category; final AnimationController animationController; final Animation animation; + final databaseReference = Firestore.instance; @override Widget build(BuildContext context) { @@ -106,10 +110,14 @@ class CategoryView extends StatelessWidget { child: InkWell( splashColor: Colors.transparent, onTap: () { - if (this.category.title=="Pending Inspections List") { + if (this.category.title == "Pending Inspections List") { Navigator.push(context, MaterialPageRoute(builder: (context) => HomeScreen())); - } else { + } else + if (this.category.title == "Register new Vehicle Manually") { + createRecord("vechile_3"); + } + else { callback(); } }, @@ -171,11 +179,11 @@ class CategoryView extends StatelessWidget { Container( child: Padding( padding: - const EdgeInsets.only(top: 24, right: 16, left: 16), + const EdgeInsets.only(top: 24, right: 16, left: 16), child: Container( decoration: BoxDecoration( borderRadius: - const BorderRadius.all(Radius.circular(16.0)), + const BorderRadius.all(Radius.circular(16.0)), boxShadow: [ BoxShadow( color: DesignCourseAppTheme.grey @@ -186,7 +194,7 @@ class CategoryView extends StatelessWidget { ), child: ClipRRect( borderRadius: - const BorderRadius.all(Radius.circular(16.0)), + const BorderRadius.all(Radius.circular(16.0)), child: AspectRatio( aspectRatio: 1.28, child: Image.asset(category.imagePath)), @@ -203,4 +211,30 @@ class CategoryView extends StatelessWidget { }, ); } -} + + + void createRecord(String vechile) async { + DocumentReference ref = await databaseReference.collection(vechile) + .add({ + "body":"body", + "break":"break", + "chassisEmbossing":"chassisEmbossing", + "electricals":"elec", + "horn":"horn", + "location": GeoPoint(-80,80), + "painting":"painting", + "pollution":"pollution", + "roadTest":"roadtest", + "safetyBelts":"SafteyBelt", + "signals":"signals", + "speedometer":"speedometer", + "steering":"steering", + "suspension":"suspension", + "steering":"steering", + "time":Timestamp(1000,2000), + "tyres":"tyres", + "wiper":"wiper" + }); + print(ref.documentID); + } +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index fe0e18a..f71d33b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -21,42 +21,49 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0-nullsafety" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety" + version: "2.1.0-nullsafety.1" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.2" + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety" + version: "1.2.0-nullsafety.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.1.0-nullsafety.1" + cloud_firestore: + dependency: "direct main" + description: + name: cloud_firestore + url: "https://pub.dartlang.org" + source: hosted + version: "0.11.0+2" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.2" + version: "1.15.0-nullsafety.3" convert: dependency: transitive description: @@ -91,7 +98,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.2.0-nullsafety.1" firebase: dependency: transitive description: @@ -246,21 +253,21 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10-nullsafety" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.2" + version: "1.3.0-nullsafety.3" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety" + version: "1.8.0-nullsafety.1" pedantic: dependency: transitive description: @@ -307,56 +314,56 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19-nullsafety" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.2" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.2" + version: "2.1.0-nullsafety.3" xml: dependency: transitive description: @@ -372,5 +379,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0-0.0.dev <2.10.0" + dart: ">=2.10.0-110 <2.11.0" flutter: ">=1.12.13+hotfix.4 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 0433f40..454da6d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,6 +37,7 @@ dependencies: flutter_launcher_icons: ^0.7.4 firebase_auth: ^0.16.0 google_sign_in: ^4.4.4 + cloud_firestore: ^0.11.0+2 dev_dependencies: flutter_test: