正在显示
1 个修改的文件
包含
48 行增加
和
38 行删除
| @@ -11,6 +11,8 @@ import androidx.activity.result.contract.ActivityResultContracts | @@ -11,6 +11,8 @@ import androidx.activity.result.contract.ActivityResultContracts | ||
| 11 | import androidx.activity.viewModels | 11 | import androidx.activity.viewModels |
| 12 | import androidx.compose.foundation.Image | 12 | import androidx.compose.foundation.Image |
| 13 | import androidx.compose.foundation.layout.* | 13 | import androidx.compose.foundation.layout.* |
| 14 | +import androidx.compose.foundation.rememberScrollState | ||
| 15 | +import androidx.compose.foundation.verticalScroll | ||
| 14 | import androidx.compose.material.* | 16 | import androidx.compose.material.* |
| 15 | import androidx.compose.runtime.* | 17 | import androidx.compose.runtime.* |
| 16 | import androidx.compose.ui.Alignment | 18 | import androidx.compose.ui.Alignment |
| @@ -84,52 +86,60 @@ class MainActivity : ComponentActivity() { | @@ -84,52 +86,60 @@ class MainActivity : ComponentActivity() { | ||
| 84 | AppTheme { | 86 | AppTheme { |
| 85 | var url by remember { mutableStateOf(defaultUrl) } | 87 | var url by remember { mutableStateOf(defaultUrl) } |
| 86 | var token by remember { mutableStateOf(defaultToken) } | 88 | var token by remember { mutableStateOf(defaultToken) } |
| 89 | + val scrollState = rememberScrollState() | ||
| 87 | // A surface container using the 'background' color from the theme | 90 | // A surface container using the 'background' color from the theme |
| 88 | Surface( | 91 | Surface( |
| 89 | color = MaterialTheme.colors.background, | 92 | color = MaterialTheme.colors.background, |
| 90 | - modifier = Modifier.fillMaxSize() | 93 | + modifier = Modifier |
| 94 | + .fillMaxSize() | ||
| 91 | ) { | 95 | ) { |
| 92 | - Column( | ||
| 93 | - horizontalAlignment = Alignment.CenterHorizontally, | ||
| 94 | - modifier = Modifier.padding(10.dp) | 96 | + Box( |
| 97 | + modifier = Modifier | ||
| 98 | + .verticalScroll(scrollState) | ||
| 95 | ) { | 99 | ) { |
| 96 | - Spacer(modifier = Modifier.height(50.dp)) | ||
| 97 | - Image( | ||
| 98 | - painter = painterResource(id = R.drawable.banner_dark), | ||
| 99 | - contentDescription = "", | ||
| 100 | - ) | ||
| 101 | - Spacer(modifier = Modifier.height(20.dp)) | ||
| 102 | - OutlinedTextField( | ||
| 103 | - value = url, | ||
| 104 | - onValueChange = { url = it }, | ||
| 105 | - label = { Text("URL") }, | ||
| 106 | - modifier = Modifier.fillMaxWidth(), | ||
| 107 | - ) | ||
| 108 | - Spacer(modifier = Modifier.height(20.dp)) | ||
| 109 | - OutlinedTextField( | ||
| 110 | - value = token, | ||
| 111 | - onValueChange = { token = it }, | ||
| 112 | - label = { Text("Token") }, | ||
| 113 | - modifier = Modifier.fillMaxWidth(), | ||
| 114 | - ) | 100 | + Column( |
| 101 | + horizontalAlignment = Alignment.CenterHorizontally, | ||
| 102 | + modifier = Modifier | ||
| 103 | + .padding(10.dp) | ||
| 104 | + ) { | ||
| 105 | + Spacer(modifier = Modifier.height(50.dp)) | ||
| 106 | + Image( | ||
| 107 | + painter = painterResource(id = R.drawable.banner_dark), | ||
| 108 | + contentDescription = "", | ||
| 109 | + ) | ||
| 110 | + Spacer(modifier = Modifier.height(20.dp)) | ||
| 111 | + OutlinedTextField( | ||
| 112 | + value = url, | ||
| 113 | + onValueChange = { url = it }, | ||
| 114 | + label = { Text("URL") }, | ||
| 115 | + modifier = Modifier.fillMaxWidth(), | ||
| 116 | + ) | ||
| 117 | + Spacer(modifier = Modifier.height(20.dp)) | ||
| 118 | + OutlinedTextField( | ||
| 119 | + value = token, | ||
| 120 | + onValueChange = { token = it }, | ||
| 121 | + label = { Text("Token") }, | ||
| 122 | + modifier = Modifier.fillMaxWidth(), | ||
| 123 | + ) | ||
| 115 | 124 | ||
| 116 | - Spacer(modifier = Modifier.height(20.dp)) | ||
| 117 | - Button(onClick = { onConnect(url, token) }) { | ||
| 118 | - Text("Connect") | ||
| 119 | - } | 125 | + Spacer(modifier = Modifier.height(20.dp)) |
| 126 | + Button(onClick = { onConnect(url, token) }) { | ||
| 127 | + Text("Connect") | ||
| 128 | + } | ||
| 120 | 129 | ||
| 121 | - Spacer(modifier = Modifier.height(20.dp)) | ||
| 122 | - Button(onClick = { onSave(url, token) }) { | ||
| 123 | - Text("Save Values") | ||
| 124 | - } | 130 | + Spacer(modifier = Modifier.height(20.dp)) |
| 131 | + Button(onClick = { onSave(url, token) }) { | ||
| 132 | + Text("Save Values") | ||
| 133 | + } | ||
| 125 | 134 | ||
| 126 | - Spacer(modifier = Modifier.height(20.dp)) | ||
| 127 | - Button(onClick = { | ||
| 128 | - onReset() | ||
| 129 | - url = MainViewModel.URL | ||
| 130 | - token = MainViewModel.TOKEN | ||
| 131 | - }) { | ||
| 132 | - Text("Reset Values") | 135 | + Spacer(modifier = Modifier.height(20.dp)) |
| 136 | + Button(onClick = { | ||
| 137 | + onReset() | ||
| 138 | + url = MainViewModel.URL | ||
| 139 | + token = MainViewModel.TOKEN | ||
| 140 | + }) { | ||
| 141 | + Text("Reset Values") | ||
| 142 | + } | ||
| 133 | } | 143 | } |
| 134 | } | 144 | } |
| 135 | } | 145 | } |
-
请 注册 或 登录 后发表评论