-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
392 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
plugins { | ||
alias(libs.plugins.android.library) | ||
alias(libs.plugins.kotlin.android) | ||
alias(libs.plugins.composeCompiler) | ||
alias(libs.plugins.jetbrainsCompose) | ||
alias(libs.plugins.screenshot) | ||
alias(libs.plugins.serialization) | ||
} | ||
|
||
android { | ||
namespace = "dev.kioba.feature.details" | ||
|
||
compileSdk = libs.versions.compileSdk | ||
.get() | ||
.toInt() | ||
|
||
defaultConfig { | ||
minSdk = 21 | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_17.toString() | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
@Suppress("UnstableApiUsage") | ||
experimentalProperties["android.experimental.enableScreenshotTest"] = true | ||
|
||
@Suppress("UnstableApiUsage") | ||
testOptions { | ||
screenshotTests { | ||
imageDifferenceThreshold = 0.05f // 5% | ||
} | ||
|
||
} | ||
} | ||
|
||
kotlin { | ||
explicitApi() | ||
} | ||
|
||
dependencies { | ||
// implementation(projects.designSystem) | ||
// implementation(projects.domain.post.api) | ||
// implementation(projects.domain.post.fakes) | ||
// implementation(projects.domain.user.api) | ||
// implementation(projects.domain.user.fakes) | ||
implementation(projects.platform.androidCompose) | ||
implementation(projects.platform.androidDatabase) | ||
implementation(projects.platform.database) | ||
implementation(projects.platform.domain) | ||
implementation(projects.platform.network) | ||
implementation(projects.platform.test) | ||
|
||
implementation(libs.bundles.compose) | ||
implementation(libs.navigation.compose) | ||
implementation(platform(libs.androidX.compose.bom)) | ||
|
||
implementation(libs.arrow.core) | ||
|
||
implementation(libs.architecture.anchor) | ||
implementation(libs.kotlinX.coroutines.core) | ||
implementation(libs.kotlinX.coroutines.android) | ||
implementation(libs.kotlinx.serialization.json) | ||
|
||
testImplementation(libs.test.mockK) | ||
testImplementation(libs.test.junit4) | ||
testImplementation(libs.architecture.anchorTest) | ||
androidTestImplementation(libs.androidTest.androidXTest.core) | ||
androidTestImplementation(libs.androidTest.androidXTest.junit) | ||
androidTestImplementation(libs.androidTest.testRunner) | ||
androidTestImplementation(libs.androidTest.espresso) | ||
} |
24 changes: 24 additions & 0 deletions
24
feature/details/src/androidTest/kotlin/dev/kioba/feature/details/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dev.kioba.feature.details | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("dev.kioba.feature.details.test", appContext.packageName) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
feature/details/src/main/kotlin/dev/kioba/feature/details/data/DetailsEffects.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package dev.kioba.feature.details.data | ||
|
||
import dev.kioba.anchor.Anchor | ||
import dev.kioba.anchor.Effect | ||
import dev.kioba.anchor.RememberAnchorScope | ||
import dev.kioba.feature.details.model.DetailsViewState | ||
import dev.kioba.platform.database.DatabaseScope | ||
import dev.kioba.platform.domain.EffectContext | ||
import dev.kioba.platform.domain.buildEffectContext | ||
import dev.kioba.platform.network.NetworkScope | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
|
||
internal typealias DetailsAnchor = Anchor<DetailsEffects, DetailsViewState> | ||
|
||
public class DetailsEffects( | ||
databaseScope: DatabaseScope, | ||
networkScope: NetworkScope, | ||
) : EffectContext by buildEffectContext(databaseScope, networkScope), Effect | ||
|
||
internal fun RememberAnchorScope.detailsAnchor( | ||
effectsScope: DetailsEffects, | ||
): DetailsAnchor = | ||
create( | ||
initialState = ::DetailsViewState, | ||
effectScope = { effectsScope }, | ||
init = DetailsAnchor::init, | ||
) { | ||
listen(::onCreated) | ||
} | ||
|
||
fun onCreated(any: Any): Flow<*> { | ||
TODO("Not yet implemented") | ||
} |
7 changes: 7 additions & 0 deletions
7
feature/details/src/main/kotlin/dev/kioba/feature/details/model/DetailsViewState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package dev.kioba.feature.details.model | ||
|
||
import dev.kioba.anchor.ViewState | ||
|
||
internal data class DetailsViewState( | ||
val isLoading: Boolean = true, | ||
): ViewState |
39 changes: 39 additions & 0 deletions
39
feature/details/src/main/kotlin/dev/kioba/feature/details/ui/DetailsPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package dev.kioba.feature.details.ui | ||
|
||
import android.content.Context | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.navigation.NavBackStackEntry | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.compose.composable | ||
import dev.kioba.anchor.compose.RememberAnchor | ||
import dev.kioba.android.database.buildDatabaseScope | ||
import dev.kioba.feature.details.data.DetailsEffects | ||
import dev.kioba.feature.details.data.detailsAnchor | ||
import dev.kioba.platform.network.buildNetworkScope | ||
import kotlinx.serialization.Serializable | ||
|
||
|
||
private fun DetailsEffects( | ||
context: Context, | ||
): DetailsEffects = | ||
DetailsEffects( | ||
networkScope = buildNetworkScope(), | ||
databaseScope = buildDatabaseScope(context), | ||
) | ||
|
||
public fun NavGraphBuilder.feedComposable( | ||
) { | ||
composable<DetailsDestination> { stack -> stack.DetailsPage() } | ||
} | ||
|
||
@Serializable | ||
public data object DetailsDestination | ||
|
||
@Composable | ||
private fun NavBackStackEntry.DetailsPage() { | ||
val context = LocalContext.current | ||
RememberAnchor( | ||
scope = { detailsAnchor(DetailsEffects(context)) }, | ||
) { state -> DetailsUi(state = state) } | ||
} |
17 changes: 17 additions & 0 deletions
17
feature/details/src/test/kotlin/dev/kioba/feature/details/ExampleUnitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package dev.kioba.feature.details | ||
|
||
import org.junit.Test | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
class ExampleUnitTest { | ||
@Test | ||
fun addition_isCorrect() { | ||
assertEquals(4, 2 + 2) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 16 additions & 3 deletions
19
feature/feed/src/main/kotlin/dev/kioba/feature/feed/ui/FeedPage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,36 @@ | ||
package dev.kioba.feature.feed.ui | ||
|
||
import android.content.Context | ||
import androidx.activity.ComponentActivity | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.navigation.NavBackStackEntry | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.compose.composable | ||
import dev.kioba.anchor.compose.RememberAnchor | ||
import dev.kioba.android.database.buildDatabaseScope | ||
import dev.kioba.feature.feed.data.FeedEffects | ||
import dev.kioba.feature.feed.data.feedAnchor | ||
import dev.kioba.platform.network.buildNetworkScope | ||
import kotlinx.serialization.Serializable | ||
|
||
private fun FeedEffects(context: Context): FeedEffects = | ||
FeedEffects( | ||
networkScope = buildNetworkScope(), | ||
databaseScope = buildDatabaseScope(context = context) | ||
) | ||
|
||
public fun NavGraphBuilder.feedComposable( | ||
) { | ||
composable<FeedDestination> { stack -> stack.FeedPage() } | ||
} | ||
|
||
@Serializable | ||
public data object FeedDestination | ||
|
||
@Composable | ||
public fun ComponentActivity.FeedPage() { | ||
private fun NavBackStackEntry.FeedPage() { | ||
val context = LocalContext.current | ||
RememberAnchor( | ||
scope = { feedAnchor(FeedEffects(this@FeedPage)) }, | ||
scope = { feedAnchor(FeedEffects(context)) }, | ||
) { state -> FeedUi(state = state) } | ||
} |
Oops, something went wrong.