mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-15 05:17:03 +05:30
common: add UserProfile composable and integrate navigation
This commit is contained in:
parent
c046036fdc
commit
5b024c8d6e
2 changed files with 31 additions and 0 deletions
|
@ -45,6 +45,7 @@ import dev.msfjarvis.claw.common.comments.LocalHTMLConverter
|
||||||
import dev.msfjarvis.claw.common.res.ClawIcons
|
import dev.msfjarvis.claw.common.res.ClawIcons
|
||||||
import dev.msfjarvis.claw.common.theme.LobstersTheme
|
import dev.msfjarvis.claw.common.theme.LobstersTheme
|
||||||
import dev.msfjarvis.claw.common.urllauncher.UrlLauncher
|
import dev.msfjarvis.claw.common.urllauncher.UrlLauncher
|
||||||
|
import dev.msfjarvis.claw.common.user.UserProfile
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import soup.compose.material.motion.materialElevationScaleIn
|
import soup.compose.material.motion.materialElevationScaleIn
|
||||||
import soup.compose.material.motion.materialElevationScaleOut
|
import soup.compose.material.motion.materialElevationScaleOut
|
||||||
|
@ -212,6 +213,22 @@ fun LobstersApp(
|
||||||
postActions = postActions,
|
postActions = postActions,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
composable(
|
||||||
|
route = Destinations.User.getRoute("{username}"),
|
||||||
|
arguments = listOf(navArgument("username") { type = NavType.StringType }),
|
||||||
|
deepLinks = listOf(navDeepLink { uriPattern = "$uri/u/{username}" }),
|
||||||
|
enterMotionSpec = { translateXIn { it } },
|
||||||
|
exitMotionSpec = { materialElevationScaleOut() },
|
||||||
|
popEnterMotionSpec = { materialElevationScaleIn() },
|
||||||
|
popExitMotionSpec = { translateXOut { it } },
|
||||||
|
) { backStackEntry ->
|
||||||
|
val username = requireNotNull(backStackEntry.arguments?.getString("username"))
|
||||||
|
UserProfile(
|
||||||
|
username = username,
|
||||||
|
getProfile = viewModel::getUserProfile,
|
||||||
|
modifier = Modifier.navigationBarsPadding(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package dev.msfjarvis.claw.common.user
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import dev.msfjarvis.claw.model.User
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
@Composable
|
||||||
|
fun UserProfile(
|
||||||
|
username: String,
|
||||||
|
getProfile: suspend (username: String) -> User,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue