diff --git a/lib/helper/enum.dart b/lib/helper/enum.dart index 68dbf07c..a8ef9e5c 100644 --- a/lib/helper/enum.dart +++ b/lib/helper/enum.dart @@ -3,28 +3,29 @@ enum AuthStatus { NOT_LOGGED_IN, LOGGED_IN, } + enum TweetType { - Tweet, - Detail, - Reply, - ParentTweet, + TWEET, + DETAIL, + REPLY, + PARENT_TWEET, } enum SortUser { - Verified, - Alphabetically, - Newest, - Oldest, - MaxFollower, + VERIFIED, + ALPHABETICALLY, + NEWEST, + OLDEST, + MAX_FOLLOWER, } enum NotificationType { NOT_DETERMINED, - Message, - Tweet, - Reply, - Retweet, - Follow, - Mention, - Like + MESSAGE, + TWEET, + REPLY, + RETWEET, + FOLLOW, + MENTION, + LIKE } diff --git a/lib/model/feedModel.dart b/lib/model/feedModel.dart index 78f35c5b..5c6775ab 100644 --- a/lib/model/feedModel.dart +++ b/lib/model/feedModel.dart @@ -132,7 +132,7 @@ class FeedModel { /// get tweet key to retweet. /// - /// If tweet [TweetType] is [TweetType.Retweet] and its description is null + /// If tweet [TweetType] is [TweetType.RETWEET] and its description is null /// then its retweeted child tweet will be shared. String get getTweetKeyToRetweet { if (description == null && imagePath == null && childRetwetkey != null) { diff --git a/lib/state/base/tweetBaseState.dart b/lib/state/base/tweetBaseState.dart index ff8ae04e..000874b6 100644 --- a/lib/state/base/tweetBaseState.dart +++ b/lib/state/base/tweetBaseState.dart @@ -133,7 +133,7 @@ class TweetBaseState extends AppState { .child(tweet.key!) .set({ 'type': - tweet.likeList!.isEmpty ? null : NotificationType.Like.toString(), + tweet.likeList!.isEmpty ? null : NotificationType.LIKE.toString(), 'updatedAt': tweet.likeList!.isEmpty ? null : DateTime.now().toUtc().toString(), }); diff --git a/lib/state/chats/chatState.dart b/lib/state/chats/chatState.dart index 012b3593..1e45b9eb 100644 --- a/lib/state/chats/chatState.dart +++ b/lib/state/chats/chatState.dart @@ -307,7 +307,7 @@ class ChatState extends AppState { 'click_action': 'FLUTTER_NOTIFICATION_CLICK', 'id': '1', 'status': 'done', - "type": NotificationType.Message.toString(), + "type": NotificationType.MESSAGE.toString(), "senderId": model.senderId, "receiverId": model.receiverId, "title": "title", diff --git a/lib/state/feedState.dart b/lib/state/feedState.dart index 4384f407..d049a357 100644 --- a/lib/state/feedState.dart +++ b/lib/state/feedState.dart @@ -345,7 +345,7 @@ class FeedState extends AppState { try { /// Delete tweet if it is in nested tweet detail page kDatabase.child('tweet').child(tweetId).remove().then((_) { - if (type == TweetType.Detail && + if (type == TweetType.DETAIL && _tweetDetailModelList != null && _tweetDetailModelList!.isNotEmpty) { // var deletedTweet = @@ -441,7 +441,7 @@ class FeedState extends AppState { .child(tweet.key!) .set({ 'type': - tweet.likeList!.isEmpty ? null : NotificationType.Like.toString(), + tweet.likeList!.isEmpty ? null : NotificationType.LIKE.toString(), 'updatedAt': tweet.likeList!.isEmpty ? null : DateTime.now().toUtc().toString(), }); diff --git a/lib/state/profile_state.dart b/lib/state/profile_state.dart index 66aa45d5..01f3b207 100644 --- a/lib/state/profile_state.dart +++ b/lib/state/profile_state.dart @@ -148,7 +148,7 @@ class ProfileState extends ChangeNotifier { // Sends notification to user who created tweet // UserModel owner can see notification on notification page kDatabase.child('notification').child(profileId).child(userId).set({ - 'type': NotificationType.Follow.toString(), + 'type': NotificationType.FOLLOW.toString(), 'createdAt': DateTime.now().toUtc().toString(), 'data': UserModel( displayName: userModel.displayName, diff --git a/lib/state/searchState.dart b/lib/state/searchState.dart index 2496128a..35fabd2f 100644 --- a/lib/state/searchState.dart +++ b/lib/state/searchState.dart @@ -6,7 +6,7 @@ import 'appState.dart'; class SearchState extends AppState { bool isBusy = false; - SortUser sortBy = SortUser.MaxFollower; + SortUser sortBy = SortUser.MAX_FOLLOWER; List? _userFilterList; List? _userlist; @@ -96,26 +96,26 @@ class SearchState extends AppState { String get selectedFilter { switch (sortBy) { - case SortUser.Alphabetically: + case SortUser.ALPHABETICALLY: _userFilterList! .sort((x, y) => x.displayName!.compareTo(y.displayName!)); return "Alphabetically"; - case SortUser.MaxFollower: + case SortUser.MAX_FOLLOWER: _userFilterList!.sort((x, y) => y.followers!.compareTo(x.followers!)); return "Popular"; - case SortUser.Newest: + case SortUser.NEWEST: _userFilterList!.sort((x, y) => DateTime.parse(y.createdAt!) .compareTo(DateTime.parse(x.createdAt!))); return "Newest user"; - case SortUser.Oldest: + case SortUser.OLDEST: _userFilterList!.sort((x, y) => DateTime.parse(x.createdAt!) .compareTo(DateTime.parse(y.createdAt!))); return "Oldest user"; - case SortUser.Verified: + case SortUser.VERIFIED: _userFilterList!.sort((x, y) => y.isVerified.toString().compareTo(x.isVerified.toString())); return "Verified user"; diff --git a/lib/ui/page/bookmark/bookmarkPage.dart b/lib/ui/page/bookmark/bookmarkPage.dart index 3242d268..fc626031 100644 --- a/lib/ui/page/bookmark/bookmarkPage.dart +++ b/lib/ui/page/bookmark/bookmarkPage.dart @@ -46,7 +46,7 @@ class BookmarkPageBody extends StatelessWidget { color: Colors.white, child: Tweet( model: model, - type: TweetType.Tweet, + type: TweetType.TWEET, scaffoldKey: GlobalKey(), ), ); diff --git a/lib/ui/page/feed/composeTweet/state/composeTweetState.dart b/lib/ui/page/feed/composeTweet/state/composeTweetState.dart index 20715957..330cd3fb 100644 --- a/lib/ui/page/feed/composeTweet/state/composeTweetState.dart +++ b/lib/ui/page/feed/composeTweet/state/composeTweetState.dart @@ -181,7 +181,7 @@ class ComposeTweetState extends ChangeNotifier { 'click_action': 'FLUTTER_NOTIFICATION_CLICK', 'id': '1', 'status': 'done', - "type": NotificationType.Mention.toString(), + "type": NotificationType.MENTION.toString(), "senderId": model.user!.userId, "receiverId": user.userId, "title": "title", diff --git a/lib/ui/page/feed/feedPage.dart b/lib/ui/page/feed/feedPage.dart index d4d092c3..eb209e82 100644 --- a/lib/ui/page/feed/feedPage.dart +++ b/lib/ui/page/feed/feedPage.dart @@ -111,7 +111,7 @@ class _FeedPageBody extends StatelessWidget { trailing: TweetBottomSheet().tweetOptionIcon( context, model: model, - type: TweetType.Tweet, + type: TweetType.TWEET, scaffoldKey: scaffoldKey), scaffoldKey: scaffoldKey, ), diff --git a/lib/ui/page/feed/feedPostDetail.dart b/lib/ui/page/feed/feedPostDetail.dart index 1270c92d..126c4188 100644 --- a/lib/ui/page/feed/feedPostDetail.dart +++ b/lib/ui/page/feed/feedPostDetail.dart @@ -51,9 +51,9 @@ class _FeedPostDetailState extends State { Widget _commentRow(FeedModel model) { return Tweet( model: model, - type: TweetType.Reply, + type: TweetType.REPLY, trailing: TweetBottomSheet().tweetOptionIcon(context, - scaffoldKey: scaffoldKey, model: model, type: TweetType.Reply), + scaffoldKey: scaffoldKey, model: model, type: TweetType.REPLY), scaffoldKey: scaffoldKey, ); } @@ -61,9 +61,9 @@ class _FeedPostDetailState extends State { Widget _tweetDetail(FeedModel model) { return Tweet( model: model, - type: TweetType.Detail, + type: TweetType.DETAIL, trailing: TweetBottomSheet().tweetOptionIcon(context, - scaffoldKey: scaffoldKey, model: model, type: TweetType.Detail), + scaffoldKey: scaffoldKey, model: model, type: TweetType.DETAIL), scaffoldKey: scaffoldKey, ); } @@ -83,7 +83,7 @@ class _FeedPostDetailState extends State { var state = Provider.of(context, listen: false); state.deleteTweet(tweetId, type, parentkey: parentkey); Navigator.of(context).pop(); - if (type == TweetType.Detail) Navigator.of(context).pop(); + if (type == TweetType.DETAIL) Navigator.of(context).pop(); } @override diff --git a/lib/ui/page/homePage.dart b/lib/ui/page/homePage.dart index ca3b5a00..b3df68fd 100644 --- a/lib/ui/page/homePage.dart +++ b/lib/ui/page/homePage.dart @@ -104,7 +104,7 @@ class _HomePageState extends State { /// Redirect to chat screen /// `model.data.senderId` is a user id who sends you a message /// `model.data.receiverId` is a your user id. - if (model.type == NotificationType.Message.toString() && + if (model.type == NotificationType.MESSAGE.toString() && model.receiverId == authState.user!.uid) { /// Get sender profile detail from firebase state.getUserDetail(model.senderId).then((user) { @@ -120,7 +120,7 @@ class _HomePageState extends State { /// If you are mentioned in tweet then it redirect to user profile who mentioned you in a tweet /// You can check that tweet on his profile timeline /// `model.data.senderId` is user id who tagged you in a tweet - else if (model.type == NotificationType.Mention.toString() && + else if (model.type == NotificationType.MENTION.toString() && model.receiverId == authState.user!.uid) { var feedState = Provider.of(context, listen: false); feedState.getPostDetailFromDatabase(model.tweetId); diff --git a/lib/ui/page/notification/notificationPage.dart b/lib/ui/page/notification/notificationPage.dart index 7aa31d3f..933aaf0a 100644 --- a/lib/ui/page/notification/notificationPage.dart +++ b/lib/ui/page/notification/notificationPage.dart @@ -60,7 +60,7 @@ class NotificationPageBody extends StatelessWidget { Widget _notificationRow(BuildContext context, NotificationModel model) { var state = Provider.of(context); - if (model.type == NotificationType.Follow.toString()) { + if (model.type == NotificationType.FOLLOW.toString()) { return FollowNotificationTile( model: model, ); diff --git a/lib/ui/page/profile/follow/followListState.dart b/lib/ui/page/profile/follow/followListState.dart index a78c4b3f..88a20b6d 100644 --- a/lib/ui/page/profile/follow/followListState.dart +++ b/lib/ui/page/profile/follow/followListState.dart @@ -97,7 +97,7 @@ class FollowListState extends AppState { .child(profileId) .child(_currentUser!.userId!) .set({ - 'type': NotificationType.Follow.toString(), + 'type': NotificationType.FOLLOW.toString(), 'createdAt': DateTime.now().toUtc().toString(), 'data': UserModel( displayName: _currentUser!.displayName, diff --git a/lib/ui/page/profile/profilePage.dart b/lib/ui/page/profile/profilePage.dart index 74acf3cb..926cfb54 100644 --- a/lib/ui/page/profile/profilePage.dart +++ b/lib/ui/page/profile/profilePage.dart @@ -466,7 +466,7 @@ class _ProfilePageState extends State trailing: TweetBottomSheet().tweetOptionIcon( context, model: list[index], - type: TweetType.Tweet, + type: TweetType.TWEET, scaffoldKey: scaffoldKey, ), scaffoldKey: scaffoldKey, diff --git a/lib/ui/page/settings/accountSettings/contentPrefrences/trends/trendsPage.dart b/lib/ui/page/settings/accountSettings/contentPrefrences/trends/trendsPage.dart index 1719fc1d..0bc13541 100644 --- a/lib/ui/page/settings/accountSettings/contentPrefrences/trends/trendsPage.dart +++ b/lib/ui/page/settings/accountSettings/contentPrefrences/trends/trendsPage.dart @@ -52,15 +52,15 @@ class TrendsPage extends StatelessWidget { child: TitleText('Sort user list'), ), const Divider(height: 0), - _row(context, "Verified user", SortUser.Verified), + _row(context, "Verified user", SortUser.VERIFIED), const Divider(height: 0), - _row(context, "Alphabetically", SortUser.Alphabetically), + _row(context, "Alphabetically", SortUser.ALPHABETICALLY), const Divider(height: 0), - _row(context, "Newest user", SortUser.Newest), + _row(context, "Newest user", SortUser.NEWEST), const Divider(height: 0), - _row(context, "Oldest user", SortUser.Oldest), + _row(context, "Oldest user", SortUser.OLDEST), const Divider(height: 0), - _row(context, "Popular User", SortUser.MaxFollower), + _row(context, "Popular User", SortUser.MAX_FOLLOWER), ], ), ); diff --git a/lib/widgets/tweet/tweet.dart b/lib/widgets/tweet/tweet.dart index c800845a..bcf4cf37 100644 --- a/lib/widgets/tweet/tweet.dart +++ b/lib/widgets/tweet/tweet.dart @@ -28,13 +28,13 @@ class Tweet extends StatelessWidget { Key? key, required this.model, this.trailing, - this.type = TweetType.Tweet, + this.type = TweetType.TWEET, this.isDisplayOnProfile = false, required this.scaffoldKey, }) : super(key: key); void onLongPressedTweet(BuildContext context) { - if (type == TweetType.Detail || type == TweetType.ParentTweet) { + if (type == TweetType.DETAIL || type == TweetType.PARENT_TWEET) { Utility.copyToClipBoard( context: context, text: model.description ?? "", @@ -44,10 +44,10 @@ class Tweet extends StatelessWidget { void onTapTweet(BuildContext context) { var feedState = Provider.of(context, listen: false); - if (type == TweetType.Detail || type == TweetType.ParentTweet) { + if (type == TweetType.DETAIL || type == TweetType.PARENT_TWEET) { return; } - if (type == TweetType.Tweet && !isDisplayOnProfile) { + if (type == TweetType.TWEET && !isDisplayOnProfile) { feedState.clearAllDetailAndReplyTweetStack(); } feedState.getPostDetailFromDatabase(null, model: model); @@ -60,7 +60,7 @@ class Tweet extends StatelessWidget { alignment: Alignment.topLeft, children: [ /// Left vertical bar of a tweet - type != TweetType.ParentTweet + type != TweetType.PARENT_TWEET ? const SizedBox.shrink() : Positioned.fill( child: Container( @@ -87,11 +87,11 @@ class Tweet extends StatelessWidget { children: [ Container( padding: EdgeInsets.only( - top: type == TweetType.Tweet || type == TweetType.Reply + top: type == TweetType.TWEET || type == TweetType.REPLY ? 12 : 0, ), - child: type == TweetType.Tweet || type == TweetType.Reply + child: type == TweetType.TWEET || type == TweetType.REPLY ? _TweetBody( isDisplayOnProfile: isDisplayOnProfile, model: model, @@ -122,18 +122,18 @@ class Tweet extends StatelessWidget { ), Padding( padding: - EdgeInsets.only(left: type == TweetType.Detail ? 10 : 60), + EdgeInsets.only(left: type == TweetType.DETAIL ? 10 : 60), child: TweetIconsRow( type: type, model: model, - isTweetDetail: type == TweetType.Detail, + isTweetDetail: type == TweetType.DETAIL, iconColor: Theme.of(context).textTheme.caption!.color!, iconEnableColor: TwitterColor.ceriseRed, size: 20, scaffoldKey: GlobalKey(), ), ), - type == TweetType.ParentTweet + type == TweetType.PARENT_TWEET ? const SizedBox.shrink() : const Divider(height: .5, thickness: .5) ], @@ -159,13 +159,13 @@ class _TweetBody extends StatelessWidget { @override Widget build(BuildContext context) { - double descriptionFontSize = type == TweetType.Tweet + double descriptionFontSize = type == TweetType.TWEET ? 15 - : type == TweetType.Detail || type == TweetType.ParentTweet + : type == TweetType.DETAIL || type == TweetType.PARENT_TWEET ? 18 : 14; FontWeight descriptionFontWeight = - type == TweetType.Tweet || type == TweetType.Tweet + type == TweetType.TWEET || type == TweetType.TWEET ? FontWeight.w400 : FontWeight.w400; TextStyle textStyle = TextStyle( @@ -297,16 +297,16 @@ class _TweetDetailBody extends StatelessWidget { @override Widget build(BuildContext context) { - double descriptionFontSize = type == TweetType.Tweet + double descriptionFontSize = type == TweetType.TWEET ? context.getDimension(context, 15) - : type == TweetType.Detail + : type == TweetType.DETAIL ? context.getDimension(context, 18) - : type == TweetType.ParentTweet + : type == TweetType.PARENT_TWEET ? context.getDimension(context, 14) : 10; FontWeight descriptionFontWeight = - type == TweetType.Tweet || type == TweetType.Tweet + type == TweetType.TWEET || type == TweetType.TWEET ? FontWeight.w300 : FontWeight.w400; TextStyle textStyle = TextStyle( @@ -322,7 +322,7 @@ class _TweetDetailBody extends StatelessWidget { children: [ model.parentkey != null && model.childRetwetkey == null && - type != TweetType.ParentTweet + type != TweetType.PARENT_TWEET ? ParentTweetWidget( childRetwetkey: model.parentkey!, // isImageAvailable: false, @@ -377,7 +377,7 @@ class _TweetDetailBody extends StatelessWidget { model.description == null ? const SizedBox() : Padding( - padding: type == TweetType.ParentTweet + padding: type == TweetType.PARENT_TWEET ? const EdgeInsets.only(left: 80, right: 16) : const EdgeInsets.symmetric(horizontal: 16), child: Column( diff --git a/lib/widgets/tweet/widgets/parentTweet.dart b/lib/widgets/tweet/widgets/parentTweet.dart index 2bfc6988..59ea4aa5 100644 --- a/lib/widgets/tweet/widgets/parentTweet.dart +++ b/lib/widgets/tweet/widgets/parentTweet.dart @@ -36,7 +36,7 @@ class ParentTweetWidget extends StatelessWidget { if (snapshot.hasData) { return Tweet( model: snapshot.data!, - type: TweetType.ParentTweet, + type: TweetType.PARENT_TWEET, trailing: trailing, scaffoldKey: GlobalKey(), ); diff --git a/lib/widgets/tweet/widgets/retweetWidget.dart b/lib/widgets/tweet/widgets/retweetWidget.dart index 30bd3d90..a242882b 100644 --- a/lib/widgets/tweet/widgets/retweetWidget.dart +++ b/lib/widgets/tweet/widgets/retweetWidget.dart @@ -112,7 +112,7 @@ class RetweetWidget extends StatelessWidget { if (snapshot.hasData) { return Container( margin: EdgeInsets.only( - left: type == TweetType.Tweet || type == TweetType.ParentTweet + left: type == TweetType.TWEET || type == TweetType.PARENT_TWEET ? 70 : 12, right: 16, diff --git a/lib/widgets/tweet/widgets/tweetBottomSheet.dart b/lib/widgets/tweet/widgets/tweetBottomSheet.dart index 726b32a9..6c6faae3 100644 --- a/lib/widgets/tweet/widgets/tweetBottomSheet.dart +++ b/lib/widgets/tweet/widgets/tweetBottomSheet.dart @@ -49,7 +49,7 @@ class TweetBottomSheet { return Container( padding: const EdgeInsets.only(top: 5, bottom: 0), height: context.height * - (type == TweetType.Tweet + (type == TweetType.TWEET ? (isMyTweet ? .25 : .44) : (isMyTweet ? .38 : .52)), width: context.width, @@ -60,7 +60,7 @@ class TweetBottomSheet { topRight: Radius.circular(20), ), ), - child: type == TweetType.Tweet + child: type == TweetType.TWEET ? _tweetOptions(context, scaffoldKey: scaffoldKey, isMyTweet: isMyTweet, @@ -380,7 +380,7 @@ class TweetBottomSheet { state.deleteTweet(tweetId, type, parentkey: parentkey); // CLose bottom sheet Navigator.of(context).pop(); - if (type == TweetType.Detail) { + if (type == TweetType.DETAIL) { // Close Tweet detail page Navigator.of(context).pop(); // Remove last tweet from tweet detail stack page diff --git a/lib/widgets/tweet/widgets/tweetImage.dart b/lib/widgets/tweet/widgets/tweetImage.dart index c0b96b4e..32b0f86b 100644 --- a/lib/widgets/tweet/widgets/tweetImage.dart +++ b/lib/widgets/tweet/widgets/tweetImage.dart @@ -29,7 +29,7 @@ class TweetImage extends StatelessWidget { Radius.circular(isRetweetImage ? 0 : 20), ), onTap: () { - if (type == TweetType.ParentTweet) { + if (type == TweetType.PARENT_TWEET) { return; } var state = Provider.of(context, listen: false); @@ -43,7 +43,7 @@ class TweetImage extends StatelessWidget { ), child: Container( width: - context.width * (type == TweetType.Detail ? .95 : .8) - + context.width * (type == TweetType.DETAIL ? .95 : .8) - 8, decoration: BoxDecoration( color: Theme.of(context).backgroundColor, diff --git a/lib/widgets/tweet/widgets/unavailableTweet.dart b/lib/widgets/tweet/widgets/unavailableTweet.dart index 1e250c31..3ffa185a 100644 --- a/lib/widgets/tweet/widgets/unavailableTweet.dart +++ b/lib/widgets/tweet/widgets/unavailableTweet.dart @@ -19,7 +19,7 @@ class UnavailableTweet extends StatelessWidget { margin: EdgeInsets.only( right: 16, top: 5, - left: type == TweetType.Tweet || type == TweetType.ParentTweet + left: type == TweetType.TWEET || type == TweetType.PARENT_TWEET ? 70 : 16), alignment: Alignment.centerLeft,