Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 87764cc15b |
@@ -11,6 +11,7 @@ import androidx.activity.compose.rememberLauncherForActivityResult
|
|||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Close
|
||||||
import androidx.compose.material.icons.filled.Upload
|
import androidx.compose.material.icons.filled.Upload
|
||||||
import androidx.compose.material3.*
|
import androidx.compose.material3.*
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
@@ -194,12 +195,27 @@ fun GeneralUploadTab(
|
|||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.padding(16.dp)) {
|
Column(modifier = Modifier.padding(16.dp)) {
|
||||||
Text(
|
Row(
|
||||||
text = "Selected File",
|
modifier = Modifier.fillMaxWidth(),
|
||||||
style = MaterialTheme.typography.titleSmall,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
color = MaterialTheme.colorScheme.primary
|
verticalAlignment = Alignment.CenterVertically
|
||||||
)
|
) {
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
Text(
|
||||||
|
text = "Selected File",
|
||||||
|
style = MaterialTheme.typography.titleSmall,
|
||||||
|
color = MaterialTheme.colorScheme.primary
|
||||||
|
)
|
||||||
|
IconButton(
|
||||||
|
onClick = { viewModel.clearSelectedFile() },
|
||||||
|
enabled = !uiState.isLoading
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
Icons.Default.Close,
|
||||||
|
contentDescription = "Remove selected file",
|
||||||
|
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Text(
|
Text(
|
||||||
text = fileName,
|
text = fileName,
|
||||||
style = MaterialTheme.typography.bodyMedium
|
style = MaterialTheme.typography.bodyMedium
|
||||||
|
|||||||
@@ -139,7 +139,9 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
showUploadResultDialog = true,
|
showUploadResultDialog = true,
|
||||||
uploadProgress = 0,
|
uploadProgress = 0,
|
||||||
bytesUploaded = 0,
|
bytesUploaded = 0,
|
||||||
totalBytes = 0
|
totalBytes = 0,
|
||||||
|
selectedFile = null,
|
||||||
|
selectedFileName = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
AppConstants.ACTION_UPLOAD_ERROR -> {
|
AppConstants.ACTION_UPLOAD_ERROR -> {
|
||||||
@@ -328,6 +330,16 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the selected file
|
||||||
|
*/
|
||||||
|
fun clearSelectedFile() {
|
||||||
|
_uiState.value = _uiState.value.copy(
|
||||||
|
selectedFile = null,
|
||||||
|
selectedFileName = null
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show upload parameters dialog
|
* Show upload parameters dialog
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user