Skip to content

Commit

Permalink
Merge pull request #2 from Velord/feature/TryNewVerion
Browse files Browse the repository at this point in the history
  • Loading branch information
Velord authored Jul 18, 2023
2 parents 3b39eed + 9fe15a0 commit d965620
Show file tree
Hide file tree
Showing 14 changed files with 309 additions and 141 deletions.
25 changes: 9 additions & 16 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
// Migrate to gradle 8.1 when be released should fix that
// Suppress according to https://github.com/gradle/gradle/issues/22797
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
id(libs.plugins.android.application.get().pluginId)
id(libs.plugins.kotlin.android.get().pluginId)
id(libs.plugins.kotlin.kapt.get().pluginId)
}

// When app incompatible with previous version change this value
val globalVersion = 0
// When you create huge feature(or many) release change this value
val majorVersion = 1
val majorVersion = 2
// When you create feature release change this value
val minorVersion = 0
// When you create fix change this value
Expand Down Expand Up @@ -72,14 +69,12 @@ android {
applicationIdSuffix = ".develop"
buildConfigField("String", "CURRENT_VERSION", "\"${currentVersion}\"")
}

create("stage") {
dimension = "environment"
manifestPlaceholders["enableCrashReporting"] = true
applicationIdSuffix = ".stage"
buildConfigField("String", "CURRENT_VERSION", "\"${currentVersion}\"")
}

create("production") {
dimension = "environment"
manifestPlaceholders["enableCrashReporting"] = true
Expand All @@ -101,20 +96,18 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}
packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {
// Module
implementation(project(":multiplebackstackapplier"))
// Templates
implementation(libs.bundles.kotlin.all)
implementation(libs.bundles.androidx.all)
implementation(libs.bundles.compose.all)
implementation(libs.bundles.androidx.module)
// Compose
implementation(libs.bundles.compose.material.third)
implementation(libs.bundles.compose.ui)
implementation(libs.bundles.compose.accompanist.core)
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class).all {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import androidx.annotation.StringRes
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
package com.velord.composemultiplebackstackdemo.ui.main

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.annotation.IdRes
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.core.os.bundleOf
import androidx.core.view.WindowCompat
import androidx.navigation.fragment.NavHostFragment
import com.velord.composemultiplebackstackdemo.R
import com.velord.composemultiplebackstackdemo.databinding.ActivityMainBinding
import com.velord.composemultiplebackstackdemo.ui.compose.theme.MainTheme

class MainActivity : AppCompatActivity() {

companion object {
const val fragmentContainer = R.id.navHostFragment
val fragmentContainer = R.id.navHostFragment
}

private var binding: ActivityMainBinding? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
package com.velord.composemultiplebackstackdemo.ui.main.bottomNavigation

import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalAbsoluteTonalElevation
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationBarItemDefaults
import androidx.compose.material3.Snackbar
import androidx.compose.material3.Text
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -39,9 +52,9 @@ class BottomNavFragment : Fragment(R.layout.fragment_bottom_nav) {
MultipleBackstack(
navController = lazy { navController },
lifecycleOwner = this,
flowOnSelect = viewModel.currentTabFlow,
context = requireContext(),
items = viewModel.getNavigationItems(),
flowOnSelect = viewModel.currentTabFlow,
onMenuChange = {
val current = navController.currentDestination
viewModel.updateBackHandling(current)
Expand Down Expand Up @@ -92,6 +105,7 @@ private fun BottomNavScreen(viewModel: BottomNavViewModel) {
val tabFlow = viewModel.currentTabFlow.collectAsStateWithLifecycle()
val isBackHandlingEnabledState =
viewModel.isBackHandlingEnabledFlow.collectAsStateWithLifecycle()
Log.d("multiplebackstackapplier", "isBackHandlingEnabledState: ${isBackHandlingEnabledState.value}")

Content(
selectedItem = tabFlow.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import android.view.ViewGroup
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
Expand All @@ -18,7 +18,6 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.velord.composemultiplebackstackdemo.R
import com.velord.composemultiplebackstackdemo.ui.compose.theme.setContentWithTheme
import com.velord.composemultiplebackstackdemo.ui.utils.activityNavController
Expand All @@ -44,15 +43,8 @@ class InDevelopmentFragment : Fragment() {

private fun initObserving() {
viewLifecycleScope.launch {
launch {
viewModel.navigationEvent.collect {
activityNavController()?.navigate(it.id)
}
}
launch {
viewModel.backEvent.collect {
findNavController().popBackStack()
}
viewModel.navigationEvent.collect {
activityNavController()?.navigate(it.id)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ import kotlinx.coroutines.launch
class InDevelopmentViewModel : ViewModel() {

val navigationEvent = MutableSharedFlow<NavigationData>()
val backEvent = MutableSharedFlow<Unit>()

fun onOpenNew() = viewModelScope.launch {
navigationEvent.emit(NavigationData(R.id.toInDevelopmentFragment))
}

fun onBackPressed() = viewModelScope.launch {
backEvent.emit(Unit)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.velord.composemultiplebackstackdemo.ui.navigation

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.*
import androidx.compose.material.icons.outlined.Add
import androidx.compose.material.icons.outlined.ArrowBack
import androidx.compose.material.icons.outlined.ArrowForward
import com.velord.composemultiplebackstackdemo.R
import com.velord.multiplebackstackapplier.MultipleBackstackGraphItem

Expand All @@ -15,8 +17,8 @@ enum class BottomNavigationItem(


val icon get() = when (this) {
Left -> Icons.Outlined.ArrowLeft
Center -> Icons.Outlined.CenterFocusStrong
Right -> Icons.Outlined.ArrowRight
Left -> Icons.Outlined.ArrowBack
Center -> Icons.Outlined.Add
Right -> Icons.Outlined.ArrowForward
}
}
13 changes: 1 addition & 12 deletions app/src/main/res/navigation/main_nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@
android:name="com.velord.composemultiplebackstackdemo.ui.main.bottomNavigation.BottomNavFragment"
android:label="BottomNavFragment">

<action
android:id="@+id/toBottomNavFragment"
app:destination="@+id/bottomNavFragment"
app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right"
app:popUpTo="@id/bottomNavFragment"
app:popUpToInclusive="true" />

<action
android:id="@+id/toInDevelopmentFragment"
app:destination="@id/inDevelopmentFragment"
Expand All @@ -29,7 +19,6 @@
<fragment
android:id="@+id/inDevelopmentFragment"
android:name="com.velord.composemultiplebackstackdemo.ui.main.inDevelopment.InDevelopmentFragment"
android:label="InDevelopmentFragment" >
</fragment>
android:label="InDevelopmentFragment" />

</navigation>
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true
# Fixing the "Build Type contains custom BuildConfig fields, but the feature is disabled" error w/ buildConfigField
android.defaults.buildfeatures.buildconfig=true
Loading

0 comments on commit d965620

Please sign in to comment.