mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
use lazyColumn to layout settings screen
This commit is contained in:
parent
9a40f7c08d
commit
730cc0283e
2 changed files with 47 additions and 17 deletions
|
|
@ -35,7 +35,7 @@ fun SearchBar(
|
|||
) {
|
||||
val searchText: String by libraryViewModel.searchTextLiveData.observeAsState("")
|
||||
|
||||
SmallTopAppBar(
|
||||
TopAppBar(
|
||||
title = {
|
||||
if (libraryViewModel.showSearchField) {
|
||||
SearchField(searchText) { libraryViewModel.updateSearchText(it) }
|
||||
|
|
@ -43,7 +43,7 @@ fun SearchBar(
|
|||
Text("Library")
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.smallTopAppBarColors(
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
),
|
||||
actions = {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
import android.annotation.SuppressLint
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Home
|
||||
import androidx.compose.material.pullrefresh.pullRefresh
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
|
|
@ -11,13 +16,15 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.navigation.NavHostController
|
||||
import app.omnivore.omnivore.Routes
|
||||
import app.omnivore.omnivore.ui.auth.LoginViewModel
|
||||
import app.omnivore.omnivore.ui.library.LibraryViewContent
|
||||
import app.omnivore.omnivore.ui.library.LibraryViewModel
|
||||
import app.omnivore.omnivore.ui.library.SearchBar
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignIn
|
||||
import com.google.android.gms.auth.api.signin.GoogleSignInOptions
|
||||
import io.intercom.android.sdk.Intercom
|
||||
import io.intercom.android.sdk.IntercomSpace
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
|
||||
@Composable
|
||||
fun SettingsView(
|
||||
loginViewModel: LoginViewModel,
|
||||
|
|
@ -25,11 +32,8 @@ fun SettingsView(
|
|||
) {
|
||||
Scaffold(
|
||||
topBar = {
|
||||
SmallTopAppBar(
|
||||
TopAppBar(
|
||||
title = { Text("Settings") },
|
||||
colors = TopAppBarDefaults.smallTopAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
),
|
||||
actions = {
|
||||
IconButton(onClick = { navController.navigate(Routes.Library.route) }) {
|
||||
Icon(
|
||||
|
|
@ -37,23 +41,49 @@ fun SettingsView(
|
|||
contentDescription = null
|
||||
)
|
||||
}
|
||||
}
|
||||
}, colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.surfaceVariant
|
||||
)
|
||||
)
|
||||
}
|
||||
) { paddingValues ->
|
||||
SettingsViewContent(
|
||||
loginViewModel = loginViewModel,
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
top = paddingValues.calculateTopPadding(),
|
||||
bottom = paddingValues.calculateBottomPadding()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SettingsViewContent(loginViewModel: LoginViewModel, modifier: Modifier) {
|
||||
val listState = rememberLazyListState()
|
||||
|
||||
Box(
|
||||
modifier = modifier.fillMaxSize()
|
||||
) {
|
||||
Column(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
LazyColumn(
|
||||
state = listState,
|
||||
verticalArrangement = Arrangement.Top,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
.background(MaterialTheme.colorScheme.background)
|
||||
.fillMaxSize()
|
||||
.navigationBarsPadding()
|
||||
.padding(horizontal = 16.dp)
|
||||
.padding(horizontal = 6.dp)
|
||||
) {
|
||||
LogoutButton { loginViewModel.logout() }
|
||||
Button(onClick = {
|
||||
Intercom.client().present(space = IntercomSpace.Messages)
|
||||
}) {
|
||||
Text(text = "Open Help Center")
|
||||
item {
|
||||
LogoutButton { loginViewModel.logout() }
|
||||
}
|
||||
|
||||
item {
|
||||
Button(onClick = {
|
||||
Intercom.client().present(space = IntercomSpace.Messages)
|
||||
}) {
|
||||
Text(text = "Open Help Center")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue