Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
remove unnecessary 'new' keyword, resolves mdanics#39
Browse files Browse the repository at this point in the history
  • Loading branch information
mdanics committed May 3, 2019
1 parent fdd1bc6 commit de41f53
Show file tree
Hide file tree
Showing 12 changed files with 377 additions and 377 deletions.
78 changes: 39 additions & 39 deletions lib/activity_feed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import 'main.dart'; //needed for currentuser id

class ActivityFeedPage extends StatefulWidget {
@override
_ActivityFeedPageState createState() => new _ActivityFeedPageState();
_ActivityFeedPageState createState() => _ActivityFeedPageState();
}

class _ActivityFeedPageState extends State<ActivityFeedPage> with AutomaticKeepAliveClientMixin<ActivityFeedPage> {
@override
Widget build(BuildContext context) {
super.build(context); // reloads state when opened again

return new Scaffold(
appBar: new AppBar(
title: new Text(
return Scaffold(
appBar: AppBar(
title: Text(
"Activity Feed",
style: new TextStyle(color: Colors.black),
style: TextStyle(color: Colors.black),
),
backgroundColor: Colors.white,
),
Expand All @@ -27,17 +27,17 @@ class _ActivityFeedPageState extends State<ActivityFeedPage> with AutomaticKeepA
}

buildActivityFeed() {
return new Container(
child: new FutureBuilder(
return Container(
child: FutureBuilder(
future: getFeed(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return new Container(
return Container(
alignment: FractionalOffset.center,
padding: const EdgeInsets.only(top: 10.0),
child: new CircularProgressIndicator());
child: CircularProgressIndicator());
else {
return new ListView(children: snapshot.data);
return ListView(children: snapshot.data);
}
}),
);
Expand All @@ -53,7 +53,7 @@ class _ActivityFeedPageState extends State<ActivityFeedPage> with AutomaticKeepA
.getDocuments();

for (var doc in snap.documents) {
items.add(new ActivityFeedItem.fromDocument(doc));
items.add(ActivityFeedItem.fromDocument(doc));
}
return items;
}
Expand All @@ -68,7 +68,7 @@ class ActivityFeedItem extends StatelessWidget {
final String username;
final String userId;
final String
type; // potetial types include liked photo, follow user, comment on photo
type; // types include liked photo, follow user, comment on photo
final String mediaUrl;
final String mediaId;
final String userProfileImg;
Expand All @@ -84,7 +84,7 @@ class ActivityFeedItem extends StatelessWidget {
this.commentData});

factory ActivityFeedItem.fromDocument(DocumentSnapshot document) {
return new ActivityFeedItem(
return ActivityFeedItem(
username: document['username'],
userId: document['userId'],
type: document['type'],
Expand All @@ -95,26 +95,26 @@ class ActivityFeedItem extends StatelessWidget {
);
}

Widget mediaPreview = new Container();
Widget mediaPreview = Container();
String actionText;

void configureItem(BuildContext context) {
if (type == "like" || type == "comment") {
mediaPreview = new GestureDetector(
mediaPreview = GestureDetector(
onTap: () {
openImage(context, mediaId);
},
child: new Container(
child: Container(
height: 45.0,
width: 45.0,
child: new AspectRatio(
child: AspectRatio(
aspectRatio: 487 / 451,
child: new Container(
decoration: new BoxDecoration(
image: new DecorationImage(
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
alignment: FractionalOffset.topCenter,
image: new NetworkImage(mediaUrl),
image: NetworkImage(mediaUrl),
)),
),
),
Expand All @@ -136,18 +136,18 @@ class ActivityFeedItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
configureItem(context);
return new Row(
return Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
new Padding(
Padding(
padding: const EdgeInsets.only(left: 20.0, right: 15.0),
child: new CircleAvatar(
child: CircleAvatar(
radius: 23.0,
backgroundImage: new NetworkImage(userProfileImg),
backgroundImage: NetworkImage(userProfileImg),
),
),
Expanded(
child: new Row(
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
GestureDetector(
Expand All @@ -170,11 +170,11 @@ class ActivityFeedItem extends StatelessWidget {
],
),
),
new Container(
child: new Align(
child: new Padding(
Container(
child: Align(
child: Padding(
child: mediaPreview,
padding: new EdgeInsets.all(15.0),
padding: EdgeInsets.all(15.0),
),
alignment: AlignmentDirectional.bottomEnd))
],
Expand All @@ -185,19 +185,19 @@ class ActivityFeedItem extends StatelessWidget {
openImage(BuildContext context, String imageId) {
print("the image id is $imageId");
Navigator.of(context)
.push(new MaterialPageRoute<bool>(builder: (BuildContext context) {
return new Center(
child: new Scaffold(
appBar: new AppBar(
title: new Text('Photo',
style: new TextStyle(
.push(MaterialPageRoute<bool>(builder: (BuildContext context) {
return Center(
child: Scaffold(
appBar: AppBar(
title: Text('Photo',
style: TextStyle(
color: Colors.black, fontWeight: FontWeight.bold)),
backgroundColor: Colors.white,
),
body: new ListView(
body: ListView(
children: <Widget>[
new Container(
child: new ImagePostFromId(id: imageId),
Container(
child: ImagePostFromId(id: imageId),
),
],
)),
Expand Down
54 changes: 27 additions & 27 deletions lib/comment_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CommentScreen extends StatefulWidget {

const CommentScreen({this.postId, this.postOwner, this.postMediaUrl});
@override
_CommentScreenState createState() => new _CommentScreenState(
_CommentScreenState createState() => _CommentScreenState(
postId: this.postId,
postOwner: this.postOwner,
postMediaUrl: this.postMediaUrl);
Expand All @@ -21,17 +21,17 @@ class _CommentScreenState extends State<CommentScreen> {
final String postOwner;
final String postMediaUrl;

final TextEditingController _commentController = new TextEditingController();
final TextEditingController _commentController = TextEditingController();

_CommentScreenState({this.postId, this.postOwner, this.postMediaUrl});

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text(
return Scaffold(
appBar: AppBar(
title: Text(
"Comments",
style: new TextStyle(color: Colors.black),
style: TextStyle(color: Colors.black),
),
backgroundColor: Colors.white,
),
Expand All @@ -40,20 +40,20 @@ class _CommentScreenState extends State<CommentScreen> {
}

Widget buildPage() {
return new Column(
return Column(
children: [
new Expanded(
Expanded(
child:
buildComments(),
),
new Divider(),
new ListTile(
title: new TextFormField(
Divider(),
ListTile(
title: TextFormField(
controller: _commentController,
decoration: new InputDecoration(labelText: 'Write a comment...'),
decoration: InputDecoration(labelText: 'Write a comment...'),
onFieldSubmitted: addComment,
),
trailing: new OutlineButton(onPressed: (){addComment(_commentController.text);}, borderSide: BorderSide.none, child: new Text("Post"),),
trailing: OutlineButton(onPressed: (){addComment(_commentController.text);}, borderSide: BorderSide.none, child: Text("Post"),),
),

],
Expand All @@ -63,15 +63,15 @@ class _CommentScreenState extends State<CommentScreen> {


Widget buildComments() {
return new FutureBuilder<List<Comment>>(
return FutureBuilder<List<Comment>>(
future: getComments(),
builder: (context, snapshot) {
if (!snapshot.hasData)
return new Container(
return Container(
alignment: FractionalOffset.center,
child: new CircularProgressIndicator());
child: CircularProgressIndicator());

return new ListView(
return ListView(
children: snapshot.data,
);
});
Expand All @@ -86,7 +86,7 @@ class _CommentScreenState extends State<CommentScreen> {
.collection("comments")
.getDocuments();
data.documents.forEach((DocumentSnapshot doc) {
comments.add(new Comment.fromDocument(doc));
comments.add(Comment.fromDocument(doc));
});

return comments;
Expand All @@ -101,7 +101,7 @@ class _CommentScreenState extends State<CommentScreen> {
.add({
"username": currentUserModel.username,
"comment": comment,
"timestamp": new DateTime.now().toString(),
"timestamp": DateTime.now().toString(),
"avatarUrl": currentUserModel.photoUrl,
"userId": currentUserModel.id
});
Expand All @@ -117,7 +117,7 @@ class _CommentScreenState extends State<CommentScreen> {
"type": "comment",
"userProfileImg": currentUserModel.photoUrl,
"commentData": comment,
"timestamp": new DateTime.now().toString(),
"timestamp": DateTime.now().toString(),
"postId": postId,
"mediaUrl": postMediaUrl,
});
Expand All @@ -139,7 +139,7 @@ class Comment extends StatelessWidget {
this.timestamp});

factory Comment.fromDocument(DocumentSnapshot document) {
return new Comment(
return Comment(
username: document['username'],
userId: document['userId'],
comment: document["comment"],
Expand All @@ -150,15 +150,15 @@ class Comment extends StatelessWidget {

@override
Widget build(BuildContext context) {
return new Column(
return Column(
children: <Widget>[
new ListTile(
title: new Text(comment),
leading: new CircleAvatar(
backgroundImage: new NetworkImage(avatarUrl),
ListTile(
title: Text(comment),
leading: CircleAvatar(
backgroundImage: NetworkImage(avatarUrl),
),
),
new Divider(),
Divider(),
],
);
}
Expand Down
Loading

0 comments on commit de41f53

Please sign in to comment.