Skip to content

Commit c6461dd

Browse files
committed
✨ Add Interactive widget to tweet and profile image.
1 parent a9c6c76 commit c6461dd

File tree

7 files changed

+50
-43
lines changed

7 files changed

+50
-43
lines changed

android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ android {
3333

3434
defaultConfig {
3535
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
36-
applicationId "com.thealphamerc.flutter_twitter_clone"
36+
applicationId "com.thealphamerc.flutter_twitter_clone_dev"
3737
minSdkVersion 16
3838
targetSdkVersion 29
3939
versionCode flutterVersionCode.toInteger()

lib/page/feed/composeTweet/widget/composeTweetImage.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ class ComposeTweetImage extends StatelessWidget {
1616
? Container()
1717
: Stack(
1818
children: <Widget>[
19-
Container(
20-
alignment: Alignment.topRight,
19+
InteractiveViewer(
2120
child: Container(
22-
height: 220,
23-
width: fullWidth(context) * .8,
24-
decoration: BoxDecoration(
25-
borderRadius: BorderRadius.all(Radius.circular(10)),
26-
image: DecorationImage(
27-
image: FileImage(image), fit: BoxFit.cover),
21+
alignment: Alignment.topRight,
22+
child: Container(
23+
height: 220,
24+
width: fullWidth(context) * .8,
25+
decoration: BoxDecoration(
26+
borderRadius: BorderRadius.all(Radius.circular(10)),
27+
image: DecorationImage(
28+
image: FileImage(image), fit: BoxFit.cover),
29+
),
2830
),
2931
),
3032
),

lib/page/feed/imageViewPage.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,15 @@ class _ImageViewPgeState extends State<ImageViewPge> {
140140
: Container(
141141
alignment: Alignment.center,
142142
child: Container(
143+
child: InteractiveViewer(
143144
child: customNetworkImage(
144145
_image,
145146
fit: BoxFit.fitWidth,
146147
),
147-
),
148+
)),
148149
);
149150
}
150151

151-
void addLikeToTweet() {
152-
var state = Provider.of<FeedState>(context, listen: false);
153-
var authState = Provider.of<AuthState>(context, listen: false);
154-
state.addLikeToTweet(state.tweetDetailModel.last, authState.userId);
155-
}
156-
157152
void _submitButton() {
158153
if (_textEditingController.text == null ||
159154
_textEditingController.text.isEmpty) {

lib/page/profile/profileImageView.dart

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ class ProfileImageView extends StatelessWidget {
2323
actions: <Widget>[
2424
PopupMenuButton<Choice>(
2525
onSelected: (d) {
26-
switch (d.title) {
27-
case "Share image link": share(authstate.profileUserModel.profilePic); break;
28-
case "Open in browser": launchURL(authstate.profileUserModel.profilePic); break;
29-
case "Save": break;
30-
}
31-
26+
switch (d.title) {
27+
case "Share image link":
28+
share(authstate.profileUserModel.profilePic);
29+
break;
30+
case "Open in browser":
31+
launchURL(authstate.profileUserModel.profilePic);
32+
break;
33+
case "Save":
34+
break;
35+
}
3236
},
3337
itemBuilder: (BuildContext context) {
3438
return choices.map((Choice choice) {
@@ -42,15 +46,17 @@ class ProfileImageView extends StatelessWidget {
4246
],
4347
),
4448
body: Center(
45-
child: Container(
46-
alignment: Alignment.center,
47-
width: fullWidth(context),
48-
// height: fullWidth(context),
49-
decoration: BoxDecoration(
50-
image: DecorationImage(
51-
image: customAdvanceNetworkImage(
52-
authstate.profileUserModel.profilePic),
53-
fit: BoxFit.contain,
49+
child: InteractiveViewer(
50+
child: Container(
51+
alignment: Alignment.center,
52+
width: fullWidth(context),
53+
// height: fullWidth(context),
54+
decoration: BoxDecoration(
55+
image: DecorationImage(
56+
image: customAdvanceNetworkImage(
57+
authstate.profileUserModel.profilePic),
58+
fit: BoxFit.contain,
59+
),
5460
),
5561
),
5662
),

lib/state/chats/chatState.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:flutter_twitter_clone/state/appState.dart';
1111

1212
class ChatState extends AppState {
1313
bool setIsChatScreenOpen;
14-
// final FirebaseDatabase _database = FirebaseDatabase.instance;
14+
final FirebaseMessaging firebaseMessaging = FirebaseMessaging();
1515

1616
List<ChatMessage> _messageList;
1717
List<ChatMessage> _chatUserList;
@@ -262,6 +262,9 @@ class ChatState extends AppState {
262262
notifyListeners();
263263
}
264264

265+
/// [Warning] do not call super.dispose() from this method
266+
/// If this method called here it will dipose chat state data
267+
// super.dispose();
265268
void dispose() {
266269
var user = _chatUserList.firstWhere((x) => x.key == chatUser.userId);
267270
if (_messageList != null) {
@@ -270,16 +273,10 @@ class ChatState extends AppState {
270273
_messageList = null;
271274
notifyListeners();
272275
}
273-
274-
/// [Warning] do not call super.dispose() from this method
275-
/// If this method called here it will dipose chat state data
276-
// super.dispose();
277276
}
278277

279-
final FirebaseMessaging firebaseMessaging = FirebaseMessaging();
280-
278+
/// Push notification will be sent to other user whrn you send him a message on in chat.
281279
void sendAndRetrieveMessage(ChatMessage model) async {
282-
/// on noti
283280
await firebaseMessaging.requestNotificationPermissions(
284281
const IosNotificationSettings(
285282
sound: true, badge: true, alert: true, provisional: false),
@@ -303,7 +300,6 @@ class ChatState extends AppState {
303300
"receiverId": model.receiverId,
304301
"title": "title",
305302
"body": model.message,
306-
"tweetId": ""
307303
},
308304
'to': chatUser.fcmToken
309305
});
@@ -313,6 +309,10 @@ class ChatState extends AppState {
313309
'Authorization': 'key=$serverToken',
314310
},
315311
body: body);
312+
if (response.reasonPhrase.contains("INVALID_KEY")) {
313+
cprint("You are using Invalid FCM key");
314+
return;
315+
}
316316
print(response.body.toString());
317317
}
318318
}

lib/state/notificationState.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class NotificationState extends AppState {
162162
}
163163
}
164164

165-
/// Configure notification services
165+
/// Initilise push notification services
166166
void initfirebaseService() {
167167
_firebaseMessaging.configure(
168168
onMessage: (Map<String, dynamic> message) async {

lib/widgets/tweet/tweet.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ class _TweetBody extends StatelessWidget {
158158
Widget build(BuildContext context) {
159159
double descriptionFontSize = type == TweetType.Tweet
160160
? 15
161-
: type == TweetType.Detail || type == TweetType.ParentTweet ? 18 : 14;
161+
: type == TweetType.Detail || type == TweetType.ParentTweet
162+
? 18
163+
: 14;
162164
FontWeight descriptionFontWeight =
163165
type == TweetType.Tweet || type == TweetType.Tweet
164166
? FontWeight.w400
@@ -270,7 +272,9 @@ class _TweetDetailBody extends StatelessWidget {
270272
? getDimention(context, 15)
271273
: type == TweetType.Detail
272274
? getDimention(context, 18)
273-
: type == TweetType.ParentTweet ? getDimention(context, 14) : 10;
275+
: type == TweetType.ParentTweet
276+
? getDimention(context, 14)
277+
: 10;
274278

275279
FontWeight descriptionFontWeight =
276280
type == TweetType.Tweet || type == TweetType.Tweet

0 commit comments

Comments
 (0)