Skip to content

Commit

Permalink
fix: NavbarLayout broken for END and BOTTOM positions
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed Aug 19, 2024
1 parent 78b0865 commit 554b441
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 83 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kotlin.code.style=official
group=com.mineinabyss
version=0.12
idofrontVersion=0.24.10
idofrontVersion=0.25.1

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,51 @@
package com.mineinabyss.guiy.example

import com.mineinabyss.guiy.example.gui.AnimatedTitle
import com.mineinabyss.guiy.example.gui.ArrangementMenu
import com.mineinabyss.guiy.example.gui.CreativeMenu
import com.mineinabyss.guiy.example.gui.Cursor
import com.mineinabyss.guiy.inventory.guiy
import com.mineinabyss.idofront.commands.brigadier.commands
import org.bukkit.plugin.java.JavaPlugin

class GuiyExamplePlugin : JavaPlugin() {
override fun onEnable() {
GuiyCommands(this)
override fun onEnable() = commands {
"guiyexample" {
"arrangement" {
playerExecutes {
guiy {
ArrangementMenu(player)
}
}
}
"animated" {
playerExecutes {
guiy {
AnimatedTitle(player)
}
}
}
"creative" {
playerExecutes {
guiy {
CreativeMenu(player)
}
}
}
"cursor" {
playerExecutes {
guiy {
Cursor(player)
}
}
}
"pagination" {
playerExecutes {
guiy {
com.mineinabyss.guiy.example.gui.PaginatedMenu(player)
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mineinabyss.guiy.example.gui

import androidx.compose.runtime.*
import com.mineinabyss.guiy.components.HorizontalGrid
import com.mineinabyss.guiy.components.Item
import com.mineinabyss.guiy.components.VerticalGrid
import com.mineinabyss.guiy.components.canvases.Chest
import com.mineinabyss.guiy.components.lists.NavbarPosition
import com.mineinabyss.guiy.components.lists.Paginated
Expand Down Expand Up @@ -31,11 +31,11 @@ fun PaginatedMenu(player: Player) {
Paginated(
items,
page = page,
navbarPosition = NavbarPosition.START,
navbarPosition = NavbarPosition.END,
previousButton = { Item(Material.RED_CONCRETE, "Previous", modifier = Modifier.clickable { page-- }) },
nextButton = { Item(Material.BLUE_CONCRETE, "Next", modifier = Modifier.clickable { page++ }) },
) { pageItems ->
VerticalGrid {
HorizontalGrid {
pageItems.forEach { item ->
Item(item)
}
Expand Down
36 changes: 21 additions & 15 deletions src/main/kotlin/com/mineinabyss/guiy/components/lists/Paginated.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package com.mineinabyss.guiy.components.lists
import androidx.compose.runtime.*
import com.mineinabyss.guiy.components.Item
import com.mineinabyss.guiy.components.Spacer
import com.mineinabyss.guiy.jetpack.Alignment
import com.mineinabyss.guiy.jetpack.Arrangement
import com.mineinabyss.guiy.layout.Box
import com.mineinabyss.guiy.layout.Column
import com.mineinabyss.guiy.layout.Row
import com.mineinabyss.guiy.layout.Size
import com.mineinabyss.guiy.modifiers.*
import com.mineinabyss.guiy.modifiers.placement.padding.padding
import com.mineinabyss.idofront.items.editItemMeta
import org.bukkit.Material
import org.bukkit.inventory.ItemStack
Expand Down Expand Up @@ -61,7 +63,7 @@ fun <T> Paginated(
inline fun NavbarButtons(
navbarPosition: NavbarPosition,
background: ItemStack?,
crossinline content: @Composable () -> Unit
crossinline content: @Composable () -> Unit,
) {
val navbarSize =
if (navbarPosition.isVertical()) Modifier.fillMaxHeight().width(1)
Expand Down Expand Up @@ -93,28 +95,32 @@ fun NavbarLayout(
content: @Composable () -> Unit,
) {
when (position) {
NavbarPosition.START ->
Row {
navbar()
content()
}
NavbarPosition.START -> Row {
navbar()
content()
}

NavbarPosition.END ->
Row {
NavbarPosition.END -> Box {
Box(Modifier.padding(end = 1)) {
content()
navbar()
}

NavbarPosition.TOP ->
Column {
Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.TopEnd) {
navbar()
content()
}
}

NavbarPosition.TOP -> Column {
navbar()
content()
}

NavbarPosition.BOTTOM ->
Column {
NavbarPosition.BOTTOM -> Box {
Box(Modifier.padding(bottom = 1)) {
content()
}
Box(Modifier.fillMaxHeight(), contentAlignment = Alignment.BottomStart) {
navbar()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun Modifier.padding(
end: Int = 0,
top: Int = 0,
bottom: Int = 0,
) = then(PaddingModifier(PaddingValues(start, end, bottom, top)))
) = then(PaddingModifier(PaddingValues(start, end, top, bottom)))

@Stable
fun Modifier.padding(horizontal: Int = 0, vertical: Int = 0) =
Expand Down

0 comments on commit 554b441

Please sign in to comment.