Skip to main content

Display the community

Show the Octopus community screens inside your app, full screen or embedded in one of your screens.

Before you begin​

How it works​

The community UI starts on the main feed and handles its own navigation between feeds, posts, groups and profiles. You choose where it lives:

PresentationAndroidiOSFlutterReact NativeUnity
Full screen, over your appYour own route.fullScreenCovershowOctopusHomeScreenopenUI()Open()
Embedded in one of your screensOctopusHomeContentOctopusHomeScreen in a tabOctopusHomeScreen widget<OctopusUIView>Not available

Your app gets callbacks when the community needs something only your app can do: sign the user in, edit a profile field your app owns, open a link, or show your own profile screen.


Show the community​

Add the OctopusHomeContent composable to your community screen:

  • navController: your main NavHostController.
  • onNavigateToLogin: called when the SDK needs a signed-in user. Start your login flow, then call OctopusSDK.connectUser(...).
  • onNavigateToProfileEdit: called when the user taps a profile field your app owns. fieldToEdit tells you which one, or null. Open your profile editor, then call OctopusSDK.connectUser(...) again with the updated profile.
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.ui.Modifier
import com.octopuscommunity.sdk.domain.model.ProfileField
import com.octopuscommunity.sdk.ui.OctopusTheme
import com.octopuscommunity.sdk.ui.home.OctopusHomeContent

OctopusTheme {
OctopusHomeContent(
modifier = Modifier.fillMaxSize(),
navController = navController,
onNavigateToLogin = {
navController.navigate(LoginRoute)
},
onNavigateToProfileEdit = { fieldToEdit ->
navController.navigate(
ProfileRoute(focusNickname = fieldToEdit == ProfileField.NICKNAME),
)
},
)
}

Then register the other community screens in your main NavHost with octopusComposables. It adds one composable() destination per community screen to your NavGraphBuilder:

import androidx.navigation.compose.NavHost
import com.octopuscommunity.sdk.ui.octopusComposables

NavHost(navController = navController, startDestination = HomeRoute) {
// Your own destinations
octopusComposables(
navController = navController,
onNavigateToLogin = { navController.navigate(LoginRoute) },
onNavigateToProfileEdit = { fieldToEdit -> /* same as above */ },
) { backStackEntry, content ->
// Theme a community screen, possibly based on backStackEntry
OctopusTheme {
content()
}
}
}
warning

When OctopusHomeContent, or the NavHost that holds octopusComposables, sits inside your own Scaffold, pass the innerPadding and consume it: Modifier.padding(innerPadding).consumeWindowInsets(innerPadding). Otherwise the system bar and keyboard insets count twice: the comment composer floats above the keyboard by the height of your bottom bar, and a gap shows under it when the keyboard is closed. This is the Compose guidance for nested Scaffolds.

See the Android sample: the Community tab embeds OctopusHomeContent, MainScaffold registers octopusComposables under a bottom navigation bar, and the presentation scenarios open the community full screen, in a modal and in a bottom sheet, hosted by MainActivity.

Since 1.15.0, SDK lists animate insertions, removals and placement; scrolling to content and switching translations are animated too. These changes require no host configuration.


Modify the bottom safe area​

Android availableiOS availableFlutter ≥ 1.12.0React Native availableUnity not available

Reserve extra space at the bottom of the community UI, for example under your own bottom bar, so the floating "Write a post" button and the comment composer stay visible.

Use the contentPadding parameter of OctopusHomeContent:

OctopusHomeContent(
modifier = Modifier.fillMaxSize(),
navController = navController,
contentPadding = PaddingValues(bottom = 10.dp),
onNavigateToLogin = { /* Open your sign-in screen */ },
)

Next steps​