A cheap attempt at a native Bluesky client for Android

Timeline: show errors in a Snackbar

Replace the error `Toast` with a `Snackbar`. This provides a more integrated UI for displaying errors within the app and includes a dismiss action.

+19 -5
+19 -5
app/src/main/java/industries/geesawra/monarch/MainView.kt
··· 42 42 import androidx.compose.material3.NavigationDrawerItem 43 43 import androidx.compose.material3.NavigationDrawerItemDefaults 44 44 import androidx.compose.material3.Scaffold 45 + import androidx.compose.material3.Snackbar 46 + import androidx.compose.material3.SnackbarHost 45 47 import androidx.compose.material3.Text 46 48 import androidx.compose.material3.TopAppBar 47 49 import androidx.compose.material3.TopAppBarColors ··· 100 102 skipPartiallyExpanded = true, 101 103 ) 102 104 ) 103 - 104 105 val inReplyTo = remember { mutableStateOf<SkeetData?>(null) } 105 106 val isQuotePost = remember { mutableStateOf(false) } 106 107 ··· 122 123 isQuotePost = isQuotePost 123 124 ) 124 125 }, 126 + snackbarHost = { 127 + SnackbarHost(it) { sd -> 128 + Snackbar(snackbarData = sd, actionOnNewLine = true) 129 + } 130 + }, 125 131 content = { paddingValues -> 126 132 InnerTimelineView( 127 133 modifier = Modifier.padding(paddingValues), ··· 139 145 scaffoldState.bottomSheetState.expand() 140 146 } 141 147 }, 142 - loginError = onLoginError 148 + loginError = onLoginError, 149 + onError = { 150 + coroutineScope.launch { 151 + scaffoldState.snackbarHostState.showSnackbar( 152 + message = "Error: $it", 153 + withDismissAction = true, 154 + ) 155 + } 156 + } 143 157 ) 144 158 } 145 159 ) ··· 154 168 onReplyTap: (SkeetData, Boolean) -> Unit = { _, _ -> }, 155 169 fobOnClick: () -> Unit, 156 170 loginError: () -> Unit, 171 + onError: (String) -> Unit, 157 172 ) { 158 173 var currentDestination by rememberSaveable { mutableStateOf(TabBarDestinations.TIMELINE) } 159 174 val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior( ··· 183 198 184 199 LaunchedEffect(timelineViewModel.uiState.error) { 185 200 timelineViewModel.uiState.error?.let { 186 - Toast.makeText(ctx, "Error: $it", Toast.LENGTH_LONG) 187 - .show() 201 + onError(it) 188 202 } 189 203 } 190 204 ··· 230 244 timelineState.scrollToItem(0) 231 245 } 232 246 } 233 - 247 + 234 248 coroutineScope.launch { 235 249 drawerState.close() 236 250 }