Skip to content

Commit

Permalink
Merge branch 'openMF:development' into registration_compose
Browse files Browse the repository at this point in the history
  • Loading branch information
akashmeruva9 committed Jun 17, 2024
2 parents 7374988 + 6d09e39 commit 678b477
Show file tree
Hide file tree
Showing 37 changed files with 1,298 additions and 351 deletions.
5 changes: 4 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ android {
}

dependencies {

//logs module
implementation(projects.core.logs)

implementation(projects.ui)

implementation("androidx.legacy:legacy-support-v4:1.0.0")
Expand Down Expand Up @@ -177,7 +181,6 @@ dependencies {
// google maps
implementation ("com.google.maps.android:maps-compose:4.4.1")


}


2 changes: 1 addition & 1 deletion app/src/debug/java/org/mifos/mobile/api/ObserveUiState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.mifos.mobile.api
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.mifos.mobile.utils.BeneficiaryUiState
//import org.mifos.mobile.utils.BeneficiaryUiState

//fun TestScope.obserrveUiState(): MutableList<BeneficiaryUiState> {
// val uiStates = mutableListOf<BeneficiaryUiState>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.mifos.mobile.databinding.NavDrawerHeaderBinding
import org.mifos.mobile.models.client.Client
import org.mifos.mobile.ui.about.AboutUsActivity
import org.mifos.mobile.ui.activities.base.BaseActivity
import org.mifos.mobile.ui.beneficiary_list.BeneficiaryListComposeFragment
import org.mifos.mobile.ui.client_charge.ClientChargeComposeFragment
import org.mifos.mobile.ui.enums.AccountType
import org.mifos.mobile.ui.enums.ChargeType
Expand Down Expand Up @@ -204,7 +205,7 @@ class HomeActivity :
)

R.id.item_beneficiaries -> replaceFragment(
BeneficiaryListFragment.newInstance(),
BeneficiaryListComposeFragment.newInstance(),
true,
R.id.container,
)
Expand Down Expand Up @@ -422,7 +423,7 @@ class HomeActivity :
setNavigationViewSelectedItem(R.id.item_third_party_transfer)
}

is BeneficiaryListFragment -> {
is BeneficiaryListComposeFragment -> {
setNavigationViewSelectedItem(R.id.item_beneficiaries)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,12 @@ class BeneficiaryAddOptionsFragment : BaseFragment() {
_binding = null
}

override fun onResume() {
super.onResume()
(activity as? BaseActivity)?.hideToolbar()
}

companion object {
@JvmStatic
fun newInstance(): BeneficiaryAddOptionsFragment {
val fragment = BeneficiaryAddOptionsFragment()
val args = Bundle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.res.Configuration
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -32,40 +33,43 @@ fun BeneficiaryScreen(
scaniconClicked: () -> Unit,
uploadiconClicked: () -> Unit
) {
MifosTopBar(
navigateBack = topAppbarNavigateback,
title = {
Text(text = stringResource(id = R.string.add_beneficiary))
Scaffold(
topBar = {
MifosTopBar(
navigateBack = topAppbarNavigateback,
title = {
Text(text = stringResource(id = R.string.add_beneficiary))
}
)
}
)

Column(
modifier = Modifier.padding(dimensionResource(id = R.dimen.padding_10dp))
) {
Text(
stringResource(id = R.string.select_mode),
fontSize = 18.sp,
color = MaterialTheme.colorScheme.onSurface
)

Text(
modifier = Modifier.padding(top = 16.dp),
text = stringResource(R.string.add_beneficiary_option),
fontSize = 18.sp,
color = MaterialTheme.colorScheme.onSurface
)
Column(
modifier = Modifier.padding(it).padding(dimensionResource(id = R.dimen.padding_10dp))
) {
Text(
stringResource(id = R.string.select_mode),
fontSize = 18.sp,
color = MaterialTheme.colorScheme.onSurface
)

BeneficiaryScreenIcons(
modifier = Modifier.padding(top = 20.dp),
addIconclicked = addiconClicked,
scanIconClicked = scaniconClicked,
uploadIconClicked = uploadiconClicked
)
Text(
modifier = Modifier.padding(top = 16.dp),
text = stringResource(R.string.add_beneficiary_option),
fontSize = 18.sp,
color = MaterialTheme.colorScheme.onSurface
)

BeneficiaryScreenIcons(
modifier = Modifier.padding(top = 20.dp),
addIconclicked = addiconClicked,
scanIconClicked = scaniconClicked,
uploadIconClicked = uploadiconClicked
)
}
}

}


@Preview(
name = "Night Mode",
uiMode = Configuration.UI_MODE_NIGHT_YES,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.mifos.mobile.ui.beneficiary_list

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import dagger.hilt.android.AndroidEntryPoint
import org.mifos.mobile.R
import org.mifos.mobile.core.ui.component.mifosComposeView
import org.mifos.mobile.models.beneficiary.Beneficiary
import org.mifos.mobile.ui.activities.base.BaseActivity
import org.mifos.mobile.ui.beneficiary.presentation.BeneficiaryAddOptionsFragment
import org.mifos.mobile.ui.beneficiary_detail.BeneficiaryDetailFragment
//import org.mifos.mobile.ui.fragments.BeneficiaryListFragment
import org.mifos.mobile.ui.fragments.base.BaseFragment


@AndroidEntryPoint
class BeneficiaryListComposeFragment : BaseFragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View {
return mifosComposeView(requireContext()) {
BeneficiaryListScreen(
navigateBack = { activity?.supportFragmentManager?.popBackStack() },
addBeneficiaryClicked = { addBeneficiary() },
onBeneficiaryItemClick = { position, beneficiaryList ->
onItemClick(
position = position,
beneficiaryList = beneficiaryList
)
},
)
}
}

private fun onItemClick(position: Int, beneficiaryList: List<Beneficiary>) {
(activity as? BaseActivity)?.replaceFragment(
BeneficiaryDetailFragment.newInstance(beneficiaryList[position]),
true,
R.id.container,
)
}

private fun addBeneficiary() {
(activity as? BaseActivity)?.replaceFragment(
BeneficiaryAddOptionsFragment.newInstance(),
true,
R.id.container,
)
}

override fun onResume() {
super.onResume()
(activity as? BaseActivity)?.hideToolbar()
}

companion object {
fun newInstance(): BeneficiaryListComposeFragment {
return BeneficiaryListComposeFragment()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package org.mifos.mobile.ui.beneficiary_list

import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.pulltorefresh.PullToRefreshContainer
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import org.mifos.mobile.R
import org.mifos.mobile.core.ui.component.EmptyDataView
import org.mifos.mobile.core.ui.component.NoInternet
import org.mifos.mobile.core.ui.theme.MifosMobileTheme
import org.mifos.mobile.models.beneficiary.Beneficiary
import org.mifos.mobile.utils.Network


@Composable
fun ShowBeneficiary(
beneficiaryList: List<Beneficiary>,
onClick: (position: Int) -> Unit
) {
Box(
modifier = Modifier
.fillMaxSize()
) {
LazyColumn {
itemsIndexed(beneficiaryList) { index, beneficiary ->
BeneficiaryItem(beneficiary, onClick = {
onClick(index)
})
}
}
}
}

@Composable
fun BeneficiaryItem(
beneficiary: Beneficiary,
onClick: () -> Unit
) {
Card(
modifier = Modifier.fillMaxWidth(),
shape = RoundedCornerShape(0.dp),
onClick = onClick,
colors = CardDefaults.cardColors(
containerColor = Color.Transparent
)
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp, vertical = 16.dp)
) {
Text(
text = "${beneficiary.name}",
style = MaterialTheme.typography.bodyMedium
)

Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
text = "${beneficiary.id}",
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onBackground.copy(alpha = .7f)
)

Text(
text = "${beneficiary.officeName}",
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onBackground.copy(alpha = .7f)
)
}

}
HorizontalDivider(
modifier = Modifier
.fillMaxWidth()
.height(0.2.dp),
color = MaterialTheme.colorScheme.onBackground.copy(alpha = .3f)
)

}
}

@Composable
@Preview(showSystemUi = true)
fun PreviewBeneficiaryListEmpty(modifier: Modifier = Modifier) {
val beneficiary = Beneficiary(name = "Victor", id = 242344343, officeName = "Main office")
MifosMobileTheme {
BeneficiaryItem(
beneficiary = beneficiary,
onClick = {}
)
}
}

Loading

0 comments on commit 678b477

Please sign in to comment.