Skip to content

Commit ce7c6a2

Browse files
authored
Created Readme
1 parent 138ff08 commit ce7c6a2

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# ProSwipeButton
2+
A swipe button for Android with a circular progress bar for async operations
3+
4+
![](https://media.giphy.com/media/3ohjUYjiYN5J04NjtS/giphy.gif)
5+
6+
# Gradle
7+
```
8+
dependencies {
9+
...
10+
compile 'in.shadowfax:proswipebutton:1.0.1'
11+
}
12+
```
13+
14+
# Usage
15+
1. In your XML layout file, add this custom view
16+
```xml
17+
<in.shadowfax.proswipebutton.ProSwipeButton
18+
android:id="@+id/awesome_btn"
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
android:layout_margin="8dp"
22+
app:bg_color="@android:color/holo_blue_dark"
23+
app:btn_text="Place Order" />
24+
```
25+
26+
2. React to successful swipe on the button by adding a swipe listener
27+
```java
28+
ProSwipeButton proSwipeBtn = (ProSwipeButton) findViewById(R.id.awesome_btn);
29+
proSwipeBtn.setOnSwipeListener(new ProSwipeButton.OnSwipeListener() {
30+
@Override
31+
public void onSwipeConfirm() {
32+
// user has swiped the btn. Perform your async operation now
33+
new Handler().postDelayed(new Runnable() {
34+
@Override
35+
public void run() {
36+
// task success! show TICK icon in ProSwipeButton
37+
proSwipeBtn.showResultIcon(true); // false is task failed
38+
}
39+
}, 2000);
40+
}
41+
});
42+
```
43+
44+
3. After the async task is completed, tell the ProSwipeButton to show a result icon.
45+
Either a tick for a successful async operation or cross for a failed async operation.
46+
47+
```java
48+
proSwipeBtn.showResultIcon(true); //if task succeeds
49+
proSwipeBtn.showResultIcon(false); //if task fails
50+
```
51+
52+
# Customizations
53+
54+
You can customize the button via XML or programatically.
55+
56+
```XML
57+
<in.shadowfax.proswipebutton.ProSwipeButton
58+
android:id="@+id/proswipebutton_main_error"
59+
android:layout_width="match_parent"
60+
android:layout_height="wrap_content"
61+
android:layout_margin="8dp"
62+
app:arrow_color="#33FFFFFF"
63+
app:bg_color="@android:color/holo_blue_dark"
64+
app:btn_radius="2dp"
65+
app:btn_text="Place Order"
66+
app:text_color="@android:color/white"
67+
app:text_size="12sp" />
68+
```
69+
70+
# Sample
71+
Clone the repository and check out the `app` module.
72+
73+
# License
74+
75+
```
76+
MIT License
77+
78+
Copyright (c) 2017 Shadowfax Technologies
79+
80+
Permission is hereby granted, free of charge, to any person obtaining a copy
81+
of this software and associated documentation files (the "Software"), to deal
82+
in the Software without restriction, including without limitation the rights
83+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
84+
copies of the Software, and to permit persons to whom the Software is
85+
furnished to do so, subject to the following conditions:
86+
87+
The above copyright notice and this permission notice shall be included in all
88+
copies or substantial portions of the Software.
89+
90+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
91+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
92+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
93+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
94+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
95+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
96+
SOFTWARE.
97+
```

0 commit comments

Comments
 (0)