mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 09:28:41 +00:00
fix #184
This commit is contained in:
parent
f372444b5a
commit
9a06271140
4 changed files with 114 additions and 44 deletions
|
|
@ -61,6 +61,10 @@ enum PushKind: String, Codable {
|
||||||
case reaction
|
case reaction
|
||||||
case testNotification
|
case testNotification
|
||||||
case reopenedMedia
|
case reopenedMedia
|
||||||
|
case reactionToVideo
|
||||||
|
case reactionToText
|
||||||
|
case reactionToImage
|
||||||
|
case response
|
||||||
}
|
}
|
||||||
|
|
||||||
import CryptoKit
|
import CryptoKit
|
||||||
|
|
@ -181,6 +185,14 @@ func determinePushKind(from message: String) -> PushKind? {
|
||||||
return .testNotification
|
return .testNotification
|
||||||
} else if message.contains("reopenedMedia") {
|
} else if message.contains("reopenedMedia") {
|
||||||
return .reopenedMedia
|
return .reopenedMedia
|
||||||
|
} else if message.contains("reactionToVideo") {
|
||||||
|
return .reactionToVideo
|
||||||
|
} else if message.contains("reactionToText") {
|
||||||
|
return .reactionToText
|
||||||
|
} else if message.contains("reactionToImage") {
|
||||||
|
return .reactionToImage
|
||||||
|
} else if message.contains("response") {
|
||||||
|
return .response
|
||||||
} else {
|
} else {
|
||||||
return nil // Unknown PushKind
|
return nil // Unknown PushKind
|
||||||
}
|
}
|
||||||
|
|
@ -321,7 +333,12 @@ func getPushNotificationText(pushKind: PushKind) -> String {
|
||||||
.acceptRequest: "ist jetzt mit dir vernetzt.",
|
.acceptRequest: "ist jetzt mit dir vernetzt.",
|
||||||
.storedMediaFile: "hat dein Bild gespeichert.",
|
.storedMediaFile: "hat dein Bild gespeichert.",
|
||||||
.reaction: "hat auf dein Bild reagiert.",
|
.reaction: "hat auf dein Bild reagiert.",
|
||||||
.reopenedMedia: "Dein Bild wurde erneut geöffnet."
|
.testNotification: "Das ist eine Testbenachrichtigung.",
|
||||||
|
.reopenedMedia: "hat dein Bild erneut geöffnet.",
|
||||||
|
.reactionToVideo: "hat auf dein Video reagiert.",
|
||||||
|
.reactionToText: "hat auf deinen Text reagiert.",
|
||||||
|
.reactionToImage: "hat auf dein Bild reagiert.",
|
||||||
|
.response: "hat dir geantwortet."
|
||||||
]
|
]
|
||||||
} else { // Default to English
|
} else { // Default to English
|
||||||
pushNotificationText = [
|
pushNotificationText = [
|
||||||
|
|
@ -333,7 +350,12 @@ func getPushNotificationText(pushKind: PushKind) -> String {
|
||||||
.acceptRequest: "is now connected with you.",
|
.acceptRequest: "is now connected with you.",
|
||||||
.storedMediaFile: "has stored your image.",
|
.storedMediaFile: "has stored your image.",
|
||||||
.reaction: "has reacted to your image.",
|
.reaction: "has reacted to your image.",
|
||||||
.reopenedMedia: "Your image was reopened."
|
.testNotification: "This is a test notification.",
|
||||||
|
.reopenedMedia: "has reopened your image.",
|
||||||
|
.reactionToVideo: "has reacted to your video.",
|
||||||
|
.reactionToText: "has reacted to your text.",
|
||||||
|
.reactionToImage: "has reacted to your image.",
|
||||||
|
.response: "has responded."
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -357,7 +379,12 @@ func getPushNotificationTextWithoutUserId(pushKind: PushKind) -> String {
|
||||||
.acceptRequest: "Deine Kontaktanfrage wurde angenommen.",
|
.acceptRequest: "Deine Kontaktanfrage wurde angenommen.",
|
||||||
.storedMediaFile: "Dein Bild wurde gespeichert.",
|
.storedMediaFile: "Dein Bild wurde gespeichert.",
|
||||||
.reaction: "Du hast eine Reaktion auf dein Bild erhalten.",
|
.reaction: "Du hast eine Reaktion auf dein Bild erhalten.",
|
||||||
.reopenedMedia: "hat dein Bild erneut geöffnet."
|
.testNotification: "Das ist eine Testbenachrichtigung.",
|
||||||
|
.reopenedMedia: "hat dein Bild erneut geöffnet.",
|
||||||
|
.reactionToVideo: "Du hast eine Reaktion auf dein Video erhalten.",
|
||||||
|
.reactionToText: "Du hast eine Reaktion auf deinen Text erhalten.",
|
||||||
|
.reactionToImage: "Du hast eine Reaktion auf dein Bild erhalten.",
|
||||||
|
.response: "Du hast eine Antwort erhalten."
|
||||||
]
|
]
|
||||||
} else { // Default to English
|
} else { // Default to English
|
||||||
pushNotificationText = [
|
pushNotificationText = [
|
||||||
|
|
@ -369,7 +396,12 @@ func getPushNotificationTextWithoutUserId(pushKind: PushKind) -> String {
|
||||||
.acceptRequest: "Your contact request has been accepted.",
|
.acceptRequest: "Your contact request has been accepted.",
|
||||||
.storedMediaFile: "Your image has been saved.",
|
.storedMediaFile: "Your image has been saved.",
|
||||||
.reaction: "You got a reaction to your image.",
|
.reaction: "You got a reaction to your image.",
|
||||||
.reopenedMedia: "has reopened your image."
|
.testNotification: "This is a test notification.",
|
||||||
|
.reopenedMedia: "has reopened your image.",
|
||||||
|
.reactionToVideo: "You got a reaction to your video.",
|
||||||
|
.reactionToText: "You got a reaction to your text.",
|
||||||
|
.reactionToImage: "You got a reaction to your image.",
|
||||||
|
.response: "You got a response."
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,11 @@ enum PushKind {
|
||||||
acceptRequest,
|
acceptRequest,
|
||||||
storedMediaFile,
|
storedMediaFile,
|
||||||
testNotification,
|
testNotification,
|
||||||
reopenedMedia
|
reopenedMedia,
|
||||||
|
reactionToVideo,
|
||||||
|
reactionToText,
|
||||||
|
reactionToImage,
|
||||||
|
response,
|
||||||
}
|
}
|
||||||
|
|
||||||
extension PushKindExtension on PushKind {
|
extension PushKindExtension on PushKind {
|
||||||
|
|
@ -527,27 +531,42 @@ String getPushNotificationTextWithoutUserId(PushKind pushKind) {
|
||||||
|
|
||||||
if (systemLanguage.contains("de")) {
|
if (systemLanguage.contains("de")) {
|
||||||
pushNotificationText = {
|
pushNotificationText = {
|
||||||
PushKind.text.name: "Du hast eine Nachricht erhalten.",
|
PushKind.text.name: "Du hast eine neue Nachricht erhalten.",
|
||||||
PushKind.twonly.name: "Du hast ein twonly erhalten.",
|
PushKind.twonly.name: "Du hast ein neues twonly erhalten.",
|
||||||
PushKind.video.name: "Du hast ein Video erhalten.",
|
PushKind.video.name: "Du hast ein neues Video erhalten.",
|
||||||
PushKind.image.name: "Du hast ein Bild erhalten.",
|
PushKind.image.name: "Du hast ein neues Bild erhalten.",
|
||||||
PushKind.contactRequest.name: "Du hast eine Kontaktanfrage erhalten.",
|
PushKind.contactRequest.name:
|
||||||
|
"Du hast eine neue Kontaktanfrage erhalten.",
|
||||||
PushKind.acceptRequest.name: "Deine Kontaktanfrage wurde angenommen.",
|
PushKind.acceptRequest.name: "Deine Kontaktanfrage wurde angenommen.",
|
||||||
PushKind.storedMediaFile.name: "Dein Bild wurde gespeichert.",
|
PushKind.storedMediaFile.name: "Dein Bild wurde gespeichert.",
|
||||||
PushKind.reaction.name: "Du hast eine Reaktion auf dein Bild erhalten.",
|
PushKind.reaction.name: "Du hast eine Reaktion auf dein Bild erhalten.",
|
||||||
PushKind.reopenedMedia.name: "Dein Bild wurde erneut geöffnet."
|
PushKind.reopenedMedia.name: "Dein Bild wurde erneut geöffnet.",
|
||||||
|
PushKind.reactionToVideo.name:
|
||||||
|
"Du hast eine Reaktion auf dein Video erhalten.",
|
||||||
|
PushKind.reactionToText.name:
|
||||||
|
"Du hast eine Reaktion auf deinen Text erhalten.",
|
||||||
|
PushKind.reactionToImage.name:
|
||||||
|
"Du hast eine Reaktion auf dein Bild erhalten.",
|
||||||
|
PushKind.response.name: "Du hast eine Antwort erhalten.",
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
pushNotificationText = {
|
pushNotificationText = {
|
||||||
PushKind.text.name: "You got a message.",
|
PushKind.text.name: "You have received a new message.",
|
||||||
PushKind.twonly.name: "You got a twonly.",
|
PushKind.twonly.name: "You have received a new twonly.",
|
||||||
PushKind.video.name: "You got a video.",
|
PushKind.video.name: "You have received a new video.",
|
||||||
PushKind.image.name: "You got an image.",
|
PushKind.image.name: "You have received a new image.",
|
||||||
PushKind.contactRequest.name: "You got a contact request.",
|
PushKind.contactRequest.name: "You have received a new contact request.",
|
||||||
PushKind.acceptRequest.name: "Your contact request has been accepted.",
|
PushKind.acceptRequest.name: "Your contact request has been accepted.",
|
||||||
PushKind.storedMediaFile.name: "Your image has been saved.",
|
PushKind.storedMediaFile.name: "Your image has been saved.",
|
||||||
PushKind.reaction.name: "You got a reaction to your image.",
|
PushKind.reaction.name: "You have received a reaction to your image.",
|
||||||
PushKind.reopenedMedia.name: "Your image was reopened."
|
PushKind.reopenedMedia.name: "Your image has been reopened.",
|
||||||
|
PushKind.reactionToVideo.name:
|
||||||
|
"You have received a reaction to your video.",
|
||||||
|
PushKind.reactionToText.name:
|
||||||
|
"You have received a reaction to your text.",
|
||||||
|
PushKind.reactionToImage.name:
|
||||||
|
"You have received a reaction to your image.",
|
||||||
|
PushKind.response.name: "You have received a response.",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return pushNotificationText[pushKind.name] ?? "";
|
return pushNotificationText[pushKind.name] ?? "";
|
||||||
|
|
@ -564,11 +583,15 @@ String getPushNotificationText(PushKind pushKind) {
|
||||||
PushKind.twonly.name: "hat dir ein twonly gesendet.",
|
PushKind.twonly.name: "hat dir ein twonly gesendet.",
|
||||||
PushKind.video.name: "hat dir ein Video gesendet.",
|
PushKind.video.name: "hat dir ein Video gesendet.",
|
||||||
PushKind.image.name: "hat dir ein Bild gesendet.",
|
PushKind.image.name: "hat dir ein Bild gesendet.",
|
||||||
PushKind.contactRequest.name: "möchte sich mir dir vernetzen.",
|
PushKind.contactRequest.name: "möchte sich mit dir vernetzen.",
|
||||||
PushKind.acceptRequest.name: "ist jetzt mit dir vernetzt.",
|
PushKind.acceptRequest.name: "ist jetzt mit dir vernetzt.",
|
||||||
PushKind.storedMediaFile.name: "hat dein Bild gespeichert.",
|
PushKind.storedMediaFile.name: "hat dein Bild gespeichert.",
|
||||||
PushKind.reaction.name: "hat auf dein Bild reagiert.",
|
PushKind.reaction.name: "hat auf dein Bild reagiert.",
|
||||||
PushKind.reopenedMedia.name: "hat dein Bild erneut geöffnet."
|
PushKind.reopenedMedia.name: "hat dein Bild erneut geöffnet.",
|
||||||
|
PushKind.reactionToVideo.name: "hat auf dein Video reagiert.",
|
||||||
|
PushKind.reactionToText.name: "hat auf deinen Text reagiert.",
|
||||||
|
PushKind.reactionToImage.name: "hat auf dein Bild reagiert.",
|
||||||
|
PushKind.response.name: "hat dir geantwortet.",
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
pushNotificationText = {
|
pushNotificationText = {
|
||||||
|
|
@ -580,7 +603,11 @@ String getPushNotificationText(PushKind pushKind) {
|
||||||
PushKind.acceptRequest.name: "is now connected with you.",
|
PushKind.acceptRequest.name: "is now connected with you.",
|
||||||
PushKind.storedMediaFile.name: "has stored your image.",
|
PushKind.storedMediaFile.name: "has stored your image.",
|
||||||
PushKind.reaction.name: "has reacted to your image.",
|
PushKind.reaction.name: "has reacted to your image.",
|
||||||
PushKind.reopenedMedia.name: "has reopened your image."
|
PushKind.reopenedMedia.name: "has reopened your image.",
|
||||||
|
PushKind.reactionToVideo.name: "has reacted to your video.",
|
||||||
|
PushKind.reactionToText.name: "has reacted to your text.",
|
||||||
|
PushKind.reactionToImage.name: "has reacted to your image.",
|
||||||
|
PushKind.response.name: "has responded.",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return pushNotificationText[pushKind.name] ?? "";
|
return pushNotificationText[pushKind.name] ?? "";
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ class _ChatMessagesViewState extends State<ChatMessagesView> {
|
||||||
responseToMessageId: responseToMessage?.messageOtherId,
|
responseToMessageId: responseToMessage?.messageOtherId,
|
||||||
responseToOtherMessageId: responseToMessage?.messageId,
|
responseToOtherMessageId: responseToMessage?.messageId,
|
||||||
),
|
),
|
||||||
PushKind.text,
|
(responseToMessage == null) ? PushKind.text : PushKind.response,
|
||||||
);
|
);
|
||||||
newMessageController.clear();
|
newMessageController.clear();
|
||||||
currentInputText = "";
|
currentInputText = "";
|
||||||
|
|
|
||||||
|
|
@ -662,6 +662,7 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
||||||
mediaViewerDistanceFromBottom: mediaViewerDistanceFromBottom,
|
mediaViewerDistanceFromBottom: mediaViewerDistanceFromBottom,
|
||||||
userId: widget.contact.userId,
|
userId: widget.contact.userId,
|
||||||
responseToMessageId: allMediaFiles.first.messageOtherId!,
|
responseToMessageId: allMediaFiles.first.messageOtherId!,
|
||||||
|
isVideo: videoController != null,
|
||||||
hide: () {
|
hide: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
showShortReactions = false;
|
showShortReactions = false;
|
||||||
|
|
@ -677,17 +678,20 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReactionButtons extends StatefulWidget {
|
class ReactionButtons extends StatefulWidget {
|
||||||
const ReactionButtons(
|
const ReactionButtons({
|
||||||
{super.key,
|
super.key,
|
||||||
required this.show,
|
required this.show,
|
||||||
required this.textInputFocused,
|
required this.textInputFocused,
|
||||||
required this.userId,
|
required this.userId,
|
||||||
required this.mediaViewerDistanceFromBottom,
|
required this.mediaViewerDistanceFromBottom,
|
||||||
required this.responseToMessageId,
|
required this.responseToMessageId,
|
||||||
required this.hide});
|
required this.isVideo,
|
||||||
|
required this.hide,
|
||||||
|
});
|
||||||
|
|
||||||
final double mediaViewerDistanceFromBottom;
|
final double mediaViewerDistanceFromBottom;
|
||||||
final bool show;
|
final bool show;
|
||||||
|
final bool isVideo;
|
||||||
final bool textInputFocused;
|
final bool textInputFocused;
|
||||||
final int userId;
|
final int userId;
|
||||||
final int responseToMessageId;
|
final int responseToMessageId;
|
||||||
|
|
@ -751,6 +755,7 @@ class _ReactionButtonsState extends State<ReactionButtons> {
|
||||||
responseToMessageId: widget.responseToMessageId,
|
responseToMessageId: widget.responseToMessageId,
|
||||||
hide: widget.hide,
|
hide: widget.hide,
|
||||||
show: widget.show,
|
show: widget.show,
|
||||||
|
isVideo: widget.isVideo,
|
||||||
emoji: emoji,
|
emoji: emoji,
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
|
|
@ -760,13 +765,16 @@ class _ReactionButtonsState extends State<ReactionButtons> {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: firstRowEmojis
|
children: firstRowEmojis
|
||||||
.map((emoji) => EmojiReactionWidget(
|
.map(
|
||||||
userId: widget.userId,
|
(emoji) => EmojiReactionWidget(
|
||||||
responseToMessageId: widget.responseToMessageId,
|
userId: widget.userId,
|
||||||
hide: widget.hide,
|
responseToMessageId: widget.responseToMessageId,
|
||||||
show: widget.show,
|
hide: widget.hide,
|
||||||
emoji: emoji,
|
show: widget.show,
|
||||||
))
|
isVideo: widget.isVideo,
|
||||||
|
emoji: emoji,
|
||||||
|
),
|
||||||
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
@ -782,6 +790,7 @@ class EmojiReactionWidget extends StatefulWidget {
|
||||||
final int responseToMessageId;
|
final int responseToMessageId;
|
||||||
final Function hide;
|
final Function hide;
|
||||||
final bool show;
|
final bool show;
|
||||||
|
final bool isVideo;
|
||||||
final String emoji;
|
final String emoji;
|
||||||
|
|
||||||
const EmojiReactionWidget({
|
const EmojiReactionWidget({
|
||||||
|
|
@ -789,6 +798,7 @@ class EmojiReactionWidget extends StatefulWidget {
|
||||||
required this.userId,
|
required this.userId,
|
||||||
required this.responseToMessageId,
|
required this.responseToMessageId,
|
||||||
required this.hide,
|
required this.hide,
|
||||||
|
required this.isVideo,
|
||||||
required this.show,
|
required this.show,
|
||||||
required this.emoji,
|
required this.emoji,
|
||||||
});
|
});
|
||||||
|
|
@ -808,13 +818,14 @@ class _EmojiReactionWidgetState extends State<EmojiReactionWidget> {
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
sendTextMessage(
|
sendTextMessage(
|
||||||
widget.userId,
|
widget.userId,
|
||||||
TextMessageContent(
|
TextMessageContent(
|
||||||
text: widget.emoji,
|
text: widget.emoji,
|
||||||
responseToMessageId: widget.responseToMessageId,
|
responseToMessageId: widget.responseToMessageId,
|
||||||
),
|
),
|
||||||
PushKind.reaction,
|
widget.isVideo
|
||||||
);
|
? PushKind.reactionToVideo
|
||||||
|
: PushKind.reactionToImage);
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedShortReaction = 0; // Assuming index is 0 for this example
|
selectedShortReaction = 0; // Assuming index is 0 for this example
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue