Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat firestore #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 46 additions & 12 deletions lib/design_course/popular_course_list_view.dart
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -16,6 +19,7 @@ class PopularCourseListView extends StatefulWidget {
class _PopularCourseListViewState extends State<PopularCourseListView>
with TickerProviderStateMixin {
AnimationController animationController;

@override
void initState() {
animationController = AnimationController(
Expand Down Expand Up @@ -80,18 +84,18 @@ class _PopularCourseListViewState extends State<PopularCourseListView>
}

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<dynamic> animation;
final databaseReference = Firestore.instance;

@override
Widget build(BuildContext context) {
Expand All @@ -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();
}
},
Expand Down Expand Up @@ -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>[
BoxShadow(
color: DesignCourseAppTheme.grey
Expand All @@ -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)),
Expand All @@ -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);
}
}
45 changes: 26 additions & 19 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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"
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down