-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1026cb9
commit 7427620
Showing
12 changed files
with
610 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
app/src/main/java/com/jerboa/ui/components/home/Sidebar.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.jerboa.ui.components.home | ||
|
||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.jerboa.DotSpacer | ||
import com.jerboa.MyMarkdownText | ||
import com.jerboa.datatypes.SiteView | ||
import com.jerboa.datatypes.sampleSiteView | ||
import com.jerboa.siFormat | ||
import com.jerboa.ui.components.common.LargerCircularIcon | ||
import com.jerboa.ui.components.common.PictrsBannerImage | ||
import com.jerboa.ui.components.common.TimeAgo | ||
import com.jerboa.ui.theme.MEDIUM_PADDING | ||
import com.jerboa.ui.theme.Muted | ||
import com.jerboa.ui.theme.PROFILE_BANNER_SIZE | ||
|
||
@Composable | ||
fun Sidebar(siteView: SiteView) { | ||
val site = siteView.site | ||
Column( | ||
modifier = Modifier.padding(MEDIUM_PADDING), | ||
verticalArrangement = Arrangement.spacedBy(MEDIUM_PADDING) | ||
) { | ||
Box( | ||
modifier = Modifier.fillMaxWidth(), | ||
contentAlignment = Alignment.BottomStart | ||
) { | ||
site.banner?.also { | ||
PictrsBannerImage( | ||
url = it, modifier = Modifier.height(PROFILE_BANNER_SIZE) | ||
) | ||
} | ||
Box(modifier = Modifier.padding(MEDIUM_PADDING)) { | ||
site.icon?.also { | ||
LargerCircularIcon(icon = it) | ||
} | ||
} | ||
} | ||
site.description?.also { | ||
Text( | ||
text = it, | ||
style = MaterialTheme.typography.subtitle1 | ||
) | ||
} | ||
TimeAgo( | ||
precedingString = "Created", | ||
includeAgo = true, | ||
dateStr = site.published | ||
) | ||
CommentsAndPosts(siteView = siteView) | ||
site.sidebar?.also { | ||
MyMarkdownText( | ||
markdown = it, | ||
color = Muted, | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun CommentsAndPosts(siteView: SiteView) { | ||
Row { | ||
Text( | ||
text = "${siFormat(siteView.counts.users_active_month)} users / month", | ||
color = Muted, | ||
) | ||
DotSpacer() | ||
Text( | ||
text = "${siFormat(siteView.counts.posts)} posts", | ||
color = Muted, | ||
) | ||
DotSpacer() | ||
Text( | ||
text = "${siFormat(siteView.counts.comments)} comments", | ||
color = Muted, | ||
) | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
fun SidebarPreview() { | ||
Sidebar(siteView = sampleSiteView) | ||
} |
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/jerboa/ui/components/home/SidebarActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.jerboa.ui.components.home | ||
|
||
import android.util.Log | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Scaffold | ||
import androidx.compose.material.Surface | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.navigation.NavController | ||
import com.jerboa.SimpleTopAppBar | ||
|
||
@Composable | ||
fun SidebarActivity( | ||
siteViewModel: SiteViewModel, | ||
navController: NavController, | ||
) { | ||
|
||
Log.d("jerboa", "got to sidebar activity") | ||
|
||
val ctx = LocalContext.current | ||
val scope = rememberCoroutineScope() | ||
val title = "${siteViewModel.siteRes?.site_view?.site?.name} Sidebar" | ||
|
||
Surface(color = MaterialTheme.colors.background) { | ||
Scaffold( | ||
topBar = { | ||
SimpleTopAppBar( | ||
text = title, | ||
navController = navController | ||
) | ||
}, | ||
content = { | ||
siteViewModel.siteRes?.site_view?.also { | ||
Sidebar(it) | ||
} | ||
} | ||
) | ||
} | ||
} |
Oops, something went wrong.