Skip to content

Commit d78758e

Browse files
committed
🗃 Change remote config
🩹 (fix) non critical issues
1 parent 5e6e15c commit d78758e

16 files changed

+124
-82
lines changed

lib/helper/constant.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ class Constants {
44
static List<String> dummyProfilePicList = [
55
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ6TaCLCqU4K0ieF27ayjl51NmitWaJAh_X0r1rLX4gMvOe0MDaYw&s',
66
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTFDjXj1F8Ix-rRFgY_r3GerDoQwfiOMXVt-tZdv_Mcou_yIlUC&s',
7-
'http://www.azembelani.co.za/wp-content/uploads/2016/07/20161014_58006bf6e7079-3.png',
87
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRzDG366qY7vXN2yng09wb517WTWqp-oua-mMsAoCadtncPybfQ&s',
98
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTq7BgpG1CwOveQ_gEFgOJASWjgzHAgVfyozkIXk67LzN1jnj9I&s',
109
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRPxjRIYT8pG0zgzKTilbko-MOv8pSnmO63M9FkOvfHoR9FvInm&s',

lib/helper/utility.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@ class Utility {
7979
}
8080

8181
var dur = DateTime.now().toLocal().difference(dt);
82-
if (dur.inDays > 0) {
82+
if (dur.inDays > 365) {
83+
msg = DateFormat.yMMMd().format(dt);
84+
} else if (dur.inDays > 30) {
85+
msg = DateFormat.yMMMd().format(dt);
86+
} else if (dur.inDays > 0) {
8387
msg = '${dur.inDays} d';
84-
return dur.inDays == 1 ? '1d' : DateFormat("dd MMM").format(dt);
88+
return dur.inDays == 1 ? '1d' : DateFormat.MMMd().format(dt);
8589
} else if (dur.inHours > 0) {
8690
msg = '${dur.inHours} h';
8791
} else if (dur.inMinutes > 0) {
@@ -146,8 +150,7 @@ class Utility {
146150
}
147151
}
148152

149-
static void logEvent(String event,
150-
{required Map<String, dynamic> parameter}) {
153+
static void logEvent(String event, {Map<String, dynamic>? parameter}) {
151154
kReleaseMode
152155
? kAnalytics.logEvent(name: event, parameters: parameter)
153156
: print("[EVENT]: $event");

lib/model/notificationModel.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ class NotificationModel {
66
String? id;
77
String? tweetKey;
88
String? updatedAt;
9-
late String? createdAt;
9+
String? createdAt;
1010
late String type;
11-
late Map<String, dynamic> data;
11+
Map<String, dynamic>? data;
1212

1313
NotificationModel(
1414
{this.id,
@@ -30,10 +30,6 @@ class NotificationModel {
3030
createdAt = map["createdAt"];
3131
this.data = data;
3232
}
33-
34-
Map<String, dynamic> toJson() => {
35-
"tweetKey": tweetKey,
36-
};
3733
}
3834

3935
extension NotificationModelHelper on NotificationModel {

lib/state/authState.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class AuthState extends AppState {
6060
notifyListeners();
6161
}
6262

63-
databaseInit() {
63+
void databaseInit() {
6464
try {
6565
if (_profileQuery == null) {
6666
_profileQuery = kDatabase.child("profile").child(user!.uid);
@@ -135,7 +135,7 @@ class AuthState extends AppState {
135135
}
136136

137137
/// Create user profile from google login
138-
createUserFromGoogleSignIn(User user) {
138+
void createUserFromGoogleSignIn(User user) {
139139
var diff = DateTime.now().difference(user.metadata.creationTime!);
140140
// Check if user is new or old
141141
// If user is new then add new user to firebase realtime kDatabase
@@ -193,7 +193,7 @@ class AuthState extends AppState {
193193
/// `Create` and `Update` user
194194
/// IF `newUser` is true new user is created
195195
/// Else existing user will update with new values
196-
createUser(UserModel user, {bool newUser = false}) {
196+
void createUser(UserModel user, {bool newUser = false}) {
197197
if (newUser) {
198198
// Create username by the combination of name and id
199199
user.userName =
@@ -233,7 +233,7 @@ class AuthState extends AppState {
233233
}
234234

235235
/// Reload user to get refresh user data
236-
reloadUser() async {
236+
void reloadUser() async {
237237
await user!.reload();
238238
user = _firebaseAuth.currentUser;
239239
if (user!.emailVerified) {
@@ -308,13 +308,15 @@ class AuthState extends AppState {
308308
var name = userModel.displayName ?? user!.displayName;
309309
_firebaseAuth.currentUser!.updateDisplayName(name);
310310
_firebaseAuth.currentUser!.updatePhotoURL(userModel.profilePic);
311+
Utility.logEvent('user_profile_image');
311312
}
312313

313314
/// upload banner image if not null
314315
if (bannerImage != null) {
315316
/// get banner storage path from server
316317
userModel!.bannerImage = await _uploadFileToStorage(bannerImage,
317318
'user/profile/${userModel.userName}/${path.basename(bannerImage.path)}');
319+
Utility.logEvent('user_banner_image');
318320
}
319321

320322
if (userModel != null) {
@@ -324,7 +326,7 @@ class AuthState extends AppState {
324326
}
325327
}
326328

327-
Utility.logEvent('update_user', parameter: {});
329+
Utility.logEvent('update_user');
328330
} catch (error) {
329331
cprint(error, errorIn: 'updateUserProfile');
330332
}
@@ -333,7 +335,7 @@ class AuthState extends AppState {
333335
Future<String> _uploadFileToStorage(File file, path) async {
334336
var task = _firebaseStorage.ref().child(path);
335337
var status = await task.putFile(file);
336-
print(status.state);
338+
cprint(status.state);
337339

338340
/// get file storage path from server
339341
return await task.getDownloadURL();

lib/ui/page/common/sidebar.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ class _SidebarMenuState extends State<SidebarMenu> {
255255
Navigator.push(
256256
context, ProfilePage.getRoute(profileId: state.userId));
257257
}),
258-
_menuListRowButton('Lists', icon: AppIcon.lists),
259258
_menuListRowButton(
260259
'Bookmark',
261260
icon: AppIcon.bookmark,
@@ -264,8 +263,8 @@ class _SidebarMenuState extends State<SidebarMenu> {
264263
Navigator.push(context, BookmarkPage.getRoute());
265264
},
266265
),
266+
_menuListRowButton('Lists', icon: AppIcon.lists),
267267
_menuListRowButton('Moments', icon: AppIcon.moments),
268-
_menuListRowButton('Fwitter ads', icon: AppIcon.twitterAds),
269268
const Divider(),
270269
_menuListRowButton('Settings and privacy', isEnable: true,
271270
onPressed: () {

lib/ui/page/common/splash.dart

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class _SplashPageState extends State<SplashPage> {
3939
cprint("App is updated");
4040
Future.delayed(const Duration(seconds: 1)).then((_) {
4141
var state = Provider.of<AuthState>(context, listen: false);
42-
// state.authStatus = AuthStatus.NOT_DETERMINED;
4342
state.getCurrentUser();
4443
});
4544
}
@@ -54,25 +53,24 @@ class _SplashPageState extends State<SplashPage> {
5453
Future<bool> _checkAppVersion() async {
5554
PackageInfo packageInfo = await PackageInfo.fromPlatform();
5655
final currentAppVersion = packageInfo.version;
57-
final appVersion = await _getAppVersionFromFirebaseConfig();
58-
if (appVersion != currentAppVersion) {
56+
final buildNo = packageInfo.buildNumber;
57+
final config = await _getAppVersionFromFirebaseConfig();
58+
59+
if (config != null &&
60+
config['name'] == currentAppVersion &&
61+
config['versions'].contains(int.tryParse(buildNo))) {
62+
return true;
63+
} else {
5964
if (kDebugMode) {
6065
cprint("Latest version of app is not installed on your system");
6166
cprint(
62-
"In debug mode we are not restrict devlopers to redirect to update screen");
67+
"This is for testing purpose only. In debug mode update screen will not be open up");
6368
cprint(
64-
"Redirect devs to update screen can put other devs in confusion");
69+
"If you are planning to publish app on store then please update app version in firebase config");
6570
return true;
6671
}
67-
Navigator.pushReplacement(
68-
context,
69-
MaterialPageRoute(
70-
builder: (_) => const UpdateApp(),
71-
),
72-
);
72+
Navigator.pushReplacement(context, UpdateApp.getRoute());
7373
return false;
74-
} else {
75-
return true;
7674
}
7775
}
7876

@@ -82,20 +80,24 @@ class _SplashPageState extends State<SplashPage> {
8280
/// you have to add latest app version in firebase remote config
8381
/// To fetch this key go to project setting in firebase
8482
/// Open `Remote Config` section in fireabse
85-
/// Add [appVersion] as paramerter key and below json in Default value
86-
/// ``` json
83+
/// Add [supportedBuild] as paramerter key and below json in Default value
84+
/// ```
8785
/// {
88-
/// "key": "1.0.0"
86+
/// "supportedBuild":
87+
/// {
88+
/// "name": "<Current Build Version>","
89+
/// "versions": [ <Current Build Version> ]
90+
/// }
8991
/// } ```
9092
/// After adding app version key click on Publish Change button
9193
/// For package detail check:- https://pub.dev/packages/firebase_remote_config#-readme-tab-
92-
Future<String?> _getAppVersionFromFirebaseConfig() async {
94+
Future<Map?> _getAppVersionFromFirebaseConfig() async {
9395
final RemoteConfig remoteConfig = RemoteConfig.instance;
9496
await remoteConfig.fetchAndActivate();
9597
// await remoteConfig.activateFetched();
96-
var data = remoteConfig.getString('appVersion');
98+
var data = remoteConfig.getString('supportedBuild');
9799
if (data.isNotEmpty) {
98-
return jsonDecode(data)["key"];
100+
return jsonDecode(data) as Map;
99101
} else {
100102
cprint(
101103
"Please add your app's current version into Remote config in firebase",

lib/ui/page/common/updateApp.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import 'package:flutter_twitter_clone/widgets/newWidget/title_text.dart';
88
class UpdateApp extends StatefulWidget {
99
const UpdateApp({Key? key}) : super(key: key);
1010

11+
static Route<T> getRoute<T>() {
12+
return MaterialPageRoute(
13+
builder: (_) => UpdateApp(),
14+
);
15+
}
16+
1117
@override
1218
_UpdateAppState createState() => _UpdateAppState();
1319
}

lib/ui/page/feed/composeTweet/composeTweet.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,7 @@ class _ComposeTweetReplyPageState extends State<ComposeTweetPage> {
202202
Widget build(BuildContext context) {
203203
return Scaffold(
204204
appBar: CustomAppBar(
205-
title: customTitleText(
206-
'',
207-
),
205+
title: customTitleText(''),
208206
onActionPressed: _submitButton,
209207
isCrossButton: true,
210208
submitButtonText: widget.isTweet
@@ -589,6 +587,7 @@ class _UserList extends StatelessWidget {
589587
const BoxConstraints(minHeight: 30, maxHeight: double.infinity),
590588
child: ListView.builder(
591589
itemCount: list!.length,
590+
physics: ClampingScrollPhysics(),
592591
itemBuilder: (context, index) {
593592
return _UserTile(
594593
user: list![index],

lib/ui/page/message/chatListPage.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ class _ChatListPageState extends State<ChatListPage> {
6060
physics: const BouncingScrollPhysics(),
6161
itemCount: state.chatUserList!.length,
6262
itemBuilder: (context, index) => _userCard(
63-
searchState.userlist!.firstWhere(
64-
(x) => x.userId == state.chatUserList![index].key,
65-
orElse: () => UserModel(userName: "Unknown"),
66-
),
67-
state.chatUserList![index]),
63+
searchState.userlist!.firstWhere(
64+
(x) => x.userId == state.chatUserList![index].key,
65+
orElse: () => UserModel(userName: "Unknown"),
66+
),
67+
state.chatUserList![index],
68+
),
6869
separatorBuilder: (context, index) {
6970
return const Divider(
7071
height: 0,
@@ -120,11 +121,17 @@ class _ChatListPageState extends State<ChatListPage> {
120121
getLastMessage(lastMessage?.message) ?? '@${model.displayName}',
121122
style:
122123
TextStyles.onPrimarySubTitleText.copyWith(color: Colors.black54),
124+
maxLines: 2,
125+
overflow: TextOverflow.ellipsis,
123126
),
124127
trailing: lastMessage == null
125128
? const SizedBox.shrink()
126129
: Text(
127130
Utility.getChatTime(lastMessage.createdAt).toString(),
131+
style: TextStyles.onPrimarySubTitleText.copyWith(
132+
color: Colors.black54,
133+
fontSize: 12,
134+
),
128135
),
129136
),
130137
);

lib/ui/page/profile/profilePage.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,13 @@ class _ProfilePageState extends State<ProfilePage>
315315
late TabController _tabController;
316316

317317
void shareProfile(BuildContext context) async {
318-
var authstate = context.read<AuthState>();
318+
var authstate = context.read<ProfileState>();
319319
var user = authstate.profileUserModel;
320320
Utility.createLinkAndShare(
321321
context,
322322
"profilePage/${widget.profileId}/",
323323
socialMetaTagParameters: SocialMetaTagParameters(
324-
description: !user!.bio!.contains("Edit profile")
324+
description: !user.bio!.contains("Edit profile")
325325
? user.bio
326326
: "Checkout ${user.displayName}'s profile on Fwitter app",
327327
title: "${user.displayName} is on Fwitter app",

lib/ui/page/profile/widgets/circular_image.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ class CircularImage extends StatelessWidget {
2929
}
3030

3131
CachedNetworkImageProvider customAdvanceNetworkImage(String? path) {
32-
path ??= Constants.dummyProfilePic;
32+
if (path ==
33+
'http://www.azembelani.co.za/wp-content/uploads/2016/07/20161014_58006bf6e7079-3.png') {
34+
path = Constants.dummyProfilePic;
35+
} else {
36+
path ??= Constants.dummyProfilePic;
37+
}
3338
return CachedNetworkImageProvider(
3439
path,
40+
cacheKey: path,
3541
);
3642
}

lib/widgets/cache_image.dart

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ import 'package:flutter/material.dart';
33
import 'package:flutter_twitter_clone/helper/constant.dart';
44

55
class CacheImage extends StatelessWidget {
6-
const CacheImage({Key? key, this.path, this.fit = BoxFit.contain})
7-
: super(key: key);
6+
const CacheImage({
7+
Key? key,
8+
this.path,
9+
this.fit = BoxFit.contain,
10+
this.errorWidget,
11+
}) : super(key: key);
812
final String? path;
913
final BoxFit fit;
14+
final Widget? errorWidget;
1015

1116
Widget customNetworkImage(String? path, {BoxFit fit = BoxFit.contain}) {
1217
return CachedNetworkImage(
@@ -24,7 +29,16 @@ class CacheImage extends StatelessWidget {
2429
placeholder: (context, url) => Container(
2530
color: const Color(0xffeeeeee),
2631
),
27-
errorWidget: (context, url, error) => const Icon(Icons.error),
32+
cacheKey: path,
33+
errorWidget: (context, url, error) =>
34+
errorWidget ??
35+
Container(
36+
color: const Color(0xffeeeeee),
37+
child: Icon(
38+
Icons.error,
39+
color: Colors.grey[700],
40+
),
41+
),
2842
);
2943
}
3044

lib/widgets/customWidgets.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ Widget customIcon(
3737
);
3838
}
3939

40-
Widget customText(String? msg,
41-
{Key? key,
42-
TextStyle? style,
43-
TextAlign textAlign = TextAlign.justify,
44-
TextOverflow overflow = TextOverflow.visible,
45-
BuildContext? context,
46-
bool softwrap = true}) {
40+
Widget customText(
41+
String? msg, {
42+
Key? key,
43+
TextStyle? style,
44+
TextAlign textAlign = TextAlign.justify,
45+
TextOverflow overflow = TextOverflow.visible,
46+
BuildContext? context,
47+
bool softwrap = true,
48+
int? maxLines,
49+
}) {
4750
if (msg == null) {
4851
return const SizedBox(
4952
height: 0,
@@ -64,6 +67,7 @@ Widget customText(String? msg,
6467
overflow: overflow,
6568
softWrap: softwrap,
6669
key: key,
70+
maxLines: maxLines,
6771
);
6872
}
6973
}

0 commit comments

Comments
 (0)