@State var content: [SuraReadModeAyath] = []
ForEach(content.indices, id: \.self) { index in
let sura = content[index]
let text = isBanglaSelected ? sura.transliterationBn ?? "" : sura.arabicUthmani ?? ""
Text(text)
.font(isBanglaSelected ? Font.custom("Inter", size: customFontSize - 10): Font.custom("KFGQPC Uthmanic Script HAFS", size: customFontSize))
.foregroundStyle(index == suraDetailsVM.serial ? .deenThemeColor: .deenBlack)
.multilineTextAlignment(isBanglaSelected ? .leading : .trailing)
.padding(.vertical, 4)
.id(index)
.onTapGesture {
AudioPlayerManager.shared.isAudioClicked = true
suraDetailsVM.serial = index
if suraDetailsVM.serial == index {
suraDetailsVM.isPlayDictionary[suraDetailsVM.serial] = true
if suraDetailsVM.isPlayDictionary[suraDetailsVM.serial] ?? false {
audioControllerVM.suraDetailsAudio(index: suraDetailsVM.serial, suraDetailsVM: suraDetailsVM)
}
}
}
}
#content contain suraReadModeVM.ayaths
In above code, I get all text and each of them individually clickable. The problem is I want to show it like a paragraph. functionality will be same as it is. Now each text start with new line.
I am using Xcode 15+, iOS 16.0, SwiftUI
Please include a minimal reproducible example. No one can run the code you’ve posted.
Think like I have an array of text with id, I need to perform some action on tap of that text. Here I used foreach loop. Everything is right, the problem is it shows each text with new line. I need it like a paragraph
This answer in the duplicate target is how I recommend to do it.