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

@ -1,6 +1,6 @@
class ApiConsts { class ApiConsts {
//static String baseUrl = "http://10.200.204.20:2801/"; // Local 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://uat.hmgwebservices.com"; // UAT server
static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrl = "https://hmgwebservices.com"; // Live server
static String baseUrlServices = baseUrl + "/Services/"; // server static String baseUrlServices = baseUrl + "/Services/"; // server
// static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server
@ -15,12 +15,14 @@ class ApiConsts {
//Chat //Chat
static String chatServerBaseUrl = "https://apiderichat.hmg.com/"; static String chatServerBaseUrl = "https://apiderichat.hmg.com/";
static String chatServerBaseApiUrl = chatServerBaseUrl + "api/"; static String chatServerBaseApiUrl = chatServerBaseUrl + "api/";
static String chatLoginTokenUrl = chatServerBaseApiUrl + "user/";
static String chatHubConnectionUrl = chatServerBaseUrl + "ConnectionChatHub"; static String chatHubConnectionUrl = chatServerBaseUrl + "ConnectionChatHub";
static String chatSearchMember = "user/getUserWithStatusAndFavAsync/";
static String chatRecentUrl = "UserChatHistory/getchathistorybyuserid"; //For a Mem // static String chatSearchMember = chatLoginTokenUrl + "user/";
static String chatSingleUserHistoryUrl = "UserChatHistory/GetUserChatHistory"; static String chatRecentUrl = chatServerBaseApiUrl + "UserChatHistory/"; //For a Mem
static String chatMediaImageUploadUrl = "shared/upload"; static String chatSingleUserHistoryUrl = chatServerBaseApiUrl + "UserChatHistory/";
static String chatFavoriteUsers = "FavUser/getFavUserById/"; static String chatMediaImageUploadUrl = chatServerBaseApiUrl + "shared/";
static String chatFavUser = chatServerBaseApiUrl + "FavUser/";
} }
class SharedPrefsConsts { 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/chat_home.dart';
import 'package:mohem_flutter_app/ui/chat/favorite_users_screen.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/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/itg/survey_screen.dart';
import 'package:mohem_flutter_app/ui/landing/today_attendance_screen.dart'; import 'package:mohem_flutter_app/ui/landing/today_attendance_screen.dart';
import 'package:mohem_flutter_app/ui/landing/today_attendance_screen2.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 addEitScreen = "/addeitScreen";
static const String initialRoute = login; static const String initialRoute = login;
static const String survey = "/survey"; static const String survey = "/survey";
static const String advertisement = "/advertisement";
//Work List //Work List
static const String workList = "/workList"; static const String workList = "/workList";
@ -116,8 +118,7 @@ class AppRoutes {
static const String addVacationRule = "/addVacationRule"; static const String addVacationRule = "/addVacationRule";
//Bottom Sheet //Bottom Sheet
static const String attendanceDetailsBottomSheet = static const String attendanceDetailsBottomSheet = "/attendanceDetailsBottomSheet";
"/attendanceDetailsBottomSheet";
//Profile //Profile
static const String profile = "/profile"; static const String profile = "/profile";
@ -135,8 +136,7 @@ class AppRoutes {
// Pending Transactions // Pending Transactions
static const String pendingTransactions = "/pendingTransactions"; static const String pendingTransactions = "/pendingTransactions";
static const String pendingTransactionsDetails = static const String pendingTransactionsDetails = "/pendingTransactionsDetails";
"/pendingTransactionsDetails";
// Announcements // Announcements
static const String announcements = "/announcements"; static const String announcements = "/announcements";
@ -192,6 +192,7 @@ class AppRoutes {
verifyLastLogin: (BuildContext context) => VerifyLastLoginScreen(), verifyLastLogin: (BuildContext context) => VerifyLastLoginScreen(),
dashboard: (BuildContext context) => DashboardScreen(), dashboard: (BuildContext context) => DashboardScreen(),
survey: (BuildContext context) => SurveyScreen(), survey: (BuildContext context) => SurveyScreen(),
advertisement: (BuildContext context) => ITGAdsScreen(),
subMenuScreen: (BuildContext context) => SubMenuScreen(), subMenuScreen: (BuildContext context) => SubMenuScreen(),
newPassword: (BuildContext context) => NewPasswordScreen(), newPassword: (BuildContext context) => NewPasswordScreen(),
@ -223,8 +224,7 @@ class AppRoutes {
addVacationRule: (BuildContext context) => AddVacationRuleScreen(), addVacationRule: (BuildContext context) => AddVacationRuleScreen(),
//Bottom Sheet //Bottom Sheet
attendanceDetailsBottomSheet: (BuildContext context) => attendanceDetailsBottomSheet: (BuildContext context) => AttendenceDetailsBottomSheet(),
AttendenceDetailsBottomSheet(),
//Profile //Profile
//profile: (BuildContext context) => Profile(), //profile: (BuildContext context) => Profile(),
@ -235,13 +235,10 @@ class AppRoutes {
familyMembers: (BuildContext context) => FamilyMembers(), familyMembers: (BuildContext context) => FamilyMembers(),
dynamicScreen: (BuildContext context) => DynamicListViewScreen(), dynamicScreen: (BuildContext context) => DynamicListViewScreen(),
addDynamicInput: (BuildContext context) => DynamicInputScreen(), addDynamicInput: (BuildContext context) => DynamicInputScreen(),
addDynamicInputProfile: (BuildContext context) => addDynamicInputProfile: (BuildContext context) => DynamicInputScreenProfile(),
DynamicInputScreenProfile(), addDynamicAddressScreen: (BuildContext context) => DynamicInputScreenAddress(),
addDynamicAddressScreen: (BuildContext context) =>
DynamicInputScreenAddress(),
deleteFamilyMember: (BuildContext context) => deleteFamilyMember: (BuildContext context) => DeleteFamilyMember(ModalRoute.of(context)!.settings.arguments as int),
DeleteFamilyMember(ModalRoute.of(context)!.settings.arguments as int),
requestSubmitScreen: (BuildContext context) => RequestSubmitScreen(), requestSubmitScreen: (BuildContext context) => RequestSubmitScreen(),
addUpdateFamilyMember: (BuildContext context) => AddUpdateFamilyMember(), addUpdateFamilyMember: (BuildContext context) => AddUpdateFamilyMember(),
@ -251,8 +248,7 @@ class AppRoutes {
mowadhafhiHRRequest: (BuildContext context) => MowadhafhiHRRequest(), mowadhafhiHRRequest: (BuildContext context) => MowadhafhiHRRequest(),
pendingTransactions: (BuildContext context) => PendingTransactions(), pendingTransactions: (BuildContext context) => PendingTransactions(),
pendingTransactionsDetails: (BuildContext context) => pendingTransactionsDetails: (BuildContext context) => PendingTransactionsDetails(),
PendingTransactionsDetails(),
announcements: (BuildContext context) => Announcements(), announcements: (BuildContext context) => Announcements(),
announcementsDetails: (BuildContext context) => AnnouncementDetails(), announcementsDetails: (BuildContext context) => AnnouncementDetails(),
@ -268,8 +264,7 @@ class AppRoutes {
// Offers & Discounts // Offers & Discounts
offersAndDiscounts: (BuildContext context) => OffersAndDiscountsHome(), offersAndDiscounts: (BuildContext context) => OffersAndDiscountsHome(),
offersAndDiscountsDetails: (BuildContext context) => offersAndDiscountsDetails: (BuildContext context) => OffersAndDiscountsDetails(),
OffersAndDiscountsDetails(),
//pay slip //pay slip
monthlyPaySlip: (BuildContext context) => MonthlyPaySlipScreen(), monthlyPaySlip: (BuildContext context) => MonthlyPaySlipScreen(),
@ -296,8 +291,7 @@ class AppRoutes {
// Marathon // Marathon
marathonIntroScreen: (BuildContext context) => MarathonIntroScreen(), marathonIntroScreen: (BuildContext context) => MarathonIntroScreen(),
marathonScreen: (BuildContext context) => MarathonScreen(), marathonScreen: (BuildContext context) => MarathonScreen(),
marathonWinnerSelection: (BuildContext context) => marathonWinnerSelection: (BuildContext context) => MarathonWinnerSelection(),
MarathonWinnerSelection(),
marathonWinnerScreen: (BuildContext context) => WinnerScreen(), marathonWinnerScreen: (BuildContext context) => WinnerScreen(),
}; };
} }

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

@ -155,6 +155,28 @@ class ChatBubble extends StatelessWidget {
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ 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(), (text).toText12(),
Align( Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
@ -193,6 +215,28 @@ class ChatBubble extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ 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), (text).toText12(color: Colors.white),
Align( Align(
alignment: Alignment.centerRight, 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:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:signalr_netcore/signalr_client.dart'; import 'package:signalr_netcore/signalr_client.dart';
import 'package:sizer/sizer.dart';
import 'package:swipe_to/swipe_to.dart'; import 'package:swipe_to/swipe_to.dart';
class ChatDetailScreen extends StatefulWidget { class ChatDetailScreen extends StatefulWidget {
@ -74,14 +75,16 @@ class _ChatDetailScreenState extends State<ChatDetailScreen> {
image: userDetails["targetUser"].image, image: userDetails["targetUser"].image,
actions: [ actions: [
IconButton( IconButton(
constraints: const BoxConstraints(),
onPressed: () { onPressed: () {
makeCall(callType: "AUDIO", con: hubConnection); // makeCall(callType: "AUDIO", con: hubConnection);
}, },
icon: SvgPicture.asset("assets/icons/chat/call.svg", width: 22, height: 22), icon: SvgPicture.asset("assets/icons/chat/call.svg", width: 22, height: 22),
), ),
IconButton( IconButton(
constraints: const BoxConstraints(),
onPressed: () { onPressed: () {
makeCall(callType: "VIDEO", con: hubConnection); //makeCall(callType: "VIDEO", con: hubConnection);
}, },
icon: SvgPicture.asset("assets/icons/chat/video_call.svg", width: 20, height: 20), 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, enabledBorder: InputBorder.none,
errorBorder: InputBorder.none, errorBorder: InputBorder.none,
disabledBorder: 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(), 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( suffixIcon: SizedBox(
width: 96, width: 100,
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center, // added line crossAxisAlignment: CrossAxisAlignment.center, // added line
children: <Widget>[ children: <Widget>[
if (m.sFileType.isNotEmpty) if (m.sFileType.isNotEmpty)
IconButton( Row(
padding: EdgeInsets.zero, children: <Widget>[
alignment: Alignment.centerRight, const Icon(Icons.cancel, size: 15, color: MyColors.redA3Color).paddingOnly(right: 5),
icon: Row( ("Clear").toText11(color: MyColors.redA3Color, isUnderLine: true).paddingOnly(left: 0),
crossAxisAlignment: CrossAxisAlignment.start, ],
mainAxisAlignment: MainAxisAlignment.end, ).onPress(() => m.removeAttachment()).paddingOnly(right: 25),
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();
},
),
if (m.sFileType.isEmpty) if (m.sFileType.isEmpty)
RotationTransition( RotationTransition(
turns: const AlwaysStoppedAnimation(45 / 360), turns: const AlwaysStoppedAnimation(45 / 360),
child: IconButton( child: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor).onPress(
padding: EdgeInsets.zero, () => m.selectImageToUpload(context),
alignment: Alignment.topRight,
icon: const Icon(Icons.attach_file_rounded, size: 26, color: MyColors.grey3AColor),
onPressed: () async {
m.selectImageToUpload(context);
},
), ),
), ).paddingOnly(right: 25),
IconButton( SvgPicture.asset("assets/icons/chat/chat_send_icon.svg", height: 26, width: 26).onPress(
alignment: Alignment.centerRight, () => m.sendChatMessage(userDetails["targetUser"].id, userDetails["targetUser"].userName, context),
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: 20), ).paddingOnly(right: 21),
), ),
), ),
], ],

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

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

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

Loading…
Cancel
Save