Skip to content

Commit

Permalink
add bottom sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
bowyer-app committed Aug 6, 2015
1 parent d23d09e commit 317ebf6
Show file tree
Hide file tree
Showing 5 changed files with 550 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bowyer.fabtransitionlayout.demo;

import com.bowyer.app.fabtransitionlayout.BottomSheetLayout;
import com.bowyer.app.fabtransitionlayout.FooterLayout;
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
Expand All @@ -8,14 +9,13 @@
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -31,8 +31,15 @@ public class MainActivity extends ActionBarActivity implements ObservableScrollV
ObservableListView mObservableListView;
@InjectView(R.id.fabtoolbar)
FooterLayout mFabToolbar;
@InjectView(R.id.fablist)
BottomSheetLayout mFooterLayout;
@InjectView(R.id.list_menu)
ListView mListView;

@InjectView(R.id.fab)
FloatingActionButton mFab;
@InjectView(R.id.fab_left)
FloatingActionButton mFabLeft;

@InjectView(R.id.ic_call)
ImageView mIcCall;
Expand All @@ -47,9 +54,21 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
initListView();
initListMenu();
mFabToolbar.setFab(mFab);
mFooterLayout.setFab(mFabLeft);
}

private void initListMenu(){
List<String> menu = new ArrayList<>();
menu.add("Share");
menu.add("Upload");
menu.add("Fav");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, menu);
mListView.setAdapter(adapter);

}
private void initListView() {
List<String> list = new ArrayList<String>(100);
for (int i = 0; i < 100; i++) {
Expand All @@ -76,8 +95,10 @@ public void onDownMotionEvent() {
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
if (scrollState == ScrollState.UP) {
mFabToolbar.slideOutFab();
mFooterLayout.slideOutFab();
} else if (scrollState == ScrollState.DOWN) {
mFabToolbar.slideInFab();
mFooterLayout.slideInFab();
}
}

Expand All @@ -86,6 +107,11 @@ void onFabClick() {
mFabToolbar.expandFab();
}

@OnClick(R.id.fab_left)
void onFabLeftClick(){
mFooterLayout.expandFab();
}

@OnClick(R.id.call)
void onClickCall() {
iconAnim(mIcCall);
Expand Down
29 changes: 29 additions & 0 deletions demo/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,40 @@
android:layout_gravity="bottom|end"
android:layout_marginBottom="32dp"
android:layout_marginRight="32dp"
android:visibility="invisible"
android:src="@drawable/ic_add_white_24dp"
app:borderWidth="0dp"
app:fabSize="normal"
app:rippleColor="@color/primary"
/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="32dp"
android:layout_marginRight="32dp"
android:src="@drawable/ic_add_white_24dp"
app:borderWidth="0dp"
app:fabSize="normal"
app:rippleColor="@color/primary"
/>

<com.bowyer.app.fabtransitionlayout.BottomSheetLayout
android:id="@+id/fablist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
app:ft_container_gravity="end"
app:ft_color="@color/primary">

<ListView
android:id="@+id/list_menu"
android:background="@color/primary"
android:divider="@null"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.bowyer.app.fabtransitionlayout.BottomSheetLayout>

<com.bowyer.app.fabtransitionlayout.FooterLayout
android:id="@+id/fabtoolbar"
Expand Down
Loading

0 comments on commit 317ebf6

Please sign in to comment.