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 (isNewChat) {
userChatHistory = [];
} else if (loadMore) {
}
} else if (loadMore) {}
} else {
if (loadMore) {
List<SingleUserChatModel> temp = getSingleUserChatModel(response.body).reversed.toList();
@ -933,7 +931,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
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);
if (favoriteChatUser.response != null) {
for (ChatUser user in searchedChats!) {
@ -956,15 +954,16 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
}
}
}
for (ChatUser user in favUsersList) {
if (user.id == targetUserID) {
user.userLocalDownlaodedImage = null;
user.isImageLoading = false;
user.isImageLoaded = false;
if (fromSearch) {
for (ChatUser user in favUsersList) {
if (user.id == targetUserID) {
user.userLocalDownlaodedImage = null;
user.isImageLoading = false;
user.isImageLoaded = false;
}
}
}
notifyListeners();
}
Future<void> unFavoriteUser({required int userID, required int targetUserID}) async {

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

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

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

@ -11,56 +11,75 @@ import 'package:mohem_flutter_app/widgets/circular_avatar.dart';
import 'package:provider/provider.dart';
AppBar ChatAppBarWidget(BuildContext context,
{required String title,
bool showHomeButton = true,
String? image,
ChatUser? chatUser,
bool showTyping = false,
List<Widget>? actions,
void Function()? onHomeTapped,
void Function()? onBackTapped}) {
{required String title, bool showHomeButton = true, ChatUser? chatUser, bool showTyping = false, List<Widget>? actions, void Function()? onHomeTapped, void Function()? onBackTapped}) {
return AppBar(
leadingWidth: 0,
title: Row(
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: Feedback.wrapForTap(() {
(onBackTapped == null ? Navigator.maybePop(context) : onBackTapped());
}, 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,
title: Consumer<ChatProviderModel>(builder: (BuildContext cxt, ChatProviderModel data, Widget? child) {
return Row(
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: Feedback.wrapForTap(() {
(onBackTapped == null ? Navigator.maybePop(context) : onBackTapped());
}, context),
child: const Icon(Icons.arrow_back_ios, color: MyColors.darkIconColor),
),
if (image != 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)
Consumer<ChatProviderModel>(
builder: (BuildContext cxt, ChatProviderModel data, Widget? child) {
if (chatUser!.isTyping!) {
return ("Typing ...").toText10(color: MyColors.textMixColor);
} else {
return const SizedBox();
}
},
),
],
),
)
],
),
4.width,
if (chatUser != null)
Stack(
children: <Widget>[
if (chatUser.isImageLoading!)
const SizedBox(
height: 48,
width: 48,
).toShimmer().circle(30),
if (!chatUser.isImageLoading! && chatUser.userLocalDownlaodedImage == null)
SvgPicture.asset(
"assets/images/user.svg",
height: 48,
width: 48,
),
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,
elevation: 0,
backgroundColor: Colors.white,

Loading…
Cancel
Save