Skip to content

Commit

Permalink
Added Post Option : Reworked On Post Display & User Profile [Added Li…
Browse files Browse the repository at this point in the history
…ke & Comment Operations For User Posts ]
  • Loading branch information
Dev-Adnani committed Sep 10, 2021
1 parent ae83146 commit 7b0dc5e
Show file tree
Hide file tree
Showing 11 changed files with 591 additions and 81 deletions.
4 changes: 3 additions & 1 deletion lib/app/providers/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import 'package:social_tower/core/helpers/LandingHelpers/landing.notifier.dart';
import 'package:social_tower/core/helpers/LandingHelpers/landing.utlis.dart';
import 'package:social_tower/core/helpers/LandingHelpers/landingService.notifier.dart';
import 'package:social_tower/core/helpers/ProfileHelpers/profile.helpers.dart';
import 'package:social_tower/core/posts/upload.post.dart';
import 'package:social_tower/core/utils/posts.functions.dart';
import 'package:social_tower/core/utils/upload.post.dart';
import 'package:social_tower/core/services/authentication.notifier.dart';
import 'package:social_tower/core/services/firebase.notifier.dart';

Expand All @@ -22,4 +23,5 @@ List<SingleChildWidget> remoteProviders = [
ChangeNotifierProvider(create: (_) => ProfileHelpers()),
ChangeNotifierProvider(create: (_) => UploadPost()),
ChangeNotifierProvider(create: (_) => FeedHelpers()),
ChangeNotifierProvider(create: (_) => PostFunctions()),
];
257 changes: 254 additions & 3 deletions lib/core/helpers/FeedHelpers/feed.helpers.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:lottie/lottie.dart';
import 'package:provider/provider.dart';
import 'package:social_tower/app/constants/constant.colors.dart';
import 'package:social_tower/core/posts/upload.post.dart';
import 'package:social_tower/core/utils/posts.functions.dart';
import 'package:social_tower/core/utils/upload.post.dart';
import 'package:social_tower/core/services/authentication.notifier.dart';

class FeedHelpers with ChangeNotifier {
Widget appBar(BuildContext context) {
Expand Down Expand Up @@ -44,20 +50,265 @@ class FeedHelpers with ChangeNotifier {

Widget feedBody(BuildContext context) {
return SingleChildScrollView(
physics: NeverScrollableScrollPhysics(),
scrollDirection: Axis.horizontal,
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
height: MediaQuery.of(context).size.height * 0.9,
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: darkColor,
color: darkColor.withOpacity(0.6),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(18.0),
topRight: Radius.circular(18.0),
),
),
child: StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance.collection('posts').snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: SizedBox(
height: 500,
width: 400.0,
child: Lottie.asset('assets/animations/loading.json'),
),
);
} else {
return loadPost(context, snapshot);
}
},
),
),
),
);
}

Widget loadPost(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
return ListView(
children: snapshot.data.docs.map((DocumentSnapshot documentSnapshot) {
return Container(
height: MediaQuery.of(context).size.height * 0.6,
width: MediaQuery.of(context).size.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(top: 8.0, left: 8.0),
child: Row(
children: [
GestureDetector(
child: GestureDetector(
child: CircleAvatar(
backgroundColor: Colors.transparent,
radius: 20.0,
backgroundImage: NetworkImage(
documentSnapshot.data()['userImage']),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Container(
width: MediaQuery.of(context).size.width * 0.6,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Text(
documentSnapshot.data()['caption'],
style: TextStyle(
color: greenColor,
fontWeight: FontWeight.bold,
fontSize: 16.0),
),
),
Container(
child: RichText(
text: TextSpan(
text: documentSnapshot.data()['userName'],
style: TextStyle(
color: blueColor,
fontSize: 14.0,
fontWeight: FontWeight.bold,
),
children: [
TextSpan(
text: ' , 12 hours ago',
style: TextStyle(
color: lightColor.withOpacity(0.8),
),
)
],
),
))
],
),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
height: MediaQuery.of(context).size.height * 0.46,
width: MediaQuery.of(context).size.width,
child: FittedBox(
child: Image.network(
documentSnapshot.data()['postImage'],
scale: 2,
),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
width: 80,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () {
print('Added Like');
Provider.of<PostFunctions>(context,
listen: false)
.addLike(
context: context,
postId:
documentSnapshot.data()['caption'],
subDocId: Provider.of<Authentication>(
context,
listen: false)
.getUserUid);
},
child: Icon(
FontAwesomeIcons.heart,
color: redColor,
size: 22,
),
),
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('posts')
.doc(documentSnapshot.data()['caption'])
.collection('likes')
.snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
} else {
return Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
snapshot.data.docs.length.toString(),
style: TextStyle(
color: whiteColor,
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
);
}
},
)
],
),
),
Container(
width: 80,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
GestureDetector(
onTap: () async {
Provider.of<PostFunctions>(context,
listen: false)
.showCommentSheet(
context: context,
snapshot: documentSnapshot,
docId:
documentSnapshot.data()['caption']);
},
child: Icon(
FontAwesomeIcons.comment,
color: yellowColor,
size: 22,
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
'0',
style: TextStyle(
color: whiteColor,
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
)
],
),
),
Container(
width: 80,
child: Row(
children: [
GestureDetector(
onTap: () {},
child: Icon(
FontAwesomeIcons.award,
color: greenColor,
size: 22,
),
),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
'0',
style: TextStyle(
color: whiteColor,
fontSize: 18.0,
fontWeight: FontWeight.bold,
),
),
)
],
),
),
Spacer(),
Provider.of<Authentication>(context, listen: false)
.getUserUid ==
documentSnapshot.data()['userUid']
? IconButton(
icon: Icon(EvaIcons.moreVertical,
color: whiteColor),
onPressed: () {},
)
: Container(
width: 0.0,
height: 0.0,
)
],
),
),
),
],
),
);
}).toList(),
);
}
}
4 changes: 1 addition & 3 deletions lib/core/helpers/LandingHelpers/landing.notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ class LandingNotifier with ChangeNotifier {
color: whiteColor,
),
),
Provider.of<LandingService>(context, listen: false)
.passwordLessSignIn(context),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expand Down Expand Up @@ -243,7 +241,7 @@ class LandingNotifier with ChangeNotifier {
),
],
),
height: MediaQuery.of(context).size.height * 0.5,
height: MediaQuery.of(context).size.height * 0.1,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: blueGreyColor,
Expand Down
56 changes: 1 addition & 55 deletions lib/core/helpers/LandingHelpers/landingService.notifier.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:image_picker/image_picker.dart';
Expand Down Expand Up @@ -100,59 +99,6 @@ class LandingService with ChangeNotifier {
});
}

Widget passwordLessSignIn(BuildContext context) {
return SizedBox(
height: MediaQuery.of(context).size.height * 0.40,
width: MediaQuery.of(context).size.width,
child: StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance.collection('users').snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
} else {
if (snapshot.hasData) {
return new ListView(
children: snapshot.data.docs
.map((DocumentSnapshot documentSnapshot) {
return ListTile(
trailing: IconButton(
onPressed: () {},
icon: Icon(
FontAwesomeIcons.trashAlt,
color: redColor,
)),
leading: CircleAvatar(
backgroundColor: Colors.transparent,
backgroundImage: NetworkImage(
(documentSnapshot.data() as dynamic)['userImage']),
),
title: Text(
(documentSnapshot.data() as dynamic)['userName'],
style: TextStyle(
fontWeight: FontWeight.bold, color: greenColor),
),
subtitle: Text(
(documentSnapshot.data() as dynamic)['userEmail'],
style: TextStyle(
fontWeight: FontWeight.bold,
color: greenColor,
fontSize: 12.0),
),
);
}).toList());
} else {
return Center(
child: CircularProgressIndicator(),
);
}
}
},
),
);
}

loginSheet(BuildContext context) {
return showModalBottomSheet(
isScrollControlled: true,
Expand Down Expand Up @@ -414,7 +360,7 @@ class LandingService with ChangeNotifier {
Provider.of<FirebaseNotifier>(context,
listen: false)
.createUserCollection(context, {
'useruid': Provider.of<Authentication>(
'userUid': Provider.of<Authentication>(
context,
listen: false)
.getUserUid,
Expand Down
Loading

0 comments on commit 7b0dc5e

Please sign in to comment.