mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-26 11:30:50 +02:00
Configured and applied SwiftFormat
This commit is contained in:
committed by
Stefan Ceriu
parent
ff2e6ddfa7
commit
43c28d23b7
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -24,7 +24,7 @@ struct UserSessionInfo: Identifiable {
|
||||
// MARK: - Properties
|
||||
|
||||
var id: String {
|
||||
return sessionId
|
||||
sessionId
|
||||
}
|
||||
|
||||
/// The session identifier
|
||||
@@ -56,7 +56,6 @@ struct UserSessionInfo: Identifiable {
|
||||
isVerified: Bool,
|
||||
lastSeenIP: String?,
|
||||
lastSeenTimestamp: TimeInterval?) {
|
||||
|
||||
self.sessionId = sessionId
|
||||
self.sessionName = sessionName
|
||||
self.deviceType = deviceType
|
||||
|
||||
@@ -29,7 +29,6 @@ class UserSessionLastActivityFormatter {
|
||||
|
||||
/// Session last activity string
|
||||
func lastActivityDateString(from lastActivityTimestamp: TimeInterval) -> String {
|
||||
|
||||
let date = Date(timeIntervalSince1970: lastActivityTimestamp)
|
||||
|
||||
return UserSessionLastActivityFormatter.lastActivityDateFormatter.string(from: date)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -17,7 +17,7 @@
|
||||
import Foundation
|
||||
|
||||
/// Enables to build user session name
|
||||
class UserSessionNameFormatter {
|
||||
class UserSessionNameFormatter {
|
||||
/// Session name with client name and session display name
|
||||
func sessionName(deviceType: DeviceType, sessionDisplayName: String?) -> String {
|
||||
let sessionName: String
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import DesignKit
|
||||
import SwiftUI
|
||||
|
||||
/// Avatar view for device
|
||||
struct DeviceAvatarView: View {
|
||||
@@ -28,7 +28,6 @@ struct DeviceAvatarView: View {
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .bottomTrailing) {
|
||||
|
||||
// Device image
|
||||
VStack(alignment: .center) {
|
||||
viewData.deviceType.image
|
||||
@@ -40,7 +39,6 @@ struct DeviceAvatarView: View {
|
||||
|
||||
// Verification badge
|
||||
if let isVerified = viewData.isVerified {
|
||||
|
||||
Image(isVerified ? Asset.Images.userSessionVerified.name : Asset.Images.userSessionUnverified.name)
|
||||
.frame(maxWidth: CGFloat(badgeSize), maxHeight: CGFloat(badgeSize))
|
||||
.shapedBorder(color: theme.colors.system, borderWidth: 1, shape: Circle())
|
||||
@@ -55,7 +53,7 @@ struct DeviceAvatarView: View {
|
||||
|
||||
struct DeviceAvatarViewListPreview: View {
|
||||
var viewDataList: [DeviceAvatarViewData] {
|
||||
return [
|
||||
[
|
||||
DeviceAvatarViewData(deviceType: .desktop, isVerified: true),
|
||||
DeviceAvatarViewData(deviceType: .web, isVerified: true),
|
||||
DeviceAvatarViewData(deviceType: .mobile, isVerified: true),
|
||||
@@ -66,7 +64,7 @@ struct DeviceAvatarViewListPreview: View {
|
||||
var body: some View {
|
||||
HStack {
|
||||
VStack(alignment: .center, spacing: 20) {
|
||||
DeviceAvatarView(viewData: DeviceAvatarViewData.init(deviceType: .web, isVerified: true))
|
||||
DeviceAvatarView(viewData: DeviceAvatarViewData(deviceType: .web, isVerified: true))
|
||||
DeviceAvatarView(viewData: DeviceAvatarViewData(deviceType: .desktop, isVerified: false))
|
||||
DeviceAvatarView(viewData: DeviceAvatarViewData(deviceType: .mobile, isVerified: true))
|
||||
DeviceAvatarView(viewData: DeviceAvatarViewData(deviceType: .unknown, isVerified: false))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -14,40 +14,40 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import DesignKit
|
||||
import SwiftUI
|
||||
|
||||
struct UserSessionCardView: View {
|
||||
@Environment(\.theme) var theme: ThemeSwiftUI
|
||||
|
||||
var viewData: UserSessionCardViewData
|
||||
|
||||
var onVerifyAction: ((String) -> (Void))? = nil
|
||||
var onViewDetailsAction: ((String) -> (Void))? = nil
|
||||
var onLearnMoreAction: (() -> (Void))? = nil
|
||||
var onVerifyAction: ((String) -> Void)?
|
||||
var onViewDetailsAction: ((String) -> Void)?
|
||||
var onLearnMoreAction: (() -> Void)?
|
||||
|
||||
private var verificationStatusImageName: String {
|
||||
return viewData.isVerified ? Asset.Images.userSessionVerified.name : Asset.Images.userSessionUnverified.name
|
||||
viewData.isVerified ? Asset.Images.userSessionVerified.name : Asset.Images.userSessionUnverified.name
|
||||
}
|
||||
|
||||
private var verificationStatusText: String {
|
||||
return viewData.isVerified ? VectorL10n.userSessionVerified : VectorL10n.userSessionUnverified
|
||||
viewData.isVerified ? VectorL10n.userSessionVerified : VectorL10n.userSessionUnverified
|
||||
}
|
||||
|
||||
private var verificationStatusColor: Color {
|
||||
return viewData.isVerified ? theme.colors.accent : theme.colors.alert
|
||||
viewData.isVerified ? theme.colors.accent : theme.colors.alert
|
||||
}
|
||||
|
||||
private var verificationStatusAdditionalInfoText: String {
|
||||
return viewData.isVerified ? VectorL10n.userSessionVerifiedAdditionalInfo : VectorL10n.userSessionUnverifiedAdditionalInfo
|
||||
viewData.isVerified ? VectorL10n.userSessionVerifiedAdditionalInfo : VectorL10n.userSessionUnverifiedAdditionalInfo
|
||||
}
|
||||
|
||||
private var backgroundShape: RoundedRectangle {
|
||||
return RoundedRectangle(cornerRadius: 8)
|
||||
RoundedRectangle(cornerRadius: 8)
|
||||
}
|
||||
|
||||
private var showExtraInformations: Bool {
|
||||
return viewData.isCurrentSessionDisplayMode == false && (viewData.lastActivityDateString.isEmptyOrNil == false || viewData.lastSeenIPInfo.isEmptyOrNil == false)
|
||||
viewData.isCurrentSessionDisplayMode == false && (viewData.lastActivityDateString.isEmptyOrNil == false || viewData.lastSeenIPInfo.isEmptyOrNil == false)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -90,7 +90,7 @@ struct UserSessionCardView: View {
|
||||
.multilineTextAlignment(.center)
|
||||
}
|
||||
|
||||
if let lastSeenIPInfo = viewData.lastSeenIPInfo, lastSeenIPInfo.isEmpty == false {
|
||||
if let lastSeenIPInfo = viewData.lastSeenIPInfo, lastSeenIPInfo.isEmpty == false {
|
||||
Text(lastSeenIPInfo)
|
||||
.font(theme.fonts.footnote)
|
||||
.foregroundColor(theme.colors.secondaryContent)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -22,7 +22,7 @@ struct UserSessionCardViewData {
|
||||
private static let lastActivityDateFormatter = UserSessionLastActivityFormatter()
|
||||
|
||||
var id: String {
|
||||
return sessionId
|
||||
sessionId
|
||||
}
|
||||
|
||||
let sessionId: String
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -111,6 +111,6 @@ final class UserSessionsFlowCoordinator: Coordinator, Presentable {
|
||||
}
|
||||
|
||||
func toPresentable() -> UIViewController {
|
||||
return navigationRouter.toPresentable()
|
||||
navigationRouter.toPresentable()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import CommonKit
|
||||
import SwiftUI
|
||||
|
||||
struct UserSessionDetailsCoordinatorParameters {
|
||||
let userSessionInfo: UserSessionInfo
|
||||
@@ -63,6 +63,6 @@ final class UserSessionDetailsCoordinator: Coordinator, Presentable {
|
||||
}
|
||||
|
||||
func toPresentable() -> UIViewController {
|
||||
return userSessionDetailsHostingController
|
||||
userSessionDetailsHostingController
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -33,11 +33,11 @@ enum MockUserSessionDetailsScreenState: MockScreenState, CaseIterable {
|
||||
/// A list of screen state definitions
|
||||
static var allCases: [MockUserSessionDetailsScreenState] {
|
||||
// Each of the presence statuses
|
||||
return [.allSections, .sessionSectionOnly]
|
||||
[.allSections, .sessionSectionOnly]
|
||||
}
|
||||
|
||||
/// Generate the view struct for the screen state.
|
||||
var screenView: ([Any], AnyView) {
|
||||
var screenView: ([Any], AnyView) {
|
||||
let currentSessionInfo: UserSessionInfo
|
||||
switch self {
|
||||
case .allSections:
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import RiotSwiftUI
|
||||
import XCTest
|
||||
|
||||
class UserSessionDetailsUITests: MockScreenTestCase {
|
||||
func test_longPressDetailsCell_CopiesValueToClipboard() throws {
|
||||
@@ -30,6 +30,6 @@ class UserSessionDetailsUITests: MockScreenTestCase {
|
||||
app.buttons["Copy"].tap()
|
||||
|
||||
let clipboard = try XCTUnwrap(UIPasteboard.general.string)
|
||||
XCTAssertEqual(clipboard,"iOS")
|
||||
XCTAssertEqual(clipboard, "iOS")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -96,7 +96,6 @@ class UserSessionDetailsViewModelTests: XCTestCase {
|
||||
isVerified: isVerified,
|
||||
lastSeenIP: lastSeenIP,
|
||||
lastSeenTimestamp: lastSeenTimestamp)
|
||||
|
||||
}
|
||||
|
||||
private func sessionNameItem(sessionName: String) -> UserSessionDetailsSectionItemViewData {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -20,13 +20,11 @@ import Foundation
|
||||
|
||||
// MARK: View model
|
||||
|
||||
enum UserSessionDetailsViewModelResult {
|
||||
}
|
||||
enum UserSessionDetailsViewModelResult { }
|
||||
|
||||
// MARK: View
|
||||
|
||||
enum UserSessionDetailsViewAction {
|
||||
}
|
||||
enum UserSessionDetailsViewAction { }
|
||||
|
||||
struct UserSessionDetailsViewState: BindableState, Equatable {
|
||||
let sections: [UserSessionDetailsSectionViewData]
|
||||
@@ -48,14 +46,14 @@ struct UserSessionDetailsSectionItemViewData: Identifiable {
|
||||
extension UserSessionDetailsSectionViewData: Equatable {
|
||||
static func == (lhs: UserSessionDetailsSectionViewData, rhs: UserSessionDetailsSectionViewData) -> Bool {
|
||||
lhs.header == rhs.header &&
|
||||
lhs.footer == rhs.footer &&
|
||||
lhs.items == rhs.items
|
||||
lhs.footer == rhs.footer &&
|
||||
lhs.items == rhs.items
|
||||
}
|
||||
}
|
||||
|
||||
extension UserSessionDetailsSectionItemViewData: Equatable {
|
||||
static func == (lhs: UserSessionDetailsSectionItemViewData, rhs: UserSessionDetailsSectionItemViewData) -> Bool {
|
||||
lhs.title == rhs.title &&
|
||||
lhs.value == rhs.value
|
||||
lhs.value == rhs.value
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@
|
||||
import Foundation
|
||||
|
||||
typealias UserSessionDetailsViewModelType = StateStoreViewModel<UserSessionDetailsViewState,
|
||||
Never,
|
||||
UserSessionDetailsViewAction>
|
||||
Never,
|
||||
UserSessionDetailsViewAction>
|
||||
|
||||
class UserSessionDetailsViewModel: UserSessionDetailsViewModelType, UserSessionDetailsViewModelProtocol {
|
||||
var completion: ((UserSessionDetailsViewModelResult) -> Void)?
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -28,7 +28,7 @@ struct UserSessionDetailsItem: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack() {
|
||||
HStack {
|
||||
Text(viewData.title)
|
||||
.font(theme.fonts.subheadline)
|
||||
.foregroundColor(theme.colors.secondaryContent)
|
||||
@@ -59,10 +59,10 @@ struct UserSessionDetailsItem_Previews: PreviewProvider {
|
||||
List {
|
||||
UserSessionDetailsItem(viewData: UserSessionDetailsSectionItemViewData(title: "Session name",
|
||||
value: "Element Web: Firefox on macOS"))
|
||||
.listRowInsets(EdgeInsets())
|
||||
.listRowInsets(EdgeInsets())
|
||||
UserSessionDetailsItem(viewData: UserSessionDetailsSectionItemViewData(title: "Session ID",
|
||||
value: "76c95352559d-react-7c57680b93db-js-b64dbdce74b0"))
|
||||
.listRowInsets(EdgeInsets())
|
||||
.listRowInsets(EdgeInsets())
|
||||
}
|
||||
.preferredColorScheme(.light)
|
||||
|
||||
@@ -70,10 +70,10 @@ struct UserSessionDetailsItem_Previews: PreviewProvider {
|
||||
List {
|
||||
UserSessionDetailsItem(viewData: UserSessionDetailsSectionItemViewData(title: "Session name",
|
||||
value: "Element Web: Firefox on macOS"))
|
||||
.listRowInsets(EdgeInsets())
|
||||
.listRowInsets(EdgeInsets())
|
||||
UserSessionDetailsItem(viewData: UserSessionDetailsSectionItemViewData(title: "Session ID",
|
||||
value: "76c95352559d-react-7c57680b93db-js-b64dbdce74b0"))
|
||||
.listRowInsets(EdgeInsets())
|
||||
.listRowInsets(EdgeInsets())
|
||||
}
|
||||
.preferredColorScheme(.dark)
|
||||
.theme(.dark)
|
||||
|
||||
+3
-3
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import CommonKit
|
||||
import SwiftUI
|
||||
|
||||
struct UserSessionOverviewCoordinatorParameters {
|
||||
let userSessionInfo: UserSessionInfo
|
||||
@@ -58,7 +58,7 @@ final class UserSessionOverviewCoordinator: Coordinator, Presentable {
|
||||
MXLog.debug("[UserSessionOverviewCoordinator] UserSessionOverviewViewModel did complete with result: \(result).")
|
||||
switch result {
|
||||
case .verifyCurrentSession:
|
||||
break // TODO
|
||||
break // TODO:
|
||||
case let .showSessionDetails(sessionInfo: sessionInfo):
|
||||
self.completion?(.openSessionDetails(session: sessionInfo))
|
||||
}
|
||||
@@ -66,7 +66,7 @@ final class UserSessionOverviewCoordinator: Coordinator, Presentable {
|
||||
}
|
||||
|
||||
func toPresentable() -> UIViewController {
|
||||
return hostingController
|
||||
hostingController
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
+13
-13
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -34,28 +34,28 @@ enum MockUserSessionOverviewScreenState: MockScreenState, CaseIterable {
|
||||
/// A list of screen state definitions
|
||||
static var allCases: [MockUserSessionOverviewScreenState] {
|
||||
// Each of the presence statuses
|
||||
return [.currentSession, .otherSession]
|
||||
[.currentSession, .otherSession]
|
||||
}
|
||||
|
||||
/// Generate the view struct for the screen state.
|
||||
var screenView: ([Any], AnyView) {
|
||||
var screenView: ([Any], AnyView) {
|
||||
let viewModel: UserSessionOverviewViewModel
|
||||
switch self {
|
||||
case .currentSession:
|
||||
let currentSessionInfo = UserSessionInfo(sessionId: "session",
|
||||
sessionName: "iOS",
|
||||
deviceType: .mobile,
|
||||
isVerified: false,
|
||||
lastSeenIP: "10.0.0.10",
|
||||
lastSeenTimestamp: Date().timeIntervalSince1970 - 100)
|
||||
sessionName: "iOS",
|
||||
deviceType: .mobile,
|
||||
isVerified: false,
|
||||
lastSeenIP: "10.0.0.10",
|
||||
lastSeenTimestamp: Date().timeIntervalSince1970 - 100)
|
||||
viewModel = UserSessionOverviewViewModel(userSessionInfo: currentSessionInfo, isCurrentSession: true)
|
||||
case .otherSession:
|
||||
let currentSessionInfo = UserSessionInfo(sessionId: "session",
|
||||
sessionName: "Mac",
|
||||
deviceType: .desktop,
|
||||
isVerified: true,
|
||||
lastSeenIP: "10.0.0.10",
|
||||
lastSeenTimestamp: Date().timeIntervalSince1970 - 100)
|
||||
sessionName: "Mac",
|
||||
deviceType: .desktop,
|
||||
isVerified: true,
|
||||
lastSeenIP: "10.0.0.10",
|
||||
lastSeenTimestamp: Date().timeIntervalSince1970 - 100)
|
||||
viewModel = UserSessionOverviewViewModel(userSessionInfo: currentSessionInfo, isCurrentSession: false)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import RiotSwiftUI
|
||||
import XCTest
|
||||
|
||||
class UserSessionOverviewUITests: MockScreenTestCase {
|
||||
func test_whenCurrentSessionSelected_correctNavTittleDisplayed() {
|
||||
|
||||
+7
-7
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Combine
|
||||
import XCTest
|
||||
|
||||
@testable import RiotSwiftUI
|
||||
|
||||
@@ -47,10 +47,10 @@ class UserSessionOverviewViewModelTests: XCTestCase {
|
||||
|
||||
private func createUserSessionInfo() -> UserSessionInfo {
|
||||
UserSessionInfo(sessionId: "session",
|
||||
sessionName: "iOS",
|
||||
deviceType: .mobile,
|
||||
isVerified: false,
|
||||
lastSeenIP: "10.0.0.10",
|
||||
lastSeenTimestamp: Date().timeIntervalSince1970 - 100)
|
||||
sessionName: "iOS",
|
||||
deviceType: .mobile,
|
||||
isVerified: false,
|
||||
lastSeenIP: "10.0.0.10",
|
||||
lastSeenTimestamp: Date().timeIntervalSince1970 - 100)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@
|
||||
import SwiftUI
|
||||
|
||||
typealias UserSessionOverviewViewModelType = StateStoreViewModel<UserSessionOverviewViewState,
|
||||
Never,
|
||||
UserSessionOverviewViewAction>
|
||||
Never,
|
||||
UserSessionOverviewViewAction>
|
||||
|
||||
class UserSessionOverviewViewModel: UserSessionOverviewViewModelType, UserSessionOverviewViewModelProtocol {
|
||||
private let userSessionInfo: UserSessionInfo
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2021 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
@@ -25,12 +25,12 @@ struct UserSessionOverview: View {
|
||||
ScrollView {
|
||||
UserSessionCardView(viewData: viewModel.viewState.cardViewData,
|
||||
onVerifyAction: { _ in
|
||||
viewModel.send(viewAction: .verifyCurrentSession)
|
||||
},
|
||||
viewModel.send(viewAction: .verifyCurrentSession)
|
||||
},
|
||||
onViewDetailsAction: { _ in
|
||||
viewModel.send(viewAction: .viewSessionDetails)
|
||||
})
|
||||
.padding(16)
|
||||
viewModel.send(viewAction: .viewSessionDetails)
|
||||
})
|
||||
.padding(16)
|
||||
SwiftUI.Section {
|
||||
UserSessionOverviewDisclosureCell(title: VectorL10n.userSessionOverviewSessionDetailsButtonTitle, onBackgroundTap: {
|
||||
viewModel.send(viewAction: .viewSessionDetails)
|
||||
@@ -40,8 +40,8 @@ struct UserSessionOverview: View {
|
||||
.background(theme.colors.system.ignoresSafeArea())
|
||||
.frame(maxHeight: .infinity)
|
||||
.navigationTitle(viewModel.viewState.isCurrentSession ?
|
||||
VectorL10n.userSessionOverviewCurrentSessionTitle :
|
||||
VectorL10n.userSessionOverviewSessionTitle)
|
||||
VectorL10n.userSessionOverviewCurrentSessionTitle :
|
||||
VectorL10n.userSessionOverviewSessionTitle)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -20,13 +20,13 @@ struct UserSessionOverviewDisclosureCell: View {
|
||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||
|
||||
let title: String
|
||||
var onBackgroundTap: (() -> (Void))? = nil
|
||||
var onBackgroundTap: (() -> Void)?
|
||||
|
||||
var body: some View {
|
||||
Button(action: { onBackgroundTap?()}) {
|
||||
Button(action: { onBackgroundTap?() }) {
|
||||
VStack(spacing: 0) {
|
||||
SeparatorLine()
|
||||
HStack() {
|
||||
HStack {
|
||||
Text(title)
|
||||
.font(theme.fonts.body)
|
||||
.foregroundColor(theme.colors.primaryContent)
|
||||
|
||||
+6
-6
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import CommonKit
|
||||
import SwiftUI
|
||||
|
||||
struct UserSessionsOverviewCoordinatorParameters {
|
||||
let session: MXSession
|
||||
@@ -69,7 +69,7 @@ final class UserSessionsOverviewCoordinator: Coordinator, Presentable {
|
||||
}
|
||||
|
||||
func toPresentable() -> UIViewController {
|
||||
return hostingViewController
|
||||
hostingViewController
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
@@ -88,15 +88,15 @@ final class UserSessionsOverviewCoordinator: Coordinator, Presentable {
|
||||
}
|
||||
|
||||
private func showAllUnverifiedSessions() {
|
||||
// TODO
|
||||
// TODO:
|
||||
}
|
||||
|
||||
private func showAllInactiveSessions() {
|
||||
// TODO
|
||||
// TODO:
|
||||
}
|
||||
|
||||
private func startVerifyCurrentSession() {
|
||||
// TODO
|
||||
// TODO:
|
||||
}
|
||||
|
||||
private func showCurrentSessionOverview(sessionInfo: UserSessionInfo) {
|
||||
@@ -108,6 +108,6 @@ final class UserSessionsOverviewCoordinator: Coordinator, Presentable {
|
||||
}
|
||||
|
||||
private func showAllOtherSessions() {
|
||||
// TODO
|
||||
// TODO:
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -33,12 +33,12 @@ enum MockUserSessionsOverviewScreenState: MockScreenState, CaseIterable {
|
||||
/// A list of screen state definitions
|
||||
static var allCases: [MockUserSessionsOverviewScreenState] {
|
||||
// Each of the presence statuses
|
||||
return [.verifiedSession]
|
||||
[.verifiedSession]
|
||||
}
|
||||
|
||||
/// Generate the view struct for the screen state.
|
||||
var screenView: ([Any], AnyView) {
|
||||
let service: MockUserSessionsOverviewService = MockUserSessionsOverviewService()
|
||||
var screenView: ([Any], AnyView) {
|
||||
let service = MockUserSessionsOverviewService()
|
||||
switch self {
|
||||
case .verifiedSession:
|
||||
break
|
||||
|
||||
+5
-5
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -25,10 +25,10 @@ class UserSessionsOverviewService: UserSessionsOverviewServiceProtocol {
|
||||
init(mxSession: MXSession) {
|
||||
self.mxSession = mxSession
|
||||
|
||||
overviewData = UserSessionsOverviewData(currentSession: nil,
|
||||
unverifiedSessions: [],
|
||||
inactiveSessions: [],
|
||||
otherSessions: [])
|
||||
overviewData = UserSessionsOverviewData(currentSession: nil,
|
||||
unverifiedSessions: [],
|
||||
inactiveSessions: [],
|
||||
otherSessions: [])
|
||||
|
||||
setupInitialOverviewData()
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -35,14 +35,14 @@ class MockUserSessionsOverviewService: UserSessionsOverviewServiceProtocol {
|
||||
let inactiveSessionsInfo: [UserSessionInfo] = []
|
||||
|
||||
let otherSessionsInfo: [UserSessionInfo] = [
|
||||
UserSessionInfo(sessionId: "1", sessionName: "macOS", deviceType: .desktop, isVerified: true, lastSeenIP: "1.0.0.1", lastSeenTimestamp: (Date().timeIntervalSince1970 - 130000)),
|
||||
UserSessionInfo(sessionId: "2", sessionName: "Firefox on Windows", deviceType: .web, isVerified: true, lastSeenIP: "2.0.0.2", lastSeenTimestamp: (Date().timeIntervalSince1970 - 100)),
|
||||
UserSessionInfo(sessionId: "3", sessionName: "Android", deviceType: .mobile, isVerified: false, lastSeenIP: "3.0.0.3", lastSeenTimestamp: (Date().timeIntervalSince1970 - 10))
|
||||
UserSessionInfo(sessionId: "1", sessionName: "macOS", deviceType: .desktop, isVerified: true, lastSeenIP: "1.0.0.1", lastSeenTimestamp: Date().timeIntervalSince1970 - 130_000),
|
||||
UserSessionInfo(sessionId: "2", sessionName: "Firefox on Windows", deviceType: .web, isVerified: true, lastSeenIP: "2.0.0.2", lastSeenTimestamp: Date().timeIntervalSince1970 - 100),
|
||||
UserSessionInfo(sessionId: "3", sessionName: "Android", deviceType: .mobile, isVerified: false, lastSeenIP: "3.0.0.3", lastSeenTimestamp: Date().timeIntervalSince1970 - 10)
|
||||
]
|
||||
|
||||
overviewData = UserSessionsOverviewData(currentSession: currentSessionInfo,
|
||||
unverifiedSessions: unverifiedSessionsInfo,
|
||||
inactiveSessions: inactiveSessionsInfo,
|
||||
otherSessions: otherSessionsInfo)
|
||||
unverifiedSessions: unverifiedSessionsInfo,
|
||||
inactiveSessions: inactiveSessionsInfo,
|
||||
otherSessions: otherSessionsInfo)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
+1
-1
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import RiotSwiftUI
|
||||
import XCTest
|
||||
|
||||
class UserSessionsOverviewUITests: MockScreenTestCase {
|
||||
// TODO:
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -14,8 +14,8 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Combine
|
||||
import XCTest
|
||||
|
||||
@testable import RiotSwiftUI
|
||||
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -44,7 +44,7 @@ struct UserSessionsOverviewViewState: BindableState {
|
||||
|
||||
var otherSessionsViewData = [UserSessionListItemViewData]()
|
||||
|
||||
var showLoadingIndicator: Bool = false
|
||||
var showLoadingIndicator = false
|
||||
}
|
||||
|
||||
enum UserSessionsOverviewViewAction {
|
||||
|
||||
+3
-3
@@ -17,8 +17,8 @@
|
||||
import SwiftUI
|
||||
|
||||
typealias UserSessionsOverviewViewModelType = StateStoreViewModel<UserSessionsOverviewViewState,
|
||||
Never,
|
||||
UserSessionsOverviewViewAction>
|
||||
Never,
|
||||
UserSessionsOverviewViewAction>
|
||||
|
||||
class UserSessionsOverviewViewModel: UserSessionsOverviewViewModelType, UserSessionsOverviewViewModelProtocol {
|
||||
private let userSessionsOverviewService: UserSessionsOverviewServiceProtocol
|
||||
@@ -88,7 +88,7 @@ class UserSessionsOverviewViewModel: UserSessionsOverviewViewModelType, UserSess
|
||||
case .success(let overViewData):
|
||||
self.updateViewState(with: overViewData)
|
||||
case .failure(let error):
|
||||
// TODO
|
||||
// TODO:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ struct UserSessionListItem: View {
|
||||
|
||||
let viewData: UserSessionListItemViewData
|
||||
|
||||
var onBackgroundTap: ((String) -> (Void))? = nil
|
||||
var onBackgroundTap: ((String) -> Void)?
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
@@ -71,7 +71,7 @@ struct UserSessionListPreview: View {
|
||||
ForEach(userSessionsOverviewService.overviewData.otherSessions) { userSessionInfo in
|
||||
let viewData = UserSessionListItemViewData(userSessionInfo: userSessionInfo)
|
||||
|
||||
UserSessionListItem(viewData: viewData, onBackgroundTap: { sessionId in
|
||||
UserSessionListItem(viewData: viewData, onBackgroundTap: { _ in
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
+1
-2
@@ -22,7 +22,7 @@ struct UserSessionListItemViewData: Identifiable {
|
||||
private static let lastActivityDateFormatter = UserSessionLastActivityFormatter()
|
||||
|
||||
var id: String {
|
||||
return sessionId
|
||||
sessionId
|
||||
}
|
||||
|
||||
let sessionId: String
|
||||
@@ -38,7 +38,6 @@ struct UserSessionListItemViewData: Identifiable {
|
||||
deviceType: DeviceType,
|
||||
isVerified: Bool,
|
||||
lastActivityDate: TimeInterval?) {
|
||||
|
||||
self.sessionId = sessionId
|
||||
sessionName = Self.userSessionNameFormatter.sessionName(deviceType: deviceType, sessionDisplayName: sessionDisplayName)
|
||||
sessionDetails = Self.buildSessionDetails(isVerified: isVerified, lastActivityDate: lastActivityDate)
|
||||
|
||||
+2
-3
@@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -49,7 +49,6 @@ struct UserSessionsOverview: View {
|
||||
ScrollView {
|
||||
// Security recommendations section
|
||||
if viewModel.viewState.unverifiedSessionsViewData.isEmpty == false || viewModel.viewState.inactiveSessionsViewData.isEmpty == false {
|
||||
|
||||
// TODO:
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ struct UserSessionsOverview: View {
|
||||
.frame(maxHeight: .infinity)
|
||||
.navigationTitle(VectorL10n.userSessionsOverviewTitle)
|
||||
.activityIndicator(show: viewModel.viewState.showLoadingIndicator)
|
||||
.onAppear() {
|
||||
.onAppear {
|
||||
viewModel.send(viewAction: .viewAppeared)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user