-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: refactor NewIndividual Collection Sheet screen to jetpack c…
…ompose with multi module
- Loading branch information
1 parent
d9cd3b1
commit 7b89da2
Showing
28 changed files
with
1,206 additions
and
502 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
43 changes: 6 additions & 37 deletions
43
...tastore/src/main/java/com/mifos/core/objects/collectionsheet/IndividualCollectionSheet.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 |
---|---|---|
@@ -1,48 +1,17 @@ | ||
package com.mifos.core.objects.collectionsheet | ||
|
||
import android.os.Parcel | ||
import android.os.Parcelable | ||
import com.google.gson.annotations.SerializedName | ||
import com.mifos.core.objects.accounts.loan.PaymentTypeOptions | ||
import kotlinx.parcelize.Parcelize | ||
|
||
/** | ||
* Created by Tarun on 06-07-2017. | ||
*/ | ||
class IndividualCollectionSheet() : Parcelable { | ||
var dueDate: IntArray? = null | ||
@Parcelize | ||
data class IndividualCollectionSheet( | ||
var dueDate: IntArray? = null, | ||
|
||
@SerializedName("clients") | ||
var clients: ArrayList<ClientCollectionSheet>? = null | ||
var clients: ArrayList<ClientCollectionSheet>? = null, | ||
|
||
var paymentTypeOptions: ArrayList<PaymentTypeOptions>? = null | ||
|
||
constructor(parcel: Parcel) : this() { | ||
dueDate = parcel.createIntArray() | ||
clients = ArrayList<ClientCollectionSheet>().apply { | ||
parcel.readList(this, ClientCollectionSheet::class.java.classLoader) | ||
} | ||
paymentTypeOptions = ArrayList<PaymentTypeOptions>().apply { | ||
parcel.readList(this, PaymentTypeOptions::class.java.classLoader) | ||
} | ||
} | ||
|
||
override fun writeToParcel(dest: Parcel, flags: Int) { | ||
dest.writeIntArray(dueDate) | ||
dest.writeList(clients) | ||
dest.writeList(paymentTypeOptions) | ||
} | ||
|
||
override fun describeContents(): Int { | ||
return 0 | ||
} | ||
|
||
companion object CREATOR : Parcelable.Creator<IndividualCollectionSheet> { | ||
override fun createFromParcel(parcel: Parcel): IndividualCollectionSheet { | ||
return IndividualCollectionSheet(parcel) | ||
} | ||
|
||
override fun newArray(size: Int): Array<IndividualCollectionSheet?> { | ||
return arrayOfNulls(size) | ||
} | ||
} | ||
} | ||
) : Parcelable |
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
89 changes: 89 additions & 0 deletions
89
...esignsystem/src/main/java/com/mifos/core/designsystem/component/MifosTextFieldDropdown.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,89 @@ | ||
@file:OptIn(ExperimentalMaterial3Api::class) | ||
|
||
package com.mifos.core.designsystem.component | ||
|
||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.text.KeyboardOptions | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.ArrowDropDown | ||
import androidx.compose.material.icons.filled.ArrowDropUp | ||
import androidx.compose.material3.DropdownMenuItem | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.ExposedDropdownMenuBox | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.OutlinedTextField | ||
import androidx.compose.material3.OutlinedTextFieldDefaults | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalDensity | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.text.input.ImeAction | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import com.mifos.core.designsystem.theme.BluePrimary | ||
import com.mifos.core.designsystem.theme.BluePrimaryDark | ||
|
||
@Composable | ||
fun MifosTextFieldDropdown( | ||
value: String, | ||
onValueChanged: (String) -> Unit, | ||
onOptionSelected: (Int, String) -> Unit, | ||
label: Int, | ||
options: List<String> | ||
) { | ||
var isExpended by remember { mutableStateOf(false) } | ||
|
||
ExposedDropdownMenuBox( | ||
expanded = isExpended, | ||
onExpandedChange = { isExpended = it } | ||
) { | ||
OutlinedTextField( | ||
value = value, | ||
onValueChange = { onValueChanged(it) }, | ||
label = { Text(text = stringResource(id = label)) }, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.padding(start = 16.dp, end = 16.dp) | ||
.menuAnchor(), | ||
maxLines = 1, | ||
colors = OutlinedTextFieldDefaults.colors( | ||
focusedBorderColor = if (isSystemInDarkTheme()) BluePrimaryDark else BluePrimary, | ||
), | ||
textStyle = LocalDensity.current.run { | ||
TextStyle(fontSize = 18.sp) | ||
}, | ||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next), | ||
trailingIcon = { | ||
val image = | ||
if (isExpended) Icons.Default.ArrowDropUp else Icons.Default.ArrowDropDown | ||
IconButton(onClick = { isExpended = !isExpended }) { | ||
Icon(imageVector = image, null) | ||
} | ||
} | ||
) | ||
|
||
ExposedDropdownMenu( | ||
expanded = isExpended, | ||
onDismissRequest = { isExpended = false } | ||
) { | ||
options.forEachIndexed { index, value -> | ||
DropdownMenuItem( | ||
text = { Text(text = value) }, | ||
onClick = { | ||
isExpended = false | ||
onOptionSelected(index, value) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.