-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Medicine information panel now can be rotated.
- Loading branch information
1 parent
93ce599
commit e10baaa
Showing
4 changed files
with
138 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...rc/main/kotlin/pt/ulisboa/ist/pharmacist/ui/screens/medicine/components/MedicineHeader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package pt.ulisboa.ist.pharmacist.ui.screens.medicine.components | ||
|
||
import android.content.res.Configuration | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.rounded.NotificationsActive | ||
import androidx.compose.material.icons.rounded.NotificationsOff | ||
import androidx.compose.material3.Icon | ||
import androidx.compose.material3.IconButton | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalConfiguration | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import pt.ulisboa.ist.pharmacist.R | ||
import pt.ulisboa.ist.pharmacist.domain.medicines.Medicine | ||
import pt.ulisboa.ist.pharmacist.ui.screens.shared.components.MeteredAsyncImage | ||
|
||
@Composable | ||
fun MedicineHeader( | ||
medicine: Medicine, | ||
toggleMedicineNotification: () -> Unit, | ||
notificationsActive: Boolean | ||
) { | ||
val isLandscape = | ||
LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE | ||
|
||
Column( | ||
horizontalAlignment = Alignment.CenterHorizontally, | ||
modifier = Modifier.fillMaxWidth(if (isLandscape) 0.5f else 1f) | ||
) { | ||
MeteredAsyncImage( | ||
url = medicine.boxPhotoUrl, | ||
contentDescription = stringResource(R.string.medicine_boxPhoto_description), | ||
modifier = Modifier | ||
.fillMaxWidth(if (isLandscape) 0.5f else 0.6f) | ||
.padding(top = 16.dp) | ||
) | ||
|
||
Text( | ||
text = medicine.name, | ||
style = MaterialTheme.typography.titleLarge, | ||
modifier = Modifier.padding(8.dp), | ||
) | ||
|
||
Text( | ||
text = medicine.description, | ||
style = MaterialTheme.typography.bodyLarge | ||
) | ||
|
||
IconButton( | ||
modifier = Modifier, | ||
onClick = toggleMedicineNotification, | ||
) { | ||
Icon( | ||
if (notificationsActive) Icons.Rounded.NotificationsActive else Icons.Rounded.NotificationsOff, | ||
contentDescription = stringResource(R.string.medicine_addToNotifications_button_description), | ||
tint = MaterialTheme.colorScheme.primary | ||
) | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...n/kotlin/pt/ulisboa/ist/pharmacist/ui/screens/medicine/components/MedicinePharmacyList.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package pt.ulisboa.ist.pharmacist.ui.screens.medicine.components | ||
|
||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.unit.dp | ||
import androidx.paging.compose.LazyPagingItems | ||
import pt.ulisboa.ist.pharmacist.R | ||
import pt.ulisboa.ist.pharmacist.domain.pharmacies.Pharmacy | ||
import pt.ulisboa.ist.pharmacist.service.http.services.pharmacies.models.getPharmacyById.PharmacyWithUserDataModel | ||
|
||
@Composable | ||
fun MedicinePharmacyList( | ||
pharmacies: LazyPagingItems<PharmacyWithUserDataModel>, | ||
onPharmacyClick: (Pharmacy) -> Unit | ||
) { | ||
Column( | ||
horizontalAlignment = Alignment.CenterHorizontally | ||
) { | ||
Text( | ||
text = if (pharmacies.itemCount != 1) stringResource( | ||
R.string.medicine_availableInXPharmacies_text, | ||
pharmacies.itemCount | ||
) else | ||
stringResource(R.string.medicine_availableIn1Pharmacy_text), | ||
style = MaterialTheme.typography.bodyMedium, | ||
modifier = Modifier | ||
.padding(8.dp) | ||
) | ||
LazyColumn( | ||
modifier = Modifier | ||
.padding(10.dp) | ||
) { | ||
items(pharmacies.itemCount) { index -> | ||
val pharmacy = pharmacies[index]!! | ||
MedicinePharmacyEntry( | ||
pharmacy, | ||
onPharmacyClick = onPharmacyClick | ||
) | ||
} | ||
} | ||
} | ||
} |