Skip to content

Instantly share code, notes, and snippets.

@LeonidIvankin
Created July 10, 2022 07:59
Show Gist options
  • Save LeonidIvankin/ac78624f8d0bea5e0d580d07b9623e07 to your computer and use it in GitHub Desktop.
Save LeonidIvankin/ac78624f8d0bea5e0d580d07b9623e07 to your computer and use it in GitHub Desktop.
package com.leonidivankin.draftandroid.articles.refactoring
import android.os.Bundle
import android.view.View
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import com.leonidivankin.draftandroid.R
class LegacyActivityExternal : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
title = "LegacyActivity, external"
setContent { ExternalPart() }
}
}
@Composable
private fun ExternalPart() {
Box(
Modifier
.fillMaxSize()
.background(color = Color(0xFFF44336))
.padding(32.dp)
) {
Box(
Modifier
.fillMaxSize()
.background(color = Color(0xFF9C27B0))
.padding(32.dp)
) {
AndroidView(
modifier = Modifier.fillMaxSize(),
factory = { context ->
View.inflate(context, R.layout.internal_part, null)
}
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment