Skip to content

Commit

Permalink
Refactor others previews in sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluchu committed Oct 12, 2023
1 parent 247007a commit e332053
Show file tree
Hide file tree
Showing 18 changed files with 800 additions and 606 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.ui.unit.dp
import com.jeluchu.composer.core.ui.theme.milky
import com.jeluchu.composer.core.ui.theme.secondary
import com.jeluchu.jchucomponents.ktx.compose.toImageVector
import com.jeluchu.jchucomponents.ktx.compose.toPainter
import com.jeluchu.jchucomponents.ui.R
import com.jeluchu.jchucomponents.ui.composables.column.ScrollableColumn
import com.jeluchu.jchucomponents.ui.composables.toolbars.CenterToolbarColors
Expand Down Expand Up @@ -107,7 +108,7 @@ fun ScaffoldListStructure(
actions = actionsIcons,
navigationIcon = {
IconLink(
imageVector = navIcon.toImageVector(),
painter = navIcon.toPainter(),
contentDescription = "ToolbarBack"
) { onNavIconClick() }
},
Expand All @@ -118,6 +119,6 @@ fun ScaffoldListStructure(
) { contentPadding ->
ListColumn(
modifier = Modifier.padding(contentPadding),
verticalArrangement = Arrangement.spacedBy(10.dp)
verticalArrangement = Arrangement.spacedBy(15.dp)
) { content() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import androidx.navigation.compose.navigation
import com.jeluchu.composer.core.utils.DestinationsIds
import com.jeluchu.composer.core.utils.NavigationIds
import com.jeluchu.composer.features.bottons.view.ButtonsView
import com.jeluchu.composer.features.bottons.view.FloatingButtonView
import com.jeluchu.composer.features.dashboard.view.MainView
import com.jeluchu.composer.features.dividers.view.DividersView
import com.jeluchu.composer.features.lists.view.LazyGridsView
import com.jeluchu.composer.features.lists.view.LazyStaticGridView
import com.jeluchu.composer.features.progress.view.IconProgressbarView
import com.jeluchu.composer.features.progress.view.LinearProgressbarView
import com.jeluchu.composer.features.progress.view.ProgressView
import com.jeluchu.composer.features.toolbars.view.ToolbarsView
import com.jeluchu.jchucomponents.ui.composables.button.FloatingButtonPreview
import com.jeluchu.jchucomponents.ui.composables.progress.IconProgressbarPreview
import com.jeluchu.jchucomponents.ui.composables.progress.LinearProgressbarPreview
import com.jeluchu.jchucomponents.ui.composables.toolbars.CenterToolbarActionsPreview
Expand Down Expand Up @@ -46,7 +49,11 @@ fun NavGraphBuilder.buttonsNav(nav: Destinations) {
}

composable(Feature.FLOATING_BUTTONS.nav) {
FloatingButtonPreview()
FloatingButtonView { id ->
when (id) {
DestinationsIds.back -> nav.goBack(it)
}
}
}
}
}
Expand All @@ -67,11 +74,19 @@ fun NavGraphBuilder.progressNav(nav: Destinations) {
}

composable(Feature.LINEAR_PROGRESS.nav) {
LinearProgressbarPreview()
LinearProgressbarView { id ->
when (id) {
DestinationsIds.back -> nav.goBack(it)
}
}
}

composable(Feature.ICON_PROGRESS.nav) {
IconProgressbarPreview()
IconProgressbarView { id ->
when (id) {
DestinationsIds.back -> nav.goBack(it)
}
}
}
}
}
Expand All @@ -91,7 +106,11 @@ fun NavGraphBuilder.lazyGridsNav(nav: Destinations) {
}

composable(Feature.LAZY_STATIC_GRIDS.nav) {
LazyStaticGridPreview()
LazyStaticGridView { id ->
when (id) {
DestinationsIds.back -> nav.goBack(it)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import androidx.compose.ui.graphics.Color

@Stable val primary = Color(0xFFA9D2B5)
@Stable val secondary = Color(0xFF79BA98)
@Stable val darkGreen = Color(0xFF4D7C63)
@Stable val darkness = Color(0xFF333333)
@Stable val milky = Color(0xFFF9F8DD)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.jeluchu.composer.features.bottons.view

import androidx.compose.runtime.Composable
import com.jeluchu.composer.core.ui.composables.ScaffoldStructure
import com.jeluchu.composer.core.ui.theme.milky
import com.jeluchu.composer.core.ui.theme.secondary
import com.jeluchu.composer.core.utils.DestinationsIds
import com.jeluchu.composer.core.utils.Names
import com.jeluchu.jchucomponents.ui.accompanist.systemui.SystemStatusBarColors
import com.jeluchu.jchucomponents.ui.composables.button.FloatingButtonPreview
import com.jeluchu.jchucomponents.ui.composables.toolbars.CenterToolbarColors

@Composable
fun FloatingButtonView(onItemClick: (String) -> Unit) {
SystemStatusBarColors(
systemBarsColor = secondary,
statusBarColor = secondary
)

FloatingButton(onItemClick)
}

@Composable
private fun FloatingButton(
onItemClick: (String) -> Unit
) = ScaffoldStructure(
title = Names.floatingButtons,
colors = CenterToolbarColors(
containerColor = secondary,
contentColor = milky
),
onNavIconClick = { onItemClick(DestinationsIds.back) }
) { FloatingButtonPreview() }
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import androidx.compose.ui.unit.dp
import com.jeluchu.composer.core.commons.models.MenuOptions
import com.jeluchu.composer.core.ui.composables.ScaffoldListStructure
import com.jeluchu.composer.core.ui.composables.SimpleButton
import com.jeluchu.composer.core.ui.theme.darkGreen
import com.jeluchu.composer.core.ui.theme.darkness
import com.jeluchu.composer.core.ui.theme.milky
import com.jeluchu.composer.core.ui.theme.primary
Expand All @@ -40,7 +41,7 @@ fun Main(
onItemClick: (String) -> Unit
) = ScaffoldListStructure(
title = "Jchucomponents",
navIcon = com.jeluchu.jchucomponents.ui.R.drawable.ic_btn_qrcode,
navIcon = com.jeluchu.jchucomponents.ui.R.drawable.ic_deco_jeluchu,
colors = CenterToolbarColors(
containerColor = primary,
contentColor = darkness
Expand All @@ -49,7 +50,7 @@ fun Main(
stickyHeader {
Text(
text = "UI Components",
color = primary,
color = milky.copy(.8f),
modifier = Modifier
.fillMaxWidth()
.background(secondary)
Expand All @@ -63,9 +64,9 @@ fun Main(
modifier = Modifier
.padding(horizontal = 15.dp)
.clip(10.cornerRadius())
.background(secondary),
.background(secondary.copy(.4f)),
label = option.name,
color = milky
color = darkGreen
) { onItemClick(option.id) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.jeluchu.composer.features.lists.view

import androidx.compose.runtime.Composable
import com.jeluchu.composer.core.ui.composables.ScaffoldStructure
import com.jeluchu.composer.core.ui.theme.milky
import com.jeluchu.composer.core.ui.theme.secondary
import com.jeluchu.composer.core.utils.DestinationsIds
import com.jeluchu.composer.core.utils.Names
import com.jeluchu.jchucomponents.ui.accompanist.systemui.SystemStatusBarColors
import com.jeluchu.jchucomponents.ui.composables.progress.IconProgressbarPreview
import com.jeluchu.jchucomponents.ui.composables.progress.LinearProgressbarPreview
import com.jeluchu.jchucomponents.ui.composables.toolbars.CenterToolbarColors
import com.jeluchu.jchucomponents.ui.foundation.lists.LazyStaticGridPreview

@Composable
fun LazyStaticGridView(onItemClick: (String) -> Unit) {
SystemStatusBarColors(
systemBarsColor = secondary,
statusBarColor = secondary
)

LazyStaticGrid(onItemClick)
}

@Composable
private fun LazyStaticGrid(
onItemClick: (String) -> Unit
) = ScaffoldStructure(
title = Names.lazyStaticGrids,
colors = CenterToolbarColors(
containerColor = secondary,
contentColor = milky
),
onNavIconClick = { onItemClick(DestinationsIds.back) }
) { LazyStaticGridPreview() }
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.jeluchu.composer.features.progress.view

import androidx.compose.runtime.Composable
import com.jeluchu.composer.core.ui.composables.ScaffoldStructure
import com.jeluchu.composer.core.ui.theme.milky
import com.jeluchu.composer.core.ui.theme.secondary
import com.jeluchu.composer.core.utils.DestinationsIds
import com.jeluchu.composer.core.utils.Names
import com.jeluchu.jchucomponents.ui.accompanist.systemui.SystemStatusBarColors
import com.jeluchu.jchucomponents.ui.composables.progress.IconProgressbarPreview
import com.jeluchu.jchucomponents.ui.composables.progress.LinearProgressbarPreview
import com.jeluchu.jchucomponents.ui.composables.toolbars.CenterToolbarColors

@Composable
fun IconProgressbarView(onItemClick: (String) -> Unit) {
SystemStatusBarColors(
systemBarsColor = secondary,
statusBarColor = secondary
)

IconProgressbar(onItemClick)
}

@Composable
private fun IconProgressbar(
onItemClick: (String) -> Unit
) = ScaffoldStructure(
title = Names.iconProgress,
colors = CenterToolbarColors(
containerColor = secondary,
contentColor = milky
),
onNavIconClick = { onItemClick(DestinationsIds.back) }
) { IconProgressbarPreview() }
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.jeluchu.composer.features.progress.view

import androidx.compose.runtime.Composable
import com.jeluchu.composer.core.ui.composables.ScaffoldStructure
import com.jeluchu.composer.core.ui.theme.milky
import com.jeluchu.composer.core.ui.theme.secondary
import com.jeluchu.composer.core.utils.DestinationsIds
import com.jeluchu.composer.core.utils.Names
import com.jeluchu.jchucomponents.ui.accompanist.systemui.SystemStatusBarColors
import com.jeluchu.jchucomponents.ui.composables.progress.LinearProgressbarPreview
import com.jeluchu.jchucomponents.ui.composables.toolbars.CenterToolbarColors

@Composable
fun LinearProgressbarView(onItemClick: (String) -> Unit) {
SystemStatusBarColors(
systemBarsColor = secondary,
statusBarColor = secondary
)

LinearProgressbar(onItemClick)
}

@Composable
private fun LinearProgressbar(
onItemClick: (String) -> Unit
) = ScaffoldStructure(
title = Names.linearProgress,
colors = CenterToolbarColors(
containerColor = secondary,
contentColor = milky
),
onNavIconClick = { onItemClick(DestinationsIds.back) }
) { LinearProgressbarPreview() }
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import com.google.accompanist.systemuicontroller.rememberSystemUiController
fun SystemStatusBarColors(
statusBarColor: Color,
systemBarsColor: Color,
isNavigationBarContrastEnforced: Boolean = true,
useDarkIcons: Boolean = !isSystemInDarkTheme()
) = with(rememberSystemUiController()) {
SideEffect {
Expand Down
Loading

0 comments on commit e332053

Please sign in to comment.