@@ -7,86 +7,129 @@ import androidx.compose.foundation.rememberScrollState
77import androidx.compose.foundation.shape.RoundedCornerShape
88import androidx.compose.foundation.verticalScroll
99import androidx.compose.material.icons.Icons
10+ import androidx.compose.material.icons.automirrored.filled.ArrowBack
1011import androidx.compose.material.icons.filled.*
1112import androidx.compose.material3.*
1213import androidx.compose.runtime.*
1314import androidx.compose.ui.Alignment
1415import androidx.compose.ui.Modifier
1516import androidx.compose.ui.draw.clip
17+ import androidx.compose.ui.graphics.Brush
1618import androidx.compose.ui.graphics.Color
19+ import androidx.compose.ui.platform.LocalContext
1720import androidx.compose.ui.text.font.FontWeight
1821import androidx.compose.ui.unit.dp
1922import androidx.compose.ui.unit.sp
2023import com.example.ui.theme.*
2124import kotlinx.coroutines.delay
25+ import kotlinx.coroutines.launch
2226
2327@Composable
2428fun LoanScreen (onNavigateBack : () -> Unit ) {
2529 var isAnalyzing by remember { mutableStateOf(false ) }
2630 var showResults by remember { mutableStateOf(false ) }
31+ val context = LocalContext .current
32+ val scope = rememberCoroutineScope()
33+ val lang = LanguageManager .currentLanguage.collectAsState().value
34+
35+ // Get real state from location
36+ var userState by remember { mutableStateOf(" Maharashtra" ) }
37+ LaunchedEffect (Unit ) {
38+ val loc = LocationHelper .getCurrentLocationStateAndMandi(context)
39+ if (loc != null ) userState = loc.first
40+ }
2741
2842 Column (
2943 modifier = Modifier
3044 .fillMaxSize()
31- .background(NuKropDark )
32- .padding(16 .dp)
45+ .background(Brush .verticalGradient(listOf (Color (0xFF0D1208 ), NuKropDark )))
3346 ) {
3447 // Header
35- Row (verticalAlignment = Alignment .CenterVertically ) {
48+ Row (
49+ modifier = Modifier
50+ .fillMaxWidth()
51+ .background(Color (0xCC141A0A ))
52+ .statusBarsPadding()
53+ .padding(horizontal = 8 .dp, vertical = 8 .dp),
54+ verticalAlignment = Alignment .CenterVertically
55+ ) {
3656 IconButton (onClick = onNavigateBack) {
37- Icon (Icons .Default .ArrowBack , contentDescription = " Back" , tint = NuKropText )
57+ Icon (Icons .AutoMirrored .Filled .ArrowBack , contentDescription = " Back" , tint = NuKropText )
58+ }
59+ Spacer (Modifier .width(4 .dp))
60+ Column {
61+ Text (AppStrings .get(" subsidy_title" , lang), fontSize = 20 .sp, fontWeight = FontWeight .Bold , color = NuKropText )
62+ Text (" Real Govt Schemes for $userState " , fontSize = 11 .sp, color = NuKropTextMuted )
3863 }
39- Spacer (Modifier .width(8 .dp))
40- Text (" Government Schemes AI" , fontSize = 20 .sp, fontWeight = FontWeight .Bold , color = NuKropText )
4164 }
4265
43- Spacer (modifier = Modifier .height(24 .dp))
66+ Column (
67+ modifier = Modifier
68+ .weight(1f )
69+ .padding(16 .dp)
70+ ) {
71+ if (! showResults) {
72+ Spacer (Modifier .height(24 .dp))
73+ Text (AppStrings .get(" ai_matcher" , lang), fontSize = 24 .sp, fontWeight = FontWeight .ExtraBold , color = NuKropAccent )
74+ Spacer (Modifier .height(8 .dp))
75+ Text (
76+ " Let AI analyze your farm profile (Size, Crop, State) to instantly find eligible subsidies and loans you are missing." ,
77+ color = NuKropTextMuted ,
78+ lineHeight = 22 .sp
79+ )
4480
45- if (! showResults) {
46- Text (" AI Scheme Matcher" , fontSize = 24 .sp, fontWeight = FontWeight .ExtraBold , color = NuKropAccent )
47- Spacer (Modifier .height(8 .dp))
48- Text (" Let AI analyze your farm profile (Size, Crop, State) to instantly find eligible subsidies and loans you are missing." , color = NuKropTextMuted )
49-
50- Spacer (Modifier .height(32 .dp))
81+ Spacer (Modifier .height(32 .dp))
5182
52- Button (
53- onClick = {
54- isAnalyzing = true
55- } ,
56- modifier = Modifier .fillMaxWidth().height( 60 .dp),
57- colors = ButtonDefaults .buttonColors(containerColor = NuKropAccent )
58- ) {
59- if (isAnalyzing) {
60- CircularProgressIndicator (color = NuKropDark , modifier = Modifier .size( 24 .dp))
61- Spacer ( Modifier .width( 12 .dp) )
62- Text ( " Scanning Gov Databases... " , color = NuKropDark , fontWeight = FontWeight . Bold )
63- } else {
64- Icon ( Icons . Default . Search , contentDescription = null , tint = NuKropDark )
65- Spacer (modifier = Modifier .width( 8 .dp) )
66- Text ( " FIND MY SUBSIDIES " , color = NuKropDark , fontWeight = FontWeight . Bold , fontSize = 16 .sp)
83+ Button (
84+ onClick = { isAnalyzing = true },
85+ modifier = Modifier .fillMaxWidth().height( 60 .dp),
86+ shape = RoundedCornerShape ( 16 .dp) ,
87+ colors = ButtonDefaults .buttonColors(containerColor = NuKropAccent )
88+ ) {
89+ if (isAnalyzing ) {
90+ CircularProgressIndicator (color = NuKropDark , modifier = Modifier .size( 24 .dp), strokeWidth = 2.5 .dp)
91+ Spacer ( Modifier .width( 12 .dp))
92+ Text ( AppStrings .get( " scanning_gov " , lang), color = NuKropDark , fontWeight = FontWeight . Bold )
93+ } else {
94+ Icon ( Icons . Default . Search , contentDescription = null , tint = NuKropDark )
95+ Spacer (modifier = Modifier .width( 8 .dp) )
96+ Text ( AppStrings .get( " find_subsidies " , lang), color = NuKropDark , fontWeight = FontWeight . Bold , fontSize = 16 .sp )
97+ }
6798 }
68- }
6999
70- LaunchedEffect (isAnalyzing) {
71- if (isAnalyzing) {
72- delay(2000 ) // Simulate AI API Call
73- isAnalyzing = false
74- showResults = true
75- }
76- }
77- } else {
78- val stateName = " Maharashtra" // Normally derived from LocationManager
79- val realSubsidies = remember { SubsidiesApiService .getSubsidiesForState(stateName) }
80-
81- Column (Modifier .verticalScroll(rememberScrollState())) {
82- Box (Modifier .clip(RoundedCornerShape (8 .dp)).background(NuKropBadgeGreen .copy(alpha= 0.15f )).padding(8 .dp)) {
83- Text (" ✓ AI Found ${realSubsidies.size} Eligible Schemes for your Farm in $stateName ." , color = NuKropBadgeGreen , fontSize = 12 .sp, fontWeight = FontWeight .Bold )
100+ LaunchedEffect (isAnalyzing) {
101+ if (isAnalyzing) {
102+ delay(2000 )
103+ isAnalyzing = false
104+ showResults = true
105+ }
84106 }
85- Spacer (Modifier .height(16 .dp))
107+ } else {
108+ val realSubsidies = remember(userState) { SubsidiesApiService .getSubsidiesForState(userState) }
86109
87- realSubsidies.forEach { subsidy ->
88- SchemeCard (subsidy.name, subsidy.amount, subsidy.description, Color (0xFF64B5F6 ))
89- Spacer (Modifier .height(12 .dp))
110+ Column (Modifier .verticalScroll(rememberScrollState())) {
111+ Box (
112+ Modifier .fillMaxWidth().clip(RoundedCornerShape (12 .dp))
113+ .background(NuKropBadgeGreen .copy(alpha = 0.12f ))
114+ .border(1 .dp, NuKropBadgeGreen .copy(alpha = 0.3f ), RoundedCornerShape (12 .dp))
115+ .padding(12 .dp)
116+ ) {
117+ Row (verticalAlignment = Alignment .CenterVertically , horizontalArrangement = Arrangement .spacedBy(8 .dp)) {
118+ Icon (Icons .Default .CheckCircle , null , tint = NuKropBadgeGreen , modifier = Modifier .size(20 .dp))
119+ Text (
120+ " AI Found ${realSubsidies.size} Eligible Schemes for your Farm in $userState ." ,
121+ color = NuKropBadgeGreen , fontSize = 13 .sp, fontWeight = FontWeight .Bold
122+ )
123+ }
124+ }
125+ Spacer (Modifier .height(16 .dp))
126+
127+ val colors = listOf (Color (0xFF64B5F6 ), NuKropWarning , NuKropAccent , Color (0xFFBA68C8 ))
128+ realSubsidies.forEachIndexed { index, subsidy ->
129+ SchemeCard (subsidy.name, subsidy.amount, subsidy.description, colors[index % colors.size])
130+ Spacer (Modifier .height(12 .dp))
131+ }
132+ Spacer (Modifier .height(40 .dp))
90133 }
91134 }
92135 }
@@ -100,25 +143,30 @@ fun SchemeCard(title: String, amount: String, desc: String, accent: Color) {
100143 .fillMaxWidth()
101144 .clip(RoundedCornerShape (16 .dp))
102145 .background(NuKropCard )
103- .border(1 .dp, accent.copy(alpha= 0.3f ), RoundedCornerShape (16 .dp))
146+ .border(1 .dp, accent.copy(alpha = 0.3f ), RoundedCornerShape (16 .dp))
104147 .padding(16 .dp)
105148 ) {
106149 Column {
107150 Row (Modifier .fillMaxWidth(), Arrangement .SpaceBetween , Alignment .Top ) {
108- Text (title, fontSize = 16 .sp, fontWeight = FontWeight .Bold , color = NuKropText )
109- Box (Modifier .clip(RoundedCornerShape (4 .dp)).background(accent.copy(alpha= 0.2f )).padding(horizontal= 6 .dp, vertical= 2 .dp)) {
110- Text (amount, color = accent, fontSize = 10 .sp, fontWeight = FontWeight .Bold )
151+ Text (title, fontSize = 15 .sp, fontWeight = FontWeight .Bold , color = NuKropText , modifier = Modifier .weight(1f ))
152+ Spacer (Modifier .width(8 .dp))
153+ Box (Modifier .clip(RoundedCornerShape (8 .dp)).background(accent.copy(alpha = 0.15f )).padding(horizontal = 8 .dp, vertical = 4 .dp)) {
154+ Text (amount, color = accent, fontSize = 11 .sp, fontWeight = FontWeight .Bold )
111155 }
112156 }
113- Spacer (Modifier .height(8 .dp))
114- Text (desc, fontSize = 12 .sp, color = NuKropTextMuted , lineHeight = 18 .sp)
115- Spacer (Modifier .height(12 .dp))
157+ Spacer (Modifier .height(10 .dp))
158+ Text (desc, fontSize = 12 .sp, color = NuKropTextMuted , lineHeight = 19 .sp)
159+ Spacer (Modifier .height(14 .dp))
116160 Button (
117161 onClick = {},
118- modifier = Modifier .fillMaxWidth().height(40 .dp),
119- colors = ButtonDefaults .buttonColors(containerColor = NuKropSurface )
162+ modifier = Modifier .fillMaxWidth().height(42 .dp),
163+ shape = RoundedCornerShape (12 .dp),
164+ colors = ButtonDefaults .buttonColors(containerColor = accent.copy(alpha = 0.15f ))
120165 ) {
121- Text (" Auto-Fill Application" , color = NuKropText , fontSize = 12 .sp)
166+ Row (verticalAlignment = Alignment .CenterVertically , horizontalArrangement = Arrangement .spacedBy(6 .dp)) {
167+ Icon (Icons .Default .Edit , null , tint = accent, modifier = Modifier .size(16 .dp))
168+ Text (" Auto-Fill Application" , color = accent, fontSize = 12 .sp, fontWeight = FontWeight .Bold )
169+ }
122170 }
123171 }
124172 }
0 commit comments