mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 16:42:44 +02:00
Cleaned up various things, mostly removed unnecessary selfs, comments and bad formatting
This commit is contained in:
committed by
Stefan Ceriu
parent
c073dfd95d
commit
eac1401cc1
+3
-14
@@ -17,9 +17,6 @@
|
||||
import SwiftUI
|
||||
|
||||
struct UserSessionListItem: View {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private enum LayoutConstants {
|
||||
static let horizontalPadding: CGFloat = 15
|
||||
static let verticalPadding: CGFloat = 16
|
||||
@@ -27,23 +24,16 @@ struct UserSessionListItem: View {
|
||||
static let avatarRightMargin: CGFloat = 18
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
// MARK: Public
|
||||
|
||||
let viewData: UserSessionListItemViewData
|
||||
|
||||
var onBackgroundTap: ((String) -> (Void))? = nil
|
||||
|
||||
// MARK: - Body
|
||||
|
||||
var body: some View {
|
||||
Button(action: { onBackgroundTap?(self.viewData.sessionId)
|
||||
}) {
|
||||
Button {
|
||||
onBackgroundTap?(viewData.sessionId)
|
||||
} label: {
|
||||
VStack(alignment: .leading, spacing: LayoutConstants.verticalPadding) {
|
||||
HStack(spacing: LayoutConstants.avatarRightMargin) {
|
||||
DeviceAvatarView(viewData: viewData.deviceAvatarViewData)
|
||||
@@ -74,7 +64,6 @@ struct UserSessionListItem: View {
|
||||
}
|
||||
|
||||
struct UserSessionListPreview: View {
|
||||
|
||||
let userSessionsOverviewService: UserSessionsOverviewServiceProtocol = MockUserSessionsOverviewService()
|
||||
|
||||
var body: some View {
|
||||
|
||||
+4
-13
@@ -18,14 +18,9 @@ import Foundation
|
||||
|
||||
/// View data for UserSessionListItem
|
||||
struct UserSessionListItemViewData: Identifiable {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
private static let userSessionNameFormatter = UserSessionNameFormatter()
|
||||
private static let lastActivityDateFormatter = UserSessionLastActivityFormatter()
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
|
||||
var id: String {
|
||||
return sessionId
|
||||
}
|
||||
@@ -38,8 +33,6 @@ struct UserSessionListItemViewData: Identifiable {
|
||||
|
||||
let deviceAvatarViewData: DeviceAvatarViewData
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
init(sessionId: String,
|
||||
sessionDisplayName: String?,
|
||||
deviceType: DeviceType,
|
||||
@@ -47,15 +40,14 @@ struct UserSessionListItemViewData: Identifiable {
|
||||
lastActivityDate: TimeInterval?) {
|
||||
|
||||
self.sessionId = sessionId
|
||||
self.sessionName = Self.userSessionNameFormatter.sessionName(deviceType: deviceType, sessionDisplayName: sessionDisplayName)
|
||||
self.sessionDetails = Self.buildSessionDetails(isVerified: isVerified, lastActivityDate: lastActivityDate)
|
||||
self.deviceAvatarViewData = DeviceAvatarViewData(deviceType: deviceType, isVerified: isVerified)
|
||||
sessionName = Self.userSessionNameFormatter.sessionName(deviceType: deviceType, sessionDisplayName: sessionDisplayName)
|
||||
sessionDetails = Self.buildSessionDetails(isVerified: isVerified, lastActivityDate: lastActivityDate)
|
||||
deviceAvatarViewData = DeviceAvatarViewData(deviceType: deviceType, isVerified: isVerified)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private static func buildSessionDetails(isVerified: Bool, lastActivityDate: TimeInterval?) -> String {
|
||||
|
||||
let sessionDetailsString: String
|
||||
|
||||
let sessionStatusText = isVerified ? VectorL10n.userSessionVerifiedShort : VectorL10n.userSessionUnverifiedShort
|
||||
@@ -77,7 +69,6 @@ struct UserSessionListItemViewData: Identifiable {
|
||||
}
|
||||
|
||||
extension UserSessionListItemViewData {
|
||||
|
||||
init(userSessionInfo: UserSessionInfo) {
|
||||
self.init(sessionId: userSessionInfo.sessionId, sessionDisplayName: userSessionInfo.sessionName, deviceType: userSessionInfo.deviceType, isVerified: userSessionInfo.isVerified, lastActivityDate: userSessionInfo.lastSeenTimestamp)
|
||||
}
|
||||
|
||||
+1
-8
@@ -17,11 +17,6 @@
|
||||
import SwiftUI
|
||||
|
||||
struct UserSessionsOverview: View {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
@ViewBuilder
|
||||
@@ -52,7 +47,6 @@ struct UserSessionsOverview: View {
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
|
||||
// Security recommendations section
|
||||
if viewModel.viewState.unverifiedSessionsViewData.isEmpty == false || viewModel.viewState.inactiveSessionsViewData.isEmpty == false {
|
||||
|
||||
@@ -64,7 +58,7 @@ struct UserSessionsOverview: View {
|
||||
|
||||
// Other sessions section
|
||||
if viewModel.viewState.otherSessionsViewData.isEmpty == false {
|
||||
self.otherSessionsSection
|
||||
otherSessionsSection
|
||||
}
|
||||
}
|
||||
.background(theme.colors.system.ignoresSafeArea())
|
||||
@@ -77,7 +71,6 @@ struct UserSessionsOverview: View {
|
||||
}
|
||||
|
||||
private var otherSessionsSection: some View {
|
||||
|
||||
SwiftUI.Section {
|
||||
// Device list
|
||||
LazyVStack(spacing: 0) {
|
||||
|
||||
Reference in New Issue
Block a user