Skip to content

Commit 682bbda

Browse files
committed
✨ (feat) Add Retweet without coment
#17
1 parent 9410d67 commit 682bbda

File tree

4 files changed

+76
-51
lines changed

4 files changed

+76
-51
lines changed

lib/model/feedModel.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ class FeedModel {
115115

116116
bool get isValidTweet {
117117
bool isValid = false;
118-
if (description != null &&
119-
description.isNotEmpty &&
120-
this.user != null &&
118+
if (this.user != null &&
121119
this.user.userName != null &&
122120
this.user.userName.isNotEmpty) {
123121
isValid = true;

lib/widgets/tweet/tweet.dart

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -234,20 +234,22 @@ class _TweetBody extends StatelessWidget {
234234
Container(child: trailing == null ? SizedBox() : trailing),
235235
],
236236
),
237-
UrlText(
238-
text: model.description,
239-
onHashTagPressed: (tag) {
240-
cprint(tag);
241-
},
242-
style: TextStyle(
243-
color: Colors.black,
244-
fontSize: descriptionFontSize,
245-
fontWeight: descriptionFontWeight),
246-
urlStyle: TextStyle(
247-
color: Colors.blue,
248-
fontSize: descriptionFontSize,
249-
fontWeight: descriptionFontWeight),
250-
),
237+
model.description == null
238+
? SizedBox()
239+
: UrlText(
240+
text: model.description,
241+
onHashTagPressed: (tag) {
242+
cprint(tag);
243+
},
244+
style: TextStyle(
245+
color: Colors.black,
246+
fontSize: descriptionFontSize,
247+
fontWeight: descriptionFontWeight),
248+
urlStyle: TextStyle(
249+
color: Colors.blue,
250+
fontSize: descriptionFontSize,
251+
fontWeight: descriptionFontWeight),
252+
),
251253
],
252254
),
253255
),
@@ -336,27 +338,29 @@ class _TweetDetailBody extends StatelessWidget {
336338
customText('${model.user.userName}', style: userNameStyle),
337339
trailing: trailing,
338340
),
339-
Padding(
340-
padding: type == TweetType.ParentTweet
341-
? EdgeInsets.only(left: 80, right: 16)
342-
: EdgeInsets.symmetric(horizontal: 16),
343-
child: UrlText(
344-
text: model.description,
345-
onHashTagPressed: (tag) {
346-
cprint(tag);
347-
},
348-
style: TextStyle(
349-
color: Colors.black,
350-
fontSize: descriptionFontSize,
351-
fontWeight: descriptionFontWeight,
352-
),
353-
urlStyle: TextStyle(
354-
color: Colors.blue,
355-
fontSize: descriptionFontSize,
356-
fontWeight: descriptionFontWeight,
357-
),
358-
),
359-
)
341+
model.description == null
342+
? SizedBox()
343+
: Padding(
344+
padding: type == TweetType.ParentTweet
345+
? EdgeInsets.only(left: 80, right: 16)
346+
: EdgeInsets.symmetric(horizontal: 16),
347+
child: UrlText(
348+
text: model.description,
349+
onHashTagPressed: (tag) {
350+
cprint(tag);
351+
},
352+
style: TextStyle(
353+
color: Colors.black,
354+
fontSize: descriptionFontSize,
355+
fontWeight: descriptionFontWeight,
356+
),
357+
urlStyle: TextStyle(
358+
color: Colors.blue,
359+
fontSize: descriptionFontSize,
360+
fontWeight: descriptionFontWeight,
361+
),
362+
),
363+
)
360364
],
361365
),
362366
),

lib/widgets/tweet/widgets/retweetWidget.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,21 @@ class RetweetWidget extends StatelessWidget {
7676
],
7777
),
7878
),
79-
Padding(
80-
padding: EdgeInsets.symmetric(horizontal: 8),
81-
child: UrlText(
82-
text: model.description,
83-
style: TextStyle(
84-
color: Colors.black,
85-
fontSize: 14,
86-
fontWeight: FontWeight.w400,
87-
),
88-
urlStyle:
89-
TextStyle(color: Colors.blue, fontWeight: FontWeight.w400),
90-
),
91-
),
79+
model.description == null
80+
? SizedBox()
81+
: Padding(
82+
padding: EdgeInsets.symmetric(horizontal: 8),
83+
child: UrlText(
84+
text: model.description,
85+
style: TextStyle(
86+
color: Colors.black,
87+
fontSize: 14,
88+
fontWeight: FontWeight.w400,
89+
),
90+
urlStyle: TextStyle(
91+
color: Colors.blue, fontWeight: FontWeight.w400),
92+
),
93+
),
9294
SizedBox(height: model.imagePath == null ? 8 : 0),
9395
TweetImage(model: model, type: type, isRetweetImage: true),
9496
],

lib/widgets/tweet/widgets/tweetBottomSheet.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter_twitter_clone/helper/constant.dart';
33
import 'package:flutter_twitter_clone/helper/enum.dart';
44
import 'package:flutter_twitter_clone/helper/theme.dart';
55
import 'package:flutter_twitter_clone/model/feedModel.dart';
6+
import 'package:flutter_twitter_clone/model/user.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';
@@ -313,7 +314,27 @@ class TweetBottomSheet {
313314
_widgetBottomSheetRow(
314315
context,
315316
AppIcon.retweet,
317+
isEnable: true,
316318
text: 'Retweet',
319+
onPressed: () {
320+
var state = Provider.of<FeedState>(context, listen: false);
321+
var authState = Provider.of<AuthState>(context, listen: false);
322+
var myUser = authState.userModel;
323+
myUser = UserModel(
324+
displayName: myUser.displayName ?? myUser.email.split('@')[0],
325+
profilePic: myUser.profilePic,
326+
userId: myUser.userId,
327+
isVerified: authState.userModel.isVerified,
328+
userName: authState.userModel.userName);
329+
// Prepare current Tweet model to reply
330+
FeedModel post = new FeedModel(
331+
childRetwetkey: model.key,
332+
createdAt: DateTime.now().toUtc().toString(),
333+
user: myUser,
334+
userId: myUser.userId);
335+
state.createReTweet(post);
336+
Navigator.pop(context);
337+
},
317338
),
318339
_widgetBottomSheetRow(
319340
context,

0 commit comments

Comments
 (0)