-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
123 additions
and
325 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
12 changes: 0 additions & 12 deletions
12
app/src/main/java/com/maruchin/domaindrivenandroid/data/category/CategoriesRepository.kt
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
app/src/main/java/com/maruchin/domaindrivenandroid/data/category/Category.kt
This file was deleted.
Oops, something went wrong.
41 changes: 21 additions & 20 deletions
41
app/src/main/java/com/maruchin/domaindrivenandroid/data/coupon/Coupon.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,43 +1,44 @@ | ||
package com.maruchin.domaindrivenandroid.data.coupon | ||
|
||
import java.net.URL | ||
import java.util.Currency | ||
|
||
data class Coupon( | ||
val id: String, | ||
val title: String, | ||
val subtitle: String, | ||
val value: Money, | ||
val name: String, | ||
val price: Money, | ||
val image: URL, | ||
) | ||
|
||
val sampleForHomeCoupons = listOf( | ||
val sampleCoupons = listOf( | ||
Coupon( | ||
id = "1", | ||
title = "Coupon for Allegro", | ||
subtitle = "Free delivery with Allegro Smart", | ||
value = Money(value = 50.0, currency = Currency.getInstance("PLN")) | ||
name = "Cheesburger with fries", | ||
price = Money(value = 17.99, currency = Currency.getInstance("USD")), | ||
image = URL("https://raw.githubusercontent.com/Maruchin1/domain-driven-android/master/images/cheesburger_with_fries_coupon.jpeg"), | ||
), | ||
Coupon( | ||
id = "2", | ||
title = "Coupon for H&M", | ||
subtitle = "Fashion and quality clothes at a good price", | ||
value = Money(value = 100.0, currency = Currency.getInstance("PLN")) | ||
name = "Chicekburger with fries", | ||
price = Money(value = 15.99, currency = Currency.getInstance("USD")), | ||
image = URL("https://raw.githubusercontent.com/Maruchin1/domain-driven-android/master/images/chickenburger_with_fries_coupon.jpeg"), | ||
), | ||
Coupon( | ||
id = "3", | ||
title = "Coupon for Ikea", | ||
subtitle = "Furniture and interior design for your home", | ||
value = Money(value = 100.0, currency = Currency.getInstance("PLN")) | ||
name = "Chicken nuggets with fries", | ||
price = Money(value = 20.99, currency = Currency.getInstance("USD")), | ||
image = URL("https://raw.githubusercontent.com/Maruchin1/domain-driven-android/master/images/chicken_nuggets_with_fries_coupon.jpeg"), | ||
), | ||
Coupon( | ||
id = "4", | ||
title = "Designer brands at TK Maxx", | ||
subtitle = "Hunt for stylish pearls and unique products", | ||
value = Money(value = 100.0, currency = Currency.getInstance("PLN")) | ||
name = "2 x Milkshake", | ||
price = Money(value = 8.99, currency = Currency.getInstance("USD")), | ||
image = URL("https://raw.githubusercontent.com/Maruchin1/domain-driven-android/master/images/two_milkshakes_coupon.jpeg"), | ||
), | ||
Coupon( | ||
id = "5", | ||
title = "Coupon for Amazon.pl", | ||
subtitle = "Thousands of products in one place", | ||
value = Money(value = 94.0, currency = Currency.getInstance("PLN")) | ||
) | ||
name = "2 x Soda drink", | ||
price = Money(value = 6.99, currency = Currency.getInstance("USD")), | ||
image = URL("https://raw.githubusercontent.com/Maruchin1/domain-driven-android/master/images/two_soda_drinks_coupon.jpeg"), | ||
), | ||
) |
8 changes: 2 additions & 6 deletions
8
app/src/main/java/com/maruchin/domaindrivenandroid/data/coupon/CouponsRepository.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,16 +1,12 @@ | ||
package com.maruchin.domaindrivenandroid.data.coupon | ||
|
||
import com.maruchin.domaindrivenandroid.data.category.Category | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class CouponsRepository @Inject constructor() { | ||
|
||
suspend fun getCouponsFromCategory(category: Category): List<Coupon> { | ||
return when (category.id) { | ||
"for_home" -> sampleForHomeCoupons | ||
else -> emptyList() | ||
} | ||
suspend fun getAllCoupons(): List<Coupon> { | ||
return sampleCoupons | ||
} | ||
} |
10 changes: 9 additions & 1 deletion
10
app/src/main/java/com/maruchin/domaindrivenandroid/data/coupon/Money.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,13 @@ | ||
package com.maruchin.domaindrivenandroid.data.coupon | ||
|
||
import java.text.DecimalFormat | ||
import java.util.Currency | ||
|
||
data class Money(val value: Double, val currency: Currency) | ||
data class Money(val value: Double, val currency: Currency) { | ||
|
||
override fun toString(): String { | ||
val formatter = DecimalFormat.getCurrencyInstance() | ||
formatter.currency = currency | ||
return formatter.format(value) | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
app/src/main/java/com/maruchin/domaindrivenandroid/ui/common/CategoryExtensions.kt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
app/src/main/java/com/maruchin/domaindrivenandroid/ui/common/MoneyExtensions.kt
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.