mirror of https://github.com/readrops/Readrops.git
Add topAppBar to some tabs
This commit is contained in:
parent
f08d3eac71
commit
cf0f94bff2
|
@ -3,9 +3,13 @@ package com.readrops.app.compose.account
|
|||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
|
@ -27,6 +31,7 @@ object AccountTab : Tab {
|
|||
title = "Account"
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
|
@ -37,11 +42,14 @@ object AccountTab : Tab {
|
|||
navigator.replaceAll(AccountSelectionScreen())
|
||||
}
|
||||
|
||||
Column {
|
||||
Text(text = "Account")
|
||||
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(title = { Text(text = "Account") })
|
||||
}
|
||||
) { paddingValues ->
|
||||
Column(
|
||||
modifier = Modifier.padding(paddingValues)
|
||||
) {
|
||||
Row {
|
||||
Button(onClick = { viewModel.deleteAccount() }) {
|
||||
Text(
|
||||
|
@ -60,4 +68,7 @@ object AccountTab : Tab {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -7,8 +7,12 @@ import androidx.compose.foundation.lazy.LazyColumn
|
|||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
|
@ -31,6 +35,7 @@ object FeedTab : Tab {
|
|||
title = "Feeds"
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val viewModel = getViewModel<FeedViewModel>()
|
||||
|
@ -48,8 +53,15 @@ object FeedTab : Tab {
|
|||
)
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(title = { Text(text = "Feeds") })
|
||||
}
|
||||
) { paddingValues ->
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize()
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(paddingValues)
|
||||
) {
|
||||
when (state) {
|
||||
is FeedsState.LoadedState -> {
|
||||
|
@ -67,16 +79,16 @@ object FeedTab : Tab {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
is FeedsState.ErrorState -> {
|
||||
|
||||
}
|
||||
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
FloatingActionButton(
|
||||
modifier = Modifier
|
||||
.align(Alignment.BottomEnd)
|
||||
|
@ -89,6 +101,6 @@ object FeedTab : Tab {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,21 +3,23 @@ package com.readrops.app.compose.timelime
|
|||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||
import cafe.adriel.voyager.navigator.Navigator
|
||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import cafe.adriel.voyager.navigator.tab.LocalTabNavigator
|
||||
import cafe.adriel.voyager.navigator.tab.Tab
|
||||
import cafe.adriel.voyager.navigator.tab.TabOptions
|
||||
import com.google.accompanist.swiperefresh.SwipeRefresh
|
||||
|
@ -37,6 +39,7 @@ object TimelineTab : Tab {
|
|||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val viewModel = getViewModel<TimelineViewModel>()
|
||||
|
@ -47,11 +50,19 @@ object TimelineTab : Tab {
|
|||
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(text = "Timeline") }
|
||||
)
|
||||
}
|
||||
) { paddingValues ->
|
||||
SwipeRefresh(
|
||||
state = swipeToRefreshState,
|
||||
onRefresh = {
|
||||
viewModel.refreshTimeline()
|
||||
},
|
||||
modifier = Modifier.padding(paddingValues)
|
||||
) {
|
||||
when (state) {
|
||||
is TimelineState.LoadedState -> {
|
||||
|
@ -71,13 +82,18 @@ object TimelineTab : Tab {
|
|||
NoItemPlaceholder()
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
NoItemPlaceholder()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun NoItemPlaceholder() {
|
||||
val scrollState = rememberScrollState()
|
||||
|
|
Loading…
Reference in New Issue