Skip to content

Commit

Permalink
Include rate button and initial search
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluchu committed Oct 23, 2023
1 parent f5f0fb6 commit 3eaecd5
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.jeluchu.wastickersonline.core.ui.navigation

import androidx.navigation.NavGraphBuilder
import androidx.navigation.navArgument
import com.jeluchu.jchucomponents.ktx.context.rateUs
import com.jeluchu.wastickersonline.R
import com.jeluchu.wastickersonline.core.utils.Links
import com.jeluchu.wastickersonline.features.details.view.StickersDetailsView
import com.jeluchu.wastickersonline.features.sticker.view.DashboardView
Expand All @@ -10,7 +12,8 @@ fun NavGraphBuilder.mainNav(nav: Destinations) {
composable(Screen.Dashboard) {
DashboardView(
onStickerClick = { sticker -> nav.goToDetails(sticker) },
onLogoClick = { uri -> uri.openUri(Links.website) }
onLogoClick = { uri -> uri.openUri(Links.website) },
onRateClick = { ctx -> ctx.rateUs(ctx.packageName, R.color.primary) }
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.jeluchu.wastickersonline.features.sticker.view

import android.content.Context
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
Expand All @@ -19,21 +19,27 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.platform.UriHandler
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.jeluchu.jchucomponents.core.states.ListStates
import com.jeluchu.jchucomponents.ktx.compose.toPainter
import com.jeluchu.jchucomponents.ktx.compose.toImageVector
import com.jeluchu.jchucomponents.ui.accompanist.systemui.SystemStatusBarColors
import com.jeluchu.jchucomponents.ui.animations.lists.Animations
import com.jeluchu.jchucomponents.ui.animations.lists.animateItem
import com.jeluchu.jchucomponents.ui.composables.button.FloatingButton
import com.jeluchu.jchucomponents.ui.composables.button.FloatingButtonSettings
import com.jeluchu.jchucomponents.ui.composables.column.ScrollableColumn
import com.jeluchu.jchucomponents.ui.composables.images.NetworkImage
import com.jeluchu.jchucomponents.ui.extensions.modifier.cornerRadius
import com.jeluchu.jchucomponents.ui.extensions.modifier.noRippleClickable
import com.jeluchu.jchucomponents.ui.foundation.icon.IconLink
import com.jeluchu.jchucomponents.ui.foundation.lists.ListRow
import com.jeluchu.wastickersonline.R
import com.jeluchu.wastickersonline.core.ui.theme.darkGreen
import com.jeluchu.wastickersonline.core.ui.theme.darkness
import com.jeluchu.wastickersonline.core.ui.theme.milky
Expand All @@ -44,10 +50,12 @@ import com.jeluchu.wastickersonline.features.sticker.viewmodel.StickersViewModel

@Composable
fun DashboardView(
ctx: Context = LocalContext.current,
uri: UriHandler = LocalUriHandler.current,
vm: StickersViewModel = hiltViewModel(),
onStickerClick: (StickerPack) -> Unit,
onLogoClick: (UriHandler) -> Unit
onLogoClick: (UriHandler) -> Unit,
onRateClick: (Context) -> Unit
) {
SystemStatusBarColors(
statusBarColor = primary,
Expand All @@ -59,7 +67,8 @@ fun DashboardView(
DashboardView(
state = state,
onStickerClick = onStickerClick,
onLogoClick = { onLogoClick(uri) }
onLogoClick = { onLogoClick(uri) },
onRateClick = { onRateClick(ctx) }
)
}

Expand All @@ -68,43 +77,65 @@ fun DashboardView(
private fun DashboardView(
state: ListStates<StickerPack>,
onStickerClick: (StickerPack) -> Unit,
onLogoClick: () -> Unit
onLogoClick: () -> Unit,
onRateClick: () -> Unit,
) = Scaffold(
topBar = {
CenterAlignedTopAppBar(
title = { Text(text = "Stickers") },
navigationIcon = {
IconLink(
tint = darkness,
modifier = Modifier.size(30.dp),
painter = com.jeluchu.jchucomponents.ui.R.drawable.ic_deco_jeluchu.toPainter(),
imageVector = R.drawable.ic_deco_sticker.toImageVector(),
contentDescription = "",
onClick = onLogoClick
)
},
actions = {
IconLink(
tint = darkness,
modifier = Modifier.size(30.dp),
imageVector = R.drawable.ic_deco_rate_app.toImageVector(),
contentDescription = "",
onClick = onRateClick
)
},
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = primary,
titleContentColor = darkness
)
)
},
floatingActionButton = {
FloatingButton(
floatButton = FloatingButtonSettings(
icon = R.drawable.ic_deco_search,
tint = milky,
background = darkGreen
),
onClick = { /*isSearchActive = !isSearchActive*/ }
)
},
containerColor = primary
) { paddingValues ->
ScrollableColumn(
modifier = Modifier.padding(paddingValues)
) {
state.data.forEach {
Column(
modifier = Modifier.clickable { onStickerClick(it) }
modifier = Modifier.noRippleClickable { onStickerClick(it) }
) {
Surface(
modifier = Modifier.padding(horizontal = 15.dp),
shape = 10.cornerRadius(),
color = darkGreen,
contentColor = milky
color = darkGreen.copy(.2f),
contentColor = darkness.copy(.7f)
) {
Text(
modifier = Modifier.padding(5.dp),
text = it.name
text = it.name,
fontWeight = FontWeight.Bold
)
}

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_deco_rate_app.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M10.788,3.103c0.495,-1.004 1.926,-1.004 2.421,0l2.358,4.777 5.273,0.766c1.107,0.161 1.549,1.522 0.748,2.303l-3.816,3.72 0.901,5.25c0.19,1.103 -0.968,1.944 -1.959,1.424l-4.716,-2.48 -4.715,2.48c-0.99,0.52 -2.148,-0.32 -1.96,-1.424l0.901,-5.25 -3.815,-3.72c-0.801,-0.78 -0.359,-2.142 0.748,-2.303L8.43,7.88l2.358,-4.777Z"
android:fillColor="#212121"/>
</vector>
4 changes: 4 additions & 0 deletions app/src/main/res/drawable/ic_deco_search.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<vector android:height="24dp" android:viewportHeight="118.78"
android:viewportWidth="118.78" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M115.97,101.6L88.66,74.29c4.64,-7.39 7.33,-16.12 7.33,-25.49c0,-26.51 -21.49,-48 -48,-48S0,22.29 0,48.8c0,26.51 21.49,47.99 48,47.99c10.2,0 19.64,-3.19 27.41,-8.6l26.98,26.99c1.88,1.87 4.33,2.81 6.79,2.81c2.46,0 4.91,-0.93 6.79,-2.81C119.72,111.42 119.72,105.35 115.97,101.6zM48,81.24c-17.92,0 -32.44,-14.52 -32.44,-32.44s14.53,-32.44 32.44,-32.44c17.92,0 32.44,14.53 32.44,32.44S65.91,81.24 48,81.24z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_deco_sticker.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="40"
android:viewportWidth="40" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#000000" android:fillType="evenOdd" android:pathData="m22,29.956c0,-1.363 0,-2.447 0.072,-3.322 0.011,-0.133 0.023,-0.263 0.038,-0.39 -0.627,0.198 -1.292,0.304 -1.981,0.304 -2.527,0 -4.713,-1.428 -5.874,-3.514 -0.269,-0.483 -0.095,-1.092 0.387,-1.36 0.483,-0.269 1.092,-0.095 1.36,0.387 0.836,1.501 2.38,2.486 4.126,2.486 0.902,0 1.744,-0.261 2.465,-0.718 0.235,-0.149 0.457,-0.318 0.663,-0.507 0.539,-0.695 1.227,-1.267 2.019,-1.671 0.699,-0.356 1.463,-0.509 2.359,-0.582 0.875,-0.072 1.959,-0.072 3.322,-0.072h0.035,2.001c0.008,-0.632 0.008,-1.339 0.008,-2.138v-0.195,-0.187c0,-2.302 0,-3.663 -0.307,-4.809 -0.832,-3.106 -3.258,-5.532 -6.364,-6.364 -1.146,-0.307 -2.507,-0.307 -4.809,-0.307l-0.187,0h-1.371c-1.832,0 -3.258,0 -4.408,0.078 -1.167,0.08 -2.122,0.243 -2.999,0.607 -2.205,0.913 -3.957,2.665 -4.871,4.871 -0.363,0.877 -0.527,1.832 -0.607,2.999 -0.078,1.15 -0.078,2.576 -0.078,4.408v1.371l-0,0.187c-0,2.302 -0,3.663 0.307,4.809 0.832,3.106 3.258,5.532 6.364,6.364 1.146,0.307 2.507,0.307 4.809,0.307h0.187,0.195c1.249,0 2.269,0 3.138,-0.029l-0.045,-2 0.045,-0.002zM24.246,17.954c0.816,0 1.477,-0.661 1.477,-1.477 0,-0.816 -0.661,-1.477 -1.477,-1.477s-1.477,0.661 -1.477,1.477c0,0.816 0.661,1.477 1.477,1.477zM15.938,17.954c0.816,0 1.477,-0.661 1.477,-1.477 0,-0.816 -0.661,-1.477 -1.477,-1.477s-1.477,0.661 -1.477,1.477c0,0.816 0.661,1.477 1.477,1.477z"/>
<path android:fillColor="#000000" android:pathData="m24.847,32.625c1.459,-0.391 2.795,-1.069 3.944,-1.972 2.42,-1.722 4.041,-4.495 4.196,-7.653h-2.076c-1.37,0 -2.347,0.002 -3.114,0.065 -0.772,0.063 -1.243,0.183 -1.613,0.371 -0.753,0.384 -1.365,0.995 -1.748,1.748 -0.189,0.37 -0.308,0.841 -0.371,1.613 -0.064,0.784 -0.065,1.786 -0.065,3.203v0.438,2.365c0.297,-0.047 0.577,-0.105 0.847,-0.178z"/>
</vector>

0 comments on commit 3eaecd5

Please sign in to comment.