Skip to content

Commit

Permalink
product: module, design and navigation component #10 #11
Browse files Browse the repository at this point in the history
  • Loading branch information
reskimulud committed Aug 10, 2022
1 parent 1eee7ef commit 493bdef
Show file tree
Hide file tree
Showing 25 changed files with 326 additions and 1 deletion.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies {

implementation project(':core')
implementation project(':auth')
implementation project(':product')
implementation fileTree(dir: 'libs', include: ['*.jar'])

}
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ dependencies {
implementation "androidx.datastore:datastore-preferences-core:1.0.0"

// paging 3
implementation "androidx.paging:paging-runtime-ktx:3.1.1"
api "androidx.paging:paging-runtime-ktx:3.1.1"

}
1 change: 1 addition & 0 deletions product/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
42 changes: 42 additions & 0 deletions product/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}

apply from: '../ui_dependencies.gradle'

android {
compileSdk 32

defaultConfig {
minSdk 21
targetSdk 32

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}

dependencies {
implementation project(':core')
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
Empty file added product/consumer-rules.pro
Empty file.
21 changes: 21 additions & 0 deletions product/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.mankart.eshop.product

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.mankart.eshop.product.test", appContext.packageName)
}
}
12 changes: 12 additions & 0 deletions product/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mankart.eshop.product">

<application
android:theme="@style/Theme.Eshop">
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mankart.eshop.product.di

import com.mankart.eshop.core.domain.usecase.favproduct.FavoriteProductInteractor
import com.mankart.eshop.core.domain.usecase.products.ProductUseCase
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped

@Module
@InstallIn(ViewModelComponent::class)
abstract class ProductModule {
@Binds
@ViewModelScoped
abstract fun provideProductUseCase(productInteractor: FavoriteProductInteractor): ProductUseCase
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.mankart.eshop.product.ui

import androidx.fragment.app.Fragment
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class DetailProductFragment: Fragment() {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.mankart.eshop.product.ui

import androidx.lifecycle.ViewModel
import androidx.paging.PagingData
import com.mankart.eshop.core.data.Resource
import com.mankart.eshop.core.domain.model.Product
import com.mankart.eshop.core.domain.usecase.products.ProductUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

@HiltViewModel
class ProductViewModel @Inject constructor(
private val productUseCase: ProductUseCase,
): ViewModel() {
fun getProducts(): Flow<PagingData<Product>> = productUseCase.getProducts()
fun getProductById(productId: String): Flow<Resource<Product>> = productUseCase.getProductById(productId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.mankart.eshop.product.ui

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import com.mankart.eshop.product.databinding.FragmentProductsBinding
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class ProductsFragment: Fragment() {
private var _binding: FragmentProductsBinding? = null
private val binding get() = _binding!!

private val productViewModel: ProductViewModel by viewModels()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
_binding = FragmentProductsBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}

override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
}
7 changes: 7 additions & 0 deletions product/src/main/res/drawable/fragment_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorBase"/>
<corners
android:bottomLeftRadius="32dp"
android:bottomRightRadius="32dp"/>
</shape>
7 changes: 7 additions & 0 deletions product/src/main/res/font/poppins.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="Poppins"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>
16 changes: 16 additions & 0 deletions product/src/main/res/layout/fragment_detail_product.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.DetailProductFragment">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="18sp"
android:text="@string/detail_product"
android:fontFamily="@font/poppins"/>

</androidx.constraintlayout.widget.ConstraintLayout>
17 changes: 17 additions & 0 deletions product/src/main/res/layout/fragment_products.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.ProductsFragment">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/products"
android:textSize="18sp"
android:background="@drawable/fragment_background"
android:fontFamily="@font/poppins"/>

</androidx.constraintlayout.widget.ConstraintLayout>
18 changes: 18 additions & 0 deletions product/src/main/res/navigation/product_nav_graph.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/product_nav_graph"
app:startDestination="@id/productsFragment">

<fragment
android:id="@+id/productsFragment"
android:name="com.mankart.eshop.product.ui.ProductsFragment"
android:label="fragment_products"
tools:layout="@layout/fragment_products" />
<fragment
android:id="@+id/detailProductFragment"
android:name="com.mankart.eshop.product.ui.DetailProductFragment"
android:label="fragment_detail_product"
tools:layout="@layout/fragment_detail_product" />
</navigation>
17 changes: 17 additions & 0 deletions product/src/main/res/values/font_certs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="com_google_android_gms_fonts_certs">
<item>@array/com_google_android_gms_fonts_certs_dev</item>
<item>@array/com_google_android_gms_fonts_certs_prod</item>
</array>
<string-array name="com_google_android_gms_fonts_certs_dev">
<item>
MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAeFw0wODA0MTUyMzM2NTZaFw0zNTA5MDEyMzM2NTZaMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9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1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
</item>
</string-array>
</resources>
6 changes: 6 additions & 0 deletions product/src/main/res/values/preloaded_fonts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="preloaded_fonts" translatable="false">
<item>@font/poppins</item>
</array>
</resources>
5 changes: 5 additions & 0 deletions product/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="products">Products</string>
<string name="detail_product">Detail Product</string>
</resources>
29 changes: 29 additions & 0 deletions product/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Colors -->
<color name="colorBase">#EEEEEE</color>
<color name="colorPrimary">#181818</color>
<color name="colorAccent">#FF5B36</color>
<color name="colorText">#121212</color>
<color name="colorTextSecondary">#636363</color>
<color name="colorPrimaryVariant">#1C1C1C</color>

<color name="transparant">#6691C1F4</color>

<style name="Theme.Eshop" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryVariant">@color/colorPrimaryVariant</item>
<item name="colorOnPrimary">@color/colorAccent</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">@color/colorPrimary</item>
<!-- Customize your theme here. -->
<item name="android:navigationBarColor">@color/colorBase</item>
<item name="backgroundColor">@color/colorBase</item>

<!-- Transition Animation -->
<item name="android:windowActivityTransitions">true</item>-->
<item name="android:windowEnterTransition">@android:transition/explode</item>
<item name="android:windowExitTransition">@android:transition/explode</item>
</style>
</resources>
17 changes: 17 additions & 0 deletions product/src/test/java/com/mankart/eshop/product/ExampleUnitTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mankart.eshop.product

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ rootProject.name = "Eshop"
include ':app'
include ':core'
include ':auth'
include ':product'

0 comments on commit 493bdef

Please sign in to comment.