Osman Saral
08/08/2024, 9:27 AMList
in SwiftUI. Since it's only possible to create ViewControllers from components, would it be possible and would it make sense to use so many ViewControllers in a List (even if they're very light ViewControllers)Osman Saral
08/08/2024, 9:28 AMstruct TextBubbleFooo: UIViewRepresentable {
let message: ChatMessage
func makeUIView(context: Context) -> some UIView {
return TextController(message: message).view
}
func updateUIView(_ uiView: UIViewType, context: Context) {
}
@available(iOS 16.0, *)
func sizeThatFits(_ proposal: ProposedViewSize, uiView: UIViewType, context: Context) -> CGSize? {
return CGSizeMake(100, 100)
}
}
Osman Saral
08/08/2024, 9:29 AMCOMPOSE proposal: ProposedViewSize(width: Optional(313.0), height: Optional(0.0))
COMPOSE proposal: ProposedViewSize(width: Optional(313.0), height: Optional(inf))
COMPOSE proposal: ProposedViewSize(width: Optional(313.0), height: Optional(93.83333333333334))
COMPOSE proposal: ProposedViewSize(width: Optional(313.0), height: Optional(93.69200000000001))
COMPOSE proposal: ProposedViewSize(width: Optional(313.0), height: nil)
Osman Saral
08/08/2024, 9:37 AMUIViewRepresentable
instead of UIViewControllerRepresentable
. But i don't know how to calculate the view sizemohamed rejeb
08/08/2024, 9:39 AMOsman Saral
08/08/2024, 11:54 AMstruct TextBubbleFoo: UIViewRepresentable {
let message: String
func makeUIView(context: Context) -> some UIView {
return TextController(message: message).view
}
func updateUIView(_ uiView: UIViewType, context: Context) {
}
@available(iOS 16.0, *)
func sizeThatFits(_ proposal: ProposedViewSize, uiView: UIViewType, context: Context) -> CGSize? {
return CGSizeMake(proposal.width ?? 100, proposal.height ?? 50)
}
}
List(0...50,id: \.self){index in
TextBubbleFoo(message: "\(index).item")
.padding()
}
@Composable
fun TextBubbleCommon(
message: String
) {
Column(Modifier.background(Color.Green)) {
Text(message, color = Color.Blue, modifier = Modifier.padding(20.dp).background(Color.Red))
}
}
fun TextController(message: String): UIViewController = ComposeUIViewController {
TextBubbleCommon(message)
}
If I implement sizeThatFits it looks like the first screenshot. If I don't the second screenshot.Elijah Semyonov
08/09/2024, 7:15 AMElijah Semyonov
08/09/2024, 7:17 AMElijah Semyonov
08/09/2024, 7:17 AMElijah Semyonov
08/09/2024, 7:22 AMOsman Saral
08/09/2024, 9:14 PMGuyaume Tremblay
08/14/2024, 2:47 PMUICollectionViewCell
in an old UICollectionView
. The view did appear great the first time but when I navigate back to the screen, The content disappear...Elijah Semyonov
08/14/2024, 3:31 PMGuyaume Tremblay
08/14/2024, 3:51 PMElijah Semyonov
08/14/2024, 5:00 PMGuyaume Tremblay
08/14/2024, 6:25 PMElijah Semyonov
08/15/2024, 8:49 AMOsman Saral
08/15/2024, 8:58 AMElijah Semyonov
08/15/2024, 8:59 AMOsman Saral
08/15/2024, 9:02 AMElijah Semyonov
08/15/2024, 9:03 AMOsman Saral
08/15/2024, 9:04 AMElijah Semyonov
08/15/2024, 9:07 AMhostingConfiguration
implies that the actual SwiftUI hosting machinery (which I suppose is something conceptually similar to Compose) resides inside `UITableView`/`UICollectionView` , so the user is only required to assign a single property with SwiftUI.View
inside.Elijah Semyonov
08/15/2024, 9:10 AMUIHostingView
is exponentially more complicated 🙂Elijah Semyonov
08/15/2024, 9:11 AMElijah Semyonov
08/15/2024, 9:12 AMElijah Semyonov
08/15/2024, 9:13 AMComposeUIViewController
s, not advised, but not restricted either 😏Osman Saral
08/15/2024, 9:14 AMOsman Saral
08/15/2024, 9:15 AMElijah Semyonov
08/15/2024, 9:16 AMOsman Saral
08/15/2024, 9:16 AMcollectionViewLayout.estimatedItemSize = CGSize(width: collectionView.bounds.width, height: 100)
yeahOsman Saral
08/15/2024, 9:16 AMElijah Semyonov
08/15/2024, 9:17 AMOsman Saral
08/15/2024, 9:18 AMElijah Semyonov
08/15/2024, 9:18 AMElijah Semyonov
08/15/2024, 9:19 AMElijah Semyonov
08/15/2024, 11:40 AMElijah Semyonov
08/15/2024, 11:41 AMElijah Semyonov
08/15/2024, 11:42 AM