Skip to content

Commit

Permalink
Modularized the app and moved the book details
Browse files Browse the repository at this point in the history
  • Loading branch information
donald-okara committed Jan 22, 2025
1 parent dc4ff3c commit d6ad205
Show file tree
Hide file tree
Showing 81 changed files with 1,367 additions and 521 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

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

6 changes: 5 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.hilt.android)
alias(libs.plugins.kotlin.serialization)
id("kotlin-kapt")
id("kotlin-parcelize")
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.0"
}

android {
Expand Down Expand Up @@ -99,6 +99,10 @@ dependencies {
//noinspection KaptUsageInsteadOfKsp
kapt(libs.compiler)

implementation(project(":common-navigation"))
implementation(project(":common-domain"))


testImplementation(libs.junit)
testImplementation(libs.mockito.kotlin)
testImplementation(libs.kotlinx.coroutines.test)
Expand Down
17 changes: 1 addition & 16 deletions app/src/main/java/com/don/preface/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.don.preface.presentation.navigation.NavGraph
import com.don.preface.presentation.screens.book_details.BookDetailsScreen
import com.don.preface.presentation.screens.search.BookSearchScreen
import com.don.preface.presentation.screens.search.SearchViewModel
import com.don.preface.ui.theme.PrefaceTheme
import dagger.hilt.android.AndroidEntryPoint
import ke.don.shared_navigation.NavGraph
import kotlinx.coroutines.delay

@AndroidEntryPoint
Expand All @@ -42,12 +36,9 @@ class MainActivity : ComponentActivity() {
PrefaceTheme {
val navController = rememberNavController()

val searchViewModel: SearchViewModel = hiltViewModel()

Surface(modifier = Modifier.fillMaxSize()) {
NavGraph(
navController = navController,
searchViewModel = searchViewModel
)

}
Expand All @@ -56,12 +47,6 @@ class MainActivity : ComponentActivity() {
}
}

enum class PrefaceScreens {
Splash,
Search,
Details, // Future screens can be added here
}

@Composable
fun PrefaceSplashScreen(
modifier: Modifier = Modifier,
Expand Down

This file was deleted.

This file was deleted.

86 changes: 0 additions & 86 deletions app/src/test/java/com/don/preface/fake/data/FakeBooksDataSource.kt

This file was deleted.

1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ plugins {
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.hilt.android) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.android.library) apply false
}
1 change: 1 addition & 0 deletions common-domain/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
43 changes: 43 additions & 0 deletions common-domain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
}

android {
namespace = "ke.don.shared_domain"
compileSdk = 35

defaultConfig {
minSdk = 24

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}
File renamed without changes.
21 changes: 21 additions & 0 deletions common-domain/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ke.don.shared_domain

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("ke.don.shared_domain.test", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions common-domain/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.don.preface.presentation.navigation
package ke.don.shared_domain.screens

sealed class Screens(
var route: String
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ke.don.shared_domain

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)
}
}
1 change: 1 addition & 0 deletions common-navigation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Loading

0 comments on commit d6ad205

Please sign in to comment.