Skip to content

Commit 341d753

Browse files
Merge branch 'feature/property-detail' into develop
2 parents 616c269 + ebb9cf8 commit 341d753

File tree

47 files changed

+1066
-94
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1066
-94
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Sample project that build with MVVM clean architure and various cool techs inclu
1111

1212
Unit tests are written with JUnit4, JUnit5, MockK, Truth, MockWebServer.
1313

14-
| Flow | RxJava3 | Pagination | Favorites
14+
| Flow | RxJava3 | Pagination
1515
| ------------------|-------------| -----|--------------|
16-
| <img src="./screenshots/property_flow.png"/> | <img src="./screenshots/property_rxjava3.png"/> | <img src="./screenshots/property_pagination.png"/> |<img src="./screenshots/favorites.png"/> |
16+
| <img src="./screenshots/property_flow.png"/> | <img src="./screenshots/property_rxjava3.png"/> | <img src="./screenshots/property_pagination.png"/> |
1717

1818

1919
## Overview

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ android {
9797

9898
dynamicFeatures = mutableSetOf(
9999
Modules.DynamicFeature.HOME,
100+
Modules.DynamicFeature.PROPERTY_DETAIL,
100101
Modules.DynamicFeature.FAVORITES,
101102
Modules.DynamicFeature.NOTIFICATION,
102103
Modules.DynamicFeature.ACCOUNT

app/src/main/java/com/smarttoolfactory/propertyfindar/MainFragment.kt

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@ package com.smarttoolfactory.propertyfindar
22

33
import android.os.Bundle
44
import android.view.View
5+
import androidx.core.os.bundleOf
6+
import androidx.fragment.app.activityViewModels
7+
import androidx.navigation.fragment.findNavController
8+
import com.google.android.material.bottomnavigation.BottomNavigationView
59
import com.smarttoolfactory.core.ui.fragment.DynamicNavigationFragment
10+
import com.smarttoolfactory.core.util.observe
11+
import com.smarttoolfactory.core.viewmodel.PropertyDetailNavigationVM
612
import com.smarttoolfactory.propertyfindar.databinding.FragmentMainBinding
713
import com.smarttoolfactory.propertyfindar.ui.BottomNavigationFragmentStateAdapter
814

915
class MainFragment : DynamicNavigationFragment<FragmentMainBinding>() {
1016

17+
/**
18+
* ViewModel for navigating to property detail screen from Main Fragment
19+
*/
20+
private val propertyDetailNavigationVM by activityViewModels<PropertyDetailNavigationVM>()
21+
1122
override fun getLayoutRes(): Int = R.layout.fragment_main
1223

1324
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -51,7 +62,26 @@ class MainFragment : DynamicNavigationFragment<FragmentMainBinding>() {
5162
}
5263
}
5364
}
54-
false
65+
subscribePropertyDetailNavigation()
66+
}
67+
68+
/**
69+
* Navigates to Property Detail fragment from this fragment that replacing main fragment
70+
* that contains [BottomNavigationView]
71+
*/
72+
private fun subscribePropertyDetailNavigation() {
73+
viewLifecycleOwner.observe(propertyDetailNavigationVM.goToPropertyDetailFromMain) {
74+
75+
it.getContentIfNotHandled()?.let { propertyItem ->
76+
val bundle = bundleOf("property" to propertyItem)
77+
78+
findNavController()
79+
.navigate(
80+
R.id.action_mainFragment_to_propertyDetailFragment,
81+
bundle
82+
)
83+
}
84+
}
5585
}
5686

5787
override fun onDestroyView() {

app/src/main/res/anim/fade_in.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2018 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<set xmlns:android="http://schemas.android.com/apk/res/android">
19+
<alpha
20+
android:duration="@android:integer/config_mediumAnimTime"
21+
android:fromAlpha="0.0"
22+
android:toAlpha="1.0"/>
23+
</set>

app/src/main/res/anim/fade_out.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2018 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<set xmlns:android="http://schemas.android.com/apk/res/android">
19+
<alpha
20+
android:duration="@android:integer/config_mediumAnimTime"
21+
android:fromAlpha="1.0"
22+
android:toAlpha="0.0"/>
23+
</set>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<translate android:fromXDelta="-100%" android:toXDelta="0%"
5+
android:fromYDelta="0%" android:toYDelta="0%"
6+
android:duration="700"/>
7+
</set>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<translate android:fromXDelta="100%" android:toXDelta="0%"
5+
android:fromYDelta="0%" android:toYDelta="0%"
6+
android:duration="700"/>
7+
</set>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<translate android:fromXDelta="0%" android:toXDelta="-100%"
5+
android:fromYDelta="0%" android:toYDelta="0%"
6+
android:duration="700"/>
7+
</set>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<set xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
<translate android:fromXDelta="0%" android:toXDelta="100%"
5+
android:fromYDelta="0%" android:toYDelta="0%"
6+
android:duration="700"/>
7+
</set>

app/src/main/res/navigation/nav_graph_main.xml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,29 @@
99
android:id="@+id/mainFragment"
1010
android:name="com.smarttoolfactory.propertyfindar.MainFragment"
1111
android:label="MainFragment"
12-
tools:layout="@layout/fragment_main" />
12+
tools:layout="@layout/fragment_main">
1313

14+
<action
15+
android:id="@+id/action_mainFragment_to_propertyDetailFragment"
16+
app:destination="@id/nav_graph_property_detail"
17+
app:enterAnim="@anim/slide_in_right"
18+
app:exitAnim="@anim/slide_out_left"
19+
app:popEnterAnim="@anim/slide_in_left"
20+
app:popExitAnim="@anim/slide_out_right" />
21+
22+
</fragment>
23+
24+
25+
<!-- Property Detail dynamic feature module -->
26+
<include-dynamic
27+
android:id="@+id/nav_graph_property_detail"
28+
android:name="com.smarttoolfactory.property_detail"
29+
app:graphResName="nav_graph_property_detail"
30+
app:moduleName="property_detail">
31+
32+
<argument
33+
android:name="property"
34+
app:argType="com.smarttoolfactory.domain.model.PropertyItem" />
35+
36+
</include-dynamic>
1437
</navigation>

0 commit comments

Comments
 (0)