mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-30 21:26:57 +02:00
Merge branch 'develop' into alfogrillo/learn_more_sheet
# Conflicts: # RiotSwiftUI/Modules/UserSessions/UserOtherSessions/UserOtherSessionsModels.swift # RiotSwiftUI/Modules/UserSessions/UserOtherSessions/UserOtherSessionsViewModel.swift # RiotSwiftUI/Modules/UserSessions/UserSessionOverview/UserSessionOverviewModels.swift # RiotSwiftUI/Modules/UserSessions/UserSessionOverview/UserSessionOverviewViewModel.swift # RiotSwiftUI/Modules/UserSessions/UserSessionOverview/View/UserSessionOverview.swift
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
extension Label where Title == Text, Icon == Image {
|
||||
init(showLocationInfo: Bool) {
|
||||
let text = showLocationInfo ? VectorL10n.userSessionsHideLocationInfo : VectorL10n.userSessionsShowLocationInfo
|
||||
let image = showLocationInfo ? "eye.slash" : "eye"
|
||||
self.init(text, systemImage: image)
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,9 @@ struct UserSessionCardView: View {
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
}
|
||||
|
||||
let showLocationInformations: Bool
|
||||
private var showExtraInformations: Bool {
|
||||
viewData.isCurrentSessionDisplayMode == false && (viewData.lastActivityDateString.isEmptyOrNil == false || viewData.lastSeenIPInfo.isEmptyOrNil == false)
|
||||
viewData.isCurrentSessionDisplayMode == false && (viewData.lastActivityDateString.isEmptyOrNil == false || ipText.isEmptyOrNil == false)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -70,8 +71,8 @@ struct UserSessionCardView: View {
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
}
|
||||
if let lastSeenIPInfo = viewData.lastSeenIPInfo, lastSeenIPInfo.isEmpty == false {
|
||||
Text(lastSeenIPInfo)
|
||||
if showLocationInformations, let ipText = ipText {
|
||||
Text(ipText)
|
||||
.font(theme.fonts.footnote)
|
||||
.foregroundColor(theme.colors.secondaryContent)
|
||||
.multilineTextAlignment(.center)
|
||||
@@ -110,6 +111,13 @@ struct UserSessionCardView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var ipText: String? {
|
||||
guard let lastSeenIp = viewData.lastSeenIP, !lastSeenIp.isEmpty else {
|
||||
return nil
|
||||
}
|
||||
return viewData.lastSeenIPLocation.map { "\(lastSeenIp) (\($0))" } ?? lastSeenIp
|
||||
}
|
||||
}
|
||||
|
||||
struct UserSessionCardViewPreview: View {
|
||||
@@ -139,7 +147,7 @@ struct UserSessionCardViewPreview: View {
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
UserSessionCardView(viewData: viewData)
|
||||
UserSessionCardView(viewData: viewData, showLocationInformations: true)
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(theme.colors.system)
|
||||
|
||||
@@ -34,7 +34,8 @@ struct UserSessionCardViewData {
|
||||
|
||||
var lastActivityIcon: String?
|
||||
|
||||
let lastSeenIPInfo: String?
|
||||
let lastSeenIP: String?
|
||||
let lastSeenIPLocation: String?
|
||||
|
||||
let deviceAvatarViewData: DeviceAvatarViewData
|
||||
|
||||
@@ -95,6 +96,7 @@ struct UserSessionCardViewData {
|
||||
verificationState: UserSessionInfo.VerificationState,
|
||||
lastActivityTimestamp: TimeInterval?,
|
||||
lastSeenIP: String?,
|
||||
lastSeenIPLocation: String?,
|
||||
isCurrentSessionDisplayMode: Bool = false,
|
||||
isActive: Bool) {
|
||||
self.sessionId = sessionId
|
||||
@@ -112,7 +114,8 @@ struct UserSessionCardViewData {
|
||||
}
|
||||
}
|
||||
self.lastActivityDateString = lastActivityDateString
|
||||
lastSeenIPInfo = lastSeenIP
|
||||
self.lastSeenIP = lastSeenIP
|
||||
self.lastSeenIPLocation = lastSeenIPLocation
|
||||
deviceAvatarViewData = DeviceAvatarViewData(deviceType: deviceType, verificationState: verificationState)
|
||||
|
||||
self.isCurrentSessionDisplayMode = isCurrentSessionDisplayMode
|
||||
@@ -127,6 +130,7 @@ extension UserSessionCardViewData {
|
||||
verificationState: sessionInfo.verificationState,
|
||||
lastActivityTimestamp: sessionInfo.lastSeenTimestamp,
|
||||
lastSeenIP: sessionInfo.lastSeenIP,
|
||||
lastSeenIPLocation: sessionInfo.lastSeenIPLocation,
|
||||
isCurrentSessionDisplayMode: sessionInfo.isCurrent,
|
||||
isActive: sessionInfo.isActive)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user