-
Notifications
You must be signed in to change notification settings - Fork 455
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
fix #1629 : migrated MakeTransferFragment to compose #1630
fix #1629 : migrated MakeTransferFragment to compose #1630
Conversation
onDismissRequest = { | ||
showBottomSheet = false | ||
}, | ||
dragHandle = { BottomSheetDefaults.DragHandle() }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think its the default value ?
var showBottomSheet by rememberSaveable { | ||
mutableStateOf(showBottomSheet) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
point of adding this here
.width(100.dp) | ||
.height(50.dp) | ||
) { | ||
Text(text = "Cancel") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract string res
.width(100.dp) | ||
.height(50.dp) | ||
) { | ||
Text(text = "Confirm") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string res
style = TextStyle( | ||
Color.Black, | ||
MaterialTheme.typography.bodyMedium.fontSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repetitive styles can be moved to MifosTextStyle.kt
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewWithMakeTransferContentLoading() { | ||
MakeTransferScreen( | ||
uiState = MakeTransferState.Loading, | ||
showTransactionStatus = ShowTransactionStatus( | ||
showSuccessStatus = false, | ||
showErrorStatus = false | ||
), | ||
makeTransfer = { _, _ -> } | ||
) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewWithMakeTransferContentSuccess() { | ||
MakeTransferScreen( | ||
uiState = MakeTransferState.Success( | ||
toClientId = 1234, | ||
resultName = "John Doe", | ||
externalId = "[email protected]", | ||
transferAmount = 100.0, | ||
showBottomSheet = true, | ||
), | ||
showTransactionStatus = ShowTransactionStatus( | ||
showSuccessStatus = false, | ||
showErrorStatus = false | ||
), | ||
makeTransfer = { _, _ -> } | ||
) | ||
} | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewMakeTransferContent() { | ||
MakeTransferContent( | ||
toClientId = 1234, | ||
resultName = "John Doe", | ||
externalId = "[email protected]", | ||
transferAmount = 100.0, | ||
makeTransfer = { _, _ -> }, | ||
sheetState = null, | ||
showBottomSheet = true | ||
) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewMakeTransferBottomSheetContent() { | ||
MakeTransferBottomSheetContent( | ||
showBottomSheet = true, | ||
toClientId = 1234, | ||
resultName = "John Doe", | ||
externalId = "[email protected]", | ||
transferAmount = 100.0, | ||
showTransactionStatus = ShowTransactionStatus( | ||
showSuccessStatus = false, | ||
showErrorStatus = false | ||
), | ||
makeTransfer = { _, _ -> } | ||
) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewWithMakeTransferContentError() { | ||
MakeTransferScreen( | ||
uiState = MakeTransferState.Error("An error occurred"), | ||
showTransactionStatus = ShowTransactionStatus( | ||
showSuccessStatus = false, | ||
showErrorStatus = false | ||
), | ||
makeTransfer = { _, _ -> } | ||
) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use preview parameter annotation
val showBottomSheet = uiState.showBottomSheet | ||
val toClientId = uiState.toClientId | ||
val resultName = uiState.resultName | ||
val externalId = uiState.externalId | ||
val transferAmount = uiState.transferAmount | ||
val showTransactionStatus = showTransactionStatus | ||
|
||
MakeTransferBottomSheetContent( | ||
showBottomSheet, | ||
toClientId, | ||
resultName, | ||
externalId, | ||
transferAmount, | ||
showTransactionStatus, | ||
makeTransfer = makeTransfer | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directly pass these values to the composable.
also always pass by naming the parameter, link showBottomSheet = uiState.showBottomSheet
for functions for more good visibility of code.
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewWithMakeTransferContentLoading() { | ||
MakeTransferScreen( | ||
uiState = MakeTransferState.Loading, | ||
showTransactionStatus = ShowTransactionStatus( | ||
showSuccessStatus = false, | ||
showErrorStatus = false | ||
), | ||
makeTransfer = { _, _ -> } | ||
) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewWithMakeTransferContentSuccess() { | ||
MakeTransferScreen( | ||
uiState = MakeTransferState.Success( | ||
toClientId = 1234, | ||
resultName = "John Doe", | ||
externalId = "[email protected]", | ||
transferAmount = 100.0, | ||
showBottomSheet = true, | ||
), | ||
showTransactionStatus = ShowTransactionStatus( | ||
showSuccessStatus = false, | ||
showErrorStatus = false | ||
), | ||
makeTransfer = { _, _ -> } | ||
) | ||
} | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewMakeTransferContent() { | ||
MakeTransferContent( | ||
toClientId = 1234, | ||
resultName = "John Doe", | ||
externalId = "[email protected]", | ||
transferAmount = 100.0, | ||
makeTransfer = { _, _ -> }, | ||
sheetState = null, | ||
showBottomSheet = true | ||
) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewMakeTransferBottomSheetContent() { | ||
MakeTransferBottomSheetContent( | ||
showBottomSheet = true, | ||
toClientId = 1234, | ||
resultName = "John Doe", | ||
externalId = "[email protected]", | ||
transferAmount = 100.0, | ||
showTransactionStatus = ShowTransactionStatus( | ||
showSuccessStatus = false, | ||
showErrorStatus = false | ||
), | ||
makeTransfer = { _, _ -> } | ||
) | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
fun PreviewWithMakeTransferContentError() { | ||
MakeTransferScreen( | ||
uiState = MakeTransferState.Error("An error occurred"), | ||
showTransactionStatus = ShowTransactionStatus( | ||
showSuccessStatus = false, | ||
showErrorStatus = false | ||
), | ||
makeTransfer = { _, _ -> } | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use preview parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the require changes
.width(100.dp) | ||
.height(50.dp) | ||
) { | ||
Text(text = "Confirm") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use stringResource
.width(100.dp) | ||
.height(50.dp) | ||
) { | ||
Text(text = "Cancel") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use stringResource
mifospay/src/main/java/org/mifospay/common/presenter/MakeTransferViewModel.kt
Outdated
Show resolved
Hide resolved
…o MakeTransferFragment_Migration
Issue Fix
Fixes #1629
Screenshots
before migration:
after migration:
Description
Apply the
AndroidStyle.xml
style template to your code in Android Studio.Run the unit tests with
./gradlew check
to make sure you didn't break anythingIf you have multiple commits please combine them into one commit by squashing them.