-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Design container UI from scratch. - Add dynamic theming.
- Loading branch information
1 parent
9e1220c
commit 018cbd9
Showing
33 changed files
with
549 additions
and
863 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
16 changes: 4 additions & 12 deletions
16
app/src/main/java/com/akash/newzz_compose/NewzzApplication.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,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) | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/com/akash/newzz_compose/di/NewzzActivityModule.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,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() | ||
} |
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/akash/newzz_compose/other/Category.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,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") | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
30 changes: 18 additions & 12 deletions
30
app/src/main/java/com/akash/newzz_compose/ui/NewzzActivity.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,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) | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.