Skip to content

Commit

Permalink
Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
cesardeazevedo committed Jun 1, 2017
0 parents commit 35b85b0
Show file tree
Hide file tree
Showing 56 changed files with 1,835 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
@@ -0,0 +1,3 @@
{
"presets": ["react-native"]
}
6 changes: 6 additions & 0 deletions .buckconfig
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
*.pbxproj -text
64 changes: 64 additions & 0 deletions .gitignore
@@ -0,0 +1,64 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
android/.gradle
android/.idea
android/app
android/gradle/*
android/gradlew
android/gradlew.bat
android/loca.properties
android/android.iml
android/RNCollapsibleToolbar.iml
android/app/libs
android/keystores/debug.keystore
1 change: 1 addition & 0 deletions .npmignore
@@ -0,0 +1 @@
example
1 change: 1 addition & 0 deletions .watchmanconfig
@@ -0,0 +1 @@
{}
40 changes: 40 additions & 0 deletions android/build.gradle
@@ -0,0 +1,40 @@
apply plugin: "com.android.library"

android {
compileSdkVersion 25
buildToolsVersion "23.0.1"

defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
}

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}

allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$projectDir/../example/node_modules/react-native/android"
}
}
}

dependencies {
// compile project(':react-native-nested-scroll-view')
compile 'com.facebook.react:react-native:+'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
}
3 changes: 3 additions & 0 deletions android/src/main/AndroidManifest.xml
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rncollapsingtoolbarlayout">
</manifest>
@@ -0,0 +1,78 @@
package com.rncollapsingtoolbarlayout;

import android.support.annotation.Nullable;
import android.support.design.widget.AppBarLayout;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.PixelUtil;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.RCTEventEmitter;

import java.util.HashMap;
import java.util.Map;

public class AppBarLayoutManager extends ViewGroupManager<AppBarLayoutView>
implements AppBarLayout.OnOffsetChangedListener {

private final static String REACT_CLASS = "RCTAppBarLayout";

@Override
public String getName() {
return REACT_CLASS;
}

@Override
public AppBarLayoutView createViewInstance(ThemedReactContext context) {
AppBarLayoutView view = new AppBarLayoutView(context);
view.addOnOffsetChangedListener(this);
return view;
}

@ReactProp(name = "height")
public void setHeight(AppBarLayoutView view, int height) {
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) view.getLayoutParams();
params.height = (int) PixelUtil.toPixelFromDIP(height);
view.setLayoutParams(params);
}

@Override
public Map<String, Object> getExportedViewConstants() {
final Map<String, Object> constants = new HashMap<>();
constants.put("SCROLL_FLAG_SNAP", AppBarLayout.LayoutParams.SCROLL_FLAG_SNAP);
constants.put("SCROLL_FLAG_SCROLL", AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL);
constants.put("SCROLL_FLAG_ENTER_ALWAYS", AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
constants.put("SCROLL_FLAG_EXIT_UNTIL_COLLAPSED", AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
constants.put("SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED", AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
return constants;
}

@Nullable
@Override
public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
return MapBuilder.<String, Object>builder()
.put("topOffsetChanged",
MapBuilder.of(
"phasedRegistrationNames",
MapBuilder.of(
"bubbled", "onOffsetChanged", "captured", "onOffsetChangedCapture")))
.build();
}

@Override
public boolean needsCustomLayoutForChildren() {
return true;
}

@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
WritableMap event = Arguments.createMap();
event.putDouble("offset", verticalOffset);
ReactContext reactContext = (ReactContext) appBarLayout.getContext();
reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(appBarLayout.getId(), "topOffsetChanged", event);
}
}
@@ -0,0 +1,18 @@
package com.rncollapsingtoolbarlayout;

import android.content.Context;
import android.support.design.widget.AppBarLayout;
import android.view.ViewGroup;

public class AppBarLayoutView extends AppBarLayout {
public AppBarLayoutView(Context context) {
super(context);

int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.WRAP_CONTENT;

AppBarLayout.LayoutParams params = new AppBarLayout.LayoutParams(width, height);

this.setLayoutParams(params);
}
}
@@ -0,0 +1,37 @@
package com.rncollapsingtoolbarlayout;

import android.support.design.widget.CollapsingToolbarLayout;
import android.widget.FrameLayout;

import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.annotations.ReactProp;

public class CollapsingParallaxManager extends ViewGroupManager<FrameLayout> {

private final static String REACT_CLASS = "RCTCollapsingParallax";

@Override
public String getName() {
return REACT_CLASS;
}

@Override
public FrameLayout createViewInstance(ThemedReactContext context) {
FrameLayout view = new FrameLayout(context);
CollapsingToolbarLayout.LayoutParams params = new CollapsingToolbarLayout.LayoutParams(
CollapsingToolbarLayout.LayoutParams.MATCH_PARENT,
CollapsingToolbarLayout.LayoutParams.WRAP_CONTENT
);
params.setCollapseMode(CollapsingToolbarLayout.LayoutParams.COLLAPSE_MODE_PARALLAX);
view.setLayoutParams(params);
return view;
}

@ReactProp(name = "parallaxMultiplier")
public void setParallaxMultiplier(FrameLayout view, float multiplier) {
CollapsingToolbarLayout.LayoutParams params = (CollapsingToolbarLayout.LayoutParams) view.getLayoutParams();
params.setParallaxMultiplier(multiplier);
view.setLayoutParams(params);
}
}

0 comments on commit 35b85b0

Please sign in to comment.