forked from ide/react-native-button
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
0 parents
commit 84f1c04
Showing
59 changed files
with
9,170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
[android] | ||
target = Google Inc.:Google APIs:23 | ||
|
||
[maven_repositories] | ||
central = https://repo1.maven.org/maven2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
root: true, | ||
extends: '@react-native-community', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pbxproj -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# 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 | ||
|
||
# Visual Studio Code | ||
# | ||
.vscode/ | ||
|
||
# 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://docs.fastlane.tools/best-practices/source-control/ | ||
|
||
*/fastlane/report.xml | ||
*/fastlane/Preview.html | ||
*/fastlane/screenshots | ||
|
||
# Bundle artifact | ||
*.jsbundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React, {Component} from 'react'; | ||
import Button from './Button'; | ||
|
||
export default class ExampleComponent extends Component { | ||
|
||
render() { | ||
return ( | ||
<Button | ||
containerStyle={{ | ||
padding: 10, | ||
height: 45, | ||
overflow: 'hidden', | ||
borderRadius: 4, | ||
backgroundColor: 'white' | ||
}} | ||
disabledContainerStyle={{backgroundColor: 'grey'}} | ||
style={{fontSize: 20, color: 'green'}}> | ||
Press me! | ||
</Button> | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
import React from 'react'; | ||
import { | ||
StyleSheet, | ||
Text, | ||
TouchableOpacity, | ||
View, | ||
ViewStyle, | ||
StyleProp, | ||
TextStyle, | ||
TouchableOpacityProps | ||
} from 'react-native'; | ||
|
||
import coalesceNonElementChildren from './coalesceNonElementChildren'; | ||
|
||
const systemButtonOpacity = 0.2; | ||
|
||
interface propTypes extends TouchableOpacityProps { | ||
accessibilityLabel?: string, | ||
textID?: string, | ||
allowFontScaling?: boolean, | ||
disabled?: boolean, | ||
containerStyle?: StyleProp<ViewStyle>, | ||
disabledContainerStyle?: StyleProp<ViewStyle>, | ||
style?: StyleProp<TextStyle>, | ||
styleDisabled?: StyleProp<TextStyle>, | ||
childGroupStyle?: StyleProp<ViewStyle>, | ||
children: React.ReactChild | ||
} | ||
|
||
|
||
export default function Button({ | ||
disabled, | ||
activeOpacity, | ||
style, | ||
styleDisabled, | ||
childGroupStyle, | ||
children, | ||
allowFontScaling, | ||
containerStyle, | ||
disabledContainerStyle, | ||
onPress, | ||
onPressIn, | ||
onPressOut, | ||
onLongPress, | ||
delayPressIn, | ||
delayPressOut, | ||
delayLongPress, | ||
testID, | ||
accessibilityLabel | ||
}: propTypes) { | ||
function _computeActiveOpacity() { | ||
if (disabled) { | ||
return 1; | ||
} | ||
return activeOpacity != null ? | ||
activeOpacity : | ||
systemButtonOpacity; | ||
} | ||
|
||
function _renderGroupedChildren() { | ||
let styleRenderGroup = [ | ||
styles.text, | ||
disabled ? styles.disabledText : null, | ||
style, | ||
disabled ? styleDisabled : null, | ||
]; | ||
let childGroupStyleCustom = [ | ||
styles.group, | ||
childGroupStyle, | ||
]; | ||
const childrenCustom = coalesceNonElementChildren(children, (children: React.ReactNode, index: string | number | undefined) => { | ||
return ( | ||
<Text key={index} style={styleRenderGroup} {...{allowFontScaling}}> | ||
{childrenCustom} | ||
</Text> | ||
); | ||
}); | ||
|
||
switch (childrenCustom.length) { | ||
case 0: | ||
return null; | ||
case 1: | ||
return childrenCustom[0]; | ||
default: | ||
return <View style={childGroupStyleCustom}>{childrenCustom}</View>; | ||
} | ||
} | ||
|
||
|
||
const touchableProps: TouchableOpacityProps = { | ||
activeOpacity: _computeActiveOpacity(), | ||
|
||
}; | ||
const containerStyleCustom = [ | ||
containerStyle, | ||
disabled ? disabledContainerStyle : null | ||
]; | ||
|
||
if (!disabled) { | ||
touchableProps.onPress = onPress; | ||
touchableProps.onPressIn = onPressIn; | ||
touchableProps.onPressOut = onPressOut; | ||
touchableProps.onLongPress = onLongPress; | ||
touchableProps.delayPressIn = delayPressIn; | ||
touchableProps.delayPressOut = delayPressOut; | ||
touchableProps.delayLongPress = delayLongPress; | ||
} | ||
|
||
return ( | ||
<TouchableOpacity | ||
{...{ | ||
touchableProps, testID, accessibilityLabel | ||
}} | ||
style={containerStyleCustom} | ||
accessibilityRole="button"> | ||
{_renderGroupedChildren()} | ||
</TouchableOpacity> | ||
); | ||
} | ||
|
||
|
||
const styles = StyleSheet.create({ | ||
text: { | ||
color: '#007aff', | ||
fontSize: 17, | ||
fontWeight: '500', | ||
textAlign: 'center', | ||
}, | ||
disabledText: { | ||
color: '#dcdcdc', | ||
}, | ||
group: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* @format | ||
*/ | ||
|
||
import 'react-native'; | ||
import React from 'react'; | ||
import App from '../App'; | ||
|
||
// Note: test renderer must be required after react-native. | ||
import renderer from 'react-test-renderer'; | ||
|
||
it('renders correctly', () => { | ||
renderer.create(<App />); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# To learn about Buck see [Docs](https://buckbuild.com/). | ||
# To run your application with Buck: | ||
# - install Buck | ||
# - `npm start` - to start the packager | ||
# - `cd android` | ||
# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` | ||
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck | ||
# - `buck install -r android/app` - compile, install and run application | ||
# | ||
|
||
load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") | ||
|
||
lib_deps = [] | ||
|
||
create_aar_targets(glob(["libs/*.aar"])) | ||
|
||
create_jar_targets(glob(["libs/*.jar"])) | ||
|
||
android_library( | ||
name = "all-libs", | ||
exported_deps = lib_deps, | ||
) | ||
|
||
android_library( | ||
name = "app-code", | ||
srcs = glob([ | ||
"src/main/java/**/*.java", | ||
]), | ||
deps = [ | ||
":all-libs", | ||
":build_config", | ||
":res", | ||
], | ||
) | ||
|
||
android_build_config( | ||
name = "build_config", | ||
package = "com.rnb", | ||
) | ||
|
||
android_resource( | ||
name = "res", | ||
package = "com.rnb", | ||
res = "src/main/res", | ||
) | ||
|
||
android_binary( | ||
name = "app", | ||
keystore = "//android/keystores:debug", | ||
manifest = "src/main/AndroidManifest.xml", | ||
package_type = "debug", | ||
deps = [ | ||
":app-code", | ||
], | ||
) |
Oops, something went wrong.