Skip to content

Commit 3989bdc

Browse files
committed
Senior Dev Audit: Fix all compilation issues, remove duplicate worker, add missing translations, align UI
1 parent 8ce21a1 commit 3989bdc

3 files changed

Lines changed: 182 additions & 158 deletions

File tree

app/src/main/java/com/example/AppStrings.kt

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,34 @@ object AppStrings {
3636
"analyzing" to "Analyzing image...",
3737
"chat_placeholder" to "Ask NuKropAI...",
3838
"chat_title" to "NuKropAI Assistant",
39-
"weather_alerts" to "Market & Weather Alerts Active"
39+
"weather_alerts" to "Market & Weather Alerts Active",
40+
"nav_autopilot" to "Autopilot",
41+
"nav_finance" to "Finance",
42+
"good_farmer" to "Good %s, Farmer!",
43+
"quick_actions" to "Quick Actions",
44+
"scan_crop" to "Scan Crop",
45+
"ai_disease" to "AI Disease & Pest Detect",
46+
"scan_soil" to "Scan Soil",
47+
"ai_soil" to "AI Soil Health Analysis",
48+
"market_rates_action" to "Market Rates",
49+
"live_mandi_prices" to "Live Mandi Prices",
50+
"ai_advisor" to "AI Advisor",
51+
"ask_question" to "Ask Any Farm Question",
52+
"loan_subsidy" to "Loan & Subsidy",
53+
"govt_schemes" to "Govt Schemes Matcher",
54+
"field_navigator" to "Field Navigator",
55+
"gps_route" to "GPS Route & Coverage",
56+
"my_tracked" to "My Tracked Prices",
57+
"pest_radar" to "Hyperlocal Pest Prediction AI",
58+
"high_risk" to "HIGH RISK",
59+
"report_outbreak" to "Report Outbreak in My Field",
60+
"outbreak_logged" to "Outbreak logged. Neighboring farmers alerted!",
61+
"ai_tasks" to "AI Task Schedules",
62+
"farm_tips" to "Today's Farm Tips",
63+
"subsidy_title" to "Government Schemes AI",
64+
"ai_matcher" to "AI Scheme Matcher",
65+
"find_subsidies" to "FIND MY SUBSIDIES",
66+
"scanning_gov" to "Scanning Gov Databases..."
4067
),
4168
"hi" to mapOf(
4269
"nav_home" to "होम",
@@ -72,7 +99,34 @@ object AppStrings {
7299
"analyzing" to "छवि का विश्लेषण हो रहा है...",
73100
"chat_placeholder" to "NuKropAI से पूछें...",
74101
"chat_title" to "NuKropAI सहायक",
75-
"weather_alerts" to "बाजार और मौसम अलर्ट सक्रिय"
102+
"weather_alerts" to "बाजार और मौसम अलर्ट सक्रिय",
103+
"nav_autopilot" to "ऑटोपायलट",
104+
"nav_finance" to "वित्त",
105+
"good_farmer" to "शुभ %s, किसान!",
106+
"quick_actions" to "त्वरित कार्य",
107+
"scan_crop" to "फसल स्कैन",
108+
"ai_disease" to "एआई रोग एवं कीट पहचान",
109+
"scan_soil" to "मिट्टी स्कैन",
110+
"ai_soil" to "एआई मिट्टी स्वास्थ्य विश्लेषण",
111+
"market_rates_action" to "बाजार भाव",
112+
"live_mandi_prices" to "लाइव मंडी भाव",
113+
"ai_advisor" to "एआई सलाहकार",
114+
"ask_question" to "कोई भी कृषि प्रश्न पूछें",
115+
"loan_subsidy" to "ऋण एवं सब्सिडी",
116+
"govt_schemes" to "सरकारी योजना मैचर",
117+
"field_navigator" to "खेत नेविगेटर",
118+
"gps_route" to "GPS मार्ग एवं कवरेज",
119+
"my_tracked" to "मेरी ट्रैक की गई कीमतें",
120+
"pest_radar" to "हाइपरलोकल कीट पूर्वानुमान एआई",
121+
"high_risk" to "उच्च जोखिम",
122+
"report_outbreak" to "मेरे खेत में प्रकोप की रिपोर्ट करें",
123+
"outbreak_logged" to "प्रकोप दर्ज किया गया। पड़ोसी किसानों को सूचित किया!",
124+
"ai_tasks" to "एआई कार्य अनुसूची",
125+
"farm_tips" to "आज की कृषि सुझाव",
126+
"subsidy_title" to "सरकारी योजनाएं एआई",
127+
"ai_matcher" to "एआई योजना मैचर",
128+
"find_subsidies" to "मेरी सब्सिडी खोजें",
129+
"scanning_gov" to "सरकारी डेटाबेस स्कैन हो रहा है..."
76130
),
77131
"te" to mapOf(
78132
"nav_home" to "హోమ్",
@@ -108,7 +162,13 @@ object AppStrings {
108162
"analyzing" to "చిత్రాన్ని విశ్లేషిస్తోంది...",
109163
"chat_placeholder" to "NuKropAI ని అడగండి...",
110164
"chat_title" to "NuKropAI సహాయకుడు",
111-
"weather_alerts" to "మార్కెట్ & వాతావరణ హెచ్చరికలు యాక్టివ్‌గా ఉన్నాయి"
165+
"weather_alerts" to "మార్కెట్ & వాతావరణ హెచ్చరికలు యాక్టివ్‌గా ఉన్నాయి",
166+
"nav_autopilot" to "ఆటోపైలట్",
167+
"nav_finance" to "ఫైనాన్స్",
168+
"subsidy_title" to "ప్రభుత్వ పథకాలు AI",
169+
"ai_matcher" to "AI స్కీమ్ మ్యాచర్",
170+
"find_subsidies" to "నా సబ్సిడీలను కనుగొనండి",
171+
"scanning_gov" to "ప్రభుత్వ డేటాబేస్లను స్కాన్ చేస్తోంది..."
112172
),
113173
"ta" to mapOf(
114174
"nav_home" to "முகப்பு",
@@ -144,7 +204,13 @@ object AppStrings {
144204
"analyzing" to "படம் பகுப்பாய்வு செய்யப்படுகிறது...",
145205
"chat_placeholder" to "NuKropAI இடம் கேளுங்கள்...",
146206
"chat_title" to "NuKropAI உதவியாளர்",
147-
"weather_alerts" to "சந்தை மற்றும் வானிலை எச்சரிக்கைகள் செயலில் உள்ளன"
207+
"weather_alerts" to "சந்தை மற்றும் வானிலை எச்சரிக்கைகள் செயலில் உள்ளன",
208+
"nav_autopilot" to "ஆட்டோபைலட்",
209+
"nav_finance" to "நிதி",
210+
"subsidy_title" to "அரசு திட்டங்கள் AI",
211+
"ai_matcher" to "AI திட்ட மேட்சர்",
212+
"find_subsidies" to "எனது மானியங்களைக் கண்டறியுங்கள்",
213+
"scanning_gov" to "அரசு தரவுத்தளங்களை ஸ்கேன் செய்கிறது..."
148214
),
149215
"mr" to mapOf(
150216
"nav_home" to "होम",
@@ -180,7 +246,13 @@ object AppStrings {
180246
"analyzing" to "प्रतिमेचे विश्लेषण करत आहे...",
181247
"chat_placeholder" to "NuKropAI ला विचारा...",
182248
"chat_title" to "NuKropAI सहाय्यक",
183-
"weather_alerts" to "बाजार आणि हवामान सूचना सक्रिय"
249+
"weather_alerts" to "बाजार आणि हवामान सूचना सक्रिय",
250+
"nav_autopilot" to "ऑटोपायलट",
251+
"nav_finance" to "वित्त",
252+
"subsidy_title" to "सरकारी योजना AI",
253+
"ai_matcher" to "AI योजना मॅचर",
254+
"find_subsidies" to "माझे अनुदान शोधा",
255+
"scanning_gov" to "सरकारी डेटाबेस स्कॅन होत आहे..."
184256
)
185257
)
186258

app/src/main/java/com/example/LoanScreen.kt

Lines changed: 105 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,86 +7,129 @@ import androidx.compose.foundation.rememberScrollState
77
import androidx.compose.foundation.shape.RoundedCornerShape
88
import androidx.compose.foundation.verticalScroll
99
import androidx.compose.material.icons.Icons
10+
import androidx.compose.material.icons.automirrored.filled.ArrowBack
1011
import androidx.compose.material.icons.filled.*
1112
import androidx.compose.material3.*
1213
import androidx.compose.runtime.*
1314
import androidx.compose.ui.Alignment
1415
import androidx.compose.ui.Modifier
1516
import androidx.compose.ui.draw.clip
17+
import androidx.compose.ui.graphics.Brush
1618
import androidx.compose.ui.graphics.Color
19+
import androidx.compose.ui.platform.LocalContext
1720
import androidx.compose.ui.text.font.FontWeight
1821
import androidx.compose.ui.unit.dp
1922
import androidx.compose.ui.unit.sp
2023
import com.example.ui.theme.*
2124
import kotlinx.coroutines.delay
25+
import kotlinx.coroutines.launch
2226

2327
@Composable
2428
fun 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

Comments
 (0)