-
Notifications
You must be signed in to change notification settings - Fork 664
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'openMF:development' into registration_compose
- Loading branch information
Showing
37 changed files
with
1,298 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
app/src/main/java/org/mifos/mobile/ui/beneficiary_list/BeneficiaryListComposeFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} | ||
} |
132 changes: 132 additions & 0 deletions
132
app/src/main/java/org/mifos/mobile/ui/beneficiary_list/BeneficiaryListContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {} | ||
) | ||
} | ||
} | ||
|
Oops, something went wrong.