Skip to content

Commit

Permalink
✨ Add Interactive widget to tweet and profile image.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlphamerc committed Dec 12, 2020
1 parent a9c6c76 commit c6461dd
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 43 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.thealphamerc.flutter_twitter_clone"
applicationId "com.thealphamerc.flutter_twitter_clone_dev"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
Expand Down
18 changes: 10 additions & 8 deletions lib/page/feed/composeTweet/widget/composeTweetImage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ class ComposeTweetImage extends StatelessWidget {
? Container()
: Stack(
children: <Widget>[
Container(
alignment: Alignment.topRight,
InteractiveViewer(
child: Container(
height: 220,
width: fullWidth(context) * .8,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
image: DecorationImage(
image: FileImage(image), fit: BoxFit.cover),
alignment: Alignment.topRight,
child: Container(
height: 220,
width: fullWidth(context) * .8,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
image: DecorationImage(
image: FileImage(image), fit: BoxFit.cover),
),
),
),
),
Expand Down
9 changes: 2 additions & 7 deletions lib/page/feed/imageViewPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,15 @@ class _ImageViewPgeState extends State<ImageViewPge> {
: Container(
alignment: Alignment.center,
child: Container(
child: InteractiveViewer(
child: customNetworkImage(
_image,
fit: BoxFit.fitWidth,
),
),
)),
);
}

void addLikeToTweet() {
var state = Provider.of<FeedState>(context, listen: false);
var authState = Provider.of<AuthState>(context, listen: false);
state.addLikeToTweet(state.tweetDetailModel.last, authState.userId);
}

void _submitButton() {
if (_textEditingController.text == null ||
_textEditingController.text.isEmpty) {
Expand Down
36 changes: 21 additions & 15 deletions lib/page/profile/profileImageView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ class ProfileImageView extends StatelessWidget {
actions: <Widget>[
PopupMenuButton<Choice>(
onSelected: (d) {
switch (d.title) {
case "Share image link": share(authstate.profileUserModel.profilePic); break;
case "Open in browser": launchURL(authstate.profileUserModel.profilePic); break;
case "Save": break;
}

switch (d.title) {
case "Share image link":
share(authstate.profileUserModel.profilePic);
break;
case "Open in browser":
launchURL(authstate.profileUserModel.profilePic);
break;
case "Save":
break;
}
},
itemBuilder: (BuildContext context) {
return choices.map((Choice choice) {
Expand All @@ -42,15 +46,17 @@ class ProfileImageView extends StatelessWidget {
],
),
body: Center(
child: Container(
alignment: Alignment.center,
width: fullWidth(context),
// height: fullWidth(context),
decoration: BoxDecoration(
image: DecorationImage(
image: customAdvanceNetworkImage(
authstate.profileUserModel.profilePic),
fit: BoxFit.contain,
child: InteractiveViewer(
child: Container(
alignment: Alignment.center,
width: fullWidth(context),
// height: fullWidth(context),
decoration: BoxDecoration(
image: DecorationImage(
image: customAdvanceNetworkImage(
authstate.profileUserModel.profilePic),
fit: BoxFit.contain,
),
),
),
),
Expand Down
18 changes: 9 additions & 9 deletions lib/state/chats/chatState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:flutter_twitter_clone/state/appState.dart';

class ChatState extends AppState {
bool setIsChatScreenOpen;
// final FirebaseDatabase _database = FirebaseDatabase.instance;
final FirebaseMessaging firebaseMessaging = FirebaseMessaging();

List<ChatMessage> _messageList;
List<ChatMessage> _chatUserList;
Expand Down Expand Up @@ -262,6 +262,9 @@ class ChatState extends AppState {
notifyListeners();
}

/// [Warning] do not call super.dispose() from this method
/// If this method called here it will dipose chat state data
// super.dispose();
void dispose() {
var user = _chatUserList.firstWhere((x) => x.key == chatUser.userId);
if (_messageList != null) {
Expand All @@ -270,16 +273,10 @@ class ChatState extends AppState {
_messageList = null;
notifyListeners();
}

/// [Warning] do not call super.dispose() from this method
/// If this method called here it will dipose chat state data
// super.dispose();
}

final FirebaseMessaging firebaseMessaging = FirebaseMessaging();

/// Push notification will be sent to other user whrn you send him a message on in chat.
void sendAndRetrieveMessage(ChatMessage model) async {
/// on noti
await firebaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(
sound: true, badge: true, alert: true, provisional: false),
Expand All @@ -303,7 +300,6 @@ class ChatState extends AppState {
"receiverId": model.receiverId,
"title": "title",
"body": model.message,
"tweetId": ""
},
'to': chatUser.fcmToken
});
Expand All @@ -313,6 +309,10 @@ class ChatState extends AppState {
'Authorization': 'key=$serverToken',
},
body: body);
if (response.reasonPhrase.contains("INVALID_KEY")) {
cprint("You are using Invalid FCM key");
return;
}
print(response.body.toString());
}
}
2 changes: 1 addition & 1 deletion lib/state/notificationState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class NotificationState extends AppState {
}
}

/// Configure notification services
/// Initilise push notification services
void initfirebaseService() {
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
Expand Down
8 changes: 6 additions & 2 deletions lib/widgets/tweet/tweet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ class _TweetBody extends StatelessWidget {
Widget build(BuildContext context) {
double descriptionFontSize = type == TweetType.Tweet
? 15
: type == TweetType.Detail || type == TweetType.ParentTweet ? 18 : 14;
: type == TweetType.Detail || type == TweetType.ParentTweet
? 18
: 14;
FontWeight descriptionFontWeight =
type == TweetType.Tweet || type == TweetType.Tweet
? FontWeight.w400
Expand Down Expand Up @@ -270,7 +272,9 @@ class _TweetDetailBody extends StatelessWidget {
? getDimention(context, 15)
: type == TweetType.Detail
? getDimention(context, 18)
: type == TweetType.ParentTweet ? getDimention(context, 14) : 10;
: type == TweetType.ParentTweet
? getDimention(context, 14)
: 10;

FontWeight descriptionFontWeight =
type == TweetType.Tweet || type == TweetType.Tweet
Expand Down

0 comments on commit c6461dd

Please sign in to comment.