Skip to content

Commit

Permalink
ShowOxygenPosts Completed
Browse files Browse the repository at this point in the history
  • Loading branch information
niloysikdar committed May 1, 2021
1 parent 456e09c commit fe5b441
Showing 1 changed file with 103 additions and 58 deletions.
161 changes: 103 additions & 58 deletions lib/screens/showOxygenposts.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:plaso_connect/constants/colors.dart';
import 'package:plaso_connect/models/oxygenpostmodel.dart';
import 'package:plaso_connect/widgets/boxdecoration.dart';

class ShowOxygenPosts extends StatelessWidget {
Expand All @@ -8,66 +10,109 @@ class ShowOxygenPosts extends StatelessWidget {
Size size = MediaQuery.of(context).size;
return SafeArea(
child: Scaffold(
body: Column(
children: [
Container(
margin: EdgeInsets.all(20),
padding: EdgeInsets.all(20),
decoration: newboxDecoration(),
width: size.width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"This is a title",
style: TextStyle(
color: kelectronBlue,
fontSize: 22,
fontWeight: FontWeight.w600,
),
),
SizedBox(height: 3),
Text(
"This is a description",
style: TextStyle(
color: kelectronBlue,
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 3),
Text(
"Area PIN: 733202",
style: TextStyle(
color: kelectronBlue,
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 3),
Text(
"30/07/2001 -by Admin",
style: TextStyle(
color: Colors.grey[800],
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 3),
Text(
"Role: Admin",
style: TextStyle(
color: Colors.grey[800],
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
],
),
),
],
appBar: AppBar(
title: Text("Oxygen Posts"),
centerTitle: true,
),
body: Container(
height: size.height,
width: size.width,
child: StreamBuilder(
stream: FirebaseFirestore.instance
.collection("oxygenPosts")
.snapshots(),
builder:
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasData) {
return ListView.builder(
itemCount: snapshot.data!.docs.length,
itemBuilder: (context, index) {
OxygenPostModel oxygenPostModel = OxygenPostModel(
title: snapshot.data!.docs[index]["title"],
description: snapshot.data!.docs[index]["description"],
pin: snapshot.data!.docs[index]["pin"],
postedOn: snapshot.data!.docs[index]["postedOn"],
postedBy: snapshot.data!.docs[index]["postedBy"],
postedRole: snapshot.data!.docs[index]["postedRole"],
);
return oxygenCard(
oxygenPostModel: oxygenPostModel,
size: size,
);
},
);
} else if (snapshot.hasError) {
return Text("Error");
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
),
),
),
);
}

Widget oxygenCard({
required OxygenPostModel oxygenPostModel,
required Size size,
}) {
return Container(
margin: EdgeInsets.all(20),
padding: EdgeInsets.all(20),
decoration: newboxDecoration(),
width: size.width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
oxygenPostModel.title,
style: TextStyle(
color: kelectronBlue,
fontSize: 22,
fontWeight: FontWeight.w600,
),
),
SizedBox(height: 3),
Text(
oxygenPostModel.description,
style: TextStyle(
color: kelectronBlue,
fontSize: 20,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 3),
Text(
"Area PIN: ${oxygenPostModel.pin}",
style: TextStyle(
color: Colors.grey[800],
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
SizedBox(height: 10),
Text(
"30/07/2001 -by Admin",
style: TextStyle(
color: kelectronBlue,
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 3),
Text(
"Role: Admin",
style: TextStyle(
color: Colors.grey[800],
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
],
),
);
}
}

0 comments on commit fe5b441

Please sign in to comment.