Skip to content

Commit

Permalink
Merge pull request #44 from stslex/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
stslex authored Sep 3, 2023
2 parents dce20b8 + 71261e0 commit 6b80ef3
Show file tree
Hide file tree
Showing 107 changed files with 999 additions and 669 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.

4 changes: 3 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

[![Android CI/CD](https://github.com/stslex/Notes/actions/workflows/android_jobs.yml/badge.svg)](https://github.com/stslex/Notes/actions/workflows/android_jobs.yml)
[![Android CI/CD](https://github.com/stslex/Notes/actions/workflows/android_jobs.yml/badge.svg)](https://github.com/stslex/Notes/actions/workflows/android_jobs.yml) \
[![Deploy beta Store](https://github.com/stslex/Notes/actions/workflows/android_deploy_beta.yml/badge.svg)](https://github.com/stslex/Notes/actions/workflows/android_jobs.yml) \
[![Deploy prod Store](https://github.com/stslex/Notes/actions/workflows/android_deploy_prod.yml/badge.svg)](https://github.com/stslex/Notes/actions/workflows/android_jobs.yml)

https://stslex.github.io/Notes/

Expand Down
9 changes: 3 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import java.io.FileInputStream
import java.io.InputStreamReader
import java.util.Properties

plugins {
id("notes.android.application")
id("notes.android.application.compose")
}

android.namespace = "com.stslex93.notes"

dependencies {
implementation(project(":core:core"))
implementation(project(":core:ui"))
implementation(project(":core:database"))
implementation(project(":core:notes"))
implementation(project(":core:navigation"))
implementation(project(":feature:home"))
implementation(project(":feature:edit"))
}

android.namespace = "com.stslex93.notes"
38 changes: 16 additions & 22 deletions app/src/main/java/com/stslex93/notes/NoteApplication.kt
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
package com.stslex93.notes

import android.app.Application
import com.stslex93.notes.core.database.coreDatabaseModule
import com.stslex93.notes.core.notes.di.coreNotesModule
import com.stslex93.notes.feature.edit.di.featureEditModule
import com.stslex93.notes.feature.home.di.featureHomeModule
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin
import com.stslex93.notes.core.core.AppApi
import com.stslex93.notes.core.core.ApplicationApi
import com.stslex93.notes.di.app.AppComponent
import com.stslex93.notes.di.app.DaggerAppComponent

class NoteApplication : Application() {
class NoteApplication : Application(), ApplicationApi {

override fun onCreate() {
setUpKoin()
super.onCreate()
private val appComponent: AppComponent by lazy {
DaggerAppComponent
.builder()
.context(this)
.build()
}

private fun setUpKoin() {
startKoin {
androidLogger()
androidContext(this@NoteApplication)
modules(
coreDatabaseModule,
coreNotesModule,
featureEditModule,
featureHomeModule,
)
}
override val appApi: AppApi
get() = appComponent

override fun onCreate() {
appComponent.inject(this)
super.onCreate()
}
}
24 changes: 24 additions & 0 deletions app/src/main/java/com/stslex93/notes/di/app/AppComponent.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.stslex93.notes.di.app

import android.content.Context
import com.stslex93.notes.NoteApplication
import com.stslex93.notes.core.core.AppApi
import dagger.BindsInstance
import dagger.Component
import javax.inject.Singleton

@Singleton
@Component
interface AppComponent : AppApi {

@Component.Builder
interface Builder {

@BindsInstance
fun context(context: Context): Builder

fun build(): AppComponent
}

fun inject(application: NoteApplication)
}
27 changes: 27 additions & 0 deletions app/src/main/java/com/stslex93/notes/di/main/MainComponent.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.stslex93.notes.di.main

import com.stslex93.notes.core.core.AppApi
import com.stslex93.notes.core.ui.di.NavigationApi
import dagger.Component

@Component(dependencies = [MainDependencies::class])
interface MainComponent {

@Component.Factory
interface Factory {
fun create(dependencies: MainDependencies): MainComponent
}

@Component(dependencies = [AppApi::class, NavigationApi::class])
interface MainDependenciesComponent : MainDependencies {

@Component.Factory
interface Factory {
fun create(
appApi: AppApi,
navigationApi: NavigationApi
): MainDependenciesComponent
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.stslex93.notes.di.main

import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import com.stslex93.notes.core.core.AppApi
import com.stslex93.notes.core.core.appApi
import com.stslex93.notes.core.ui.di.NavigationApi

object MainComponentBuilder {

fun build(
appApi: AppApi,
navigationApi: NavigationApi
): MainComponent = DaggerMainComponent
.factory()
.create(
DaggerMainComponent_MainDependenciesComponent.factory()
.create(
appApi = appApi,
navigationApi = navigationApi
)
)

@Composable
fun Build(navigationApi: NavigationApi) {
val context = LocalContext.current
build(
appApi = context.appApi,
navigationApi = navigationApi
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.stslex93.notes.di.main

import com.stslex93.notes.core.ui.di.Navigator

interface MainDependencies {

val navigator: Navigator
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/stslex93/notes/ui/AppInit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fun AppInit(
) {
val systemUiController = rememberSystemUiController()
val isDarkTheme = isSystemInDarkTheme()

DisposableEffect(systemUiController, isDarkTheme) {
systemUiController.setSystemBarsColor(
color = Color.Transparent,
Expand Down
36 changes: 18 additions & 18 deletions app/src/main/java/com/stslex93/notes/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ package com.stslex93.notes.ui
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.Composable
import androidx.core.view.WindowCompat
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.stslex93.notes.core.navigation.di.moduleCoreNavigation
import org.koin.androidx.compose.getKoin
import com.stslex93.notes.core.navigation.di.NavigationComponentBuilder
import com.stslex93.notes.core.ui.di.MainUiApi
import com.stslex93.notes.core.ui.di.NavigationApi
import com.stslex93.notes.core.ui.theme.AppTheme
import com.stslex93.notes.di.main.MainComponentBuilder

class MainActivity : AppCompatActivity() {
class MainActivity : AppCompatActivity(), MainUiApi {

private var _navigationApi: NavigationApi? = null
override val navigationApi: NavigationApi
get() = requireNotNull(_navigationApi)

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
val navController = rememberNavController()
_navigationApi = NavigationComponentBuilder
.build(navController)
.also { api ->
MainComponentBuilder.Build(api)
}

AppTheme {
val navController = rememberNavController()
SetupComposeDependencies(navController)
AppInit(navController)
}
}
}

@Composable
private fun SetupComposeDependencies(
navController: NavHostController
) {
getKoin().loadModules(
listOf(moduleCoreNavigation(navController))
)
}
}
}
23 changes: 0 additions & 23 deletions app/src/main/java/com/stslex93/notes/ui/MaterialTheme.kt

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/java/com/stslex93/notes/ui/NavigationHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import com.stslex93.notes.core.navigation.AppDestination
import com.stslex93.notes.core.navigation.model.AppDestination
import com.stslex93.notes.feature.edit.ui.init.editGraph
import com.stslex93.notes.feature.home.ui.init.homeGraph

Expand Down
68 changes: 0 additions & 68 deletions app/src/test/java/com/stslex93/notes/data/di/AppModuleTest.kt

This file was deleted.

4 changes: 2 additions & 2 deletions build-logic/dependencies/src/main/kotlin/AppVersion.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
object AppVersion {
const val VERSION_CODE = 12
const val VERSION_NAME = "1.12"
const val VERSION_CODE = 16
const val VERSION_NAME = "1.16"
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ internal fun Project.configureAndroidCompose(

val material = libs.findLibrary("material").get()
add("implementation", material)

val lifecycle = libs.findBundle("lifecycle").get()
add("implementation", lifecycle)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ internal fun Project.configureKotlinAndroid(
val immutableCollection = libs.findLibrary("kotlinx-collections-immutable").get()
add("implementation", immutableCollection)

// TODO вынести
val koin = libs.findBundle("koin").get()
add("implementation", koin)
val dagger = libs.findLibrary("dagger-core").get()
add("implementation", dagger)

val daggerCompiler = libs.findLibrary("dagger-compiler").get()
add("ksp", daggerCompiler)
}
}

Expand Down
1 change: 1 addition & 0 deletions core/core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
5 changes: 5 additions & 0 deletions core/core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
plugins {
id("notes.android.library")
}

android.namespace = "com.stslex93.notes.core.core"
Empty file added core/core/consumer-rules.pro
Empty file.
Loading

0 comments on commit 6b80ef3

Please sign in to comment.