-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/ALTAPPS-1042/Fill-blanks-with-sel…
…ect-improvements
- Loading branch information
Showing
212 changed files
with
4,670 additions
and
900 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
source "https://rubygems.org" | ||
ruby "3.1.0" | ||
|
||
gem "fastlane", "2.216.0" | ||
gem "fastlane", "2.217.0" | ||
|
||
eval_gemfile("fastlane/Pluginfile") |
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
78 changes: 78 additions & 0 deletions
78
...lApp/src/main/java/org/hyperskill/app/android/challenge/delegate/ChallengeCardDelegate.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,78 @@ | ||
package org.hyperskill.app.android.challenge.delegate | ||
|
||
import android.app.Activity | ||
import android.content.Context | ||
import android.net.Uri | ||
import android.widget.Toast | ||
import androidx.browser.customtabs.CustomTabsIntent | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.platform.ComposeView | ||
import androidx.fragment.app.FragmentManager | ||
import androidx.lifecycle.compose.collectAsStateWithLifecycle | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import org.hyperskill.app.R | ||
import org.hyperskill.app.android.challenge.ui.ChallengeCard | ||
import org.hyperskill.app.android.core.extensions.openUrl | ||
import org.hyperskill.app.android.core.extensions.setHyperskillColors | ||
import org.hyperskill.app.android.core.view.ui.dialog.CreateMagicLinkLoadingProgressDialogFragment | ||
import org.hyperskill.app.android.core.view.ui.dialog.dismissDialogFragmentIfExists | ||
import org.hyperskill.app.android.core.view.ui.widget.compose.HyperskillTheme | ||
import org.hyperskill.app.challenges.widget.presentation.ChallengeWidgetFeature | ||
import org.hyperskill.app.challenges.widget.view.model.ChallengeWidgetViewState | ||
import org.hyperskill.app.challenges.widget.view.model.isLoadingMagicLink | ||
import ru.nobird.android.view.base.ui.extension.showIfNotExists | ||
|
||
class ChallengeCardDelegate { | ||
private val stateFlow: MutableStateFlow<ChallengeWidgetViewState?> = MutableStateFlow(null) | ||
|
||
fun setup( | ||
composeView: ComposeView, | ||
onNewMessage: (ChallengeWidgetFeature.Message) -> Unit | ||
) { | ||
composeView.setContent { | ||
HyperskillTheme { | ||
val viewState by stateFlow.collectAsStateWithLifecycle() | ||
viewState?.let { actualViewState -> | ||
ChallengeCard(viewState = actualViewState, onNewMessage = onNewMessage) | ||
} | ||
} | ||
} | ||
} | ||
|
||
fun render( | ||
fragmentManager: FragmentManager, | ||
state: ChallengeWidgetViewState | ||
) { | ||
stateFlow.value = state | ||
if (state is ChallengeWidgetViewState.Content && state.isLoadingMagicLink) { | ||
CreateMagicLinkLoadingProgressDialogFragment.newInstance() | ||
.showIfNotExists(fragmentManager, CreateMagicLinkLoadingProgressDialogFragment.TAG) | ||
} else { | ||
fragmentManager.dismissDialogFragmentIfExists(CreateMagicLinkLoadingProgressDialogFragment.TAG) | ||
} | ||
} | ||
|
||
fun handleAction( | ||
context: Context, | ||
activity: Activity, | ||
action: ChallengeWidgetFeature.Action.ViewAction | ||
) { | ||
when (action) { | ||
is ChallengeWidgetFeature.Action.ViewAction.OpenUrl -> { | ||
if (action.shouldOpenInApp) { | ||
val intent = CustomTabsIntent.Builder() | ||
.setHyperskillColors(context) | ||
.build() | ||
intent.launchUrl(activity, Uri.parse(action.url)) | ||
} else { | ||
context.openUrl(action.url) | ||
} | ||
} | ||
ChallengeWidgetFeature.Action.ViewAction.ShowNetworkError -> { | ||
Toast | ||
.makeText(context, R.string.common_error, Toast.LENGTH_SHORT) | ||
.show() | ||
} | ||
} | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...illApp/src/main/java/org/hyperskill/app/android/challenge/ui/AnnouncementChallengeCard.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,79 @@ | ||
package org.hyperskill.app.android.challenge.ui | ||
|
||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.tooling.preview.PreviewParameter | ||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider | ||
import org.hyperskill.app.android.core.view.ui.widget.compose.HyperskillButton | ||
import org.hyperskill.app.android.core.view.ui.widget.compose.HyperskillTheme | ||
import org.hyperskill.app.challenges.widget.view.model.ChallengeWidgetViewState.Content.Announcement | ||
|
||
@Composable | ||
fun AnnouncementChallengeCard( | ||
state: Announcement, | ||
onReloadClick: () -> Unit, | ||
onDescriptionLinkClick: (String) -> Unit, | ||
modifier: Modifier = Modifier | ||
) { | ||
ChallengeScaffold(modifier) { | ||
ChallengeHeader( | ||
title = state.headerData.title, | ||
dateText = state.headerData.formattedDurationOfTime, | ||
imageRes = org.hyperskill.app.android.R.drawable.img_challenge_announcment, | ||
modifier = Modifier.fillMaxWidth() | ||
) | ||
ChallengeDescription( | ||
description = state.headerData.description, | ||
onLinkClick = onDescriptionLinkClick | ||
) | ||
when (val startIn = state.startsInState) { | ||
Announcement.StartsInState.Deadline -> { | ||
HyperskillButton( | ||
onClick = onReloadClick, | ||
modifier = Modifier.fillMaxWidth() | ||
) { | ||
Text( | ||
text = stringResource( | ||
id = org.hyperskill.app.R.string.challenge_widget_reload_button | ||
) | ||
) | ||
} | ||
} | ||
is Announcement.StartsInState.TimeRemaining -> { | ||
ChallengeTimeText(title = startIn.title, subtitle = startIn.subtitle) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private class AnnouncementChallengeCardPreviewProvider : PreviewParameterProvider<Announcement.StartsInState> { | ||
override val values: Sequence<Announcement.StartsInState> | ||
get() = sequenceOf( | ||
Announcement.StartsInState.TimeRemaining( | ||
title = ChallengeCardPreviewValues.TIME_TITLE, | ||
subtitle = ChallengeCardPreviewValues.TIME_SUBTITLE | ||
), | ||
Announcement.StartsInState.Deadline | ||
) | ||
} | ||
|
||
@Preview() | ||
@Composable | ||
private fun AnnouncementChallengeCardPreview( | ||
@PreviewParameter(AnnouncementChallengeCardPreviewProvider::class) startsIn: Announcement.StartsInState | ||
) { | ||
HyperskillTheme { | ||
AnnouncementChallengeCard( | ||
state = Announcement( | ||
headerData = ChallengeCardPreviewValues.headerData, | ||
startsInState = startsIn | ||
), | ||
onReloadClick = {}, | ||
onDescriptionLinkClick = {} | ||
) | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
androidHyperskillApp/src/main/java/org/hyperskill/app/android/challenge/ui/ChallengeCard.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,83 @@ | ||
package org.hyperskill.app.android.challenge.ui | ||
|
||
import androidx.compose.foundation.layout.aspectRatio | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import org.hyperskill.app.R | ||
import org.hyperskill.app.android.core.view.ui.widget.compose.ShimmerLoading | ||
import org.hyperskill.app.android.core.view.ui.widget.compose.WidgetDataLoadingError | ||
import org.hyperskill.app.challenges.widget.presentation.ChallengeWidgetFeature.Message | ||
import org.hyperskill.app.challenges.widget.view.model.ChallengeWidgetViewState | ||
|
||
@Composable | ||
fun ChallengeCard( | ||
viewState: ChallengeWidgetViewState, | ||
onNewMessage: (Message) -> Unit | ||
) { | ||
when (viewState) { | ||
ChallengeWidgetViewState.Idle, ChallengeWidgetViewState.Empty -> { | ||
// no op | ||
} | ||
is ChallengeWidgetViewState.Loading -> { | ||
if (viewState.shouldShowSkeleton) { | ||
ShimmerLoading( | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.aspectRatio(ratio = 0.5f) | ||
) | ||
} | ||
} | ||
ChallengeWidgetViewState.Error -> { | ||
WidgetDataLoadingError( | ||
onRetryClick = { | ||
onNewMessage(Message.RetryContentLoading) | ||
}, | ||
modifier = Modifier.fillMaxWidth(), | ||
title = stringResource(id = R.string.challenge_widget_network_error_text) | ||
) | ||
} | ||
is ChallengeWidgetViewState.Content.Announcement -> { | ||
AnnouncementChallengeCard( | ||
state = viewState, | ||
onReloadClick = { | ||
onNewMessage(Message.DeadlineReachedReloadClicked) | ||
}, | ||
onDescriptionLinkClick = { | ||
onNewMessage(Message.LinkInTheDescriptionClicked(it)) | ||
} | ||
) | ||
} | ||
is ChallengeWidgetViewState.Content.HappeningNow -> { | ||
HappeningNowChallengeCard( | ||
state = viewState, | ||
onReloadClick = { | ||
onNewMessage(Message.DeadlineReachedReloadClicked) | ||
}, | ||
onDescriptionLinkClick = { | ||
onNewMessage(Message.LinkInTheDescriptionClicked(it)) | ||
} | ||
) | ||
} | ||
is ChallengeWidgetViewState.Content.Completed -> { | ||
CompletedChallengeCard( | ||
state = viewState, | ||
onCollectRewardClick = { | ||
onNewMessage(Message.CollectRewardClicked) | ||
} | ||
) | ||
} | ||
is ChallengeWidgetViewState.Content.PartiallyCompleted -> { | ||
PartiallyCompletedChallengeCard( | ||
state = viewState, | ||
onCollectRewardClick = { | ||
onNewMessage(Message.CollectRewardClicked) | ||
} | ||
) | ||
} | ||
is ChallengeWidgetViewState.Content.Ended -> { | ||
NotCompletedChallengeCard(state = viewState) | ||
} | ||
} | ||
} |
Oops, something went wrong.