HomeiOS Developmentios - Swift Textual content solely displaying first 2 traces

ios – Swift Textual content solely displaying first 2 traces


I’m making a chatbot that may ultimately use the ChatGPT api. Proper now I’m creating the chat part. I can sort into the textfield and add to the array which i then show utilizing Textual content() as proven within the code. Nevertheless when typing a protracted message it can solely present the two traces after which … . As proven in picture. How can I get it to make use of greater than 2 traces and show all of it. I’ve tried utilizing lineLimit nevertheless it made no distinction.

import SwiftUI

struct writtenpromptView: View {
    
    @State personal var Immediate: String = ""

    @State var chatarray: [String] = ["Hello", "hello"]
    @State var aiarray: [String] = ["good question", "hello"]
    
    var physique: some View {
        ZStack {
            Colour("darkgpt")
                .edgesIgnoringSafeArea(.all)
            VStack {
                topbar()
                    .padding(.prime, 35)
                    .edgesIgnoringSafeArea(.all)
                    .body(peak:45)
                    .padding(.backside, 10)
                ScrollView {
                    ScrollViewReader { worth in
                        GeometryReader { geometry in
                            VStack {
                                ForEach(0..<chatarray.rely, id:.self) { index in
                                        Rectangle()
                                        .foregroundColor(Colour("darkgpt"))
                                        .body(minWidth: geometry.dimension.width, maxWidth: geometry.dimension.width, minHeight: 50, maxHeight: 500)
                                        .overlay(Textual content(chatarray[index]).foregroundColor(Colour("textgrey")).body(minWidth: 50, maxWidth: geometry.dimension.width - 60, minHeight: 50, maxHeight: 500))
                                    
                                        Rectangle()
                                        .foregroundColor(Colour("gptresponse"))
                                        .body(minWidth: geometry.dimension.width, maxWidth: geometry.dimension.width, minHeight: 50, maxHeight: 500)
                                        .overlay(Textual content(aiarray[index]).foregroundColor(Colour("textgrey")).body(minWidth: 50, maxWidth: geometry.dimension.width - 60, minHeight: 50, maxHeight: 500)
                                        )
                                    
                                    
                                }
                            }
                        }
                    }
            }
                
                ZStack {
                    if Immediate == "" {
                        HStack {
                            TypingAnimationView(promptArray: ["Ask us anything...", "Explain quantum computing in simple terms.", "Write an essay on George Washington.", "Tell me a joke.", "write code to print "hello World" in python."], typingSpeed: 0.09, deletionSpeed: 0.09)
                        }
                    }
                        
                    TextField("", textual content: $Immediate)
                        .padding()
                        .body(width: 300, peak: 50)
                        .background(Colour("textbar").opacity(0.3).cornerRadius(20))
                        .padding(.backside, 25)
                        .foregroundColor(Colour.white)
                        .font(.headline)
                        .onSubmit {
                            chatarray.append(self.Immediate)
                            aiarray.append(self.Immediate)
                            self.Immediate = ""
                        }
                }
            }
        }
    }
}

struct writtenpromptView_Previews: PreviewProvider {
    static var previews: some View {
        writtenpromptView()
    }
}

image of output when typing long message into textfield

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments