Skip to content

Commit 40c2471

Browse files
committed
Tweet detail display style changed.
1 parent 08912b4 commit 40c2471

File tree

4 files changed

+170
-162
lines changed

4 files changed

+170
-162
lines changed

lib/page/feed/feedPostDetail.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,6 @@ class _FeedPostDetailState extends State<FeedPostDetail> {
143143
);
144144
}
145145

146-
// void addLikeToTweet(String postId) {
147-
// var state = Provider.of<FeedState>(context,);
148-
// var authState = Provider.of<AuthState>(context,);
149-
// state.addLikeToTweet(postId, authState.userId);
150-
// }
151-
152146
void addLikeToComment(String commentId) {
153147
var state = Provider.of<FeedState>(
154148
context,

lib/page/feed/feedPostreply.dart

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'package:flutter_twitter_clone/widgets/newWidget/customUrlText.dart';
1515
import 'package:provider/provider.dart';
1616

1717
import 'widgets/bottomIconWidget.dart';
18+
import 'widgets/tweetImage.dart';
1819

1920
class FeedPostReplyPage extends StatefulWidget {
2021
FeedPostReplyPage({Key key, this.postId}) : super(key: key);
@@ -36,20 +37,20 @@ class _FeedPostReplyPageState extends State<FeedPostReplyPage> {
3637

3738
/// if tweet is detail tweet
3839
if(feedState.tweetDetailModel.any((x)=>x.key == postId)){
39-
cprint('Search tweet from tweet detail page stack tweet');
40+
// cprint('Search tweet from tweet detail page stack tweet');
4041
model = feedState.tweetDetailModel.last;
4142
}
4243
/// if tweet is reply tweet
4344
else if(feedState.tweetReplyMap.values.any((x)=> x.any((y)=>y.key == postId))){
44-
cprint('Search tweet from twee detail page roply tweet');
45+
// cprint('Search tweet from twee detail page roply tweet');
4546
feedState.tweetReplyMap.forEach((key,value){
4647
if(value.any((x)=> x.key == postId)){
4748
model = value.firstWhere((x)=>x.key == postId);
4849
}
4950
});
5051
}
5152
else{
52-
cprint('Search tweet from home page tweet');
53+
// cprint('Search tweet from home page tweet');
5354
model = feedState.feedlist.firstWhere((x)=> x.key == postId);
5455
}
5556
scrollcontroller = ScrollController();
@@ -171,43 +172,6 @@ class _FeedPostReplyPageState extends State<FeedPostReplyPage> {
171172
);
172173
}
173174

174-
Widget _imageFeed() {
175-
return _image == null
176-
? Container()
177-
: Stack(
178-
children: <Widget>[
179-
Container(
180-
alignment: Alignment.topRight,
181-
child: Container(
182-
height: 300,
183-
width: fullWidth(context) * .8,
184-
decoration: BoxDecoration(
185-
borderRadius: BorderRadius.all(Radius.circular(10)),
186-
image: DecorationImage(
187-
image: FileImage(_image), fit: BoxFit.cover)),
188-
)),
189-
Align(
190-
alignment: Alignment.topRight,
191-
child: Container(
192-
padding: EdgeInsets.all(0),
193-
decoration: BoxDecoration(
194-
shape: BoxShape.circle, color: Colors.black26),
195-
child: IconButton(
196-
padding: EdgeInsets.all(0),
197-
iconSize: 20,
198-
onPressed: () {
199-
setState(() {
200-
_image = null;
201-
});
202-
},
203-
icon: Icon(Icons.close,
204-
color: Theme.of(context).colorScheme.onPrimary),
205-
),
206-
))
207-
],
208-
);
209-
}
210-
211175
void _submitButton() async {
212176
if (_textEditingController.text == null ||
213177
_textEditingController.text.isEmpty ||
@@ -297,8 +261,14 @@ class _FeedPostReplyPageState extends State<FeedPostReplyPage> {
297261
)
298262
],
299263
),
300-
_imageFeed(),
301-
// Divider(),
264+
TweetImage(
265+
image: _image,
266+
onCrossIconPressed: () {
267+
setState(() {
268+
_image = null;
269+
});
270+
},
271+
),
302272
Expanded(
303273
child: Container(),
304274
)

lib/page/feed/widgets/tweetIconsRow.dart

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_twitter_clone/helper/constant.dart';
33
import 'package:flutter_twitter_clone/helper/enum.dart';
4+
import 'package:flutter_twitter_clone/helper/theme.dart';
45
import 'package:flutter_twitter_clone/helper/utility.dart';
56
import 'package:flutter_twitter_clone/model/feedModel.dart';
67
import 'package:flutter_twitter_clone/state/authState.dart';
78
import 'package:flutter_twitter_clone/state/feedState.dart';
89
import 'package:flutter_twitter_clone/widgets/customWidgets.dart';
910
import 'package:provider/provider.dart';
1011

11-
class TweetIconsRow extends StatefulWidget {
12+
class TweetIconsRow extends StatelessWidget {
1213
final FeedModel model;
1314
final Color iconColor;
1415
final Color iconEnableColor;
@@ -17,14 +18,8 @@ class TweetIconsRow extends StatefulWidget {
1718
final TweetType type;
1819
const TweetIconsRow({Key key, this.model, this.iconColor, this.iconEnableColor, this.size, this.isTweetDetail = false, this.type}) : super(key: key);
1920

20-
_TweetIconsRowState createState() => _TweetIconsRowState();
21-
}
22-
23-
class _TweetIconsRowState extends State<TweetIconsRow> {
24-
25-
Widget _likeCommentsIcons(FeedModel model) {
21+
Widget _likeCommentsIcons(BuildContext context, FeedModel model) {
2622
var state = Provider.of<AuthState>(context,);
27-
var feedstate = Provider.of<FeedState>(context,);
2823
return Container(
2924
color: Colors.transparent,
3025
padding: EdgeInsets.only(bottom: 0,top:0),
@@ -33,38 +28,42 @@ class _TweetIconsRowState extends State<TweetIconsRow> {
3328
children: <Widget>[
3429
SizedBox(width: 20,),
3530
_iconWidget(
36-
text: widget.isTweetDetail ? '' : model.commentCount.toString(),
37-
icon:AppIcon.reply,iconColor: widget.iconColor,
38-
size : widget.size ?? 20,
31+
context,
32+
text: isTweetDetail ? '' : model.commentCount.toString(),
33+
icon:AppIcon.reply,iconColor: iconColor,
34+
size : size ?? 20,
3935
onPressed: (){
4036
Navigator.of(context).pushNamed('/FeedPostReplyPage/'+model.key);
4137
},),
4238
_iconWidget(
43-
text:widget.isTweetDetail ? '' : model.commentCount.toString(),
44-
icon:AppIcon.retweet,iconColor: widget.iconColor,size : widget.size ?? 20),
39+
context,
40+
text:isTweetDetail ? '' : model.commentCount.toString(),
41+
icon:AppIcon.retweet,iconColor: iconColor,size : size ?? 20),
4542
_iconWidget(
46-
text:widget.isTweetDetail ? '' : model.likeCount.toString(),
43+
context,
44+
text:isTweetDetail ? '' : model.likeCount.toString(),
4745
icon:model.likeList.any((x)=>x.userId == state.userId)
4846
? AppIcon.heartFill
4947
: AppIcon.heartEmpty,
50-
onPressed:(){addLikeToTweet();},
51-
iconColor: model.likeList.any((x)=>x.userId == state.userId )? widget.iconEnableColor : widget.iconColor ,
52-
size : widget.size ?? 20
48+
onPressed:(){addLikeToTweet(context);},
49+
iconColor: model.likeList.any((x)=>x.userId == state.userId )? iconEnableColor : iconColor ,
50+
size : size ?? 20
5351
),
5452
_iconWidget(
53+
context,
5554
text:'',
5655
icon:null,
5756
sysIcon:Icons.share,
5857
onPressed: (){share('${model.description}',
5958
subject:'${model.user.displayName}\'s post');},
60-
iconColor: widget.iconColor,
61-
size : widget.size ?? 20),
59+
iconColor: iconColor,
60+
size : size ?? 20),
6261

6362
],
6463
)
6564
);
6665
}
67-
Widget _iconWidget({String text, int icon,Function onPressed,IconData sysIcon,Color iconColor, double size = 20}){
66+
Widget _iconWidget(BuildContext context,{String text, int icon,Function onPressed,IconData sysIcon,Color iconColor, double size = 20}){
6867
return Expanded(
6968
child:Container(
7069
child: Row(
@@ -80,16 +79,17 @@ class _TweetIconsRowState extends State<TweetIconsRow> {
8079
)
8180
);
8281
}
83-
Widget _timeWidget(){
82+
Widget _timeWidget(BuildContext context){
8483
return Column(children: <Widget>[
85-
SizedBox(height: 15,),
84+
SizedBox(height: 5,),
8685
Row(
8786
children: <Widget>[
88-
customText(getPostTime2(widget.model.createdAt),
87+
SizedBox(width: 5,),
88+
customText(getPostTime2(model.createdAt),
8989
style: TextStyle(
9090
fontSize: 14,
9191
fontWeight: FontWeight.w500,
92-
color: Colors.black54)),
92+
color: TwitterColor.woodsmoke_50)),
9393
SizedBox(
9494
width: 10,
9595
),
@@ -115,7 +115,7 @@ class _TweetIconsRowState extends State<TweetIconsRow> {
115115
SizedBox(
116116
width: 10,
117117
),
118-
customText(widget.model.commentCount.toString(),
118+
customText(model.commentCount.toString(),
119119
style: TextStyle(fontWeight: FontWeight.bold)),
120120
SizedBox(
121121
width: 10,
@@ -126,9 +126,9 @@ class _TweetIconsRowState extends State<TweetIconsRow> {
126126
),
127127
customSwitcherWidget(
128128
duraton: Duration(milliseconds: 300),
129-
child: customText(widget.model.likeCount.toString(),
129+
child: customText(model.likeCount.toString(),
130130
style: TextStyle(fontWeight: FontWeight.bold),
131-
key: ValueKey(widget.model.likeCount)),
131+
key: ValueKey(model.likeCount)),
132132
),
133133
SizedBox(
134134
width: 10,
@@ -145,19 +145,19 @@ class _TweetIconsRowState extends State<TweetIconsRow> {
145145
),
146146
],);
147147
}
148-
void addLikeToTweet() {
148+
void addLikeToTweet(BuildContext context) {
149149
var state = Provider.of<FeedState>(context,);
150150
var authState = Provider.of<AuthState>(context,);
151-
state.addLikeToTweet(widget.model, authState.userId);
151+
state.addLikeToTweet(model, authState.userId);
152152
}
153153
@override
154154
Widget build(BuildContext context) {
155155
return Container(
156156
child:Column(children: <Widget>[
157-
widget.isTweetDetail ? _timeWidget() : SizedBox(),
158-
widget.isTweetDetail ? _likeCommentWidget() : SizedBox(),
157+
isTweetDetail ? _timeWidget(context): SizedBox(),
158+
isTweetDetail ? _likeCommentWidget() : SizedBox(),
159159

160-
_likeCommentsIcons(widget.model)
160+
_likeCommentsIcons(context, model)
161161
],)
162162
);
163163
}

0 commit comments

Comments
 (0)