Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored enum UPPER_CASE #293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions lib/helper/enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion lib/model/feedModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/state/base/tweetBaseState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
Expand Down
2 changes: 1 addition & 1 deletion lib/state/chats/chatState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions lib/state/feedState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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(),
});
Expand Down
2 changes: 1 addition & 1 deletion lib/state/profile_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions lib/state/searchState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'appState.dart';

class SearchState extends AppState {
bool isBusy = false;
SortUser sortBy = SortUser.MaxFollower;
SortUser sortBy = SortUser.MAX_FOLLOWER;
List<UserModel>? _userFilterList;
List<UserModel>? _userlist;

Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/page/bookmark/bookmarkPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BookmarkPageBody extends StatelessWidget {
color: Colors.white,
child: Tweet(
model: model,
type: TweetType.Tweet,
type: TweetType.TWEET,
scaffoldKey: GlobalKey<ScaffoldState>(),
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/page/feed/composeTweet/state/composeTweetState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/page/feed/feedPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class _FeedPageBody extends StatelessWidget {
trailing: TweetBottomSheet().tweetOptionIcon(
context,
model: model,
type: TweetType.Tweet,
type: TweetType.TWEET,
scaffoldKey: scaffoldKey),
scaffoldKey: scaffoldKey,
),
Expand Down
10 changes: 5 additions & 5 deletions lib/ui/page/feed/feedPostDetail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ class _FeedPostDetailState extends State<FeedPostDetail> {
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,
);
}

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,
);
}
Expand All @@ -83,7 +83,7 @@ class _FeedPostDetailState extends State<FeedPostDetail> {
var state = Provider.of<FeedState>(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
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/page/homePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class _HomePageState extends State<HomePage> {
/// 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) {
Expand All @@ -120,7 +120,7 @@ class _HomePageState extends State<HomePage> {
/// 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<FeedState>(context, listen: false);
feedState.getPostDetailFromDatabase(model.tweetId);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/page/notification/notificationPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class NotificationPageBody extends StatelessWidget {

Widget _notificationRow(BuildContext context, NotificationModel model) {
var state = Provider.of<NotificationState>(context);
if (model.type == NotificationType.Follow.toString()) {
if (model.type == NotificationType.FOLLOW.toString()) {
return FollowNotificationTile(
model: model,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/page/profile/follow/followListState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/page/profile/profilePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ class _ProfilePageState extends State<ProfilePage>
trailing: TweetBottomSheet().tweetOptionIcon(
context,
model: list[index],
type: TweetType.Tweet,
type: TweetType.TWEET,
scaffoldKey: scaffoldKey,
),
scaffoldKey: scaffoldKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
),
);
Expand Down
38 changes: 19 additions & 19 deletions lib/widgets/tweet/tweet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? "",
Expand All @@ -44,10 +44,10 @@ class Tweet extends StatelessWidget {

void onTapTweet(BuildContext context) {
var feedState = Provider.of<FeedState>(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);
Expand All @@ -60,7 +60,7 @@ class Tweet extends StatelessWidget {
alignment: Alignment.topLeft,
children: <Widget>[
/// Left vertical bar of a tweet
type != TweetType.ParentTweet
type != TweetType.PARENT_TWEET
? const SizedBox.shrink()
: Positioned.fill(
child: Container(
Expand All @@ -87,11 +87,11 @@ class Tweet extends StatelessWidget {
children: <Widget>[
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,
Expand Down Expand Up @@ -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<ScaffoldState>(),
),
),
type == TweetType.ParentTweet
type == TweetType.PARENT_TWEET
? const SizedBox.shrink()
: const Divider(height: .5, thickness: .5)
],
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -322,7 +322,7 @@ class _TweetDetailBody extends StatelessWidget {
children: <Widget>[
model.parentkey != null &&
model.childRetwetkey == null &&
type != TweetType.ParentTweet
type != TweetType.PARENT_TWEET
? ParentTweetWidget(
childRetwetkey: model.parentkey!,
// isImageAvailable: false,
Expand Down Expand Up @@ -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(
Expand Down
Loading