-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from DeKaN/product-list-compose
Migrate product list to Jetpack Compose
- Loading branch information
Showing
27 changed files
with
530 additions
and
218 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
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
5 changes: 2 additions & 3 deletions
5
app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/GetOrderListUseCase.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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
package com.hieuwu.groceriesstore.domain.usecases | ||
|
||
import com.hieuwu.groceriesstore.domain.models.OrderModel | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface GetOrderListUseCase : UseCase<GetOrderListUseCase.Input, GetOrderListUseCase.Output> { | ||
interface GetOrderListUseCase : SuspendUseCase<GetOrderListUseCase.Input, GetOrderListUseCase.Output> { | ||
class Input | ||
sealed class Output { | ||
class Success(val data: List<OrderModel>) : Output() | ||
object Failure : Output() | ||
} | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/RefreshAppDataUseCase.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package com.hieuwu.groceriesstore.domain.usecases | ||
|
||
interface RefreshAppDataUseCase : UseCase<Unit, Unit> | ||
interface RefreshAppDataUseCase : SuspendUseCase<Unit, Unit> |
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
4 changes: 2 additions & 2 deletions
4
app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/SignInUseCase.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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package com.hieuwu.groceriesstore.domain.usecases | ||
|
||
interface SignInUseCase : UseCase<SignInUseCase.Input, SignInUseCase.Output> { | ||
interface SignInUseCase : SuspendUseCase<SignInUseCase.Input, SignInUseCase.Output> { | ||
data class Input(val email: String, val password: String) | ||
open class Output(val result: Boolean) { | ||
sealed class Error : Output(false) | ||
object AccountNotExistedError : Output(false) | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/SignOutUseCase.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.hieuwu.groceriesstore.domain.usecases | ||
|
||
interface SignOutUseCase : UseCase<SignOutUseCase.Input, SignOutUseCase.Output> { | ||
interface SignOutUseCase : SuspendUseCase<SignOutUseCase.Input, SignOutUseCase.Output> { | ||
class Input | ||
class Output | ||
} | ||
} |
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
8 changes: 6 additions & 2 deletions
8
app/src/main/java/com/hieuwu/groceriesstore/domain/usecases/UseCase.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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
package com.hieuwu.groceriesstore.domain.usecases | ||
|
||
interface UseCase<Input, Output> { | ||
interface SuspendUseCase<Input, Output> { | ||
suspend fun execute(input: Input): Output | ||
} | ||
} | ||
|
||
interface UseCase<Input, Output> { | ||
fun execute(input: Input): Output | ||
} |
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
69 changes: 69 additions & 0 deletions
69
app/src/main/java/com/hieuwu/groceriesstore/presentation/core/widgets/PrimaryIconButtons.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,69 @@ | ||
package com.hieuwu.groceriesstore.presentation.core.widgets | ||
|
||
import androidx.compose.foundation.layout.defaultMinSize | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Search | ||
import androidx.compose.material3.FilledIconButton | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButtonDefaults | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.Shape | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import com.hieuwu.groceriesstore.R | ||
|
||
@Composable | ||
fun PrimaryIconButton( | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
enabled: Boolean = true, | ||
shape: Shape = IconButtonDefaults.filledShape, | ||
content: @Composable () -> Unit | ||
) { | ||
FilledIconButton( | ||
onClick = onClick, | ||
modifier = modifier.defaultMinSize(minWidth = 48.dp, minHeight = 48.dp), | ||
enabled = enabled, | ||
shape = shape, | ||
colors = IconButtonDefaults.filledIconButtonColors( | ||
containerColor = colorResource(id = R.color.colorPrimary), | ||
disabledContainerColor = colorResource(id = R.color.light_gray), | ||
contentColor = Color.White, | ||
), | ||
content = content | ||
) | ||
} | ||
|
||
@Composable | ||
fun PrimarySquareIconButton( | ||
onClick: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
enabled: Boolean = true, | ||
content: @Composable () -> Unit | ||
) = PrimaryIconButton( | ||
onClick = onClick, | ||
modifier = modifier, | ||
enabled = enabled, | ||
shape = RoundedCornerShape(8.dp), | ||
content = content | ||
) | ||
|
||
@Preview | ||
@Composable | ||
private fun PrimaryIconButtonPreview() { | ||
PrimaryIconButton(onClick = {}) { | ||
Icon(imageVector = Icons.Default.Search, contentDescription = "") | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun PrimarySquareIconButtonPreview() { | ||
PrimarySquareIconButton(onClick = {}) { | ||
Icon(imageVector = Icons.Default.Search, contentDescription = "") | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/hieuwu/groceriesstore/presentation/core/widgets/WebImage.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,28 @@ | ||
package com.hieuwu.groceriesstore.presentation.core.widgets | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.layout.ContentScale | ||
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi | ||
import com.bumptech.glide.integration.compose.GlideImage | ||
import com.bumptech.glide.integration.compose.placeholder | ||
import com.hieuwu.groceriesstore.R | ||
|
||
@OptIn(ExperimentalGlideComposeApi::class) | ||
@Composable | ||
fun WebImage( | ||
model: Any?, | ||
contentDescription: String?, | ||
modifier: Modifier = Modifier, | ||
alignment: Alignment = Alignment.Center, | ||
contentScale: ContentScale = ContentScale.Fit, | ||
) = GlideImage( | ||
model = model, | ||
contentDescription = contentDescription, | ||
modifier = modifier, | ||
alignment = alignment, | ||
contentScale = contentScale, | ||
loading = placeholder(R.drawable.loading_animation), | ||
failure = placeholder(R.drawable.ic_broken_image) | ||
) |
Oops, something went wrong.