|
@@ -1,6 +1,8 @@
|
|
package com.example.collectionofshortstories
|
|
package com.example.collectionofshortstories
|
|
|
|
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
|
|
+import android.provider.ContactsContract.Contacts
|
|
|
|
+import android.util.Log
|
|
import androidx.activity.ComponentActivity
|
|
import androidx.activity.ComponentActivity
|
|
import androidx.activity.compose.setContent
|
|
import androidx.activity.compose.setContent
|
|
import androidx.activity.enableEdgeToEdge
|
|
import androidx.activity.enableEdgeToEdge
|
|
@@ -13,8 +15,17 @@ import androidx.compose.material3.Text
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.runtime.Composable
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.Modifier
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
|
+import androidx.compose.ui.unit.Constraints
|
|
|
|
+import androidx.lifecycle.Lifecycle
|
|
|
|
+import androidx.lifecycle.LifecycleEventObserver
|
|
|
|
+import androidx.lifecycle.LifecycleOwner
|
|
|
|
+import androidx.lifecycle.ProcessLifecycleOwner
|
|
|
|
+import androidx.lifecycle.lifecycleScope
|
|
|
|
+import com.example.collectionofshortstories.domain.untils.Constants
|
|
import com.example.collectionofshortstories.navigation.Navigathion
|
|
import com.example.collectionofshortstories.navigation.Navigathion
|
|
import com.example.collectionofshortstories.ui.theme.CollectionOfShortStoriesTheme
|
|
import com.example.collectionofshortstories.ui.theme.CollectionOfShortStoriesTheme
|
|
|
|
+import io.github.jan.supabase.gotrue.auth
|
|
|
|
+import kotlinx.coroutines.launch
|
|
|
|
|
|
class MainActivity : ComponentActivity() {
|
|
class MainActivity : ComponentActivity() {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
@@ -22,7 +33,7 @@ class MainActivity : ComponentActivity() {
|
|
enableEdgeToEdge()
|
|
enableEdgeToEdge()
|
|
setContent {
|
|
setContent {
|
|
CollectionOfShortStoriesTheme {
|
|
CollectionOfShortStoriesTheme {
|
|
- Surface (
|
|
|
|
|
|
+ Surface(
|
|
modifier = Modifier.fillMaxSize(),
|
|
modifier = Modifier.fillMaxSize(),
|
|
color = MaterialTheme.colorScheme.background
|
|
color = MaterialTheme.colorScheme.background
|
|
) {
|
|
) {
|
|
@@ -30,6 +41,19 @@ class MainActivity : ComponentActivity() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ ProcessLifecycleOwner.get().lifecycle.addObserver(object : LifecycleEventObserver {
|
|
|
|
+ override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
|
|
|
+ if (event == Lifecycle.Event.ON_DESTROY) {
|
|
|
|
+ // Запуск сопрограммы для вызова signOut()
|
|
|
|
+ lifecycleScope.launch {
|
|
|
|
+ Log.d("exit","yes")
|
|
|
|
+ Constants.supabase.auth.signOut()
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|