In Open Event Orga App (Github Repo), we allow the option to check the attendee details before checking him/her in or out. Originally, a dialog was shown showing the attendee details, which did not contain much information about the attendee, ticket or the order. The disadvantage of such design was also that it was tied to only one view. We couldn’t show the check in dialog elsewhere in the app, like during QR scanning. So we had to switch back to the attendee view for showing the check in dialog. We decided to create a usable detached component in the form of a bottom sheet containing all required information. This blog will outline the procedure we employed to design the bottom sheet UI.
The attendee check in dialog looked like this:
So, first we decide what we need to show on the check in bottom sheet:
- Attendee Name
- Attendee Email
- Attendee Check In Status
- Order Status ( Completed, Pending, etc )
- TIcket Type ( Free, Paid, Donation )
- Ticket Price
- Order Date
- Invoice Number
- Order ‘Paid Via’
As we are using Android Data Binding in our layout, we’ll start by including the variables required in the layout. Besides the obvious attendee variable, we need presenter instance to handle the check in and check out of the attendee and DateUtils class to parse the order date. Additionally, to handle the visibility of views, we need to include the View class too
Then, we make the root layout to be CoordinatorLayout and add a NestedScrollView inside it, which contains a vertical linear layout in it. This vertical linear layout will contain our fields.
Note: For brevity, I’ll skip most of the layout attributes from the blog and only show the ones that correspond to the text
Firstly, we show the attendee name:
The perks of using data binding can be seen here, as we are using string concatenation in layout itself. Furthermore, data binding also handles null checks for us if we add a question mark at the end of the variable name ( attendee.firstName? ).
But our server ensures that both these fields are not null, so we skip that part.
Next up, we display the attendee email
And then the check in status of the attendee
Notice that we dynamically change the color and text based on the check in status of the attendee
Now we begin showing the fields with icons to their left. You can use Compound Drawable to achieve this effect, but we use vector drawables which are incompatible with compound drawables on older versions of Android, so we use a horizontal LinearLayout instead.
The first field is the order status denoting if the order is completed or in transient state
Now, again for keeping the snippets relevant, I’ll skip the icon portion and only show the text binding from now on.
Next, we include the type of ticket attendee has. There are 3 types of ticket supported in Open Event API – free, paid, donation
Next, we want to show the price of the ticket, but only when the ticket is of paid type.
I’ll include the previously omitted LinearLayout part in this snippet because it is the view we control to hide or show the field
As you can see, we are showing this layout only if the ticket type equals paid
The next part is about showing the date on which the order took place
Here we are using internal DateUtils method to format the date into complete date time from the ISO 8601 standard date present in the order object
Now, we show the invoice number of the order
Lastly, we want to show how the ticket was paid for via
Notice that here too we are controlling the visibility of the layout container and only showing it if the ticket type is paid
This ends our vertical linear layout showing the fields about attendee detail. Now, we add a floating action button to toggle the check in status of attendee
We have used a FrameLayout to wrap a FAB and progress bar together in top end of the bottom sheet. The progress bar shows the indeterminate progress of the toggling of attendee status. And you can see the click binder on FAB triggering the presenter method toggleCheckIn() and how the background color and icon change according to the check in status of the attendee.
This wraps up our layout design. Now we just have to create a BottomSheetDialogFragment, inflate this layout in it and bind the attendee variable and we are all set. The result with all fields visible looks like this:
To learn more about bottom sheet and android data binding, please refer to these links:
- Material Bottom Sheet Specs https://material.io/guidelines/components/bottom-sheets.html
- Bottom Sheets Android Introduction http://www.materialdoc.com/bottom-sheets/
- Bottom Sheets in Android https://mayojava.github.io/android/bottom-sheets-android/
- Android Data Binding Documentation https://developer.android.com/topic/libraries/data-binding/index.html
- Data Binding Tutorial http://www.vogella.com/tutorials/AndroidDatabinding/article.html