mirror of
https://github.com/Shabinder/SpotiFlyer.git
synced 2024-12-22 20:57:54 +01:00
Status/Nav Bar padding Fixes,migrate to IR Compiler and various updates
This commit is contained in:
parent
2034616aeb
commit
c25837845e
@ -49,7 +49,7 @@ android {
|
||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||
}
|
||||
}
|
||||
|
||||
kotlinOptions.useIR = true
|
||||
compileOptions {
|
||||
// Flag to enable support for the new language APIs
|
||||
//coreLibraryDesugaringEnabled = true
|
||||
@ -68,6 +68,7 @@ android {
|
||||
packagingOptions {
|
||||
exclude("META-INF/*")
|
||||
}
|
||||
buildToolsVersion = "30.0.3"
|
||||
/*buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
@ -90,12 +91,14 @@ dependencies {
|
||||
implementation(Koin.android)
|
||||
implementation(Koin.compose)
|
||||
|
||||
implementation("com.google.accompanist:accompanist-insets:0.7.1")
|
||||
|
||||
//DECOMPOSE
|
||||
implementation(Decompose.decompose)
|
||||
implementation(Decompose.extensionsCompose)
|
||||
|
||||
//Firebase
|
||||
implementation(platform("com.google.firebase:firebase-bom:26.5.0"))
|
||||
implementation(platform("com.google.firebase:firebase-bom:27.0.0"))
|
||||
implementation("com.google.firebase:firebase-analytics-ktx")
|
||||
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
||||
implementation("com.google.firebase:firebase-perf-ktx")
|
||||
@ -129,16 +132,5 @@ dependencies {
|
||||
androidTestImplementation(Androidx.expresso)
|
||||
|
||||
//Desugaring
|
||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.1")
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
freeCompilerArgs = listOf(
|
||||
"-Xallow-jvm-ir-dependencies","-Xallow-unstable-dependencies",
|
||||
"-Xskip-prerelease-check",
|
||||
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"
|
||||
)
|
||||
}
|
||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")
|
||||
}
|
@ -37,6 +37,7 @@ import androidx.compose.material.icons.rounded.SystemSecurityUpdate
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawBehind
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
@ -49,6 +50,10 @@ import com.arkivanov.decompose.ComponentContext
|
||||
import com.arkivanov.decompose.extensions.compose.jetbrains.rememberRootComponent
|
||||
import com.arkivanov.mvikotlin.logging.store.LoggingStoreFactory
|
||||
import com.arkivanov.mvikotlin.main.store.DefaultStoreFactory
|
||||
import com.google.accompanist.insets.ProvideWindowInsets
|
||||
import com.google.accompanist.insets.navigationBarsPadding
|
||||
import com.google.accompanist.insets.statusBarsHeight
|
||||
import com.google.accompanist.insets.statusBarsPadding
|
||||
import com.razorpay.Checkout
|
||||
import com.razorpay.PaymentResultListener
|
||||
import com.shabinder.common.database.activityContext
|
||||
@ -58,6 +63,7 @@ import com.shabinder.common.models.TrackDetails
|
||||
import com.shabinder.common.root.SpotiFlyerRoot
|
||||
import com.shabinder.common.root.callbacks.SpotiFlyerRootCallBacks
|
||||
import com.shabinder.common.uikit.*
|
||||
import com.shabinder.common.uikit.utils.verticalGradientScrim
|
||||
import com.shabinder.spotiflyer.utils.*
|
||||
import com.tonyodev.fetch2.Status
|
||||
import kotlinx.coroutines.*
|
||||
@ -88,24 +94,29 @@ class MainActivity : ComponentActivity(), PaymentResultListener {
|
||||
setContent {
|
||||
SpotiFlyerTheme {
|
||||
Surface(contentColor = colorOffWhite) {
|
||||
ProvideWindowInsets {
|
||||
permissionGranted = remember { mutableStateOf(true) }
|
||||
val view = LocalView.current
|
||||
|
||||
var statusBarHeight by remember { mutableStateOf(27.dp) }
|
||||
permissionGranted = remember { mutableStateOf(true) }
|
||||
val view = LocalView.current
|
||||
|
||||
LaunchedEffect(view){
|
||||
permissionGranted.value = checkPermissions()
|
||||
view.setOnApplyWindowInsetsListener { _, insets ->
|
||||
statusBarHeight = insets.systemWindowInsetTop.dp
|
||||
insets
|
||||
LaunchedEffect(view) {
|
||||
permissionGranted.value = checkPermissions()
|
||||
}
|
||||
Box {
|
||||
root = SpotiFlyerRootContent(
|
||||
rememberRootComponent(::spotiFlyerRoot),
|
||||
Modifier.statusBarsPadding().navigationBarsPadding()
|
||||
)
|
||||
Spacer(
|
||||
Modifier
|
||||
.statusBarsHeight()
|
||||
.fillMaxWidth()
|
||||
.background(MaterialTheme.colors.background.copy(alpha = 0.65f))
|
||||
)
|
||||
}
|
||||
|
||||
NetworkDialog()
|
||||
PermissionDialog()
|
||||
}
|
||||
|
||||
root = SpotiFlyerRootContent(rememberRootComponent(::spotiFlyerRoot),statusBarHeight)
|
||||
|
||||
|
||||
NetworkDialog()
|
||||
PermissionDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,4 +33,9 @@ allprojects {
|
||||
maven(url = "https://dl.bintray.com/kotlin/kotlin-js-wrappers")
|
||||
maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev")
|
||||
}
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
||||
kotlinOptions {
|
||||
useIR = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ dependencies {
|
||||
implementation("com.android.tools.build:gradle:4.0.2")
|
||||
implementation("com.google.gms:google-services:4.3.5")
|
||||
implementation("com.google.firebase:perf-plugin:1.3.5")
|
||||
implementation("com.google.firebase:firebase-crashlytics-gradle:2.5.1")
|
||||
implementation("com.google.firebase:firebase-crashlytics-gradle:2.5.2")
|
||||
implementation("org.jlleitschuh.gradle:ktlint-gradle:${Versions.ktLint}")
|
||||
implementation(JetBrains.Compose.gradlePlugin)
|
||||
implementation(JetBrains.Kotlin.gradlePlugin)
|
||||
|
@ -17,13 +17,13 @@
|
||||
@file:Suppress("MayBeConstant", "SpellCheckingInspection")
|
||||
|
||||
object Versions {
|
||||
// App's Version (To be bumped at each update)
|
||||
const val versionName = "2.2.0"
|
||||
const val kotlinVersion = "1.4.31"
|
||||
|
||||
// Kotlin
|
||||
const val kotlinVersion = "1.4.32"
|
||||
const val coroutinesVersion = "1.4.2"
|
||||
|
||||
const val coilVersion = "0.4.1"
|
||||
|
||||
// Code Formatting
|
||||
const val ktLint = "10.0.0"
|
||||
|
||||
@ -34,9 +34,9 @@ object Versions {
|
||||
const val kermit = "0.1.8"
|
||||
|
||||
// Internet
|
||||
const val ktor = "1.5.2"
|
||||
const val ktor = "1.5.3"
|
||||
|
||||
const val kotlinxSerialization = "1.1.0-RC"
|
||||
const val kotlinxSerialization = "1.1.0"
|
||||
// Database
|
||||
const val sqlDelight = "1.4.4"
|
||||
|
||||
@ -86,19 +86,19 @@ object JetBrains {
|
||||
|
||||
object Compose {
|
||||
// __LATEST_COMPOSE_RELEASE_VERSION__
|
||||
const val VERSION = "0.3.2"
|
||||
const val VERSION = "0.4.0-build182"
|
||||
const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION"
|
||||
}
|
||||
}
|
||||
object Decompose {
|
||||
private const val VERSION = "0.1.9"
|
||||
private const val VERSION = "0.2.1"
|
||||
const val decompose = "com.arkivanov.decompose:decompose:$VERSION"
|
||||
const val decomposeIosX64 = "com.arkivanov.decompose:decompose-iosx64:$VERSION"
|
||||
const val decomposeIosArm64 = "com.arkivanov.decompose:decompose-iosarm64:$VERSION"
|
||||
const val extensionsCompose = "com.arkivanov.decompose:extensions-compose-jetbrains:$VERSION"
|
||||
}
|
||||
object MVIKotlin {
|
||||
private const val VERSION = "2.0.0"
|
||||
private const val VERSION = "2.0.1"
|
||||
const val rx = "com.arkivanov.mvikotlin:rx:$VERSION"
|
||||
const val mvikotlin = "com.arkivanov.mvikotlin:mvikotlin:$VERSION"
|
||||
const val mvikotlinMain = "com.arkivanov.mvikotlin:mvikotlin-main:$VERSION"
|
||||
|
@ -22,15 +22,23 @@ plugins {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm("desktop")
|
||||
android()
|
||||
jvm("desktop").compilations.all {
|
||||
kotlinOptions {
|
||||
useIR = true
|
||||
}
|
||||
}
|
||||
android().compilations.all {
|
||||
kotlinOptions {
|
||||
useIR = true
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
named("commonMain") {
|
||||
dependencies {
|
||||
implementation(compose.runtime)
|
||||
implementation(compose.foundation)
|
||||
implementation(compose.material)
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.3-native-mt")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,21 @@ plugins {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm("desktop")
|
||||
android()
|
||||
// ios()
|
||||
jvm("desktop").compilations.all {
|
||||
kotlinOptions {
|
||||
useIR = true
|
||||
}
|
||||
}
|
||||
android().compilations.all {
|
||||
kotlinOptions {
|
||||
useIR = true
|
||||
}
|
||||
}
|
||||
js() {
|
||||
/*
|
||||
* TODO Enable JS IR Compiler
|
||||
* waiting for Decompose & MVI Kotlin to support same
|
||||
* */
|
||||
browser()
|
||||
// nodejs()
|
||||
binaries.executable()
|
||||
|
@ -22,9 +22,21 @@ plugins {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm("desktop")
|
||||
android()
|
||||
jvm("desktop").compilations.all {
|
||||
kotlinOptions {
|
||||
useIR = true
|
||||
}
|
||||
}
|
||||
android().compilations.all {
|
||||
kotlinOptions {
|
||||
useIR = true
|
||||
}
|
||||
}
|
||||
js() {
|
||||
/*
|
||||
* TODO Enable JS IR Compiler
|
||||
* waiting for Decompose & MVI Kotlin to support same
|
||||
* */
|
||||
browser()
|
||||
// nodejs()
|
||||
binaries.executable()
|
||||
|
@ -14,6 +14,8 @@
|
||||
* * along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@file:Suppress("EXPERIMENTAL_API_USAGE")
|
||||
|
||||
package com.shabinder.common.uikit
|
||||
|
||||
import androidx.compose.animation.core.MutableTransitionState
|
||||
@ -37,6 +39,7 @@ import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.TopAppBar
|
||||
import androidx.compose.material.ripple.RippleAlpha
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
@ -48,6 +51,7 @@ import androidx.compose.ui.platform.LocalViewConfiguration
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.arkivanov.decompose.extensions.compose.jetbrains.Children
|
||||
import com.arkivanov.decompose.extensions.compose.jetbrains.animation.child.crossfadeScale
|
||||
import com.shabinder.common.root.SpotiFlyerRoot
|
||||
import com.shabinder.common.root.SpotiFlyerRoot.Child
|
||||
import com.shabinder.common.uikit.splash.Splash
|
||||
@ -58,39 +62,39 @@ import com.shabinder.common.uikit.utils.verticalGradientScrim
|
||||
private var isSplashShown = SplashState.Shown
|
||||
|
||||
@Composable
|
||||
fun SpotiFlyerRootContent(component: SpotiFlyerRoot, statusBarHeight: Dp = 0.dp): SpotiFlyerRoot {
|
||||
fun SpotiFlyerRootContent(component: SpotiFlyerRoot, modifier: Modifier = Modifier): SpotiFlyerRoot {
|
||||
|
||||
val transitionState = remember { MutableTransitionState(SplashState.Shown) }
|
||||
val transition = updateTransition(transitionState)
|
||||
val transition = updateTransition(transitionState, label = "transition")
|
||||
|
||||
val splashAlpha by transition.animateFloat(
|
||||
transitionSpec = { tween(durationMillis = 100) }
|
||||
transitionSpec = { tween(durationMillis = 100) }, label = "Splash-Alpha"
|
||||
) {
|
||||
if (it == SplashState.Shown && isSplashShown == SplashState.Shown) 1f else 0f
|
||||
}
|
||||
val contentAlpha by transition.animateFloat(
|
||||
transitionSpec = { tween(durationMillis = 300) }
|
||||
transitionSpec = { tween(durationMillis = 300) }, label = "Content-Alpha"
|
||||
) {
|
||||
if (it == SplashState.Shown && isSplashShown == SplashState.Shown) 0f else 1f
|
||||
}
|
||||
val contentTopPadding by transition.animateDp(
|
||||
transitionSpec = { spring(stiffness = StiffnessLow) }
|
||||
transitionSpec = { spring(stiffness = StiffnessLow) }, label = "Content-Padding"
|
||||
) {
|
||||
if (it == SplashState.Shown && isSplashShown == SplashState.Shown) 100.dp else 0.dp
|
||||
}
|
||||
|
||||
Box {
|
||||
Splash(
|
||||
modifier = Modifier.alpha(splashAlpha),
|
||||
modifier = modifier.alpha(splashAlpha),
|
||||
onTimeout = {
|
||||
transitionState.targetState = SplashState.Completed
|
||||
isSplashShown = SplashState.Completed
|
||||
}
|
||||
)
|
||||
MainScreen(
|
||||
Modifier.alpha(contentAlpha),
|
||||
modifier,
|
||||
contentAlpha,
|
||||
contentTopPadding,
|
||||
statusBarHeight,
|
||||
component
|
||||
)
|
||||
}
|
||||
@ -98,20 +102,19 @@ fun SpotiFlyerRootContent(component: SpotiFlyerRoot, statusBarHeight: Dp = 0.dp)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun MainScreen(modifier: Modifier = Modifier, topPadding: Dp = 0.dp, statusBarHeight: Dp = 0.dp, component: SpotiFlyerRoot) {
|
||||
fun MainScreen(modifier: Modifier = Modifier, alpha: Float,topPadding: Dp = 0.dp, component: SpotiFlyerRoot) {
|
||||
|
||||
val appBarColor = MaterialTheme.colors.surface.copy(alpha = 0.65f)
|
||||
|
||||
Column(
|
||||
modifier = modifier.fillMaxSize()
|
||||
modifier = Modifier.fillMaxSize()
|
||||
.alpha(alpha)
|
||||
.verticalGradientScrim(
|
||||
color = colorPrimaryDark.copy(alpha = 0.38f),
|
||||
startYPercentage = 0.29f,
|
||||
endYPercentage = 0f,
|
||||
)
|
||||
).then(modifier)
|
||||
) {
|
||||
Spacer(Modifier.background(appBarColor).height(statusBarHeight).fillMaxWidth())
|
||||
LocalViewConfiguration.current
|
||||
|
||||
AppBar(
|
||||
backgroundColor = appBarColor,
|
||||
@ -120,8 +123,9 @@ fun MainScreen(modifier: Modifier = Modifier, topPadding: Dp = 0.dp, statusBarHe
|
||||
Spacer(Modifier.padding(top = topPadding))
|
||||
Children(
|
||||
routerState = component.routerState,
|
||||
) { child, _ ->
|
||||
when (child) {
|
||||
animation = crossfadeScale()
|
||||
) {
|
||||
when (val child = it.instance) {
|
||||
is Child.Main -> SpotiFlyerMainContent(component = child.component)
|
||||
is Child.List -> SpotiFlyerListContent(component = child.component)
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ internal class SpotiFlyerRootImpl(
|
||||
router<Configuration, Child>(
|
||||
initialConfiguration = Configuration.Main,
|
||||
handleBackButton = true,
|
||||
componentFactory = ::createChild
|
||||
childFactory = ::createChild
|
||||
)
|
||||
|
||||
override val routerState: Value<RouterState<*, Child>> = router.state
|
||||
|
Loading…
Reference in New Issue
Block a user