1
+ /*
2
+ * Copyright 2024 Mifos Initiative
3
+ *
4
+ * This Source Code Form is subject to the terms of the Mozilla Public
5
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7
+ *
8
+ * See https://github.com/openMF/android-client/blob/master/LICENSE.md
9
+ */
1
10
package com.mifos.feature.savings.navigation
2
11
3
12
import androidx.navigation.NavController
@@ -9,11 +18,11 @@ import androidx.navigation.navigation
9
18
import com.mifos.core.common.utils.Constants
10
19
import com.mifos.core.objects.accounts.savings.DepositType
11
20
import com.mifos.core.objects.accounts.savings.SavingsAccountWithAssociations
12
- import com.mifos.feature.savings.account .SavingsAccountScreen
13
- import com.mifos.feature.savings.account_activate .SavingsAccountActivateScreen
14
- import com.mifos.feature.savings.account_approval .SavingsAccountApprovalScreen
15
- import com.mifos.feature.savings.account_summary .SavingsAccountSummaryScreen
16
- import com.mifos.feature.savings.account_transaction .SavingsAccountTransactionScreen
21
+ import com.mifos.feature.savings.savingsAccount .SavingsAccountScreen
22
+ import com.mifos.feature.savings.savingsAccountActivate .SavingsAccountActivateScreen
23
+ import com.mifos.feature.savings.savingsAccountApproval .SavingsAccountApprovalScreen
24
+ import com.mifos.feature.savings.savingsAccountSummary .SavingsAccountSummaryScreen
25
+ import com.mifos.feature.savings.savingsAccountTransaction .SavingsAccountTransactionScreen
17
26
18
27
/* *
19
28
* Created by Pronay Sarker on 14/08/2024 (1:10 PM)
@@ -22,41 +31,41 @@ import com.mifos.feature.savings.account_transaction.SavingsAccountTransactionSc
22
31
fun NavGraphBuilder.savingsNavGraph (
23
32
navController : NavController ,
24
33
onBackPressed : () -> Unit ,
25
- loadMoreSavingsAccountInfo : (Int ) -> Unit ,
26
- loadDocuments : (Int ) -> Unit ,
34
+ loadMoreSavingsAccountInfo : (String , Int ) -> Unit ,
35
+ loadDocuments : (Int , String ) -> Unit ,
27
36
) {
28
37
navigation(
29
38
startDestination = SavingsScreens .SavingsAccountSummary .route,
30
- route = " savings_summary_route"
39
+ route = " savings_summary_route" ,
31
40
) {
32
41
savingsSummaryScreen(
33
42
onBackPressed = navController::popBackStack,
34
- loadMoreSavingsAccountInfo = loadMoreSavingsAccountInfo,
35
- loadDocuments = loadDocuments,
43
+ loadMoreSavingsAccountInfo = { loadMoreSavingsAccountInfo( Constants . DATA_TABLE_NAME_SAVINGS , it) } ,
44
+ loadDocuments = { loadDocuments(it, Constants . ENTITY_TYPE_SAVINGS ) } ,
36
45
onDepositClick = { savingsAccountWithAssociations, depositType ->
37
46
navController.navigateToSavingsAccountTransactionScreen(
38
47
savingsAccountWithAssociations = savingsAccountWithAssociations,
39
48
depositType = depositType,
40
- transactionType = Constants .SAVINGS_ACCOUNT_TRANSACTION_DEPOSIT
49
+ transactionType = Constants .SAVINGS_ACCOUNT_TRANSACTION_DEPOSIT ,
41
50
)
42
51
},
43
52
onWithdrawButtonClicked = { savingsAccountWithAssociations, depositType ->
44
53
navController.navigateToSavingsAccountTransactionScreen(
45
54
savingsAccountWithAssociations = savingsAccountWithAssociations,
46
55
depositType = depositType,
47
- transactionType = Constants .SAVINGS_ACCOUNT_TRANSACTION_WITHDRAWAL
56
+ transactionType = Constants .SAVINGS_ACCOUNT_TRANSACTION_WITHDRAWAL ,
48
57
)
49
58
},
50
59
approveSavings = { _, accountNumber ->
51
60
navController.navigateToSavingsAccountApproval(
52
- accountNumber
61
+ accountNumber,
53
62
)
54
63
},
55
64
activateSavings = { _, accountNumber ->
56
65
navController.navigateToSavingsAccountActivate(
57
- accountNumber
66
+ accountNumber,
58
67
)
59
- }
68
+ },
60
69
)
61
70
62
71
addSavingsAccountScreen {
@@ -78,18 +87,18 @@ fun NavGraphBuilder.savingsNavGraph(
78
87
}
79
88
80
89
fun NavGraphBuilder.addSavingsAccountScreen (
81
- onBackPressed : () -> Unit
90
+ onBackPressed : () -> Unit ,
82
91
) {
83
92
composable(
84
93
route = SavingsScreens .SavingsAccount .route,
85
94
arguments = listOf (
86
95
navArgument(name = Constants .GROUP_ID , builder = { type = NavType .IntType }),
87
96
navArgument(name = Constants .CLIENT_ID , builder = { type = NavType .IntType }),
88
- navArgument(name = Constants .GROUP_ACCOUNT , builder = { type = NavType .BoolType })
89
- )
97
+ navArgument(name = Constants .GROUP_ACCOUNT , builder = { type = NavType .BoolType }),
98
+ ),
90
99
) {
91
100
SavingsAccountScreen (
92
- navigateBack = onBackPressed
101
+ navigateBack = onBackPressed,
93
102
)
94
103
}
95
104
}
@@ -101,13 +110,13 @@ fun NavGraphBuilder.savingsSummaryScreen(
101
110
onDepositClick : (SavingsAccountWithAssociations , DepositType ? ) -> Unit ,
102
111
onWithdrawButtonClicked : (SavingsAccountWithAssociations , DepositType ? ) -> Unit ,
103
112
approveSavings : (savingsAccountType: DepositType ? , savingsAccountNumber: Int ) -> Unit ,
104
- activateSavings : (savingsAccountType: DepositType ? , savingsAccountNumber: Int ) -> Unit
113
+ activateSavings : (savingsAccountType: DepositType ? , savingsAccountNumber: Int ) -> Unit ,
105
114
) {
106
115
composable(
107
116
route = SavingsScreens .SavingsAccountSummary .route,
108
117
arguments = listOf (
109
- navArgument(name = " arg" , builder = { type = NavType .StringType })
110
- )
118
+ navArgument(name = " arg" , builder = { type = NavType .StringType }),
119
+ ),
111
120
) {
112
121
SavingsAccountSummaryScreen (
113
122
navigateBack = onBackPressed,
@@ -116,60 +125,60 @@ fun NavGraphBuilder.savingsSummaryScreen(
116
125
onDepositClick = onDepositClick,
117
126
onWithdrawButtonClicked = onWithdrawButtonClicked,
118
127
approveSavings = approveSavings,
119
- activateSavings = activateSavings
128
+ activateSavings = activateSavings,
120
129
)
121
130
}
122
131
}
123
132
124
133
fun NavGraphBuilder.savingsAccountActivateScreen (
125
- onBackPressed : () -> Unit
134
+ onBackPressed : () -> Unit ,
126
135
) {
127
136
composable(
128
137
route = SavingsScreens .SavingsAccountActivate .route,
129
138
arguments = listOf (
130
- navArgument(name = Constants .SAVINGS_ACCOUNT_ID , builder = { type = NavType .IntType })
131
- )
139
+ navArgument(name = Constants .SAVINGS_ACCOUNT_ID , builder = { type = NavType .IntType }),
140
+ ),
132
141
) {
133
142
SavingsAccountActivateScreen (
134
- navigateBack = onBackPressed
143
+ navigateBack = onBackPressed,
135
144
)
136
145
}
137
146
}
138
147
139
148
fun NavGraphBuilder.savingsAccountApprovalScreen (
140
- onBackPressed : () -> Unit
149
+ onBackPressed : () -> Unit ,
141
150
) {
142
151
composable(
143
152
route = SavingsScreens .SavingsAccountApproval .route,
144
153
arguments = listOf (
145
- navArgument(name = Constants .SAVINGS_ACCOUNT_ID , builder = { type = NavType .IntType })
146
- )
154
+ navArgument(name = Constants .SAVINGS_ACCOUNT_ID , builder = { type = NavType .IntType }),
155
+ ),
147
156
) {
148
157
SavingsAccountApprovalScreen (
149
- navigateBack = onBackPressed
158
+ navigateBack = onBackPressed,
150
159
)
151
160
}
152
161
}
153
162
154
163
fun NavGraphBuilder.savingsAccountTransactionScreen (
155
- onBackPressed : () -> Unit
164
+ onBackPressed : () -> Unit ,
156
165
) {
157
166
composable(
158
167
route = SavingsScreens .SavingsAccountTransaction .route,
159
168
arguments = listOf (
160
- navArgument(name = " arg" , builder = { type = NavType .StringType })
161
- )
169
+ navArgument(name = " arg" , builder = { type = NavType .StringType }),
170
+ ),
162
171
) {
163
172
SavingsAccountTransactionScreen (
164
- navigateBack = onBackPressed
173
+ navigateBack = onBackPressed,
165
174
)
166
175
}
167
176
}
168
177
169
178
fun NavController.navigateToAddSavingsAccount (
170
179
groupId : Int ,
171
180
clientId : Int ,
172
- isGroupAccount : Boolean
181
+ isGroupAccount : Boolean ,
173
182
) {
174
183
navigate(SavingsScreens .SavingsAccount .argument(groupId, clientId, isGroupAccount))
175
184
}
@@ -182,20 +191,20 @@ fun NavController.navigateToSavingsAccountActivate(savingsAccountId: Int) {
182
191
navigate(SavingsScreens .SavingsAccountActivate .argument(savingsAccountId))
183
192
}
184
193
185
- fun NavController.navigateToSavingsAccountSummaryScreen (id : Int , type : DepositType ){
194
+ fun NavController.navigateToSavingsAccountSummaryScreen (id : Int , type : DepositType ) {
186
195
navigate(SavingsScreens .SavingsAccountSummary .argument(id, type))
187
196
}
188
197
189
198
fun NavController.navigateToSavingsAccountTransactionScreen (
190
199
savingsAccountWithAssociations : SavingsAccountWithAssociations ,
191
200
transactionType : String ,
192
- depositType : DepositType ?
201
+ depositType : DepositType ? ,
193
202
) {
194
203
navigate(
195
204
SavingsScreens .SavingsAccountTransaction .argument(
196
205
savingsAccountWithAssociations,
197
206
transactionType,
198
- depositType
199
- )
207
+ depositType,
208
+ ),
200
209
)
201
- }
210
+ }
0 commit comments