Merge branch 'development_aamir' into 'master'

App Bar Online / Offline  & Fixes

See merge request Cloud_Solution/mohemm-flutter-app!127
merge-requests/128/merge
Sikander Saleem 3 years ago
commit 438217adcb

@ -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,6 +954,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
}
}
}
if (fromSearch) {
for (ChatUser user in favUsersList) {
if (user.id == targetUserID) {
user.userLocalDownlaodedImage = null;
@ -963,8 +962,8 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
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,17 +11,11 @@ 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(
title: Consumer<ChatProviderModel>(builder: (BuildContext cxt, ChatProviderModel data, Widget? child) {
return Row(
children: [
GestureDetector(
behavior: HitTestBehavior.opaque,
@ -31,14 +25,46 @@ AppBar ChatAppBarWidget(BuildContext 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 (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!),
),
),
),
if (image != null) 14.width,
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(
@ -47,20 +73,13 @@ AppBar ChatAppBarWidget(BuildContext context,
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();
}
},
),
if (chatUser!.isTyping!) ("Typing ...").toText10(color: MyColors.textMixColor) else const SizedBox(),
],
),
)
],
),
);
}),
centerTitle: false,
elevation: 0,
backgroundColor: Colors.white,

Loading…
Cancel
Save