For those may not know, Onsen UI offers a rich variety of UI components and tons of ready to implement features, specially designed for mobile apps. However, with all these possibilities one can’t help but be puzzled about how can all these components be combined to create an app. For that purpose, we in the Onsen UI team will show you how to use a combination of Onsen UI components to create a user interface pattern almost identical to the one of the popular music app Spotify!
First of all, when creating an interface, you must decide how many and what kind of screens (pages) do you need for an app. In this case, our work is cut short, since we will follow the example of an existing app. However, since most of the pages of the actual app are quite similar in design with just slight differences in their functionality, we will limit the number of pages to three:
- Browsing Page
- Playlist Page
- Play Screen Page
We shall go through these three pages briefly so that we give you the general idea of how you can easily combine components to create an interface on par with the ones of popular apps. For the complete user interface pattern, please visit our tutorial page.
Note: We will not implement the different functionalities of the interface (except some that are necessary for the flow of the app) since that is not the purpose of this post.
The Browsing Page
The first page of this pattern is the Browsing Page which allows the users to browse through playlists and find one that suits their tastes. The implementation of this page is quite simple. It’s constructed with the following Onsen UI elements:
On the top, we have a carousel which elements have fixed length to get the overflowing horizontal list look, displaying the list of playlists the app recommends to the user:
[...] <ons-carousel auto-refresh swipeable overscrollable item-width="130px" class="recomended_list"> <ons-carousel-item modifier="nodivider" id="playlist_1" class="recomended_playlist" onclick="openPlaylist(this.id)"> <div class="thumbnail"><ons-icon icon="ion-music-note"></ons-icon></div> <div class="recomended_playlist_title" id="playlist_1_name">Playlist 1</div> </ons-carousel-item> [...] </ons-carousel> [...]
Followed by a standard vertical list, giving more options for categorizing the playlists:
[...] <ons-list class="menu_list"> <ons-list-item class="menu_item" modifier="chevron" tappable><ons-icon icon="line-chart"></ons-icon> Charts</ons-list-item> [...] </ons-list> [...]
And last but not least, a grid-like pattern used to categorize the playlists by Genre and Mood, constructed by using the combination of
[...] <ons-row class="category"> <ons-col modifier="nodivider" id="Category_1" onclick="openPlaylist(this.id)"> <div class="category_wrapper"> <figure class="category_thumbnail"> <ons-icon icon="fa-users"></ons-icon> <div class="category_title" id="Category_1_name">Party</div> </figure> </div> </ons-col> [...] </ons-row> [...]
After tapping on some of the recommended playlists or Genres/Moods, the Playlist Page is opened. Notice that the items in the vertical list won’t activate anything upon tapping them since this would lead to a screen with similar content, but a different organization of the playlist.
For the detail code of this page, including the CSS classes, visit our tutorial page.
The Playlist Page
The Playlist Page consists of two parts. The first one consists of a carousel showing details about the playlist at the top:
[...] <ons-carousel class="carousel" swipeable auto-scroll id="carousel"> <ons-carousel-item> <div> <figure class="playlist_thumbnail"> <img src="assets/img/profile-image-05.png"> <div class="playlist_title" id="playlist_title">Classical</div> </figure> <div> <div class="playlist_follow">FOLLOW</div> </div> <div class="playlist_info">1,023 FOLLOWERS・BY UNKNOWN AUTHOR</div> </div> </ons-carousel-item> [...] </ons-carousel> [...]
The carousel has two pages (items), the first one presenting the cover of the playlist, the name, number of followers and author, while the second one displays a small description about the playlist as well as the date of upload, and the total duration of the playlist.
The second part consists of the list of the playlist’s tracks, where the first element of the list is an option allowing for the playlist to be played in offline mode:
[...] <ons-list class="track_list"> <ons-list-item class="track_offline"> <div class="center">Available Offline</div> <div class="right"> <ons-switch></ons-switch> </div> </ons-list-item> <ons-list-item class="track" tappable> <div class="center"> <div class="list-item__title">Track 01</div> <div class="list-item__subtitle track_title">Unknown Artist - Track 01</div> </div> <div class="right"> <ons-icon icon="ion-ios-more,material:ion-android-more-vertical"></ons-icon> </div> </ons-list-item> [...] </ons-list> [...]
What’s peculiar about the list’s elements is that each track element has a three dotted icon on the right, which appears horizontally in the case of iOS or vertically in the case of Android. This is accomplished by providing the name of the icon, that will appear on Android, with the
material keyword after the name of the default icon.
Moreover, the two parts are separated by the “Shuffle Play!”
which, when tapped, shows the
element at the bottom of the screen, showing the currently playing track:
[...] <ons-toast> <div onclick="openPlayScreen()"><ons-icon size="20px" icon="angle-up"></ons-icon> Unknown Artist - Track 01 </div> <button><ons-icon id="play_icon" size="20px" icon="play-circle-o" onclick="play_toggle(this.id)"></ons-icon></button> </ons-toast> [...]
By tapping this
element, the Play Screen will open.
The Play Screen
This screen is rather simple, however, it contains some interesting components that make its creation quite easy:
[...] <div> <!-- Image --> </div> <ons-row> <!-- Track info --> </ons-row> <ons-row> <!-- Duration info --> </ons-row> <ons-row> <!-- Buttons --> </ons-row> [...]
Apart from the
, this screen consists of one standard
wrapper elements for easily structuring the screen. These elements are used to show the title of the track, the duration as well as the current progress of the playing track and buttons usually found in a music player. Each
is divided into equal width parts by using as many
elements as the number of parts you need.
Although this screen is simple, it can be further improved by enclosing the image and the first
into a carousel, thus enabling songs switching by swiping the carousel.
We hope this little pattern of ours will give you an inspiration about how to design your app. But this is not all! We created several patterns based on popular apps like this one, which can be accessed on our tutorial page and hope that they will be of help to you!
Stay tuned to Onsen UI for even more fun content and new updates!
Onsen UI is an open source library used to create the user interface of hybrid apps. You can find more information on our GitHub page. If you like Onsen UI, please don’t forget to give us a star! ★★★★★