Skip to content

Commit 4bc3c8c

Browse files
committed
feat: adapted to the edit top app bar
1 parent 8fc2788 commit 4bc3c8c

File tree

8 files changed

+160
-124
lines changed

8 files changed

+160
-124
lines changed

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ plugins {
3838
alias(libs.plugins.secrets) apply false
3939
alias(libs.plugins.android.library) apply false
4040
alias(libs.plugins.detekt) apply false
41-
alias(libs.plugins.jetbrainsKotlinAndroid) apply false
4241
}

feature/favourite/src/main/kotlin/com/espressodev/gptmap/feature/favourite/FavouriteScreen.kt

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.espressodev.gptmap.feature.favourite
22

3+
import android.util.Log
34
import androidx.compose.foundation.layout.Arrangement
45
import androidx.compose.foundation.layout.Column
56
import androidx.compose.foundation.layout.PaddingValues
@@ -47,7 +48,7 @@ fun FavouriteRoute(
4748
viewModel: FavouriteViewModel = hiltViewModel()
4849
) {
4950
val favourites by viewModel.favourites.collectAsStateWithLifecycle()
50-
51+
Log.d("FavouriteRoute", "favourites: $favourites")
5152
FavouriteScreen(
5253
popUp = popUp,
5354
onCardClick = navigateToMap,
@@ -76,20 +77,27 @@ fun FavouriteScreen(
7677
with(favourites) {
7778
when (this) {
7879
is Response.Success -> {
79-
LazyColumn(
80-
modifier = Modifier
81-
.fillMaxSize()
82-
.padding(it),
83-
verticalArrangement = Arrangement.spacedBy(HIGH_PADDING),
84-
horizontalAlignment = Alignment.CenterHorizontally,
85-
contentPadding = PaddingValues(HIGH_PADDING)
86-
) {
87-
items(data, key = { favourite -> favourite.id }) { favourite ->
88-
FavouriteCard(
89-
favourite = favourite,
90-
onClick = { onCardClick(favourite.favouriteId) }
91-
)
80+
if (data.isNotEmpty()) {
81+
LazyColumn(
82+
modifier = Modifier
83+
.fillMaxSize()
84+
.padding(it),
85+
verticalArrangement = Arrangement.spacedBy(HIGH_PADDING),
86+
horizontalAlignment = Alignment.CenterHorizontally,
87+
contentPadding = PaddingValues(HIGH_PADDING)
88+
) {
89+
items(data, key = { favourite -> favourite.id }) { favourite ->
90+
FavouriteCard(
91+
favourite = favourite,
92+
onClick = { onCardClick(favourite.favouriteId) }
93+
)
94+
}
9295
}
96+
} else {
97+
LottieAnimationPlaceholder(
98+
modifier = Modifier.padding(it),
99+
rawRes = AppRaw.nothing_here_anim
100+
)
93101
}
94102
}
95103

feature/profile/src/main/kotlin/com/espressodev/gptmap/feature/profile/ProfileScreen.kt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import androidx.compose.ui.draw.clip
2727
import androidx.compose.ui.graphics.vector.ImageVector
2828
import androidx.compose.ui.res.stringResource
2929
import androidx.compose.ui.text.style.TextOverflow
30-
import androidx.compose.ui.tooling.preview.Preview
3130
import androidx.compose.ui.unit.dp
3231
import androidx.hilt.navigation.compose.hiltViewModel
3332
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -38,7 +37,6 @@ import com.espressodev.gptmap.core.designsystem.component.GmTonalIconButton
3837
import com.espressodev.gptmap.core.designsystem.component.GmTopAppBar
3938
import com.espressodev.gptmap.core.designsystem.component.LetterInCircle
4039
import com.espressodev.gptmap.core.designsystem.component.LottieAnimationPlaceholder
41-
import com.espressodev.gptmap.core.designsystem.theme.GptmapTheme
4240
import com.espressodev.gptmap.core.model.Response
4341
import com.espressodev.gptmap.core.model.User
4442
import com.espressodev.gptmap.core.designsystem.R.raw as AppRaw
@@ -144,21 +142,3 @@ fun ProfileItem(icon: ImageVector, @StringRes textId: Int, onClick: () -> Unit)
144142
)
145143
}
146144
}
147-
148-
@Preview(showBackground = true)
149-
@Composable
150-
fun ProfilePreview() {
151-
GptmapTheme {
152-
ProfileScreen(
153-
user = User(
154-
userId = "sumo",
155-
fullName = "Selena Beard",
156-
email = "[email protected]",
157-
profilePictureUrl = "https://search.yahoo.com/search?p=vestibulum",
158-
fcmToken = "perpetua",
159-
provider = "iisque"
160-
),
161-
{}, {}, {}
162-
)
163-
}
164-
}

feature/register/src/main/kotlin/com/espressodev/gptmap/feature/register/RegisterScreen.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.espressodev.gptmap.core.designsystem.Constants.TERMS_CONDITIONS
2424
import com.espressodev.gptmap.core.designsystem.Constants.TERMS_CONDITIONS_LINK
2525
import com.espressodev.gptmap.core.designsystem.Constants.VERY_HIGH_PADDING
2626
import com.espressodev.gptmap.core.designsystem.GmIcons
27-
import com.espressodev.gptmap.core.designsystem.component.AppAlertDialog
27+
import com.espressodev.gptmap.core.designsystem.component.GmAlertDialog
2828
import com.espressodev.gptmap.core.designsystem.component.AppWrapper
2929
import com.espressodev.gptmap.core.designsystem.component.DayHeader
3030
import com.espressodev.gptmap.core.designsystem.component.DefaultButton
@@ -37,7 +37,6 @@ import com.espressodev.gptmap.core.designsystem.component.PasswordTextField
3737
import com.espressodev.gptmap.core.google_auth.composable.OneTapLauncher
3838
import com.espressodev.gptmap.core.model.LoadingState
3939
import com.espressodev.gptmap.core.model.google.GoogleResponse
40-
import kotlinx.collections.immutable.immutableMapOf
4140
import kotlinx.collections.immutable.persistentMapOf
4241
import com.espressodev.gptmap.core.designsystem.R.drawable as AppDrawable
4342
import com.espressodev.gptmap.core.designsystem.R.string as AppText
@@ -55,17 +54,19 @@ fun RegisterRoute(
5554
}
5655

5756
uiState.verificationAlertState is LoadingState.Loading -> {
58-
AppAlertDialog(
59-
GmIcons.MarkEmailUnreadOutlined,
60-
AppText.email_confirmation_title,
61-
AppText.email_confirmation_body,
57+
GmAlertDialog(
58+
icon = GmIcons.MarkEmailUnreadOutlined,
59+
title = AppText.email_confirmation_title,
6260
onConfirm = { viewModel.handleVerificationAndNavigate { clearAndNavigateLogin() } },
6361
onDismiss = {
6462
viewModel.onEvent(
6563
RegisterEvent.OnVerificationAlertStateChanged(
6664
LoadingState.Idle
6765
)
6866
)
67+
},
68+
text = {
69+
Text(stringResource(AppText.email_confirmation_body), textAlign = TextAlign.Center)
6970
}
7071
)
7172
}

feature/screenshot-gallery/src/main/kotlin/com/espressodev/gptmap/feature/screenshot_gallery/ScreenshotGalleryScreen.kt

Lines changed: 83 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package com.espressodev.gptmap.feature.screenshot_gallery
22

33
import android.util.Log
4+
import androidx.activity.compose.BackHandler
45
import androidx.compose.animation.core.FastOutSlowInEasing
56
import androidx.compose.animation.core.animateFloatAsState
67
import androidx.compose.animation.core.tween
78
import androidx.compose.foundation.ExperimentalFoundationApi
89
import androidx.compose.foundation.background
910
import androidx.compose.foundation.basicMarquee
11+
import androidx.compose.foundation.border
1012
import androidx.compose.foundation.combinedClickable
1113
import androidx.compose.foundation.layout.Arrangement
1214
import androidx.compose.foundation.layout.Box
13-
import androidx.compose.foundation.layout.BoxScope
1415
import androidx.compose.foundation.layout.Column
1516
import androidx.compose.foundation.layout.PaddingValues
1617
import androidx.compose.foundation.layout.aspectRatio
@@ -28,10 +29,9 @@ import androidx.compose.foundation.pager.HorizontalPager
2829
import androidx.compose.foundation.pager.PagerState
2930
import androidx.compose.foundation.pager.rememberPagerState
3031
import androidx.compose.foundation.shape.CircleShape
32+
import androidx.compose.foundation.shape.RoundedCornerShape
3133
import androidx.compose.material3.Card
32-
import androidx.compose.material3.ElevatedCard
3334
import androidx.compose.material3.ExperimentalMaterial3Api
34-
import androidx.compose.material3.Icon
3535
import androidx.compose.material3.MaterialTheme
3636
import androidx.compose.material3.Scaffold
3737
import androidx.compose.material3.Text
@@ -46,7 +46,9 @@ import androidx.compose.runtime.setValue
4646
import androidx.compose.ui.Alignment
4747
import androidx.compose.ui.Modifier
4848
import androidx.compose.ui.draw.clip
49+
import androidx.compose.ui.draw.shadow
4950
import androidx.compose.ui.graphics.Color
51+
import androidx.compose.ui.graphics.Shape
5052
import androidx.compose.ui.graphics.graphicsLayer
5153
import androidx.compose.ui.platform.LocalDensity
5254
import androidx.compose.ui.text.style.TextAlign
@@ -61,6 +63,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
6163
import com.espressodev.gptmap.core.designsystem.GmIcons
6264
import com.espressodev.gptmap.core.designsystem.IconType
6365
import com.espressodev.gptmap.core.designsystem.TextType
66+
import com.espressodev.gptmap.core.designsystem.component.GmEditAlertDialog
6467
import com.espressodev.gptmap.core.designsystem.component.GmTopAppBar
6568
import com.espressodev.gptmap.core.designsystem.component.LottieAnimationPlaceholder
6669
import com.espressodev.gptmap.core.designsystem.component.ShimmerImage
@@ -90,9 +93,9 @@ fun ScreenshotGalleryRoute(
9093
onBackClick = popUp,
9194
editText = uiState.selectedImageSummary.title,
9295
isInEditMode = uiState.uiIsInEditMode,
93-
onEditClick = viewModel::onEditClick,
94-
onDeleteClick = viewModel::onDeleteClick,
95-
onCancelClick = viewModel::onCancelClick
96+
onEditClick = { viewModel.onEvent(ScreenshotGalleryUiEvent.OnEditClick) },
97+
onDeleteClick = { viewModel.onEvent(ScreenshotGalleryUiEvent.OnDeleteClick) },
98+
onCancelClick = { viewModel.onEvent(ScreenshotGalleryUiEvent.OnCancelClick) }
9699
)
97100
}
98101
) {
@@ -103,15 +106,41 @@ fun ScreenshotGalleryRoute(
103106

104107
Response.Loading -> {}
105108
is Response.Success -> {
106-
ScreenshotGalleryScreen(
107-
modifier = Modifier.padding(it),
108-
images = result.data,
109-
onLongClick = viewModel::onLongClickToImage,
110-
selectedId = uiState.selectedImageSummary.id
111-
)
109+
if (result.data.isNotEmpty()) {
110+
ScreenshotGalleryScreen(
111+
modifier = Modifier.padding(it),
112+
images = result.data,
113+
onLongClick = { imageSummary ->
114+
viewModel.onEvent(
115+
ScreenshotGalleryUiEvent.OnLongClickToImage(imageSummary)
116+
)
117+
},
118+
selectedId = uiState.selectedImageSummary.id
119+
)
120+
} else {
121+
LottieAnimationPlaceholder(
122+
modifier = Modifier.padding(it),
123+
rawRes = AppRaw.nothing_here_anim
124+
)
125+
}
112126
}
113127
}
114128
}
129+
130+
BackHandler {
131+
if (uiState.uiIsInEditMode) {
132+
viewModel.onEvent(ScreenshotGalleryUiEvent.Reset)
133+
}
134+
}
135+
136+
if (uiState.editDialogState) {
137+
GmEditAlertDialog(
138+
title = AppText.screenshot_gallery_edit_dialog_title,
139+
textFieldLabel = AppText.screenshot_gallery_edit_dialog_text_field_placeholder,
140+
onConfirm = { viewModel.onEvent(ScreenshotGalleryUiEvent.OnEditDialogConfirm(it)) },
141+
onDismiss = { viewModel.onEvent(ScreenshotGalleryUiEvent.OnEditDialogDismiss) }
142+
)
143+
}
115144
}
116145

117146
@OptIn(ExperimentalFoundationApi::class)
@@ -157,64 +186,48 @@ fun ScreenshotGalleryScreen(
157186
fun ImageCard(
158187
imageSummary: ImageSummary,
159188
modifier: Modifier = Modifier,
189+
shape: Shape = RoundedCornerShape(16.dp),
160190
isSelected: Boolean = false,
161191
onClick: () -> Unit = {},
162192
onLongClick: () -> Unit = {}
163193
) {
164194
var isImageLoaded by remember { mutableStateOf(value = false) }
195+
val borderStroke = if (isSelected) 3.dp else 0.dp
196+
val elevation = if (isSelected) 8.dp else 0.dp
165197

166-
ElevatedCard(
167-
modifier = modifier.combinedClickable(
168-
onClick = onClick,
169-
onLongClick = onLongClick
170-
)
198+
Box(
199+
modifier = modifier
200+
.shadow(elevation, shape)
201+
.clip(shape)
202+
.border(borderStroke, MaterialTheme.colorScheme.primary, shape)
203+
.combinedClickable(
204+
onClick = onClick,
205+
onLongClick = onLongClick
206+
),
171207
) {
172-
Box {
173-
if (isSelected) {
174-
SelectedIconView()
175-
}
176-
ShimmerImage(
177-
imageSummary.imageUrl,
178-
modifier = Modifier.aspectRatio(1f),
179-
onSuccess = { isImageLoaded = true }
180-
)
181-
if (isImageLoaded)
182-
Box(
183-
modifier = Modifier
184-
.matchParentSize()
185-
.background(brush = darkBottomOverlayBrush)
186-
)
187-
Text(
188-
text = imageSummary.title,
208+
ShimmerImage(
209+
imageSummary.imageUrl,
210+
modifier = Modifier.aspectRatio(1f),
211+
onSuccess = { isImageLoaded = true }
212+
)
213+
if (isImageLoaded)
214+
Box(
189215
modifier = Modifier
190-
.padding(8.dp)
191-
.fillMaxWidth()
192-
.align(Alignment.BottomCenter)
193-
.basicMarquee(iterations = Int.MAX_VALUE),
194-
style = MaterialTheme.typography.titleMedium,
195-
textAlign = TextAlign.Center,
196-
color = Color.White
216+
.matchParentSize()
217+
.background(brush = darkBottomOverlayBrush)
197218
)
198-
}
199-
}
200-
}
201-
202-
@Composable
203-
private fun BoxScope.SelectedIconView() {
204-
Box(
205-
modifier = Modifier.Companion
206-
.matchParentSize()
207-
.zIndex(1f)
208-
) {
209-
Icon(
210-
imageVector = GmIcons.ApproveFilled,
211-
contentDescription = null,
219+
Text(
220+
text = imageSummary.title,
212221
modifier = Modifier
213222
.padding(8.dp)
214-
.size(56.dp)
215-
.align(Alignment.TopEnd),
216-
tint = MaterialTheme.colorScheme.primary
223+
.fillMaxWidth()
224+
.align(Alignment.BottomCenter)
225+
.basicMarquee(iterations = Int.MAX_VALUE),
226+
style = MaterialTheme.typography.titleMedium,
227+
textAlign = TextAlign.Center,
228+
color = Color.White
217229
)
230+
218231
}
219232
}
220233

@@ -342,12 +355,18 @@ fun DotsIndicator(
342355
fun ScreenshotGalleryPreview() {
343356
GptmapTheme {
344357
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
345-
ImageCard(imageSummary = ImageSummary(
346-
id = "debet",
347-
imageUrl = "https://www.google.com/#q=fames",
348-
title = "himenaeos",
349-
date = LocalDateTime.now()
350-
), isSelected = true, onClick = {}, onLongClick = {})
358+
ImageCard(
359+
imageSummary = ImageSummary(
360+
id = "debet",
361+
imageUrl = "https://www.google.com/#q=fames",
362+
title = "himenaeos",
363+
date = LocalDateTime.now()
364+
),
365+
isSelected = true,
366+
onClick = {},
367+
onLongClick = {},
368+
modifier = Modifier.padding(8.dp)
369+
)
351370
}
352371
}
353372
}

feature/screenshot-gallery/src/main/kotlin/com/espressodev/gptmap/feature/screenshot_gallery/ScreenshotGalleryUiState.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,15 @@ import java.time.LocalDateTime
66
data class ScreenshotGalleryUiState(
77
val selectedImageSummary: ImageSummary = ImageSummary(date = LocalDateTime.now()),
88
val uiIsInEditMode: Boolean = false,
9-
)
9+
val editDialogState: Boolean = false,
10+
)
11+
12+
sealed class ScreenshotGalleryUiEvent {
13+
data class OnLongClickToImage(val imageSummary: ImageSummary) : ScreenshotGalleryUiEvent()
14+
data object OnCancelClick : ScreenshotGalleryUiEvent()
15+
data object OnDeleteClick : ScreenshotGalleryUiEvent()
16+
data object OnEditClick : ScreenshotGalleryUiEvent()
17+
data object OnEditDialogDismiss : ScreenshotGalleryUiEvent()
18+
data object Reset: ScreenshotGalleryUiEvent()
19+
data class OnEditDialogConfirm(val text: String) : ScreenshotGalleryUiEvent()
20+
}

0 commit comments

Comments
 (0)