@@ -26,7 +26,6 @@ import androidx.compose.foundation.rememberScrollState
2626import androidx.compose.foundation.verticalScroll
2727import androidx.compose.material3.ButtonDefaults
2828import androidx.compose.material3.MaterialTheme
29- import androidx.compose.material3.OutlinedTextField
3029import androidx.compose.material3.OutlinedTextFieldDefaults
3130import androidx.compose.material3.Text
3231import androidx.compose.runtime.Composable
@@ -38,6 +37,7 @@ import androidx.compose.ui.unit.dp
3837import androidx.lifecycle.compose.collectAsStateWithLifecycle
3938import com.mifos.core.designsystem.component.MifosCircularProgress
4039import com.mifos.core.designsystem.component.MifosOutlinedButton
40+ import com.mifos.core.designsystem.component.MifosOutlinedTextField
4141import com.mifos.core.designsystem.component.MifosScaffold
4242import com.mifos.core.designsystem.theme.DesignToken
4343import com.mifos.core.designsystem.theme.MifosTypography
@@ -49,14 +49,19 @@ import org.koin.compose.viewmodel.koinViewModel
4949
5050@Composable
5151internal fun AddEditNoteScreen (
52- onBackPressed : (Boolean? ) -> Unit ,
52+ onBackPressed : () -> Unit ,
53+ onNavigateWithUpdatedList : (Int , String? ) -> Unit ,
5354 viewModel : AddEditNoteViewModel = koinViewModel(),
5455) {
5556 val state by viewModel.stateFlow.collectAsStateWithLifecycle()
5657
5758 EventsEffect (viewModel.eventFlow) { event ->
5859 when (event) {
59- AddEditNoteEvent .NavigateBack -> onBackPressed(state.isRequiredUpdateListNote)
60+ AddEditNoteEvent .NavigateBack -> onBackPressed()
61+ AddEditNoteEvent .NavigateBackWithUpdateList -> onNavigateWithUpdatedList(
62+ state.resourceId,
63+ state.resourceType,
64+ )
6065 }
6166 }
6267
@@ -87,9 +92,11 @@ fun AddEditNoteScreenDialog(
8792 },
8893 )
8994 }
95+
9096 AddEditNoteState .DialogState .Loading -> {
9197 MifosCircularProgress ()
9298 }
99+
93100 AddEditNoteState .DialogState .MisTouchBack -> {
94101 MifosAlertDialog (
95102 onDismissRequest = {
@@ -104,6 +111,7 @@ fun AddEditNoteScreenDialog(
104111 icon = null ,
105112 )
106113 }
114+
107115 null -> Unit
108116 }
109117}
@@ -140,9 +148,11 @@ private fun AddEditNote(
140148
141149 Column (
142150 modifier = Modifier
143- .verticalScroll(scrollState)
144151 .fillMaxWidth()
145- .padding(horizontal = DesignToken .spacing.large),
152+ .padding(
153+ horizontal = DesignToken .spacing.large,
154+ vertical = DesignToken .spacing.small,
155+ ),
146156 verticalArrangement = Arrangement .spacedBy(DesignToken .spacing.large),
147157 ) {
148158 Text (
@@ -151,70 +161,77 @@ private fun AddEditNote(
151161 color = MaterialTheme .colorScheme.onSurface,
152162 )
153163
154- OutlinedTextField (
155- value = state.textFieldNotesPayload.note ? : " " ,
156- onValueChange = {
157- onAction(AddEditNoteAction .TextFieldNotesPayload (state.textFieldNotesPayload.copy(note = it)))
158- },
159- singleLine = false ,
160- shape = DesignToken .shapes.large,
161- label = {
162- Text (
163- text = stringResource(state.label),
164- style = MaterialTheme .typography.bodySmall,
165- color = MaterialTheme .colorScheme.onSurfaceVariant,
166- )
167- },
164+ Column (
168165 modifier = Modifier
169- .fillMaxWidth()
170- .heightIn(min = 600 .dp),
171- textStyle = MaterialTheme .typography.bodyLarge.copy(textAlign = TextAlign .Start ),
172- colors = OutlinedTextFieldDefaults .colors(
173- unfocusedBorderColor = MaterialTheme .colorScheme.secondaryContainer,
174- ),
175- )
176-
177- Row (
178- modifier = Modifier .fillMaxWidth(),
179- horizontalArrangement = Arrangement .spacedBy(DesignToken .spacing.extraSmall),
166+ .verticalScroll(scrollState),
167+ verticalArrangement = Arrangement .spacedBy(DesignToken .spacing.large),
180168 ) {
181- MifosOutlinedButton (
182- modifier = Modifier .weight(1f ),
183- text = {
184- Text (
185- text = stringResource(Res .string.feature_note_button_back),
169+ MifosOutlinedTextField (
170+ value = state.textFieldNotesPayload.note ? : " " ,
171+ onValueChange = {
172+ onAction(
173+ AddEditNoteAction .TextFieldNotesPayload (
174+ state.textFieldNotesPayload.copy(
175+ note = it,
176+ ),
177+ ),
186178 )
187179 },
188- colors = ButtonDefaults .outlinedButtonColors(
189- contentColor = MaterialTheme .colorScheme.primary,
190- containerColor = MaterialTheme .colorScheme.onPrimary,
180+ maxLines = 18 ,
181+ singleLine = false ,
182+ shape = DesignToken .shapes.large,
183+ label = stringResource(state.label),
184+ modifier = Modifier
185+ .fillMaxWidth()
186+ .heightIn(min = 550 .dp),
187+ textStyle = MaterialTheme .typography.bodyLarge.copy(textAlign = TextAlign .Start ),
188+ colors = OutlinedTextFieldDefaults .colors(
189+ unfocusedBorderColor = MaterialTheme .colorScheme.secondaryContainer,
191190 ),
192- onClick = {
193- onAction(AddEditNoteAction .MisTouchBackDialog )
194- },
195191 )
196192
197- MifosOutlinedButton (
198- modifier = Modifier .weight(1f ),
199- text = {
200- Text (text = stringResource(state.addUpdateButton))
201- },
202- onClick = {
203- if (state.editEnabled) {
204- onAction(AddEditNoteAction .EditNote (state.textFieldNotesPayload))
205- } else {
206- onAction(AddEditNoteAction .AddNote (state.textFieldNotesPayload))
207- }
208- if (state.isError) {
209- onAction(AddEditNoteAction .NavigateBack )
210- }
211- },
212- colors = ButtonDefaults .outlinedButtonColors(
213- contentColor = MaterialTheme .colorScheme.onPrimary,
214- containerColor = MaterialTheme .colorScheme.primary,
215- ),
216- enabled = ! state.textFieldNotesPayload.note.isNullOrEmpty(),
217- )
193+ Row (
194+ modifier = Modifier .fillMaxWidth(),
195+ horizontalArrangement = Arrangement .spacedBy(DesignToken .spacing.extraSmall),
196+ ) {
197+ MifosOutlinedButton (
198+ modifier = Modifier .weight(1f ),
199+ text = {
200+ Text (
201+ text = stringResource(Res .string.feature_note_button_back),
202+ )
203+ },
204+ colors = ButtonDefaults .outlinedButtonColors(
205+ contentColor = MaterialTheme .colorScheme.primary,
206+ containerColor = MaterialTheme .colorScheme.onPrimary,
207+ ),
208+ onClick = {
209+ onAction(AddEditNoteAction .MisTouchBackDialog )
210+ },
211+ )
212+
213+ MifosOutlinedButton (
214+ modifier = Modifier .weight(1f ),
215+ text = {
216+ Text (text = stringResource(state.addUpdateButton))
217+ },
218+ onClick = {
219+ if (state.editEnabled) {
220+ onAction(AddEditNoteAction .EditNote (state.textFieldNotesPayload))
221+ } else {
222+ onAction(AddEditNoteAction .AddNote (state.textFieldNotesPayload))
223+ }
224+ if (state.isError) {
225+ onAction(AddEditNoteAction .NavigateBack )
226+ }
227+ },
228+ colors = ButtonDefaults .outlinedButtonColors(
229+ contentColor = MaterialTheme .colorScheme.onPrimary,
230+ containerColor = MaterialTheme .colorScheme.primary,
231+ ),
232+ enabled = ! state.textFieldNotesPayload.note.isNullOrEmpty(),
233+ )
234+ }
218235 }
219236 }
220237}
0 commit comments