Skip to content

Commit

Permalink
feat(ui): add provider what's new screen and init provider test screen
Browse files Browse the repository at this point in the history
  • Loading branch information
rhenwinch committed Jun 11, 2024
1 parent 856ea3f commit 7178d04
Show file tree
Hide file tree
Showing 16 changed files with 247 additions and 80 deletions.
5 changes: 4 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,11 @@ dependencies {
implementation(projects.feature.mobile.home)
implementation(projects.feature.mobile.player)
implementation(projects.feature.mobile.preferences)
implementation(projects.feature.mobile.providerList)
implementation(projects.feature.mobile.providerInfo)
implementation(projects.feature.mobile.providerList)
implementation(projects.feature.mobile.providerSettings)
implementation(projects.feature.mobile.providerTest)
implementation(projects.feature.mobile.providerWhatsNew)
implementation(projects.feature.mobile.recentlyWatched)
implementation(projects.feature.mobile.repository)
implementation(projects.feature.mobile.repositorySearch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.flixclusive.core.ui.common

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -23,17 +23,21 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.flixclusive.core.util.R as UtilR

val COMMON_TOP_BAR_HEIGHT = 65.dp

@Composable
fun CommonTopBar(
modifier: Modifier = Modifier,
headerTitle: String,
onNavigationIconClick: () -> Unit,
endContent: (@Composable () -> Unit)? = null,
) {
Column(
Box(
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.surface)
.statusBarsPadding()
.height(COMMON_TOP_BAR_HEIGHT),
contentAlignment = Alignment.TopCenter
) {
Spacer(modifier = Modifier.statusBarsPadding())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ object DummyDataForPreview {
authors = List(5) { Author("FLX $it") },
repositoryUrl = "https://github.com/flixclusive/123Movies",
buildUrl = "https://raw.githubusercontent.com/Flixclusive/plugins-template/builds/updater.json",
changelog = """Test""",
changelog = """
# v1.0.0
- Added new feature
- Fixed a bug
""".trimIndent(),
versionName = "1.0.0",
versionCode = 10000,
description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
Expand Down
1 change: 1 addition & 0 deletions core/util/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
<string name="source_data_dialog_state_unavailable_default">I\'m sorry, this is not yet watchable</string>
<string name="unavailable_episode">Episode is not yet available</string>
<string name="unknown_provider_type">Unknown provider type</string>
<string name="coming_soon_feature">This feature is coming soon!</string>
<string name="up_to_date">Version is up to date!</string>
<string name="watchlist_empty_message">Start adding now!</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ fun ProviderInfoScreen(
.padding(bottom = 10.dp),
providerInstallationStatus = viewModel.providerInstallationStatus,
onTestProvider = {
context.showToast(context.getString(UtilR.string.coming_soon_feature))
navigator.testProviders(listOf(args.providerData))
},
onToggleInstallationState = viewModel::toggleInstallation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import androidx.compose.runtime.currentComposer
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import com.flixclusive.core.ui.common.COMMON_TOP_BAR_HEIGHT
import com.flixclusive.core.ui.common.CommonTopBar
import com.flixclusive.core.ui.common.navigation.GoBackAction
import com.flixclusive.core.ui.common.navigation.ProviderInfoScreenNavArgs
import com.ramcosta.composedestinations.annotation.Destination
Expand All @@ -30,7 +32,7 @@ fun ProviderSettingsScreen(
Box(
modifier = Modifier
.statusBarsPadding()
.padding(top = TOP_BAR_HEIGHT)
.padding(top = COMMON_TOP_BAR_HEIGHT)
) {
if (viewModel.providerInstance != null) {
// Need to call the composable with the reflection way bc
Expand All @@ -49,8 +51,8 @@ fun ProviderSettingsScreen(
}
}

ProviderSettingsTopBar(
label = args.providerData.name,
CommonTopBar(
headerTitle = args.providerData.name,
onNavigationIconClick = navigator::goBack
)
}
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions feature/mobile/provider-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
23 changes: 23 additions & 0 deletions feature/mobile/provider-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.flixclusive.feature)
alias(libs.plugins.flixclusive.compose)
alias(libs.plugins.flixclusive.destinations)
}

android {
namespace = "com.flixclusive.feature.mobile.provider.test"
}

dependencies {
implementation(projects.core.ui.mobile)
implementation(projects.data.provider)

implementation(libs.coil.compose)
implementation(libs.compose.foundation)
implementation(libs.compose.material3)
implementation(libs.compose.runtime)
implementation(libs.compose.ui)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.lifecycle.runtimeCompose)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.flixclusive.feature.mobile.provider.test

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import com.flixclusive.core.ui.common.navigation.ProviderInfoScreenNavArgs
import com.flixclusive.data.provider.ProviderManager
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class ProviderSettingsScreenViewModel @Inject constructor(
providerManager: ProviderManager,
savedStateHandle: SavedStateHandle
) : ViewModel() {
val providerData = savedStateHandle.navArgs<ProviderInfoScreenNavArgs>().providerData
val providerInstance = providerManager.providers[providerData.name]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.flixclusive.feature.mobile.provider.test

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.currentComposer
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import com.flixclusive.core.ui.common.COMMON_TOP_BAR_HEIGHT
import com.flixclusive.core.ui.common.CommonTopBar
import com.flixclusive.core.ui.common.navigation.GoBackAction
import com.flixclusive.core.ui.common.navigation.ProviderInfoScreenNavArgs
import com.ramcosta.composedestinations.annotation.Destination

@Destination(
navArgsDelegate = ProviderInfoScreenNavArgs::class
)
@Composable
fun ProviderTestScreen(
navigator: GoBackAction,
args: ProviderInfoScreenNavArgs
) {
val viewModel = hiltViewModel<ProviderSettingsScreenViewModel>()

Box(
modifier = Modifier
.fillMaxSize()
) {
Box(
modifier = Modifier
.statusBarsPadding()
.padding(top = COMMON_TOP_BAR_HEIGHT)
) {
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)
}
}

CommonTopBar(
headerTitle = args.providerData.name,
onNavigationIconClick = navigator::goBack
)
}
}
1 change: 1 addition & 0 deletions feature/mobile/provider-whats-new/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
24 changes: 24 additions & 0 deletions feature/mobile/provider-whats-new/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.flixclusive.feature)
alias(libs.plugins.flixclusive.compose)
alias(libs.plugins.flixclusive.destinations)
}

android {
namespace = "com.flixclusive.feature.mobile.provider.whats_new"
}

dependencies {
implementation(projects.core.ui.mobile)
implementation(projects.data.provider)

implementation(libs.coil.compose)
implementation(libs.compose.foundation)
implementation(libs.compose.material3)
implementation(libs.compose.runtime)
implementation(libs.compose.ui)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.lifecycle.runtimeCompose)
implementation(libs.markdown)
}
Loading

0 comments on commit 7178d04

Please sign in to comment.