Skip to content

Commit

Permalink
Merge pull request #230 from SwEnt-Group13/chore/use-async-image-wrapper
Browse files Browse the repository at this point in the history
Use AsyncImageWrapper in BannerImagePicker
  • Loading branch information
armouldr authored Dec 5, 2024
2 parents 1211c02 + 8b8c4ee commit e1f2b2d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.net.Uri
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
Expand Down Expand Up @@ -54,16 +53,15 @@ import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.PopupProperties
import coil.compose.rememberAsyncImagePainter
import com.android.unio.R
import com.android.unio.model.association.Association
import com.android.unio.model.map.Location
import com.android.unio.model.map.nominatim.NominatimLocationSearchViewModel
import com.android.unio.model.strings.FormatStrings.DAY_MONTH_YEAR_FORMAT
import com.android.unio.model.strings.FormatStrings.HOUR_MINUTE_FORMAT
import com.android.unio.ui.image.AsyncImageWrapper
import com.google.firebase.Timestamp
import java.text.SimpleDateFormat
import java.util.Date
Expand Down Expand Up @@ -197,20 +195,14 @@ fun BannerImagePicker(eventBannerUri: MutableState<Uri>, modifier: Modifier) {
pickMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
},
contentAlignment = Alignment.Center) {
if (eventBannerUri.value != Uri.EMPTY) {
Image(
painter = rememberAsyncImagePainter(eventBannerUri.value),
contentDescription =
context.getString(R.string.event_creation_selected_image_description),
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop)
} else {
Image(
painter = painterResource(id = R.drawable.adec),
contentDescription =
context.getString(R.string.event_creation_placeholder_image_description),
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop)
AsyncImageWrapper(
eventBannerUri.value,
contentDescription =
context.getString(R.string.event_creation_selected_image_description),
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop,
placeholderResourceId = R.drawable.adec)
if (eventBannerUri.value == Uri.EMPTY) {
Text(
text = context.getString(R.string.event_creation_image_label),
modifier = Modifier.align(Alignment.Center))
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/java/com/android/unio/ui/explore/Explore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,6 @@ fun AssociationItem(association: Association, onClick: () -> Unit) {
placeholderResourceId = R.drawable.adec,
contentScale = ContentScale.Crop)

/**
* The following code is commented out because all images are not available in the Firestore
* database. Uncomment the code when all images are available, and remove the placeholder
* image.
*
* AsyncImage( model = association.image.toUri(), contentDescription =
* context.getString(R.string.explore_content_description_async_image), modifier =
* Modifier.size(124.dp).testTag("associationImage"), contentScale = ContentScale.Crop //
* crop the image to fit )
*/
Spacer(modifier = Modifier.height(8.dp))

Text(
Expand Down

0 comments on commit e1f2b2d

Please sign in to comment.