Quote List Component

The quote list reacts to the booking status and automatically fetches quotes that the user may book.

Sandbox quotes returned inside the quote list componentSandbox quotes returned inside the quote list component

Sandbox quotes returned inside the quote list component

📘

Quote list input/output

The quote list turns a pickup, drop off and date into a bookable quote. This is the quote the user selects from the list UI.

iOS Sample

// A scrollable list of quotes based on the set booking details
    private lazy var quoteList: QuoteListView = {
        let quoteList = KarhooUI.components.quoteList()
        quoteList.set(quoteListActions: self)
        return quoteList
    }()

Once the quote list has been added to a container view it will update the following delegate methods when a user selects a quote or if there is / is not availability in the requested pickup / drop off points.

// Quote list component output
extension YourController: QuoteListActions {
    func quotesAvailabilityDidUpdate(availability: Bool) {
        print("quotesAvailabilityDidUpdate: ", availability)
    }

    func didSelectQuote(_ quote: Quote) {
        print("user did select quote: \(quote)")
    }
}

The quote list booking details are either updated through the address bar component or they can be manually changed by manipulating the KarhooBookingStatus publisher

KarhooBookingStatus.shared.set(pickup: LocationInfo())
KarhooBookingStatus.shared.set(destination: LocationInfo())
KarhooBookingStatus.shared.set(prebookDate: Date?)

You can use latitude and longitude to construct a LocationInfo object. see the documentation for that heresee the documentation for that here

Android Sample

Add the View to your layout

<com.karhoo.uisdk.screen.booking.quotes.QuotesListView
        android:id="@+id/quotes_list_widget"
        android:layout_width="0dp"
        android:layout_height="@dimen/collapsible_pane_expanded_height"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

Initialise the View in your Activity or Fragment. Example shown below is for a Fragment.

private lateinit var bookingQuotesViewModel: BookingQuotesViewModel
private lateinit var bookingStatusStateViewModel: BookingStatusStateViewModel
  
private var vehiclesObserver: Observer<Resource<QuoteList>>? = null
private var vehiclesObservable: Observable<QuoteList>? = null
  
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)

    // Setup the Quote List Component
    quotes_list_widget.bindViewToData(
        requireActivity(),
        bookingStatusStateViewModel,
        bookingQuotesViewModel
    )
    //Set up the observer for the actions and outputs
    bookingStatusStateViewModel.viewStates().observe(owner, createPlanningObservable())
}
      
private fun createPlanningObservable() =
    androidx.lifecycle.Observer<BookingStatus> {
        cancelVehicleCallback()
    }
}

private fun cancelVehicleCallback() {
    vehiclesObserver?.let { vehiclesObservable?.apply { unsubscribe(it) } }

Initialise the availability in onResume()

override fun onResume() {
    super.onResume()
    quotes_list_widget.initAvailability(requireActivity())
}