diff --git a/Meshtastic-iOS.xcodeproj/project.pbxproj b/Meshtastic-iOS.xcodeproj/project.pbxproj index 5487424..ba8643b 100644 --- a/Meshtastic-iOS.xcodeproj/project.pbxproj +++ b/Meshtastic-iOS.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 0D4E46F725D3C3C5008686AB /* LogManagerTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D4E46F625D3C3C5008686AB /* LogManagerTemplate.swift */; }; 0DEE520925D0BA71003C6EB7 /* SwiftProtobuf in Frameworks */ = {isa = PBXBuildFile; productRef = 0DEE520825D0BA71003C6EB7 /* SwiftProtobuf */; }; 0DEE520D25D0BE8B003C6EB7 /* DeviceDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DEE520C25D0BE8B003C6EB7 /* DeviceDetailView.swift */; }; + 8A713CD02623EAD300F6D4BB /* MessageKit in Frameworks */ = {isa = PBXBuildFile; productRef = 8A713CCF2623EAD300F6D4BB /* MessageKit */; }; D5248FC6251ED2FA00CF50E6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D5248FC5251ED2FA00CF50E6 /* Assets.xcassets */; }; D5248FC9251ED2FA00CF50E6 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D5248FC7251ED2FA00CF50E6 /* LaunchScreen.storyboard */; }; D55AC0AB25D0A52700151E9D /* DeviceInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = D55AC0AA25D0A52700151E9D /* DeviceInfo.swift */; }; @@ -69,6 +70,7 @@ buildActionMask = 2147483647; files = ( 0DEE520925D0BA71003C6EB7 /* SwiftProtobuf in Frameworks */, + 8A713CD02623EAD300F6D4BB /* MessageKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -190,6 +192,7 @@ name = Meshtastic; packageProductDependencies = ( 0DEE520825D0BA71003C6EB7 /* SwiftProtobuf */, + 8A713CCF2623EAD300F6D4BB /* MessageKit */, ); productName = "M-iOS_test"; productReference = D5248FB9251ED2F900CF50E6 /* Meshtastic.app */; @@ -220,6 +223,7 @@ mainGroup = D5248FB0251ED2F900CF50E6; packageReferences = ( 0DEE520725D0BA71003C6EB7 /* XCRemoteSwiftPackageReference "swift-protobuf" */, + 8A713CCE2623EAD300F6D4BB /* XCRemoteSwiftPackageReference "MessageKit" */, ); productRefGroup = D5248FBA251ED2F900CF50E6 /* Products */; projectDirPath = ""; @@ -407,7 +411,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = SKJCUF8GFH; + DEVELOPMENT_TEAM = NLSA9C94UQ; INFOPLIST_FILE = Meshtastic/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -426,7 +430,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = SKJCUF8GFH; + DEVELOPMENT_TEAM = NLSA9C94UQ; INFOPLIST_FILE = Meshtastic/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -471,6 +475,14 @@ minimumVersion = 1.15.0; }; }; + 8A713CCE2623EAD300F6D4BB /* XCRemoteSwiftPackageReference "MessageKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/MessageKit/MessageKit"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 3.3.0; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -479,6 +491,11 @@ package = 0DEE520725D0BA71003C6EB7 /* XCRemoteSwiftPackageReference "swift-protobuf" */; productName = SwiftProtobuf; }; + 8A713CCF2623EAD300F6D4BB /* MessageKit */ = { + isa = XCSwiftPackageProductDependency; + package = 8A713CCE2623EAD300F6D4BB /* XCRemoteSwiftPackageReference "MessageKit" */; + productName = MessageKit; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = D5248FB1251ED2F900CF50E6 /* Project object */; diff --git a/Meshtastic-iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Meshtastic-iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 75c7423..c176e70 100644 --- a/Meshtastic-iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Meshtastic-iOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,6 +1,24 @@ { "object": { "pins": [ + { + "package": "InputBarAccessoryView", + "repositoryURL": "https://github.com/nathantannar4/InputBarAccessoryView", + "state": { + "branch": null, + "revision": "f5e21ad31f7e747ae08eae91b6fc6d2348bb750d", + "version": "5.3.1" + } + }, + { + "package": "MessageKit", + "repositoryURL": "https://github.com/MessageKit/MessageKit", + "state": { + "branch": null, + "revision": "bdb07821037d7760041c979d7986774a0edb06ef", + "version": "3.6.0" + } + }, { "package": "SwiftProtobuf", "repositoryURL": "https://github.com/apple/swift-protobuf.git", diff --git a/Meshtastic/Views/ChatView.swift b/Meshtastic/Views/ChatView.swift index e5a2034..cd2fb8e 100644 --- a/Meshtastic/Views/ChatView.swift +++ b/Meshtastic/Views/ChatView.swift @@ -7,21 +7,194 @@ import SwiftUI + + struct ChatView: View { +// @State private var messageInput = "" +// @State private var chatHistory = "" + var body: some View { - NavigationView { - Form { - Section { - Text("Chat message") - } - } - .navigationBarTitle(Text("Chat")) - } +// VStack { +// ScrollView { +// LazyVStack(alignment: .leading, spacing: 32) { +// ForEach(0 ..< 12) { _ in +// TextField("Lorem Ipsum Lorem Ipsum", text: $chatHistory) +// } +// +// } +// } +// TextField("Message", text: $messageInput) +// .frame(width: 300, height: 40) +// .font(Font.system(size: 15, weight: .semibold)) +// .overlay(RoundedRectangle(cornerRadius: 10).stroke(Color.blue, lineWidth: 1)) +// .padding() +// } + + + // Borrowed from KavSoft + chatInstance() + + + + + + + } } + struct ChatView_Previews: PreviewProvider { static var previews: some View { ChatView() } } + + +struct chatInstance : View { + + @State var txt = "" + @State var height : CGFloat = 0 + @State var keyboardHeight : CGFloat = 0 + + var body: some View { + VStack (spacing: 0) { + + HStack { + Text("Chat") + .font(.title) + .fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/) + + Spacer() + }.padding() + .background(Color.white) + + Spacer() + + ScrollView(.vertical, showsIndicators: false) { + + // Chat Content + Text("") + } + + HStack(spacing: 8) { + + resizeableChat(txt: self.$txt, height: self.$height) + .frame(height: self.height < 150 ? self.height : 150) + .padding(.horizontal) + .background(Color.white) + .cornerRadius(15) + Button(action: { + + }) { + + Image(systemName: "arrow.forward.circle") + .font(.system(size: 18, weight: .regular)) + .foregroundColor(.black) + .padding(10) + } + .background(Color.white) + .clipShape(Circle()) + } + .padding(.horizontal) + + } + .padding(.bottom, self.keyboardHeight) + .background(Color.black.opacity(0.06).edgesIgnoringSafeArea(.bottom) + .onTapGesture { + + UIApplication.shared.windows.first?.rootViewController?.view + .endEditing(true) + }) + .onAppear { + + NotificationCenter.default.addObserver(forName: + UIResponder.keyboardDidShowNotification, object: nil, queue: .main) { + (data) in + + let height1 = data.userInfo![UIResponder.keyboardFrameEndUserInfoKey] + as! NSValue + + self.keyboardHeight = height1.cgRectValue.height - 20 + + } + + NotificationCenter.default.addObserver(forName: + UIResponder.keyboardDidHideNotification, object: nil, queue: .main) { + (_) in + + self.keyboardHeight = 0 + + } + } + } +} + + +struct resizeableChat : UIViewRepresentable { + + @Binding var txt: String + @Binding var height : CGFloat + + func makeCoordinator() -> Coordinator { + + return resizeableChat.Coordinator(parent1: self) + } + + + func makeUIView(context: Context) -> UITextView { + + let view = UITextView() + view.isEditable = true + view.isScrollEnabled = true + view.text = "Enter Message" + view.font = .systemFont(ofSize: 18) + view.textColor = .gray + view.backgroundColor = .clear + view.delegate = context.coordinator + return view + } + + func updateUIView(_ uiView: UITextView, context: Context) { + DispatchQueue.main.async { + + self.height = uiView.contentSize.height + } + } + + class Coordinator : NSObject, UITextViewDelegate { + + var parent : resizeableChat + + init(parent1 : resizeableChat) { + + parent = parent1 + } + + func textViewDidBeginEditing(_ textView: UITextView) { + + if self.parent.txt == "" { + + textView.text = "" + textView.textColor = .black + } + } + + func textViewDidEndEditing(_ textView: UITextView) { + if self.parent.txt == ""{ + + textView.text = "Enter Message" + textView.textColor = .gray + } + } + + func textViewDidChange(_ textView: UITextView) { + + DispatchQueue.main.async { + self.parent.height = textView.contentSize.height + self.parent.txt = textView.text + + } + } + } +}