├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── font
│ │ │ └── markpro.otf
│ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ ├── layout
│ │ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ ├── values-v29
│ │ │ └── themes.xml
│ │ ├── drawable
│ │ │ ├── splash_screen.xml
│ │ │ └── ic_launcher_background.xml
│ │ ├── xml
│ │ │ ├── backup_rules.xml
│ │ │ └── data_extraction_rules.xml
│ │ ├── values
│ │ │ ├── themes.xml
│ │ │ └── styles.xml
│ │ └── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ └── ru
│ │ │ └── tech
│ │ │ └── ecommerce
│ │ │ └── activity
│ │ │ ├── application
│ │ │ └── EcommerceApplication.kt
│ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle.kts
├── feature-main-screen
├── .gitignore
├── consumer-rules.pro
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── ru
│ │ │ └── tech
│ │ │ └── feature_main_screen
│ │ │ ├── data
│ │ │ ├── remote
│ │ │ │ ├── response
│ │ │ │ │ ├── Home.kt
│ │ │ │ │ ├── HomeItem.kt
│ │ │ │ │ ├── HomeStore.kt
│ │ │ │ │ └── BestSeller.kt
│ │ │ │ └── EcommerceApi.kt
│ │ │ └── repository
│ │ │ │ └── EcommerceRepository.kt
│ │ │ ├── utils
│ │ │ └── Resource.kt
│ │ │ ├── extensions
│ │ │ └── Extensions.kt
│ │ │ ├── di
│ │ │ └── AppModule.kt
│ │ │ ├── fragment
│ │ │ ├── ModalBottomSheet.kt
│ │ │ └── HomeFragment.kt
│ │ │ ├── viewModel
│ │ │ └── FeatureMainScreenViewModel.kt
│ │ │ └── adapter
│ │ │ ├── HotSalesAdapter.kt
│ │ │ ├── BestSellersAdapter.kt
│ │ │ └── CategoryAdapter.kt
│ │ └── res
│ │ ├── drawable
│ │ ├── ellipse_white.xml
│ │ ├── rounded_background.xml
│ │ ├── rounded_background_5.xml
│ │ ├── rounded_background_primary_10.xml
│ │ ├── rounded_background_secondary.xml
│ │ ├── rounded_background_secondary_10.xml
│ │ ├── text_container.xml
│ │ ├── ellipse.xml
│ │ ├── arrow_down.xml
│ │ ├── user.xml
│ │ ├── filter.xml
│ │ ├── search.xml
│ │ ├── phone.xml
│ │ ├── location.xml
│ │ ├── like.xml
│ │ ├── heart.xml
│ │ ├── delike.xml
│ │ ├── x.xml
│ │ ├── cart.xml
│ │ ├── computer.xml
│ │ ├── health.xml
│ │ ├── qr.xml
│ │ ├── text.xml
│ │ └── books.xml
│ │ ├── values
│ │ ├── colors.xml
│ │ └── strings.xml
│ │ └── layout
│ │ ├── category_item.xml
│ │ ├── hot_sales_item.xml
│ │ ├── best_seller_item.xml
│ │ ├── modal_bottom_sheet_content.xml
│ │ └── fragment_home.xml
├── proguard-rules.pro
└── build.gradle.kts
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── compiler.xml
├── vcs.xml
├── gradle.xml
└── misc.xml
├── .gitignore
├── settings.gradle
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature-main-screen/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/feature-main-screen/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/src/main/res/font/markpro.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/app/src/main/res/font/markpro.otf
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/feature-main-screen/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/T8RIN/Ecommerce/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/data/remote/response/Home.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.data.remote.response
2 |
3 | class Home : ArrayList()
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/ellipse_white.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/java/ru/tech/ecommerce/activity/application/EcommerceApplication.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.ecommerce.activity.application
2 |
3 | import android.app.Application
4 | import dagger.hilt.android.HiltAndroidApp
5 |
6 | @HiltAndroidApp
7 | class EcommerceApplication : Application() {
8 | }
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/data/remote/response/HomeItem.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.data.remote.response
2 |
3 | data class HomeItem(
4 | val _id: String,
5 | val best_seller: List,
6 | val home_store: List
7 | )
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Feb 21 22:17:45 MSK 2022
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/rounded_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/rounded_background_5.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/rounded_background_primary_10.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/rounded_background_secondary.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/rounded_background_secondary_10.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/utils/Resource.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.utils
2 |
3 | sealed class Resource(val data: T? = null, val message: String? = null) {
4 | class Success(data: T) : Resource(data)
5 | class Error(data: T? = null, message: String) : Resource(data, message)
6 | }
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/data/remote/response/HomeStore.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.data.remote.response
2 |
3 | data class HomeStore(
4 | val id: Int,
5 | val is_buy: Boolean,
6 | val is_new: Boolean,
7 | val picture: String,
8 | val subtitle: String,
9 | val title: String
10 | )
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/data/remote/response/BestSeller.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.data.remote.response
2 |
3 | data class BestSeller(
4 | val discount_price: Int,
5 | val id: Int,
6 | val is_favorites: Boolean,
7 | val picture: String,
8 | val price_without_discount: Int,
9 | val title: String
10 | )
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/text_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF000000
4 | #FFFFFFFF
5 |
6 | #FF6E4E
7 | #010035
8 | #B3B3C3
9 | #E5E5E5
10 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/data/remote/EcommerceApi.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.data.remote
2 |
3 | import retrofit2.http.GET
4 | import retrofit2.http.Headers
5 | import ru.tech.feature_main_screen.data.remote.response.Home
6 |
7 | interface EcommerceApi {
8 |
9 | @Headers("x-apikey: 61ddae2e95cb716ea5ee48e4")
10 | @GET("home")
11 | suspend fun getHome(): Home
12 |
13 |
14 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 | rootProject.name = "Ecommerce"
16 | include ':app'
17 | include ':feature-main-screen'
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v29/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/splash_screen.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/ellipse.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/extensions/Extensions.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.extensions
2 |
3 | import android.content.res.ColorStateList
4 | import android.graphics.PorterDuff
5 | import android.widget.ImageView
6 | import androidx.annotation.ColorInt
7 | import androidx.core.widget.ImageViewCompat
8 |
9 | object Extensions {
10 |
11 | fun ImageView.setTint(@ColorInt color: Int?) {
12 | if (color != null) {
13 | ImageViewCompat.setImageTintMode(this, PorterDuff.Mode.SRC_ATOP)
14 | ImageViewCompat.setImageTintList(
15 | this,
16 | ColorStateList.valueOf(color)
17 | )
18 | } else ImageViewCompat.setImageTintList(this, null)
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/arrow_down.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
12 |
13 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
19 |
20 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/data/repository/EcommerceRepository.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.data.repository
2 |
3 | import dagger.hilt.android.scopes.ActivityScoped
4 | import ru.tech.feature_main_screen.data.remote.EcommerceApi
5 | import ru.tech.feature_main_screen.data.remote.response.Home
6 | import ru.tech.feature_main_screen.utils.Resource
7 | import javax.inject.Inject
8 |
9 | @ActivityScoped
10 | class EcommerceRepository @Inject constructor(
11 | private val api: EcommerceApi
12 | ) {
13 |
14 | suspend fun getHome(): Resource {
15 | val response = try {
16 | api.getHome()
17 | } catch (e: Exception) {
18 | return Resource.Error(message = e.message.toString())
19 | }
20 | return Resource.Success(response)
21 | }
22 |
23 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.kts.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/feature-main-screen/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/user.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/filter.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/search.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/di/AppModule.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.di
2 |
3 | import dagger.Module
4 | import dagger.Provides
5 | import dagger.hilt.InstallIn
6 | import dagger.hilt.components.SingletonComponent
7 | import retrofit2.Retrofit
8 | import retrofit2.converter.gson.GsonConverterFactory
9 | import ru.tech.feature_main_screen.data.remote.EcommerceApi
10 | import ru.tech.feature_main_screen.data.repository.EcommerceRepository
11 | import javax.inject.Singleton
12 |
13 | @Module
14 | @InstallIn(SingletonComponent::class)
15 | object AppModule {
16 |
17 | @Singleton
18 | @Provides
19 | fun provideRepository(
20 | api: EcommerceApi
21 | ) = EcommerceRepository(api)
22 |
23 | @Singleton
24 | @Provides
25 | fun providePokeApi(): EcommerceApi {
26 | return Retrofit.Builder()
27 | .addConverterFactory(GsonConverterFactory.create())
28 | .baseUrl("https://shopapi-0575.restdb.io/rest/")
29 | .build()
30 | .create(EcommerceApi::class.java)
31 | }
32 | }
--------------------------------------------------------------------------------
/app/src/main/java/ru/tech/ecommerce/activity/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.ecommerce.activity
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 | import androidx.core.view.WindowCompat
6 | import dagger.hilt.android.AndroidEntryPoint
7 | import ru.tech.ecommerce.R
8 | import ru.tech.ecommerce.databinding.ActivityMainBinding
9 | import ru.tech.feature_main_screen.fragment.HomeFragment
10 |
11 | @AndroidEntryPoint
12 | class MainActivity : AppCompatActivity() {
13 |
14 | private lateinit var binding: ActivityMainBinding
15 |
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | setTheme(R.style.Theme_Ecommerce)
18 | WindowCompat.setDecorFitsSystemWindows(window, false)
19 | super.onCreate(savedInstanceState)
20 |
21 | binding = ActivityMainBinding.inflate(layoutInflater)
22 | setContentView(binding.root)
23 |
24 | if (savedInstanceState == null) {
25 | supportFragmentManager.beginTransaction().add(R.id.container, HomeFragment()).commit()
26 | }
27 |
28 | }
29 |
30 | }
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/phone.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
16 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/location.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
19 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/fragment/ModalBottomSheet.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.fragment
2 |
3 | import android.os.Bundle
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment
8 | import ru.tech.feature_main_screen.databinding.ModalBottomSheetContentBinding
9 |
10 | class ModalBottomSheet : BottomSheetDialogFragment() {
11 |
12 | private var _binding: ModalBottomSheetContentBinding? = null
13 | private val binding get() = _binding!!
14 |
15 |
16 | override fun onCreateView(
17 | inflater: LayoutInflater,
18 | container: ViewGroup?,
19 | savedInstanceState: Bundle?
20 | ): View {
21 | _binding = ModalBottomSheetContentBinding.inflate(inflater, container, false)
22 | return binding.root
23 | }
24 |
25 | override fun onDestroyView() {
26 | super.onDestroyView()
27 | _binding = null
28 | }
29 |
30 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
31 | super.onViewCreated(view, savedInstanceState)
32 | binding.close.setOnClickListener { dismiss() }
33 | binding.done.setOnClickListener { dismiss() }
34 | }
35 |
36 | companion object {
37 | const val TAG = "ModalBottomSheet"
38 | }
39 | }
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/like.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/layout/category_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
20 |
31 |
32 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/heart.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Ecommerce
3 | Zihuatanejo, Gro
4 | Filter
5 | Dropdown
6 | Select Category
7 | view all
8 | Phones
9 | Computer
10 | Health
11 | Books
12 | Search
13 | Hot sales
14 | see more
15 | New
16 | Title
17 | Buy now!
18 | Best Seller
19 | like
20 | Explorer
21 | Done
22 | Filter options
23 | Brand
24 | Price
25 | Size
26 | Samsung
27 | $300 - $500
28 | 4.5 to 5.5 inches
29 |
30 | Hello blank fragment
31 |
32 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/delike.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/x.xml:
--------------------------------------------------------------------------------
1 |
6 |
13 |
20 |
27 |
34 |
41 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/viewModel/FeatureMainScreenViewModel.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.viewModel
2 |
3 | import androidx.lifecycle.MutableLiveData
4 | import androidx.lifecycle.ViewModel
5 | import androidx.lifecycle.viewModelScope
6 | import dagger.hilt.android.lifecycle.HiltViewModel
7 | import kotlinx.coroutines.launch
8 | import ru.tech.feature_main_screen.R
9 | import ru.tech.feature_main_screen.data.remote.response.Home
10 | import ru.tech.feature_main_screen.data.repository.EcommerceRepository
11 | import ru.tech.feature_main_screen.utils.Resource
12 | import javax.inject.Inject
13 |
14 | @HiltViewModel
15 | class FeatureMainScreenViewModel @Inject constructor(
16 | private val repository: EcommerceRepository
17 | ) : ViewModel() {
18 |
19 | var isLoading = false
20 | var errorMessage = ""
21 |
22 | var selectedItemPos = 0
23 | var lastItemSelectedPos = 0
24 |
25 |
26 | val home: MutableLiveData by lazy {
27 | MutableLiveData()
28 | }
29 |
30 | fun getCategoriesList(): List> {
31 | return listOf(
32 | Pair(R.string.phones, R.drawable.phone),
33 | Pair(R.string.computer, R.drawable.computer),
34 | Pair(R.string.health, R.drawable.health),
35 | Pair(R.string.books, R.drawable.books)
36 | )
37 | }
38 |
39 | init {
40 | getHome()
41 | }
42 |
43 | private fun getHome() {
44 | viewModelScope.launch {
45 | isLoading = true
46 | when (val result = repository.getHome()) {
47 | is Resource.Success -> {
48 | home.value = result.data
49 | errorMessage = ""
50 | }
51 | else -> {
52 | errorMessage = result.message.toString()
53 | }
54 | }
55 | isLoading = false
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/adapter/HotSalesAdapter.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.adapter
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.View.GONE
6 | import android.view.View.VISIBLE
7 | import android.view.ViewGroup
8 | import androidx.recyclerview.widget.RecyclerView
9 | import coil.load
10 | import ru.tech.feature_main_screen.data.remote.response.HomeStore
11 | import ru.tech.feature_main_screen.databinding.HotSalesItemBinding
12 |
13 | class HotSalesAdapter(
14 | private val context: Context,
15 | private val list: List
16 | ) : RecyclerView.Adapter() {
17 |
18 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
19 | return ViewHolder(
20 | HotSalesItemBinding.inflate(
21 | LayoutInflater.from(parent.context),
22 | parent,
23 | false
24 | )
25 | )
26 | }
27 |
28 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
29 | holder.apply {
30 | background.load(list[position].picture)
31 | title.text = list[position].title
32 | subtitle.text = list[position].subtitle
33 | new.visibility =
34 | if (list[position].is_new) VISIBLE
35 | else GONE
36 | buy.visibility =
37 | if (list[position].is_buy) VISIBLE
38 | else GONE
39 | }
40 | }
41 |
42 | override fun getItemCount(): Int {
43 | return list.size
44 | }
45 |
46 |
47 | inner class ViewHolder(binding: HotSalesItemBinding) : RecyclerView.ViewHolder(binding.root) {
48 | val background = binding.background
49 | val title = binding.title
50 | val subtitle = binding.subtitle
51 | val new = binding.neww
52 | val buy = binding.buy
53 | }
54 |
55 | }
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/cart.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/computer.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/adapter/BestSellersAdapter.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.adapter
2 |
3 | import android.annotation.SuppressLint
4 | import android.content.Context
5 | import android.graphics.Paint
6 | import android.view.LayoutInflater
7 | import android.view.ViewGroup
8 | import androidx.recyclerview.widget.RecyclerView
9 | import coil.load
10 | import ru.tech.feature_main_screen.data.remote.response.BestSeller
11 | import ru.tech.feature_main_screen.databinding.BestSellerItemBinding
12 | import java.text.DecimalFormat
13 |
14 | class BestSellersAdapter(private val context: Context, private val list: List) :
15 | RecyclerView.Adapter() {
16 |
17 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
18 | return ViewHolder(
19 | BestSellerItemBinding.inflate(
20 | LayoutInflater.from(parent.context),
21 | parent,
22 | false
23 | )
24 | )
25 | }
26 |
27 | @SuppressLint("SetTextI18n")
28 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
29 | val dec = DecimalFormat("#,###")
30 | holder.apply {
31 | if (list[position].is_favorites) favSwitcher.showNext()
32 | image.load(list[position].picture)
33 | discount.text = "$${dec.format(list[position].discount_price)}"
34 | noDiscount.text = "$${dec.format(list[position].price_without_discount)}"
35 | title.text = list[position].title
36 | }
37 |
38 | }
39 |
40 | override fun getItemCount(): Int {
41 | return list.size
42 | }
43 |
44 | inner class ViewHolder(binding: BestSellerItemBinding) : RecyclerView.ViewHolder(binding.root) {
45 | val image = binding.image
46 | val title = binding.title
47 | val discount = binding.discount
48 | val favSwitcher = binding.addToFav
49 | val noDiscount = binding.withoutDiscount
50 |
51 | init {
52 | noDiscount.paintFlags = noDiscount.paintFlags or Paint.STRIKE_THRU_TEXT_FLAG
53 | favSwitcher.setOnClickListener { favSwitcher.showNext() }
54 | }
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/health.xml:
--------------------------------------------------------------------------------
1 |
6 |
10 |
11 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/qr.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
30 |
31 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/fragment/HomeFragment.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.fragment
2 |
3 | import android.os.Bundle
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import androidx.fragment.app.Fragment
8 | import androidx.fragment.app.viewModels
9 | import androidx.recyclerview.widget.PagerSnapHelper
10 | import dagger.hilt.android.AndroidEntryPoint
11 | import ru.tech.feature_main_screen.adapter.BestSellersAdapter
12 | import ru.tech.feature_main_screen.adapter.CategoryAdapter
13 | import ru.tech.feature_main_screen.adapter.HotSalesAdapter
14 | import ru.tech.feature_main_screen.databinding.FragmentHomeBinding
15 | import ru.tech.feature_main_screen.viewModel.FeatureMainScreenViewModel
16 |
17 | @AndroidEntryPoint
18 | class HomeFragment : Fragment() {
19 |
20 | private var _binding: FragmentHomeBinding? = null
21 | private val binding get() = _binding!!
22 |
23 | private val viewModel: FeatureMainScreenViewModel by viewModels()
24 |
25 | override fun onCreateView(
26 | inflater: LayoutInflater, container: ViewGroup?,
27 | savedInstanceState: Bundle?
28 | ): View {
29 | _binding = FragmentHomeBinding.inflate(inflater, container, false)
30 | return binding.root
31 | }
32 |
33 | override fun onDestroyView() {
34 | super.onDestroyView()
35 | _binding = null
36 | }
37 |
38 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
39 | super.onViewCreated(view, savedInstanceState)
40 |
41 | binding.categoriesRecycler.adapter =
42 | CategoryAdapter(
43 | requireContext(),
44 | viewModel.getCategoriesList(),
45 | viewModel
46 | )
47 |
48 | viewModel.home.observe(requireActivity()) {
49 | binding.hotSalesRecycler.adapter =
50 | HotSalesAdapter(
51 | requireContext(),
52 | viewModel.home.value!![0].home_store
53 | )
54 | binding.bestSellerRecycler.adapter =
55 | BestSellersAdapter(
56 | requireContext(),
57 | viewModel.home.value!![0].best_seller
58 | )
59 | }
60 |
61 | binding.filter.setOnClickListener {
62 | val modalBottomSheet = ModalBottomSheet()
63 | modalBottomSheet.show(requireActivity().supportFragmentManager, ModalBottomSheet.TAG)
64 | }
65 |
66 | val snapHelper = PagerSnapHelper()
67 | snapHelper.attachToRecyclerView(binding.hotSalesRecycler)
68 |
69 | }
70 |
71 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/feature-main-screen/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.library")
3 | id("org.jetbrains.kotlin.android")
4 | id("kotlin-kapt")
5 | id("dagger.hilt.android.plugin")
6 | }
7 |
8 | android {
9 | namespace = "ru.tech.feature_main_screen"
10 | compileSdk = 32
11 |
12 | defaultConfig {
13 | minSdk = 21
14 | targetSdk = 32
15 |
16 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
17 | consumerProguardFiles("consumer-rules.pro")
18 | }
19 |
20 | buildTypes {
21 | release {
22 | isMinifyEnabled = true
23 | proguardFiles(
24 | getDefaultProguardFile("proguard-android-optimize.txt"),
25 | "proguard-rules.pro"
26 | )
27 | }
28 | }
29 | compileOptions {
30 | isCoreLibraryDesugaringEnabled = true
31 | sourceCompatibility = JavaVersion.VERSION_1_8
32 | targetCompatibility = JavaVersion.VERSION_1_8
33 | }
34 | kotlinOptions {
35 | jvmTarget = "1.8"
36 | }
37 | buildFeatures {
38 | viewBinding = true
39 | }
40 | packagingOptions {
41 | resources {
42 | excludes += ("/META-INF/{AL2.0,LGPL2.1}")
43 | }
44 | }
45 | }
46 |
47 | dependencies {
48 |
49 | implementation("androidx.core:core-ktx:1.7.0")
50 | implementation("androidx.appcompat:appcompat:1.4.1")
51 | implementation("com.google.android.material:material:1.6.0-alpha02")
52 | implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
53 |
54 | // Retrofit
55 | implementation("com.squareup.retrofit2:retrofit:2.9.0")
56 | implementation("com.squareup.retrofit2:converter-gson:2.9.0")
57 | implementation("com.squareup.okhttp3:okhttp:4.9.2")
58 | implementation("com.squareup.okhttp3:logging-interceptor:4.9.2")
59 |
60 | // Coroutines
61 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
62 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
63 |
64 | // Coroutine Lifecycle Scopes
65 | implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1")
66 | implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
67 |
68 | //Dagger - Hilt
69 | implementation("com.google.dagger:hilt-android:2.38.1")
70 | implementation("androidx.constraintlayout:constraintlayout:2.1.3")
71 | implementation("androidx.recyclerview:recyclerview:1.2.1")
72 | implementation("androidx.hilt:hilt-navigation-fragment:1.0.0")
73 | implementation("androidx.navigation:navigation-fragment-ktx:2.4.1")
74 | implementation("androidx.navigation:navigation-ui-ktx:2.4.1")
75 | kapt("com.google.dagger:hilt-android-compiler:2.38.1")
76 | implementation("androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03")
77 | kapt("androidx.hilt:hilt-compiler:1.0.0")
78 |
79 | //Desugaring
80 | coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")
81 |
82 | //Coil
83 | implementation("io.coil-kt:coil:1.1.1")
84 |
85 | }
--------------------------------------------------------------------------------
/feature-main-screen/src/main/java/ru/tech/feature_main_screen/adapter/CategoryAdapter.kt:
--------------------------------------------------------------------------------
1 | package ru.tech.feature_main_screen.adapter
2 |
3 | import android.content.Context
4 | import android.view.LayoutInflater
5 | import android.view.ViewGroup
6 | import androidx.core.content.ContextCompat
7 | import androidx.recyclerview.widget.RecyclerView
8 | import ru.tech.feature_main_screen.R
9 | import ru.tech.feature_main_screen.databinding.CategoryItemBinding
10 | import ru.tech.feature_main_screen.extensions.Extensions.setTint
11 | import ru.tech.feature_main_screen.viewModel.FeatureMainScreenViewModel
12 |
13 | class CategoryAdapter(
14 | private val context: Context,
15 | private val categoriesList: List>,
16 | private val viewModel: FeatureMainScreenViewModel
17 | ) : RecyclerView.Adapter() {
18 |
19 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
20 | return ViewHolder(
21 | CategoryItemBinding.inflate(
22 | LayoutInflater.from(parent.context),
23 | parent,
24 | false
25 | )
26 | )
27 | }
28 |
29 | override fun onBindViewHolder(holder: ViewHolder, position: Int) {
30 | holder.text.text = context.getString(categoriesList[position].first)
31 | if (position == viewModel.selectedItemPos)
32 | holder.selectedItem(position)
33 | else
34 | holder.unselectedItem(position)
35 | }
36 |
37 | override fun getItemCount(): Int {
38 | return categoriesList.size
39 | }
40 |
41 | inner class ViewHolder(binding: CategoryItemBinding) :
42 | RecyclerView.ViewHolder(binding.root) {
43 | val text = binding.text
44 | private val imageView = binding.background
45 |
46 | init {
47 | itemView.setOnClickListener {
48 | viewModel.selectedItemPos = layoutPosition
49 | viewModel.lastItemSelectedPos = if (viewModel.lastItemSelectedPos == -1)
50 | viewModel.selectedItemPos
51 | else {
52 | notifyItemChanged(viewModel.lastItemSelectedPos)
53 | viewModel.selectedItemPos
54 | }
55 | notifyItemChanged(viewModel.selectedItemPos)
56 | }
57 | }
58 |
59 | fun selectedItem(position: Int) {
60 | imageView.setTint(ContextCompat.getColor(context, R.color.white))
61 | imageView.setImageResource(categoriesList[position].second)
62 | imageView.setBackgroundResource(R.drawable.ellipse)
63 | text.setTextColor(ContextCompat.getColor(context, R.color.primary))
64 | }
65 |
66 | fun unselectedItem(position: Int) {
67 | imageView.setTint(ContextCompat.getColor(context, R.color.unchecked))
68 | imageView.setImageResource(categoriesList[position].second)
69 | imageView.setBackgroundResource(R.drawable.ellipse_white)
70 | text.setTextColor(ContextCompat.getColor(context, R.color.black))
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.application")
3 | id("kotlin-android")
4 | id("kotlin-kapt")
5 | id("dagger.hilt.android.plugin")
6 | }
7 |
8 | android {
9 | namespace = "ru.tech.ecommerce"
10 | compileSdk = 32
11 |
12 | defaultConfig {
13 | applicationId = "ru.tech.ecommerce"
14 | minSdk = 21
15 | targetSdk = 32
16 | versionCode = 1
17 | versionName = "1.0"
18 |
19 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
20 |
21 | }
22 |
23 | buildTypes {
24 | release {
25 | isMinifyEnabled = true
26 | isShrinkResources = true
27 | proguardFiles(
28 | getDefaultProguardFile("proguard-android-optimize.txt"),
29 | "proguard-rules.pro"
30 | )
31 | }
32 | }
33 | compileOptions {
34 | isCoreLibraryDesugaringEnabled = true
35 | sourceCompatibility = JavaVersion.VERSION_1_8
36 | targetCompatibility = JavaVersion.VERSION_1_8
37 | }
38 | kotlinOptions {
39 | jvmTarget = "1.8"
40 | }
41 | buildFeatures {
42 | viewBinding = true
43 | }
44 | packagingOptions {
45 | resources {
46 | excludes += ("/META-INF/{AL2.0,LGPL2.1}")
47 | }
48 | }
49 | }
50 |
51 | dependencies {
52 |
53 | implementation("androidx.core:core-ktx:1.7.0")
54 | implementation("androidx.appcompat:appcompat:1.4.1")
55 | implementation("com.google.android.material:material:1.6.0-alpha02")
56 | implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
57 |
58 | // Retrofit
59 | implementation("com.squareup.retrofit2:retrofit:2.9.0")
60 | implementation("com.squareup.retrofit2:converter-gson:2.9.0")
61 | implementation("com.squareup.okhttp3:okhttp:4.9.2")
62 | implementation("com.squareup.okhttp3:logging-interceptor:4.9.2")
63 |
64 | // Coroutines
65 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
66 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
67 |
68 | // Coroutine Lifecycle Scopes
69 | implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1")
70 | implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
71 |
72 | //Dagger - Hilt
73 | implementation("com.google.dagger:hilt-android:2.38.1")
74 | implementation("androidx.constraintlayout:constraintlayout:2.1.3")
75 | implementation("androidx.recyclerview:recyclerview:1.2.1")
76 | implementation("androidx.hilt:hilt-navigation-fragment:1.0.0")
77 | implementation("androidx.navigation:navigation-fragment-ktx:2.4.1")
78 | implementation("androidx.navigation:navigation-ui-ktx:2.4.1")
79 | kapt("com.google.dagger:hilt-android-compiler:2.38.1")
80 | implementation("androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03")
81 | kapt("androidx.hilt:hilt-compiler:1.0.0")
82 |
83 | //Desugaring
84 | coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.5")
85 |
86 | //Coil
87 | implementation("io.coil-kt:coil:1.1.1")
88 |
89 | //Modules
90 | implementation(project(path = ":feature-main-screen"))
91 |
92 | }
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/layout/hot_sales_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
21 |
22 |
35 |
36 |
48 |
49 |
61 |
62 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/layout/best_seller_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
15 |
16 |
23 |
24 |
34 |
35 |
42 |
43 |
50 |
51 |
52 |
53 |
62 |
63 |
73 |
74 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/text.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/layout/modal_bottom_sheet_content.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
20 |
21 |
32 |
33 |
49 |
50 |
58 |
59 |
64 |
65 |
71 |
72 |
79 |
80 |
91 |
92 |
93 |
98 |
99 |
105 |
106 |
113 |
114 |
125 |
126 |
127 |
132 |
133 |
139 |
140 |
147 |
148 |
159 |
160 |
161 |
162 |
163 |
164 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/drawable/books.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
21 |
24 |
27 |
28 |
--------------------------------------------------------------------------------
/feature-main-screen/src/main/res/layout/fragment_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
18 |
19 |
29 |
30 |
40 |
41 |
51 |
52 |
62 |
63 |
73 |
74 |
87 |
88 |
103 |
104 |
123 |
124 |
135 |
136 |
149 |
150 |
160 |
161 |
174 |
175 |
185 |
186 |
196 |
197 |
209 |
210 |
223 |
224 |
225 |
226 |
227 |
228 |
233 |
234 |
244 |
245 |
256 |
257 |
269 |
270 |
280 |
281 |
291 |
292 |
293 |
294 |
--------------------------------------------------------------------------------