diff --git a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift index 8ecbc13ad..132d4442d 100644 --- a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift +++ b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift @@ -196,14 +196,8 @@ struct HistoryContactFragment: View { .padding(.top, 5) } - if let avatarModel = historyModel.avatarModel { - Text(avatarModel.lastPresenceInfo) - .foregroundStyle(avatarModel.lastPresenceInfo == "Online" ? Color.greenSuccess500 : Color.orangeWarning600) - .multilineTextAlignment(.center) - .default_text_style_300(styleSize: 12) - .frame(maxWidth: .infinity) - .frame(height: 20) - .padding(.top, 5) + if let avatar = historyModel.avatarModel { + AvatarPresenceView(avatarModel: avatar) } else { Text("") .multilineTextAlignment(.center) @@ -423,6 +417,21 @@ struct HistoryContactFragment: View { } } +struct AvatarPresenceView: View { + @ObservedObject var avatarModel: ContactAvatarModel + + var body: some View { + Text(avatarModel.lastPresenceInfo) + .foregroundStyle(avatarModel.lastPresenceInfo == "Online" ? Color.greenSuccess500 : Color.orangeWarning600) + .multilineTextAlignment(.center) + .default_text_style_300(styleSize: 12) + .frame(maxWidth: .infinity) + .frame(height: 20) + .padding(.top, 5) + } +} + + #Preview { HistoryContactFragment( isShowDeleteAllHistoryPopup: .constant(false),