Skip to content

Commit

Permalink
- Migrate to Hilt.
Browse files Browse the repository at this point in the history
- Design container UI from scratch.
- Add dynamic theming.
  • Loading branch information
Akashkamble committed Aug 28, 2020
1 parent 9e1220c commit 018cbd9
Show file tree
Hide file tree
Showing 33 changed files with 549 additions and 863 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

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

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

2 changes: 1 addition & 1 deletion .idea/misc.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

49 changes: 30 additions & 19 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'


android {
compileSdkVersion 29

defaultConfig {
applicationId "com.akash.newzz_compose"
applicationId "com.akash.newzzcompose"
minSdkVersion 21
targetSdkVersion 29
versionCode 2
Expand All @@ -28,51 +29,61 @@ android {
}
kotlinOptions {
jvmTarget = '1.8'
useIR = true
}
buildFeatures {
compose true
}

composeOptions {
kotlinCompilerVersion "1.3.70-dev-withExperimentalGoogleExtensions-20200424"
kotlinCompilerExtensionVersion "0.1.0-dev14"
kotlinCompilerVersion "$kotlin_version"
kotlinCompilerExtensionVersion "$compose_version"
}
}

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation project(':data')
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "androidx.activity:activity-ktx:1.1.0"
implementation 'android.arch.lifecycle:extensions:1.1.1'

/* ---------------------JetPack Compose-----------------------------*/
implementation("androidx.compose:compose-runtime:$compose_version")
implementation("androidx.ui:ui-core:$compose_version")
implementation "androidx.ui:ui-layout:$compose_version"
implementation "androidx.ui:ui-material:$compose_version"
implementation "androidx.ui:ui-tooling:$compose_version"
implementation "androidx.ui:ui-livedata:$compose_version"
implementation("androidx.compose.runtime:runtime:$compose_version")
implementation("androidx.compose.runtime:runtime-livedata:$compose_version")
implementation("androidx.compose.foundation:foundation:$compose_version")
implementation("androidx.compose.foundation:foundation-layout:$compose_version")

implementation("androidx.compose.ui:ui:$compose_version")
implementation("androidx.compose.material:material:$compose_version")
implementation("androidx.compose.material:material-icons-extended:$compose_version")

implementation("androidx.ui:ui-tooling:$compose_version")

/* ---------------------LifeCycle Extension-----------------------------*/
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"

/*-----------------------Koin-------------------------------------*/
implementation "org.koin:koin-android:$koin_version"
implementation "org.koin:koin-android-viewmodel:$koin_version"
/*------------------------Dagger Hilt----------------------------------*/
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"

implementation "androidx.hilt:hilt-lifecycle-viewmodel:$hilt_jetpack_config_version"
kapt "androidx.hilt:hilt-compiler:$hilt_jetpack_config_version"

/*---------------------ChromeCustomTab------------------------------*/
implementation 'androidx.browser:browser:1.3.0-alpha04'
implementation 'androidx.browser:browser:1.3.0-alpha05'

/*---------------------CoilImageLoader------------------------------*/
implementation "dev.chrisbanes.accompanist:accompanist-coil:0.1.6"
implementation "dev.chrisbanes.accompanist:accompanist-coil:0.2.0"

/*----------------------------Moshi-------------------------------------*/
implementation 'com.squareup.moshi:moshi:1.9.1'


testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

}
17 changes: 0 additions & 17 deletions app/src/main/java/com/akash/newzz_compose/Category.kt

This file was deleted.

16 changes: 4 additions & 12 deletions app/src/main/java/com/akash/newzz_compose/NewzzApplication.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
package com.akash.newzz_compose

import com.akash.newzz.data.BaseApplication
import com.akash.newzz_compose.di.appModule
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin
import dagger.hilt.android.HiltAndroidApp

/**
* Created by Akash on 06/06/20
* Created by Akash on 28/08/20
*/
@HiltAndroidApp
class NewzzApplication : BaseApplication() {

override fun onCreate() {
super.onCreate()
startKoin {
androidLogger()
androidContext(this@NewzzApplication)
modules(appModule)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.akash.newzz_compose.di

import com.akash.newzz.data.apiservice.NewzzApiService
import com.akash.newzz.data.repository.NewsRepository
import com.akash.newzz.data.repository.NewsRepositoryImpl
import com.squareup.moshi.Moshi
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.scopes.ActivityScoped

/**
* Created by Akash on 28/08/20
*/

@Module
@InstallIn(ActivityComponent::class)
object NewzzActivityModule {

@Provides
@ActivityScoped
fun provideNewsApiService(): NewzzApiService = NewzzApiService()

@Provides
@ActivityScoped
fun provideNewsRepo(
apiService: NewzzApiService,
moshi: Moshi
): NewsRepository = NewsRepositoryImpl(apiService, moshi)

@Provides
@ActivityScoped
fun provideMoshi(): Moshi = Moshi.Builder().build()
}
20 changes: 0 additions & 20 deletions app/src/main/java/com/akash/newzz_compose/di/module.kt

This file was deleted.

36 changes: 36 additions & 0 deletions app/src/main/java/com/akash/newzz_compose/other/Category.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.akash.newzz_compose.other

import com.akash.newzz_compose.R

/**
* Created by Akash on 28/08/20
*/

interface Category {
val category: String
val icon: Int
}


data class General(
override val category: String = "general",
override val icon: Int = R.drawable.ic_general
) : Category

data class Business(
override val category: String = "business",
override val icon: Int = R.drawable.ic_business
) : Category

data class Technology(
override val category: String = "technology",
override val icon: Int = R.drawable.ic_tech
) : Category


fun getTitleResource(activeCategory: Category): Int = when (activeCategory) {
is General -> R.string.title_general
is Business -> R.string.title_business
is Technology -> R.string.title_technology
else -> throw IllegalAccessException("Page number is invalid")
}
34 changes: 0 additions & 34 deletions app/src/main/java/com/akash/newzz_compose/style/Color.kt

This file was deleted.

24 changes: 0 additions & 24 deletions app/src/main/java/com/akash/newzz_compose/style/Theme.kt

This file was deleted.

30 changes: 18 additions & 12 deletions app/src/main/java/com/akash/newzz_compose/ui/NewzzActivity.kt
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
package com.akash.newzz_compose.ui

import android.os.Bundle
import android.util.Log
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.ui.core.setContent
import androidx.ui.livedata.observeAsState
import androidx.ui.material.MaterialTheme
import com.akash.newzz_compose.style.darkThemeColor
import com.akash.newzz_compose.style.themeColor
import com.akash.newzz_compose.ui.home.Home
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.platform.setContent
import com.akash.newzz_compose.ui.newzzappui.NewzzAppUI
import com.akash.newzz_compose.ui.style.NewzzTheme
import com.akash.newzz_compose.viewmodel.NewzzViewModel
import org.koin.android.viewmodel.ext.android.viewModel
import dagger.hilt.android.AndroidEntryPoint

/**
* Created by Akash on 27/08/20
*/
@AndroidEntryPoint
class NewzzActivity : AppCompatActivity() {
private val viewModel: NewzzViewModel by viewModel()

private val viewModel: NewzzViewModel by viewModels()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val isDark = viewModel.isDarkTheme.observeAsState(false)
MaterialTheme(colors = if (isDark.value) darkThemeColor else themeColor) {
Home(viewModel)
val darkTheme = viewModel.isDarkTheme.observeAsState(false)
Log.d("THEME", "darkTheme: ${darkTheme.value}")
NewzzTheme(darkTheme = darkTheme.value) {
NewzzAppUI(viewModel = viewModel)
}
}
}
}
}
Loading

0 comments on commit 018cbd9

Please sign in to comment.