Skip to content

Commit

Permalink
Merge pull request #7 from niloysikdar/oxygen
Browse files Browse the repository at this point in the history
Oxygen
  • Loading branch information
niloysikdar authored May 1, 2021
2 parents f3faba7 + fe5b441 commit 7358b5c
Show file tree
Hide file tree
Showing 9 changed files with 410 additions and 35 deletions.
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:plaso_connect/constants/colors.dart';
import 'package:plaso_connect/screens/donorlist.dart';
import 'package:plaso_connect/screens/showOxygenposts.dart';

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -30,7 +30,7 @@ class MyApp extends StatelessWidget {
primaryColor: kelectronBlue,
iconTheme: IconThemeData(color: kelectronBlue),
),
home: DonorList(),
home: ShowOxygenPosts(),
);
}
}
28 changes: 28 additions & 0 deletions lib/models/oxygenpostmodel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class OxygenPostModel {
final String title;
final String description;
final String pin;
final String postedOn;
final String postedBy;
final String postedRole;

OxygenPostModel({
required this.title,
required this.description,
required this.pin,
required this.postedOn,
required this.postedBy,
required this.postedRole,
});

Map<String, dynamic> toMap() {
return {
"title": title,
"description": description,
"pin": pin,
"postedOn": postedOn,
"postedBy": postedBy,
"postedRole": postedRole,
};
}
}
183 changes: 183 additions & 0 deletions lib/screens/addoxygen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
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';

class AddOxygenDetails extends StatefulWidget {
@override
_AddOxygenDetailsState createState() => _AddOxygenDetailsState();
}

class _AddOxygenDetailsState extends State<AddOxygenDetails> {
late TextEditingController titlecontroller;
late TextEditingController descriptioncontroller;
late TextEditingController pincontroller;

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();
pincontroller.clear();
}

@override
void initState() {
super.initState();
titlecontroller = TextEditingController();
descriptioncontroller = TextEditingController();
pincontroller = TextEditingController();
}

@override
void dispose() {
titlecontroller.dispose();
descriptioncontroller.dispose();
pincontroller.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return SafeArea(
child: Scaffold(
body: Stack(
children: [
formBanner(
size: size,
svgPath: "assets/images/medicine.svg",
),
SingleChildScrollView(
child: Container(
width: double.infinity,
margin: EdgeInsets.only(
top: size.height * 0.35,
left: 20,
right: 20,
),
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
color: kbackgroundLight,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
blurRadius: 10.0,
spreadRadius: 5.0,
offset: Offset(0.0, 0.0),
)
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"*$headerstring",
style: TextStyle(
color: Colors.red,
fontSize: 15,
),
),
SizedBox(height: 10),
inputforOxygen(
controller: titlecontroller,
prefixIcon: Icons.title_rounded,
hintText: "Title of the post",
textInputType: TextInputType.text,
maxLines: 1,
),
inputforOxygen(
controller: descriptioncontroller,
prefixIcon: Icons.description_rounded,
hintText: "Full Information",
textInputType: TextInputType.text,
maxLines: 3,
),
inputforOxygen(
controller: pincontroller,
prefixIcon: Icons.location_on_rounded,
hintText: "Area PIN code",
textInputType: TextInputType.number,
maxLines: 1,
),
SizedBox(height: 30),
GestureDetector(
onTap: () {
postPressed();
print("Posted");
},
child: doneBtn(),
),
],
),
),
),
],
),
),
);
}

Widget doneBtn() {
return Container(
margin: EdgeInsets.symmetric(horizontal: 30),
child: Material(
elevation: 5,
borderRadius: BorderRadius.circular(15),
color: kelectronBlue[700],
child: Container(
padding: EdgeInsets.symmetric(vertical: 12),
child: Center(
child: Text(
"Post",
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.w600,
),
),
),
),
),
);
}

Widget inputforOxygen({
required TextEditingController controller,
required IconData prefixIcon,
required String hintText,
required TextInputType textInputType,
required int maxLines,
}) {
return Container(
margin: EdgeInsets.symmetric(vertical: 10),
child: inputField(
controller: controller,
prefixIcon: prefixIcon,
hintText: hintText,
textInputType: textInputType,
maxLines: maxLines,
),
);
}
}
45 changes: 12 additions & 33 deletions lib/screens/plasmaform.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:plaso_connect/constants/colors.dart';
import 'package:plaso_connect/models/donormodel.dart';
import 'package:plaso_connect/services/database.dart';
import 'package:plaso_connect/widgets/formbanner.dart';
import 'package:plaso_connect/widgets/inputfield.dart';

class PlasmaDonate extends StatefulWidget {
Expand Down Expand Up @@ -80,38 +80,9 @@ class _PlasmaDonateState extends State<PlasmaDonate> {
child: Scaffold(
body: Stack(
children: [
Positioned(
top: 0,
left: 0,
child: Container(
height: size.height * 0.3,
width: size.width,
padding: EdgeInsets.all(15),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: klightShadowForLight,
offset: Offset(0.0, 0.0),
blurRadius: 7.0,
),
BoxShadow(
color: kdarkShadowForLight,
offset: Offset(4.0, 4.0),
blurRadius: 7.0,
),
],
color: Color(0xFFEFEEEE),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30),
bottomRight: Radius.circular(30),
),
// image: DecorationImage(
// image: AssetImage("assets/images/banner2.png"),
// fit: BoxFit.cover,
// ),
),
child: SvgPicture.asset("assets/images/login.svg"),
),
formBanner(
size: size,
svgPath: "assets/images/login.svg",
),
SingleChildScrollView(
child: Container(
Expand Down Expand Up @@ -154,30 +125,35 @@ class _PlasmaDonateState extends State<PlasmaDonate> {
prefixIcon: Icons.account_circle_rounded,
hintText: "Full Name",
textInputType: TextInputType.name,
maxLines: 1,
),
inputforPlasma(
controller: phonecontroller,
prefixIcon: Icons.phone_rounded,
hintText: "Phone Number",
textInputType: TextInputType.phone,
maxLines: 1,
),
inputforPlasma(
controller: agecontroller,
prefixIcon: Icons.add_rounded,
hintText: "Age",
textInputType: TextInputType.number,
maxLines: 1,
),
inputforPlasma(
controller: addresscontroller,
prefixIcon: Icons.location_on_rounded,
hintText: "Full Address",
textInputType: TextInputType.name,
maxLines: 3,
),
inputforPlasma(
controller: pincontroller,
prefixIcon: Icons.location_on_rounded,
hintText: "Address PIN code",
textInputType: TextInputType.number,
maxLines: 1,
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 5),
Expand Down Expand Up @@ -321,6 +297,7 @@ class _PlasmaDonateState extends State<PlasmaDonate> {
prefixIcon: Icons.date_range_rounded,
hintText: "Date of Recovery",
textInputType: TextInputType.datetime,
maxLines: 1,
)
: Container(height: 0),
Row(
Expand Down Expand Up @@ -437,6 +414,7 @@ class _PlasmaDonateState extends State<PlasmaDonate> {
required IconData prefixIcon,
required String hintText,
required TextInputType textInputType,
required int maxLines,
}) {
return Container(
margin: EdgeInsets.symmetric(vertical: 10),
Expand All @@ -445,6 +423,7 @@ class _PlasmaDonateState extends State<PlasmaDonate> {
prefixIcon: prefixIcon,
hintText: hintText,
textInputType: textInputType,
maxLines: maxLines,
),
);
}
Expand Down
Loading

0 comments on commit 7358b5c

Please sign in to comment.