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 testNotification
|
||||
case reopenedMedia
|
||||
case reactionToVideo
|
||||
case reactionToText
|
||||
case reactionToImage
|
||||
case response
|
||||
}
|
||||
|
||||
import CryptoKit
|
||||
|
|
@ -181,6 +185,14 @@ func determinePushKind(from message: String) -> PushKind? {
|
|||
return .testNotification
|
||||
} else if message.contains("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 {
|
||||
return nil // Unknown PushKind
|
||||
}
|
||||
|
|
@ -321,7 +333,12 @@ func getPushNotificationText(pushKind: PushKind) -> String {
|
|||
.acceptRequest: "ist jetzt mit dir vernetzt.",
|
||||
.storedMediaFile: "hat dein Bild gespeichert.",
|
||||
.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
|
||||
pushNotificationText = [
|
||||
|
|
@ -333,7 +350,12 @@ func getPushNotificationText(pushKind: PushKind) -> String {
|
|||
.acceptRequest: "is now connected with you.",
|
||||
.storedMediaFile: "has stored 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.",
|
||||
.storedMediaFile: "Dein Bild wurde gespeichert.",
|
||||
.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
|
||||
pushNotificationText = [
|
||||
|
|
@ -369,7 +396,12 @@ func getPushNotificationTextWithoutUserId(pushKind: PushKind) -> String {
|
|||
.acceptRequest: "Your contact request has been accepted.",
|
||||
.storedMediaFile: "Your image has been saved.",
|
||||
.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,
|
||||
storedMediaFile,
|
||||
testNotification,
|
||||
reopenedMedia
|
||||
reopenedMedia,
|
||||
reactionToVideo,
|
||||
reactionToText,
|
||||
reactionToImage,
|
||||
response,
|
||||
}
|
||||
|
||||
extension PushKindExtension on PushKind {
|
||||
|
|
@ -527,27 +531,42 @@ String getPushNotificationTextWithoutUserId(PushKind pushKind) {
|
|||
|
||||
if (systemLanguage.contains("de")) {
|
||||
pushNotificationText = {
|
||||
PushKind.text.name: "Du hast eine Nachricht erhalten.",
|
||||
PushKind.twonly.name: "Du hast ein twonly erhalten.",
|
||||
PushKind.video.name: "Du hast ein Video erhalten.",
|
||||
PushKind.image.name: "Du hast ein Bild erhalten.",
|
||||
PushKind.contactRequest.name: "Du hast eine Kontaktanfrage erhalten.",
|
||||
PushKind.text.name: "Du hast eine neue Nachricht erhalten.",
|
||||
PushKind.twonly.name: "Du hast ein neues twonly erhalten.",
|
||||
PushKind.video.name: "Du hast ein neues Video erhalten.",
|
||||
PushKind.image.name: "Du hast ein neues Bild erhalten.",
|
||||
PushKind.contactRequest.name:
|
||||
"Du hast eine neue Kontaktanfrage erhalten.",
|
||||
PushKind.acceptRequest.name: "Deine Kontaktanfrage wurde angenommen.",
|
||||
PushKind.storedMediaFile.name: "Dein Bild wurde gespeichert.",
|
||||
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 {
|
||||
pushNotificationText = {
|
||||
PushKind.text.name: "You got a message.",
|
||||
PushKind.twonly.name: "You got a twonly.",
|
||||
PushKind.video.name: "You got a video.",
|
||||
PushKind.image.name: "You got an image.",
|
||||
PushKind.contactRequest.name: "You got a contact request.",
|
||||
PushKind.text.name: "You have received a new message.",
|
||||
PushKind.twonly.name: "You have received a new twonly.",
|
||||
PushKind.video.name: "You have received a new video.",
|
||||
PushKind.image.name: "You have received a new image.",
|
||||
PushKind.contactRequest.name: "You have received a new contact request.",
|
||||
PushKind.acceptRequest.name: "Your contact request has been accepted.",
|
||||
PushKind.storedMediaFile.name: "Your image has been saved.",
|
||||
PushKind.reaction.name: "You got a reaction to your image.",
|
||||
PushKind.reopenedMedia.name: "Your image was reopened."
|
||||
PushKind.reaction.name: "You have received a reaction to your image.",
|
||||
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] ?? "";
|
||||
|
|
@ -564,11 +583,15 @@ String getPushNotificationText(PushKind pushKind) {
|
|||
PushKind.twonly.name: "hat dir ein twonly gesendet.",
|
||||
PushKind.video.name: "hat dir ein Video 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.storedMediaFile.name: "hat dein Bild gespeichert.",
|
||||
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 {
|
||||
pushNotificationText = {
|
||||
|
|
@ -580,7 +603,11 @@ String getPushNotificationText(PushKind pushKind) {
|
|||
PushKind.acceptRequest.name: "is now connected with you.",
|
||||
PushKind.storedMediaFile.name: "has stored 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] ?? "";
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ class _ChatMessagesViewState extends State<ChatMessagesView> {
|
|||
responseToMessageId: responseToMessage?.messageOtherId,
|
||||
responseToOtherMessageId: responseToMessage?.messageId,
|
||||
),
|
||||
PushKind.text,
|
||||
(responseToMessage == null) ? PushKind.text : PushKind.response,
|
||||
);
|
||||
newMessageController.clear();
|
||||
currentInputText = "";
|
||||
|
|
|
|||
|
|
@ -662,6 +662,7 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
|||
mediaViewerDistanceFromBottom: mediaViewerDistanceFromBottom,
|
||||
userId: widget.contact.userId,
|
||||
responseToMessageId: allMediaFiles.first.messageOtherId!,
|
||||
isVideo: videoController != null,
|
||||
hide: () {
|
||||
setState(() {
|
||||
showShortReactions = false;
|
||||
|
|
@ -677,17 +678,20 @@ class _MediaViewerViewState extends State<MediaViewerView> {
|
|||
}
|
||||
|
||||
class ReactionButtons extends StatefulWidget {
|
||||
const ReactionButtons(
|
||||
{super.key,
|
||||
const ReactionButtons({
|
||||
super.key,
|
||||
required this.show,
|
||||
required this.textInputFocused,
|
||||
required this.userId,
|
||||
required this.mediaViewerDistanceFromBottom,
|
||||
required this.responseToMessageId,
|
||||
required this.hide});
|
||||
required this.isVideo,
|
||||
required this.hide,
|
||||
});
|
||||
|
||||
final double mediaViewerDistanceFromBottom;
|
||||
final bool show;
|
||||
final bool isVideo;
|
||||
final bool textInputFocused;
|
||||
final int userId;
|
||||
final int responseToMessageId;
|
||||
|
|
@ -751,6 +755,7 @@ class _ReactionButtonsState extends State<ReactionButtons> {
|
|||
responseToMessageId: widget.responseToMessageId,
|
||||
hide: widget.hide,
|
||||
show: widget.show,
|
||||
isVideo: widget.isVideo,
|
||||
emoji: emoji,
|
||||
))
|
||||
.toList(),
|
||||
|
|
@ -760,13 +765,16 @@ class _ReactionButtonsState extends State<ReactionButtons> {
|
|||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: firstRowEmojis
|
||||
.map((emoji) => EmojiReactionWidget(
|
||||
.map(
|
||||
(emoji) => EmojiReactionWidget(
|
||||
userId: widget.userId,
|
||||
responseToMessageId: widget.responseToMessageId,
|
||||
hide: widget.hide,
|
||||
show: widget.show,
|
||||
isVideo: widget.isVideo,
|
||||
emoji: emoji,
|
||||
))
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
|
|
@ -782,6 +790,7 @@ class EmojiReactionWidget extends StatefulWidget {
|
|||
final int responseToMessageId;
|
||||
final Function hide;
|
||||
final bool show;
|
||||
final bool isVideo;
|
||||
final String emoji;
|
||||
|
||||
const EmojiReactionWidget({
|
||||
|
|
@ -789,6 +798,7 @@ class EmojiReactionWidget extends StatefulWidget {
|
|||
required this.userId,
|
||||
required this.responseToMessageId,
|
||||
required this.hide,
|
||||
required this.isVideo,
|
||||
required this.show,
|
||||
required this.emoji,
|
||||
});
|
||||
|
|
@ -813,8 +823,9 @@ class _EmojiReactionWidgetState extends State<EmojiReactionWidget> {
|
|||
text: widget.emoji,
|
||||
responseToMessageId: widget.responseToMessageId,
|
||||
),
|
||||
PushKind.reaction,
|
||||
);
|
||||
widget.isVideo
|
||||
? PushKind.reactionToVideo
|
||||
: PushKind.reactionToImage);
|
||||
setState(() {
|
||||
selectedShortReaction = 0; // Assuming index is 0 for this example
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue