You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/Session/Home/New Conversation/StartConversationScreen.swift

160 lines
6.7 KiB
Swift

// Copyright © 2024 Rangeproof Pty Ltd. All rights reserved.
import SwiftUI
import SessionUIKit
import SignalUtilitiesKit
import SessionUtilitiesKit
struct StartConversationScreen: View {
@EnvironmentObject var host: HostWrapper
var body: some View {
ZStack(alignment: .topLeading) {
ScrollView(.vertical, showsIndicators: false) {
VStack(
alignment: .leading,
spacing: Values.smallSpacing
) {
VStack(
alignment: .center,
spacing: 0
) {
let title: String = "messageNew"
.putNumber(1)
.localized()
NewConversationCell(
image: "Message",
title: title
) {
let viewController: SessionHostingViewController = SessionHostingViewController(rootView: NewMessageScreen())
viewController.setNavBarTitle(title)
viewController.setUpDismissingButton(on: .right)
self.host.controller?.navigationController?.pushViewController(viewController, animated: true)
}
.accessibility(
Accessibility(
identifier: "New direct message",
label: "New direct message"
)
)
Line(color: .borderSeparator)
.padding(.leading, 38 + Values.smallSpacing)
.padding(.trailing, -Values.largeSpacing)
NewConversationCell(
image: "Group",
title: "groupCreate".localized()
) {
let viewController = NewClosedGroupVC()
self.host.controller?.navigationController?.pushViewController(viewController, animated: true)
}
.accessibility(
Accessibility(
identifier: "Create group",
label: "Create group"
)
)
Line(color: .borderSeparator)
.padding(.leading, 38 + Values.smallSpacing)
.padding(.trailing, -Values.largeSpacing)
NewConversationCell(
image: "Globe",
title: "communityJoin".localized()
) {
let viewController = JoinOpenGroupVC()
self.host.controller?.navigationController?.pushViewController(viewController, animated: true)
}
.accessibility(
Accessibility(
identifier: "Join community",
label: "Join community"
)
)
Line(color: .borderSeparator)
.padding(.leading, 38 + Values.smallSpacing)
.padding(.trailing, -Values.largeSpacing)
NewConversationCell(
image: "icon_invite",
title: "sessionInviteAFriend".localized()
) {
let viewController: SessionHostingViewController = SessionHostingViewController(rootView: InviteAFriendScreen())
viewController.setNavBarTitle("sessionInviteAFriend".localized())
viewController.setUpDismissingButton(on: .right)
self.host.controller?.navigationController?.pushViewController(viewController, animated: true)
}
.accessibility(
Accessibility(
identifier: "Invite friend button",
label: "Invite friend button"
)
)
}
.padding(.bottom, Values.mediumSpacing)
Text("accountIdYours".localized())
.font(.system(size: Values.mediumLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
Text("qrYoursDescription".localized())
.font(.system(size: Values.verySmallFontSize))
.foregroundColor(themeColor: .textSecondary)
QRCodeView(
string: getUserHexEncodedPublicKey(),
hasBackground: false,
logo: "SessionWhite40", // stringlint:disable
themeStyle: ThemeManager.currentTheme.interfaceStyle
)
.aspectRatio(1, contentMode: .fit)
.padding(.vertical, Values.smallSpacing)
}
.padding(.horizontal, Values.largeSpacing)
}
}
.backgroundColor(themeColor: .backgroundSecondary)
}
}
fileprivate struct NewConversationCell: View {
let image: String
let title: String
let action: () -> ()
var body: some View {
Button {
action()
} label: {
HStack(
alignment: .center,
spacing: Values.smallSpacing
) {
ZStack(alignment: .center) {
Image(image)
.renderingMode(.template)
.foregroundColor(themeColor: .textPrimary)
.frame(width: 25, height: 24, alignment: .bottom)
}
.frame(width: 38, height: 38, alignment: .leading)
Text(title)
.font(.system(size: Values.mediumLargeFontSize))
.foregroundColor(themeColor: .textPrimary)
.frame(
maxWidth: .infinity,
alignment: .leading
)
}
.frame(height: 55)
}
}
}
#Preview {
StartConversationScreen()
}