-
Notifications
You must be signed in to change notification settings - Fork 986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MBL-1475 Add backing details navigation #2064
Changes from all commits
0994e38
1982375
67c0dae
d4bc908
7131121
9b438e8
ab2e491
615f4ed
8aeb9e9
fbebe9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.kickstarter.features.pledgedprojectsoverview.ui | ||
|
||
import android.os.Bundle | ||
import androidx.activity.addCallback | ||
import androidx.activity.viewModels | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.lifecycle.repeatOnLifecycle | ||
import com.kickstarter.databinding.ActivityBackingDetailsBinding | ||
import com.kickstarter.libs.utils.extensions.getEnvironment | ||
import com.kickstarter.ui.extensions.finishWithAnimation | ||
import com.kickstarter.viewmodels.BackingDetailsViewModel | ||
import kotlinx.coroutines.launch | ||
|
||
class BackingDetailsActivity : AppCompatActivity() { | ||
|
||
private lateinit var binding: ActivityBackingDetailsBinding | ||
private lateinit var viewModelFactory: BackingDetailsViewModel.Factory | ||
private val viewModel: BackingDetailsViewModel by viewModels { viewModelFactory } | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityBackingDetailsBinding.inflate(layoutInflater) | ||
|
||
this.getEnvironment()?.let { env -> | ||
viewModelFactory = BackingDetailsViewModel.Factory(env, intent = intent) | ||
env | ||
} | ||
|
||
setContentView(binding.root) | ||
|
||
lifecycleScope.launch { | ||
repeatOnLifecycle(Lifecycle.State.STARTED) { | ||
viewModel.url.collect { url -> | ||
binding.webView.loadUrl(url) | ||
} | ||
} | ||
} | ||
|
||
this.onBackPressedDispatcher.addCallback { | ||
finishWithAnimation() | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,8 @@ private fun PledgedProjectsOverviewScreenPreview() { | |
totalAlerts = 10, | ||
onBackPressed = {}, | ||
onAddressConfirmed = {}, | ||
onCardClick = {}, | ||
onProjectPledgeSummaryClick = {}, | ||
onSendMessageClick = {}, | ||
errorSnackBarHostState = SnackbarHostState() | ||
) | ||
|
@@ -72,6 +74,8 @@ fun PledgedProjectsOverviewScreen( | |
errorSnackBarHostState: SnackbarHostState, | ||
ppoCards: LazyPagingItems<PPOCardDataMock>, | ||
totalAlerts: Int = 0, | ||
onCardClick: () -> Unit, | ||
onProjectPledgeSummaryClick: (backingDetailsUrl: String) -> Unit, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
onSendMessageClick: (projectName: String) -> Unit | ||
) { | ||
val openConfirmAddressAlertDialog = remember { mutableStateOf(false) } | ||
|
@@ -129,6 +133,7 @@ fun PledgedProjectsOverviewScreen( | |
PPOCardView( | ||
viewType = it.viewType, | ||
onCardClick = { }, | ||
onProjectPledgeSummaryClick = { onProjectPledgeSummaryClick(it.backingDetailsUrl) }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @leighdouglas Here's where we pass the backingDetailsUrl from the PPO card when user clicks on the tap area. |
||
projectName = it.projectName, | ||
pledgeAmount = it.pledgeAmount, | ||
imageUrl = it.imageUrl, | ||
|
@@ -196,5 +201,6 @@ data class PPOCardDataMock( | |
val showBadge: Boolean = true, | ||
val onActionButtonClicked: () -> Unit = {}, | ||
val onSecondaryActionButtonClicked: () -> Unit = {}, | ||
val timeNumberForAction: Int = 25 | ||
val timeNumberForAction: Int = 25, | ||
val backingDetailsUrl: String = "https://www.kickstarter.com/projects/thehoneycouple/the-honey-couples-building-expansion" | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.kickstarter.viewmodels | ||
|
||
import android.content.Intent | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.ViewModelProvider | ||
import androidx.lifecycle.viewModelScope | ||
import com.kickstarter.libs.Environment | ||
import com.kickstarter.ui.IntentKey | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.SharingStarted | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.flow.stateIn | ||
import kotlinx.coroutines.launch | ||
|
||
class BackingDetailsViewModel(environment: Environment, private val intent: Intent? = null) : ViewModel() { | ||
|
||
private var mutableUrl = MutableStateFlow<String>("") | ||
val url: StateFlow<String> | ||
get() = mutableUrl.asStateFlow() | ||
.stateIn( | ||
scope = viewModelScope, | ||
started = SharingStarted.WhileSubscribed(), | ||
initialValue = "" | ||
) | ||
init { | ||
viewModelScope.launch { | ||
intent?.getStringExtra(IntentKey.URL)?.let { url -> | ||
mutableUrl.emit(url) | ||
} | ||
} | ||
} | ||
|
||
class Factory(private val environment: Environment, private val intent: Intent? = null) : ViewModelProvider.Factory { | ||
override fun <T : ViewModel> create(modelClass: Class<T>): T { | ||
return BackingDetailsViewModel(environment, intent) as T | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.coordinatorlayout.widget.CoordinatorLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<com.google.android.material.appbar.AppBarLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<com.kickstarter.ui.toolbars.KSToolbar | ||
android:id="@+id/web_view_toolbar" | ||
style="@style/Toolbar" | ||
app:contentInsetLeft="0dp" | ||
app:contentInsetStart="0dp"> | ||
|
||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center_vertical" | ||
android:orientation="horizontal"> | ||
|
||
<com.kickstarter.ui.views.IconButton | ||
android:id="@+id/back_button" | ||
style="@style/ToolbarIconBackButton" /> | ||
|
||
<TextView | ||
android:id="@+id/title_text_view" | ||
style="@style/ToolbarTitle" | ||
android:text="@string/backing_details_fpo" /> | ||
|
||
</RelativeLayout> | ||
|
||
</com.kickstarter.ui.toolbars.KSToolbar> | ||
|
||
</com.google.android.material.appbar.AppBarLayout> | ||
|
||
<com.kickstarter.ui.views.KSWebView | ||
android:id="@+id/web_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> | ||
|
||
</androidx.coordinatorlayout.widget.CoordinatorLayout> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,7 @@ | |
<!-- PPO Mock Strings --> | ||
<string name="project_alerts_fpo">Project Alerts</string> | ||
<string name="alerts_fpo">Alerts (%1$s)</string> | ||
<string name="address_confirmed_snackbar_text">Address confirmed! Need to change your address before it locks? Visit your backing details on our website.</string> | ||
<string name="address_confirmed_snackbar_text_fpo">Address confirmed! Need to change your address before it locks? Visit your backing details on our website.</string> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I snuck in this tiny string name change unrelated to this ticket because I realized I forgot to add "fpo" to the end of it |
||
<string name="backing_details_fpo">Backing details</string> | ||
|
||
</resources> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉