Skip to content

Commit 26268e6

Browse files
authored
Merge pull request #12 from nativeapptemplate/goto_onboarding_with_background_tag_reading_when_not_signed_in
goto onboarding with background tag reading when not signed in
2 parents b622341 + 58c027d commit 26268e6

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ android {
1818
applicationId = "com.nativeapptemplate.nativeapptemplatefree"
1919
targetSdk = 35
2020
minSdk = 26
21-
versionCode = 2
22-
versionName = "2.0.0"
21+
versionCode = 3
22+
versionName = "2.0.1"
2323

2424
vectorDrawables {
2525
useSupportLibrary = true

app/src/main/kotlin/com/nativeapptemplate/nativeapptemplatefree/MainActivity.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ import com.nativeapptemplate.nativeapptemplatefree.ui.app_root.rememberNatAppSta
3232
import com.nativeapptemplate.nativeapptemplatefree.utils.NetworkMonitor
3333
import com.nativeapptemplate.nativeapptemplatefree.utils.Utility
3434
import dagger.hilt.android.AndroidEntryPoint
35-
import kotlinx.coroutines.flow.collect
36-
import kotlinx.coroutines.flow.onEach
3735
import kotlinx.coroutines.launch
3836
import java.util.Date
3937
import javax.inject.Inject
@@ -47,13 +45,12 @@ class MainActivity : ComponentActivity() {
4745
lateinit var loginRepository: LoginRepository
4846

4947
private val viewModel: MainActivityViewModel by viewModels()
48+
var uiState: MainActivityUiState by mutableStateOf(Loading)
5049

5150
override fun onCreate(savedInstanceState: Bundle?) {
5251
val splashScreen = installSplashScreen()
5352
super.onCreate(savedInstanceState)
5453

55-
var uiState: MainActivityUiState by mutableStateOf(Loading)
56-
5754
viewModel.updateShouldNavigateToScanView(false)
5855
viewModel.updateShouldFetchItemTagForShowTagInfoScan(false)
5956
viewModel.updateShouldCompleteItemTagForCompleteScan(false)
@@ -67,9 +64,9 @@ class MainActivity : ComponentActivity() {
6764
// Update the uiState
6865
lifecycleScope.launch {
6966
lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
70-
viewModel.uiState
71-
.onEach { uiState = it }
72-
.collect()
67+
viewModel.uiState.collect {
68+
uiState = it
69+
}
7370
}
7471
}
7572

@@ -121,6 +118,8 @@ class MainActivity : ComponentActivity() {
121118
}
122119
}
123120

121+
if (!uiState.isLoggedIn) return
122+
124123
val intent = intent
125124
if (NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action) {
126125
viewModel.updateShouldNavigateToScanView(false)
@@ -153,6 +152,9 @@ class MainActivity : ComponentActivity() {
153152

154153
override fun onNewIntent(intent: Intent) {
155154
super.onNewIntent(intent)
155+
156+
if (!uiState.isLoggedIn) return
157+
156158
if (NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action) {
157159
viewModel.updateShouldNavigateToScanView(false)
158160

app/src/main/kotlin/com/nativeapptemplate/nativeapptemplatefree/MainActivityViewModel.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,9 @@ class MainActivityViewModel @Inject constructor(
145145

146146
sealed interface MainActivityUiState {
147147
data object Loading : MainActivityUiState
148-
data class Success(val userData: UserData) : MainActivityUiState
148+
data class Success(val userData: UserData) : MainActivityUiState {
149+
override val isLoggedIn = userData.isLoggedIn
150+
}
151+
152+
val isLoggedIn: Boolean get() = false
149153
}

0 commit comments

Comments
 (0)