From 641e7ac03feee18b5047a6704e79b3d671c0df5a Mon Sep 17 00:00:00 2001 From: niloysikdar Date: Sun, 2 May 2021 03:54:51 +0530 Subject: [PATCH] Oxygen Upload --- lib/main.dart | 2 +- lib/screens/addoxygen.dart | 16 ++++++++++++++++ lib/widgets/inputfield.dart | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 1a823b5..7a0ebfc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,7 +7,7 @@ import 'package:plaso_connect/screens/addoxygen.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - // await Firebase.initializeApp(); + await Firebase.initializeApp(); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, ]).then((val) { diff --git a/lib/screens/addoxygen.dart b/lib/screens/addoxygen.dart index 16741b8..0b8c3ee 100644 --- a/lib/screens/addoxygen.dart +++ b/lib/screens/addoxygen.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; import 'package:plaso_connect/constants/colors.dart'; +import 'package:plaso_connect/models/oxygenpostmodel.dart'; +import 'package:plaso_connect/services/database.dart'; import 'package:plaso_connect/widgets/formbanner.dart'; import 'package:plaso_connect/widgets/inputfield.dart'; @@ -16,6 +18,19 @@ class _AddOxygenDetailsState extends State { String headerstring = "Please ensure all the data that you are providing are from verified sources.\nFeeding any false information or spamming will lead to permanent ban."; + void postPressed() async { + var oxygenPostModel = OxygenPostModel( + title: titlecontroller.text, + description: descriptioncontroller.text, + pin: pincontroller.text, + postedOn: DateTime.now().toString(), + postedBy: "Admin", + postedRole: "Admin", + ); + await DatabaseMethod().uploadOxygen(oxygenPostModel); + clearcontrollers(); + } + void clearcontrollers() { titlecontroller.clear(); descriptioncontroller.clear(); @@ -108,6 +123,7 @@ class _AddOxygenDetailsState extends State { SizedBox(height: 30), GestureDetector( onTap: () { + postPressed(); print("Posted"); }, child: doneBtn(), diff --git a/lib/widgets/inputfield.dart b/lib/widgets/inputfield.dart index 3ad01c2..117becf 100644 --- a/lib/widgets/inputfield.dart +++ b/lib/widgets/inputfield.dart @@ -14,11 +14,11 @@ Widget inputField({ child: TextFormField( controller: controller, keyboardType: textInputType, + maxLines: maxLines, style: TextStyle( fontSize: 22, color: Colors.grey[700], ), - maxLines: maxLines, decoration: InputDecoration( filled: true, fillColor: Color(0xFFEFEEEE),