Skip to content

Commit 6e9a723

Browse files
authored
Add new option for the payment options view (APPS-1915) (#249)
1 parent 6fa88ef commit 6e9a723

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
33

44
## UNRELEASED
55
### Added
6+
*ui: Add new headline option for the payment options (APPS-1915)
67
### Changed
78
### Removed
89
### Fixed
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
package io.snabble.sdk.ui.payment
22

3+
import android.os.Bundle
4+
import android.view.View
35
import io.snabble.sdk.ui.BaseFragment
46
import io.snabble.sdk.ui.R
57

68
open class PaymentOptionsFragment : BaseFragment(
79
layoutResId = R.layout.snabble_fragment_payment_options,
810
waitForProject = false
9-
)
11+
) {
12+
companion object {
13+
const val ARG_PAYMENT_OPTIONS_HEADLINE = PaymentOptionsView.ARG_PAYMENT_OPTIONS_HEADLINE
14+
}
15+
16+
override fun onActualViewCreated(view: View, savedInstanceState: Bundle?) {
17+
val v = view as PaymentOptionsView
18+
arguments?.getString(ARG_PAYMENT_OPTIONS_HEADLINE)?.let { v.setHeadline(it) }
19+
}
20+
}

ui/src/main/java/io/snabble/sdk/ui/payment/PaymentOptionsView.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.view.ViewGroup
99
import android.widget.FrameLayout
1010
import android.widget.ImageView
1111
import android.widget.TextView
12+
import androidx.core.view.isVisible
1213
import androidx.lifecycle.Lifecycle
1314
import androidx.lifecycle.LifecycleEventObserver
1415
import androidx.lifecycle.LifecycleOwner
@@ -25,12 +26,15 @@ import io.snabble.sdk.ui.SnabbleUI
2526
import io.snabble.sdk.ui.utils.executeUiAction
2627
import io.snabble.sdk.ui.utils.getFragmentActivity
2728
import io.snabble.sdk.ui.utils.loadAsset
28-
import kotlin.collections.set
2929

3030
open class PaymentOptionsView @JvmOverloads constructor(
3131
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
3232
) : FrameLayout(context, attrs, defStyleAttr) {
3333

34+
companion object {
35+
const val ARG_PAYMENT_OPTIONS_HEADLINE = "headline"
36+
}
37+
3438
init {
3539
inflate(context, R.layout.snabble_payment_options, this)
3640
val recyclerView = findViewById<RecyclerView>(R.id.recycler_view)
@@ -61,6 +65,13 @@ open class PaymentOptionsView @JvmOverloads constructor(
6165
})
6266
}
6367

68+
fun setHeadline(headline: String) {
69+
findViewById<TextView>(R.id.headline).apply {
70+
text = headline
71+
isVisible = true
72+
}
73+
}
74+
6475
private fun getEntries(): List<Entry> {
6576
val projects = Snabble.projects.filter { project ->
6677
project.availablePaymentMethods.count { it.isRequiringCredentials } > 0
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:id="@+id/recycler_view"
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
43
android:layout_width="match_parent"
5-
android:layout_height="match_parent" />
4+
android:layout_height="match_parent"
5+
android:orientation="vertical">
6+
7+
<TextView
8+
android:id="@+id/headline"
9+
style="@style/TextAppearance.Material3.BodyLarge"
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content"
12+
android:paddingHorizontal="16dp"
13+
android:paddingVertical="16dp"
14+
android:textAlignment="center"
15+
android:visibility="gone" />
16+
17+
<androidx.recyclerview.widget.RecyclerView
18+
android:id="@+id/recycler_view"
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content" />
21+
</LinearLayout>

0 commit comments

Comments
 (0)