mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-11-11 13:57:42 +00:00
* ios: snapshot tests render all previews at fixed dates * ios: previews of your servers and terminal render without errors * ios: snapshots fill the screen height for lists, skip device migration * ios: snapshots show the sample user, secondary chat preview has items * ios: snapshots skip previews of live prices, profiles and console * ci: references of all iOS previews * ci: snapshot docs state window height, exclusions and timing * ios: snapshots skip previews with a blinking caret or a spinner * ios: snapshots end editing and stop animations, restoring 8 previews * ci: references of the restored cursor and spinner previews * ios: chat item previews clip items to bubbles as the chat view does * ci: references of chat item previews with bubbles
85 lines
3.1 KiB
Swift
85 lines
3.1 KiB
Swift
//
|
|
// ContactConnectionView.swift
|
|
// SimpleX (iOS)
|
|
//
|
|
// Created by Evgeny on 24/04/2022.
|
|
// Copyright © 2022 SimpleX Chat. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
import SimpleXChat
|
|
|
|
struct ContactConnectionView: View {
|
|
@EnvironmentObject var m: ChatModel
|
|
@ObservedObject var chat: Chat
|
|
@EnvironmentObject var theme: AppTheme
|
|
@Environment(\.dynamicTypeSize) private var userFont: DynamicTypeSize
|
|
@State private var localAlias = ""
|
|
@FocusState private var aliasTextFieldFocused: Bool
|
|
|
|
var body: some View {
|
|
if case let .contactConnection(conn) = chat.chatInfo {
|
|
contactConnectionView(conn)
|
|
}
|
|
}
|
|
|
|
func contactConnectionView(_ contactConnection: PendingContactConnection) -> some View {
|
|
HStack(spacing: 8) {
|
|
Group {
|
|
Image(systemName: contactConnection.initiated ? "link.badge.plus" : "link")
|
|
.resizable()
|
|
.scaledToFill()
|
|
.frame(width: 48, height: 48)
|
|
.foregroundColor(Color(uiColor: .tertiarySystemGroupedBackground).asAnotherColorFromSecondaryVariant(theme))
|
|
}
|
|
.frame(width: 63, height: 63)
|
|
.padding(.leading, 4)
|
|
|
|
VStack(alignment: .leading, spacing: 0) {
|
|
HStack(alignment: .top) {
|
|
Text(contactConnection.chatViewName)
|
|
.font(.title3)
|
|
.bold()
|
|
.allowsTightening(false)
|
|
.foregroundColor(theme.colors.secondary)
|
|
.padding(.horizontal, 8)
|
|
.padding(.top, 1)
|
|
.padding(.bottom, 0.5)
|
|
.frame(alignment: .topLeading)
|
|
|
|
Spacer()
|
|
|
|
formatTimestampText(contactConnection.updatedAt)
|
|
.font(.subheadline)
|
|
.padding(.trailing, 8)
|
|
.padding(.vertical, 4)
|
|
.frame(minWidth: 60, alignment: .trailing)
|
|
.foregroundColor(theme.colors.secondary)
|
|
}
|
|
.padding(.bottom, 2)
|
|
|
|
ZStack(alignment: .topTrailing) {
|
|
Text(contactConnection.description)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
incognitoIcon(contactConnection.incognito, theme.colors.secondary, size: dynamicSize(userFont).incognitoSize)
|
|
.padding(.top, 26)
|
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
|
}
|
|
.padding(.horizontal, 8)
|
|
|
|
Spacer()
|
|
}
|
|
.frame(maxHeight: .infinity)
|
|
}
|
|
}
|
|
}
|
|
|
|
struct ContactConnectionView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
var contactConnection = PendingContactConnection.getSampleData()
|
|
contactConnection.updatedAt = previewDate
|
|
return ContactConnectionView(chat: Chat(chatInfo: .contactConnection(contactConnection: contactConnection)))
|
|
.previewLayout(.fixed(width: 360, height: 80))
|
|
}
|
|
}
|