Skip to content

Commit dfc1287

Browse files
committed
refactor(feature:autopay): remove unused screens and improve ui ux
1 parent 4f0094d commit dfc1287

File tree

11 files changed

+137
-1578
lines changed

11 files changed

+137
-1578
lines changed

cmp-shared/src/commonMain/kotlin/org/mifospay/shared/navigation/MifosNavHost.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,10 @@ import org.mifospay.feature.autopay.navigateToAddBiller
2929
import org.mifospay.feature.autopay.navigateToAutoPay
3030
import org.mifospay.feature.autopay.navigateToAutoPayHistory
3131
import org.mifospay.feature.autopay.navigateToAutoPayPreferences
32-
import org.mifospay.feature.autopay.navigateToAutoPayRules
3332
import org.mifospay.feature.autopay.navigateToAutoPayScheduleDetails
34-
import org.mifospay.feature.autopay.navigateToAutoPaySetup
3533
import org.mifospay.feature.autopay.navigateToBillList
3634
import org.mifospay.feature.autopay.navigateToBillerList
35+
import org.mifospay.feature.autopay.navigateToScheduleManagement
3736
import org.mifospay.feature.editpassword.navigation.editPasswordScreen
3837
import org.mifospay.feature.editpassword.navigation.navigateToEditPassword
3938
import org.mifospay.feature.faq.navigation.faqScreen
@@ -141,11 +140,8 @@ internal fun MifosNavHost(
141140
},
142141
TabContent(PaymentsScreenContents.AUTOPAY.name) {
143142
AutoPayScreen(
144-
onNavigateToSetup = {
145-
navController.navigateToAutoPaySetup()
146-
},
147-
onNavigateToRules = {
148-
navController.navigateToAutoPayRules()
143+
onNavigateToScheduleManagement = {
144+
navController.navigateToScheduleManagement()
149145
},
150146
onNavigateToPreferences = {
151147
navController.navigateToAutoPayPreferences()

feature/autopay/src/commonMain/kotlin/org/mifospay/feature/autopay/AutoPayHistoryScreen.kt

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import androidx.compose.foundation.lazy.LazyColumn
2222
import androidx.compose.foundation.lazy.items
2323
import androidx.compose.material3.Card
2424
import androidx.compose.material3.CardDefaults
25-
import androidx.compose.material3.Divider
25+
import androidx.compose.material3.DividerDefaults
26+
import androidx.compose.material3.HorizontalDivider
2627
import androidx.compose.material3.Icon
2728
import androidx.compose.material3.MaterialTheme
2829
import androidx.compose.material3.Text
@@ -94,6 +95,17 @@ private fun HistoryItemCard(
9495
historyItem: AutoPayHistoryItem,
9596
modifier: Modifier = Modifier,
9697
) {
98+
val statusColor = when (historyItem.status) {
99+
"Completed" -> Color(0xFF4CAF50) // Green color for success
100+
"Failed" -> MaterialTheme.colorScheme.error
101+
null -> when (historyItem.title) {
102+
"Schedule Created" -> MaterialTheme.colorScheme.primary
103+
"Schedule Cancelled" -> MaterialTheme.colorScheme.tertiary
104+
else -> MaterialTheme.colorScheme.primary
105+
}
106+
else -> MaterialTheme.colorScheme.primary
107+
}
108+
97109
Card(
98110
modifier = modifier.fillMaxWidth(),
99111
colors = CardDefaults.cardColors(
@@ -112,7 +124,7 @@ private fun HistoryItemCard(
112124
imageVector = historyItem.icon,
113125
contentDescription = null,
114126
modifier = Modifier.size(24.dp),
115-
tint = historyItem.statusColor,
127+
tint = statusColor,
116128
)
117129

118130
Spacer(modifier = Modifier.size(12.dp))
@@ -153,14 +165,14 @@ private fun HistoryItemCard(
153165
if (historyItem.status != null) {
154166
Spacer(modifier = Modifier.height(8.dp))
155167

156-
Divider()
168+
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
157169

158170
Spacer(modifier = Modifier.height(8.dp))
159171

160172
Text(
161173
text = "Status: ${historyItem.status}",
162174
style = MaterialTheme.typography.bodySmall,
163-
color = historyItem.statusColor,
175+
color = statusColor,
164176
fontWeight = FontWeight.Medium,
165177
)
166178
}
@@ -187,7 +199,7 @@ private fun getDummyHistoryItems(): List<AutoPayHistoryItem> {
187199
date = "Jan 15, 2024",
188200
status = "Completed",
189201
icon = MifosIcons.CheckCircle,
190-
statusColor = Color.Green,
202+
statusColor = Color.Unspecified,
191203
),
192204
AutoPayHistoryItem(
193205
title = "Internet Bill",
@@ -196,7 +208,7 @@ private fun getDummyHistoryItems(): List<AutoPayHistoryItem> {
196208
date = "Jan 10, 2024",
197209
status = "Completed",
198210
icon = MifosIcons.CheckCircle,
199-
statusColor = Color.Green,
211+
statusColor = Color.Unspecified,
200212
),
201213
AutoPayHistoryItem(
202214
title = "Electricity Bill",
@@ -205,7 +217,7 @@ private fun getDummyHistoryItems(): List<AutoPayHistoryItem> {
205217
date = "Jan 5, 2024",
206218
status = "Failed",
207219
icon = MifosIcons.Error,
208-
statusColor = Color.Red,
220+
statusColor = Color.Unspecified,
209221
),
210222
AutoPayHistoryItem(
211223
title = "Phone Bill",
@@ -214,7 +226,7 @@ private fun getDummyHistoryItems(): List<AutoPayHistoryItem> {
214226
date = "Dec 28, 2023",
215227
status = "Completed",
216228
icon = MifosIcons.CheckCircle,
217-
statusColor = Color.Green,
229+
statusColor = Color.Unspecified,
218230
),
219231
AutoPayHistoryItem(
220232
title = "Gym Membership",
@@ -223,7 +235,7 @@ private fun getDummyHistoryItems(): List<AutoPayHistoryItem> {
223235
date = "Dec 20, 2023",
224236
status = "Completed",
225237
icon = MifosIcons.CheckCircle,
226-
statusColor = Color.Green,
238+
statusColor = Color.Unspecified,
227239
),
228240
AutoPayHistoryItem(
229241
title = "Schedule Created",
@@ -232,7 +244,7 @@ private fun getDummyHistoryItems(): List<AutoPayHistoryItem> {
232244
date = "Dec 15, 2023",
233245
status = null,
234246
icon = MifosIcons.Add,
235-
statusColor = Color.Blue,
247+
statusColor = Color.Unspecified,
236248
),
237249
AutoPayHistoryItem(
238250
title = "Schedule Cancelled",
@@ -241,7 +253,7 @@ private fun getDummyHistoryItems(): List<AutoPayHistoryItem> {
241253
date = "Dec 10, 2023",
242254
status = null,
243255
icon = MifosIcons.Cancel,
244-
statusColor = Color.Yellow,
256+
statusColor = Color.Unspecified,
245257
),
246258
)
247259
}

feature/autopay/src/commonMain/kotlin/org/mifospay/feature/autopay/AutoPayNavigation.kt

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ import androidx.navigation.navOptions
2525

2626
object AutoPayNavigation {
2727
const val AUTO_PAY_ROUTE = "autopay_route"
28-
const val AUTO_PAY_SETUP_ROUTE = "autopay_schedule_management_route" // Updated to reflect new purpose
29-
const val AUTO_PAY_SUCCESS_ROUTE = "autopay_success_route"
30-
const val AUTO_PAY_RULES_ROUTE = "autopay_rules_route"
28+
const val AUTO_PAY_SCHEDULE_MANAGEMENT_ROUTE = "autopay_schedule_management_route"
3129
const val AUTO_PAY_PREFERENCES_ROUTE = "autopay_preferences_route"
3230
const val AUTO_PAY_HISTORY_ROUTE = "autopay_history_route"
3331
const val AUTO_PAY_SCHEDULE_DETAILS_ROUTE = "autopay_schedule_details_route"
@@ -77,16 +75,8 @@ fun NavController.navigateToAutoPay(navOptions: NavOptions? = null) {
7775
navigate(AutoPayNavigation.AUTO_PAY_ROUTE, navOptions)
7876
}
7977

80-
fun NavController.navigateToAutoPaySetup(navOptions: NavOptions? = null) {
81-
navigate(AutoPayNavigation.AUTO_PAY_SETUP_ROUTE, navOptions)
82-
}
83-
84-
fun NavController.navigateToAutoPaySuccess(navOptions: NavOptions? = null) {
85-
navigate(AutoPayNavigation.AUTO_PAY_SUCCESS_ROUTE, navOptions)
86-
}
87-
88-
fun NavController.navigateToAutoPayRules(navOptions: NavOptions? = null) {
89-
navigate(AutoPayNavigation.AUTO_PAY_RULES_ROUTE, navOptions)
78+
fun NavController.navigateToScheduleManagement(navOptions: NavOptions? = null) {
79+
navigate(AutoPayNavigation.AUTO_PAY_SCHEDULE_MANAGEMENT_ROUTE, navOptions)
9080
}
9181

9282
fun NavController.navigateToAutoPayPreferences(navOptions: NavOptions? = null) {
@@ -135,11 +125,8 @@ fun NavGraphBuilder.autoPayGraph(
135125
) {
136126
composableWithFadeTransitions(AutoPayNavigation.AUTO_PAY_ROUTE) {
137127
AutoPayScreen(
138-
onNavigateToSetup = {
139-
navController.navigateToAutoPaySetup()
140-
},
141-
onNavigateToRules = {
142-
navController.navigateToAutoPayRules()
128+
onNavigateToScheduleManagement = {
129+
navController.navigateToScheduleManagement()
143130
},
144131
onNavigateToPreferences = {
145132
navController.navigateToAutoPayPreferences()
@@ -167,7 +154,7 @@ fun NavGraphBuilder.autoPayGraph(
167154
)
168155
}
169156

170-
composableWithFadeTransitions(AutoPayNavigation.AUTO_PAY_SETUP_ROUTE) {
157+
composableWithFadeTransitions(AutoPayNavigation.AUTO_PAY_SCHEDULE_MANAGEMENT_ROUTE) {
171158
AutoPayScheduleManagementScreen(
172159
onNavigateBack = onNavigateBack,
173160
onNavigateToAddBill = {
@@ -182,21 +169,6 @@ fun NavGraphBuilder.autoPayGraph(
182169
)
183170
}
184171

185-
composableWithFadeTransitions(AutoPayNavigation.AUTO_PAY_SUCCESS_ROUTE) {
186-
AutoPaySuccessScreen(
187-
onNavigateBack = onNavigateBack,
188-
onNavigateToHome = {
189-
navController.popBackStack(AutoPayNavigation.AUTO_PAY_ROUTE, false)
190-
},
191-
)
192-
}
193-
194-
composableWithFadeTransitions(AutoPayNavigation.AUTO_PAY_RULES_ROUTE) {
195-
AutoPayRulesScreen(
196-
onNavigateBack = onNavigateBack,
197-
)
198-
}
199-
200172
composableWithFadeTransitions(AutoPayNavigation.AUTO_PAY_PREFERENCES_ROUTE) {
201173
AutoPayPreferencesScreen(
202174
onNavigateBack = onNavigateBack,

feature/autopay/src/commonMain/kotlin/org/mifospay/feature/autopay/AutoPayRulesScreen.kt

Lines changed: 0 additions & 180 deletions
This file was deleted.

0 commit comments

Comments
 (0)