App Bar online / Offline & Fixes

merge-requests/127/head
Aamir Muhammad 3 years ago
parent d24fa6b61b
commit 5028a3b860

@ -175,9 +175,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
if (response.statusCode == 204) { if (response.statusCode == 204) {
if (isNewChat) { if (isNewChat) {
userChatHistory = []; userChatHistory = [];
} else if (loadMore) { } else if (loadMore) {}
}
} else { } else {
if (loadMore) { if (loadMore) {
List<SingleUserChatModel> temp = getSingleUserChatModel(response.body).reversed.toList(); List<SingleUserChatModel> temp = getSingleUserChatModel(response.body).reversed.toList();
@ -933,7 +931,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
return f.format(data); return f.format(data);
} }
Future<void> favoriteUser({required int userID, required int targetUserID}) async { Future<void> favoriteUser({required int userID, required int targetUserID, required bool fromSearch}) async {
fav.FavoriteChatUser favoriteChatUser = await ChatApiClient().favUser(userID: userID, targetUserID: targetUserID); fav.FavoriteChatUser favoriteChatUser = await ChatApiClient().favUser(userID: userID, targetUserID: targetUserID);
if (favoriteChatUser.response != null) { if (favoriteChatUser.response != null) {
for (ChatUser user in searchedChats!) { for (ChatUser user in searchedChats!) {
@ -956,15 +954,16 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
} }
} }
} }
for (ChatUser user in favUsersList) { if (fromSearch) {
if (user.id == targetUserID) { for (ChatUser user in favUsersList) {
user.userLocalDownlaodedImage = null; if (user.id == targetUserID) {
user.isImageLoading = false; user.userLocalDownlaodedImage = null;
user.isImageLoaded = false; user.isImageLoading = false;
user.isImageLoaded = false;
}
} }
} }
notifyListeners(); notifyListeners();
} }
Future<void> unFavoriteUser({required int userID, required int targetUserID}) async { Future<void> unFavoriteUser({required int userID, required int targetUserID}) async {

@ -87,7 +87,6 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
context, context,
title: params!.chatUser!.userName.toString().replaceAll(".", " ").capitalizeFirstofEach, title: params!.chatUser!.userName.toString().replaceAll(".", " ").capitalizeFirstofEach,
showHomeButton: false, showHomeButton: false,
image: params!.chatUser!.image == null || params!.chatUser!.image.isEmpty ? null : params!.chatUser!.image,
showTyping: true, showTyping: true,
chatUser: params!.chatUser, chatUser: params!.chatUser,
actions: [ actions: [

@ -179,6 +179,7 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> {
m.favoriteUser( m.favoriteUser(
userID: AppState().chatDetails!.response!.id!, userID: AppState().chatDetails!.response!.id!,
targetUserID: m.searchedChats![index].id!, targetUserID: m.searchedChats![index].id!,
fromSearch: false
); );
} else if (m.searchedChats![index].isFav == true) { } else if (m.searchedChats![index].isFav == true) {
m.unFavoriteUser( m.unFavoriteUser(
@ -189,6 +190,7 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> {
m.favoriteUser( m.favoriteUser(
userID: AppState().chatDetails!.response!.id!, userID: AppState().chatDetails!.response!.id!,
targetUserID: m.searchedChats![index].id!, targetUserID: m.searchedChats![index].id!,
fromSearch: false
); );
} }
}, },

@ -312,6 +312,7 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
.favoriteUser( .favoriteUser(
userID: AppState().chatDetails!.response!.id!, userID: AppState().chatDetails!.response!.id!,
targetUserID: provider.chatUsersList![index].id!, targetUserID: provider.chatUsersList![index].id!,
fromSearch: true
) )
.then((value) { .then((value) {
setState(() {}); setState(() {});
@ -330,6 +331,7 @@ class _SearchEmployeeBottomSheetState extends State<SearchEmployeeBottomSheet> {
.favoriteUser( .favoriteUser(
userID: AppState().chatDetails!.response!.id!, userID: AppState().chatDetails!.response!.id!,
targetUserID: provider.chatUsersList![index].id!, targetUserID: provider.chatUsersList![index].id!,
fromSearch: true
) )
.then((value) { .then((value) {
setState(() {}); setState(() {});

@ -11,56 +11,75 @@ import 'package:mohem_flutter_app/widgets/circular_avatar.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
AppBar ChatAppBarWidget(BuildContext context, AppBar ChatAppBarWidget(BuildContext context,
{required String title, {required String title, bool showHomeButton = true, ChatUser? chatUser, bool showTyping = false, List<Widget>? actions, void Function()? onHomeTapped, void Function()? onBackTapped}) {
bool showHomeButton = true,
String? image,
ChatUser? chatUser,
bool showTyping = false,
List<Widget>? actions,
void Function()? onHomeTapped,
void Function()? onBackTapped}) {
return AppBar( return AppBar(
leadingWidth: 0, leadingWidth: 0,
title: Row( title: Consumer<ChatProviderModel>(builder: (BuildContext cxt, ChatProviderModel data, Widget? child) {
children: [ return Row(
GestureDetector( children: [
behavior: HitTestBehavior.opaque, GestureDetector(
onTap: Feedback.wrapForTap(() { behavior: HitTestBehavior.opaque,
(onBackTapped == null ? Navigator.maybePop(context) : onBackTapped()); onTap: Feedback.wrapForTap(() {
}, context), (onBackTapped == null ? Navigator.maybePop(context) : onBackTapped());
child: const Icon(Icons.arrow_back_ios, color: MyColors.darkIconColor), }, context),
), child: const Icon(Icons.arrow_back_ios, color: MyColors.darkIconColor),
4.width,
if (image != null)
CircularAvatar(
url: image,
height: 40,
width: 40,
isImageBase64: true,
), ),
if (image != null) 14.width, 4.width,
SizedBox( if (chatUser != null)
height: 40, Stack(
child: Column( children: <Widget>[
crossAxisAlignment: CrossAxisAlignment.start, if (chatUser.isImageLoading!)
mainAxisAlignment: MainAxisAlignment.start, const SizedBox(
children: [ height: 48,
title.toText20(color: MyColors.darkTextColor, isBold: true).expanded, width: 48,
if (showTyping) ).toShimmer().circle(30),
Consumer<ChatProviderModel>( if (!chatUser.isImageLoading! && chatUser.userLocalDownlaodedImage == null)
builder: (BuildContext cxt, ChatProviderModel data, Widget? child) { SvgPicture.asset(
if (chatUser!.isTyping!) { "assets/images/user.svg",
return ("Typing ...").toText10(color: MyColors.textMixColor); height: 48,
} else { width: 48,
return const SizedBox(); ),
} if (!chatUser.isImageLoading! && chatUser.userLocalDownlaodedImage != null)
}, Container(
), width: 48.0,
], height: 48.0,
), decoration: BoxDecoration(
) shape: BoxShape.circle,
], image: DecorationImage(
), fit: BoxFit.cover,
image: FileImage(chatUser.userLocalDownlaodedImage!),
),
),
),
Positioned(
right: 5,
bottom: 1,
child: Container(
width: 10,
height: 10,
decoration: BoxDecoration(
color: chatUser.userStatus == 1 ? MyColors.green2DColor : Colors.red,
),
).circle(10),
)
],
),
if (chatUser != null) 14.width,
SizedBox(
height: 40,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
title.toText20(color: MyColors.darkTextColor, isBold: true).expanded,
if (showTyping)
if (chatUser!.isTyping!) ("Typing ...").toText10(color: MyColors.textMixColor) else const SizedBox(),
],
),
)
],
);
}),
centerTitle: false, centerTitle: false,
elevation: 0, elevation: 0,
backgroundColor: Colors.white, backgroundColor: Colors.white,

Loading…
Cancel
Save