|
| 1 | +package com.example |
| 2 | + |
| 3 | +import androidx.compose.foundation.background |
| 4 | +import androidx.compose.foundation.border |
| 5 | +import androidx.compose.foundation.layout.* |
| 6 | +import androidx.compose.foundation.rememberScrollState |
| 7 | +import androidx.compose.foundation.shape.CircleShape |
| 8 | +import androidx.compose.foundation.shape.RoundedCornerShape |
| 9 | +import androidx.compose.foundation.verticalScroll |
| 10 | +import androidx.compose.material.icons.Icons |
| 11 | +import androidx.compose.material.icons.automirrored.filled.ArrowBack |
| 12 | +import androidx.compose.material.icons.filled.* |
| 13 | +import androidx.compose.material3.* |
| 14 | +import androidx.compose.runtime.* |
| 15 | +import androidx.compose.ui.Alignment |
| 16 | +import androidx.compose.ui.Modifier |
| 17 | +import androidx.compose.ui.draw.clip |
| 18 | +import androidx.compose.ui.graphics.Brush |
| 19 | +import androidx.compose.ui.graphics.Color |
| 20 | +import androidx.compose.ui.text.font.FontWeight |
| 21 | +import androidx.compose.ui.unit.dp |
| 22 | +import androidx.compose.ui.unit.sp |
| 23 | +import com.example.agristack.AgriStackPassportEngine |
| 24 | +import com.example.ui.theme.* |
| 25 | + |
| 26 | +@Composable |
| 27 | +fun AgriStackPassportScreen(onNavigateBack: () -> Unit) { |
| 28 | + val scrollState = rememberScrollState() |
| 29 | + val passport = remember { AgriStackPassportEngine.getSovereignPassport() } |
| 30 | + |
| 31 | + Column( |
| 32 | + modifier = Modifier |
| 33 | + .fillMaxSize() |
| 34 | + .background(Brush.verticalGradient(listOf(Color(0xFF10140A), NuKropDark))) |
| 35 | + ) { |
| 36 | + // Header |
| 37 | + Row( |
| 38 | + modifier = Modifier |
| 39 | + .fillMaxWidth() |
| 40 | + .background(Color(0xCC141A0A)) |
| 41 | + .statusBarsPadding() |
| 42 | + .padding(horizontal = 8.dp, vertical = 8.dp), |
| 43 | + verticalAlignment = Alignment.CenterVertically |
| 44 | + ) { |
| 45 | + IconButton(onClick = onNavigateBack) { |
| 46 | + Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back", tint = NuKropText) |
| 47 | + } |
| 48 | + Spacer(Modifier.width(4.dp)) |
| 49 | + Column { |
| 50 | + Text("AgriStack Health Passport", fontSize = 18.sp, fontWeight = FontWeight.Bold, color = NuKropText) |
| 51 | + Text("Sovereign Soil & National Farmer Registry", fontSize = 11.sp, color = NuKropAccent) |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + Column( |
| 56 | + modifier = Modifier |
| 57 | + .weight(1f) |
| 58 | + .verticalScroll(scrollState) |
| 59 | + .padding(start = 16.dp, end = 16.dp, top = 16.dp, bottom = 120.dp), |
| 60 | + verticalArrangement = Arrangement.spacedBy(16.dp) |
| 61 | + ) { |
| 62 | + // Sovereign ID Card |
| 63 | + Box( |
| 64 | + modifier = Modifier |
| 65 | + .fillMaxWidth() |
| 66 | + .clip(RoundedCornerShape(20.dp)) |
| 67 | + .background( |
| 68 | + Brush.linearGradient( |
| 69 | + listOf( |
| 70 | + Color(0xFF1E3A1E), |
| 71 | + Color(0xFF132413), |
| 72 | + NuKropCard |
| 73 | + ) |
| 74 | + ) |
| 75 | + ) |
| 76 | + .border(1.5.dp, NuKropAccent.copy(alpha = 0.5f), RoundedCornerShape(20.dp)) |
| 77 | + .padding(18.dp) |
| 78 | + ) { |
| 79 | + Column { |
| 80 | + Row( |
| 81 | + modifier = Modifier.fillMaxWidth(), |
| 82 | + horizontalArrangement = Arrangement.SpaceBetween, |
| 83 | + verticalAlignment = Alignment.Top |
| 84 | + ) { |
| 85 | + Column { |
| 86 | + Text("GOVERNMENT OF INDIA • AGRI-STACK", fontSize = 10.sp, color = NuKropAccent, fontWeight = FontWeight.ExtraBold) |
| 87 | + Spacer(Modifier.height(4.dp)) |
| 88 | + Text(passport.farmerName, fontSize = 18.sp, fontWeight = FontWeight.Bold, color = NuKropText) |
| 89 | + Text("ID: ${passport.sovereignFarmerId}", fontSize = 12.sp, color = NuKropTextMuted) |
| 90 | + } |
| 91 | + Box( |
| 92 | + modifier = Modifier |
| 93 | + .clip(RoundedCornerShape(8.dp)) |
| 94 | + .background(NuKropBadgeGreen) |
| 95 | + .padding(horizontal = 8.dp, vertical = 4.dp) |
| 96 | + ) { |
| 97 | + Text("PM-KISAN VERIFIED", fontSize = 9.sp, fontWeight = FontWeight.ExtraBold, color = NuKropDark) |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | + Spacer(Modifier.height(14.dp)) |
| 102 | + HorizontalDivider(color = Color(0x30FFFFFF)) |
| 103 | + Spacer(Modifier.height(10.dp)) |
| 104 | + |
| 105 | + Row(Modifier.fillMaxWidth(), Arrangement.SpaceBetween) { |
| 106 | + Column { |
| 107 | + Text("Survey / Khasra No.", fontSize = 10.sp, color = NuKropTextMuted) |
| 108 | + Text(passport.surveyParcelNumber, fontSize = 12.sp, fontWeight = FontWeight.Bold, color = NuKropText) |
| 109 | + } |
| 110 | + Column { |
| 111 | + Text("Land Holding", fontSize = 10.sp, color = NuKropTextMuted) |
| 112 | + Text("${passport.landSizeAcres} Acres", fontSize = 12.sp, fontWeight = FontWeight.Bold, color = NuKropText) |
| 113 | + } |
| 114 | + Column(horizontalAlignment = Alignment.End) { |
| 115 | + Text("Village / District", fontSize = 10.sp, color = NuKropTextMuted) |
| 116 | + Text("${passport.villageName}, ${passport.district}", fontSize = 12.sp, fontWeight = FontWeight.Bold, color = NuKropText) |
| 117 | + } |
| 118 | + } |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + // Algorithmic Agri-Credit Score Gauge |
| 123 | + Box( |
| 124 | + modifier = Modifier |
| 125 | + .fillMaxWidth() |
| 126 | + .clip(RoundedCornerShape(16.dp)) |
| 127 | + .background(NuKropCard) |
| 128 | + .border(1.dp, NuKropBadgeGreen.copy(alpha = 0.3f), RoundedCornerShape(16.dp)) |
| 129 | + .padding(16.dp) |
| 130 | + ) { |
| 131 | + Column { |
| 132 | + Row( |
| 133 | + modifier = Modifier.fillMaxWidth(), |
| 134 | + horizontalArrangement = Arrangement.SpaceBetween, |
| 135 | + verticalAlignment = Alignment.CenterVertically |
| 136 | + ) { |
| 137 | + Text("🏛️ Algorithmic Agri-Credit Score", fontSize = 14.sp, fontWeight = FontWeight.Bold, color = NuKropBadgeGreen) |
| 138 | + Text("${passport.agriCreditScore} / 900", fontSize = 18.sp, fontWeight = FontWeight.ExtraBold, color = NuKropBadgeGreen) |
| 139 | + } |
| 140 | + Spacer(Modifier.height(4.dp)) |
| 141 | + Text(passport.creditRatingTier, fontSize = 11.sp, color = NuKropAccent, fontWeight = FontWeight.SemiBold) |
| 142 | + Spacer(Modifier.height(8.dp)) |
| 143 | + LinearProgressIndicator( |
| 144 | + progress = { (passport.agriCreditScore - 300) / 600f }, |
| 145 | + modifier = Modifier.fillMaxWidth().height(8.dp).clip(RoundedCornerShape(4.dp)), |
| 146 | + color = NuKropBadgeGreen, |
| 147 | + trackColor = Color(0x30FFFFFF) |
| 148 | + ) |
| 149 | + Spacer(Modifier.height(8.dp)) |
| 150 | + Text("Pre-Approved Kisan Credit Card (KCC) Limit: ₹${passport.maxEligibleKccLoanLimit.toInt()}", fontSize = 12.sp, color = NuKropTextDim) |
| 151 | + } |
| 152 | + } |
| 153 | + |
| 154 | + // Digitized Soil Health Card |
| 155 | + Box( |
| 156 | + modifier = Modifier |
| 157 | + .fillMaxWidth() |
| 158 | + .clip(RoundedCornerShape(16.dp)) |
| 159 | + .background(NuKropCard) |
| 160 | + .border(1.dp, Color(0x30FFFFFF), RoundedCornerShape(16.dp)) |
| 161 | + .padding(16.dp) |
| 162 | + ) { |
| 163 | + Column { |
| 164 | + Text("🌱 Digitized Soil Health Card", fontSize = 14.sp, fontWeight = FontWeight.Bold, color = NuKropText) |
| 165 | + Text("Status: ${passport.soilHealthSummary.overallFertilityIndex}", fontSize = 11.sp, color = NuKropBadgeGreen, fontWeight = FontWeight.SemiBold) |
| 166 | + Spacer(Modifier.height(10.dp)) |
| 167 | + |
| 168 | + Row(Modifier.fillMaxWidth(), Arrangement.SpaceBetween) { |
| 169 | + Text("Nitrogen (N): ${passport.soilHealthSummary.nitrogenKgPerHa} kg/ha", fontSize = 11.sp, color = NuKropTextMuted) |
| 170 | + Text("Phosphorus (P): ${passport.soilHealthSummary.phosphorusKgPerHa} kg/ha", fontSize = 11.sp, color = NuKropTextMuted) |
| 171 | + } |
| 172 | + Spacer(Modifier.height(4.dp)) |
| 173 | + Row(Modifier.fillMaxWidth(), Arrangement.SpaceBetween) { |
| 174 | + Text("Potassium (K): ${passport.soilHealthSummary.potassiumKgPerHa} kg/ha", fontSize = 11.sp, color = NuKropTextMuted) |
| 175 | + Text("Soil pH: ${passport.soilHealthSummary.soilPh} (Neutral)", fontSize = 11.sp, color = NuKropTextMuted) |
| 176 | + } |
| 177 | + Spacer(Modifier.height(4.dp)) |
| 178 | + Row(Modifier.fillMaxWidth(), Arrangement.SpaceBetween) { |
| 179 | + Text("Organic Carbon: ${passport.soilHealthSummary.organicCarbonPct}%", fontSize = 11.sp, color = NuKropAccent, fontWeight = FontWeight.Bold) |
| 180 | + Text("Zinc: ${passport.soilHealthSummary.zincPpm} ppm | Iron: ${passport.soilHealthSummary.ironPpm} ppm", fontSize = 11.sp, color = NuKropTextDim) |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | + |
| 185 | + // 1-Click Scheme Matcher |
| 186 | + Text("📜 Matched Government Schemes & Subsidies", fontSize = 14.sp, fontWeight = FontWeight.Bold, color = NuKropText) |
| 187 | + passport.eligibleSchemes.forEach { scheme -> |
| 188 | + Box( |
| 189 | + modifier = Modifier |
| 190 | + .fillMaxWidth() |
| 191 | + .clip(RoundedCornerShape(14.dp)) |
| 192 | + .background(NuKropCard) |
| 193 | + .border(1.dp, NuKropAccent.copy(alpha = 0.2f), RoundedCornerShape(14.dp)) |
| 194 | + .padding(14.dp) |
| 195 | + ) { |
| 196 | + Row( |
| 197 | + modifier = Modifier.fillMaxWidth(), |
| 198 | + horizontalArrangement = Arrangement.SpaceBetween, |
| 199 | + verticalAlignment = Alignment.CenterVertically |
| 200 | + ) { |
| 201 | + Column { |
| 202 | + Text(scheme.schemeName, fontSize = 13.sp, fontWeight = FontWeight.Bold, color = NuKropText) |
| 203 | + Text("${scheme.ministryOrDepartment} • ${scheme.validityYear}", fontSize = 11.sp, color = NuKropTextMuted) |
| 204 | + Text("Direct Benefit: ${scheme.directBenefitAmountFormatted}", fontSize = 12.sp, color = NuKropAccent, fontWeight = FontWeight.SemiBold) |
| 205 | + } |
| 206 | + Box( |
| 207 | + modifier = Modifier |
| 208 | + .clip(RoundedCornerShape(8.dp)) |
| 209 | + .background(NuKropAccent.copy(alpha = 0.15f)) |
| 210 | + .padding(horizontal = 8.dp, vertical = 4.dp) |
| 211 | + ) { |
| 212 | + Text(scheme.applicationStatus, fontSize = 10.sp, color = NuKropAccent, fontWeight = FontWeight.Bold) |
| 213 | + } |
| 214 | + } |
| 215 | + } |
| 216 | + } |
| 217 | + } |
| 218 | + } |
| 219 | +} |
0 commit comments