Skip to content

Commit

Permalink
Merge pull request TheAlphamerc#275 from aa-rodriguezv/master
Browse files Browse the repository at this point in the history
Micro Optimizations. Erase non-informative comments. Remove unused imports. Did TODO to load asset error image. Removed unused variables.
  • Loading branch information
TheAlphamerc authored May 27, 2023
2 parents 385b883 + c917d6f commit 223a8a5
Show file tree
Hide file tree
Showing 47 changed files with 51 additions and 196 deletions.
2 changes: 1 addition & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thealphamerc.flutter_twitter_clone">
package="com.thealphamerc.flutter_twitter_clone_dev">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thealphamerc.flutter_twitter_clone">
package="com.thealphamerc.flutter_twitter_clone_dev">

<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
Expand Down
Binary file added assets/images/error_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions lib/model/feedModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,13 @@ class FeedModel {
key = map['key'];
description = map['description'];
userId = map['userId'];
// name = map['name'];
// profilePic = map['profilePic'];
likeCount = map['likeCount'] ?? 0;
commentCount = map['commentCount'];
retweetCount = map["retweetCount"] ?? 0;
imagePath = map['imagePath'];
createdAt = map['createdAt'];
imagePath = map['imagePath'];
lanCode = map['lanCode'];
// username = map['username'];
user = UserModel.fromJson(map['user']);
parentkey = map['parentkey'];
childRetwetkey = map['childRetwetkey'];
Expand Down
1 change: 0 additions & 1 deletion lib/state/base/tweetBaseState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ class TweetBaseState extends AppState {
/// upload [file] to firebase storage and return its path url
Future<String?> uploadFile(File file) async {
try {
// isBusy = true;
notifyListeners();
var storageReference = FirebaseStorage.instance
.ref()
Expand Down
2 changes: 0 additions & 2 deletions lib/state/chats/chatState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ class ChatState extends AppState {
/// Send message to other user
void onMessageSubmitted(
ChatMessage message,
/*{UserModel myUser, UserModel secondUser}*/
) {
print(chatUser!.userId);
try {
Expand Down Expand Up @@ -206,7 +205,6 @@ class ChatState extends AppState {
List<String> list = [user1, user2];
list.sort();
_channelName = '${list[0]}-${list[1]}';
// cprint(_channelName); //2RhfE-5kyFB
return _channelName!;
}

Expand Down
4 changes: 0 additions & 4 deletions lib/state/profile_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,17 @@ class ProfileState extends ChangeNotifier {
/// Trigger when logged-in user's profile change or updated
/// Firebase event callback for profile update
void _onProfileChanged(DatabaseEvent event) {
// if (event.snapshot != null) {

final updatedUser = UserModel.fromJson(event.snapshot.value as Map);
if (updatedUser.userId == profileId) {
_profileUserModel = updatedUser;
}
notifyListeners();
// }
}

@override
void dispose() {
_profileQuery!.onValue.drain();
profileSubscription.cancel();
// _profileQuery.
super.dispose();
}
}
2 changes: 0 additions & 2 deletions lib/state/suggestionUserState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ class SuggestionsState extends AppState {
.child('followingList')
.set(currentUser!.followingList);

// await getIt<SharedPreferenceHelper>().saveUserProfile(currentUser!);

displaySuggestions = false;
}
} catch (error) {
Expand Down
3 changes: 0 additions & 3 deletions lib/ui/page/Auth/forgetPasswordPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ import 'package:flutter_twitter_clone/widgets/customWidgets.dart';
import 'package:provider/provider.dart';

class ForgetPasswordPage extends StatefulWidget {
// final VoidCallback loginCallback;

const ForgetPasswordPage({
Key? key,
/*this.loginCallback*/
}) : super(key: key);
@override
State<StatefulWidget> createState() => _ForgetPasswordPageState();
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/page/Auth/signin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:flutter_twitter_clone/widgets/newWidget/customLoader.dart';
import 'package:provider/provider.dart';

class SignIn extends StatefulWidget {
final VoidCallback? loginCallback; //!
final VoidCallback? loginCallback;

const SignIn({Key? key, this.loginCallback}) : super(key: key);
@override
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/page/Auth/signup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ class _SignupState extends State<Signup> {
_entryField('Confirm password',
controller: _confirmController, isPassword: true),
_submitButton(context),

const Divider(height: 30),
const SizedBox(height: 30),
// _googleLoginButton(context),
GoogleLoginButton(
loginCallback: widget.loginCallback,
loader: loader,
Expand Down
2 changes: 0 additions & 2 deletions lib/ui/page/common/locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ final getIt = GetIt.instance;

void setupDependencies() {
getIt.registerSingleton<SharedPreferenceHelper>(SharedPreferenceHelper());
// getIt.registerSingleton<PushNotificationService>(
// PushNotificationService(FirebaseMessaging()));
}
1 change: 0 additions & 1 deletion lib/ui/page/common/sidebar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class _SidebarMenuState extends State<SidebarMenu> {
),
).ripple(() {
_logOut();
// Navigator.of(context).pushNamed('/signIn');
});
} else {
return Center(
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/page/common/splash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class _SplashPageState extends State<SplashPage> {
Widget _body() {
var height = 150.0;
return SizedBox(
height: context.height,
width: context.width,
height: double.infinity,
width: double.infinity,
child: Container(
height: height,
width: height,
Expand Down
8 changes: 3 additions & 5 deletions lib/ui/page/common/updateApp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ class _UpdateAppState extends State<UpdateApp> with WidgetsBindingObserver {
),
const SizedBox(height: 30),
Container(
width: context.width,
width: double.infinity,
margin: const EdgeInsets.symmetric(vertical: 35),
child: CustomFlatButton(
label: "Update now",
onPressed: () {
Utility.launchURL(
"https://play.google.com/store/apps/details?id=com.thealphamerc.flutter_twitter_clone");
},
onPressed: () => Utility.launchURL(
"https://play.google.com/store/apps/details?id=com.thealphamerc.flutter_twitter_clone"),
borderRadius: 30,
),
)
Expand Down
5 changes: 2 additions & 3 deletions lib/ui/page/common/usersListPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class UsersListPage extends StatelessWidget {
const UsersListPage({
Key? key,
this.pageTitle = "",
// this.appBarIcon,
required this.emptyScreenText,
required this.emptyScreenSubTileText,
this.userIdsList,
Expand All @@ -35,7 +34,7 @@ class UsersListPage extends StatelessWidget {
appBar: CustomAppBar(
isBackButton: true,
title: customTitleText(
pageTitle, /*icon: appBarIcon*/
pageTitle,
),
),
body: Consumer<SearchState>(
Expand All @@ -52,7 +51,7 @@ class UsersListPage extends StatelessWidget {
isFollowing: isFollowing,
)
: Container(
width: context.width,
width: double.infinity,
padding: const EdgeInsets.only(top: 0, left: 30, right: 30),
child: NotifyText(
title: emptyScreenText,
Expand Down
1 change: 0 additions & 1 deletion lib/ui/page/common/widget/userListWidget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class UserListWidget extends StatelessWidget {
},
itemCount: list.length,
);
// : LinearProgressIndicator();
}
}

Expand Down
2 changes: 0 additions & 2 deletions lib/ui/page/feed/composeTweet/state/composeTweetState.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ class ComposeTweetState extends ChangeNotifier {
return Future.value(null);
}
final FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.instance;
// await remoteConfig.fetch(expiration: const Duration(hours: 5));
// await remoteConfig.activateFetched();
var data = remoteConfig.getString('FcmServerKey');
serverToken = jsonDecode(data)["key"];
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class _ComposeBottomIconWidgetState extends State<ComposeBottomIconWidget> {

Widget _bottomIconWidget() {
return Container(
width: context.width,
width: double.infinity,
height: 50,
decoration: BoxDecoration(
border:
Expand Down Expand Up @@ -121,7 +121,7 @@ class _ComposeBottomIconWidgetState extends State<ComposeBottomIconWidget> {
}

double getTweetLimit() {
if (/*tweet == null || */ tweet.isEmpty) {
if (tweet.isEmpty) {
return 0.0;
}
if (tweet.length > 280) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class ComposeTweetImage extends StatelessWidget {
: super(key: key);
@override
Widget build(BuildContext context) {
if (image != null) assert(onCrossIconPressed != null);
return Container(
child: image == null
? Container()
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 @@ -87,7 +87,7 @@ class _FeedPageBody extends StatelessWidget {
height: context.height - 135,
child: CustomScreenLoader(
height: double.infinity,
width: context.width,
width: double.infinity,
backgroundColor: Colors.white,
),
),
Expand Down
8 changes: 2 additions & 6 deletions lib/ui/page/feed/feedPostDetail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class _FeedPostDetailState extends State<FeedPostDetail> {
@override
void initState() {
postId = widget.postId;
// var state = Provider.of<FeedState>(context, listen: false);
// state.getpostDetailFromDatabase(postId);
super.initState();
}

Expand Down Expand Up @@ -125,7 +123,7 @@ class _FeedPostDetailState extends State<FeedPostDetail> {
: _tweetDetail(state.tweetDetailModel!.last),
Container(
height: 6,
width: context.width,
width: double.infinity,
color: TwitterColor.mystic,
)
],
Expand All @@ -138,9 +136,7 @@ class _FeedPostDetailState extends State<FeedPostDetail> {
state.tweetReplyMap![postId] == null
? [
//!Removed container
const Center(
// child: Text('No comments'),
)
const Center()
]
: state.tweetReplyMap![postId]!
.map((x) => _commentRow(x))
Expand Down
5 changes: 2 additions & 3 deletions lib/ui/page/feed/imageViewPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter_twitter_clone/model/feedModel.dart';
import 'package:flutter_twitter_clone/model/user.dart';
import 'package:flutter_twitter_clone/state/authState.dart';
import 'package:flutter_twitter_clone/state/feedState.dart';
import 'package:flutter_twitter_clone/ui/theme/theme.dart';
import 'package:flutter_twitter_clone/widgets/cache_image.dart';
import 'package:flutter_twitter_clone/widgets/tweet/widgets/tweetIconsRow.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -37,8 +36,8 @@ class _ImageViewPgeState extends State<ImageViewPge> {
SingleChildScrollView(
child: Container(
color: Colors.brown.shade700,
constraints: BoxConstraints(
maxHeight: context.height,
constraints: const BoxConstraints(
maxHeight: double.infinity,
),
child: InkWell(
onTap: () {
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/page/feed/suggestedUsers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ class _SuggestedUsersState extends State<SuggestedUsers> {
child: searchState.isBusy
? SizedBox(
height: context.height,
child: CustomScreenLoader(
child: const CustomScreenLoader(
height: double.infinity,
width: context.width,
width: double.infinity,
backgroundColor: Colors.white,
),
)
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 @@ -37,7 +37,7 @@ class _HomePageState extends State<HomePage> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
final refreshIndicatorKey = GlobalKey<RefreshIndicatorState>();
int pageIndex = 0;
// ignore: cancel_subscriptions
// ignore: cancel_subscription
late StreamSubscription<PushNotificationModel> pushNotificationSubscription;
@override
void initState() {
Expand All @@ -57,7 +57,7 @@ class _HomePageState extends State<HomePage> {

@override
void dispose() {
// getIt<PushNotificationService>().pushBehaviorSubject.close();
pushNotificationSubscription.cancel();
super.dispose();
}

Expand Down
Loading

0 comments on commit 223a8a5

Please sign in to comment.