Skip to content

Commit

Permalink
fix: ProviderSettingsScreen cant load Provider custom settings screen
Browse files Browse the repository at this point in the history
  • Loading branch information
rhenwinch committed Apr 5, 2024
1 parent cfa3b7e commit c1233b2
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package com.flixclusive.feature.mobile.provider.settings

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.currentComposer
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.flixclusive.core.ui.common.navigation.GoBackAction
import com.flixclusive.core.ui.mobile.util.isScrollingUp
import com.flixclusive.feature.mobile.provider.settings.component.ProviderSettingsHeader
import com.flixclusive.feature.mobile.provider.settings.component.ProviderSettingsTopBar
import com.flixclusive.gradle.entities.ProviderData
import com.ramcosta.composedestinations.annotation.Destination
Expand Down Expand Up @@ -43,13 +48,41 @@ fun ProviderSettingsScreen(
onNavigationIconClick = navigator::goBack
)
}
) {
) { innerPadding ->
Box(
modifier = Modifier
.padding(it)
.padding(innerPadding)
.fillMaxSize()
) {
viewModel.providerInstance?.SettingsScreen()
LazyColumn(
state = listState,
verticalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier
.padding(horizontal = 10.dp)
) {
item {
ProviderSettingsHeader(providerData = args.providerData)
}

// This is where the SettingsScreen should go inside the ProviderManifest
item {
if (viewModel.providerInstance != null) {
// Need to call the composable with the reflection way bc
// Compose won't let us call it the normal way.
val method = remember {
viewModel.providerInstance::class.java
.declaredMethods
.find {
it.name.equals("SettingsScreen")
}?.also {
it.isAccessible = true
}
}

method?.invoke(viewModel.providerInstance, currentComposer, 0, 0)
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.flixclusive.feature.mobile.provider.settings

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import com.flixclusive.core.util.log.debugLog
import com.flixclusive.data.provider.ProviderManager
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
Expand All @@ -14,8 +13,4 @@ class ProviderSettingsScreenViewModel @Inject constructor(
) : ViewModel() {
val providerData = savedStateHandle.navArgs<ProviderSettingsScreenNavArgs>().providerData
val providerInstance = providerManager.providers[providerData.name]

init {
debugLog("Provider => $providerInstance")
}
}
9 changes: 9 additions & 0 deletions provider/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ dependencies {
api(projects.core.util)
api(projects.model.provider)

implementation(libs.coil.compose)
implementation(libs.compose.foundation)
implementation(libs.compose.material3)
implementation(libs.compose.runtime)
implementation(libs.compose.tv.material)
implementation(libs.compose.ui)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.constraintlayout.compose)
implementation(libs.coroutines.test)
implementation(libs.junit)
implementation(libs.lifecycle.runtimeCompose)
implementation(libs.mockk)
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,5 @@ abstract class Provider() {
* ```
* */
@Composable
open fun SettingsScreen(
resources: Resources? = this.resources,
) = Unit
open fun SettingsScreen() = Unit
}

0 comments on commit c1233b2

Please sign in to comment.