Hi,
I'd like to separate each paragraph of a text in a list, I'm trying to find how to do it, I know it's certainly a dumb question but I'm new at coding, please be kind haha, may someone help me?
thanks a million
Post
Replies
Boosts
Views
Activity
Hi ! I need help for coding something :
I want a function to erase random words on it, I tried everything found in the internet, nothing's worked. (here's my code : )
Anyone could give an eye to it? Many thanks
struct ContentView: View {
@State private var showScannerSheet = false
@State private var texts:[ScanData] = []
var body: some View {
NavigationView {
ZStack {
Color.white
.ignoresSafeArea()
VStack{
if texts.count > 0{
List{
ForEach(texts){text in
NavigationLink(
destination:ScrollView{Text(text.content)
.padding()},
label: {
Text(text.content).lineLimit(1)
})
}
}
}
else{
Button(action: {
self.showScannerSheet = true
}, label : {
VStack {
Image(systemName: "doc.text.viewfinder")
.resizable()
.frame(width: 200, height: 200)
.font(.title)
VStack {
Text("Scan here to begin !")
}.padding()
}
})
.sheet(isPresented: $showScannerSheet, content: {
makeScannerView()
})
}
}
}
}
}
private func makeScannerView()-> ScannerView {
ScannerView(completion: {
textPerPage in
if let outputText = textPerPage?.joined(separator: "\n").trimmingCharacters(in:
.whitespacesAndNewlines){
let newScanData = ScanData(content: outputText)
self.texts.append(newScanData)
let numberOfWordsToRemove = 5
let modifiedText = removeRandomWordsInScanData(newScanData, numberOfWordsToRemove : numberOfWordsToRemove)
newScanData.content = modifiedText
return ScannerView(completion: {
})
}
self.showScannerSheet = false
})
}
}
#Preview {
ContentView()
}