
날짜표기와 공지의 댓글 수 표기 기능을 추가했다.
먼저 날짜표기는 firestore에 있는 TimeStamp를 가져와서 parsing해주었는데 한국어로 표기해야하기 위해 년월일을 개별적으로불러왔다.
DateTime noticeDate =
DateTime.parse(doc.get("date").toDate().toString());
notice.date =
'${noticeDate.year}년 ${noticeDate.month}월 ${noticeDate.day}일';
그 다음 댓글 수는 firestore notice collection에 필드를 추가하여 해결하였는데 프론트에서 공지를 받아올때 서버에서 받아오고 공지에 댓글을 추가할때 1올린 값을 서버에 업데이트시키도록 하였다.
IconButton(
icon: Icon(
Icons.send,
),
onPressed: () {
if (commentTextController.text != '') {
setState(() {
globalCommentCount += 1;
print('GLOBAL COMMENT COUNT $globalCommentCount');
});
_handleSubmitted(
commentTextController.text, widget.noticeId);
commentTextController.clear();
}
},
),
firestore
.collection('Notice')
.doc(noticeId)
.update({'commentCount': globalCommentCount});