Fix projection selection
This commit is contained in:
@@ -21,7 +21,10 @@ import androidx.compose.material.icons.filled.Edit
|
|||||||
import androidx.compose.material.icons.filled.Percent
|
import androidx.compose.material.icons.filled.Percent
|
||||||
import androidx.compose.material.icons.filled.Settings
|
import androidx.compose.material.icons.filled.Settings
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.viewinterop.AndroidView
|
import androidx.compose.ui.viewinterop.AndroidView
|
||||||
import androidx.navigation.NavHostController
|
import androidx.navigation.NavHostController
|
||||||
@@ -40,8 +43,8 @@ import net.helcel.beans.svg.SVGWrapper
|
|||||||
|
|
||||||
class MainScreen : ComponentActivity() {
|
class MainScreen : ComponentActivity() {
|
||||||
|
|
||||||
private lateinit var psvg: SVGWrapper
|
private var psvg by mutableStateOf<SVGWrapper?>(null)
|
||||||
private lateinit var css: CSSWrapper
|
private var css by mutableStateOf<CSSWrapper?>(null)
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -50,14 +53,19 @@ class MainScreen : ComponentActivity() {
|
|||||||
Data.loadData(this, Int.MIN_VALUE)
|
Data.loadData(this, Int.MIN_VALUE)
|
||||||
GeoLocImporter.importStates(this)
|
GeoLocImporter.importStates(this)
|
||||||
|
|
||||||
|
refreshProjection()
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
SysTheme {
|
SysTheme {
|
||||||
Box(modifier = Modifier.fillMaxSize().background(MaterialTheme.colors.primary).statusBarsPadding(),) {
|
val currentPsvg = psvg
|
||||||
AppNavHost(psvg, css)
|
val currentCss = css
|
||||||
|
if (currentPsvg != null && currentCss != null) {
|
||||||
|
Box(modifier = Modifier.fillMaxSize().background(MaterialTheme.colors.primary).statusBarsPadding(),) {
|
||||||
|
AppNavHost(currentPsvg, currentCss)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
refreshProjection()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -102,19 +110,25 @@ class MainScreen : ComponentActivity() {
|
|||||||
@Composable
|
@Composable
|
||||||
fun MapScreen(psvg: SVGWrapper, css: CSSWrapper) {
|
fun MapScreen(psvg: SVGWrapper, css: CSSWrapper) {
|
||||||
Box {
|
Box {
|
||||||
val opt: RenderOptions = RenderOptions.create()
|
val cssContent = css.get()
|
||||||
opt.css(css.get())
|
val drawable = remember(psvg, css, cssContent) {
|
||||||
val drawable = remember(psvg, css) {
|
val opt: RenderOptions = RenderOptions.create()
|
||||||
|
opt.css(cssContent)
|
||||||
PictureDrawable(psvg.get()?.renderToPicture(opt))
|
PictureDrawable(psvg.get()?.renderToPicture(opt))
|
||||||
}
|
}
|
||||||
AndroidView(factory = { ctx ->
|
AndroidView(
|
||||||
PhotoView(ctx).apply {
|
factory = { ctx ->
|
||||||
setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null)
|
PhotoView(ctx).apply {
|
||||||
setImageDrawable(drawable)
|
setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null)
|
||||||
maximumScale = 64f
|
maximumScale = 64f
|
||||||
scaleType = ImageView.ScaleType.FIT_CENTER
|
scaleType = ImageView.ScaleType.FIT_CENTER
|
||||||
}
|
}
|
||||||
}, modifier = Modifier.fillMaxSize())
|
},
|
||||||
|
update = { view ->
|
||||||
|
view.setImageDrawable(drawable)
|
||||||
|
},
|
||||||
|
modifier = Modifier.fillMaxSize()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user