minor form check/hints
This commit is contained in:
		@ -1,8 +1,10 @@
 | 
			
		||||
package net.blumia.pcmdroid.ui.screen.addserver
 | 
			
		||||
 | 
			
		||||
import android.webkit.URLUtil
 | 
			
		||||
import androidx.compose.foundation.layout.*
 | 
			
		||||
import androidx.compose.foundation.rememberScrollState
 | 
			
		||||
import androidx.compose.foundation.shape.RoundedCornerShape
 | 
			
		||||
import androidx.compose.foundation.text.KeyboardActions
 | 
			
		||||
import androidx.compose.foundation.text.KeyboardOptions
 | 
			
		||||
import androidx.compose.foundation.verticalScroll
 | 
			
		||||
import androidx.compose.material.*
 | 
			
		||||
@ -14,8 +16,11 @@ import androidx.compose.runtime.*
 | 
			
		||||
import androidx.compose.runtime.livedata.observeAsState
 | 
			
		||||
import androidx.compose.runtime.saveable.rememberSaveable
 | 
			
		||||
import androidx.compose.ui.Alignment
 | 
			
		||||
import androidx.compose.ui.ExperimentalComposeUiApi
 | 
			
		||||
import androidx.compose.ui.Modifier
 | 
			
		||||
import androidx.compose.ui.graphics.Color
 | 
			
		||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
 | 
			
		||||
import androidx.compose.ui.text.input.ImeAction
 | 
			
		||||
import androidx.compose.ui.text.input.KeyboardType
 | 
			
		||||
import androidx.compose.ui.text.style.TextAlign
 | 
			
		||||
import androidx.compose.ui.tooling.preview.Preview
 | 
			
		||||
@ -23,6 +28,7 @@ import androidx.compose.ui.unit.dp
 | 
			
		||||
import net.blumia.pcmdroid.model.Server
 | 
			
		||||
import net.blumia.pcmdroid.viewmodel.AddServerViewModel
 | 
			
		||||
 | 
			
		||||
@OptIn(ExperimentalComposeUiApi::class)
 | 
			
		||||
@Composable
 | 
			
		||||
fun StepEnterApiUrl(
 | 
			
		||||
    viewModel: AddServerViewModel = AddServerViewModel(),
 | 
			
		||||
@ -55,16 +61,25 @@ fun StepEnterApiUrl(
 | 
			
		||||
 | 
			
		||||
        val urlStr: String by viewModel.apiUrl.observeAsState("")
 | 
			
		||||
 | 
			
		||||
        val keyboardController = LocalSoftwareKeyboardController.current
 | 
			
		||||
 | 
			
		||||
        OutlinedTextField(
 | 
			
		||||
            modifier = Modifier
 | 
			
		||||
                .fillMaxWidth()
 | 
			
		||||
                .padding(vertical = 10.dp),
 | 
			
		||||
            keyboardOptions = KeyboardOptions(
 | 
			
		||||
                keyboardType = KeyboardType.Uri,
 | 
			
		||||
                imeAction = ImeAction.Done,
 | 
			
		||||
            ),
 | 
			
		||||
            keyboardActions = KeyboardActions(
 | 
			
		||||
                onDone = {
 | 
			
		||||
                    keyboardController?.hide()
 | 
			
		||||
                }
 | 
			
		||||
            ),
 | 
			
		||||
            singleLine = true,
 | 
			
		||||
            value = urlStr,
 | 
			
		||||
            onValueChange = viewModel::setApiUrl,
 | 
			
		||||
            isError = !viewModel.isApiUrlValid() && urlStr.isNotEmpty(),
 | 
			
		||||
            label = { Text("Server API Url") },
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
@ -91,6 +106,7 @@ fun StepOtherDetail(
 | 
			
		||||
            modifier = Modifier
 | 
			
		||||
                .fillMaxWidth()
 | 
			
		||||
                .padding(vertical = 10.dp),
 | 
			
		||||
            singleLine = true,
 | 
			
		||||
            value = shortNameStr,
 | 
			
		||||
            onValueChange = viewModel::setShortNameStr,
 | 
			
		||||
            label = { Text("Server short name") },
 | 
			
		||||
@ -100,6 +116,7 @@ fun StepOtherDetail(
 | 
			
		||||
            modifier = Modifier
 | 
			
		||||
                .fillMaxWidth()
 | 
			
		||||
                .padding(vertical = 10.dp),
 | 
			
		||||
            singleLine = true,
 | 
			
		||||
            value = nameStr,
 | 
			
		||||
            onValueChange = viewModel::setNameStr,
 | 
			
		||||
            label = { Text("Server name") },
 | 
			
		||||
@ -109,6 +126,7 @@ fun StepOtherDetail(
 | 
			
		||||
            modifier = Modifier
 | 
			
		||||
                .fillMaxWidth()
 | 
			
		||||
                .padding(vertical = 10.dp),
 | 
			
		||||
            singleLine = true,
 | 
			
		||||
            value = baseFolderNameStr,
 | 
			
		||||
            onValueChange = viewModel::setBaseFolderNameStr,
 | 
			
		||||
            label = { Text("Base folder name") },
 | 
			
		||||
@ -118,6 +136,11 @@ fun StepOtherDetail(
 | 
			
		||||
            modifier = Modifier
 | 
			
		||||
                .fillMaxWidth()
 | 
			
		||||
                .padding(vertical = 10.dp),
 | 
			
		||||
            keyboardOptions = KeyboardOptions(
 | 
			
		||||
                keyboardType = KeyboardType.Uri,
 | 
			
		||||
                imeAction = ImeAction.Next,
 | 
			
		||||
            ),
 | 
			
		||||
            singleLine = true,
 | 
			
		||||
            value = mediaBaseUrlStr,
 | 
			
		||||
            onValueChange = viewModel::setMediaBaseUrlStr,
 | 
			
		||||
            label = { Text("Media base url") },
 | 
			
		||||
@ -208,7 +231,9 @@ fun AddServerScreen(
 | 
			
		||||
                ) {
 | 
			
		||||
                    Text("Back")
 | 
			
		||||
                }
 | 
			
		||||
                val apiUrl by viewModel.apiUrl.observeAsState()
 | 
			
		||||
                Button(
 | 
			
		||||
                    enabled = URLUtil.isNetworkUrl(apiUrl),
 | 
			
		||||
                    onClick = {
 | 
			
		||||
                        if (stepState != finalStep) {
 | 
			
		||||
                            viewModel.fetchContentFromApiUrl()
 | 
			
		||||
 | 
			
		||||
@ -84,6 +84,7 @@ fun EditServerScreen(
 | 
			
		||||
                modifier = Modifier
 | 
			
		||||
                    .fillMaxWidth()
 | 
			
		||||
                    .padding(vertical = 10.dp),
 | 
			
		||||
                singleLine = true,
 | 
			
		||||
                value = shortNameStr,
 | 
			
		||||
                onValueChange = { value -> shortNameStr = value},
 | 
			
		||||
                label = { Text("Server Short Name") },
 | 
			
		||||
@ -93,6 +94,7 @@ fun EditServerScreen(
 | 
			
		||||
                modifier = Modifier
 | 
			
		||||
                    .fillMaxWidth()
 | 
			
		||||
                    .padding(vertical = 10.dp),
 | 
			
		||||
                singleLine = true,
 | 
			
		||||
                value = nameStr,
 | 
			
		||||
                onValueChange = { value -> nameStr = value},
 | 
			
		||||
                label = { Text("Server Name") },
 | 
			
		||||
@ -105,6 +107,7 @@ fun EditServerScreen(
 | 
			
		||||
                keyboardOptions = KeyboardOptions(
 | 
			
		||||
                    keyboardType = KeyboardType.Uri,
 | 
			
		||||
                ),
 | 
			
		||||
                singleLine = true,
 | 
			
		||||
                value = urlStr,
 | 
			
		||||
                onValueChange = { value -> urlStr = value},
 | 
			
		||||
                label = { Text("Server API Url") },
 | 
			
		||||
@ -114,6 +117,7 @@ fun EditServerScreen(
 | 
			
		||||
                modifier = Modifier
 | 
			
		||||
                    .fillMaxWidth()
 | 
			
		||||
                    .padding(vertical = 10.dp),
 | 
			
		||||
                singleLine = true,
 | 
			
		||||
                value = baseFolderNameStr,
 | 
			
		||||
                onValueChange = { value -> baseFolderNameStr = value},
 | 
			
		||||
                label = { Text("Base folder name") },
 | 
			
		||||
@ -123,6 +127,10 @@ fun EditServerScreen(
 | 
			
		||||
                modifier = Modifier
 | 
			
		||||
                    .fillMaxWidth()
 | 
			
		||||
                    .padding(vertical = 10.dp),
 | 
			
		||||
                keyboardOptions = KeyboardOptions(
 | 
			
		||||
                    keyboardType = KeyboardType.Uri,
 | 
			
		||||
                ),
 | 
			
		||||
                singleLine = true,
 | 
			
		||||
                value = mediaBaseUrlStr,
 | 
			
		||||
                onValueChange = { value -> mediaBaseUrlStr = value},
 | 
			
		||||
                label = { Text("Media base url") },
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user