Skip to content

Commit

Permalink
refactor(openfeedback): migrate to repo architecture in data layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Oct 31, 2023
1 parent 7828371 commit 9ef731d
Show file tree
Hide file tree
Showing 25 changed files with 380 additions and 626 deletions.
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,17 @@ configuration which is common for all sessions of your event.

```kotlin
// In your Application class
val config = OpenFeedbackConfig(
context = context,
projectId = "<your-open-feedback-project-id>",
firebaseConfig = OpenFeedback.FirebaseConfig(
projectId = "<your-firebase-open-feedback-project-id>",
applicationId = "<your-firebase-open-feedback-app-id>",
apiKey = "<your-firebase-open-feedback-api-key>",
databaseUrl = "https://<your-firebase-open-feedback-project-id>.firebaseio.com"
)
val firebaseConfig = FirebaseConfig(
projectId = "<your-firebase-open-feedback-project-id>",
applicationId = "<your-firebase-open-feedback-app-id>",
apiKey = "<your-firebase-open-feedback-api-key>",
databaseUrl = "https://<your-firebase-open-feedback-project-id>.firebaseio.com"
)

// In your Compose screen
OpenFeedback(
openFeedbackState = MyApp.config,
config = MyApp.firebaseConfig,
projectId = "<your-open-feedback-project-id>",
sessionId = "<your-open-feedback-session-id>",
language = "<language-code>"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,29 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import io.openfeedback.android.OpenFeedbackConfig
import io.openfeedback.android.FirebaseConfig
import io.openfeedback.android.viewmodels.OpenFeedbackUiState
import io.openfeedback.android.viewmodels.OpenFeedbackViewModel
import io.openfeedback.android.viewmodels.models.UISessionFeedback
import io.openfeedback.android.viewmodels.models.UIVoteItem

@Deprecated(
message = "Use OpenFeedback component with projectId parameter."
)
@Composable
fun OpenFeedback(
openFeedbackState: OpenFeedbackConfig,
sessionId: String,
language: String,
modifier: Modifier = Modifier,
loading: @Composable () -> Unit = { Loading(modifier = modifier) }
) = OpenFeedback(
config = openFeedbackState,
projectId = openFeedbackState.openFeedbackProjectId,
sessionId = sessionId,
language = language,
modifier = modifier,
loading = loading
)

@Composable
fun OpenFeedback(
config: OpenFeedbackConfig,
config: FirebaseConfig,
projectId: String,
sessionId: String,
language: String,
modifier: Modifier = Modifier,
loading: @Composable () -> Unit = { Loading(modifier = modifier) }
) {
val context = LocalContext.current
val viewModel: OpenFeedbackViewModel = viewModel(
factory = OpenFeedbackViewModel.Factory.create(
openFeedbackConfig = config,
context = context,
firebaseConfig = config,
projectId = projectId,
sessionId = sessionId,
language = language
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.openfeedback.android.R as ROF

@Composable
fun PoweredBy(
Expand All @@ -27,9 +28,9 @@ fun PoweredBy(
color: Color = MaterialTheme.colors.onBackground
) {
val logo =
if (MaterialTheme.colors.isLight) R.drawable.openfeedback_light
else R.drawable.openfeedback_dark
val poweredBy = stringResource(id = R.string.powered_by)
if (MaterialTheme.colors.isLight) ROF.drawable.openfeedback_light
else ROF.drawable.openfeedback_dark
val poweredBy = stringResource(id = ROF.string.powered_by)
Row(
modifier = modifier.semantics(mergeDescendants = true) {
contentDescription = "$poweredBy Openfeedback"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,29 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import io.openfeedback.android.OpenFeedbackConfig
import io.openfeedback.android.FirebaseConfig
import io.openfeedback.android.viewmodels.OpenFeedbackUiState
import io.openfeedback.android.viewmodels.OpenFeedbackViewModel
import io.openfeedback.android.viewmodels.models.UISessionFeedback
import io.openfeedback.android.viewmodels.models.UIVoteItem

@Deprecated(
message = "Use OpenFeedback component with projectId parameter."
)
@Composable
fun OpenFeedback(
openFeedbackState: OpenFeedbackConfig,
sessionId: String,
language: String,
modifier: Modifier = Modifier,
loading: @Composable () -> Unit = { Loading(modifier = modifier) }
) = OpenFeedback(
config = openFeedbackState,
projectId = openFeedbackState.openFeedbackProjectId,
sessionId = sessionId,
language = language,
modifier = modifier,
loading = loading
)

@Composable
fun OpenFeedback(
config: OpenFeedbackConfig,
config: FirebaseConfig,
projectId: String,
sessionId: String,
language: String,
modifier: Modifier = Modifier,
loading: @Composable () -> Unit = { Loading(modifier = modifier) }
) {
val context = LocalContext.current
val viewModel: OpenFeedbackViewModel = viewModel(
factory = OpenFeedbackViewModel.Factory.create(
openFeedbackConfig = config,
context = context,
firebaseConfig = config,
projectId = projectId,
sessionId = sessionId,
language = language
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.openfeedback.android.m3

import androidx.compose.foundation.Image
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.height
Expand All @@ -18,6 +17,7 @@ import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.dp
import io.openfeedback.android.R as ROF

@Composable
internal fun PoweredBy(
Expand All @@ -27,9 +27,9 @@ internal fun PoweredBy(
) {

val logo =
if (MaterialTheme.colorScheme.background.luminance() > 0.5) R.drawable.openfeedback_light
else R.drawable.openfeedback_dark
val poweredBy = stringResource(id = R.string.powered_by)
if (MaterialTheme.colorScheme.background.luminance() > 0.5) ROF.drawable.openfeedback_light
else ROF.drawable.openfeedback_dark
val poweredBy = stringResource(id = ROF.string.powered_by)
Row(
modifier = modifier.semantics(mergeDescendants = true) {
contentDescription = "$poweredBy Openfeedback"
Expand Down
24 changes: 0 additions & 24 deletions openfeedback-ui/build.gradle.kts

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9ef731d

Please sign in to comment.