@@ -36,16 +36,20 @@ import androidx.compose.foundation.layout.height
3636import androidx.compose.foundation.layout.padding
3737import androidx.compose.foundation.rememberScrollState
3838import androidx.compose.foundation.verticalScroll
39+ import androidx.compose.material.icons.Icons
40+ import androidx.compose.material.icons.filled.Warning
3941import androidx.compose.material3.CircularProgressIndicator
4042import androidx.compose.material3.MaterialTheme
4143import androidx.compose.material3.Surface
4244import androidx.compose.runtime.Composable
4345import androidx.compose.runtime.livedata.observeAsState
4446import androidx.compose.ui.Modifier
47+ import androidx.compose.ui.graphics.Color
4548import androidx.compose.ui.res.stringResource
4649import androidx.compose.ui.tooling.preview.Preview
4750import androidx.compose.ui.unit.dp
4851import com.phpbg.easysync.R
52+ import com.phpbg.easysync.ui.components.StatusTitle
4953import com.phpbg.easysync.ui.components.StdText
5054import com.phpbg.easysync.ui.components.SwitchSetting
5155import com.phpbg.easysync.ui.components.Title
@@ -70,7 +74,7 @@ class AdvancedSyncSettingsActivity : ComponentActivity() {
7074 ) {
7175 val uiState = viewModel.advancedSyncSettingsUiState.observeAsState()
7276 Main (
73- uiState = uiState.value ? : AdvancedSyncSettingsUiState (paths = listOf ()),
77+ uiState = uiState.value ? : AdvancedSyncSettingsUiState (paths = listOf (), errorMsg = null ),
7478 toggleExclusionHandler = viewModel::toggleExclusion
7579 )
7680 }
@@ -95,6 +99,14 @@ private fun Main(
9599 StdText (text = stringResource(R .string.advanced_sync_settings_activity_help))
96100 Spacer (modifier = Modifier .height(16 .dp))
97101
102+ if (! uiState.errorMsg.isNullOrEmpty()) {
103+ StatusTitle (
104+ title = uiState.errorMsg,
105+ statusColor = Color .Red ,
106+ statusIcon = Icons .Default .Warning
107+ )
108+ }
109+
98110 if (uiState.paths.isEmpty()) {
99111 CircularProgressIndicator (color = MaterialTheme .colorScheme.outline)
100112 } else {
@@ -125,6 +137,28 @@ private fun MainPreview() {
125137 SyncPath (relativePath = " /bar/baz" , enabled = false ),
126138 SyncPath (relativePath = " /quuux" , enabled = true )
127139 ),
140+ errorMsg = null
141+ ),
142+ toggleExclusionHandler = { _, _ -> }
143+ )
144+ }
145+ }
146+
147+ @Preview(name = " Light Mode" , showBackground = true )
148+ @Composable
149+ private fun MainPreviewError () {
150+ EasySyncTheme {
151+ Main (
152+ uiState = AdvancedSyncSettingsUiState (
153+ paths = listOf (
154+ SyncPath (
155+ relativePath = " /foo" ,
156+ enabled = true
157+ ),
158+ SyncPath (relativePath = " /bar/baz" , enabled = false ),
159+ SyncPath (relativePath = " /quuux" , enabled = true )
160+ ),
161+ errorMsg = " WebDav error: unable to resolve host"
128162 ),
129163 toggleExclusionHandler = { _, _ -> }
130164 )
0 commit comments