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

Fixed Feat: Implement Shimmer while user details are being loaded #2443

Open
wants to merge 4 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -205,5 +205,7 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$rootProject.lifecycleVersion"
implementation "androidx.compose.material:material-icons-extended:$rootProject.composeVersion"

// Shimmer effect
implementation "com.facebook.shimmer:shimmer:$rootProject.shimmerVersion"
}
apply plugin: 'com.google.gms.google-services'
14 changes: 11 additions & 3 deletions app/src/main/java/org/mifos/mobile/ui/fragments/HomeOldFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ class HomeOldFragment : BaseFragment(), OnRefreshListener {
lifecycleScope.launchWhenStarted {
viewModel.homeUiState.collect {
when (it) {
is HomeUiState.Loading -> showProgress()
is HomeUiState.Loading ->{
binding.detailsOfCustomer.visibility = View.INVISIBLE
}
is HomeUiState.UserImage -> {
hideProgress()
stopShimmerEffect()
showUserImage(it.image)
}
is HomeUiState.ClientAccountDetails -> {
Expand All @@ -271,7 +273,7 @@ class HomeOldFragment : BaseFragment(), OnRefreshListener {
showError(getString(it.errorMessage))
}
is HomeUiState.UserDetails -> {
hideProgress()
stopShimmerEffect()
showUserDetails(it.client)
}
is HomeUiState.UnreadNotificationsCount -> {
Expand Down Expand Up @@ -360,6 +362,12 @@ class HomeOldFragment : BaseFragment(), OnRefreshListener {
private fun userImageClicked() {
startActivity(Intent(activity, UserProfileActivity::class.java))
}

private fun stopShimmerEffect(){
binding.shimmerViewContainer.stopShimmer()
binding.detailsOfCustomer.visibility = View.VISIBLE
binding.shimmerViewContainer.visibility = View.INVISIBLE
}

/**
* Calls `openAccount()` for opening [ClientAccountsFragment]
Expand Down
46 changes: 44 additions & 2 deletions app/src/main/res/layout/fragment_home_old.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@
android:layout_marginHorizontal="@dimen/Mifos.DesignSystem.Spacing.screenHorizontalMargin"
android:animateLayoutChanges="true"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="@dimen/Mifos.DesignSystem.Spacing.screenHorizontalMargin"
android:animateLayoutChanges="true"
android:orientation="vertical">
<com.facebook.shimmer.ShimmerFrameLayout
android:id="@+id/shimmer_view_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -27,6 +37,38 @@
android:orientation="horizontal"
android:padding="@dimen/Mifos.DesignSystem.Spacing.CardInnerPaddingLarger">

<com.google.android.material.imageview.ShapeableImageView
android:layout_width="84dp"
android:layout_height="84dp"
android:layout_marginEnd="@dimen/Mifos.DesignSystem.Spacing.marginBetweenItemsLarge"
app:border="true"
app:border_width="1dp"
tools:src="@drawable/ic_person_black_24dp"
app:shapeAppearanceOverlay="@style/Circular"
android:background="@color/gray_dark"
/>


<TextView
style="@style/Mifos.DesignSystem.TextStyle.Heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@color/gray_dark" />

</LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/Mifos.DesignSystem.Spacing.marginBetweenItemsSmall"
android:clickable="true"
android:focusable="true"
android:orientation="horizontal"
android:padding="@dimen/Mifos.DesignSystem.Spacing.CardInnerPaddingLarger"
android:layout_gravity="center"
android:id="@+id/details_of_customer">

<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/iv_circular_user_image"
android:layout_width="84dp"
Expand All @@ -46,7 +88,7 @@
tools:text="Hello, you guys" />

</LinearLayout>

</RelativeLayout>
<com.google.android.material.card.MaterialCardView
style="@style/Mifos.DesignSystem.Components.Cards.Filled"
android:layout_width="match_parent"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
<style name="SplashTheme" parent="Mifos.DesignSystem.Theme.Base">
<item name="android:windowBackground">@drawable/splash_background</item>
</style>

<style name="Circular">
<item name="cornerSize">50%</item>
</style>
</resources>
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ ext {
composeActivity = '1.7.2'
materialVersion = '1.1.0'
lifecycleVersion = '2.6.1'
shimmerVersion = '0.5.0'
}
Loading