Skip to content

Commit

Permalink
Merge pull request #489 from DimensionDev/feature/home_tab
Browse files Browse the repository at this point in the history
add home tab support
  • Loading branch information
Tlaster authored Sep 25, 2024
2 parents 47ca577 + 1454afa commit 76ed1a5
Show file tree
Hide file tree
Showing 15 changed files with 1,004 additions and 289 deletions.
10 changes: 10 additions & 0 deletions app/src/main/java/dev/dimension/flare/data/model/TabSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import java.io.OutputStream
data class TabSettings(
val items: List<TabItem> = TimelineTabItem.default,
val secondaryItems: List<TabItem>? = null,
val homeTabs: Map<MicroBlogKey, List<TimelineTabItem>> = mapOf(),
)

@Serializable
Expand Down Expand Up @@ -562,6 +563,15 @@ data class HomeTimelineTabItem(
override fun createPresenter(): TimelinePresenter = HomeTimelinePresenter(account)

override fun update(metaData: TabMetaData): TabItem = copy(metaData = metaData)
constructor(accountType: AccountType) :
this(
account = accountType,
metaData =
TabMetaData(
title = TitleType.Localized(TitleType.Localized.LocalizedKey.Home),
icon = IconType.Material(IconType.Material.MaterialIcon.Home),
),
)
}

@Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package dev.dimension.flare.ui.component

import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.TopAppBarColors
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp

@ExperimentalMaterial3Api
@Composable
fun FlareTopAppBar(
title: @Composable () -> Unit,
modifier: Modifier = Modifier,
navigationIcon: @Composable () -> Unit = {},
actions: @Composable RowScope.() -> Unit = {},
expandedHeight: Dp = TopAppBarDefaults.TopAppBarExpandedHeight,
windowInsets: WindowInsets = TopAppBarDefaults.windowInsets,
colors: TopAppBarColors =
TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.surface,
scrolledContainerColor = MaterialTheme.colorScheme.surface,
),
scrollBehavior: TopAppBarScrollBehavior? = null,
) {
androidx.compose.material3.TopAppBar(
title = title,
modifier = modifier,
navigationIcon = navigationIcon,
actions = actions,
expandedHeight = expandedHeight,
windowInsets = windowInsets,
colors = colors,
scrollBehavior = scrollBehavior,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ internal fun StatusPlaceholder(modifier: Modifier = Modifier) {
Column(
modifier = modifier,
) {
Spacer(modifier = Modifier.height(4.dp))
UserPlaceholder()
Spacer(modifier = Modifier.height(8.dp))
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import com.ramcosta.composedestinations.generated.NavGraphs
import com.ramcosta.composedestinations.generated.destinations.BlueskyFeedsRouteDestination
import com.ramcosta.composedestinations.generated.destinations.ComposeRouteDestination
import com.ramcosta.composedestinations.generated.destinations.DiscoverRouteDestination
import com.ramcosta.composedestinations.generated.destinations.HomeTimelineRouteDestination
import com.ramcosta.composedestinations.generated.destinations.ListScreenRouteDestination
import com.ramcosta.composedestinations.generated.destinations.MeRouteDestination
import com.ramcosta.composedestinations.generated.destinations.NotificationRouteDestination
Expand All @@ -93,6 +94,7 @@ import dev.dimension.flare.R
import dev.dimension.flare.data.model.AllListTabItem
import dev.dimension.flare.data.model.Bluesky
import dev.dimension.flare.data.model.DiscoverTabItem
import dev.dimension.flare.data.model.HomeTimelineTabItem
import dev.dimension.flare.data.model.NotificationTabItem
import dev.dimension.flare.data.model.ProfileTabItem
import dev.dimension.flare.data.model.SettingsTabItem
Expand Down Expand Up @@ -746,6 +748,10 @@ private fun getDirection(
MeRouteDestination(accountType)
}

is HomeTimelineTabItem -> {
HomeTimelineRouteDestination(accountType)
}

is TimelineTabItem -> {
TimelineRouteDestination(tab)
}
Expand Down Expand Up @@ -1019,7 +1025,7 @@ internal fun RegisterTabCallback(lazyListState: LazyStaggeredGridState) {
}
}
}
DisposableEffect(tabState, callback) {
DisposableEffect(tabState, callback, lazyListState) {
tabState.registerCallback(callback)
onDispose {
tabState.unregisterCallback(callback)
Expand Down
Loading

0 comments on commit 76ed1a5

Please sign in to comment.