feat: beter style
This commit is contained in:
@@ -5,6 +5,7 @@ import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Headers
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.Path
|
||||
import retrofit2.http.Query
|
||||
|
||||
interface DarooyabApiService {
|
||||
@@ -20,4 +21,15 @@ interface DarooyabApiService {
|
||||
@Field("autocomplete") searchText: String,
|
||||
@Field("DrugName_pageNumber") pageNumber: Int = 1
|
||||
): String
|
||||
|
||||
|
||||
@GET("{detailUrl}")
|
||||
@Headers(
|
||||
"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
||||
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9",
|
||||
"Accept-Language: en-US,en;q=0.9,fa;q=0.8"
|
||||
)
|
||||
suspend fun getDrugDetail(
|
||||
@Path(value = "detailUrl", encoded = true) detailUrl: String
|
||||
): String
|
||||
}
|
||||
+31
-9
@@ -1,42 +1,52 @@
|
||||
package com.approagency.drug.presentation.components
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.approagency.drug.domain.model.DaroYabSearchResult
|
||||
import com.approagency.drug.domain.model.DrugSearchResult
|
||||
import com.approagency.drug.presentation.common.CustomBox
|
||||
import com.vada.caller.ui.theme.LocalDime
|
||||
import com.vada.caller.ui.theme.dime
|
||||
|
||||
@Composable
|
||||
fun DaroYabSearchResult(
|
||||
drug: DrugSearchResult,
|
||||
onClick: (DrugSearchResult) -> Unit,
|
||||
onClickDetail: (DrugSearchResult) -> Unit,
|
||||
onClickDrugStore:() ->Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val dime = LocalDime.current
|
||||
|
||||
Card(
|
||||
CustomBox (
|
||||
modifier = modifier
|
||||
.padding(bottom = MaterialTheme.dime.sm)
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = dime.xs)
|
||||
.clickable { onClick(drug) },
|
||||
elevation = CardDefaults.cardElevation(defaultElevation = 2.dp),
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = MaterialTheme.colorScheme.surface
|
||||
)
|
||||
.clickable { onClickDetail(drug) },
|
||||
|
||||
) {
|
||||
Row (
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.End
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(dime.lg)
|
||||
modifier = Modifier.padding(dime.lg),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.End
|
||||
) {
|
||||
Text(
|
||||
text = drug.persianName,
|
||||
@@ -56,6 +66,18 @@ fun DaroYabSearchResult(
|
||||
fontSize = 10.sp,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Row(
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
TextButton(onClick = {onClickDetail(drug)} , content = {
|
||||
Text("اطلاعات دارویی")
|
||||
})
|
||||
TextButton(onClick = {onClickDetail(drug)} , content = {
|
||||
Text("موجودی داروخانه")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,10 @@ fun SearchScreen(
|
||||
}
|
||||
}
|
||||
|
||||
Column(modifier = modifier.fillMaxSize().padding(dime.lg)) {
|
||||
Column(modifier = modifier
|
||||
.fillMaxSize()
|
||||
.padding(horizontal = MaterialTheme.dime.md)
|
||||
.padding(top = MaterialTheme.dime.md)) {
|
||||
// Search input
|
||||
CustomTextFilled(
|
||||
value = searchText,
|
||||
@@ -117,13 +120,13 @@ fun SearchScreen(
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Spacer(modifier = Modifier.height(MaterialTheme.dime.md))
|
||||
// Results area
|
||||
when (val currentState = state) {
|
||||
is SearchState.Loading -> {
|
||||
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
androidx.compose.material3.CircularProgressIndicator(
|
||||
CircularProgressIndicator(
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Text(
|
||||
@@ -137,14 +140,15 @@ fun SearchScreen(
|
||||
|
||||
is SearchState.LoadingMore -> {
|
||||
// Show existing items with loading indicator at bottom
|
||||
LazyColumn(state = lazyListState) {
|
||||
LazyColumn(state = lazyListState , modifier = modifier.padding(vertical = MaterialTheme.dime.xs)) {
|
||||
items(currentState.currentItems) { drug ->
|
||||
DaroYabSearchResult(
|
||||
drug = drug,
|
||||
onClick = { selectedDrug ->
|
||||
onClickDetail = { selectedDrug ->println(selectedDrug.detailPageUrl)
|
||||
// Navigate to drug detail
|
||||
// navController.navigate("drug_detail/${selectedDrug.genericId}")
|
||||
}
|
||||
},
|
||||
onClickDrugStore = {}
|
||||
)
|
||||
}
|
||||
item {
|
||||
@@ -161,10 +165,11 @@ fun SearchScreen(
|
||||
items(currentState.drugs) { drug ->
|
||||
DaroYabSearchResult(
|
||||
drug = drug,
|
||||
onClick = { selectedDrug ->
|
||||
onClickDetail = { selectedDrug -> println(selectedDrug.detailPageUrl)
|
||||
// Navigate to drug detail
|
||||
// navController.navigate("drug_detail/${selectedDrug.genericId}")
|
||||
}
|
||||
},
|
||||
onClickDrugStore = {}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user