File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
flipchatApp/src/main/kotlin/xyz/flipchat/app/features/payments
ui/components/src/main/kotlin/com/getcode/ui/components/picker Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,11 @@ internal fun MessageTipPaymentConfirmation(
5353
5454 val resources = LocalResources .current!!
5555
56- val pickerState = rememberPickerState(items = tipOptions, prefix = " ⬢" ) { item ->
56+ val pickerState = rememberPickerState(
57+ items = tipOptions,
58+ prefix = " ⬢" ,
59+ initialIndex = tipOptions.indexOfFirst { it.kin == 5 .kin }
60+ ) { item ->
5761 formatAmountString(
5862 resources = resources,
5963 currency = Currency .Kin ,
Original file line number Diff line number Diff line change @@ -43,18 +43,25 @@ import kotlin.time.Duration.Companion.milliseconds
4343fun <T > rememberPickerState (
4444 items : List <T >,
4545 prefix : String = "",
46+ initialIndex : Int = 0,
4647 labelForItem : (T ) -> String = { item -> item.toString() }
4748): PickerState <T > {
4849
4950 return remember(items, prefix) {
50- PickerState (items, labelForItem, prefix)
51+ PickerState (
52+ items = items,
53+ initialIndex = initialIndex,
54+ labelForItem = labelForItem,
55+ prefix = prefix
56+ )
5157 }
5258}
5359
5460@Immutable
5561data class PickerState <T >(
5662 val items : List <T >,
5763 val labelForItem : (T ) -> String = { item -> item.toString() },
64+ val initialIndex : Int = 0 ,
5865 val prefix : String = " " ,
5966) {
6067 var selectedItem by mutableStateOf<T ?>(null )
@@ -77,7 +84,7 @@ fun <T> Picker(
7784
7885 fun getItem (index : Int ): String = items[index]
7986
80- val listState = rememberLazyListState(initialFirstVisibleItemIndex = 0 )
87+ val listState = rememberLazyListState(initialFirstVisibleItemIndex = state.initialIndex )
8188 val flingBehavior = rememberSnapFlingBehavior(lazyListState = listState)
8289
8390 var itemHeight by remember { mutableStateOf(0 .dp) }
You can’t perform that action at this time.
0 commit comments