Базовая навигация

This commit is contained in:
Roman Pytkov
2024-11-08 23:55:08 +03:00
parent 09210ff6f4
commit 7a9aee46a6
12 changed files with 149 additions and 99 deletions

View File

@@ -53,9 +53,6 @@ android {
}
dependencies {
implementation(libs.navigation)
implementation(libs.navigation.hilt.compose)
// Yandex
implementation(libs.yandex.oauth)
@@ -66,20 +63,17 @@ dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
//implementation(platform(libs.androidx.compose.bom))
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
//debugImplementation(libs.androidx.ui.tooling)
//debugImplementation(libs.androidx.ui.test.manifest)
//implementation(libs.androidx.ui)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
//androidTestImplementation(platform(libs.androidx.compose.bom))
//androidTestImplementation(libs.androidx.ui.test.junit4)
implementation(project(":domain"))
implementation(project(":presentation"))

View File

@@ -20,7 +20,6 @@
android:theme="@style/Theme.Wallenc">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

View File

@@ -1,30 +1,10 @@
package com.github.nullptroma.wallenc.app
import android.os.Bundle
import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.github.nullptroma.wallenc.presentation.screens.main.MainScreen
import com.github.nullptroma.wallenc.presentation.theme.WallencTheme
import com.yandex.authsdk.YandexAuthLoginOptions
import com.yandex.authsdk.YandexAuthOptions
import com.yandex.authsdk.YandexAuthResult
import com.yandex.authsdk.YandexAuthSdk
import com.yandex.authsdk.internal.strategy.LoginType
import com.github.nullptroma.wallenc.presentation.WallencUi
import dagger.hilt.android.AndroidEntryPoint
@@ -34,57 +14,21 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
val sdk = YandexAuthSdk.create(YandexAuthOptions(applicationContext, true))
val launcher =
registerForActivityResult(sdk.contract) { result -> handleResult(result) }
val loginOptions = YandexAuthLoginOptions(LoginType.CHROME_TAB)
// val sdk = YandexAuthSdk.create(YandexAuthOptions(applicationContext, true))
// val launcher =
// registerForActivityResult(sdk.contract) { result -> handleResult(result) }
// val loginOptions = YandexAuthLoginOptions(LoginType.CHROME_TAB)
setContent {
WallencTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
// Greeting(Modifier.padding(innerPadding)) {
// launcher.launch(loginOptions)
// }
MainScreen(
Modifier.padding(
innerPadding
)
)
}
}
WallencUi()
}
}
private fun handleResult(result: YandexAuthResult) {
when (result) {
is YandexAuthResult.Success -> Toast.makeText(applicationContext, "Success: ${result.token}", Toast.LENGTH_SHORT).show()
is YandexAuthResult.Failure -> Toast.makeText(applicationContext, "Success: ${result.exception}", Toast.LENGTH_SHORT).show()
YandexAuthResult.Cancelled -> Toast.makeText(applicationContext, "Cancel", Toast.LENGTH_SHORT).show()
}
}
// private fun handleResult(result: YandexAuthResult) {
// when (result) {
// is YandexAuthResult.Success -> Toast.makeText(applicationContext, "Success: ${result.token}", Toast.LENGTH_SHORT).show()
// is YandexAuthResult.Failure -> Toast.makeText(applicationContext, "Success: ${result.exception}", Toast.LENGTH_SHORT).show()
// YandexAuthResult.Cancelled -> Toast.makeText(applicationContext, "Cancel", Toast.LENGTH_SHORT).show()
// }
// }
}
@Composable
fun Greeting(modifier: Modifier = Modifier, onClick: () -> Unit) {
Column(
modifier = modifier
.fillMaxWidth()
.fillMaxHeight(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
Button(onClick = onClick) {
Text(text = "Login")
}
}
}
@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
com.github.nullptroma.wallenc.presentation.theme.WallencTheme {
Greeting(Modifier) {
}
}
}