I'm building 2 different section on screen. both s...
# compose
r
I'm building 2 different section on screen. both section load data from network (Like instagram profile page). What's wrong with below code? Expectation: ProfileView should be on upper part and PostView should be below it Reality: ProfileView Replace PostView and Postview is not showing up once data is loaded
Copy code
fun ProfileScreen(profileViewModel: ProfileViewModel) {
    Column {
        ProfileView(profileViewModel)
		Spacer(modifier = Modifier.padding(top = 8.dp))
        PostView(profileViewModel)
    }
}

fun ProfileView(profileViewModel: ProfileViewModel) {
  val user by remember(profileViewModel) { profileViewModel.user }.collectAsState()
  when (user) {
	  is UiState.Loading -> {
		  CircularProgressIndicator(
			  modifier = Modifier.wrapContentWidth(CenterHorizontally)
		  )
	  }
	  is UiState.Success -> {
		  (user as UiState.Success).data?.let { user ->
			  Scaffold(
				  topBar = { ProfileAppBar(user) }
			  ) { innerPadding ->
				  val modifier = Modifier.padding(innerPadding)
				  Column(modifier = modifier) {
					  UserInfo(user = user)
					  Spacer(modifier = Modifier.padding(top = 10.dp))
				  }
			  }
		  }
	  }
  }
}


fun PostView(profileViewModel: ProfileViewModel) {
  val posts by remember(profileViewModel) { profileViewModel.posts }.collectAsState()

  when (posts) {
	  is UiState.Loading -> {
		  CircularProgressIndicator(
			  modifier = Modifier.wrapContentWidth(CenterHorizontally)
		  )
	  }
	  is UiState.Success -> {
		  (posts as UiState.Success).data?.let { posts ->
			  lazyGridFor(posts) { post, index ->
				  GridItem(post = post) {
				  }
			  }
		  }
	  }
  }
}
e
Your profile view is scaffold, it fills entire screen
r
Yes I came to know that. I've used different approach to implement this. Thanks though.