Skip to content

Instantly share code, notes, and snippets.

APText(
modifier = Modifier
.testTag("txt_title")
.padding(top = 6.dp, bottom = 4.dp),
apStyle = textStyle, text = text, textColor = textColor
)
class AccountDetailsPage constructor(private val composeTestRule: ComposeContentTestRule) {
val personalDetails: PersonalDetails
get() =
with(composeTestRule) {
PersonalDetails(
preferredName = TitleValue(
title = onNestedChild(UiAssert.stringRes(R.string.glam_preferred_name), "txt_title"),
value = onNestedChild(UiAssert.stringRes(R.string.glam_preferred_name), "txt_subtitle")
),
lastName = TitleValue(
@Config(application = PostApp::class, instrumentedPackages = ["androidx.loader.content"])
class AccountDetailsActivityTest :
RobolectricTestBase<AccountDetailsActivity>(AccountDetailsActivity::class) {
@get:Rule
val composeTestRule = createComposeRule()
private lateinit var page: AccountDetailsPage
@Before
@Composable
fun DebugNavHost(
navController: NavHostController,
paddingValues: PaddingValues,
showSnackBar: (String) -> Job
) {
MaterialThemeScreenContent {
val leprechaunViewModel = viewModel<LeprechaunViewModel>()
val progressOverlayViewModel = viewModel<ProgressOverlayViewModel>()
NavHost(navController, startDestination = DebugScreen.Environment.route, modifier = Modifier.padding(paddingValues)) {
val defaultTextColor: Color
@Composable
@ReadOnlyComposable
get() = if (isSystemInDarkTheme()) AP_White else AP_Ink
val defaultSecondaryTextColor: Color
@Composable
@ReadOnlyComposable
get() = if (isSystemInDarkTheme()) AP_Smoke else AP_Iron
@OptIn(ExperimentalAnimationGraphicsApi::class)
@Composable
fun APTextField(
modifier: Modifier = Modifier,
value: String? = null,
onValueChange: (String) -> Unit,
onEndIconClicked: () -> Unit = { },
label: String? = null,
mode: APTextFieldType = APTextFieldType.Normal
) {
sealed class DebugScreen(val route: String, val title: Int, val topLevelDestination: Boolean = false) {
object Environment : DebugScreen(DebugNavigationItem.Environment.route, R.string.environment_screen_title, true)
}
Scaffold(
scaffoldState = scaffoldState,
topBar = { DebugTopBar(navController, version) },
bottomBar = { DebugBottomNavigationBar(navController) }
) { paddingValues ->
DebugNavHost(navController = navController, paddingValues, showSnackBar)
WearAppTheme {
Scaffold(
timeText = {
if (displayTime(currentScreen, scalingLazyListState)) {
TimeText()
}
},
vignette = {
Vignette(vignettePosition = VignettePosition.TopAndBottom)
},
composable(
// Route information
route = WearScreen.DETAILS.name + "/{trackNumber}",
arguments = listOf(navArgument("trackNumber") { type = NavType.StringType })
) { backStackEntry ->
val trackNumber = backStackEntry.arguments?.getString("trackNumber") ?: ""
// Retrieve View model
val trackDetailsViewModel = viewModel<TrackDetailsViewModel>()
fun Route.postGreeting() {
val greetingService by inject<GreetingService>()
post("/greeting") {
val greetingRequest = call.receive<GreetingRequest>()
call.respond(greetingService.greeting(greetingRequest))
}
}