All Projects β†’ st235 β†’ SwipeToActionLayout

st235 / SwipeToActionLayout

Licence: MIT license
Layout, which provides swipe to reveal behaviour 🎭

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to SwipeToActionLayout

pacstall
An AUR-inspired package manager for Ubuntu
Stars: ✭ 842 (+890.59%)
Mutual labels:  hacktoberfest2022
Linkify
A site that lets you include all your links in a single-page website with easy customizations. It gives you your own URL to share with anyone you want on the internet.
Stars: ✭ 29 (-65.88%)
Mutual labels:  hacktoberfest2022
galgotias icloud feedback bot
No description or website provided.
Stars: ✭ 21 (-75.29%)
Mutual labels:  hacktoberfest2022
CompressorBot
A python based Telegram Bot for Compressing Videos with negligible Quality change
Stars: ✭ 162 (+90.59%)
Mutual labels:  hacktoberfest2022
xdg-xmenu
Generate menu for xmenu
Stars: ✭ 31 (-63.53%)
Mutual labels:  menu
ConsoleMenu
A simple, highly customizable, DOS-like console menu
Stars: ✭ 27 (-68.24%)
Mutual labels:  menu
CodeForces-Solutions
Solutions to CodeForces ProblemSets
Stars: ✭ 47 (-44.71%)
Mutual labels:  hacktoberfest2022
SliderMenu
A simple Menu inspired by SWRevealView Controller and Google Material Menu
Stars: ✭ 35 (-58.82%)
Mutual labels:  menu
Dseized-Bot
This repository contains all of the code required NOTE you may need to download other dependencies which will be mentioned below. This bot has many features such as playing songs in multiple servers and making a queue for songs.
Stars: ✭ 20 (-76.47%)
Mutual labels:  hacktoberfest2022
Hacktoberfest
Everyone is free to contribute. Not eligible for Hacktoberfest
Stars: ✭ 36 (-57.65%)
Mutual labels:  hacktoberfest2022
hasura-auth
Authentication for Hasura.
Stars: ✭ 276 (+224.71%)
Mutual labels:  hacktoberfest2022
oc-menumanager-plugin
A Menu Management Plugin for October CMS
Stars: ✭ 29 (-65.88%)
Mutual labels:  menu
awesome-list
Lista de links ΓΊteis
Stars: ✭ 72 (-15.29%)
Mutual labels:  hacktoberfest2022
UIMenuScroll
The horizontal swiping navigation like on Facebook Messenger.
Stars: ✭ 18 (-78.82%)
Mutual labels:  menu
SheetSelection
An Android library for display list and be able to select the item as BottomSheet.
Stars: ✭ 85 (+0%)
Mutual labels:  hacktoberfest2022
rn-emoji-keyboard
Super performant, lightweight, fully customizable emoji picker πŸš€
Stars: ✭ 228 (+168.24%)
Mutual labels:  hacktoberfest2022
JonContextMenu
A beautiful and minimalist arc menu like the Pinterest one, written in Swift
Stars: ✭ 60 (-29.41%)
Mutual labels:  menu
ember-right-click-menu
An easy and flexible addon to add context menus anywhere in your application
Stars: ✭ 14 (-83.53%)
Mutual labels:  menu
restaurant-bot
This is an Android application that can be used for providing a digital menu for a restaurant.
Stars: ✭ 42 (-50.59%)
Mutual labels:  menu
impromptu.nvim
Create prompts fast and easy
Stars: ✭ 39 (-54.12%)
Mutual labels:  menu

SwipeToActionLayout

Min Android Sdk Maven Central

SwipeToActionLayout is a layout which helps to implement swipe to reveal behaviour. It is really easy to setup and maintain.

First of all, you need to download it, don't you? πŸ™‚

Download from ...

Important: library was migrated from JCenter to MavenCentral

It means that it may be necessary to add mavenCentral repository to your repositories list

allprojects {
    repositories {
        // your repositories

        mavenCentral()
    }
}
  • Maven
<dependency>
  <groupId>com.github.st235</groupId>
  <artifactId>swipetoactionlayout</artifactId>
  <version>X.X</version>
  <type>pom</type>
</dependency>
  • Gradle
implementation 'com.github.st235:swipetoactionlayout:X.X'
  • Ivy
<dependency org='com.github.st235' name='swipetoactionlayout' rev='X.X'>
  <artifact name='swipetoactionlayout' ext='pom' ></artifact>
</dependency>

P.S.: The latest code version is mentioned at the version badge at the top of this page.

Usage

After you have downloaded the library, you need to integrate it. You should declare layout at your xml.

<github.com.st235.lib_swipetoactionlayout.SwipeToActionLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:sal_gravity="right"
    app:sal_isFullActionSupported="false"
    app:sal_items="@menu/swipe_to_action_menu"
    app:sal_shouldVibrateOnQuickAction="false">

    ... draggable child ...

</github.com.st235.lib_swipetoactionlayout.SwipeToActionLayout>

Xml declaration supports the following attributes:

property type description
sal_gravity enum gravity of your action menu. could be without rtl support, ie left or right, and with rtl support, ie start and end
sal_isFullActionSupported boolean allows you to add support of quick action, which will be revealed on full swipe
sal_shouldVibrateOnQuickAction boolean when quick action will be applied view can perform haptic feedback. set this flag as true if you want to support it.
sal_items reference reference to your xml menu file

If you decided to use xml-declared menu then you should create menu file by the next rules:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/call"
        android:icon="@drawable/ic_call_black_18dp"
        android:background="@drawable/action_background"
        android:iconTint="@color/iconTint"/>

    <item
        android:id="@+id/email"
        android:icon="@drawable/ic_email_black_18dp"
        android:background="@drawable/action_background"
        android:iconTint="@color/iconTint" />

    <item
        android:id="@+id/delete"
        android:icon="@drawable/ic_delete_black_18dp"
        android:background="@drawable/action_background"
        android:iconTint="@color/colorAccent" />
</menu>

An item supports the following attributes:

property type description
id id an id of your action
title text a supporting text, will be shown under icon
icon reference a reference to drawable
titleTextColor color a color of your title
background reference a reference to your background resource
iconTint color tint to your icon, allows to change color of it

PS: all these properties are start with android prefix, for example android:background

Is is also possible to apply actions programmatically

        swipeToActionLayout.actions =
                listOf(
                        SwipeAction(0xFFFBDAEE.toInt(), R.drawable.baseline_call_24, getString(R.string.action_call), Color.BLACK, Color.BLACK),
                        SwipeAction(0xFFFFF7A4.toInt(), R.drawable.baseline_email_24, getString(R.string.action_email), Color.BLACK, Color.BLACK),
                        SwipeAction(0xFFC0E7F6.toInt(), R.drawable.baseline_duo_24, getString(R.string.action_duo), Color.BLACK, Color.BLACK)
                )

To listen lifecycle callbacks from SwipeToActionLayout you should implement SwipeMenuListener

swipeToActionLayout.menuListener = MenuListener()

private inner class MenuListener: SwipeMenuListener {

        override fun onClosed(view: View) {
            // empty on purpose
        }

        override fun onOpened(view: View) {
            // empty on purpose
        }

        override fun onFullyOpened(view: View, quickAction: SwipeAction) {
            // empty on purpose
        }

     override fun onActionClicked(view: View, action: SwipeAction) {
         Toast.makeText(this@MainActivity, "On clicked on: ${action.text}", Toast.LENGTH_SHORT).show()
         swipeToActionLayout.close()
     }
 }

And that is it. Enjoy it!

License

MIT License

Copyright (c) 2019 Alexander Dadukin

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].