fix: небольшие улучшения
This commit is contained in:
1 parent
5a03eeb3ea
commit
0265114e3d
8 files changed
+26
-89
No files matched your search
@@ -52,10 +52,10 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("androidx.webkit:webkit:1.14.0")
|
implementation("androidx.core:core-splashscreen:1.2.0")
|
||||||
implementation("com.github.mwiede:jsch:2.27.9")
|
implementation("com.github.mwiede:jsch:2.28.0")
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
|
||||||
implementation("androidx.security:security-crypto:1.1.0-alpha06")
|
implementation("androidx.security:security-crypto:1.1.0")
|
||||||
|
|
||||||
implementation(libs.androidx.core.ktx)
|
implementation(libs.androidx.core.ktx)
|
||||||
implementation(libs.androidx.appcompat)
|
implementation(libs.androidx.appcompat)
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
android:theme="@style/Theme.FreeTurn.Splash"
|
||||||
android:windowSoftInputMode="adjustResize">
|
android:windowSoftInputMode="adjustResize">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.fillMaxSize
|
|||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
import com.freeturn.app.ui.navigation.AppNavigation
|
import com.freeturn.app.ui.navigation.AppNavigation
|
||||||
import com.freeturn.app.ui.theme.FreeTurnTheme
|
import com.freeturn.app.ui.theme.FreeTurnTheme
|
||||||
import com.freeturn.app.viewmodel.MainViewModel
|
import com.freeturn.app.viewmodel.MainViewModel
|
||||||
@@ -21,7 +22,12 @@ class MainActivity : ComponentActivity() {
|
|||||||
private val viewModel: MainViewModel by viewModels()
|
private val viewModel: MainViewModel by viewModels()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
val splashScreen = installSplashScreen()
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
// Удерживаем системный splash пока ViewModel не инициализируется
|
||||||
|
splashScreen.setKeepOnScreenCondition { !viewModel.isInitialized.value }
|
||||||
|
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
setContent {
|
setContent {
|
||||||
val dynamicTheme by viewModel.dynamicTheme.collectAsStateWithLifecycle()
|
val dynamicTheme by viewModel.dynamicTheme.collectAsStateWithLifecycle()
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class LocalProxyManager(private val context: Context) {
|
|||||||
resetJob?.cancel()
|
resetJob?.cancel()
|
||||||
_proxyState.value = ProxyState.Error(message)
|
_proxyState.value = ProxyState.Error(message)
|
||||||
resetJob = scope.launch {
|
resetJob = scope.launch {
|
||||||
delay(3500)
|
delay(4_000)
|
||||||
if (_proxyState.value is ProxyState.Error) _proxyState.value = ProxyState.Idle
|
if (_proxyState.value is ProxyState.Error) _proxyState.value = ProxyState.Idle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,37 +2,22 @@ package com.freeturn.app.ui.navigation
|
|||||||
|
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.Crossfade
|
import androidx.compose.animation.Crossfade
|
||||||
import androidx.compose.animation.core.Animatable
|
|
||||||
import androidx.compose.animation.core.Spring
|
|
||||||
import androidx.compose.animation.core.spring
|
|
||||||
import androidx.compose.animation.core.tween
|
|
||||||
import androidx.compose.animation.slideInVertically
|
import androidx.compose.animation.slideInVertically
|
||||||
import androidx.compose.animation.slideOutVertically
|
import androidx.compose.animation.slideOutVertically
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.Spacer
|
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.height
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.foundation.layout.statusBarsPadding
|
import androidx.compose.foundation.layout.statusBarsPadding
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.NavigationBar
|
import androidx.compose.material3.NavigationBar
|
||||||
import androidx.compose.material3.NavigationBarItem
|
import androidx.compose.material3.NavigationBarItem
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
@@ -51,7 +36,6 @@ import com.freeturn.app.ui.screens.OnboardingScreen
|
|||||||
import com.freeturn.app.ui.screens.ServerManagementScreen
|
import com.freeturn.app.ui.screens.ServerManagementScreen
|
||||||
import com.freeturn.app.ui.screens.SshSetupScreen
|
import com.freeturn.app.ui.screens.SshSetupScreen
|
||||||
import com.freeturn.app.viewmodel.MainViewModel
|
import com.freeturn.app.viewmodel.MainViewModel
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
object Routes {
|
object Routes {
|
||||||
const val ONBOARDING = "onboarding"
|
const val ONBOARDING = "onboarding"
|
||||||
@@ -70,14 +54,8 @@ private val BOTTOM_NAV_ROUTES = setOf(Routes.HOME, Routes.LOGS, Routes.SERVER_MA
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AppNavigation(viewModel: MainViewModel) {
|
fun AppNavigation(viewModel: MainViewModel) {
|
||||||
val isInitialized by viewModel.isInitialized.collectAsStateWithLifecycle()
|
|
||||||
val onboardingDone by viewModel.onboardingDone.collectAsStateWithLifecycle()
|
val onboardingDone by viewModel.onboardingDone.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
if (!isInitialized) {
|
|
||||||
SplashScreen()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val startDestination = remember { if (onboardingDone) Routes.HOME else Routes.ONBOARDING }
|
val startDestination = remember { if (onboardingDone) Routes.HOME else Routes.ONBOARDING }
|
||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
val backStackEntry by navController.currentBackStackEntryAsState()
|
val backStackEntry by navController.currentBackStackEntryAsState()
|
||||||
@@ -222,69 +200,6 @@ fun AppNavigation(viewModel: MainViewModel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun SplashScreen() {
|
|
||||||
val context = LocalContext.current
|
|
||||||
val scale = remember { Animatable(0.72f) }
|
|
||||||
val alpha = remember { Animatable(0f) }
|
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.LAUNCH)
|
|
||||||
launch {
|
|
||||||
scale.animateTo(
|
|
||||||
1f,
|
|
||||||
animationSpec = spring(
|
|
||||||
dampingRatio = Spring.DampingRatioMediumBouncy,
|
|
||||||
stiffness = Spring.StiffnessMediumLow
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
alpha.animateTo(1f, animationSpec = tween(380))
|
|
||||||
}
|
|
||||||
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxSize()
|
|
||||||
.background(MaterialTheme.colorScheme.primary),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Column(
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
|
||||||
modifier = Modifier.graphicsLayer {
|
|
||||||
this.alpha = alpha.value
|
|
||||||
scaleX = scale.value
|
|
||||||
scaleY = scale.value
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.size(112.dp)
|
|
||||||
.background(MaterialTheme.colorScheme.onPrimary.copy(alpha = 0.15f), CircleShape),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
painter = painterResource(R.drawable.nearby_24px),
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier.size(60.dp),
|
|
||||||
tint = MaterialTheme.colorScheme.onPrimary
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Spacer(Modifier.height(20.dp))
|
|
||||||
Text(
|
|
||||||
stringResource(R.string.splash_title),
|
|
||||||
style = MaterialTheme.typography.displaySmall,
|
|
||||||
color = MaterialTheme.colorScheme.onPrimary
|
|
||||||
)
|
|
||||||
Spacer(Modifier.height(6.dp))
|
|
||||||
Text(
|
|
||||||
stringResource(R.string.splash_subtitle),
|
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
|
||||||
color = MaterialTheme.colorScheme.onPrimary.copy(alpha = 0.6f)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private data class NavItem(
|
private data class NavItem(
|
||||||
val route: String,
|
val route: String,
|
||||||
val labelResId: Int,
|
val labelResId: Int,
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ fun HomeScreen(
|
|||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
viewModel.reconnectSsh()
|
viewModel.reconnectSsh()
|
||||||
},
|
},
|
||||||
|
enabled = sshState !is SshConnectionState.Connecting,
|
||||||
modifier = Modifier.height(28.dp)
|
modifier = Modifier.height(28.dp)
|
||||||
) {
|
) {
|
||||||
Text(stringResource(R.string.reconnect), style = MaterialTheme.typography.labelSmall)
|
Text(stringResource(R.string.reconnect), style = MaterialTheme.typography.labelSmall)
|
||||||
|
|||||||
@@ -4,4 +4,11 @@
|
|||||||
<!-- Customize your dark theme here. -->
|
<!-- Customize your dark theme here. -->
|
||||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- Splash screen theme (Core Splash Screen API) — dark variant -->
|
||||||
|
<style name="Theme.FreeTurn.Splash" parent="Theme.SplashScreen">
|
||||||
|
<item name="windowSplashScreenBackground">#FF111318</item>
|
||||||
|
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
|
||||||
|
<item name="postSplashScreenTheme">@style/Theme.FreeTurn</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -6,4 +6,11 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.FreeTurn" parent="Base.Theme.FreeTurn" />
|
<style name="Theme.FreeTurn" parent="Base.Theme.FreeTurn" />
|
||||||
|
|
||||||
|
<!-- Splash screen theme (Core Splash Screen API) -->
|
||||||
|
<style name="Theme.FreeTurn.Splash" parent="Theme.SplashScreen">
|
||||||
|
<item name="windowSplashScreenBackground">#FF415F91</item>
|
||||||
|
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
|
||||||
|
<item name="postSplashScreenTheme">@style/Theme.FreeTurn</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in new issue
Block a user