mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Fix display of ephemeral message duration and icon
This commit is contained in:
parent
927ef5fbbc
commit
dc03349aae
5 changed files with 75 additions and 42 deletions
|
|
@ -202,6 +202,7 @@
|
|||
"conversation_dialog_subject_hint" = "Conversation subject";
|
||||
"conversation_end_to_end_encrypted_bottom_sheet_link" = "https://linphone.org/en/features/#security";
|
||||
"conversation_ephemeral_messages_duration_disabled" = "Disabled";
|
||||
"conversation_ephemeral_messages_duration_multiple_days" = "%d days";
|
||||
"conversation_ephemeral_messages_duration_one_day" = "1 day";
|
||||
"conversation_ephemeral_messages_duration_one_hour" = "1 hour";
|
||||
"conversation_ephemeral_messages_duration_one_minute" = "1 minute";
|
||||
|
|
|
|||
|
|
@ -202,6 +202,7 @@
|
|||
"conversation_dialog_subject_hint" = "Nom de la conversation";
|
||||
"conversation_end_to_end_encrypted_bottom_sheet_link" = "https://linphone.org/en/features/#security";
|
||||
"conversation_ephemeral_messages_duration_disabled" = "Désactiver";
|
||||
"conversation_ephemeral_messages_duration_multiple_days" = "%d jours";
|
||||
"conversation_ephemeral_messages_duration_one_day" = "1 jour";
|
||||
"conversation_ephemeral_messages_duration_one_hour" = "1 heure";
|
||||
"conversation_ephemeral_messages_duration_one_minute" = "1 minute";
|
||||
|
|
|
|||
|
|
@ -148,11 +148,19 @@ struct ConversationRow: View {
|
|||
.frame(width: 18, height: 18, alignment: .trailing)
|
||||
}
|
||||
|
||||
if conversation.isEphemeral {
|
||||
Image("clock-countdown")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c400)
|
||||
.frame(width: 18, height: 18, alignment: .trailing)
|
||||
}
|
||||
|
||||
if conversation.isMuted {
|
||||
Image("bell-slash")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.orangeMain500)
|
||||
.foregroundStyle(Color.grayMain2c400)
|
||||
.frame(width: 18, height: 18, alignment: .trailing)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2525,9 +2525,15 @@ class ConversationViewModel: ObservableObject {
|
|||
}
|
||||
|
||||
if lifetime == 0 {
|
||||
DispatchQueue.main.async {
|
||||
self.sharedMainViewModel.displayedConversation!.isEphemeral = false
|
||||
}
|
||||
self.sharedMainViewModel.displayedConversation!.chatRoom.ephemeralEnabled = false
|
||||
self.sharedMainViewModel.displayedConversation!.chatRoom.ephemeralLifetime = lifetime
|
||||
} else {
|
||||
DispatchQueue.main.async {
|
||||
self.sharedMainViewModel.displayedConversation!.isEphemeral = true
|
||||
}
|
||||
self.sharedMainViewModel.displayedConversation!.chatRoom.ephemeralEnabled = true
|
||||
self.sharedMainViewModel.displayedConversation!.chatRoom.ephemeralLifetime = lifetime
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,19 +21,27 @@ import Foundation
|
|||
|
||||
// swiftlint:disable large_tuple
|
||||
extension Int {
|
||||
|
||||
public func hmsFrom() -> (Int, Int, Int) {
|
||||
return (self / 3600, (self % 3600) / 60, (self % 3600) % 60)
|
||||
}
|
||||
|
||||
public func convertDurationToString() -> String {
|
||||
var duration = ""
|
||||
let (hour, minute, second) = self.hmsFrom()
|
||||
if hour > 0 {
|
||||
duration = self.getHour(hour: hour)
|
||||
}
|
||||
return "\(duration)\(self.getMinute(minute: minute))\(self.getSecond(second: second))"
|
||||
}
|
||||
|
||||
public func hmsFrom() -> (Int, Int, Int) {
|
||||
return (self / 3600, (self % 3600) / 60, (self % 3600) % 60)
|
||||
}
|
||||
|
||||
public func convertDurationToString() -> String {
|
||||
let (hour, minute, second) = self.hmsFrom()
|
||||
let day = hour / 24
|
||||
let remainingHour = hour % 24
|
||||
|
||||
if day > 0 && day <= 7 {
|
||||
return self.getDay(day: day)
|
||||
}
|
||||
|
||||
if hour > 0 {
|
||||
return "\(self.getHour(hour: remainingHour))\(self.getMinute(minute: minute))\(self.getSecond(second: second))"
|
||||
}
|
||||
|
||||
return "\(self.getMinute(minute: minute))\(self.getSecond(second: second))"
|
||||
}
|
||||
|
||||
|
||||
public func formatBytes() -> String {
|
||||
let byteCountFormatter = ByteCountFormatter()
|
||||
|
|
@ -42,36 +50,45 @@ extension Int {
|
|||
byteCountFormatter.isAdaptive = true // Adjusts automatically to appropriate unit
|
||||
return byteCountFormatter.string(fromByteCount: Int64(self))
|
||||
}
|
||||
|
||||
private func getHour(hour: Int) -> String {
|
||||
var duration = "\(hour):"
|
||||
if hour < 10 {
|
||||
duration = "0\(hour):"
|
||||
}
|
||||
return duration
|
||||
}
|
||||
|
||||
private func getMinute(minute: Int) -> String {
|
||||
if minute == 0 {
|
||||
return "00:"
|
||||
}
|
||||
|
||||
private func getDay(day: Int) -> String {
|
||||
if day == 1 {
|
||||
return NSLocalizedString("conversation_ephemeral_messages_duration_one_day", comment: "")
|
||||
}
|
||||
let format = NSLocalizedString("conversation_ephemeral_messages_duration_multiple_days", comment: "")
|
||||
return String(format: format, day)
|
||||
}
|
||||
|
||||
if minute < 10 {
|
||||
return "0\(minute):"
|
||||
}
|
||||
private func getHour(hour: Int) -> String {
|
||||
var duration = "\(hour):"
|
||||
if hour < 10 {
|
||||
duration = "0\(hour):"
|
||||
}
|
||||
return duration
|
||||
}
|
||||
|
||||
private func getMinute(minute: Int) -> String {
|
||||
if minute == 0 {
|
||||
return "00:"
|
||||
}
|
||||
|
||||
return "\(minute):"
|
||||
}
|
||||
|
||||
private func getSecond(second: Int) -> String {
|
||||
if second == 0 {
|
||||
return "00"
|
||||
}
|
||||
if minute < 10 {
|
||||
return "0\(minute):"
|
||||
}
|
||||
|
||||
if second < 10 {
|
||||
return "0\(second)"
|
||||
}
|
||||
return "\(second)"
|
||||
}
|
||||
return "\(minute):"
|
||||
}
|
||||
|
||||
private func getSecond(second: Int) -> String {
|
||||
if second == 0 {
|
||||
return "00"
|
||||
}
|
||||
|
||||
if second < 10 {
|
||||
return "0\(second)"
|
||||
}
|
||||
return "\(second)"
|
||||
}
|
||||
}
|
||||
|
||||
// swiftlint:enable large_tuple
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue