|
@@ -1,5 +1,6 @@
|
|
|
package com.ys.bdtp.adm.mvvm.ui.screen.cad
|
|
|
|
|
|
+import android.content.Intent
|
|
|
import androidx.compose.foundation.background
|
|
|
import androidx.compose.foundation.layout.*
|
|
|
import androidx.compose.foundation.lazy.LazyColumn
|
|
@@ -9,6 +10,7 @@ import androidx.compose.runtime.*
|
|
|
import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
+import androidx.compose.ui.platform.LocalContext
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
@@ -16,6 +18,7 @@ import com.ys.bdtp.adm.app.theme.textBlackColor
|
|
|
import com.ys.bdtp.adm.app.theme.trDivColor
|
|
|
import com.ys.bdtp.adm.app.theme.underColor
|
|
|
import com.ys.bdtp.adm.app.theme.whiteColor
|
|
|
+import com.ys.bdtp.adm.app.tools.file.getUri
|
|
|
import com.ys.bdtp.adm.mvvm.model.db.entity.task.CadEntity
|
|
|
import com.ys.bdtp.adm.mvvm.model.db.relation.FloorWithCads
|
|
|
import com.ys.bdtp.adm.mvvm.model.db.relation.ProjectWithBuildingAndFloors
|
|
@@ -25,10 +28,12 @@ import com.ys.bdtp.adm.mvvm.ui.screen.main.cadToLogin
|
|
|
import com.ys.bdtp.adm.mvvm.vm.cad.CadViewModel
|
|
|
import kotlinx.coroutines.launch
|
|
|
import org.kodein.di.compose.rememberViewModel
|
|
|
+import java.io.File
|
|
|
|
|
|
@Composable
|
|
|
fun CadScreen(projectId: String) {
|
|
|
val nav = LocalNavHostController.current!!
|
|
|
+ val context = LocalContext.current
|
|
|
val vm by rememberViewModel<CadViewModel>()
|
|
|
val scope = rememberCoroutineScope()
|
|
|
|
|
@@ -127,7 +132,20 @@ fun CadScreen(projectId: String) {
|
|
|
floor?.let {
|
|
|
items(it.cads) { cad: CadEntity ->
|
|
|
Box {
|
|
|
- CadDrawingItem(cad)
|
|
|
+ CadDrawingItem(cad) {
|
|
|
+ val path = context.getExternalFilesDir("dwg")
|
|
|
+ val file = File(path, cad.fileName)
|
|
|
+ if (file.exists()) {
|
|
|
+ val uri = file.getUri(context)
|
|
|
+ val intent = Intent(Intent.ACTION_VIEW)
|
|
|
+ intent.setDataAndType(uri, "application/dwg")
|
|
|
+ intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
|
|
+ context.startActivity(intent)
|
|
|
+ } else {
|
|
|
+ println("not found")
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
Spacer(
|
|
|
modifier = Modifier
|
|
|
.align(Alignment.BottomCenter)
|