Skip to content

Commit a345711

Browse files
committed
improve visuals of payment options view
1 parent c564f8b commit a345711

File tree

5 files changed

+49
-11
lines changed

5 files changed

+49
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.34.4]
5+
6+
### Changes
7+
- Improved visuals on PaymentOptionsView
8+
49
## [0.34.3]
510

611
### Fixed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ allprojects {
2929
}
3030

3131
project.ext {
32-
sdkVersion='0.34.3'
32+
sdkVersion='0.34.4'
3333
versionCode=1
3434

3535
compileSdkVersion=30

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

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ open class PaymentOptionsView @JvmOverloads constructor(
4040
recyclerView.adapter = adapter
4141
recyclerView.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
4242
recyclerView.itemAnimator = null
43-
val dividerItemDecoration = DividerItemDecoration(context, LinearLayoutManager.VERTICAL)
44-
recyclerView.addItemDecoration(dividerItemDecoration)
4543
adapter.submitList(getEntries())
4644

4745
val listener = PaymentCredentialsStore.Callback {
@@ -110,6 +108,12 @@ open class PaymentOptionsView @JvmOverloads constructor(
110108
it.type == PaymentCredentials.Type.PAYDIREKT
111109
}
112110

111+
if (globalList.size > 0) {
112+
globalList.add(
113+
Entry(isDivider = true)
114+
)
115+
}
116+
113117
globalList.add(
114118
Entry(
115119
text = "Paydirekt",
@@ -137,13 +141,19 @@ open class PaymentOptionsView @JvmOverloads constructor(
137141

138142
projectsWithCreditCards
139143
.filter { it.brand == null }
140-
.forEach { project ->
144+
.forEachIndexed { i, project ->
141145
val count = credentials.count {
142146
it.appId == Snabble.getInstance().config.appId &&
143147
it.type == PaymentCredentials.Type.CREDIT_CARD_PSD2 &&
144148
it.projectId == project.id
145149
}
146150

151+
if (i > 0) {
152+
projectList.add(
153+
Entry(isDivider = true)
154+
)
155+
}
156+
147157
projectList.add(
148158
Entry(
149159
text = project.name,
@@ -251,13 +261,16 @@ open class PaymentOptionsView @JvmOverloads constructor(
251261

252262
data class Entry(
253263
val isSectionHeader: Boolean = false,
254-
val text: String,
264+
val isDivider: Boolean = false,
265+
val text: String? = null,
255266
val count: Int = 0,
256267
val icon: Int? = null,
257268
val project: Project? = null,
258269
val click: OnClickListener? = null,
259270
)
260271

272+
class DividerViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
273+
261274
class HeaderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
262275
val text: TextView = itemView.findViewById(R.id.text)
263276
}
@@ -272,15 +285,28 @@ open class PaymentOptionsView @JvmOverloads constructor(
272285
companion object {
273286
const val SECTION_HEADER = 0
274287
const val ENTRY = 1
288+
const val DIVIDER = 2
275289
}
276290
override fun getItemViewType(position: Int): Int {
277-
return if (getItem(position).isSectionHeader) SECTION_HEADER else ENTRY
291+
val item = getItem(position)
292+
return when {
293+
item.isSectionHeader -> {
294+
SECTION_HEADER
295+
}
296+
item.isDivider -> {
297+
DIVIDER
298+
}
299+
else -> {
300+
ENTRY
301+
}
302+
}
278303
}
279304

280305
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
281306
val inflater = LayoutInflater.from(parent.context)
282307
return when(viewType) {
283308
SECTION_HEADER -> HeaderViewHolder(inflater.inflate(R.layout.snabble_item_payment_options_header, parent, false))
309+
DIVIDER -> DividerViewHolder(inflater.inflate(R.layout.snabble_divider, parent, false))
284310
else -> EntryViewHolder(inflater.inflate(R.layout.snabble_item_payment_options_entry, parent, false))
285311
}
286312
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<View xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="0.5dp"
5+
android:background="?android:attr/listDivider" />

ui/src/main/res/layout/snabble_item_payment_options_entry.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
android:layout_width="match_parent"
77
android:layout_height="wrap_content">
88
<ImageView
9-
android:layout_width="wrap_content"
10-
android:layout_height="wrap_content"
11-
android:minWidth="24dp"
9+
android:layout_width="36dp"
10+
android:layout_height="36dp"
1211
android:layout_gravity="center_vertical"
13-
android:scaleType="fitStart"
14-
android:layout_margin="16dp"
12+
android:scaleType="center"
13+
android:layout_marginStart="16dp"
14+
android:layout_marginEnd="16dp"
15+
android:layout_marginTop="8dp"
16+
android:layout_marginBottom="8dp"
1517
android:id="@+id/helper_image"
1618
tools:src="@drawable/snabble_ic_sepa_small" />
1719

0 commit comments

Comments
 (0)