Add the android sdk and platform-tools to your zsh
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.zshrc
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.zshrc
Add the android sdk and platform-tools to your zsh
echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.zshrc
echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.zshrc
use
divider = {},
like so:
TabRow(
selectedTabIndex = selectedTabIndex,
modifier = modifier,
containerColor = Color.Transparent,
contentColor = MaterialTheme.colorScheme.onSurface,
indicator = { tabPositions ->
TabRowDefaults.Indicator(
modifier = Modifier.tabIndicatorOffset(tabPositions[selectedTabIndex]),
height = 2.dp,
// uncomment below to customize indicator color:
// color = MaterialTheme.colorScheme.onSurface,
)
},
divider = {},
tabs = tabs,
)
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val config = resources.configuration
config.uiMode = Configuration.UI_MODE_NIGHT_NO
resources.updateConfiguration(config, resources.displayMetrics)
class DownloadImageUseCase @Inject constructor(
@ApplicationContext private val context: Context,
private val dispatchersProvider: DispatchersProvider,
) {
suspend operator fun invoke(imageUrl: String): String? = withContext(dispatchersProvider.io()) {
try {
val input = URL(imageUrl).openStream()
val fileName = imageUrl.substringAfterLast("/")
val file = File(context.filesDir, fileName)
FileOutputStream(file).use { output ->
input.copyTo(output)
}
file.absolutePath
} catch (e: Exception) {
e.printStackTrace()
null
}
}
}
viewModelScope.launch {
state.update { oldState ->
oldState.copy(
imagePath =
downloadImageUseCase(
"https://apod.nasa.gov/apod/image/2403/IM_Odysseus_landing-1100x600.png",
),
)
}
}
@Composable
fun DisplayImageFromDisk(imagePath: String?) {
imagePath?.let {
Image(
painter = rememberAsyncImagePainter(File(it)),
contentDescription = "Cached Image",
modifier = Modifier.fillMaxWidth()
)
}
}