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

fix #1629 : migrated MakeTransferFragment to compose #1630

Merged

Conversation

AdityaKumdale
Copy link
Contributor

@AdityaKumdale AdityaKumdale commented May 16, 2024

Issue Fix

Fixes #1629

Screenshots

before migration:
image

after migration:
image

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 anything

  • If you have multiple commits please combine them into one commit by squashing them.

onDismissRequest = {
showBottomSheet = false
},
dragHandle = { BottomSheetDefaults.DragHandle() },
Copy link
Collaborator

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 ?

Comment on lines +161 to +163
var showBottomSheet by rememberSaveable {
mutableStateOf(showBottomSheet)
}
Copy link
Collaborator

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")
Copy link
Collaborator

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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

string res

Comment on lines +194 to +196
style = TextStyle(
Color.Black,
MaterialTheme.typography.bodyMedium.fontSize
Copy link
Collaborator

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

Comment on lines +335 to +411
@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 = { _, _ -> }
)
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use preview parameter annotation

Comment on lines +87 to +102
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
)
Copy link
Contributor

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.

Comment on lines +335 to +410
@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 = { _, _ -> }
)
}
Copy link
Contributor

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

Copy link
Contributor

@Aditya-gupta99 Aditya-gupta99 left a 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")
Copy link
Contributor

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use stringResource

@therajanmaurya therajanmaurya merged commit 0a35938 into openMF:dev May 25, 2024
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

refactor: migrate MakeTransferFragment to compose
5 participants