From 1b1e223eb80338934041f2c89e857c6609718985 Mon Sep 17 00:00:00 2001 From: QuDian Date: Tue, 30 Oct 2018 16:48:48 +0800 Subject: [PATCH] first commit --- .gitattributes | 1 + .gitignore | 46 ++++ README.md | 45 +++ android/build.gradle | 36 +++ android/src/main/AndroidManifest.xml | 6 + .../ProgressHUD/RNProgressHudModule.java | 22 ++ .../ProgressHUD/RNProgressHudPackage.java | 28 ++ index.js | 73 +++++ ios/RNProgressHud.h | 11 + ios/RNProgressHud.m | 13 + ios/RNProgressHud.podspec | 24 ++ ios/RNProgressHud.xcodeproj/project.pbxproj | 259 ++++++++++++++++++ .../contents.xcworkspacedata | 9 + package.json | 18 ++ 14 files changed, 591 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 README.md create mode 100644 android/build.gradle create mode 100644 android/src/main/AndroidManifest.xml create mode 100644 android/src/main/java/com/qudian/ProgressHUD/RNProgressHudModule.java create mode 100644 android/src/main/java/com/qudian/ProgressHUD/RNProgressHudPackage.java create mode 100644 index.js create mode 100644 ios/RNProgressHud.h create mode 100644 ios/RNProgressHud.m create mode 100644 ios/RNProgressHud.podspec create mode 100644 ios/RNProgressHud.xcodeproj/project.pbxproj create mode 100644 ios/RNProgressHud.xcworkspace/contents.xcworkspacedata create mode 100644 package.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..eb39591 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.pbxproj -text \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9cadbfe --- /dev/null +++ b/.gitignore @@ -0,0 +1,46 @@ + +# OSX +# +.DS_Store + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + + +# 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 + +# BUCK +buck-out/ +\.buckd/ +*.keystore + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e057dd2 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ + +# react-native-progress-hud + +## Getting started + +`$ npm install react-native-progress-hud --save` + +### Mostly automatic installation + +`$ react-native link react-native-progress-hud` + +### Manual installation + + +#### iOS + +1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]` +2. Go to `node_modules` ➜ `react-native-progress-hud` and add `RNProgressHud.xcodeproj` +3. In XCode, in the project navigator, select your project. Add `libRNProgressHud.a` to your project's `Build Phases` ➜ `Link Binary With Libraries` +4. Run your project (`Cmd+R`)< + +#### Android + +1. Open up `android/app/src/main/java/[...]/MainActivity.java` + - Add `import com.qudian.ProgressHUD.RNProgressHudPackage;` to the imports at the top of the file + - Add `new RNProgressHudPackage()` to the list returned by the `getPackages()` method +2. Append the following lines to `android/settings.gradle`: + ``` + include ':react-native-progress-hud' + project(':react-native-progress-hud').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-progress-hud/android') + ``` +3. Insert the following lines inside the dependencies block in `android/app/build.gradle`: + ``` + compile project(':react-native-progress-hud') + ``` + + +## Usage +```javascript +import RNProgressHud from 'react-native-progress-hud'; + +// TODO: What to do with the module? +RNProgressHud; +``` + \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..a28f0dd --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,36 @@ + +buildscript { + repositories { + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:1.3.1' + } +} + +apply plugin: 'com.android.library' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.1" + + defaultConfig { + minSdkVersion 16 + targetSdkVersion 22 + versionCode 1 + versionName "1.0" + } + lintOptions { + abortOnError false + } +} + +repositories { + mavenCentral() +} + +dependencies { + compile 'com.facebook.react:react-native:+' +} + \ No newline at end of file diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..cd19ea7 --- /dev/null +++ b/android/src/main/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/android/src/main/java/com/qudian/ProgressHUD/RNProgressHudModule.java b/android/src/main/java/com/qudian/ProgressHUD/RNProgressHudModule.java new file mode 100644 index 0000000..f20d52c --- /dev/null +++ b/android/src/main/java/com/qudian/ProgressHUD/RNProgressHudModule.java @@ -0,0 +1,22 @@ + +package com.qudian.ProgressHUD; + +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.bridge.ReactContextBaseJavaModule; +import com.facebook.react.bridge.ReactMethod; +import com.facebook.react.bridge.Callback; + +public class RNProgressHudModule extends ReactContextBaseJavaModule { + + private final ReactApplicationContext reactContext; + + public RNProgressHudModule(ReactApplicationContext reactContext) { + super(reactContext); + this.reactContext = reactContext; + } + + @Override + public String getName() { + return "RNProgressHud"; + } +} \ No newline at end of file diff --git a/android/src/main/java/com/qudian/ProgressHUD/RNProgressHudPackage.java b/android/src/main/java/com/qudian/ProgressHUD/RNProgressHudPackage.java new file mode 100644 index 0000000..90c8db2 --- /dev/null +++ b/android/src/main/java/com/qudian/ProgressHUD/RNProgressHudPackage.java @@ -0,0 +1,28 @@ + +package com.qudian.ProgressHUD; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import com.facebook.react.ReactPackage; +import com.facebook.react.bridge.NativeModule; +import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.uimanager.ViewManager; +import com.facebook.react.bridge.JavaScriptModule; +public class RNProgressHudPackage implements ReactPackage { + @Override + public List createNativeModules(ReactApplicationContext reactContext) { + return Arrays.asList(new RNProgressHudModule(reactContext)); + } + + // Deprecated from RN 0.47 + public List> createJSModules() { + return Collections.emptyList(); + } + + @Override + public List createViewManagers(ReactApplicationContext reactContext) { + return Collections.emptyList(); + } +} \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..c7e3d87 --- /dev/null +++ b/index.js @@ -0,0 +1,73 @@ + +import React, { Component } from 'react'; +import { + StyleSheet, + View, + Modal, + ActivityIndicator, + Text, +} from 'react-native'; +import PropTypes from 'prop-types'; + +const { QDProgressHud } = NativeModules; + + +export default class QDProgressHud extends Component { + constructor(props) { + super(props); + this.state = { + modal: false, + text:props.text + } + } + + show(){ + this.setState({modal:true}); + } + close(){ + this.setState({modal:false}); + } + render() { + const visible = this.state.modal; + return ( + { console.log('close modal') }} + > + + + + + {this.state.text} + + + + + ); + } +} + +const styles = StyleSheet.create({ + modalBackground: { + flex: 1, + alignItems: 'center', + flexDirection: 'column', + justifyContent: 'center', + backgroundColor: '#00000040', + }, + activityIndicatorWrapper: { + backgroundColor: '#FFFFFF', + height: 100, + width: 100, + borderRadius: 10, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + + }, + textStyle:{ + marginTop: 10, + } +}) diff --git a/ios/RNProgressHud.h b/ios/RNProgressHud.h new file mode 100644 index 0000000..1d9248d --- /dev/null +++ b/ios/RNProgressHud.h @@ -0,0 +1,11 @@ + +#if __has_include("RCTBridgeModule.h") +#import "RCTBridgeModule.h" +#else +#import +#endif + +@interface RNProgressHud : NSObject + +@end + \ No newline at end of file diff --git a/ios/RNProgressHud.m b/ios/RNProgressHud.m new file mode 100644 index 0000000..9eb65bb --- /dev/null +++ b/ios/RNProgressHud.m @@ -0,0 +1,13 @@ + +#import "RNProgressHud.h" + +@implementation RNProgressHud + +- (dispatch_queue_t)methodQueue +{ + return dispatch_get_main_queue(); +} +RCT_EXPORT_MODULE() + +@end + \ No newline at end of file diff --git a/ios/RNProgressHud.podspec b/ios/RNProgressHud.podspec new file mode 100644 index 0000000..a644894 --- /dev/null +++ b/ios/RNProgressHud.podspec @@ -0,0 +1,24 @@ + +Pod::Spec.new do |s| + s.name = "RNProgressHud" + s.version = "1.0.0" + s.summary = "RNProgressHud" + s.description = <<-DESC + RNProgressHud + DESC + s.homepage = "" + s.license = "MIT" + # s.license = { :type => "MIT", :file => "FILE_LICENSE" } + s.author = { "author" => "author@domain.cn" } + s.platform = :ios, "7.0" + s.source = { :git => "https://github.com/author/RNProgressHud.git", :tag => "master" } + s.source_files = "RNProgressHud/**/*.{h,m}" + s.requires_arc = true + + + s.dependency "React" + #s.dependency "others" + +end + + \ No newline at end of file diff --git a/ios/RNProgressHud.xcodeproj/project.pbxproj b/ios/RNProgressHud.xcodeproj/project.pbxproj new file mode 100644 index 0000000..11d56a6 --- /dev/null +++ b/ios/RNProgressHud.xcodeproj/project.pbxproj @@ -0,0 +1,259 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + B3E7B58A1CC2AC0600A0062D /* RNProgressHud.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNProgressHud.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 58B511D91A9E6C8500147676 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = "include/$(PRODUCT_NAME)"; + dstSubfolderSpec = 16; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 134814201AA4EA6300B7C361 /* libRNProgressHud.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNProgressHud.a; sourceTree = BUILT_PRODUCTS_DIR; }; + B3E7B5881CC2AC0600A0062D /* RNProgressHud.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNProgressHud.h; sourceTree = ""; }; + B3E7B5891CC2AC0600A0062D /* RNProgressHud.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNProgressHud.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 58B511D81A9E6C8500147676 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 134814211AA4EA7D00B7C361 /* Products */ = { + isa = PBXGroup; + children = ( + 134814201AA4EA6300B7C361 /* libRNProgressHud.a */, + ); + name = Products; + sourceTree = ""; + }; + 58B511D21A9E6C8500147676 = { + isa = PBXGroup; + children = ( + B3E7B5881CC2AC0600A0062D /* RNProgressHud.h */, + B3E7B5891CC2AC0600A0062D /* RNProgressHud.m */, + 134814211AA4EA7D00B7C361 /* Products */, + ); + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 58B511DA1A9E6C8500147676 /* RNProgressHud */ = { + isa = PBXNativeTarget; + buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNProgressHud" */; + buildPhases = ( + 58B511D71A9E6C8500147676 /* Sources */, + 58B511D81A9E6C8500147676 /* Frameworks */, + 58B511D91A9E6C8500147676 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = RNProgressHud; + productName = RCTDataManager; + productReference = 134814201AA4EA6300B7C361 /* libRNProgressHud.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 58B511D31A9E6C8500147676 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0830; + ORGANIZATIONNAME = Facebook; + TargetAttributes = { + 58B511DA1A9E6C8500147676 = { + CreatedOnToolsVersion = 6.1.1; + }; + }; + }; + buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNProgressHud" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 58B511D21A9E6C8500147676; + productRefGroup = 58B511D21A9E6C8500147676; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 58B511DA1A9E6C8500147676 /* RNProgressHud */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 58B511D71A9E6C8500147676 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B3E7B58A1CC2AC0600A0062D /* RNProgressHud.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 58B511ED1A9E6C8500147676 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 58B511EE1A9E6C8500147676 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 58B511F01A9E6C8500147676 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../../React/**", + "$(SRCROOT)/../../react-native/React/**", + ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = RNProgressHud; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 58B511F11A9E6C8500147676 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../../React/**", + "$(SRCROOT)/../../react-native/React/**", + ); + LIBRARY_SEARCH_PATHS = "$(inherited)"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = RNProgressHud; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RNProgressHud" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 58B511ED1A9E6C8500147676 /* Debug */, + 58B511EE1A9E6C8500147676 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RNProgressHud" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 58B511F01A9E6C8500147676 /* Debug */, + 58B511F11A9E6C8500147676 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 58B511D31A9E6C8500147676 /* Project object */; +} diff --git a/ios/RNProgressHud.xcworkspace/contents.xcworkspacedata b/ios/RNProgressHud.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1af3d84 --- /dev/null +++ b/ios/RNProgressHud.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,9 @@ +// !$*UTF8*$! + + + + + + \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ec53ade --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ + +{ + "name": "react-native-progress-hud", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "react-native" + ], + "author": "", + "license": "", + "peerDependencies": { + "react-native": "^0.41.2" + } +}