-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
31 changed files
with
490 additions
and
16 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
89 changes: 89 additions & 0 deletions
89
common-ui/src/main/java/com/mrl/pixiv/common_ui/illust/IllustGrid.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.mrl.pixiv.common_ui.illust | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.aspectRatio | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.lazy.grid.GridCells | ||
import androidx.compose.foundation.lazy.grid.LazyGridState | ||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
import androidx.compose.foundation.lazy.grid.items | ||
import androidx.compose.foundation.lazy.grid.rememberLazyGridState | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableIntStateOf | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import com.mrl.pixiv.common.middleware.bookmark.BookmarkAction | ||
import com.mrl.pixiv.common.middleware.bookmark.BookmarkState | ||
import com.mrl.pixiv.common.ui.components.m3.Surface | ||
import com.mrl.pixiv.common_ui.item.SquareIllustItem | ||
import com.mrl.pixiv.data.Illust | ||
import com.mrl.pixiv.util.OnScrollToBottom | ||
import com.mrl.pixiv.util.isEven | ||
|
||
@Composable | ||
fun IllustGrid( | ||
modifier: Modifier = Modifier, | ||
lazyGridState: LazyGridState = rememberLazyGridState(), | ||
illusts: List<Illust>, | ||
bookmarkState: BookmarkState, | ||
dispatch: (BookmarkAction) -> Unit, | ||
spanCount: Int, | ||
horizontalPadding: Dp = 0.dp, | ||
paddingValues: PaddingValues = PaddingValues(1.dp), | ||
navToPictureScreen: (Illust) -> Unit, | ||
canLoadMore: Boolean = true, | ||
onLoadMore: () -> Unit, | ||
) { | ||
var currentLoadingItem by rememberSaveable { mutableIntStateOf(0) } | ||
LaunchedEffect(illusts.size) { | ||
currentLoadingItem = if (illusts.size.isEven()) { | ||
4 | ||
} else { | ||
5 | ||
} | ||
} | ||
LazyVerticalGrid( | ||
state = lazyGridState, | ||
modifier = modifier, | ||
columns = GridCells.Fixed(spanCount), | ||
verticalArrangement = Arrangement.spacedBy(3.dp), | ||
horizontalArrangement = Arrangement.spacedBy(3.dp), | ||
) { | ||
items(illusts, key = { "illust_${it.id}" }) { illust -> | ||
SquareIllustItem( | ||
illust = illust, | ||
bookmarkState = bookmarkState, | ||
dispatch = dispatch, | ||
spanCount = spanCount, | ||
horizontalPadding = horizontalPadding, | ||
paddingValues = paddingValues, | ||
navToPictureScreen = navToPictureScreen, | ||
) | ||
} | ||
|
||
if (canLoadMore) { | ||
items(currentLoadingItem, key = { "loading_$it" }) { | ||
Surface( | ||
Modifier | ||
.fillMaxWidth() | ||
.aspectRatio(1f), | ||
shape = MaterialTheme.shapes.medium, | ||
shadowElevation = 4.dp, | ||
propagateMinConstraints = false, | ||
) { | ||
|
||
} | ||
} | ||
} | ||
} | ||
lazyGridState.OnScrollToBottom(loadingItemCount = currentLoadingItem) { | ||
onLoadMore() | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...l/pixiv/setting/components/SettingItem.kt → ...m/mrl/pixiv/common_ui/item/SettingItem.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,12 @@ | ||
plugins { | ||
id("pixiv.android.library.compose") | ||
id("pixiv.android.feature") | ||
} | ||
|
||
android { | ||
namespace = "com.mrl.pixiv.history" | ||
} | ||
|
||
dependencies { | ||
implementation(project(":repository")) | ||
} |
Empty file.
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest> | ||
|
||
</manifest> |
Oops, something went wrong.