Skip to content

Commit

Permalink
Merge pull request #115 from john-safwat/Development
Browse files Browse the repository at this point in the history
update
  • Loading branch information
john-safwat authored Jun 23, 2024
2 parents 7bc0b23 + db2638f commit 541ffa6
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 37 deletions.
6 changes: 4 additions & 2 deletions lib/Core/l10n/app_ar.arb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@
"tripwirePints" : "نقاط Tripwire",
"timer" : "المؤقت",
"timerInfo" : "يقوم هذا المؤقت بتعيين الحد الأدنى من الوقت بين إشعارات Tripwire",
"tripwireUpdated" : "تم تحديث إعدادات Tripwire بنجاح"

"tripwireUpdated" : "تم تحديث إعدادات Tripwire بنجاح",
"youHaveBlockedThisContact" : "لقد قمت بحظر جهة الاتصال هذه",
"unBlock" : "الغاء الحظر",
"youNoLongerCanSendMessages": "لم يعد بإمكانك إرسال رسائل إلى هذا الشخص"
}
5 changes: 4 additions & 1 deletion lib/Core/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,8 @@
"tripwirePints" : "Tripwire Points",
"timer" : "Timer",
"timerInfo" : "This Timer Set The Minimum Time Between Notifications of Tripwire",
"tripwireUpdated" : "Tripwire Settings Updated Successfully"
"tripwireUpdated" : "Tripwire Settings Updated Successfully",
"youHaveBlockedThisContact" : "You Have Blocked This Contact",
"unBlock" : "UnBlock",
"youNoLongerCanSendMessages": "You No Longer Can Send Messages to This Person"
}
183 changes: 151 additions & 32 deletions lib/Presentation/UI/ContactChat/ContactChatView.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,40 +152,160 @@ class _ContactChatViewState
}
},
)),
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10.0, vertical: 15),
child: Row(
children: [
Expanded(
child: TextFormField(
controller: viewModel.controller,
autovalidateMode: AutovalidateMode.onUserInteraction,
cursorColor: Theme.of(context).primaryColor,
decoration: InputDecoration(
suffixIcon: InkWell(
onTap: () => viewModel.sendMessage(),
child: Icon(
EvaIcons.paperPlane,
size: 25,
color: Theme.of(context).primaryColor,
),
),
prefixIcon: InkWell(
onTap: () => value.showModalBottomSheet(),
child: const Icon(
Icons.image,
size: 25,
),
),
hintText: value.local!.sendMessage,
if (viewModel.contact.isBlockedByFirstUser &&
(viewModel.appConfigProvider!.user!.uid ==
viewModel.contact.firstUserUID)) ...[
Container(
padding: const EdgeInsets.all(20),
margin: const EdgeInsets.all(10),
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(15)),
child: Column(
children: [
Text(
viewModel.local!.youHaveBlockedThisContact,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
color: Theme.of(context)
.scaffoldBackgroundColor),
),
TextButton(
onPressed: () {
viewModel.unBlock();
},
child: Text(
viewModel.local!.unBlock,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
color: Theme.of(context)
.scaffoldBackgroundColor,
decoration: TextDecoration.underline),
))
],
),
)
]
else if (viewModel.contact.isBlockedBySecondUser &&
(viewModel.appConfigProvider!.user!.uid ==
viewModel.contact.secondUserUID)) ...[
Container(
padding: const EdgeInsets.all(20),
margin: const EdgeInsets.all(10),
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(15)),
child: Column(
children: [
Text(
viewModel.local!.youHaveBlockedThisContact,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
color: Theme.of(context)
.scaffoldBackgroundColor),
),
TextButton(
onPressed: () {
viewModel.unBlock();
},
child: Text(
viewModel.local!.unBlock,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
color: Theme.of(context)
.scaffoldBackgroundColor,
decoration: TextDecoration.underline),
))
],
),
)
]else if (viewModel.contact.isBlockedByFirstUser &&
(viewModel.appConfigProvider!.user!.uid ==
viewModel.contact.secondUserUID)) ...[
Container(
padding: const EdgeInsets.all(20),
margin: const EdgeInsets.all(10),
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(15)),
child: Column(
children: [
Text(
viewModel.local!.youNoLongerCanSendMessages,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
color: Theme.of(context)
.scaffoldBackgroundColor),
),
],
),
)
]else if (viewModel.contact.isBlockedBySecondUser &&
(viewModel.appConfigProvider!.user!.uid ==
viewModel.contact.firstUserUID)) ...[
Container(
padding: const EdgeInsets.all(20),
margin: const EdgeInsets.all(10),
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(15)),
child: Column(
children: [
Text(
viewModel.local!.youNoLongerCanSendMessages,
style: Theme.of(context)
.textTheme
.bodyLarge!
.copyWith(
color: Theme.of(context)
.scaffoldBackgroundColor),
),
],
),
)
]else ...[
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10.0, vertical: 15),
child: TextFormField(
controller: viewModel.controller,
autovalidateMode: AutovalidateMode.onUserInteraction,
cursorColor: Theme.of(context).primaryColor,
decoration: InputDecoration(
suffixIcon: InkWell(
onTap: () => viewModel.sendMessage(),
child: Icon(
EvaIcons.paperPlane,
size: 25,
color: Theme.of(context).primaryColor,
),
),
prefixIcon: InkWell(
onTap: () => value.showModalBottomSheet(),
child: const Icon(
Icons.image,
size: 25,
),
),
hintText: value.local!.sendMessage,
),

],
),
),
),
]
],
),
),
Expand All @@ -199,7 +319,6 @@ class _ContactChatViewState
return ContactChatViewModel(
sendMessageUseCase: injectSendMessageUseCase(),
getMessagesUseCase: injectGetMessagesUseCase(),
updateContactUseCase: injectUpdateContactUseCase()
);
updateContactUseCase: injectUpdateContactUseCase());
}
}
30 changes: 28 additions & 2 deletions lib/Presentation/UI/ContactChat/ContactChatViewModel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,19 @@ class ContactChatViewModel extends BaseViewModel<ContactChatNavigator> {
}

// function to block contact
blockContact() {
//todo to be implemented
blockContact()async {
if(contact.firstUserUID == appConfigProvider!.user!.uid){
contact.isBlockedByFirstUser = true;
}else{
contact.isBlockedBySecondUser = true;
}
try {
await updateContactUseCase.invoke(contact: contact);
notifyListeners();
} catch (e) {
navigator!.showErrorNotification(message: local!.errorSendingMessage);
notifyListeners();
}
}

// function to block Contact
Expand All @@ -93,4 +104,19 @@ class ContactChatViewModel extends BaseViewModel<ContactChatNavigator> {
openCamera: pickImageFromCamera,
openGallery: pickImageFromGallery));
}

unBlock()async {
if(contact.firstUserUID == appConfigProvider!.user!.uid){
contact.isBlockedByFirstUser = false;
}else{
contact.isBlockedBySecondUser = false;
}
try {
await updateContactUseCase.invoke(contact: contact);
notifyListeners();
} catch (e) {
navigator!.showErrorNotification(message: local!.errorSendingMessage);
notifyListeners();
}
}
}

0 comments on commit 541ffa6

Please sign in to comment.