Skip to content

Commit

Permalink
Merge pull request #57 from c0de-wizard/design-system
Browse files Browse the repository at this point in the history
Migrate to Materail3
  • Loading branch information
thomaskioko authored Mar 30, 2023
2 parents e613080 + e88e24b commit 64ee18b
Show file tree
Hide file tree
Showing 115 changed files with 3,829 additions and 3,286 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
echo -e "\TRAKT_REDIRECT_URI=$TRAKT_REDIRECT_URI" >> ./local.properties
- name: Check lint
run: ./gradlew lintDemoDebug
run: ./gradlew lint

- name: Build with gradle
run: ./gradlew assemble
Expand Down
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ You need to add API keys from [Trakt.tv](https://trakt.docs.apiary.io) & [TMDb](
### Android
- [Zulu Java 17](https://www.azul.com/downloads-new/?package=jdk#zulu)
- You require the latest [Android Studio Dolphin](https://developer.android.com/studio/preview) release to be able to build the app.
- You require the latest [Android Studio](https://developer.android.com/studio/preview) release to be able to build the app.
- Install Kmm Plugin. Checkout [this setup guide](https://kotlinlang.org/docs/kmm-setup.html).
Expand All @@ -115,33 +115,34 @@ https://user-images.githubusercontent.com/841885/223576880-c7391d14-63b8-47cd-a7
## Libraries Used
### Android
* [Accompanist](https://github.com/google/accompanist)
* [Insets](https://google.github.io/accompanist/insets/)
* [Pager Layouts](https://google.github.io/accompanist/pager/)
* [Android-youtube-player](https://github.com/PierfrancescoSoffritti/android-youtube-player) - Youtube Player
* [AppAuth](https://openid.github.io/AppAuth-Android/) - AppAuth for Android is a client SDK for communicating with OAuth 2.0 and OpenID Connect providers.
* [Compose Lints](https://slackhq.github.io/compose-lints/) - Custom lint checks for Jetpack Compose.
* [Dagger Hilt](https://dagger.dev/hilt) - dependency injection.
* [Jetpack Compose](https://developer.android.com/jetpack/compose)
* [Coil](https://coil-kt.github.io/coil/compose/) - Image loading
* [Navigation](https://developer.android.com/jetpack/compose/navigation) - Navigation
* [KenBurnsView](https://github.com/flavioarfaria/KenBurnsView) - Immersive image.
* [Leakcanary](https://github.com/square/leakcanary) - Memory leak detection.
* [ViewModel](https://developer.android.com/topic/libraries/architecture/viewmodel) UI related data holder, lifecycle
aware.
* [WorkManager](https://developer.android.com/topic/libraries/architecture/workmanager?gclsrc=ds&gclsrc=ds) Handle persistent work
* [Accompanist](https://github.com/google/accompanist)
* [Insets](https://google.github.io/accompanist/insets/)
* [Pager Layouts](https://google.github.io/accompanist/pager/)
* [Dagger Hilt](https://dagger.dev/hilt) - dependency injection.
* [KenBurnsView](https://github.com/flavioarfaria/KenBurnsView) - Immersive image.
* [Leakcanary](https://github.com/square/leakcanary) - Memory leak detection.
* [Android-youtube-player](https://github.com/PierfrancescoSoffritti/android-youtube-player) - Youtube Player
* [AppAuth](https://openid.github.io/AppAuth-Android/) - AppAuth for Android is a client SDK for communicating with OAuth 2.0 and OpenID Connect providers.
### Kmp - Common
* [Ktor](https://ktor.io/) - Networking
* [Kotlinx Serialization](https://ktor.io/docs/kotlin-serialization.html) - De/Serializing JSON
* [Coroutines](https://github.com/Kotlin/kotlinx.coroutines#multiplatform) - Concurrency & Threading
* [DataStore Preferences](https://android-developers.googleblog.com/2022/10/announcing-experimental-preview-of-jetpack-multiplatform-libraries.html) - Data storage
* [DateTime](https://github.com/Kotlin/kotlinx-datetime) - Date & Time
* [Flow-Redux](https://github.com/freeletics/FlowRedux)
* [Kermit](https://kermit.touchlab.co/) - Logging
* [koin](https://github.com/mockk/mockk) - Injection library.
* [Ktor](https://ktor.io/) - Networking
* [Kotest Assertions](https://kotest.io/docs/assertions/assertions.html) - Testing
* [SQLDelight](https://github.com/cashapp/sqldelight/) - Local storage
- [Coroutines Extensions](https://cashapp.github.io/sqldelight/js_sqlite/coroutines/) Consume queries as Flow
* [Napier](https://github.com/AAkira/Napier) - Logging
* [Mockk](https://github.com/mockk/mockk) - mocking library for Kotlin.
* [koin](https://github.com/mockk/mockk) - Injection library.
* [DataStore Preferences](https://android-developers.googleblog.com/2022/10/announcing-experimental-preview-of-jetpack-multiplatform-libraries.html) - Data storage
* [Flow-Redux](https://github.com/freeletics/FlowRedux)
### iOS
* [Kingfisher](https://github.com/onevcat/Kingfisher) - Image library.
Expand Down Expand Up @@ -191,11 +192,12 @@ Shared
- [Design Inspiration](https://dribbble.com/shots/7591814-HBO-Max-Companion-App-Animation)
- [Code Snippets](https://github.com/android/compose-samples)
- [Touchlab KaMPKit project](https://github.com/touchlab/KaMPKit)
- [Tivi](https://github.com/chrisbanes/tivi)
## License
```
Copyright 2022 Thomas Kioko
Copyright 2021 Thomas Kioko

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {

dependencies {

implementation(projects.android.core.compose)
implementation(projects.android.core.designsystem)
implementation(projects.android.core.navigation)
implementation(projects.android.features.discover)
implementation(projects.android.features.home)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,33 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.expandVertically
import androidx.compose.animation.shrinkVertically
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.compositeOver
import androidx.core.view.WindowCompat
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.thomaskioko.tvmaniac.compose.components.ConnectionStatus
import com.thomaskioko.tvmaniac.compose.theme.DarkColors
import com.thomaskioko.tvmaniac.compose.theme.LightColors
import com.thomaskioko.tvmaniac.compose.theme.TvManiacTheme
import com.thomaskioko.tvmaniac.core.util.network.ConnectionState
import com.thomaskioko.tvmaniac.core.util.network.ObserveConnectionState
import com.thomaskioko.tvmaniac.datastore.api.DatastoreRepository
import com.thomaskioko.tvmaniac.home.HomeScreen
import com.thomaskioko.tvmaniac.navigation.ComposeNavigationFactory
import com.thomaskioko.tvmaniac.datastore.api.DatastoreRepository
import com.thomaskioko.tvmaniac.settings.shouldUseDarkColors
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.distinctUntilChanged
import javax.inject.Inject

@OptIn(ExperimentalAnimationApi::class)
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
@Inject
Expand All @@ -48,50 +45,29 @@ class MainActivity : ComponentActivity() {
@Inject
lateinit var observeNetwork: ObserveConnectionState

@OptIn(ExperimentalAnimationApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)

setContent {
TvManiacTheme(darkTheme = datastoreRepository.shouldUseDarkColors()) {
SetupTheme()
HomeScreen(composeNavigationFactories)
val systemUiController = rememberSystemUiController()
val darkTheme = datastoreRepository.shouldUseDarkColors()

DisposableEffect(systemUiController, darkTheme) {
systemUiController.systemBarsDarkContentEnabled = !darkTheme
onDispose {}
}

TvManiacTheme(darkTheme = darkTheme) {
Surface {
HomeScreen(composeNavigationFactories)
}
}

ConnectivityStatus(observeNetwork)
}
}

@Composable
private fun SetupTheme() {
val systemUiController = rememberSystemUiController()
val isLightTheme = !datastoreRepository.shouldUseDarkColors()

val systemBarColor = MaterialTheme.colors.surface.copy(alpha = 0.0f)
val transparentColor: (Color) -> Color = { original ->
systemBarColor.compositeOver(original)
}
SideEffect {
systemUiController.setSystemBarsColor(
color = Color.Transparent,
darkIcons = isLightTheme
)

systemUiController.setStatusBarColor(
color = Color.Transparent,
darkIcons = isLightTheme,
transformColorForLightContent = transparentColor
)

systemUiController.setNavigationBarColor(
color = if (isLightTheme) LightColors.surface else DarkColors.primary,
darkIcons = isLightTheme,
navigationBarContrastEnforced = false,
transformColorForLightContent = transparentColor
)
}
}

@ExperimentalAnimationApi
@ExperimentalCoroutinesApi
Expand Down
4 changes: 3 additions & 1 deletion android/app/src/main/res/drawable/ic_app_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:width="512dp"
android:height="512dp"
android:viewportWidth="512"
android:viewportHeight="512">
android:viewportHeight="512"
tools:ignore="VectorRaster">
<path
android:pathData="m504.1,256c0,-137 -111.1,-248.1 -248.1,-248.1c-137,0 -248.1,111.1 -248.1,248.1c0,137 111.1,248.1 248.1,248.1c137,0 248.1,-111.1 248.1,-248.1z"
android:fillColor="#ffbe0b"/>
Expand Down
9 changes: 9 additions & 0 deletions android/app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="NightAdjusted.Theme.TvManiac" parent="android:Theme.Material.NoActionBar">
<item name="android:windowLightStatusBar" >false</item>
<item name="android:windowLightNavigationBar" tools:targetApi="27">false</item>
</style>

</resources>
8 changes: 8 additions & 0 deletions android/app/src/main/res/values-v27/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="PlatformAdjusted.Theme.TvManiac" parent="NightAdjusted.Theme.TvManiac">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>
</resources>
4 changes: 1 addition & 3 deletions android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimaryVariant">#FFBE0B</color>
<color name="system_ui_scrim_light">#FFFFFF</color>
<color name="system_ui_scrim_dark">#FF131313</color>
<color name="black">#FF131313</color>
</resources>
4 changes: 0 additions & 4 deletions android/app/src/main/res/values/strings.xml

This file was deleted.

14 changes: 12 additions & 2 deletions android/app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="NightAdjusted.Theme.TvManiac" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:windowLightStatusBar" >true</item>
<item name="android:windowLightNavigationBar" tools:targetApi="27">true</item>
</style>

<style name="PlatformAdjusted.Theme.TvManiac" parent="NightAdjusted.Theme.TvManiac">
<item name="android:statusBarColor">@color/black</item>
</style>

<style name="Theme.TvManiac" parent="PlatformAdjusted.Theme.TvManiac" />

<style name="Theme.TvManiac" parent="android:Theme.Material.NoActionBar" />

</resources>

This file was deleted.

Loading

0 comments on commit 64ee18b

Please sign in to comment.