SeatBookView is an Android Studio Library that helps to make it easier to create Bus, Train, Cinema Theater Seat UI and all functionalities are given.

Overview

GitHub Cards Preview

SeatBookView

SeatBookView is an Android Studio Library that helps to make it easier to create Bus 🚍 , Train πŸš‰ , Cinema Theater Seat UI and all functionalities are given. Based on varunjohn/Booking-Seats-Layout-Sample

Preview

Installation

For Gradle:

Step 1: Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2: Add the dependency

dependencies {
	        implementation 'com.github.JahidHasanCO:SeatBookView:1.0.3'
	}

For Maven:

To get a Git project into your build: Step 1: Add the JitPack repository to your build file

<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Step 2: Add the dependency

	<dependency>
	    <groupId>com.github.JahidHasanCO</groupId>
	    <artifactId>SeatBookView</artifactId>
	    <version>Tag</version>
	</dependency>

Usage

        <dev.jahidhasanco.seatbookview.SeatBookView
            android:layout_marginTop="10dp"
            android:layout_marginBottom="30dp"
            android:id="@+id/layoutSeat"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center"
            app:seat_gaping="10dp"
            app:seat_text_size="15sp"
            app:available_seats_text_color="#59575C"
            app:seat_select_limit="2"
            />

Attributes of this Library

XML Attributes Description
app:available_seat_background This attribute used to set background of non booked seat for any Drawable file.
app:reserved_seat_background This attribute used to set background of reserved seat for any Drawable file.
app:booked_seat_background This attribute used to set background of booked seat for any Drawable file.
app:selected_seats_background This attribute used to set background of selected seat for any Drawable file.
app:reserved_seats_text_color Color of the reserved seat text.
app:booked_seats_text_color Color of the booked seat text.
app:available_seats_text_color Color of the non booked seat text.
app:seat_size Size of the Seat

Check All XML Attributes here


For creating a seat system you have to create a String for your seat position.

    private var seats = (
            "/U___S" +
                    "/_____" +
                    "/AA_AA" +
                    "/UA_AR" +
                    "/AA_AA" +
                    "/RU_AA" +
                    "/AA_AR" +
                    "/AU_AA" +
                    "/AA_AA" +
                    "/AAAAA"
            )
Symbol Uses For
A Use to create a seat that hasn't book
R Use to create a seat that is already reserved.
U Use to create a seat that is already booked.
S Use to create an empty seat that you can assign Drawable.
/ Use to create a new row.
_ Use to create a space.

For setting the custom title of a seat, you need to create an ArrayList and set the value by index (You need to add value the same as your seat plan).

    private var title = listOf(
        "/", "I1", "", "", "", "E5",
        "/", "", "", "", "", "",
        "/", "A1", "A2", "", "A3", "A4",
        "/", "B1", "B2", "", "B3", "B4",
        "/", "C1", "C2", "", "C3", "C4",
        "/", "D1", "D2", "", "D3", "D4",
        "/", "E1", "E2", "", "E3", "E4",
        "/", "F1", "F2", "", "F3", "F4",
        "/", "G1", "G2", "", "G3", "G4",
        "/", "H1", "H2", "H3", "H4", "H5"
    )

Create SeatBookView Object and set Layout, Titles, Seat String, and some Attributes.

    private lateinit var seatBookView: SeatBookView
        
        seatBookView = findViewById(R.id.layoutSeat)
        seatBookView.setSeatsLayoutString(seats)
            .isCustomTitle(true)
            .setCustomTitle(title)
            .setSeatLayoutPadding(2)
            .setSeatSizeBySeatsColumnAndLayoutWidth(5, -1)
        //ParentLayoutWeight -1 if Your seatBookView layout_width = match_parent / wrap_content


        seatBookView.show()

Functions of this Library

Functions Description
isCustomTitle(r: Boolean) use to set custom title on seat title.
setCustomTitle(titles: List) To set custom titles this function needs ArrayList of String.
setSelectSeatLimit(limit: Int) Use to set selected seat limit.
setSeatGaping(size: Int) use for each seat margin.
setSeatLayoutPadding(size: Int) Use to set Container Layout Padding.
setSeatSize(size: Int) Use to set seat size. This size uses for height and weight.
setSeatSizeBySeatsColumnAndLayoutWidth(seatsInColumn: Int, parentLayoutWeight: Int) Note: ParentLayoutWeight -1 if Your seatBookView layout_width = match_parent / wrap_content

Check all functions here


For track click on seat to call setSeatLongClickListener()

        seatBookView.setSeatClickListener(object : SeatBookView.SeatClickListener {
            override fun onAvailableSeatClick(selectedIdList: List<Int>, view: View) {
            }
            override fun onBookedSeatClick(view: View) {
            }
            override fun onReservedSeatClick(view: View) {
            }
        })

For track Long press on seat to call setSeatLongClickListener()

    seatBookView.setSeatLongClickListener(object:SeatBookView.SeatLongClickListener{
            override fun onAvailableSeatLongClick(view: View) {
                Toast.makeText(this@MainActivity,"Long Pressed",Toast.LENGTH_SHORT).show()
            }
            override fun onBookedSeatLongClick(view: View) {
            }
            override fun onReservedSeatLongClick(view: View) {
            }
        })

LICENSE

This project is distributed under the MIT license, check the license for more info.

MIT License

Copyright (c) 2022 Md. Zahidul Islam

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Contributing πŸ’‘

If you want to contribute to this project and make it better with new ideas, your pull request is very welcomed. If you find any issue just put it in the repository issue section, thank you.

You might also like...
This application is used to adjust the scaling of kubernetes deployments depending on the message-count of given RabbitMQ queues.

PodAutoScaler This application is used to adjust the scaling of kubernetes deployments depending on the message-count of given RabbitMQ queues. It use

>On this day< is a JetBrains Space app which shows Wikipedia-based information about what happened on that or given day
On this day is a JetBrains Space app which shows Wikipedia-based information about what happened on that or given day

kotlin-spaces-app-onthisday On this day is a JetBrains Space app which shows Wikipedia-based information about what happened on that or given day Stat

CovidTracker traces all the covid-19 cases all over the world.
CovidTracker traces all the covid-19 cases all over the world.

CovidTracker Crona Tracker trace india covid-19 cases upto district level and can trace other countries cases too. It can also traces user's current l

Create libraries for all types of Kotlin projects: android, JVM, Multiplatform, Gradle plugins, and so on.

JavierSC Kotlin template Create libraries for all types of Kotlin projects: android, JVM, Multiplatform, Gradle plugins, and so on. Features Easy to p

A project that takes advantage of docker and makes the load test easier

Performance Test It's a project that takes advantage of docker and makes the load test easier. Also, it collects metrics from each running container.

Binding your extras more easier, more simpler for your Android project

Ktan Ktan make your intent / arguments more easier and readable. And most important, will help you bind all extras for your activity / fragment. And a

Bukkit library written in Kotlin to make with compatibility and ease non-playable-character (NPC)

mc-npk Easy to use, fast and efficient library to make non-playable-characters (

Guide to setup JetBrains Projector and access Android Studio from any device
Guide to setup JetBrains Projector and access Android Studio from any device

JetBrains Projector with Android Studio Guide to setup JetBrains Projector and access Android Studio from any device. Blog post Android Studio on an i

Event State Processor Generator plugin is compatible with IntelliJ and Android Studio.
Event State Processor Generator plugin is compatible with IntelliJ and Android Studio.

Event State Processor Generator plugin is compatible with IntelliJ and Android Studio. It provides source code generation for the EventStateProcessor Library to increase code productivity in Flutter apps development.

Comments
Releases(1.0.4)
Owner
Md. Zahidul Islam
I started My journey with a Big Dream. I am giving Myself Time, Preparing Myself. I am open to collaborating on exciting projects.
Md. Zahidul Islam
Map-vs-list-comparator - The project compares the time needed to find a given element in a map vs the time needed to find a given element in a list.

Map vs List Comparator The project compares the time needed to find a given element in a map vs the time needed to find a given element in a list. To

null 0 Jan 4, 2022
This library is created to make files uploading and downloading on Aws easier

S3Manager - aws files uploading library This library is created to make files uploading and downloading on Aws easier Features Easy to use Single/mult

Rajesh Khuti 0 Apr 30, 2022
Set of extensions for Kotlin that provides Discrete math functionalities

DiscreteMathToolkit Set of extensions for Kotlin that provides Discrete Math functionalities as an Kotlin extension functions. To stay current with ne

Marcin MoskaΕ‚a 177 Dec 15, 2022
Spikot is a Kotlin library to make Spigot development easier

Spikot is a Kotlin library to make Spigot development easier Using Spikot Installation To use spikot add the following to your build.gradle.kts file.

Cody 1 Oct 30, 2021
BindsAdapter is an Android library to help you create and maintain Adapter class easier via ksp( Kotlin Symbol Processing).

BindsAdapter BindsAdapter is an Android library to help you create and maintain Adapter class easier via ksp( Kotlin Symbol Processing). Installation

Jintin 5 Jul 30, 2022
This folder contains the source code for the Bus Scheduler app codelab

Bus Scheduler App This folder contains the source code for the Bus Scheduler app codelab. Introduction The Bus Scheduler app displays a list of bus st

null 0 Dec 9, 2021
A simple android library which helps you to create a curved bottom navigation

CurvedBottomNavigation A simple android library which helps you to create a curved bottom navigation DEMO Setup Update your module level build.gradle

Qama A. Safadi 92 Dec 29, 2022
Praveen Kumar Kumaresan 0 Jan 17, 2022
KotlinScript that generate Reel from a given image, text and audio

ReelScriot KotlinScript that generate Reel from a given image, text and audio 80f4ea39-a7da-4f21-b0ff-7a17836a1cd0.mp4 6691b51d-d7a3-4915-ae41-8bec400

Chetan Gupta 2 Dec 6, 2022
This project aims to provide a solution for finding the right product for a given EAN (European Article Number)

This project aims to provide a solution for finding the right product for a given EAN (European Article Number)

MJ 1 Apr 18, 2022