mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			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.
		
		
		
		
		
			
		
			
				
	
	
		
			157 lines
		
	
	
		
			6.6 KiB
		
	
	
	
		
			Swift
		
	
			
		
		
	
	
			157 lines
		
	
	
		
			6.6 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
 | |
|                     ) {
 | |
|                         NewConversationCell(
 | |
|                             image: "Message",
 | |
|                             title: "vc_create_private_chat_title".localized()
 | |
|                         ) {
 | |
|                             let viewController: SessionHostingViewController = SessionHostingViewController(rootView: NewMessageScreen())
 | |
|                             viewController.setNavBarTitle("vc_create_private_chat_title".localized())
 | |
|                             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: "vc_create_closed_group_title".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: "vc_join_public_chat_title".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: "vc_settings_invite_a_friend_button_title".localized()
 | |
|                         ) {
 | |
|                             let viewController: SessionHostingViewController = SessionHostingViewController(rootView: InviteAFriendScreen())
 | |
|                             viewController.setNavBarTitle("vc_settings_invite_a_friend_button_title".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",
 | |
|                         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()
 | |
| }
 |