Skip to content

Commit

Permalink
Switch reflection-based system in standalone demo to simpler mechanism (
Browse files Browse the repository at this point in the history
#520)

* migrate main menu

Signed-off-by: Ivan Morgillo <[email protected]>

* migrate Components submenu

Signed-off-by: Ivan Morgillo <[email protected]>

* create StandaloneSampleIcons.Components icons set

Signed-off-by: Ivan Morgillo <[email protected]>

---------

Signed-off-by: Ivan Morgillo <[email protected]>
  • Loading branch information
hamen authored Aug 7, 2024
1 parent 67a5217 commit 82de21f
Show file tree
Hide file tree
Showing 24 changed files with 153 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,32 @@ package org.jetbrains.jewel.samples.standalone
import org.jetbrains.jewel.ui.icon.PathIconKey

object StandaloneSampleIcons {
val componentsMenu = PathIconKey("icons/structure.svg", StandaloneSampleIcons::class.java)
val gitHub = PathIconKey("icons/github.svg", StandaloneSampleIcons::class.java)
val jewelLogo = PathIconKey("icons/jewel-logo.svg", StandaloneSampleIcons::class.java)
val markdown = PathIconKey("icons/markdown.svg", StandaloneSampleIcons::class.java)
val themeDark = PathIconKey("icons/darkTheme.svg", StandaloneSampleIcons::class.java)
val themeLight = PathIconKey("icons/lightTheme.svg", StandaloneSampleIcons::class.java)
val themeLightWithLightHeader =
PathIconKey("icons/lightWithLightHeaderTheme.svg", StandaloneSampleIcons::class.java)
val themeLightWithLightHeader = PathIconKey("icons/lightWithLightHeaderTheme.svg", StandaloneSampleIcons::class.java)
val themeSystem = PathIconKey("icons/systemTheme.svg", StandaloneSampleIcons::class.java)
val welcome = PathIconKey("icons/meetNewUi.svg", StandaloneSampleIcons::class.java)

object Components {
val borders = PathIconKey("icons/components/borders.svg", StandaloneSampleIcons::class.java)
val button = PathIconKey("icons/components/button.svg", StandaloneSampleIcons::class.java)
val checkbox = PathIconKey("icons/components/checkBox.svg", StandaloneSampleIcons::class.java)
val comboBox = PathIconKey("icons/components/comboBox.svg", StandaloneSampleIcons::class.java)
val links = PathIconKey("icons/components/links.svg", StandaloneSampleIcons::class.java)
val progressBar = PathIconKey("icons/components/progressbar.svg", StandaloneSampleIcons::class.java)
val radioButton = PathIconKey("icons/components/radioButton.svg", StandaloneSampleIcons::class.java)
val scrollbar = PathIconKey("icons/components/scrollbar.svg", StandaloneSampleIcons::class.java)
val segmentedControls = PathIconKey("icons/components/segmentedControl.svg", StandaloneSampleIcons::class.java)
val slider = PathIconKey("icons/components/slider.svg", StandaloneSampleIcons::class.java)
val tabs = PathIconKey("icons/components/tabs.svg", StandaloneSampleIcons::class.java)
val textArea = PathIconKey("icons/components/textArea.svg", StandaloneSampleIcons::class.java)
val textField = PathIconKey("icons/components/textField.svg", StandaloneSampleIcons::class.java)
val toolbar = PathIconKey("icons/components/toolbar.svg", StandaloneSampleIcons::class.java)
val tooltip = PathIconKey("icons/components/tooltip.svg", StandaloneSampleIcons::class.java)
val tree = PathIconKey("icons/components/tree.svg", StandaloneSampleIcons::class.java)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.foundation.modifier.trackActivation
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.samples.standalone.viewmodel.ComponentsViewModel
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.samples.standalone.viewmodel.ViewInfo
import org.jetbrains.jewel.ui.Orientation
import org.jetbrains.jewel.ui.component.Divider
Expand All @@ -33,7 +32,6 @@ import org.jetbrains.jewel.ui.theme.tooltipStyle
import kotlin.time.Duration.Companion.milliseconds

@Composable
@View(title = "Components", position = 1, icon = "icons/structure.svg")
fun ComponentsView() {
Row(Modifier.trackActivation().fillMaxSize().background(JewelTheme.globalColors.panelBackground)) {
ComponentsToolBar()
Expand All @@ -52,7 +50,7 @@ fun ComponentsToolBar() {
selected = ComponentsViewModel.currentView == it,
onClick = { ComponentsViewModel.currentView = it },
modifier = Modifier.size(40.dp).padding(5.dp),
tooltip = { Text("Show ${it.title}") },
tooltip = { Text(it.title) },
tooltipStyle =
TooltipStyle(
JewelTheme.tooltipStyle.colors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.samples.standalone.view.markdown.JewelReadme
import org.jetbrains.jewel.samples.standalone.view.markdown.MarkdownEditor
import org.jetbrains.jewel.samples.standalone.view.markdown.MarkdownPreview
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.Orientation
import org.jetbrains.jewel.ui.component.Divider

@View(title = "Markdown", position = 2, icon = "icons/markdown.svg")
@Composable
fun MarkdownDemo() {
Row(Modifier.trackActivation().fillMaxSize().background(JewelTheme.globalColors.panelBackground)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.samples.standalone.IntUiThemes
import org.jetbrains.jewel.samples.standalone.StandaloneSampleIcons
import org.jetbrains.jewel.samples.standalone.viewmodel.MainViewModel
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.component.CheckboxRow
import org.jetbrains.jewel.ui.component.Icon
import org.jetbrains.jewel.ui.component.RadioButtonChip
Expand All @@ -29,7 +28,6 @@ import org.jetbrains.jewel.ui.painter.hints.Selected

@OptIn(ExperimentalLayoutApi::class)
@Composable
@View(title = "Welcome", position = 0, icon = "icons/meetNewUi.svg")
fun WelcomeView() {
Column(
modifier =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.foundation.Stroke
import org.jetbrains.jewel.foundation.modifier.border
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.component.GroupHeader
import org.jetbrains.jewel.ui.component.OutlinedButton
import org.jetbrains.jewel.ui.component.RadioButtonRow
import org.jetbrains.jewel.ui.component.Text
import org.jetbrains.jewel.ui.theme.colorPalette

@Composable
@View("Borders", position = 13, icon = "icons/components/borders.svg")
internal fun Borders() {
GroupHeader("Group header")
Text("This is a group header example")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.component.ActionButton
import org.jetbrains.jewel.ui.component.DefaultButton
import org.jetbrains.jewel.ui.component.IconActionButton
Expand All @@ -32,7 +31,6 @@ import org.jetbrains.jewel.ui.painter.hints.Selected
import org.jetbrains.jewel.ui.painter.hints.Stroke

@Composable
@View(title = "Buttons", position = 0, icon = "icons/components/button.svg")
fun Buttons() {
Column(
verticalArrangement = Arrangement.spacedBy(16.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.state.ToggleableState
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.Outline
import org.jetbrains.jewel.ui.component.TriStateCheckboxRow

@Composable
@View(title = "Checkboxes", position = 1, icon = "icons/components/checkBox.svg")
fun Checkboxes() {
Row(
horizontalArrangement = Arrangement.spacedBy(10.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import org.jetbrains.jewel.foundation.lazy.rememberSelectableLazyListState
import org.jetbrains.jewel.foundation.lazy.tree.buildTree
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.foundation.util.JewelLogger
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.component.Chip
import org.jetbrains.jewel.ui.component.CircularProgressIndicator
import org.jetbrains.jewel.ui.component.GroupHeader
Expand All @@ -47,8 +46,7 @@ import org.jetbrains.jewel.ui.theme.colorPalette
import kotlin.random.Random

@Composable
@View(title = "Chips and trees", position = 11, icon = "icons/components/tree.svg")
fun ChipsAndTree() {
fun ChipsAndTrees() {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(16.dp)) {
Column(Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(8.dp)) {
GroupHeader(text = "Chips", modifier = Modifier.fillMaxWidth())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.Outline
import org.jetbrains.jewel.ui.component.Dropdown
import org.jetbrains.jewel.ui.component.Text
Expand All @@ -19,7 +18,6 @@ import org.jetbrains.jewel.ui.icons.AllIconsKeys
import kotlin.random.Random

@Composable
@View(title = "Dropdowns", position = 3, icon = "icons/components/comboBox.svg")
fun Dropdowns() {
Row(
horizontalArrangement = Arrangement.spacedBy(10.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.samples.standalone.StandaloneSampleIcons
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.component.Icon
import org.jetbrains.jewel.ui.component.PlatformIcon
import org.jetbrains.jewel.ui.component.Text
Expand All @@ -29,7 +28,6 @@ import org.jetbrains.jewel.ui.painter.hints.Stroke
import org.jetbrains.jewel.ui.theme.colorPalette

@Composable
@View(title = "Icons", position = 6, icon = "icons/components/toolbar.svg")
internal fun Icons() {
Row(
modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.intui.standalone.styling.dark
import org.jetbrains.jewel.intui.standalone.styling.light
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.component.DropdownLink
import org.jetbrains.jewel.ui.component.ExternalLink
import org.jetbrains.jewel.ui.component.Link
Expand All @@ -22,7 +21,6 @@ import org.jetbrains.jewel.ui.component.styling.LinkStyle
import org.jetbrains.jewel.ui.component.styling.LinkUnderlineBehavior

@Composable
@View(title = "Links", position = 4, icon = "icons/components/links.svg")
fun Links() {
val isDark = JewelTheme.isDark
val alwaysUnderlinedStyle =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.delay
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.component.CircularProgressIndicator
import org.jetbrains.jewel.ui.component.CircularProgressIndicatorBig
import org.jetbrains.jewel.ui.component.HorizontalProgressBar
import org.jetbrains.jewel.ui.component.IndeterminateHorizontalProgressBar
import org.jetbrains.jewel.ui.component.Text

@Composable
@View(title = "ProgressBar", position = 5, icon = "icons/components/progressbar.svg")
fun ProgressBar() {
val transition = rememberInfiniteTransition()
val currentOffset by transition.animateFloat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.Outline
import org.jetbrains.jewel.ui.component.RadioButtonRow

@Composable
@View(title = "Radio Buttons", position = 2, icon = "icons/components/radioButton.svg")
fun RadioButtons() {
Row(
horizontalArrangement = Arrangement.spacedBy(10.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import org.jetbrains.jewel.intui.standalone.styling.macOsDark
import org.jetbrains.jewel.intui.standalone.styling.macOsLight
import org.jetbrains.jewel.intui.standalone.styling.winOsDark
import org.jetbrains.jewel.intui.standalone.styling.winOsLight
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.Orientation
import org.jetbrains.jewel.ui.component.CheckboxRow
import org.jetbrains.jewel.ui.component.Divider
Expand All @@ -44,7 +43,6 @@ import org.jetbrains.skiko.hostOs
import java.util.Locale

@Composable
@View(title = "Scrollbars", position = 14, icon = "icons/components/scrollbar.svg")
fun Scrollbars() {
Column {
val isDark = JewelTheme.isDark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,14 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.component.SegmentedControl
import org.jetbrains.jewel.ui.component.SegmentedControlButtonData
import org.jetbrains.jewel.ui.component.Text

@Composable
@View(title = "Segmented Controls", position = 14, icon = "icons/components/segmentedControl.svg")
fun SegmentedControls() {
SegmentedControlShowcase()
}

@Composable
private fun SegmentedControlShowcase() {
var selectedButtonIndex by remember { mutableStateOf(0) }

val buttonIds = listOf(0, 1, 2, 3)

val buttons =
remember(selectedButtonIndex) {
buttonIds.map { index ->
Expand All @@ -37,7 +28,6 @@ private fun SegmentedControlShowcase() {
)
}
}

Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
SegmentedControl(
buttons = buttons,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.component.Slider

@Composable
@View(title = "Sliders", position = 12, icon = "icons/components/slider.svg")
fun Sliders() {
var value1 by remember { mutableStateOf(.45f) }
Slider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import org.jetbrains.jewel.foundation.theme.JewelTheme
import org.jetbrains.jewel.samples.standalone.StandaloneSampleIcons
import org.jetbrains.jewel.samples.standalone.viewmodel.View
import org.jetbrains.jewel.ui.component.Icon
import org.jetbrains.jewel.ui.component.IconButton
import org.jetbrains.jewel.ui.component.SimpleTabContent
Expand All @@ -39,7 +38,6 @@ import org.jetbrains.jewel.ui.util.thenIf
import kotlin.math.max

@Composable
@View(title = "Tabs", position = 7, icon = "icons/components/tabs.svg")
fun Tabs() {
Column {
Text("Default tabs", Modifier.fillMaxWidth())
Expand Down
Loading

0 comments on commit 82de21f

Please sign in to comment.