Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search feature #59

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.narcissus.marketplace.di

import com.narcissus.marketplace.data.di.dataModule
import com.narcissus.marketplace.domain.usecase.AddToCart
import com.narcissus.marketplace.domain.usecase.ClearSearchHistory
import com.narcissus.marketplace.domain.usecase.GetAuthStateFlow
import com.narcissus.marketplace.domain.usecase.GetCart
import com.narcissus.marketplace.domain.usecase.GetCartCost
Expand All @@ -14,7 +15,7 @@ import com.narcissus.marketplace.domain.usecase.GetPeopleAreBuyingProducts
import com.narcissus.marketplace.domain.usecase.GetProductDetails
import com.narcissus.marketplace.domain.usecase.GetRandomProducts
import com.narcissus.marketplace.domain.usecase.GetRecentlyVisitedProducts
import com.narcissus.marketplace.domain.usecase.GetSelectedCartItems
import com.narcissus.marketplace.domain.usecase.GetSearchHistory
import com.narcissus.marketplace.domain.usecase.GetSimilarProducts
import com.narcissus.marketplace.domain.usecase.GetTopRatedProducts
import com.narcissus.marketplace.domain.usecase.GetTopSalesProducts
Expand All @@ -30,6 +31,7 @@ import com.narcissus.marketplace.domain.usecase.SignInWithGoogle
import com.narcissus.marketplace.domain.usecase.SignOut
import com.narcissus.marketplace.domain.usecase.SignUpWithEmail
import com.narcissus.marketplace.domain.usecase.ValidateCard
import com.narcissus.marketplace.domain.usecase.WriteQueryToSearchHistory
import org.koin.core.context.loadKoinModules
import org.koin.dsl.module

Expand All @@ -42,13 +44,15 @@ val domainModule = module {
factory { GetRecentlyVisitedProducts(get()) }
factory { GetProductDetails(get(), get()) }
factory { MakeAnOrder(get(), get()) }
factory { WriteQueryToSearchHistory(get()) }
factory { GetSearchHistory(get()) }
factory { ClearSearchHistory(get()) }
factory { GetDepartments(get()) }
factory { GetOrderList(get()) }
factory { GetCart(get()) }
factory { GetCartItemsAmount(get()) }
factory { GetCartCost(get()) }
factory { GetCartCostFlow(get()) }
factory { GetSelectedCartItems(get()) }
factory { SetCartItemAmount(get()) }
factory { SetCartItemSelected(get()) }
factory { SelectAllCartItems(get()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.narcissus.marketplace.ui.catalog.di.catalogModule
import com.narcissus.marketplace.ui.checkout.di.checkoutModule
import com.narcissus.marketplace.ui.home.di.homeModule
import com.narcissus.marketplace.ui.product_details.di.productDetailsModule
import com.narcissus.marketplace.ui.search.di.searchViewModelsModule
import com.narcissus.marketplace.ui.sign_in.di.signInModule
import com.narcissus.marketplace.ui.sign_up.di.signUpModule
import com.narcissus.marketplace.ui.user.di.userModule
Expand All @@ -33,7 +34,8 @@ class MarketplaceApp : Application() {
userModule,
productDetailsModule,
signInModule,
signUpModule
signUpModule,
searchViewModelsModule
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.google.android.material.transition.MaterialFadeThrough
import com.hannesdorfmann.adapterdelegates4.AsyncListDifferDelegationAdapter
import com.narcissus.marketplace.R
import com.narcissus.marketplace.core.navigation.destination.ProductDetailsDestination
import com.narcissus.marketplace.core.navigation.destination.SearchHistoryDestination
import com.narcissus.marketplace.core.navigation.navigator
import com.narcissus.marketplace.databinding.FragmentHomeBinding
import com.narcissus.marketplace.ui.home.recycler.HomeScreenItem
Expand Down Expand Up @@ -71,6 +72,7 @@ class HomeFragment : Fragment(R.layout.fragment_home) {
}

private fun navigateToSearch() {
navigator.navigate(SearchHistoryDestination)
}

private fun navigateToSpecialOffer(link: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import coil.load
import coil.transform.CircleCropTransformation
import com.google.android.material.card.MaterialCardView
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
import com.narcissus.marketplace.databinding.ListItemDetailsDividerBinding
import com.narcissus.marketplace.core.databinding.ListItemDividerBinding
import com.narcissus.marketplace.databinding.ListItemDetailsMainInfoBinding
import com.narcissus.marketplace.databinding.ListItemDetailsMainInfoPlaceholderBinding
import com.narcissus.marketplace.databinding.ListItemDetailsPriceBinding
Expand Down Expand Up @@ -45,7 +45,7 @@ typealias AboutMultipleLineBinding = ListItemDetailsProductAboutMultipleLinesBin
typealias LoadingProductDetailsBinding = ListItemDetailsProductPlaceholderBinding
typealias ReviewsPreviewBinding = ListItemDetailsReviewPreviewBinding
typealias SimilarProductsListBinding = ListItemRecyclerBinding
typealias DividerBinding = ListItemDetailsDividerBinding
typealias DividerBinding = ListItemDividerBinding

sealed class ProductDetailsItem {
data class Price(val price: Int) : ProductDetailsItem() {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/email_password_text_inputs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
android:paddingTop="0dp"
android:paddingEnd="0dp"
android:paddingBottom="2dp"
android:textAppearance="@style/S1_subtitle" />
android:textAppearance="@style/S1_subtitle_primary" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tiPassword"
style="@style/textBlack"
style="@style/textPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
Expand All @@ -53,7 +53,7 @@
android:paddingTop="0dp"
android:paddingEnd="0dp"
android:paddingBottom="2dp"
android:textAppearance="@style/S1_subtitle" />
android:textAppearance="@style/S1_subtitle_primary" />
</com.google.android.material.textfield.TextInputLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_sign_in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

<TextView
android:id="@+id/tvSignInOr"
style="@style/B2_body_grey"
style="@style/B2_body_secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_sign_up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
android:paddingTop="0dp"
android:paddingEnd="0dp"
android:paddingBottom="2dp"
android:textAppearance="@style/S1_subtitle" />
android:textAppearance="@style/S1_subtitle_primary" />
</com.google.android.material.textfield.TextInputLayout>

<include
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<TextView
android:id="@+id/tvDetailsSales"
style="@style/B2_body_grey"
style="@style/B2_body_secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_default"
Expand All @@ -35,7 +35,7 @@

<TextView
android:id="@+id/tvDetailsStock"
style="@style/B2_body_grey"
style="@style/B2_body_secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<TextView
android:id="@+id/tvDetailsAboutTitleMultipleLine"
style="@style/B2_body_grey"
style="@style/B2_body_secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -20,7 +20,7 @@

<TextView
android:id="@+id/tvDetailsAboutValueMultipleLine"
style="@style/B2_body_black"
style="@style/B2_body_primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:id="@+id/tvDetailsAboutTitleSingleLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/B2_body_grey"
style="@style/B2_body_secondary"
app:layout_constraintBottom_toBottomOf="@id/tvDetailsAboutValueSingleLine"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/tvDetailsAboutValueSingleLine"
Expand All @@ -33,7 +33,7 @@
android:id="@+id/tvDetailsAboutValueSingleLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/B2_body_black"
style="@style/B2_body_primary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Laptop"/>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/list_item_details_review.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<TextView
android:id="@+id/tvReviewPreviewAuthor"
style="@style/S2_subtitle_grey"
style="@style/S2_subtitle_secondary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_small"
Expand All @@ -41,7 +41,7 @@

<TextView
android:id="@+id/tvReviewPreviewDescription"
style="@style/B2_body_black"
style="@style/B2_body_primary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/list_item_details_review_preview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<TextView
android:id="@+id/tvReviewPreviewAuthor"
style="@style/S2_subtitle_grey"
style="@style/S2_subtitle_secondary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_small"
Expand All @@ -44,7 +44,7 @@

<TextView
android:id="@+id/tvReviewPreviewDescription"
style="@style/B2_body_black"
style="@style/B2_body_primary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/list_item_product_of_the_day.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvProductTitle"
style="@style/B2_body_black"
style="@style/B2_body_primary"
android:layout_width="0dp"
android:layout_marginStart="@dimen/margin_default"
android:layout_height="wrap_content"
Expand All @@ -62,7 +62,7 @@

<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvOldPrice"
style="@style/S2_subtitle_grey"
style="@style/S2_subtitle_secondary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/list_item_product_preview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<TextView
android:id="@+id/productNameTextView"
style="@style/B2_body_black"
style="@style/B2_body_primary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/margin_small"
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/custom_styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,4 @@
<style name="CustomBottomSheetStyle" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@drawable/bottom_sheet_dialog_background</item>
</style>


</resources>
6 changes: 6 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
viewBinding true
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -30,6 +34,8 @@ android {
}

dependencies {
implementation project(path: ':domain')

implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.1'

def coroutines_version = "1.6.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.narcissus.marketplace.core.navigation.destination

import com.narcissus.marketplace.domain.model.search.SortBy

class SearchDestination(
query: String,
department: String? = null,
sortBy: SortBy = SortBy.DO_NOT_SORT,
) : NavDestination {
override val url = buildString {
append("marketplace-app://search?query=$query")
append(";sort_by=${sortBy.code}")
if (department != null) append(";department=$department")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.narcissus.marketplace.core.navigation.destination

object SearchHistoryDestination : NavDestination {
override val url = "marketplace-app://search-history"
}
10 changes: 10 additions & 0 deletions core/src/main/res/layout/list_item_divider.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#DADADA" />
</FrameLayout>
20 changes: 11 additions & 9 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="appTitle">NCS SHOP</string>
<string name="order">Order</string>
<string name="descriptionAppLogo">NCS Shop Logo</string>
<string name="price_placeholder">$%1$d</string>
<string name="amount_placeholder">%1$dx</string>
<string name="order_number_placeholder">#%1$s</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="appTitle">NCS SHOP</string>
<string name="descriptionAppLogo">NCS Shop Logo</string>
<string name="order">Order</string>
<string name="price_placeholder">$%1$d</string>
<string name="amount_placeholder">%1$dx</string>
<string name="order_number_placeholder">#%1$s</string>
<string name="you_searched_for">You searched for</string>
<string name="clear">Clear</string>
</resources>
58 changes: 58 additions & 0 deletions core/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,62 @@
<item name="android:textSize">14sp</item>
<item name="fontFamily">@font/montserrat_regular_ttf</item>
</style>
<style name="textPrimary">
<item name="android:textColor">?attr/colorOnPrimary</item>
</style>

<style name="textSecondary">
<item name="android:textColor">?attr/colorOnSecondary</item>
</style>

<style name="H4_headline" parent="textPrimary">
<item name="android:textSize">34sp</item>
<item name="fontFamily">@font/montserrat_semibold_ttf</item>
</style>

<style name="B2_body_secondary" parent="textSecondary">
<item name="android:textSize">14sp</item>
<item name="fontFamily">@font/montserrat_regular_ttf</item>
</style>

<style name="B2_body_primary" parent="textPrimary">
<item name="android:textSize">14sp</item>
<item name="fontFamily">@font/montserrat_regular_ttf</item>
</style>

<style name="Btn">
<item name="android:textSize">14sp</item>
<item name="fontFamily">@font/montserrat_bold_ttf</item>
</style>

<style name="H6_headline" parent="textPrimary">
<item name="android:textSize">21sp</item>
<item name="fontFamily">@font/montserrat_semibold_ttf</item>
</style>
<style name="H6_headline_regular" parent="H6_headline">
<item name="android:textSize">21sp</item>
<item name="fontFamily">@font/montserrat_regular_ttf</item>
</style>
<style name="S2_subtitle_secondary" parent="textSecondary">
<item name="android:textSize">15sp</item>
<item name="fontFamily">@font/montserrat_medium_ttf</item>
</style>
<style name="S1_subtitle_primary" parent="textPrimary">
<item name="android:textSize">17sp</item>
<item name="fontFamily">@font/montserrat_regular_ttf</item>
</style>


<style name="B1_body" parent="textPrimary">
<item name="android:textSize">16sp</item>
<item name="fontFamily">@font/montserrat_semibold_ttf</item>
</style>
<style name="Caption">
<item name="android:textSize">12sp</item>
<item name="fontFamily">@font/montserrat_regular_ttf</item>
</style>
<style name="H5_headline" parent="textPrimary">
<item name="android:textSize">24sp</item>
<item name="fontFamily">@font/montserrat_medium_ttf</item>
</style>
</resources>
Loading