Fixed the Repository sheet bug

Fixed linting of optIn
RepositoryItem Cleanup
This commit is contained in:
Iamlooker
2022-06-30 01:33:45 +05:30
parent 615751fbb1
commit d2d3e9c8b3
4 changed files with 9 additions and 21 deletions

View File

@ -54,7 +54,7 @@ android {
kotlinOptions {
jvmTarget = compileOptions.sourceCompatibility.toString()
freeCompilerArgs = listOf("-Xjvm-default=compatibility")
freeCompilerArgs = listOf("-Xjvm-default=compatibility", "-opt-in=kotlin.RequiresOptIn")
}
buildFeatures {

View File

@ -34,7 +34,7 @@ fun RepositoryItem(
onClick: (Repository) -> Unit = {},
onLongClick: (Repository) -> Unit = {}
) {
var (isEnabled, enable) = remember(repository.enabled) {
val (isEnabled, enable) = remember(repository.enabled) {
mutableStateOf(repository.enabled)
}
val backgroundColor by animateColorAsState(
@ -44,7 +44,7 @@ fun RepositoryItem(
Surface(
modifier = modifier
.padding(horizontal = 8.dp, vertical = 4.dp)
.padding(horizontal = 16.dp, vertical = 4.dp)
.fillMaxWidth()
.clip(MaterialTheme.shapes.large)
.combinedClickable(
@ -55,7 +55,7 @@ fun RepositoryItem(
onLongClick = { onLongClick(repository) }
),
color = backgroundColor,
shape = MaterialTheme.shapes.large
shape = MaterialTheme.shapes.extraLarge
) {
Row(
modifier = Modifier.padding(
@ -105,15 +105,3 @@ private fun RepositoryItemText(
}
}
}
//@Preview
@Composable
fun RepositoryItemPreview() {
RepositoryItem(
repository = Repository(
name = "Test Repo",
description = "Test Repo description written by looker, You are welcome"
),
onClick = {}
)
}

View File

@ -34,11 +34,9 @@ class PrefsRepositoriesFragment : BaseNavFragment() {
super.onCreate(savedInstanceState)
lifecycleScope.launchWhenStarted {
viewModel.showSheet.collectLatest {
it?.let {
RepositorySheetX(it).showNow(childFragmentManager, "Repository $it")
}
}
}
return ComposeView(requireContext()).apply {
setContent { ReposPage() }
}

View File

@ -11,7 +11,9 @@ import com.looker.droidify.database.entity.Repository.Companion.newRepository
import com.looker.droidify.service.Connection
import com.looker.droidify.service.SyncService
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
@ -23,8 +25,8 @@ class RepositoriesViewModelX(val repositoryDao: RepositoryDao) : ViewModel() {
val syncConnection = Connection(SyncService::class.java)
private val _showSheet = MutableStateFlow<Long?>(null)
val showSheet = _showSheet.asStateFlow()
private val _showSheet = MutableSharedFlow<Long>()
val showSheet: SharedFlow<Long> = _showSheet
private val _repositories = MutableStateFlow<List<Repository>>(emptyList())
val repositories = _repositories.asStateFlow()