WIP: refactor open group invitation view with SwiftUI
This commit is contained in:
parent
a943df4f9e
commit
0c7b64b41c
|
@ -112,6 +112,7 @@
|
|||
7B4C75CD26BB92060000AC89 /* DeletedMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4C75CC26BB92060000AC89 /* DeletedMessageView.swift */; };
|
||||
7B50D64D28AC7CF80086CCEC /* silence.aiff in Resources */ = {isa = PBXBuildFile; fileRef = 7B50D64C28AC7CF80086CCEC /* silence.aiff */; };
|
||||
7B521E0A29BFF84400C3C36A /* GroupLeavingJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B521E0929BFF84400C3C36A /* GroupLeavingJob.swift */; };
|
||||
7B5802992AAEF1B50050EEB1 /* OpenGroupInvitationView_SwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5802982AAEF1B50050EEB1 /* OpenGroupInvitationView_SwiftUI.swift */; };
|
||||
7B7037432834B81F000DCF35 /* ReactionContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B7037422834B81F000DCF35 /* ReactionContainerView.swift */; };
|
||||
7B7037452834BCC0000DCF35 /* ReactionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B7037442834BCC0000DCF35 /* ReactionView.swift */; };
|
||||
7B7CB18E270D066F0079FF93 /* IncomingCallBanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B7CB18D270D066F0079FF93 /* IncomingCallBanner.swift */; };
|
||||
|
@ -1228,6 +1229,7 @@
|
|||
7B4C75CC26BB92060000AC89 /* DeletedMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeletedMessageView.swift; sourceTree = "<group>"; };
|
||||
7B50D64C28AC7CF80086CCEC /* silence.aiff */ = {isa = PBXFileReference; lastKnownFileType = audio.aiff; path = silence.aiff; sourceTree = "<group>"; };
|
||||
7B521E0929BFF84400C3C36A /* GroupLeavingJob.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupLeavingJob.swift; sourceTree = "<group>"; };
|
||||
7B5802982AAEF1B50050EEB1 /* OpenGroupInvitationView_SwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenGroupInvitationView_SwiftUI.swift; sourceTree = "<group>"; };
|
||||
7B7037422834B81F000DCF35 /* ReactionContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactionContainerView.swift; sourceTree = "<group>"; };
|
||||
7B7037442834BCC0000DCF35 /* ReactionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactionView.swift; sourceTree = "<group>"; };
|
||||
7B7CB18D270D066F0079FF93 /* IncomingCallBanner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IncomingCallBanner.swift; sourceTree = "<group>"; };
|
||||
|
@ -2464,6 +2466,7 @@
|
|||
7BAFA7592AAEA281001DA43E /* LinkPreviewView_SwiftUI.swift */,
|
||||
B8D84EA225DF745A005A043E /* LinkPreviewState.swift */,
|
||||
B8EB20EF2640F7F000773E52 /* OpenGroupInvitationView.swift */,
|
||||
7B5802982AAEF1B50050EEB1 /* OpenGroupInvitationView_SwiftUI.swift */,
|
||||
7B4C75CC26BB92060000AC89 /* DeletedMessageView.swift */,
|
||||
7B7037422834B81F000DCF35 /* ReactionContainerView.swift */,
|
||||
7B7037442834BCC0000DCF35 /* ReactionView.swift */,
|
||||
|
@ -6170,6 +6173,7 @@
|
|||
FDF848F529413EEC007DCAE5 /* SessionCell+Styling.swift in Sources */,
|
||||
7BFD1A8A2745C4F000FB91B9 /* Permissions.swift in Sources */,
|
||||
B85357BF23A1AE0800AAF6CD /* SeedReminderView.swift in Sources */,
|
||||
7B5802992AAEF1B50050EEB1 /* OpenGroupInvitationView_SwiftUI.swift in Sources */,
|
||||
FD716E6C28505E1C00C96BF4 /* MessageRequestsViewModel.swift in Sources */,
|
||||
C35E8AAE2485E51D00ACB629 /* IP2Country.swift in Sources */,
|
||||
B835249B25C3AB650089A44F /* VisibleMessageCell.swift in Sources */,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
|
||||
|
||||
import SwiftUI
|
||||
import NVActivityIndicatorView
|
||||
import NVActivityIndicatorView // TODO: Loading view
|
||||
import SessionUIKit
|
||||
import SessionMessagingKit
|
||||
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
|
||||
|
||||
import SwiftUI
|
||||
import SessionUIKit
|
||||
import SessionMessagingKit
|
||||
|
||||
struct OpenGroupInvitationView_SwiftUI: View {
|
||||
private let name: String
|
||||
private let url: String
|
||||
private let textColor: ThemeValue
|
||||
private let isOutgoing: Bool
|
||||
|
||||
private static let iconSize: CGFloat = 24
|
||||
private static let iconImageViewSize: CGFloat = 48
|
||||
|
||||
init(
|
||||
name: String,
|
||||
url: String,
|
||||
textColor: ThemeValue,
|
||||
isOutgoing: Bool
|
||||
) {
|
||||
self.name = name
|
||||
self.url = {
|
||||
if let range = url.range(of: "?public_key=") {
|
||||
return String(url[..<range.lowerBound])
|
||||
}
|
||||
|
||||
return url
|
||||
}()
|
||||
self.textColor = textColor
|
||||
self.isOutgoing = isOutgoing
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(
|
||||
alignment: .center,
|
||||
spacing: Values.mediumSpacing
|
||||
) {
|
||||
// Icon
|
||||
let iconName = (isOutgoing ? "Globe" : "Plus")
|
||||
if let iconImage = UIImage(named: iconName)?
|
||||
.resizedImage(to: CGSize(width: Self.iconSize, height: Self.iconSize))?
|
||||
.withRenderingMode(.alwaysTemplate)
|
||||
{
|
||||
Image(uiImage: iconImage)
|
||||
.foregroundColor(themeColor: (isOutgoing ? .messageBubble_outgoingText : .textPrimary))
|
||||
.background(
|
||||
Circle()
|
||||
.fill(themeColor: (isOutgoing ? .messageBubble_overlay : .primary))
|
||||
.frame(
|
||||
width: Self.iconImageViewSize,
|
||||
height: Self.iconImageViewSize
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// Text
|
||||
VStack(
|
||||
spacing: 2
|
||||
) {
|
||||
Text(name)
|
||||
.bold()
|
||||
.font(.system(size: Values.largeFontSize))
|
||||
.foregroundColor(themeColor: textColor)
|
||||
|
||||
Text("view_open_group_invitation_description".localized())
|
||||
.font(.system(size: Values.smallFontSize))
|
||||
.foregroundColor(themeColor: textColor)
|
||||
.padding(.bottom, 2)
|
||||
|
||||
Text(url)
|
||||
.font(.system(size: Values.verySmallFontSize))
|
||||
.foregroundColor(themeColor: textColor)
|
||||
.multilineTextAlignment(.leading)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct OpenGroupInvitationView_SwiftUI_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
OpenGroupInvitationView_SwiftUI(
|
||||
name: "Session",
|
||||
url: "",
|
||||
textColor: .messageBubble_outgoingText,
|
||||
isOutgoing: true
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue