Skip to content

Commit

Permalink
feat(ui): swipe up and down to switch between articles (#589)
Browse files Browse the repository at this point in the history
* build(deps): bump up dependencies, compile sdk, and gradle version (#502)

* build(deps): bump up dependencies, compile sdk, and gradle version

* build(deps): remove redundant safe-args plugin

* build(deps): update Compose BOM to `2024.01.00` & compiler to `1.5.8`

* fix(i18n): configuration loss when switching locale (#541)

* fix(i18n): configuration loss when switching locale

* feat(locale): enable auto-localeconfig

* feat(i18n): add languages to in-app language picker (#571)

* feat(i18n): add languages to in-app language picker

* fix(i18n): locale system settings not working for Android 13

* feat(i18n): show selected language at settings page

* fix(ci): ignore ExtraTranslation for linter

* feat(i18n): add fallback in in-app language picker for A13+

* chore: clean up

* fix(ui): ProgressIndicator crashes in m3 1.1.2

* fix(ui): NavigationBarItem color

* feat(ui): grey out read articles even if starred (#547)

* refactor(ui): improve add account dialog

* fix(ui): accessing listState on io thread causes app to crash

* fix(ui): NavigationBar text color

* feat(ui): show full screen image viewer when clicking on images (#578)

* feat(ui): add crash report activity to handle uncaught exceptions (#576)

* feat(ui): swipe up and down to switch between articles (WIP)

* feat(ui): update animation

* docs(ui): add comments on pull to load implementation

* feat(ui): move the indicator to another file

* build: revert changes

* feat(ui): make the transition directions match the content changes

---------

Co-authored-by: MauroGuida <57829432+MauroGuida@users.noreply.github.com>
Co-authored-by: Ash <Glaxyinfinite@outlook.com>
Co-authored-by: Ash <Ashinch@outlook.it>
  • Loading branch information
4 people authored Feb 6, 2024
1 parent 80f335a commit 1b758df
Show file tree
Hide file tree
Showing 8 changed files with 641 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fun LazyListScope.Reader(
onImageClick: ((imgUrl: String, altText: String) -> Unit)? = null,
onLinkClick: (String) -> Unit
) {
Log.i("RLog", "Reader: ")
// Log.i("RLog", "Reader: ")
htmlFormattedText(
inputStream = content.byteInputStream(),
subheadUpperCase = subheadUpperCase,
Expand Down
106 changes: 59 additions & 47 deletions app/src/main/java/me/ash/reader/ui/page/home/reading/Content.kt
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
package me.ash.reader.ui.page.home.reading

import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.tween
import androidx.compose.animation.expandVertically
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.scaleIn
import androidx.compose.animation.shrinkVertically
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.text.selection.DisableSelection
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.KeyboardArrowDown
import androidx.compose.material.icons.outlined.KeyboardArrowUp
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
import me.ash.reader.infrastructure.preference.LocalOpenLink
import me.ash.reader.infrastructure.preference.LocalOpenLinkSpecificBrowser
import me.ash.reader.infrastructure.preference.LocalReadingSubheadUpperCase
import me.ash.reader.ui.component.base.RYExtensibleVisibility
import me.ash.reader.ui.component.reader.Reader
import me.ash.reader.ui.ext.drawVerticalScrollbar
import me.ash.reader.ui.ext.openURL
import me.ash.reader.ui.ext.pagerAnimate
import java.util.*
import kotlin.math.abs

@Composable
fun Content(
modifier: Modifier = Modifier,
content: String,
feedName: String,
title: String,
Expand All @@ -31,60 +50,52 @@ fun Content(
publishedDate: Date,
listState: LazyListState,
isLoading: Boolean,
pullToLoadState: PullToLoadState,
onImageClick: ((imgUrl: String, altText: String) -> Unit)? = null,
) {
val context = LocalContext.current
val subheadUpperCase = LocalReadingSubheadUpperCase.current
val openLink = LocalOpenLink.current
val openLinkSpecificBrowser = LocalOpenLinkSpecificBrowser.current

SelectionContainer {
LazyColumn(
modifier = Modifier
.fillMaxSize()
.drawVerticalScrollbar(listState),
state = listState,
) {
item {
// Top bar height
Spacer(modifier = Modifier.height(64.dp))
// padding
Spacer(modifier = Modifier.height(22.dp))
Column(
modifier = Modifier
.padding(horizontal = 12.dp)
) {
DisableSelection {
Metadata(
feedName = feedName,
title = title,
author = author,
link = link,
publishedDate = publishedDate,
)
}
}
}
item {
Spacer(modifier = Modifier.height(22.dp))
RYExtensibleVisibility(visible = isLoading) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center,
if (isLoading) {
Column {
CircularProgressIndicator(
modifier = Modifier
.size(30.dp),
color = MaterialTheme.colorScheme.onSurface,
)
}
} else {

SelectionContainer {
LazyColumn(
modifier = modifier
.fillMaxSize()
.drawVerticalScrollbar(listState)
.offset(x = 0.dp, y = (pullToLoadState.offsetFraction * 80).dp),
state = listState,
) {
item {
// Top bar height
Spacer(modifier = Modifier.height(64.dp))
// padding
Spacer(modifier = Modifier.height(22.dp))
Column(
modifier = Modifier
.padding(horizontal = 12.dp)
) {
Column {
Spacer(modifier = Modifier.height(22.dp))
CircularProgressIndicator(
modifier = Modifier
.size(30.dp),
color = MaterialTheme.colorScheme.onSurface,
DisableSelection {
Metadata(
feedName = feedName,
title = title,
author = author,
link = link,
publishedDate = publishedDate,
)
Spacer(modifier = Modifier.height(22.dp))
}
}
}
}
if (!isLoading) {
Reader(
context = context,
subheadUpperCase = subheadUpperCase.value,
Expand All @@ -95,10 +106,11 @@ fun Content(
context.openURL(it, openLink, openLinkSpecificBrowser)
}
)
}
item {
Spacer(modifier = Modifier.height(128.dp))
Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars))

item {
Spacer(modifier = Modifier.height(128.dp))
Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars))
}
}
}
}
Expand Down
Loading

0 comments on commit 1b758df

Please sign in to comment.