Skip to content

Commit 236f695

Browse files
committed
Farmer Super-App Upgrade: Add P2P Equipment Rental, 7-Day Mandi Forecast, Digital Farm Khata & Voice Mic Assistant
1 parent cdaee4d commit 236f695

7 files changed

Lines changed: 543 additions & 3 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ object AppStrings {
3939
"weather_alerts" to "Market & Weather Alerts Active",
4040
"nav_autopilot" to "Autopilot",
4141
"nav_finance" to "Finance",
42+
"nav_rental" to "Equipment",
43+
"nav_khata" to "Farm Khata",
4244
"good_farmer" to "Good %s, Farmer!",
4345
"quick_actions" to "Quick Actions",
4446
"scan_crop" to "Scan Crop",
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
package com.example
2+
3+
import android.content.Intent
4+
import android.net.Uri
5+
import androidx.compose.foundation.background
6+
import androidx.compose.foundation.border
7+
import androidx.compose.foundation.clickable
8+
import androidx.compose.foundation.layout.*
9+
import androidx.compose.foundation.rememberScrollState
10+
import androidx.compose.foundation.shape.CircleShape
11+
import androidx.compose.foundation.shape.RoundedCornerShape
12+
import androidx.compose.foundation.verticalScroll
13+
import androidx.compose.material.icons.Icons
14+
import androidx.compose.material.icons.automirrored.filled.ArrowBack
15+
import androidx.compose.material.icons.automirrored.filled.Chat
16+
import androidx.compose.material.icons.filled.*
17+
import androidx.compose.material3.*
18+
import androidx.compose.runtime.*
19+
import androidx.compose.ui.Alignment
20+
import androidx.compose.ui.Modifier
21+
import androidx.compose.ui.draw.clip
22+
import androidx.compose.ui.graphics.Brush
23+
import androidx.compose.ui.graphics.Color
24+
import androidx.compose.ui.platform.LocalContext
25+
import androidx.compose.ui.text.font.FontWeight
26+
import androidx.compose.ui.unit.dp
27+
import androidx.compose.ui.unit.sp
28+
import com.example.ui.theme.*
29+
30+
data class EquipmentItem(
31+
val name: String,
32+
val category: String,
33+
val rate: String,
34+
val owner: String,
35+
val distance: String,
36+
val phone: String,
37+
val isAvailable: Boolean,
38+
val icon: String
39+
)
40+
41+
@Composable
42+
fun EquipmentRentalScreen(
43+
onNavigateBack: () -> Unit,
44+
onNavigateToChat: () -> Unit
45+
) {
46+
val context = LocalContext.current
47+
val scrollState = rememberScrollState()
48+
49+
val equipmentList = remember {
50+
listOf(
51+
EquipmentItem(
52+
name = "Mahindra 575 DI Tractor (45 HP)",
53+
category = "Tractor & Tillage",
54+
rate = "₹450 / Hour",
55+
owner = "Verma Farms (Rajesh Verma)",
56+
distance = "3.2 km away",
57+
phone = "9876543210",
58+
isAvailable = true,
59+
icon = "🚜"
60+
),
61+
EquipmentItem(
62+
name = "DJI Agras T40 Spraying Drone",
63+
category = "Pesticide Drone Spraying",
64+
rate = "₹350 / Acre",
65+
owner = "AgriTech Kisan Co-op",
66+
distance = "5.0 km away",
67+
phone = "9812345678",
68+
isAvailable = true,
69+
icon = "🛸"
70+
),
71+
EquipmentItem(
72+
name = "CLAAS Crop Combine Harvester",
73+
category = "Harvester",
74+
rate = "₹1,200 / Hour",
75+
owner = "Suresh Patel",
76+
distance = "8.5 km away",
77+
phone = "9765432109",
78+
isAvailable = false,
79+
icon = "⚙️"
80+
),
81+
EquipmentItem(
82+
name = "Solar Drip Irrigation Pump (5 HP)",
83+
category = "Irrigation Pump",
84+
rate = "₹150 / Day",
85+
owner = "Ramesh Singh",
86+
distance = "2.1 km away",
87+
phone = "9988776655",
88+
isAvailable = true,
89+
icon = "💧"
90+
)
91+
)
92+
}
93+
94+
Column(
95+
modifier = Modifier
96+
.fillMaxSize()
97+
.background(Brush.verticalGradient(listOf(Color(0xFF0D1208), NuKropDark)))
98+
) {
99+
// Header
100+
Row(
101+
modifier = Modifier
102+
.fillMaxWidth()
103+
.background(Color(0xCC141A0A))
104+
.statusBarsPadding()
105+
.padding(horizontal = 8.dp, vertical = 8.dp),
106+
verticalAlignment = Alignment.CenterVertically
107+
) {
108+
IconButton(onClick = onNavigateBack) {
109+
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back", tint = NuKropText)
110+
}
111+
Spacer(Modifier.width(4.dp))
112+
Column {
113+
Text("P2P Equipment & Drone Rental", fontSize = 18.sp, fontWeight = FontWeight.Bold, color = NuKropText)
114+
Text("Rent nearby tractors, drones & harvesters directly", fontSize = 11.sp, color = NuKropTextMuted)
115+
}
116+
}
117+
118+
Column(
119+
modifier = Modifier
120+
.weight(1f)
121+
.verticalScroll(scrollState)
122+
.padding(16.dp),
123+
verticalArrangement = Arrangement.spacedBy(14.dp)
124+
) {
125+
// Banner
126+
Box(
127+
modifier = Modifier
128+
.fillMaxWidth()
129+
.clip(RoundedCornerShape(16.dp))
130+
.background(NuKropBadgeGreen.copy(alpha = 0.12f))
131+
.border(1.dp, NuKropBadgeGreen.copy(alpha = 0.3f), RoundedCornerShape(16.dp))
132+
.padding(16.dp)
133+
) {
134+
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp)) {
135+
Text("🚜", fontSize = 32.sp)
136+
Column {
137+
Text("Nearby Rental Marketplace", color = NuKropBadgeGreen, fontSize = 14.sp, fontWeight = FontWeight.Bold)
138+
Text("Save 60% machinery cost by renting directly from verified nearby farmers.", color = NuKropTextMuted, fontSize = 11.sp)
139+
}
140+
}
141+
}
142+
143+
equipmentList.forEach { item ->
144+
EquipmentCard(item = item, onChatClick = onNavigateToChat, onCallClick = {
145+
try {
146+
val intent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:${item.phone}"))
147+
context.startActivity(intent)
148+
} catch (_: Exception) {}
149+
})
150+
}
151+
152+
Spacer(Modifier.height(80.dp))
153+
}
154+
}
155+
}
156+
157+
@Composable
158+
fun EquipmentCard(item: EquipmentItem, onChatClick: () -> Unit, onCallClick: () -> Unit) {
159+
Box(
160+
modifier = Modifier
161+
.fillMaxWidth()
162+
.clip(RoundedCornerShape(16.dp))
163+
.background(NuKropCard)
164+
.border(1.dp, if (item.isAvailable) NuKropAccent.copy(alpha = 0.3f) else Color.Gray.copy(alpha = 0.2f), RoundedCornerShape(16.dp))
165+
.padding(16.dp)
166+
) {
167+
Column {
168+
Row(Modifier.fillMaxWidth(), Arrangement.SpaceBetween, Alignment.Top) {
169+
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {
170+
Box(
171+
modifier = Modifier
172+
.size(42.dp)
173+
.clip(CircleShape)
174+
.background(NuKropAccent.copy(alpha = 0.15f)),
175+
contentAlignment = Alignment.Center
176+
) {
177+
Text(item.icon, fontSize = 22.sp)
178+
}
179+
Column {
180+
Text(item.name, fontSize = 14.sp, fontWeight = FontWeight.Bold, color = NuKropText)
181+
Text("${item.category}${item.distance}", fontSize = 11.sp, color = NuKropTextMuted)
182+
}
183+
}
184+
Box(
185+
modifier = Modifier
186+
.clip(RoundedCornerShape(8.dp))
187+
.background(if (item.isAvailable) NuKropBadgeGreen.copy(alpha = 0.15f) else Color.Red.copy(alpha = 0.15f))
188+
.padding(horizontal = 8.dp, vertical = 4.dp)
189+
) {
190+
Text(
191+
if (item.isAvailable) "AVAILABLE" else "BOOKED",
192+
color = if (item.isAvailable) NuKropBadgeGreen else Color.Red,
193+
fontSize = 10.sp,
194+
fontWeight = FontWeight.Bold
195+
)
196+
}
197+
}
198+
199+
Spacer(Modifier.height(12.dp))
200+
201+
Row(Modifier.fillMaxWidth(), Arrangement.SpaceBetween, Alignment.CenterVertically) {
202+
Text(item.rate, fontSize = 16.sp, fontWeight = FontWeight.ExtraBold, color = NuKropAccent)
203+
Text(item.owner, fontSize = 11.sp, color = NuKropTextMuted)
204+
}
205+
206+
Spacer(Modifier.height(14.dp))
207+
208+
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
209+
Button(
210+
onClick = onCallClick,
211+
enabled = item.isAvailable,
212+
modifier = Modifier.weight(1f).height(40.dp),
213+
shape = RoundedCornerShape(10.dp),
214+
colors = ButtonDefaults.buttonColors(containerColor = NuKropAccent.copy(alpha = 0.2f))
215+
) {
216+
Icon(Icons.Default.Phone, null, tint = NuKropAccent, modifier = Modifier.size(14.dp))
217+
Spacer(Modifier.width(6.dp))
218+
Text("Call Owner", color = NuKropAccent, fontSize = 11.sp, fontWeight = FontWeight.Bold)
219+
}
220+
221+
Button(
222+
onClick = onChatClick,
223+
modifier = Modifier.weight(1f).height(40.dp),
224+
shape = RoundedCornerShape(10.dp),
225+
colors = ButtonDefaults.buttonColors(containerColor = NuKropBadgeGreen.copy(alpha = 0.2f))
226+
) {
227+
Icon(Icons.AutoMirrored.Filled.Chat, null, tint = NuKropBadgeGreen, modifier = Modifier.size(14.dp))
228+
Spacer(Modifier.width(6.dp))
229+
Text("Chat / Book", color = NuKropBadgeGreen, fontSize = 11.sp, fontWeight = FontWeight.Bold)
230+
}
231+
}
232+
}
233+
}
234+
}

0 commit comments

Comments
 (0)