Chat Fixes

merge-requests/71/head
Aamir Muhammad 3 years ago
parent d99bc6e206
commit 545c33ee4a

@ -18,7 +18,7 @@ class ChatApiClient {
Future<user.UserAutoLoginModel> getUserLoginToken() async {
Response response = await ApiClient().postJsonForResponse(
"${ApiConsts.chatServerBaseApiUrl}user/externaluserlogin",
"${ApiConsts.chatLoginTokenUrl}externaluserlogin",
{
"employeeNumber": AppState().memberInformationList!.eMPLOYEENUMBER.toString(),
"password": "FxIu26rWIKoF8n6mpbOmAjDLphzFGmpG",
@ -32,7 +32,7 @@ class ChatApiClient {
Future<List<ChatUser>?> getChatMemberFromSearch(String sName, int cUserId) async {
Response response = await ApiClient().getJsonForResponse(
"${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSearchMember}$sName/$cUserId",
"${ApiConsts.chatLoginTokenUrl}getUserWithStatusAndFavAsync/$sName/$cUserId",
token: AppState().chatDetails!.response!.token,
);
return searchUserJsonModel(response.body);
@ -44,7 +44,7 @@ class ChatApiClient {
Future<ChatUserModel> getRecentChats() async {
Response response = await ApiClient().getJsonForResponse(
"${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatRecentUrl}",
"${ApiConsts.chatRecentUrl}getchathistorybyuserid",
token: AppState().chatDetails!.response!.token,
);
return ChatUserModel.fromJson(
@ -54,7 +54,7 @@ class ChatApiClient {
Future<ChatUserModel> getFavUsers() async {
Response favRes = await ApiClient().getJsonForResponse(
"${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatFavoriteUsers}${AppState().chatDetails!.response!.id}",
"${ApiConsts.chatFavUser}getFavUserById/${AppState().chatDetails!.response!.id}",
token: AppState().chatDetails!.response!.token,
);
return ChatUserModel.fromJson(
@ -64,7 +64,7 @@ class ChatApiClient {
Future<Response> getSingleUserChatHistory({required int senderUID, required int receiverUID, required bool loadMore, bool isNewChat = false, required int paginationVal}) async {
Response response = await ApiClient().getJsonForResponse(
"${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatSingleUserHistoryUrl}/$senderUID/$receiverUID/$paginationVal",
"${ApiConsts.chatSingleUserHistoryUrl}GetUserChatHistory/$senderUID/$receiverUID/$paginationVal",
token: AppState().chatDetails!.response!.token,
);
return response;
@ -72,7 +72,7 @@ class ChatApiClient {
Future<fav.FavoriteChatUser> favUser({required int userID, required int targetUserID}) async {
Response response = await ApiClient().postJsonForResponse(
"${ApiConsts.chatServerBaseApiUrl}FavUser/addFavUser",
"${ApiConsts.chatFavUser}addFavUser",
{
"targetUserId": targetUserID,
"userId": userID,
@ -84,7 +84,7 @@ class ChatApiClient {
Future<fav.FavoriteChatUser> unFavUser({required int userID, required int targetUserID}) async {
Response response = await ApiClient().postJsonForResponse(
"${ApiConsts.chatServerBaseApiUrl}FavUser/deleteFavUser",
"${ApiConsts.chatFavUser}deleteFavUser",
{"targetUserId": targetUserID, "userId": userID},
token: AppState().chatDetails!.response!.token,
);
@ -93,7 +93,7 @@ class ChatApiClient {
}
Future<StreamedResponse> uploadMedia(String userId, File file) async {
dynamic request = MultipartRequest('POST', Uri.parse('${ApiConsts.chatServerBaseApiUrl}${ApiConsts.chatMediaImageUploadUrl}'));
dynamic request = MultipartRequest('POST', Uri.parse('${ApiConsts.chatServerBaseApiUrl}upload'));
request.fields.addAll({'userId': userId, 'fileSource': '1'});
request.files.add(await MultipartFile.fromPath('files', file.path));
request.headers.addAll({'Authorization': 'Bearer ${AppState().chatDetails!.response!.token}'});

@ -1,6 +1,6 @@
class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local server
// static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server
// static String baseUrl = "http://10.200.204.20:2801/"; // Local server
//static String baseUrl = "https://uat.hmgwebservices.com"; // UAT server
static String baseUrl = "https://hmgwebservices.com"; // Live server
static String baseUrlServices = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
@ -15,12 +15,14 @@ class ApiConsts {
//Chat
static String chatServerBaseUrl = "https://apiderichat.hmg.com/";
static String chatServerBaseApiUrl = chatServerBaseUrl + "api/";
static String chatLoginTokenUrl = chatServerBaseApiUrl + "user/";
static String chatHubConnectionUrl = chatServerBaseUrl + "ConnectionChatHub";
static String chatSearchMember = "user/getUserWithStatusAndFavAsync/";
static String chatRecentUrl = "UserChatHistory/getchathistorybyuserid"; //For a Mem
static String chatSingleUserHistoryUrl = "UserChatHistory/GetUserChatHistory";
static String chatMediaImageUploadUrl = "shared/upload";
static String chatFavoriteUsers = "FavUser/getFavUserById/";
// static String chatSearchMember = chatLoginTokenUrl + "user/";
static String chatRecentUrl = chatServerBaseApiUrl + "UserChatHistory/"; //For a Mem
static String chatSingleUserHistoryUrl = chatServerBaseApiUrl + "UserChatHistory/";
static String chatMediaImageUploadUrl = chatServerBaseApiUrl + "shared/";
static String chatFavUser = chatServerBaseApiUrl + "FavUser/";
}
class SharedPrefsConsts {

@ -7,6 +7,7 @@ import 'package:mohem_flutter_app/ui/chat/chat_detailed_screen.dart';
import 'package:mohem_flutter_app/ui/chat/chat_home.dart';
import 'package:mohem_flutter_app/ui/chat/favorite_users_screen.dart';
import 'package:mohem_flutter_app/ui/landing/dashboard_screen.dart';
import 'package:mohem_flutter_app/ui/landing/itg/its_add_screen_video_image.dart';
import 'package:mohem_flutter_app/ui/landing/itg/survey_screen.dart';
import 'package:mohem_flutter_app/ui/landing/today_attendance_screen.dart';
import 'package:mohem_flutter_app/ui/landing/today_attendance_screen2.dart';
@ -87,6 +88,7 @@ class AppRoutes {
static const String addEitScreen = "/addeitScreen";
static const String initialRoute = login;
static const String survey = "/survey";
static const String advertisement = "/advertisement";
//Work List
static const String workList = "/workList";
@ -116,8 +118,7 @@ class AppRoutes {
static const String addVacationRule = "/addVacationRule";
//Bottom Sheet
static const String attendanceDetailsBottomSheet =
"/attendanceDetailsBottomSheet";
static const String attendanceDetailsBottomSheet = "/attendanceDetailsBottomSheet";
//Profile
static const String profile = "/profile";
@ -135,8 +136,7 @@ class AppRoutes {
// Pending Transactions
static const String pendingTransactions = "/pendingTransactions";
static const String pendingTransactionsDetails =
"/pendingTransactionsDetails";
static const String pendingTransactionsDetails = "/pendingTransactionsDetails";
// Announcements
static const String announcements = "/announcements";
@ -192,6 +192,7 @@ class AppRoutes {
verifyLastLogin: (BuildContext context) => VerifyLastLoginScreen(),
dashboard: (BuildContext context) => DashboardScreen(),
survey: (BuildContext context) => SurveyScreen(),
advertisement: (BuildContext context) => ITGAdsScreen(),
subMenuScreen: (BuildContext context) => SubMenuScreen(),
newPassword: (BuildContext context) => NewPasswordScreen(),
@ -223,8 +224,7 @@ class AppRoutes {
addVacationRule: (BuildContext context) => AddVacationRuleScreen(),
//Bottom Sheet
attendanceDetailsBottomSheet: (BuildContext context) =>
AttendenceDetailsBottomSheet(),
attendanceDetailsBottomSheet: (BuildContext context) => AttendenceDetailsBottomSheet(),
//Profile
//profile: (BuildContext context) => Profile(),
@ -235,13 +235,10 @@ class AppRoutes {
familyMembers: (BuildContext context) => FamilyMembers(),
dynamicScreen: (BuildContext context) => DynamicListViewScreen(),
addDynamicInput: (BuildContext context) => DynamicInputScreen(),
addDynamicInputProfile: (BuildContext context) =>
DynamicInputScreenProfile(),
addDynamicAddressScreen: (BuildContext context) =>
DynamicInputScreenAddress(),
addDynamicInputProfile: (BuildContext context) => DynamicInputScreenProfile(),
addDynamicAddressScreen: (BuildContext context) => DynamicInputScreenAddress(),
deleteFamilyMember: (BuildContext context) =>
DeleteFamilyMember(ModalRoute.of(context)!.settings.arguments as int),
deleteFamilyMember: (BuildContext context) => DeleteFamilyMember(ModalRoute.of(context)!.settings.arguments as int),
requestSubmitScreen: (BuildContext context) => RequestSubmitScreen(),
addUpdateFamilyMember: (BuildContext context) => AddUpdateFamilyMember(),
@ -251,8 +248,7 @@ class AppRoutes {
mowadhafhiHRRequest: (BuildContext context) => MowadhafhiHRRequest(),
pendingTransactions: (BuildContext context) => PendingTransactions(),
pendingTransactionsDetails: (BuildContext context) =>
PendingTransactionsDetails(),
pendingTransactionsDetails: (BuildContext context) => PendingTransactionsDetails(),
announcements: (BuildContext context) => Announcements(),
announcementsDetails: (BuildContext context) => AnnouncementDetails(),
@ -268,8 +264,7 @@ class AppRoutes {
// Offers & Discounts
offersAndDiscounts: (BuildContext context) => OffersAndDiscountsHome(),
offersAndDiscountsDetails: (BuildContext context) =>
OffersAndDiscountsDetails(),
offersAndDiscountsDetails: (BuildContext context) => OffersAndDiscountsDetails(),
//pay slip
monthlyPaySlip: (BuildContext context) => MonthlyPaySlipScreen(),
@ -296,8 +291,7 @@ class AppRoutes {
// Marathon
marathonIntroScreen: (BuildContext context) => MarathonIntroScreen(),
marathonScreen: (BuildContext context) => MarathonScreen(),
marathonWinnerSelection: (BuildContext context) =>
MarathonWinnerSelection(),
marathonWinnerSelection: (BuildContext context) => MarathonWinnerSelection(),
marathonWinnerScreen: (BuildContext context) => WinnerScreen(),
};
}

@ -241,7 +241,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
void chatNotDelivered(List<Object?>? args) {
dynamic items = args!.toList();
// logger.d(items);
logger.d(items);
for (dynamic item in items[0]) {
searchedChats!.forEach(
(ChatUser element) {
@ -292,7 +292,6 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
data.first.currentUserId = temp.first.targetUserId;
data.first.currentUserName = temp.first.targetUserName;
}
logger.d(jsonEncode(data));
userChatHistory.insert(0, data.first);
var list = [
{
@ -601,6 +600,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
}
void clearSelections() {
print("Hereee i am ");
searchedChats = pChatHistory;
search.clear();
isChatScreenActive = false;
@ -609,6 +609,7 @@ class ChatProviderModel with ChangeNotifier, DiagnosticableTreeMixin {
isFileSelected = false;
repliedMsg = [];
sFileType = "";
isMsgReply = false;
notifyListeners();
}

@ -155,6 +155,28 @@ class ChatBubble extends StatelessWidget {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (isReplied)
ClipRRect(
borderRadius: BorderRadius.circular(
5.0,
),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
border: Border(
left: BorderSide(width: 6, color: isCurrentUser ? MyColors.gradiantStartColor : MyColors.white),
),
color: isCurrentUser ? MyColors.black.withOpacity(0.10) : MyColors.black.withOpacity(0.30),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
(userName).toText12(color: MyColors.gradiantStartColor, isBold: false).paddingOnly(right: 5, top: 5, bottom: 0, left: 5),
replyText.toText10(color: isCurrentUser ? MyColors.grey71Color : MyColors.white.withOpacity(0.5), isBold: false, maxlines: 4).paddingOnly(right: 5, top: 5, bottom: 8, left: 5),
],
).expanded,
),
).paddingOnly(right: 5, bottom: 7),
(text).toText12(),
Align(
alignment: Alignment.centerRight,
@ -193,6 +215,28 @@ class ChatBubble extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (isReplied)
ClipRRect(
borderRadius: BorderRadius.circular(
5.0,
),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
border: Border(
left: BorderSide(width: 6, color: isCurrentUser ? MyColors.gradiantStartColor : MyColors.white),
),
color: isCurrentUser ? MyColors.black.withOpacity(0.10) : MyColors.black.withOpacity(0.30),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
(userName).toText12(color: MyColors.gradiantStartColor, isBold: false).paddingOnly(right: 5, top: 5, bottom: 0, left: 5),
replyText.toText10(color: isCurrentUser ? MyColors.grey71Color : MyColors.white.withOpacity(0.5), isBold: false, maxlines: 4).paddingOnly(right: 5, top: 5, bottom: 8, left: 5),
],
).expanded,
),
).paddingOnly(right: 5, bottom: 7),
(text).toText12(color: Colors.white),
Align(
alignment: Alignment.centerRight,

@ -19,6 +19,7 @@ import 'package:mohem_flutter_app/widgets/shimmer/dashboard_shimmer_widget.dart'
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:signalr_netcore/signalr_client.dart';
import 'package:sizer/sizer.dart';
import 'package:swipe_to/swipe_to.dart';
class ChatDetailScreen extends StatefulWidget {
@ -74,14 +75,16 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
image: userDetails["targetUser"].image,
actions: [
IconButton(
constraints: const BoxConstraints(),
onPressed: () {
makeCall(callType: "AUDIO", con: hubConnection);
// makeCall(callType: "AUDIO", con: hubConnection);
},
icon: SvgPicture.asset("assets/icons/chat/call.svg", width: 22, height: 22),
),
IconButton(
constraints: const BoxConstraints(),
onPressed: () {
makeCall(callType: "VIDEO", con: hubConnection);
//makeCall(callType: "VIDEO", con: hubConnection);
},
icon: SvgPicture.asset("assets/icons/chat/video_call.svg", width: 20, height: 20),
),
@ -176,63 +179,43 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
contentPadding: EdgeInsets.only(left: m.sFileType.isNotEmpty ? 10 : 20, right: m.sFileType.isNotEmpty ? 0 : 5, top: 20, bottom: 20),
filled: true,
fillColor: MyColors.white,
contentPadding: EdgeInsets.only(
left: 21,
top: 20,
bottom: 20,
),
prefixIconConstraints: BoxConstraints(),
prefixIcon: m.sFileType.isNotEmpty ? SvgPicture.asset(m.getType(m.sFileType), height: 30, width: 22, alignment: Alignment.center, fit: BoxFit.cover) : null,
prefixIcon: m.sFileType.isNotEmpty
? SvgPicture.asset(m.getType(m.sFileType), height: 30, width: 22, alignment: Alignment.center, fit: BoxFit.cover).paddingOnly(left: 21, right: 15)
: null,
suffixIcon: SizedBox(
width: 96,
width: 100,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center, // added line
children: <Widget>[
if (m.sFileType.isNotEmpty)
IconButton(
padding: EdgeInsets.zero,
alignment: Alignment.centerRight,
icon: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Container(
decoration: const BoxDecoration(
color: MyColors.redA3Color,
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: const Icon(Icons.close, size: 15, color: MyColors.white),
),
("Clear").toText11(color: MyColors.redA3Color).paddingOnly(left: 4),
],
),
onPressed: () async {
m.removeAttachment();
},
),
Row(
children: <Widget>[
const Icon(Icons.cancel, size: 15, color: MyColors.redA3Color).paddingOnly(right: 5),
("Clear").toText11(color: MyColors.redA3Color, isUnderLine: true).paddingOnly(left: 0),
],
).onPress(() => m.removeAttachment()).paddingOnly(right: 25),
if (m.sFileType.isEmpty)
RotationTransition(
turns: const AlwaysStoppedAnimation(45 / 360),
child: IconButton(
padding: EdgeInsets.zero,
alignment: Alignment.topRight,
icon: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor),
onPressed: () async {
m.selectImageToUpload(context);
},
child: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor).onPress(
() => m.selectImageToUpload(context),
),
),
IconButton(
alignment: Alignment.centerRight,
padding: EdgeInsets.zero,
icon: SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26),
onPressed: () {
m.sendChatMessage(userDetails["targetUser"].id, userDetails["targetUser"].userName, context);
},
)
).paddingOnly(right: 25),
SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26).onPress(
() => m.sendChatMessage(userDetails["targetUser"].id, userDetails["targetUser"].userName, context),
),
],
),
).paddingOnly(right: 20),
).paddingOnly(right: 21),
),
),
],

@ -162,6 +162,7 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> {
),
Flexible(
child: IconButton(
constraints: BoxConstraints(),
alignment: Alignment.centerRight,
padding: EdgeInsets.zero,
icon: Icon(

@ -100,39 +100,44 @@ class _DashboardScreenState extends State<DashboardScreen> {
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldState,
appBar: AppBar(
actions: [
IconButton(
onPressed: () {
data.getITGNotification().then((val) {
if (val!.result!.data != null) {
if (val.result!.data!.notificationType == "Survey") {
Navigator.pushNamed(context, AppRoutes.survey, arguments: val.result!.data);
} else {
DashboardApiClient().getAdvertisementDetail(val.result!.data!.notificationMasterId ?? "").then(
(value) {
if (value!.mohemmItgResponseItem!.statusCode == 200) {
if (value.mohemmItgResponseItem!.result!.data != null) {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => ITGAdsScreen(
addMasterId: val.result!.data!.notificationMasterId!,
advertisement: value.mohemmItgResponseItem!.result!.data!.advertisement!,
),
),
);
}
}
},
);
}
}
});
},
icon: Icon(Icons.add))
],
),
// appBar: AppBar(
// actions: [
// IconButton(
// onPressed: () {
// data.getITGNotification().then((val) {
// if (val!.result!.data != null) {
// if (val.result!.data!.notificationType == "Survey") {
// Navigator.pushNamed(context, AppRoutes.survey, arguments: val.result!.data);
// } else {
// DashboardApiClient().getAdvertisementDetail(val.result!.data!.notificationMasterId ?? "").then(
// (value) {
// if (value!.mohemmItgResponseItem!.statusCode == 200) {
// if (value.mohemmItgResponseItem!.result!.data != null) {
// Navigator.pushNamed(context, AppRoutes.advertisement, arguments: {
// "masterId": val.result!.data!.notificationMasterId,
// "advertisement": value.mohemmItgResponseItem!.result!.data!.advertisement,
// });
//
// // Navigator.push(
// // context,
// // MaterialPageRoute(
// // builder: (BuildContext context) => ITGAdsScreen(
// // addMasterId: val.result!.data!.notificationMasterId!,
// // advertisement: value.mohemmItgResponseItem!.result!.data!.advertisement!,
// // ),
// // ),
// // );
// }
// }
// },
// );
// }
// }
// });
// },
// icon: Icon(Icons.add))
// ],
// ),
body: Column(
children: [
Row(

@ -12,10 +12,7 @@ import 'package:path_provider/path_provider.dart';
import 'package:video_player/video_player.dart';
class ITGAdsScreen extends StatefulWidget {
final String addMasterId;
final ads.Advertisement advertisement;
const ITGAdsScreen({required this.addMasterId, required this.advertisement});
const ITGAdsScreen({Key? key}) : super(key: key);
@override
_ITGAdsScreenState createState() => _ITGAdsScreenState();
@ -29,10 +26,13 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
bool isImage = false;
String ext = '';
late File imageFile;
ads.Advertisement? advertisementData;
dynamic data;
String? masterID;
void checkFileType() async {
String? rFile = widget.advertisement!.viewAttachFileColl!.first.base64String;
String? rFileExt = widget.advertisement!.viewAttachFileColl!.first.fileName;
String? rFile = advertisementData!.viewAttachFileColl!.first.base64String;
String? rFileExt = advertisementData!.viewAttachFileColl!.first.fileName;
ext = "." + rFileExt!.split(".").last.toLowerCase();
if (ext == ".png" || ext == ".jpg" || ext == ".jpeg" || ext == ".gif") {
await processImage(rFile!);
@ -42,6 +42,7 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
_futureController = createVideoPlayer(rFile!);
}
setState(() {});
initTimer();
}
Future processImage(String encodedBytes) async {
@ -72,18 +73,10 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
}
}
@override
void initState() {
checkFileType();
initTimer();
super.initState();
}
void initTimer() {
Future.delayed(const Duration(seconds: 5), () {
setState(() {
skip = true;
});
skip = true;
setState(() {});
});
}
@ -95,6 +88,12 @@ class _ITGAdsScreenState extends State<ITGAdsScreen> {
@override
Widget build(BuildContext context) {
data = ModalRoute.of(context)!.settings.arguments;
if (advertisementData == null) advertisementData = data["advertisement"] as ads.Advertisement;
if (masterID == null) masterID = data["masterId"];
if (advertisementData != null) {
checkFileType();
}
double height = MediaQuery.of(context).size.height * .25;
return Scaffold(
body: Column(

Loading…
Cancel
Save