Skip to content

Commit

Permalink
Merge pull request #609 from Automattic/task/410-remove-share-first-l…
Browse files Browse the repository at this point in the history
…ast-story

End of Year: Hide share from first and last story
  • Loading branch information
ashiagr committed Nov 24, 2022
1 parent dab6172 commit 56c7211
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.rememberVectorPainter
Expand Down Expand Up @@ -206,7 +207,8 @@ private fun StoriesView(
}
requireNotNull(onCaptureBitmap).let {
ShareButton(
onClick = { onShareClicked.invoke(it) }
onClick = { if (state.showShare) { onShareClicked.invoke(it) } },
modifier = modifier.alpha(if (state.showShare) 1f else 0f)
)
}
}
Expand Down Expand Up @@ -259,6 +261,7 @@ private fun StorySharableContent(
@Composable
private fun ShareButton(
onClick: () -> Unit,
modifier: Modifier,
) {
RowOutlinedButton(
text = stringResource(id = LR.string.share),
Expand All @@ -271,7 +274,9 @@ private fun ShareButton(
textIcon = rememberVectorPainter(Icons.Default.Share),
onClick = {
onClick.invoke()
}
},
modifier = modifier

)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import au.com.shiftyjelly.pocketcasts.endofyear.ShareableTextProvider.ShareTextD
import au.com.shiftyjelly.pocketcasts.endofyear.StoriesViewModel.State.Loaded.SegmentsData
import au.com.shiftyjelly.pocketcasts.repositories.endofyear.EndOfYearManager
import au.com.shiftyjelly.pocketcasts.repositories.endofyear.stories.Story
import au.com.shiftyjelly.pocketcasts.repositories.endofyear.stories.StoryEpilogue
import au.com.shiftyjelly.pocketcasts.repositories.endofyear.stories.StoryIntro
import au.com.shiftyjelly.pocketcasts.utils.FileUtilWrapper
import au.com.shiftyjelly.pocketcasts.utils.SentryHelper
import au.com.shiftyjelly.pocketcasts.utils.log.LogBuffer
Expand Down Expand Up @@ -142,6 +144,7 @@ class StoriesViewModel @Inject constructor(

fun onRetryClicked() {
viewModelScope.launch {
analyticsTracker.track(AnalyticsEvent.END_OF_YEAR_STORY_RETRY_BUTTON_TAPPED)
loadStories()
}
}
Expand Down Expand Up @@ -204,6 +207,8 @@ class StoriesViewModel @Inject constructor(
val segmentsData: SegmentsData,
val preparingShareText: Boolean = false,
) : State() {
val showShare: Boolean
get() = currentStory !is StoryIntro && currentStory !is StoryEpilogue
data class SegmentsData(
val widths: List<Float> = emptyList(),
val xStartOffsets: List<Float> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,5 @@ enum class AnalyticsEvent(val key: String) {
END_OF_YEAR_STORY_SHOWN("end_of_year_story_shown"),
END_OF_YEAR_STORY_SHARE("end_of_year_story_share"),
END_OF_YEAR_STORY_SHARED("end_of_year_story_shared"),
END_OF_YEAR_STORY_RETRY_BUTTON_TAPPED("end_of_year_story_retry_button_tapped"),
}

0 comments on commit 56c7211

Please sign in to comment.