add help page

This commit is contained in:
Minecon724 2024-07-25 18:51:40 +02:00
parent 127a31841e
commit d3d3c9f59e
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
4 changed files with 64 additions and 4 deletions

View file

@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"

View file

@ -29,6 +29,7 @@ import androidx.navigation.compose.rememberNavController
import eu.m724.vastapp.activity.dashboard.screen.Screen
import eu.m724.vastapp.activity.dashboard.screen.BillingScreen
import eu.m724.vastapp.activity.dashboard.screen.DashboardScreen
import eu.m724.vastapp.activity.dashboard.screen.HelpScreen
import eu.m724.vastapp.activity.dashboard.screen.InstancesScreen
import eu.m724.vastapp.ui.theme.VastappTheme
import eu.m724.vastapp.vastai.VastApi
@ -54,7 +55,8 @@ class DashboardActivity : ComponentActivity() {
val items = listOf(
Screen.Dashboard,
Screen.Instances,
Screen.Billing
Screen.Billing,
Screen.Help
)
val navController = rememberNavController()
@ -70,6 +72,7 @@ class DashboardActivity : ComponentActivity() {
composable("dashboard") { DashboardScreen(dashboardViewModel) }
composable("instances") { InstancesScreen(dashboardViewModel) }
composable("billing") { BillingScreen(dashboardViewModel) }
composable("help") { HelpScreen(dashboardViewModel) }
}
}
}

View file

@ -1,22 +1,24 @@
package eu.m724.vastapp.activity.dashboard
import android.content.Intent
import android.net.Uri
import androidx.compose.ui.platform.LocalContext
import androidx.core.content.ContextCompat.startActivity
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import eu.m724.vastapp.activity.login.LoginUiState
import eu.m724.vastapp.vastai.ApiRoute
import eu.m724.vastapp.vastai.VastApi
import eu.m724.vastapp.vastai.api.UserUrlRequestCallback
import eu.m724.vastapp.vastai.data.User
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
class DashboardViewModel(private val _user: User, val vastApi: VastApi) : ViewModel() {
private val _uiState: MutableStateFlow<DashboardUiState> =
MutableStateFlow(DashboardUiState(false, _user, null))

View file

@ -0,0 +1,53 @@
package eu.m724.vastapp.activity.dashboard.screen
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.os.Parcelable
import android.view.ViewGroup
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.Saver
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.content.ContextCompat.startActivity
import androidx.lifecycle.ViewModel
import eu.m724.vastapp.activity.dashboard.DashboardViewModel
@Composable
fun HelpScreen(dashboardViewModel: DashboardViewModel) { // TODO make this a webview
val context = LocalContext.current
Column(
modifier = Modifier.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Button(onClick = {
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"))
context.startActivity(browserIntent)
}) {
Text(text = "https://vast.ai/docs")
}
Text(text = "(this will be a webview)", fontSize = 12.sp)
}
}