├── .github └── issue_template.md ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── assets ├── cropperresultandroid.jpeg ├── cropperuiandroid.jpeg └── cropperuiios.png ├── demo ├── .editorconfig ├── .gitignore ├── App_Resources │ ├── Android │ │ ├── app.gradle │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ ├── background.png │ │ │ └── logo.png │ │ │ ├── drawable-ldpi │ │ │ ├── background.png │ │ │ └── logo.png │ │ │ ├── drawable-mdpi │ │ │ ├── background.png │ │ │ └── logo.png │ │ │ ├── drawable-nodpi │ │ │ └── splash_screen.xml │ │ │ ├── drawable-xhdpi │ │ │ ├── background.png │ │ │ └── logo.png │ │ │ ├── drawable-xxhdpi │ │ │ ├── background.png │ │ │ └── logo.png │ │ │ ├── drawable-xxxhdpi │ │ │ ├── background.png │ │ │ └── logo.png │ │ │ ├── drawable │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ └── ic_launcher.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-v21 │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ │ ├── values-v29 │ │ │ └── styles.xml │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── ic_launcher_background.xml │ │ │ └── styles.xml │ └── iOS │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── icon-1024.png │ │ │ ├── icon-20.png │ │ │ ├── icon-20@2x.png │ │ │ ├── icon-20@3x.png │ │ │ ├── icon-29.png │ │ │ ├── icon-29@2x.png │ │ │ ├── icon-29@3x.png │ │ │ ├── icon-40.png │ │ │ ├── icon-40@2x.png │ │ │ ├── icon-40@3x.png │ │ │ ├── icon-60@2x.png │ │ │ ├── icon-60@3x.png │ │ │ ├── icon-76.png │ │ │ ├── icon-76@2x.png │ │ │ └── icon-83.5@2x.png │ │ ├── Contents.json │ │ ├── LaunchScreen.AspectFill.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchScreen-AspectFill.png │ │ │ ├── LaunchScreen-AspectFill@2x.png │ │ │ └── LaunchScreen-AspectFill@3x.png │ │ └── LaunchScreen.Center.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchScreen-Center.png │ │ │ ├── LaunchScreen-Center@2x.png │ │ │ └── LaunchScreen-Center@3x.png │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ └── build.xcconfig ├── app │ ├── app-root.xml │ ├── app.css │ ├── app.ts │ ├── main-page.ts │ ├── main-page.xml │ ├── main-view-model.ts │ ├── modal-page.ts │ └── modal-page.xml ├── nativescript.config.ts ├── package-lock.json ├── package.json ├── references.d.ts ├── tsconfig.json └── webpack.config.js ├── ns-ng-snippet ├── app.component.html └── app.component.ts ├── ns-vue-snippet └── vue-snippet.js ├── publish ├── pack.sh ├── package-lock.json ├── package.json └── publish.sh ├── service-example └── image-upload-service.js ├── src ├── .npmignore ├── imagecropper.android.ts ├── imagecropper.ios.ts ├── index.d.ts ├── package-lock.json ├── package.json ├── platforms │ ├── android │ │ ├── AndroidManifest.xml │ │ ├── include.gradle │ │ └── nativescript_imagecropper.aar │ └── ios │ │ └── Podfile ├── references.d.ts ├── tsconfig.json └── typings │ ├── java!ucrop.d.ts │ └── objc!TOCropViewController.d.ts └── tslint.json /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | ### Make sure to check the demo app(s) for sample usage 2 | 3 | ### Make sure to check the existing issues in this repository 4 | 5 | ### If the demo apps cannot help and there is no issue for your problem, tell us about it 6 | Please, ensure your title is less than 63 characters long and starts with a capital 7 | letter. 8 | 9 | ### Which platform(s) does your issue occur on? 10 | - iOS/Android/Both 11 | - iOS/Android versions 12 | - emulator or device. What type of device? 13 | 14 | ### Please, provide the following version numbers that your issue occurs with: 15 | 16 | - CLI: (run `tns --version` to fetch it) 17 | - Cross-platform modules: (check the 'version' attribute in the 18 | `node_modules/@nativescript/core/package.json` file in your project) 19 | - Runtime(s): (look for the `"tns-android"` and `"tns-ios"` properties in the `package.json` file of your project) 20 | - Plugin(s): (look for the version numbers in the `package.json` file of your 21 | project and paste your dependencies and devDependencies here) 22 | 23 | ### Please, tell us how to recreate the issue in as much detail as possible. 24 | Describe the steps to reproduce it. 25 | 26 | ### Is there any code involved? 27 | - provide a code example to recreate the problem 28 | - (EVEN BETTER) provide a .zip with application or refer to a repository with application where the problem is reproducible. 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .idea 3 | .DS_Store 4 | *.js 5 | !ns-vue-snippet/vue-snippet.js 6 | !service-example/*.js 7 | *.js.map 8 | *.log 9 | src/*.d.ts 10 | !src/index.d.ts 11 | !src/references.d.ts 12 | !src/scripts/*.js 13 | !seed-tests/*.js 14 | seed-tests/seed-copy/**/*.* 15 | seed-tests/seed-copy-new-git-repo/**/*.* 16 | !demo/karma.conf.js 17 | !demo/app/tests/*.js 18 | demo/*.d.ts 19 | !demo/references.d.ts 20 | !demo/webpack.config.js 21 | demo/lib 22 | demo/platforms 23 | node_modules 24 | publish/src 25 | publish/package 26 | demo/report/report.html 27 | demo/report/stats.json 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | - stage: "Lint" 4 | language: node_js 5 | os: linux 6 | node_js: "6" 7 | script: cd src && npm run ci.tslint && cd ../demo && npm run ci.tslint 8 | - stage: "WebPack" 9 | os: osx 10 | env: 11 | - Platform="iOS" 12 | osx_image: xcode8.3 13 | language: node_js 14 | node_js: "6" 15 | jdk: oraclejdk8 16 | script: cd demo && npm run build.plugin && npm i && npm run build-ios-bundle 17 | - language: android 18 | os: linux 19 | env: 20 | - Platform="Android" 21 | jdk: oraclejdk8 22 | before_install: nvm install 6.10.3 23 | script: cd demo && npm run build.plugin && npm i && npm run build-android-bundle 24 | - stage: "Build and Test" 25 | env: 26 | - BuildAndroid="25" 27 | language: android 28 | os: linux 29 | jdk: oraclejdk8 30 | before_install: nvm install stable 31 | script: 32 | - cd src && npm i && npm run tsc && cd ../demo && tns build android 33 | - os: osx 34 | env: 35 | - BuildiOS="10.3" 36 | - Xcode="8.3" 37 | osx_image: xcode8.3 38 | language: node_js 39 | node_js: "6" 40 | jdk: oraclejdk8 41 | script: 42 | - cd src && npm i && npm run tsc && cd ../demo && tns build ios 43 | - os: linux 44 | language: android 45 | dist: precise 46 | sudo: required 47 | jdk: oraclejdk8 48 | before_script: 49 | - echo no | android create avd --force -n test -t android-21 -b armeabi-v7a 50 | - emulator -avd test -no-audio -no-window & 51 | - android-wait-for-emulator 52 | before_install: 53 | - nvm install 6 54 | script: cd src && npm run test.android 55 | - os: osx 56 | language: node_js 57 | node_js: "6" 58 | jdk: oraclejdk8 59 | osx_image: xcode8.3 60 | script: cd src && npm run test.ios 61 | 62 | android: 63 | components: 64 | - tools 65 | - platform-tools 66 | - build-tools-25.0.2 67 | - android-25 68 | - extra-android-m2repository 69 | - sys-img-armeabi-v7a-android-21 70 | 71 | install: 72 | - echo no | npm install -g nativescript 73 | - tns usage-reporting disable 74 | - tns error-reporting disable -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | nativescript-imagecropper 4 | Copyright (c) 2017, Brian Thurlow and Shiva Prasad 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | the Software, and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | # A {N} Image Cropping Plugin 9 | 10 | [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](http://choosealicense.com/licenses/mit/) 11 | [![npm](https://img.shields.io/npm/v/nativescript-imagecropper.svg)](https://www.npmjs.com/package/nativescript-imagecropper) [![npm](https://img.shields.io/npm/dt/nativescript-imagecropper.svg?label=npm%20downloads)](https://www.npmjs.com/package/nativescript-imagecropper) [![GitHub release](https://img.shields.io/github/release/bthurlow/nativescript-imagecropper.svg)](https://github.com/bthurlow/nativescript-imagecropper) 12 | 13 | ## Notes 14 | 15 | iOS 8+ 16 | 17 | Android 17+ 18 | 19 | v2.0.0+ the version of Android Lib has changed and the cropper looks different now, 20 | hence the breaking change 21 | 22 | ### Based on 23 | 24 | [TOCropViewController](https://github.com/TimOliver/TOCropViewController) for iOS 25 | 26 | [uCrop](https://github.com/Yalantis/uCrop) for Android 27 | 28 | ## Installation 29 | 30 | ### NativeScript 7+: 31 | Run `ns plugin add nativescript-imagecropper` 32 | 33 | ### NativeScript below 7: 34 | Run `tns plugin add nativescript-imagecropper@3.0.0` 35 | 36 | ## Screenshots 37 | 38 | ### Cropper UI & End result (android) 39 |        40 | 41 | ### Cropper UI (iOS) 42 | 43 | 44 | ### Usage (for TS demo, please see the demo folder) 45 | 46 | To use the image cropping module you must first require it. 47 | 48 | ```js 49 | var ImageCropper = require("nativescript-imagecropper").ImageCropper; 50 | ``` 51 | 52 | ### How to get the image source, from nativescript-camera plugin 53 | ```js 54 | var camera = require("nativescript-camera"); 55 | 56 | // You might want to request camera permissions first 57 | // check demo folder for sample implementation 58 | 59 | camera.takePicture({width:300,height:300,keepAspectRatio:true}) 60 | .then((imageAsset) => { 61 | let source = new imageSource.ImageSource(); 62 | source.fromAsset(imageAsset).then((source) => { 63 | // now you have the image source 64 | // pass it to the cropper 65 | // recommend using setTimeout like this 66 | setTimeout(() => { 67 | // on iOS we want a timeout of 1second as it takes time before 68 | // the imageSource is ready to be read by the plugin 69 | }, isAndroid ? 0 : 1000); 70 | }); 71 | }).catch((err) => { 72 | console.log("Error -> " + err.message); 73 | }); 74 | ``` 75 | 76 | ### Methods 77 | 78 | `show(ImageSource)`: Returns a cropped ImageSource 79 | 80 | ```js 81 | var imageCropper = new ImageCropper(); 82 | imageCropper.show(imageSource).then((args) => { 83 | console.dir(args); 84 | if(args.image !== null){ 85 | imageView.imageSource = args.image; 86 | } 87 | }) 88 | .catch(function(e){ 89 | console.dir(e); 90 | }); 91 | ``` 92 | 93 | `show(ImageSource,Options)`: Returns a cropped and resized ImageSource 94 | 95 | ```js 96 | var imageCropper = new ImageCropper(); 97 | imageCropper.show(imageSource,{width:300,height:300}).then((args) => { 98 | console.dir(args); 99 | if(args.image !== null){ 100 | imageView.imageSource = args.image; 101 | } 102 | }) 103 | .catch(function(e){ 104 | console.dir(e); 105 | }); 106 | ``` 107 | 108 | ### Options 109 | 110 | Option | Type | Description 111 | ------ | ------ | ------------------------------------------------ 112 | width | number | The width of the image you would like returned. 113 | height | number | The height of the image you would like returned. 114 | lockSquare | boolean | Pass this as true, to lock square aspect ratio on iOS, on android, this option doesn't make any difference. 115 | circularCrop | boolean | Pass this as true, to crop a circular image on iOS, on android, this options shows a circular mask while cropping, but returns a rectangular image. 116 | 117 | ### Android Config 118 | 119 | ```ts 120 | export interface OptionsAndroid { 121 | isFreeStyleCropEnabled?: boolean; // set to true to let user resize crop bounds (disabled by default) 122 | toolbarTitle?: string; // default 'Crop Image' 123 | toolbarTextColor?: string; // desired resolved color of Toolbar text and buttons (default is darker orange) 124 | toolbarColor?: string; // desired resolved color of the toolbar 125 | rootViewBackgroundColor?: string; // desired background color that should be applied to the root view 126 | logoColor?: string; // desired resolved color of logo fill (default is darker grey) 127 | statusBarColor?: string; // Set statusbar color 128 | showCropGrid?: boolean; // set to true if you want to see a crop grid/guidelines on top of an image 129 | showCropFrame?: boolean; // set to true if you want to see a crop frame rectangle on top of an image 130 | cropFrameStrokeWidth?: number; // desired width of crop frame line in pixels 131 | cropGridStrokeWidth?: number; // desired width of crop grid lines in pixels 132 | cropGridColor?: string; // desired color of crop grid/guidelines 133 | cropFrameColor?: string; // desired color of crop frame 134 | cropGridRowCount?: number; // crop grid rows count 135 | cropGridColumnCount?: number; // crop grid columns count 136 | hideBottomControls?: boolean; // set to true to hide the bottom controls (shown by default) 137 | compressionQuality?: number; // Set compression quality [0-100] that will be used to save resulting Bitmap 138 | dimmedLayerColor?: string; // desired color of dimmed area around the crop bounds 139 | setAspectRatioOptions?: AspectRatioOptions; // Pass an ordered list of desired aspect ratios that should be available for a user. 140 | toolbarCropDrawable?: any; // Android Drawable (pass native drawable object ONLY) 141 | toolbarCancelDrawable?: any; // Android Drawable (pass native drawable object ONLY) 142 | } 143 | 144 | export interface AspectRatio { 145 | aspectRatioTitle: string, 146 | aspectRatioX: number, 147 | aspectRatioY: number; 148 | } 149 | 150 | export interface AspectRatioOptions { 151 | defaultIndex: number; 152 | aspectRatios: AspectRatio[] 153 | } 154 | 155 | // example aspectRatio options 156 | setAspectRatioOptions: { 157 | defaultIndex: 0, 158 | aspectRatios: [ 159 | { 160 | aspectRatioTitle: '1:1', 161 | aspectRatioX: 1, 162 | aspectRatioY: 1 163 | }, 164 | { 165 | aspectRatioTitle: '16:9', 166 | aspectRatioX: 16, 167 | aspectRatioY: 9 168 | }, 169 | { 170 | aspectRatioTitle: '18:9', 171 | aspectRatioX: 18, 172 | aspectRatioY: 9 173 | } 174 | ] 175 | } 176 | ``` 177 | 178 | ### Additional notes for Android 179 | 180 | You can override library colors just specifying colors with the same names in your colors.xml file. 181 | For example: 182 | 183 | ```xml 184 | #000000 185 | ``` 186 | 187 | This will make toolbar color black if specified inside your `App_Resources/Android/values/colors.xml` file. 188 | 189 | #### Android styles to customize the cropper activity/styles 190 | 191 | ``` xml 192 | 193 | #FF6E40 194 | #CC5833 195 | #fff 196 | #000 197 | #FF6E40 198 | #fff 199 | #000 200 | #808080 201 | #000 202 | 203 | 204 | #80ffffff 205 | #ffffff 206 | #8c000000 207 | #4f212121 208 | ``` 209 | 210 | ### Returned Result Arguments 211 | 212 | Argument | Type | Result(s) 213 | -------- | ----------- | -------------------------------------------------------------------------- 214 | response | string | Success
Cancelled
Error 215 | image | ImageSource | `null` if there was an error or was cancelled
`ImageSource` on success 216 | 217 | ### Bonus: Snippet for using with nativescript-imagepicker 6.x 218 | 219 | ```js 220 | const context = imagepickerModule.create({ 221 | mode: 'single' // allow choosing single image 222 | }); 223 | context 224 | .authorize() 225 | .then(function() { 226 | return context.present(); 227 | }) 228 | .then(function(selection) { 229 | selection.forEach(function(selected) { 230 | selected.getImageAsync(source => { 231 | if (source) { 232 | const selectedImgSource = imageSource.fromNativeSource(source); 233 | imageCropper 234 | .show(selectedImgSource, { width: 500, height: 500 }) 235 | .then(args => { 236 | if (args.image !== null) { 237 | // Use args.image 238 | } 239 | }) 240 | .catch(function(e) { 241 | console.log(e); 242 | }); 243 | } 244 | }); 245 | }); 246 | }) 247 | .catch(function(e) { 248 | console.log(e); 249 | }); 250 | ``` 251 | -------------------------------------------------------------------------------- /assets/cropperresultandroid.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/assets/cropperresultandroid.jpeg -------------------------------------------------------------------------------- /assets/cropperuiandroid.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/assets/cropperuiandroid.jpeg -------------------------------------------------------------------------------- /assets/cropperuiios.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/assets/cropperuiios.png -------------------------------------------------------------------------------- /demo/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | trim_trailing_whitespace = true 7 | charset = utf-8 8 | 9 | [*.json] 10 | indent_style = space 11 | indent_size = 2 12 | 13 | [*.js] 14 | indent_style = space 15 | indent_size = 2 16 | 17 | [*.ts] 18 | indent_style = space 19 | indent_size = 2 -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | # NativeScript 2 | hooks/ 3 | node_modules/ 4 | platforms/ 5 | 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | 13 | # General 14 | .DS_Store 15 | .AppleDouble 16 | .LSOverride 17 | .idea 18 | .cloud 19 | .project 20 | tmp/ 21 | typings/ 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | -------------------------------------------------------------------------------- /demo/App_Resources/Android/app.gradle: -------------------------------------------------------------------------------- 1 | // Add your native dependencies here: 2 | 3 | // Uncomment to add recyclerview-v7 dependency 4 | //dependencies { 5 | // implementation 'com.android.support:recyclerview-v7:+' 6 | //} 7 | 8 | // If you want to add something to be applied before applying plugins' include.gradle files 9 | // e.g. project.ext.googlePlayServicesVersion = "15.0.1" 10 | // create a file named before-plugins.gradle in the current directory and place it there 11 | 12 | android { 13 | defaultConfig { 14 | minSdkVersion 17 15 | generatedDensities = [] 16 | } 17 | aaptOptions { 18 | additionalParameters "--no-version-vectors" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-hdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-hdpi/background.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-hdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-hdpi/logo.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-ldpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-ldpi/background.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-ldpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-ldpi/logo.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-mdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-mdpi/background.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-mdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-mdpi/logo.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-nodpi/splash_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-xhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-xhdpi/background.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-xhdpi/logo.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-xxhdpi/background.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-xxhdpi/logo.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-xxxhdpi/background.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/drawable-xxxhdpi/logo.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/Android/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/values-v21/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #65ADF1 4 | -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 13 | 14 | 15 | 18 | 19 | 20 | 23 | 24 | 28 | -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/values-v29/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 11 | 12 | -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #F5F5F5 4 | #757575 5 | #65ADF1 6 | #272734 7 | -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | -------------------------------------------------------------------------------- /demo/App_Resources/Android/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 17 | 18 | 20 | 21 | 22 | 29 | 30 | 32 | 33 | 34 | 39 | 40 | 42 | 43 | -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "icon-20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "icon-20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "icon-29.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "icon-29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "icon-29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "icon-40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "icon-40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "icon-60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "icon-60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "icon-20.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "icon-20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "icon-29.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "icon-29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "icon-40.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "icon-40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "icon-76.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "icon-76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "icon-83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "icon-1024.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-1024.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20@2x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-20@3x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchScreen-AspectFill.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchScreen-AspectFill@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchScreen-AspectFill@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@3x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchScreen-Center.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchScreen-Center@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchScreen-Center@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/demo/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@3x.png -------------------------------------------------------------------------------- /demo/App_Resources/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiresFullScreen 28 | 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /demo/App_Resources/iOS/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /demo/App_Resources/iOS/build.xcconfig: -------------------------------------------------------------------------------- 1 | // You can add custom settings here 2 | // for example you can uncomment the following line to force distribution code signing 3 | // CODE_SIGN_IDENTITY = iPhone Distribution 4 | // To build for device with XCode you need to specify your development team. 5 | // DEVELOPMENT_TEAM = YOUR_TEAM_ID; 6 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 7 | -------------------------------------------------------------------------------- /demo/app/app-root.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /demo/app/app.css: -------------------------------------------------------------------------------- 1 | /* 2 | In NativeScript, the app.css file is where you place CSS rules that 3 | you would like to apply to your entire application. Check out 4 | http://docs.nativescript.org/ui/styling for a full list of the CSS 5 | selectors and properties you can use to style UI components. 6 | 7 | /* 8 | In many cases you may want to use the NativeScript core theme instead 9 | of writing your own CSS rules. You can learn more about the 10 | NativeScript core theme at https://github.com/nativescript/theme 11 | The imported CSS rules must precede all other types of rules. 12 | */ 13 | @import '@nativescript/theme/css/core.css'; 14 | @import '@nativescript/theme/css/default.css'; 15 | 16 | /* Place any CSS rules you want to apply on both iOS and Android here. 17 | This is where the vast majority of your CSS code goes. */ 18 | 19 | /* 20 | The following CSS rule changes the font size of all Buttons that have the 21 | '-primary' class modifier. 22 | */ 23 | Button.-primary { 24 | font-size: 18; 25 | } 26 | 27 | .title { 28 | horizontal-align: center; 29 | margin: 20; 30 | } 31 | -------------------------------------------------------------------------------- /demo/app/app.ts: -------------------------------------------------------------------------------- 1 | /* 2 | In NativeScript, the app.ts file is the entry point to your application. 3 | You can use this file to perform app-level initialization, but the primary 4 | purpose of the file is to pass control to the app’s first module. 5 | */ 6 | 7 | import { Application } from '@nativescript/core' 8 | 9 | Application.run({ moduleName: 'app-root' }) 10 | 11 | /* 12 | Do not place any code after the application has been started as it will not 13 | be executed on iOS. 14 | */ 15 | -------------------------------------------------------------------------------- /demo/app/main-page.ts: -------------------------------------------------------------------------------- 1 | import { Button, EventData, Page, ShowModalOptions } from '@nativescript/core'; 2 | import { ImageCropperModel } from './main-view-model'; 3 | 4 | // Event handler for Page 'loaded' event attached in main-page.xml 5 | export function pageLoaded(args: EventData) { 6 | // Get the event sender 7 | const page = args.object; 8 | page.bindingContext = new ImageCropperModel(page, 'croppedImage'); 9 | } 10 | 11 | export function openModal(args) { 12 | const mainView: Button = 8 | 9 | 10 | -------------------------------------------------------------------------------- /ns-ng-snippet/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from "@angular/core"; 2 | import { ImageSource, isAndroid } from "@nativescript/core"; 3 | import * as camera from "nativescript-camera"; 4 | import { ImageCropper, OptionsAndroid } from "nativescript-imagecropper"; 5 | import * as permissions from "nativescript-permissions"; 6 | 7 | declare var android: any; 8 | @Component({ 9 | selector: "my-app", 10 | templateUrl: "./app.component.html", 11 | }) 12 | export class AppComponent implements OnInit { 13 | // Your TypeScript logic goes here 14 | 15 | private imageCropper: ImageCropper; 16 | public imageUrl: any; 17 | // private image ="~/images/img.jpg"; 18 | 19 | ngOnInit() { 20 | this.imageCropper = new ImageCropper(); 21 | this.imageUrl = null; 22 | } 23 | 24 | takePhoto() { 25 | const options = { lockSquare: true }; 26 | const androidOptions = { 27 | isFreeStyleCropEnabled: true, 28 | statusBarColor: "black", 29 | setAspectRatioOptions: { 30 | defaultIndex: 0, 31 | aspectRatios: [ 32 | { 33 | aspectRatioTitle: "1:1", 34 | aspectRatioX: 1, 35 | aspectRatioY: 1, 36 | }, 37 | { 38 | aspectRatioTitle: "16:9", 39 | aspectRatioX: 16, 40 | aspectRatioY: 9, 41 | }, 42 | { 43 | aspectRatioTitle: "18:9", 44 | aspectRatioX: 18, 45 | aspectRatioY: 9, 46 | }, 47 | ], 48 | }, 49 | }; 50 | 51 | if (camera.isAvailable()) { 52 | permissions 53 | .requestPermission([ 54 | android.Manifest.permission.CAMERA, 55 | android.Manifest.permission.WRITE_EXTERNAL_STORAGE, 56 | ]) 57 | .then(() => { 58 | camera 59 | .takePicture({ 60 | width: 800, 61 | keepAspectRatio: true, 62 | saveToGallery: false, 63 | cameraFacing: "rear", 64 | }) 65 | .then((imageAsset) => { 66 | ImageSource.fromAsset(imageAsset).then((source) => { 67 | setTimeout( 68 | async () => { 69 | this.imageCropper 70 | .show(source, options, androidOptions) 71 | .then((args) => { 72 | if (args.image !== null) { 73 | this.imageUrl = args.image; 74 | } 75 | }) 76 | .catch((e) => { 77 | console.dir(e); 78 | }); 79 | }, 80 | isAndroid ? 0 : 1000 81 | ); 82 | }); 83 | }) 84 | .catch((err) => { 85 | console.log("Error -> " + err.message); 86 | }); 87 | }) 88 | .catch(() => { 89 | // When user denies permission 90 | console.log("User denied permissions"); 91 | }); 92 | } 93 | } 94 | 95 | resizePhoto() { 96 | const options = { width: 300, height: 300, lockSquare: true }; 97 | 98 | if (camera.isAvailable()) { 99 | permissions 100 | .requestPermission([ 101 | android.Manifest.permission.CAMERA, 102 | android.Manifest.permission.WRITE_EXTERNAL_STORAGE, 103 | ]) 104 | .then(() => { 105 | camera 106 | .takePicture({ 107 | width: 800, 108 | keepAspectRatio: true, 109 | saveToGallery: false, 110 | cameraFacing: "rear", 111 | }) 112 | .then((imageAsset) => { 113 | ImageSource.fromAsset(imageAsset).then((source) => { 114 | setTimeout( 115 | async () => { 116 | this.imageCropper 117 | .show(source, options) 118 | .then((args) => { 119 | if (args.image !== null) { 120 | this.imageUrl = args.image; 121 | } 122 | }) 123 | .catch((e) => { 124 | console.dir(e); 125 | }); 126 | }, 127 | isAndroid ? 0 : 1000 128 | ); 129 | }); 130 | }) 131 | .catch((err) => { 132 | console.log("Error -> " + err.message); 133 | }); 134 | }) 135 | .catch(() => { 136 | // When user denies permission 137 | console.log("User denied permissions"); 138 | }); 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /ns-vue-snippet/vue-snippet.js: -------------------------------------------------------------------------------- 1 | // Contributed by Lukas Park on 20 Oct 2017 2 | const Vue = require("./nativescript-vue"); 3 | const ImageCropper = require("nativescript-imagecropper").ImageCropper; 4 | const camera = require("nativescript-camera"); 5 | const imageSource = require("@nativescript/core/image-source"); 6 | const isAndroid = require("@nativescript/core/platform").isAndroid; 7 | 8 | new Vue({ 9 | data: function() { 10 | var obj = { 11 | image_src: "" 12 | } 13 | return obj; 14 | }, 15 | mounted: function() { 16 | setTimeout(() => { 17 | camera.requestPermissions(); 18 | }); 19 | }, 20 | methods: { 21 | do_capture: function() { 22 | const options = { lockSquare: true }; 23 | const androidOptions = { 24 | isFreeStyleCropEnabled: true, 25 | statusBarColor: 'black', 26 | setAspectRatioOptions: { 27 | defaultIndex: 0, 28 | aspectRatios: [ 29 | { 30 | aspectRatioTitle: '1:1', 31 | aspectRatioX: 1, 32 | aspectRatioY: 1 33 | }, 34 | { 35 | aspectRatioTitle: '16:9', 36 | aspectRatioX: 16, 37 | aspectRatioY: 9 38 | }, 39 | { 40 | aspectRatioTitle: '18:9', 41 | aspectRatioX: 18, 42 | aspectRatioY: 9 43 | } 44 | ] 45 | } 46 | }; 47 | var self = this; 48 | camera.takePicture({ 49 | width: 800, 50 | keepAspectRatio: true, 51 | saveToGallery: false, 52 | cameraFacing: 'rear' 53 | }) 54 | .then((imageAsset) => { 55 | let source = new imageSource.ImageSource(); 56 | source.fromAsset(imageAsset).then((picture) => { 57 | setTimeout(async () => { 58 | imageCropper 59 | .show(picture, options, androidOptions) 60 | .then(args => { 61 | console.dir(args); 62 | if (args.image !== null) { 63 | self.image_src = args.image; 64 | } 65 | }) 66 | .catch(function(e) { 67 | console.dir(e); 68 | }); 69 | }, isAndroid ? 0 : 1000); 70 | }); 71 | }).catch((err) => { 72 | console.log("Error -> " + err.message); 73 | }); 74 | } 75 | }, 76 | template: ` 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | `, 88 | }).$start(); 89 | -------------------------------------------------------------------------------- /publish/pack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SOURCE_DIR=../src; 4 | TO_SOURCE_DIR=src; 5 | PACK_DIR=package; 6 | ROOT_DIR=..; 7 | PUBLISH=--publish 8 | 9 | install(){ 10 | npm i 11 | } 12 | 13 | pack() { 14 | 15 | echo 'Clearing /src and /package...' 16 | node_modules/.bin/rimraf "$TO_SOURCE_DIR" 17 | node_modules/.bin/rimraf "$PACK_DIR" 18 | 19 | # copy src 20 | echo 'Copying src...' 21 | node_modules/.bin/ncp "$SOURCE_DIR" "$TO_SOURCE_DIR" 22 | 23 | # copy README & LICENSE to src 24 | echo 'Copying README and LICENSE to /src...' 25 | node_modules/.bin/ncp "$ROOT_DIR"/LICENSE "$TO_SOURCE_DIR"/LICENSE 26 | node_modules/.bin/ncp "$ROOT_DIR"/README.md "$TO_SOURCE_DIR"/README.md 27 | 28 | # compile package and copy files required by npm 29 | echo 'Building /src...' 30 | cd "$TO_SOURCE_DIR" 31 | node_modules/.bin/tsc 32 | cd .. 33 | 34 | echo 'Creating package...' 35 | # create package dir 36 | mkdir "$PACK_DIR" 37 | 38 | # create the package 39 | cd "$PACK_DIR" 40 | npm pack ../"$TO_SOURCE_DIR" 41 | 42 | # delete source directory used to create the package 43 | cd .. 44 | node_modules/.bin/rimraf "$TO_SOURCE_DIR" 45 | } 46 | 47 | install && pack -------------------------------------------------------------------------------- /publish/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-publish", 3 | "version": "1.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "nativescript-publish", 9 | "version": "1.0.0", 10 | "devDependencies": { 11 | "ncp": "^2.0.0", 12 | "rimraf": "^2.5.0" 13 | } 14 | }, 15 | "node_modules/balanced-match": { 16 | "version": "1.0.0", 17 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 18 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 19 | "dev": true 20 | }, 21 | "node_modules/brace-expansion": { 22 | "version": "1.1.11", 23 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 24 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 25 | "dev": true, 26 | "dependencies": { 27 | "balanced-match": "^1.0.0", 28 | "concat-map": "0.0.1" 29 | } 30 | }, 31 | "node_modules/concat-map": { 32 | "version": "0.0.1", 33 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 34 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 35 | "dev": true 36 | }, 37 | "node_modules/fs.realpath": { 38 | "version": "1.0.0", 39 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 40 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 41 | "dev": true 42 | }, 43 | "node_modules/glob": { 44 | "version": "7.1.4", 45 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", 46 | "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", 47 | "dev": true, 48 | "dependencies": { 49 | "fs.realpath": "^1.0.0", 50 | "inflight": "^1.0.4", 51 | "inherits": "2", 52 | "minimatch": "^3.0.4", 53 | "once": "^1.3.0", 54 | "path-is-absolute": "^1.0.0" 55 | }, 56 | "engines": { 57 | "node": "*" 58 | } 59 | }, 60 | "node_modules/inflight": { 61 | "version": "1.0.6", 62 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 63 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 64 | "dev": true, 65 | "dependencies": { 66 | "once": "^1.3.0", 67 | "wrappy": "1" 68 | } 69 | }, 70 | "node_modules/inherits": { 71 | "version": "2.0.4", 72 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 73 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 74 | "dev": true 75 | }, 76 | "node_modules/minimatch": { 77 | "version": "3.0.4", 78 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 79 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 80 | "dev": true, 81 | "dependencies": { 82 | "brace-expansion": "^1.1.7" 83 | }, 84 | "engines": { 85 | "node": "*" 86 | } 87 | }, 88 | "node_modules/ncp": { 89 | "version": "2.0.0", 90 | "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", 91 | "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=", 92 | "dev": true, 93 | "bin": { 94 | "ncp": "bin/ncp" 95 | } 96 | }, 97 | "node_modules/once": { 98 | "version": "1.4.0", 99 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 100 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 101 | "dev": true, 102 | "dependencies": { 103 | "wrappy": "1" 104 | } 105 | }, 106 | "node_modules/path-is-absolute": { 107 | "version": "1.0.1", 108 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 109 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 110 | "dev": true, 111 | "engines": { 112 | "node": ">=0.10.0" 113 | } 114 | }, 115 | "node_modules/rimraf": { 116 | "version": "2.7.1", 117 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", 118 | "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", 119 | "dev": true, 120 | "dependencies": { 121 | "glob": "^7.1.3" 122 | }, 123 | "bin": { 124 | "rimraf": "bin.js" 125 | } 126 | }, 127 | "node_modules/wrappy": { 128 | "version": "1.0.2", 129 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 130 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 131 | "dev": true 132 | } 133 | }, 134 | "dependencies": { 135 | "balanced-match": { 136 | "version": "1.0.0", 137 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 138 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 139 | "dev": true 140 | }, 141 | "brace-expansion": { 142 | "version": "1.1.11", 143 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 144 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 145 | "dev": true, 146 | "requires": { 147 | "balanced-match": "^1.0.0", 148 | "concat-map": "0.0.1" 149 | } 150 | }, 151 | "concat-map": { 152 | "version": "0.0.1", 153 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 154 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 155 | "dev": true 156 | }, 157 | "fs.realpath": { 158 | "version": "1.0.0", 159 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 160 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 161 | "dev": true 162 | }, 163 | "glob": { 164 | "version": "7.1.4", 165 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", 166 | "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", 167 | "dev": true, 168 | "requires": { 169 | "fs.realpath": "^1.0.0", 170 | "inflight": "^1.0.4", 171 | "inherits": "2", 172 | "minimatch": "^3.0.4", 173 | "once": "^1.3.0", 174 | "path-is-absolute": "^1.0.0" 175 | } 176 | }, 177 | "inflight": { 178 | "version": "1.0.6", 179 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 180 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 181 | "dev": true, 182 | "requires": { 183 | "once": "^1.3.0", 184 | "wrappy": "1" 185 | } 186 | }, 187 | "inherits": { 188 | "version": "2.0.4", 189 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 190 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 191 | "dev": true 192 | }, 193 | "minimatch": { 194 | "version": "3.0.4", 195 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 196 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 197 | "dev": true, 198 | "requires": { 199 | "brace-expansion": "^1.1.7" 200 | } 201 | }, 202 | "ncp": { 203 | "version": "2.0.0", 204 | "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", 205 | "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=", 206 | "dev": true 207 | }, 208 | "once": { 209 | "version": "1.4.0", 210 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 211 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 212 | "dev": true, 213 | "requires": { 214 | "wrappy": "1" 215 | } 216 | }, 217 | "path-is-absolute": { 218 | "version": "1.0.1", 219 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 220 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 221 | "dev": true 222 | }, 223 | "rimraf": { 224 | "version": "2.7.1", 225 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", 226 | "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", 227 | "dev": true, 228 | "requires": { 229 | "glob": "^7.1.3" 230 | } 231 | }, 232 | "wrappy": { 233 | "version": "1.0.2", 234 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 235 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 236 | "dev": true 237 | } 238 | } 239 | } 240 | -------------------------------------------------------------------------------- /publish/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-publish", 3 | "version": "1.0.0", 4 | "description": "Publish helper", 5 | "devDependencies": { 6 | "ncp": "^2.0.0", 7 | "rimraf": "^2.5.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /publish/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PACK_DIR=package; 4 | 5 | publish() { 6 | cd $PACK_DIR 7 | echo 'Publishing to npm...' 8 | npm publish *.tgz 9 | } 10 | 11 | ./pack.sh && publish -------------------------------------------------------------------------------- /service-example/image-upload-service.js: -------------------------------------------------------------------------------- 1 | import * as L from 'nativescript-localize'; 2 | import { ImagePickerMediaType, create as PickImage } from 'nativescript-imagepicker'; 3 | import { ImageSource, fromNativeSource } from '@nativescript/core/image-source'; 4 | import { takePicture as TakePicture, isAvailable as isCameraAvailable } from 'nativescript-camera'; 5 | import { knownFolders, path } from '@nativescript/core/file-system'; 6 | import { Frame } from '@nativescript/core/ui/frame'; 7 | import { ImageCropper } from '@proplugins/nativescript-imagecropper'; 8 | import { session as Uploader } from 'nativescript-background-http'; 9 | import { UserService } from '~/services/user-service'; 10 | import { action } from '@nativescript/core/ui/dialogs'; 11 | import { isAndroid } from '@nativescript/core/platform'; 12 | import { loader } from '~/shared/helpers'; 13 | import { requestPermission } from '@proplugins/nativescript-permissions'; 14 | 15 | export class ImageUploadService { 16 | 17 | constructor() { 18 | if (ImageUploadService._instance) { 19 | throw new Error( 20 | 'Use ImageUploadService.getInstance() instead of new.' 21 | ); 22 | } 23 | 24 | this._imageCropper = new ImageCropper(); 25 | } 26 | 27 | chooseImage({ 28 | promptText, 29 | destinationId, 30 | apiPath, 31 | logEvent, 32 | cameraFacing 33 | }) { 34 | this.apiPath = apiPath; 35 | if (!apiPath) { 36 | console.log('Error: apiPath not specified'); 37 | 38 | return; 39 | } 40 | action({ 41 | message: promptText, 42 | actions: [L('imageUploadService.takeAPic'), L('imageUploadService.chooseFromGallery'), L('imageUploadService.cancelButton')] 43 | }).then(r => { 44 | let promise; 45 | switch (r) { 46 | case L('imageUploadService.takeAPic'): 47 | promise = this._takeAPicture(cameraFacing); break; 48 | case L('imageUploadService.chooseFromGallery'): 49 | promise = this._chooseFromGallery(); break; 50 | default: break; 51 | } 52 | 53 | promise.then(image => { 54 | const task = this._uploadImage(image, destinationId); 55 | loader.show({ 56 | message: L('imageUploadService.uploading') 57 | }); 58 | task.on('progress', logEvent); 59 | task.on('error', (args) => { 60 | loader.hide(); 61 | logEvent(args); 62 | }); 63 | task.on('complete', logEvent); 64 | task.on('responded', (args) => { 65 | loader.hide(); 66 | logEvent(args); 67 | }); 68 | }).catch(console.log); 69 | }); 70 | } 71 | 72 | /** 73 | * Upload image to server 74 | * @private 75 | * @param { object } image 76 | * @memberof ImageUploadService 77 | */ 78 | _uploadImage(image, destinationId) { 79 | const folder = knownFolders.documents().path; 80 | const timestamp = new Date().getTime(); 81 | const fileName = `image-${timestamp}.png`; 82 | const imageUrl = path.join(folder, fileName); 83 | const saved = image.saveToFile( 84 | imageUrl, 85 | 'png', 86 | 100 87 | ); 88 | if (saved) { 89 | const imageWidget = Frame.getFrameById('rootFrame').currentPage.getViewById(destinationId); 90 | if (imageWidget) { 91 | setTimeout(() => { 92 | if (isAndroid) { 93 | imageWidget.src = imageUrl; 94 | } else { 95 | imageWidget.src = image; 96 | } 97 | }, 1000); 98 | } 99 | const session = Uploader('image-upload'); 100 | const token = UserService.getInstance().token; 101 | const request = { 102 | url: `${global.getUrl('community_url')}${this.apiPath}?api_token=${token}`, 103 | method: 'POST', 104 | headers: { 105 | 'Content-Type': 'application/octet-stream', 106 | 'User-Agent': 'Mozilla/5.0', 107 | 'Accept': 'application/json', 108 | 'App-Version': global.settings.appVersion 109 | }, 110 | androidNotificationTitle: L('imageUploadService.uploading'), 111 | androidAutoDeleteAfterUpload: true 112 | }; 113 | 114 | // TODO: Augment this to enable configurable request params 115 | const params = [ 116 | { name: 'image', filename: imageUrl, mimeType: 'image/png' }, 117 | { name: 'is_public', value: '1' } 118 | ]; 119 | const task = session.multipartUpload(params, request); 120 | 121 | return task; 122 | } else { 123 | return null; 124 | } 125 | } 126 | 127 | /** 128 | * Crop image 129 | * @private 130 | * @param { string, string } destinationId selectedImageSource 131 | * @memberof ImageUploadService 132 | */ 133 | _cropImage({ selectedImageSource }) { 134 | return new Promise(async (resolve, reject) => { 135 | const cropResponse = await this._imageCropper.show(selectedImageSource, { 136 | width: 500, 137 | height: 500 138 | }, { 139 | isFreeStyleCropEnabled: true, 140 | toolbarColor: '#303235', 141 | toolbarTextColor: 'white', 142 | statusBarColor: 'black' 143 | }).catch(e => { 144 | reject('Error in cropping'); 145 | console.log(e); 146 | }); 147 | if (cropResponse.response === 'Success' && cropResponse.image !== null) { 148 | resolve(cropResponse.image); 149 | } else { 150 | reject('No Image => _cropImage'); 151 | } 152 | }); 153 | } 154 | 155 | /** 156 | * Take a picture using camera 157 | * @private 158 | * @memberof ImageUploadService 159 | */ 160 | _takeAPicture(cameraFacing = 'rear') { 161 | return new Promise(async (resolve, reject) => { 162 | if (isCameraAvailable()) { 163 | if (isAndroid) { 164 | const resp = await requestPermission([ 165 | android.Manifest.permission.CAMERA, 166 | android.Manifest.permission.WRITE_EXTERNAL_STORAGE 167 | ], 'Need camera permission to take photo').catch(e => { 168 | reject('User rejected permission'); 169 | console.log(e); 170 | }); 171 | 172 | if (!resp) { 173 | return; 174 | } 175 | } 176 | const imageAsset = await TakePicture({ 177 | width: 800, 178 | keepAspectRatio: true, 179 | saveToGallery: false, 180 | cameraFacing 181 | }).catch(e => { 182 | reject('No Image => _takeAPicture'); 183 | console.log(e); 184 | }); 185 | 186 | if (imageAsset) { 187 | loader.show({ 188 | message: L('imageUploadService.pleaseWait') 189 | }); 190 | const source = new ImageSource(); 191 | const selectedImageSource = await source.fromAsset(imageAsset).catch(e => { 192 | reject('Failed to get source'); console.log(e); 193 | }); 194 | 195 | setTimeout(async () => { 196 | const image = await this._cropImage({ 197 | selectedImageSource 198 | }).catch(e => { 199 | console.log('Failed to Crop'); console.log(e); 200 | }); 201 | loader.hide(); 202 | if (image) { 203 | resolve(image); 204 | } 205 | }, isAndroid ? 0 : 1000); 206 | } 207 | } else { 208 | reject('No camera'); 209 | } 210 | }); 211 | } 212 | 213 | /** 214 | * Choose Image from Gallery 215 | * @private 216 | * @memberof ImageUploadService 217 | */ 218 | _chooseFromGallery() { 219 | return new Promise(async (resolve, reject) => { 220 | const context = PickImage({ mode: 'single', mediaType: ImagePickerMediaType.Image }); 221 | if (isAndroid) { 222 | const resp = await requestPermission([ 223 | android.Manifest.permission.WRITE_EXTERNAL_STORAGE 224 | ], 'Need storage to read photo').catch(e => { 225 | reject('User rejected permission'); 226 | console.log(e); 227 | }); 228 | 229 | if (!resp) { 230 | return; 231 | } 232 | } 233 | const [selection] = await context.present().catch(e => { 234 | reject('Error in choosing image'); console.log(e); 235 | }); 236 | 237 | if (selection) { 238 | selection.getImageAsync(async source => { 239 | if (source) { 240 | const selectedImageSource = fromNativeSource(source); 241 | const image = await this._cropImage({ 242 | selectedImageSource 243 | }).catch(e => { 244 | console.log('Failed to Crop'); console.log(e); 245 | }); 246 | if (image) { 247 | resolve(image); 248 | } 249 | } 250 | }); 251 | } 252 | }); 253 | } 254 | 255 | /** 256 | * @returns {ImageUploadService} 257 | */ 258 | static getInstance() { 259 | if (!ImageUploadService._instance) { 260 | ImageUploadService._instance = new ImageUploadService(); 261 | } 262 | 263 | return ImageUploadService._instance; 264 | } 265 | } 266 | -------------------------------------------------------------------------------- /src/.npmignore: -------------------------------------------------------------------------------- 1 | *.map 2 | *.ts 3 | !index.d.ts 4 | tsconfig.json 5 | *.tgz 6 | -------------------------------------------------------------------------------- /src/imagecropper.android.ts: -------------------------------------------------------------------------------- 1 | import { AndroidApplication, Application, Color, Folder, ImageSource, knownFolders, path } from '@nativescript/core'; 2 | import { OptionsAndroid, OptionsCommon, Result } from './'; 3 | 4 | let _options: OptionsCommon; 5 | declare var com: any; 6 | 7 | export class ImageCropper { 8 | public show(image: ImageSource, options: OptionsCommon = {}, androidOptions: OptionsAndroid = {}): Promise { 9 | return new Promise((resolve: (val: Result) => void, reject: (val: Result) => void) => { 10 | try { 11 | _options = options; 12 | if (image.android) { 13 | const sourcePathTemp: string = ImageCropper._storeImageSource(image); 14 | const folder: Folder = knownFolders.temp(); 15 | const destinationPathTemp: string = path.join(folder.path, "destTemp.jpeg"); 16 | if (sourcePathTemp == null) { 17 | ImageCropper._cleanFiles(); 18 | reject({ 19 | response: "Error", 20 | image: null 21 | }); 22 | } 23 | 24 | const sourcePath: android.net.Uri = android.net.Uri.parse("file://" + sourcePathTemp); // Fix our path that comes from {N} file-system. 25 | const destinationPath: android.net.Uri = android.net.Uri.parse("file://" + destinationPathTemp); // Fix our path that comes from {N} file-system. 26 | 27 | const onResult = function(args) { 28 | const requestCode = args.requestCode; 29 | const resultCode = args.resultCode; 30 | const data = args.intent; 31 | // var _that = this; 32 | 33 | if (resultCode === android.app.Activity.RESULT_OK && requestCode === com.yalantis.ucrop.UCrop.REQUEST_CROP) { 34 | const resultUri: android.net.Uri = com.yalantis.ucrop.UCrop.getOutput(data); 35 | const is: ImageSource = new ImageSource(); 36 | try { 37 | is.setNativeSource(android.graphics.BitmapFactory.decodeFile(resultUri.getPath())); 38 | } catch (e) { 39 | console.error(e); 40 | } 41 | ImageCropper._cleanFiles(); 42 | Application.android.off(AndroidApplication.activityResultEvent, onResult); 43 | if (is.android) { 44 | resolve({ 45 | response: "Success", 46 | image: is, 47 | }); 48 | } else { 49 | reject({ 50 | response: "Error", 51 | image: null 52 | }); 53 | } 54 | return; 55 | } 56 | else if (resultCode === android.app.Activity.RESULT_CANCELED && requestCode === com.yalantis.ucrop.UCrop.REQUEST_CROP) { 57 | ImageCropper._cleanFiles(); 58 | Application.android.off(AndroidApplication.activityResultEvent, onResult); 59 | resolve({ 60 | response: "Cancelled", 61 | image: null 62 | }); 63 | return; 64 | } 65 | else if (resultCode === com.yalantis.ucrop.UCrop.RESULT_ERROR) { 66 | ImageCropper._cleanFiles(); 67 | const cropError: java.lang.Throwable = com.yalantis.ucrop.UCrop.getError(data); 68 | console.log(cropError.getMessage()); 69 | Application.android.off(AndroidApplication.activityResultEvent, onResult); 70 | reject({ 71 | response: "Error", 72 | image: null 73 | }); 74 | return; 75 | } 76 | }; 77 | 78 | Application.android.on(AndroidApplication.activityResultEvent, onResult); 79 | 80 | const options = new com.yalantis.ucrop.UCrop.Options(); 81 | options.setCircleDimmedLayer(!!_options.circularCrop); 82 | options.setFreeStyleCropEnabled(!!androidOptions.isFreeStyleCropEnabled); 83 | if (typeof androidOptions.isFreeStyleCropEnabled === 'boolean') { 84 | options.setShowCropGrid(androidOptions.isFreeStyleCropEnabled); 85 | } 86 | if (typeof androidOptions.showCropFrame === 'boolean') { 87 | options.setShowCropFrame(androidOptions.showCropFrame); 88 | } 89 | if (typeof androidOptions.hideBottomControls === 'boolean') { 90 | options.setHideBottomControls(androidOptions.hideBottomControls); 91 | } 92 | options.setToolbarTitle(androidOptions.toolbarTitle ? androidOptions.toolbarTitle : 'Crop Image'); 93 | 94 | if (typeof androidOptions.toolbarTextColor === 'string') { 95 | options.setToolbarWidgetColor(new Color(androidOptions.toolbarTextColor).android); 96 | } 97 | if (typeof androidOptions.toolbarColor === 'string') { 98 | options.setToolbarColor(new Color(androidOptions.toolbarColor).android); 99 | } 100 | if (typeof androidOptions.rootViewBackgroundColor === 'string') { 101 | options.setRootViewBackgroundColor(new Color(androidOptions.rootViewBackgroundColor).android); 102 | } 103 | if (typeof androidOptions.logoColor === 'string') { 104 | options.setLogoColor(new Color(androidOptions.logoColor).android); 105 | } 106 | if (typeof androidOptions.statusBarColor === 'string') { 107 | options.setStatusBarColor(new Color(androidOptions.statusBarColor).android); 108 | } 109 | if (typeof androidOptions.cropGridColor === 'string') { 110 | options.setCropGridColor(new Color(androidOptions.cropGridColor).android); 111 | } 112 | if (typeof androidOptions.cropFrameColor === 'string') { 113 | options.setCropFrameColor(new Color(androidOptions.cropFrameColor).android); 114 | } 115 | if (typeof androidOptions.dimmedLayerColor === 'string') { 116 | options.setDimmedLayerColor(new Color(androidOptions.dimmedLayerColor).android); 117 | } 118 | if (typeof androidOptions.cropGridRowCount === 'number') { 119 | options.setCropGridRowCount(androidOptions.cropGridRowCount); 120 | } 121 | if (typeof androidOptions.cropGridColumnCount === 'number') { 122 | options.setCropGridColumnCount(androidOptions.cropGridColumnCount); 123 | } 124 | if (typeof androidOptions.cropFrameStrokeWidth === 'number') { 125 | options.setCropFrameStrokeWidth(androidOptions.cropFrameStrokeWidth); 126 | } 127 | if (typeof androidOptions.cropGridStrokeWidth === 'number') { 128 | options.setCropGridStrokeWidth(androidOptions.cropGridStrokeWidth); 129 | } 130 | if (typeof androidOptions.compressionQuality === 'number' && androidOptions.compressionQuality >= 0 131 | && androidOptions.compressionQuality <= 100) { 132 | options.setCompressionQuality(androidOptions.compressionQuality); 133 | } 134 | if (typeof androidOptions.toolbarCropDrawable !== 'undefined') { 135 | options.setToolbarCropDrawable(androidOptions.toolbarCropDrawable); 136 | } 137 | if (typeof androidOptions.toolbarCancelDrawable !== 'undefined') { 138 | options.setToolbarCancelDrawable(androidOptions.toolbarCancelDrawable); 139 | } 140 | if (typeof androidOptions.setAspectRatioOptions !== 'undefined') { 141 | const aspectRatios = []; 142 | androidOptions.setAspectRatioOptions.aspectRatios.forEach(ratio => { 143 | aspectRatios.push(new com.yalantis.ucrop.model.AspectRatio( 144 | ratio.aspectRatioTitle, 145 | ratio.aspectRatioX, 146 | ratio.aspectRatioY 147 | )); 148 | }); 149 | options.setAspectRatioOptions(androidOptions.setAspectRatioOptions.defaultIndex, aspectRatios); 150 | } 151 | 152 | if (_options && _options.width && _options.height) { 153 | const gcd = ImageCropper._gcd(_options.width, _options.height); 154 | // console.log("gcd:" + gcd.toString()); 155 | 156 | com.yalantis.ucrop.UCrop.of(sourcePath, destinationPath) 157 | .withAspectRatio(_options.width / gcd, _options.height / gcd) 158 | .withMaxResultSize(_options.width, _options.height) 159 | .withOptions(options) 160 | .start(ImageCropper._getContext()); 161 | } 162 | else { 163 | com.yalantis.ucrop.UCrop.of(sourcePath, destinationPath) 164 | .withOptions(options) 165 | .start(ImageCropper._getContext()); 166 | } 167 | } 168 | else { 169 | // Application.android.off(AndroidApplication.activityResultEvent, this.onResult); 170 | reject({ 171 | response: "Error", 172 | image: null 173 | }); 174 | } 175 | } catch (e) { 176 | console.log(e); 177 | // Application.android.off(AndroidApplication.activityResultEvent, this.onResult); 178 | reject({ 179 | response: "Error", 180 | image: null 181 | }); 182 | } 183 | }); 184 | } 185 | 186 | private static _gcd(width: number, height: number): number { 187 | if (height === 0) { 188 | return width; 189 | } else { 190 | return ImageCropper._gcd(height, width % height); 191 | } 192 | } 193 | 194 | private static _storeImageSource(image: ImageSource): string { 195 | const folder: Folder = knownFolders.temp(); 196 | const savePath = path.join(folder.path, "temp.jpeg"); 197 | 198 | if (image.saveToFile(savePath, "jpeg", 100)) { 199 | return savePath; 200 | } 201 | else { 202 | return null; 203 | } 204 | } 205 | 206 | private static _cleanFiles(): void { 207 | // Clear Temp 208 | const folder: Folder = knownFolders.temp(); 209 | folder.clear(); 210 | } 211 | 212 | private static _getContext(): android.app.Activity { 213 | return Application.android.foregroundActivity; 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /src/imagecropper.ios.ts: -------------------------------------------------------------------------------- 1 | import { Frame, ImageSource } from '@nativescript/core'; 2 | import { OptionsAndroid, OptionsCommon, Result } from './'; 3 | 4 | let _options: OptionsCommon; 5 | 6 | @NativeClass() 7 | class TOCropViewControllerDelegateImpl extends NSObject { 8 | private _resolve: (val: Result) => void; 9 | private _reject: (val: Result) => void; 10 | private _owner: WeakRef; 11 | 12 | public static ObjCProtocols = [TOCropViewControllerDelegate]; 13 | 14 | public static initWithOwner(owner: WeakRef): TOCropViewControllerDelegateImpl { 15 | // console.log("TOCropViewControllerDelegateImpl.initWithOwner"); 16 | const handler = TOCropViewControllerDelegateImpl.new(); 17 | handler._owner = owner; 18 | return handler; 19 | } 20 | 21 | public initResolveReject(resolve: (val: Result) => void, reject: (val: Result) => void): void { 22 | // console.log("TOCropViewControllerDelegateImpl.initResolveReject"); 23 | this._resolve = resolve; 24 | this._reject = reject; 25 | } 26 | 27 | public cropViewControllerDidCropToCircularImageWithRectAngle(cropViewController: TOCropViewController, image: UIImage, cropRect: CGRect, angle: number): void { 28 | this.cropViewControllerDidCropToImageWithRectAngle(cropViewController, image, cropRect, angle); 29 | } 30 | 31 | public cropViewControllerDidCropToImageWithRectAngle(cropViewController: TOCropViewController, image: UIImage, cropRect: CGRect, angle: number): void { 32 | // console.log("TOCropViewControllerDelegateImpl.cropViewControllerDidCropToImageWithRectAngle"); 33 | cropViewController.dismissViewControllerAnimatedCompletion(false, null); 34 | if (image) { 35 | const imgSrc = new ImageSource(); 36 | if (_options && _options.width && _options.height) { 37 | // Resize Image 38 | const rect: CGRect = CGRectMake(0, 0, _options.width, _options.height); 39 | UIGraphicsBeginImageContext(rect.size); 40 | image.drawInRect(rect); 41 | const resizedImage = UIGraphicsGetImageFromCurrentImageContext(); 42 | UIGraphicsEndImageContext(); 43 | 44 | try { 45 | imgSrc.setNativeSource(resizedImage); 46 | } catch (e) { 47 | console.error(e); 48 | } 49 | if (imgSrc.ios) { 50 | this._resolve({ 51 | response: "Success", 52 | image: imgSrc 53 | }); 54 | } 55 | else { 56 | this._reject({ 57 | response: "Error", 58 | image: null 59 | }); 60 | } 61 | } 62 | else { 63 | // Use Cropped Image w/o Resize 64 | try { 65 | imgSrc.setNativeSource(image); 66 | } catch (e) { 67 | console.error(e); 68 | } 69 | if (imgSrc.ios) { 70 | this._resolve({ 71 | response: "Success", 72 | image: imgSrc 73 | }); 74 | } 75 | else { 76 | this._reject({ 77 | response: "Error", 78 | image: null 79 | }); 80 | } 81 | } 82 | } 83 | CFRelease(cropViewController.delegate); 84 | // return; 85 | } 86 | 87 | public cropViewControllerDidFinishCancelled(cropViewController: TOCropViewController, cancelled: boolean): void { // Promise 88 | // console.log("TOCropViewControllerDelegateImpl.cropViewControllerDidFinishCancelled"); 89 | cropViewController.dismissViewControllerAnimatedCompletion(true, null); 90 | this._resolve({ 91 | response: "Cancelled", 92 | image: null 93 | }); 94 | CFRelease(cropViewController.delegate); 95 | // return; 96 | } 97 | } 98 | 99 | export class ImageCropper { 100 | public show(image: ImageSource, options: OptionsCommon = {}, androidOptions: OptionsAndroid = {}): Promise { 101 | // console.log("ImageCropper.show"); 102 | return new Promise((resolve: (val: Result) => void, reject: (val: Result) => void) => { 103 | _options = options; 104 | if (image.ios) { 105 | const viewController = TOCropViewController.alloc().initWithCroppingStyleImage(options.circularCrop ? TOCropViewCroppingStyle.Circular : TOCropViewCroppingStyle.Default, image.ios); // initWithImage(image.ios); 106 | const delegate = TOCropViewControllerDelegateImpl.initWithOwner(new WeakRef(viewController)); 107 | delegate.initResolveReject(resolve, reject); 108 | CFRetain(delegate); 109 | viewController.delegate = delegate; 110 | 111 | let vc = Frame.topmost().ios.controller; 112 | const keyWindow = UIApplication.sharedApplication.keyWindow; 113 | let root = keyWindow.rootViewController; 114 | let presented = root.presentedViewController; 115 | let page = presented ? presented : root; 116 | 117 | if (_options.lockSquare) { 118 | viewController.aspectRatioPreset = TOCropViewControllerAspectRatioPreset.PresetSquare; 119 | viewController.aspectRatioLockEnabled = true; // The crop box is locked to the aspect ratio and can't be resized away from it 120 | viewController.aspectRatioPickerButtonHidden = true; 121 | viewController.resetAspectRatioEnabled = false; 122 | } 123 | page.presentViewControllerAnimatedCompletion(viewController, false, function () { 124 | if (_options) { 125 | if (_options.width && _options.height) { 126 | const gcd = ImageCropper._gcd(_options.width, _options.height); 127 | viewController.toolbar.clampButtonHidden = true; 128 | viewController.cropView.setAspectRatioAnimated(CGSizeMake(_options.width / gcd, _options.height / gcd), false); 129 | } 130 | 131 | } 132 | }); 133 | } 134 | else { 135 | reject({ 136 | response: "Error", 137 | image: null 138 | }); 139 | } 140 | }); 141 | } 142 | private static _gcd(width: number, height: number): number { 143 | if (height === 0) { 144 | return width; 145 | } else { 146 | return ImageCropper._gcd(height, width % height); 147 | } 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/index.d.ts: -------------------------------------------------------------------------------- 1 | import { ImageSource } from '@nativescript/core'; 2 | 3 | export interface OptionsCommon { 4 | width?: number; 5 | height?: number; 6 | lockSquare?: boolean; 7 | circularCrop?: boolean; 8 | } 9 | 10 | export interface AspectRatio { 11 | aspectRatioTitle: string; 12 | aspectRatioX: number; 13 | aspectRatioY: number; 14 | } 15 | 16 | export interface AspectRatioOptions { 17 | defaultIndex: number; 18 | aspectRatios: AspectRatio[]; 19 | } 20 | export interface OptionsAndroid { 21 | isFreeStyleCropEnabled?: boolean; // set to true to let user resize crop bounds (disabled by default) 22 | toolbarTitle?: string; // default 'Crop Image' 23 | toolbarTextColor?: string; // desired resolved color of Toolbar text and buttons (default is darker orange) 24 | toolbarColor?: string; // desired resolved color of the toolbar 25 | rootViewBackgroundColor?: string; // desired background color that should be applied to the root view 26 | logoColor?: string; // desired resolved color of logo fill (default is darker grey) 27 | statusBarColor?: string; // Set statusbar color 28 | showCropGrid?: boolean; // set to true if you want to see a crop grid/guidelines on top of an image 29 | showCropFrame?: boolean; // set to true if you want to see a crop frame rectangle on top of an image 30 | cropFrameStrokeWidth?: number; // desired width of crop frame line in pixels 31 | cropGridStrokeWidth?: number; // desired width of crop grid lines in pixels 32 | cropGridColor?: string; // desired color of crop grid/guidelines 33 | cropFrameColor?: string; // desired color of crop frame 34 | cropGridRowCount?: number; // crop grid rows count 35 | cropGridColumnCount?: number; // crop grid columns count 36 | hideBottomControls?: boolean; // set to true to hide the bottom controls (shown by default) 37 | compressionQuality?: number; // Set compression quality [0-100] that will be used to save resulting Bitmap 38 | dimmedLayerColor?: string; // desired color of dimmed area around the crop bounds 39 | setAspectRatioOptions?: AspectRatioOptions; // Pass an ordered list of desired aspect ratios that should be available for a user. 40 | toolbarCropDrawable?: any; // Android Drawable (pass native drawable object ONLY) 41 | toolbarCancelDrawable?: any; // Android Drawable (pass native drawable object ONLY) 42 | } 43 | 44 | export interface Result { 45 | response: 'Success' | 'Error' | 'Cancelled'; 46 | image: ImageSource | null; 47 | } 48 | 49 | export declare class ImageCropper { 50 | show(image: ImageSource, options?: OptionsCommon, androidOptions?: OptionsAndroid): Promise; 51 | } 52 | -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nativescript-imagecropper", 3 | "version": "4.0.3", 4 | "description": "NativeScript Image Cropper Plugin", 5 | "main": "imagecropper", 6 | "typings": "index.d.ts", 7 | "nativescript": { 8 | "platforms": { 9 | "android": "6.0.2", 10 | "ios": "6.0.2" 11 | }, 12 | "plugin": { 13 | "nan": "true", 14 | "pan": "true", 15 | "vue": "true", 16 | "core3": "true", 17 | "category": "Interface" 18 | } 19 | }, 20 | "scripts": { 21 | "tsc": "tsc -skipLibCheck", 22 | "build": "npm i && tsc", 23 | "postclone": "npm i && node scripts/postclone.js && cd ../demo && npm i && cd ../src", 24 | "test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch", 25 | "test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch", 26 | "tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\" --exclude \"**/typings/**\"", 27 | "demo.ios": "npm i && npm run tsc && cd ../demo && tns run ios", 28 | "demo.android": "npm i && npm run tsc && cd ../demo && tns run android", 29 | "demo.reset": "cd ../demo && rimraf platforms node_modules hooks", 30 | "plugin.prepare": "npm run tsc && cd ../demo && tns plugin remove nativescript-imagecropper && tns plugin add ../src", 31 | "clean": "cd ../demo && rimraf hooks node_modules platforms && cd ../src && rimraf node_modules", 32 | "ci.tslint": "npm i && tslint '**/*.ts' --config '../tslint.json' --exclude '**/node_modules/**'", 33 | "setup": "npm i && ts-patch install" 34 | }, 35 | "keywords": [ 36 | "NativeScript", 37 | "JavaScript", 38 | "Android", 39 | "iOS", 40 | "Image Cropper", 41 | "Crop", 42 | "imagecropper", 43 | "crop photo", 44 | "image" 45 | ], 46 | "author": { 47 | "name": "bthurlow" 48 | }, 49 | "contributors": [ 50 | { 51 | "name": "MultiShiv19", 52 | "email": "contact@shivaprasad.me", 53 | "url": "https://shiv19.com" 54 | }, 55 | { 56 | "name": "davecoffin", 57 | "email": "dave@davecoffin.com", 58 | "url": "https://github.com/davecoffin" 59 | }, 60 | { 61 | "name": "Brad Martin", 62 | "email": "bmartin@nstudio.io", 63 | "url": "https://github.com/bradmartin" 64 | }, 65 | { 66 | "name": "Dick Smith", 67 | "url": "https://github.com/DickSmith" 68 | }, 69 | { 70 | "name": "Sejun Jeong", 71 | "email": "sejun@ppygd.com", 72 | "url": "https://github.com/mailiam" 73 | }, 74 | { 75 | "name": "Jitendra Prajapati", 76 | "url": "https://github.com/jitendraashutec" 77 | } 78 | ], 79 | "repository": { 80 | "type": "git", 81 | "url": "https://github.com/bthurlow/nativescript-imagecropper" 82 | }, 83 | "bugs": { 84 | "url": "https://github.com/bthurlow/nativescript-imagecropper/issues" 85 | }, 86 | "license": "MIT", 87 | "homepage": "https://github.com/bthurlow/nativescript-imagecropper", 88 | "readmeFilename": "README.md", 89 | "devDependencies": { 90 | "@nativescript/core": "8.1.4", 91 | "@nativescript/types": "8.1.1", 92 | "@nativescript/webpack": "5.0.0", 93 | "rimraf": "^3.0.2", 94 | "ts-patch": "^1.3.0", 95 | "tslint": "^6.1.3", 96 | "typescript": "~3.9.0" 97 | }, 98 | "dependencies": { 99 | "ts-node": "^9.0.0" 100 | }, 101 | "bootstrapper": "nativescript-plugin-seed" 102 | } 103 | -------------------------------------------------------------------------------- /src/platforms/android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/platforms/android/include.gradle: -------------------------------------------------------------------------------- 1 | /* Include.gradle configuration: http://docs.nativescript.org/plugins/plugins#includegradle-specification */ 2 | 3 | android { 4 | 5 | } 6 | 7 | repositories { 8 | jcenter() 9 | maven { url "https://jitpack.io" } 10 | } 11 | 12 | dependencies { 13 | implementation 'com.github.yalantis:ucrop:2.2.3' 14 | } -------------------------------------------------------------------------------- /src/platforms/android/nativescript_imagecropper.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bthurlow/nativescript-imagecropper/c69097e31ccb951cd3f619c4080fa2528b30e28a/src/platforms/android/nativescript_imagecropper.aar -------------------------------------------------------------------------------- /src/platforms/ios/Podfile: -------------------------------------------------------------------------------- 1 | pod 'TOCropViewController','2.5' 2 | -------------------------------------------------------------------------------- /src/references.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | -------------------------------------------------------------------------------- /src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "esnext", 5 | "moduleResolution": "node", 6 | "declaration": true, 7 | "removeComments": true, 8 | "noLib": false, 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "baseUrl": ".", 12 | "lib": ["es2017", "dom"], 13 | "sourceMap": false, 14 | "pretty": true, 15 | "allowUnreachableCode": false, 16 | "allowUnusedLabels": false, 17 | "noEmitHelpers": true, 18 | "noEmitOnError": false, 19 | "noImplicitAny": false, 20 | "noImplicitReturns": true, 21 | "noImplicitUseStrict": false, 22 | "noFallthroughCasesInSwitch": true, 23 | "skipLibCheck": true, 24 | "plugins": [{ 25 | "transform": "@nativescript/webpack/dist/transformers/NativeClass", 26 | "type": "raw" 27 | }] 28 | }, 29 | "exclude": [ 30 | "node_modules" 31 | ], 32 | "compileOnSave": false 33 | } 34 | -------------------------------------------------------------------------------- /src/typings/java!ucrop.d.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable */ 2 | /// 3 | declare module com { 4 | export module yalantis { 5 | export module ucrop { 6 | export class BuildConfig { 7 | public static DEBUG: boolean; 8 | public static APPLICATION_ID: string; 9 | public static BUILD_TYPE: string; 10 | public static FLAVOR: string; 11 | public static VERSION_CODE: number; 12 | public static VERSION_NAME: string; 13 | public constructor(); 14 | } 15 | } 16 | } 17 | } 18 | 19 | import androidnetUri = android.net.Uri; 20 | import androidappActivity = android.app.Activity; 21 | import androidcontentContext = android.content.Context; 22 | import androidappFragment = android.app.Fragment; 23 | import androidsupportv4appFragment = android.support.v4.app.Fragment; 24 | import androidcontentIntent = android.content.Intent; 25 | import javalangThrowable = java.lang.Throwable; 26 | import androidosBundle = android.os.Bundle; 27 | import androidgraphicsBitmapCompressFormat = android.graphics.Bitmap.CompressFormat; 28 | /// 29 | /// 30 | /// 31 | /// 32 | /// 33 | /// 34 | /// 35 | /// 36 | /// 37 | /// 38 | declare module com { 39 | export module yalantis { 40 | export module ucrop { 41 | export class UCrop { 42 | public static REQUEST_CROP: number; 43 | public static RESULT_ERROR: number; 44 | public static EXTRA_INPUT_URI: string; 45 | public static EXTRA_OUTPUT_URI: string; 46 | public static EXTRA_OUTPUT_CROP_ASPECT_RATIO: string; 47 | public static EXTRA_OUTPUT_IMAGE_WIDTH: string; 48 | public static EXTRA_OUTPUT_IMAGE_HEIGHT: string; 49 | public static EXTRA_OUTPUT_OFFSET_X: string; 50 | public static EXTRA_OUTPUT_OFFSET_Y: string; 51 | public static EXTRA_ERROR: string; 52 | public static EXTRA_ASPECT_RATIO_X: string; 53 | public static EXTRA_ASPECT_RATIO_Y: string; 54 | public static EXTRA_MAX_SIZE_X: string; 55 | public static EXTRA_MAX_SIZE_Y: string; 56 | public start(param0: androidcontentContext, param1: androidsupportv4appFragment): void; 57 | public start(param0: androidcontentContext, param1: androidsupportv4appFragment, param2: number): void; 58 | public useSourceImageAspectRatio(): com.yalantis.ucrop.UCrop; 59 | public withMaxResultSize(param0: number, param1: number): com.yalantis.ucrop.UCrop; 60 | public static getOutputImageWidth(param0: androidcontentIntent): number; 61 | public start(param0: androidappActivity, param1: number): void; 62 | public static getOutputCropAspectRatio(param0: androidcontentIntent): number; 63 | public start(param0: androidappActivity): void; 64 | public withOptions(param0: com.yalantis.ucrop.UCrop.Options): com.yalantis.ucrop.UCrop; 65 | public static getOutput(param0: androidcontentIntent): androidnetUri; 66 | public static getOutputImageHeight(param0: androidcontentIntent): number; 67 | public static getError(param0: androidcontentIntent): javalangThrowable; 68 | public static of(param0: androidnetUri, param1: androidnetUri): com.yalantis.ucrop.UCrop; 69 | public start(param0: androidcontentContext, param1: androidappFragment): void; 70 | public withAspectRatio(param0: number, param1: number): com.yalantis.ucrop.UCrop; 71 | public getIntent(param0: androidcontentContext): androidcontentIntent; 72 | public start(param0: androidcontentContext, param1: androidappFragment, param2: number): void; 73 | } 74 | export module UCrop { 75 | export class Options { 76 | public static EXTRA_COMPRESSION_FORMAT_NAME: string; 77 | public static EXTRA_COMPRESSION_QUALITY: string; 78 | public static EXTRA_ALLOWED_GESTURES: string; 79 | public static EXTRA_MAX_BITMAP_SIZE: string; 80 | public static EXTRA_MAX_SCALE_MULTIPLIER: string; 81 | public static EXTRA_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION: string; 82 | public static EXTRA_DIMMED_LAYER_COLOR: string; 83 | public static EXTRA_CIRCLE_DIMMED_LAYER: string; 84 | public static EXTRA_SHOW_CROP_FRAME: string; 85 | public static EXTRA_CROP_FRAME_COLOR: string; 86 | public static EXTRA_CROP_FRAME_STROKE_WIDTH: string; 87 | public static EXTRA_SHOW_CROP_GRID: string; 88 | public static EXTRA_CROP_GRID_ROW_COUNT: string; 89 | public static EXTRA_CROP_GRID_COLUMN_COUNT: string; 90 | public static EXTRA_CROP_GRID_COLOR: string; 91 | public static EXTRA_CROP_GRID_STROKE_WIDTH: string; 92 | public static EXTRA_TOOL_BAR_COLOR: string; 93 | public static EXTRA_STATUS_BAR_COLOR: string; 94 | public static EXTRA_UCROP_COLOR_WIDGET_ACTIVE: string; 95 | public static EXTRA_UCROP_WIDGET_COLOR_TOOLBAR: string; 96 | public static EXTRA_UCROP_TITLE_TEXT_TOOLBAR: string; 97 | public static EXTRA_UCROP_WIDGET_CANCEL_DRAWABLE: string; 98 | public static EXTRA_UCROP_WIDGET_CROP_DRAWABLE: string; 99 | public static EXTRA_UCROP_LOGO_COLOR: string; 100 | public static EXTRA_HIDE_BOTTOM_CONTROLS: string; 101 | public static EXTRA_FREE_STYLE_CROP: string; 102 | public static EXTRA_ASPECT_RATIO_SELECTED_BY_DEFAULT: string; 103 | public static EXTRA_ASPECT_RATIO_OPTIONS: string; 104 | public static EXTRA_UCROP_ROOT_VIEW_BACKGROUND_COLOR: string; 105 | public setAllowedGestures(param0: number, param1: number, param2: number): void; 106 | public setImageToCropBoundsAnimDuration(param0: number): void; 107 | public setActiveWidgetColor(param0: number): void; 108 | public setAspectRatioOptions(param0: number, param1: native.Array): void; 109 | public setMaxBitmapSize(param0: number): void; 110 | public getOptionBundle(): androidosBundle; 111 | public setToolbarColor(param0: number): void; 112 | public setToolbarCancelDrawable(param0: number): void; 113 | public setCropGridColumnCount(param0: number): void; 114 | public setLogoColor(param0: number): void; 115 | public setFreeStyleCropEnabled(param0: boolean): void; 116 | public constructor(); 117 | public setCircleDimmedLayer(param0: boolean): void; 118 | public setDimmedLayerColor(param0: number): void; 119 | public setCropGridRowCount(param0: number): void; 120 | public setCropGridStrokeWidth(param0: number): void; 121 | public setToolbarCropDrawable(param0: number): void; 122 | public setCropFrameColor(param0: number): void; 123 | public setRootViewBackgroundColor(param0: number): void; 124 | public setCompressionQuality(param0: number): void; 125 | public setCropGridColor(param0: number): void; 126 | public setStatusBarColor(param0: number): void; 127 | public setToolbarTitle(param0: string): void; 128 | public useSourceImageAspectRatio(): void; 129 | public setCropFrameStrokeWidth(param0: number): void; 130 | public setToolbarWidgetColor(param0: number): void; 131 | public withAspectRatio(param0: number, param1: number): void; 132 | public setHideBottomControls(param0: boolean): void; 133 | public setShowCropGrid(param0: boolean): void; 134 | public withMaxResultSize(param0: number, param1: number): void; 135 | public setCompressionFormat(param0: androidgraphicsBitmapCompressFormat): void; 136 | public setShowCropFrame(param0: boolean): void; 137 | public setMaxScaleMultiplier(param0: number): void; 138 | } 139 | } 140 | } 141 | } 142 | } 143 | 144 | import androidviewMenu = android.view.Menu; 145 | import androidviewMenuItem = android.view.MenuItem; 146 | /// 147 | /// 148 | /// 149 | /// 150 | /// 151 | declare module com { 152 | export module yalantis { 153 | export module ucrop { 154 | export class UCropActivity { 155 | public static DEFAULT_COMPRESS_QUALITY: number; 156 | public static DEFAULT_COMPRESS_FORMAT: androidgraphicsBitmapCompressFormat; 157 | public static NONE: number; 158 | public static SCALE: number; 159 | public static ROTATE: number; 160 | public static ALL: number; 161 | public onCreate(param0: androidosBundle): void; 162 | public onPrepareOptionsMenu(param0: androidviewMenu): boolean; 163 | public onOptionsItemSelected(param0: androidviewMenuItem): boolean; 164 | public onCreateOptionsMenu(param0: androidviewMenu): boolean; 165 | public onStop(): void; 166 | public cropAndSaveImage(): void; 167 | public setResultUri(param0: androidnetUri, param1: number, param2: number, param3: number, param4: number, param5: number): void; 168 | public constructor(); 169 | public setResultError(param0: javalangThrowable): void; 170 | } 171 | export module UCropActivity { 172 | export class GestureTypes { 173 | /** 174 | * Constructs a new instance of the com.yalantis.ucrop.UCropActivity$GestureTypes interface with the provided implementation. 175 | */ 176 | public constructor(implementation: { 177 | }); 178 | } 179 | } 180 | } 181 | } 182 | } 183 | 184 | /// 185 | /// 186 | declare module com { 187 | export module yalantis { 188 | export module ucrop { 189 | export module callback { 190 | export class BitmapCropCallback { 191 | /** 192 | * Constructs a new instance of the com.yalantis.ucrop.callback.BitmapCropCallback interface with the provided implementation. 193 | */ 194 | public constructor(implementation: { 195 | onBitmapCropped(param0: androidnetUri, param1: number, param2: number, param3: number, param4: number): void; 196 | onCropFailure(param0: javalangThrowable): void; 197 | }); 198 | public onCropFailure(param0: javalangThrowable): void; 199 | public onBitmapCropped(param0: androidnetUri, param1: number, param2: number, param3: number, param4: number): void; 200 | } 201 | } 202 | } 203 | } 204 | } 205 | 206 | import androidgraphicsBitmap = android.graphics.Bitmap; 207 | import javalangException = java.lang.Exception; 208 | /// 209 | /// 210 | /// 211 | /// 212 | declare module com { 213 | export module yalantis { 214 | export module ucrop { 215 | export module callback { 216 | export class BitmapLoadCallback { 217 | /** 218 | * Constructs a new instance of the com.yalantis.ucrop.callback.BitmapLoadCallback interface with the provided implementation. 219 | */ 220 | public constructor(implementation: { 221 | onBitmapLoaded(param0: androidgraphicsBitmap, param1: com.yalantis.ucrop.model.ExifInfo, param2: string, param3: string): void; 222 | onFailure(param0: javalangException): void; 223 | }); 224 | public onFailure(param0: javalangException): void; 225 | public onBitmapLoaded(param0: androidgraphicsBitmap, param1: com.yalantis.ucrop.model.ExifInfo, param2: string, param3: string): void; 226 | } 227 | } 228 | } 229 | } 230 | } 231 | 232 | declare module com { 233 | export module yalantis { 234 | export module ucrop { 235 | export module callback { 236 | export class CropBoundsChangeListener { 237 | /** 238 | * Constructs a new instance of the com.yalantis.ucrop.callback.CropBoundsChangeListener interface with the provided implementation. 239 | */ 240 | public constructor(implementation: { 241 | onCropAspectRatioChanged(param0: number): void; 242 | }); 243 | public onCropAspectRatioChanged(param0: number): void; 244 | } 245 | } 246 | } 247 | } 248 | } 249 | 250 | import androidgraphicsRectF = android.graphics.RectF; 251 | /// 252 | declare module com { 253 | export module yalantis { 254 | export module ucrop { 255 | export module callback { 256 | export class OverlayViewChangeListener { 257 | /** 258 | * Constructs a new instance of the com.yalantis.ucrop.callback.OverlayViewChangeListener interface with the provided implementation. 259 | */ 260 | public constructor(implementation: { 261 | onCropRectUpdated(param0: androidgraphicsRectF): void; 262 | }); 263 | public onCropRectUpdated(param0: androidgraphicsRectF): void; 264 | } 265 | } 266 | } 267 | } 268 | } 269 | 270 | import androidosParcel = android.os.Parcel; 271 | import androidosParcelableCreator = android.os.Parcelable.Creator; 272 | /// 273 | /// 274 | declare module com { 275 | export module yalantis { 276 | export module ucrop { 277 | export module model { 278 | export class AspectRatio { 279 | public static CREATOR: androidosParcelableCreator; 280 | public getAspectRatioTitle(): string; 281 | public constructor(param0: androidosParcel); 282 | public describeContents(): number; 283 | public constructor(param0: string, param1: number, param2: number); 284 | public writeToParcel(param0: androidosParcel, param1: number): void; 285 | public getAspectRatioX(): number; 286 | public getAspectRatioY(): number; 287 | } 288 | } 289 | } 290 | } 291 | } 292 | 293 | /// 294 | /// 295 | declare module com { 296 | export module yalantis { 297 | export module ucrop { 298 | export module model { 299 | export class CropParameters { 300 | public constructor(param0: number, param1: number, param2: androidgraphicsBitmapCompressFormat, param3: number, param4: string, param5: string, param6: com.yalantis.ucrop.model.ExifInfo); 301 | public getCompressFormat(): androidgraphicsBitmapCompressFormat; 302 | public getExifInfo(): com.yalantis.ucrop.model.ExifInfo; 303 | public getCompressQuality(): number; 304 | public getImageOutputPath(): string; 305 | public getImageInputPath(): string; 306 | public getMaxResultImageSizeY(): number; 307 | public getMaxResultImageSizeX(): number; 308 | } 309 | } 310 | } 311 | } 312 | } 313 | 314 | import javalangObject = java.lang.Object; 315 | /// 316 | declare module com { 317 | export module yalantis { 318 | export module ucrop { 319 | export module model { 320 | export class ExifInfo { 321 | public getExifDegrees(): number; 322 | public equals(param0: javalangObject): boolean; 323 | public constructor(param0: number, param1: number, param2: number); 324 | public setExifDegrees(param0: number): void; 325 | public getExifTranslation(): number; 326 | public setExifOrientation(param0: number): void; 327 | public getExifOrientation(): number; 328 | public hashCode(): number; 329 | public setExifTranslation(param0: number): void; 330 | } 331 | } 332 | } 333 | } 334 | } 335 | 336 | /// 337 | declare module com { 338 | export module yalantis { 339 | export module ucrop { 340 | export module model { 341 | export class ImageState { 342 | public constructor(param0: androidgraphicsRectF, param1: androidgraphicsRectF, param2: number, param3: number); 343 | public getCurrentImageRect(): androidgraphicsRectF; 344 | public getCurrentScale(): number; 345 | public getCurrentAngle(): number; 346 | public getCropRect(): androidgraphicsRectF; 347 | } 348 | } 349 | } 350 | } 351 | } 352 | 353 | import javalangVoid = java.lang.Void; 354 | /// 355 | /// 356 | /// 357 | /// 358 | /// 359 | /// 360 | /// 361 | declare module com { 362 | export module yalantis { 363 | export module ucrop { 364 | export module task { 365 | export class BitmapCropTask { 366 | public constructor(param0: androidgraphicsBitmap, param1: com.yalantis.ucrop.model.ImageState, param2: com.yalantis.ucrop.model.CropParameters, param3: com.yalantis.ucrop.callback.BitmapCropCallback); 367 | public doInBackground(param0: native.Array): javalangThrowable; 368 | public onPostExecute(param0: javalangThrowable): void; 369 | public static cropCImg(param0: string, param1: string, param2: number, param3: number, param4: number, param5: number, param6: number, param7: number, param8: number, param9: number, param10: number, param11: number): boolean; 370 | } 371 | } 372 | } 373 | } 374 | } 375 | 376 | /// 377 | /// 378 | /// 379 | /// 380 | /// 381 | /// 382 | /// 383 | declare module com { 384 | export module yalantis { 385 | export module ucrop { 386 | export module task { 387 | export class BitmapLoadTask { 388 | public constructor(param0: androidcontentContext, param1: androidnetUri, param2: androidnetUri, param3: number, param4: number, param5: com.yalantis.ucrop.callback.BitmapLoadCallback); 389 | public doInBackground(param0: native.Array): com.yalantis.ucrop.task.BitmapLoadTask.BitmapWorkerResult; 390 | public onPostExecute(param0: com.yalantis.ucrop.task.BitmapLoadTask.BitmapWorkerResult): void; 391 | } 392 | export module BitmapLoadTask { 393 | export class BitmapWorkerResult { 394 | public constructor(param0: androidgraphicsBitmap, param1: com.yalantis.ucrop.model.ExifInfo); 395 | public constructor(param0: javalangException); 396 | } 397 | } 398 | } 399 | } 400 | } 401 | } 402 | 403 | import androidgraphicsMatrix = android.graphics.Matrix; 404 | import androidgraphicsBitmapFactoryOptions = android.graphics.BitmapFactory.Options; 405 | import javaioCloseable = java.io.Closeable; 406 | /// 407 | /// 408 | /// 409 | /// 410 | /// 411 | /// 412 | declare module com { 413 | export module yalantis { 414 | export module ucrop { 415 | export module util { 416 | export class BitmapLoadUtils { 417 | public static calculateInSampleSize(param0: androidgraphicsBitmapFactoryOptions, param1: number, param2: number): number; 418 | public static exifToTranslation(param0: number): number; 419 | public static calculateMaxBitmapSize(param0: androidcontentContext): number; 420 | public constructor(); 421 | public static close(param0: javaioCloseable): void; 422 | public static getExifOrientation(param0: androidcontentContext, param1: androidnetUri): number; 423 | public static decodeBitmapInBackground(param0: androidcontentContext, param1: androidnetUri, param2: androidnetUri, param3: number, param4: number, param5: com.yalantis.ucrop.callback.BitmapLoadCallback): void; 424 | public static transformBitmap(param0: androidgraphicsBitmap, param1: androidgraphicsMatrix): androidgraphicsBitmap; 425 | public static exifToDegrees(param0: number): number; 426 | } 427 | } 428 | } 429 | } 430 | } 431 | 432 | declare module com { 433 | export module yalantis { 434 | export module ucrop { 435 | export module util { 436 | export class CubicEasing { 437 | public static easeInOut(param0: number, param1: number, param2: number, param3: number): number; 438 | public constructor(); 439 | public static easeIn(param0: number, param1: number, param2: number, param3: number): number; 440 | public static easeOut(param0: number, param1: number, param2: number, param3: number): number; 441 | } 442 | } 443 | } 444 | } 445 | } 446 | 447 | declare module com { 448 | export module yalantis { 449 | export module ucrop { 450 | export module util { 451 | export class EglUtils { 452 | public static getMaxTextureSize(): number; 453 | } 454 | } 455 | } 456 | } 457 | } 458 | 459 | import androidgraphicsCanvas = android.graphics.Canvas; 460 | import androidgraphicsColorFilter = android.graphics.ColorFilter; 461 | /// 462 | /// 463 | /// 464 | declare module com { 465 | export module yalantis { 466 | export module ucrop { 467 | export module util { 468 | export class FastBitmapDrawable { 469 | public constructor(param0: androidgraphicsBitmap); 470 | public getAlpha(): number; 471 | public getMinimumWidth(): number; 472 | public getBitmap(): androidgraphicsBitmap; 473 | public getIntrinsicHeight(): number; 474 | public setBitmap(param0: androidgraphicsBitmap): void; 475 | public setColorFilter(param0: androidgraphicsColorFilter): void; 476 | public getIntrinsicWidth(): number; 477 | public setAlpha(param0: number): void; 478 | public setFilterBitmap(param0: boolean): void; 479 | public draw(param0: androidgraphicsCanvas): void; 480 | public getMinimumHeight(): number; 481 | public getOpacity(): number; 482 | } 483 | } 484 | } 485 | } 486 | } 487 | 488 | /// 489 | /// 490 | /// 491 | declare module com { 492 | export module yalantis { 493 | export module ucrop { 494 | export module util { 495 | export class FileUtils { 496 | public static getPath(param0: androidcontentContext, param1: androidnetUri): string; 497 | public static copyFile(param0: string, param1: string): void; 498 | public static isDownloadsDocument(param0: androidnetUri): boolean; 499 | public static isGooglePhotosUri(param0: androidnetUri): boolean; 500 | public static isMediaDocument(param0: androidnetUri): boolean; 501 | public static isExternalStorageDocument(param0: androidnetUri): boolean; 502 | public static getDataColumn(param0: androidcontentContext, param1: androidnetUri, param2: string, param3: native.Array): string; 503 | } 504 | } 505 | } 506 | } 507 | } 508 | 509 | import javaioInputStream = java.io.InputStream; 510 | import androidmediaExifInterface = android.media.ExifInterface; 511 | import javanioByteOrder = java.nio.ByteOrder; 512 | /// 513 | /// 514 | /// 515 | /// 516 | declare module com { 517 | export module yalantis { 518 | export module ucrop { 519 | export module util { 520 | export class ImageHeaderParser { 521 | public static UNKNOWN_ORIENTATION: number; 522 | public constructor(param0: javaioInputStream); 523 | public getOrientation(): number; 524 | public static copyExif(param0: androidmediaExifInterface, param1: number, param2: number, param3: string): void; 525 | } 526 | export module ImageHeaderParser { 527 | export class RandomAccessReader { 528 | public constructor(param0: native.Array, param1: number); 529 | public order(param0: javanioByteOrder): void; 530 | public length(): number; 531 | public getInt32(param0: number): number; 532 | public getInt16(param0: number): number; 533 | } 534 | export class Reader { 535 | /** 536 | * Constructs a new instance of the com.yalantis.ucrop.util.ImageHeaderParser$Reader interface with the provided implementation. 537 | */ 538 | public constructor(implementation: { 539 | getUInt16(): number; 540 | getUInt8(): number; 541 | skip(param0: number): number; 542 | read(param0: native.Array, param1: number): number; 543 | }); 544 | public skip(param0: number): number; 545 | public getUInt16(): number; 546 | public getUInt8(): number; 547 | public read(param0: native.Array, param1: number): number; 548 | } 549 | export class StreamReader { 550 | public skip(param0: number): number; 551 | public getUInt16(): number; 552 | public constructor(param0: javaioInputStream); 553 | public getUInt8(): number; 554 | public read(param0: native.Array, param1: number): number; 555 | } 556 | } 557 | } 558 | } 559 | } 560 | } 561 | 562 | /// 563 | declare module com { 564 | export module yalantis { 565 | export module ucrop { 566 | export module util { 567 | export class RectUtils { 568 | public static getCornersFromRect(param0: androidgraphicsRectF): native.Array; 569 | public static getCenterFromRect(param0: androidgraphicsRectF): native.Array; 570 | public constructor(); 571 | public static getRectSidesFromCorners(param0: native.Array): native.Array; 572 | public static trapToRect(param0: native.Array): androidgraphicsRectF; 573 | } 574 | } 575 | } 576 | } 577 | } 578 | 579 | import androidviewMotionEvent = android.view.MotionEvent; 580 | /// 581 | /// 582 | declare module com { 583 | export module yalantis { 584 | export module ucrop { 585 | export module util { 586 | export class RotationGestureDetector { 587 | public constructor(param0: com.yalantis.ucrop.util.RotationGestureDetector.OnRotationGestureListener); 588 | public getAngle(): number; 589 | public onTouchEvent(param0: androidviewMotionEvent): boolean; 590 | } 591 | export module RotationGestureDetector { 592 | export class OnRotationGestureListener { 593 | /** 594 | * Constructs a new instance of the com.yalantis.ucrop.util.RotationGestureDetector$OnRotationGestureListener interface with the provided implementation. 595 | */ 596 | public constructor(implementation: { 597 | onRotation(param0: com.yalantis.ucrop.util.RotationGestureDetector): boolean; 598 | }); 599 | public onRotation(param0: com.yalantis.ucrop.util.RotationGestureDetector): boolean; 600 | } 601 | export class SimpleOnRotationGestureListener { 602 | public constructor(); 603 | public onRotation(param0: com.yalantis.ucrop.util.RotationGestureDetector): boolean; 604 | } 605 | } 606 | } 607 | } 608 | } 609 | } 610 | 611 | import androidgraphicsdrawableDrawable = android.graphics.drawable.Drawable; 612 | /// 613 | declare module com { 614 | export module yalantis { 615 | export module ucrop { 616 | export module util { 617 | export class SelectedStateListDrawable { 618 | public constructor(param0: androidgraphicsdrawableDrawable, param1: number); 619 | public onStateChange(param0: native.Array): boolean; 620 | public isStateful(): boolean; 621 | } 622 | } 623 | } 624 | } 625 | } 626 | 627 | import androidutilAttributeSet = android.util.AttributeSet; 628 | import androidcontentresTypedArray = android.content.res.TypedArray; 629 | /// 630 | /// 631 | /// 632 | /// 633 | /// 634 | /// 635 | /// 636 | declare module com { 637 | export module yalantis { 638 | export module ucrop { 639 | export module view { 640 | export class CropImageView extends com.yalantis.ucrop.view.TransformImageView { 641 | public static DEFAULT_MAX_BITMAP_SIZE: number; 642 | public static DEFAULT_IMAGE_TO_CROP_BOUNDS_ANIM_DURATION: number; 643 | public static DEFAULT_MAX_SCALE_MULTIPLIER: number; 644 | public static SOURCE_IMAGE_ASPECT_RATIO: number; 645 | public static DEFAULT_ASPECT_RATIO: number; 646 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet, param2: number); 647 | public zoomInImage(param0: number, param1: number, param2: number): void; 648 | public postRotate(param0: number, param1: number, param2: number): void; 649 | public setCropRect(param0: androidgraphicsRectF): void; 650 | public processStyledAttributes(param0: androidcontentresTypedArray): void; 651 | public cropAndSaveImage(param0: androidgraphicsBitmapCompressFormat, param1: number, param2: com.yalantis.ucrop.callback.BitmapCropCallback): void; 652 | public getCropBoundsChangeListener(): com.yalantis.ucrop.callback.CropBoundsChangeListener; 653 | public setMaxResultImageSizeX(param0: number): void; 654 | public zoomOutImage(param0: number): void; 655 | public cancelAllAnimations(): void; 656 | public getMinScale(): number; 657 | public getTargetAspectRatio(): number; 658 | public zoomImageToPosition(param0: number, param1: number, param2: number, param3: number): void; 659 | public setTargetAspectRatio(param0: number): void; 660 | public isImageWrapCropBounds(param0: native.Array): boolean; 661 | public postScale(param0: number, param1: number, param2: number): void; 662 | public postRotate(param0: number): void; 663 | public setImageToWrapCropBoundsAnimDuration(param0: number): void; 664 | public onImageLaidOut(): void; 665 | public setCropBoundsChangeListener(param0: com.yalantis.ucrop.callback.CropBoundsChangeListener): void; 666 | public isImageWrapCropBounds(): boolean; 667 | public setMaxResultImageSizeY(param0: number): void; 668 | public setImageToWrapCropBounds(param0: boolean): void; 669 | public getMaxScale(): number; 670 | public zoomInImage(param0: number): void; 671 | public zoomOutImage(param0: number, param1: number, param2: number): void; 672 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet); 673 | public setImageToWrapCropBounds(): void; 674 | public constructor(param0: androidcontentContext); 675 | public setMaxScaleMultiplier(param0: number): void; 676 | } 677 | export module CropImageView { 678 | export class WrapCropBoundsRunnable { 679 | public run(): void; 680 | public constructor(param0: com.yalantis.ucrop.view.CropImageView, param1: number, param2: number, param3: number, param4: number, param5: number, param6: number, param7: number, param8: boolean); 681 | } 682 | export class ZoomImageToPosition { 683 | public run(): void; 684 | public constructor(param0: com.yalantis.ucrop.view.CropImageView, param1: number, param2: number, param3: number, param4: number, param5: number); 685 | } 686 | } 687 | } 688 | } 689 | } 690 | } 691 | 692 | import androidviewScaleGestureDetector = android.view.ScaleGestureDetector; 693 | /// 694 | /// 695 | /// 696 | /// 697 | /// 698 | declare module com { 699 | export module yalantis { 700 | export module ucrop { 701 | export module view { 702 | export class GestureCropImageView extends com.yalantis.ucrop.view.CropImageView { 703 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet, param2: number); 704 | public onTouchEvent(param0: androidviewMotionEvent): boolean; 705 | public isRotateEnabled(): boolean; 706 | public getDoubleTapScaleSteps(): number; 707 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet); 708 | public isScaleEnabled(): boolean; 709 | public constructor(param0: androidcontentContext); 710 | public init(): void; 711 | public setScaleEnabled(param0: boolean): void; 712 | public setRotateEnabled(param0: boolean): void; 713 | public setDoubleTapScaleSteps(param0: number): void; 714 | public getDoubleTapTargetScale(): number; 715 | } 716 | export module GestureCropImageView { 717 | export class GestureListener { 718 | public onDoubleTap(param0: androidviewMotionEvent): boolean; 719 | public onScroll(param0: androidviewMotionEvent, param1: androidviewMotionEvent, param2: number, param3: number): boolean; 720 | } 721 | export class RotateListener extends com.yalantis.ucrop.util.RotationGestureDetector.SimpleOnRotationGestureListener { 722 | public onRotation(param0: com.yalantis.ucrop.util.RotationGestureDetector): boolean; 723 | } 724 | export class ScaleListener { 725 | public onScale(param0: androidviewScaleGestureDetector): boolean; 726 | } 727 | } 728 | } 729 | } 730 | } 731 | } 732 | 733 | /// 734 | /// 735 | /// 736 | /// 737 | /// 738 | /// 739 | /// 740 | declare module com { 741 | export module yalantis { 742 | export module ucrop { 743 | export module view { 744 | export class OverlayView { 745 | public static FREESTYLE_CROP_MODE_DISABLE: number; 746 | public static FREESTYLE_CROP_MODE_ENABLE: number; 747 | public static FREESTYLE_CROP_MODE_ENABLE_WITH_PASS_THROUGH: number; 748 | public static DEFAULT_SHOW_CROP_FRAME: boolean; 749 | public static DEFAULT_SHOW_CROP_GRID: boolean; 750 | public static DEFAULT_CIRCLE_DIMMED_LAYER: boolean; 751 | public static DEFAULT_FREESTYLE_CROP_MODE: number; 752 | public static DEFAULT_CROP_GRID_ROW_COUNT: number; 753 | public static DEFAULT_CROP_GRID_COLUMN_COUNT: number; 754 | public mThisWidth: number; 755 | public mThisHeight: number; 756 | public mCropGridCorners: native.Array; 757 | public mCropGridCenter: native.Array; 758 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet, param2: number); 759 | public onTouchEvent(param0: androidviewMotionEvent): boolean; 760 | public setDimmedColor(param0: number): void; 761 | public onDraw(param0: androidgraphicsCanvas): void; 762 | public processStyledAttributes(param0: androidcontentresTypedArray): void; 763 | public setCropGridColumnCount(param0: number): void; 764 | public getOverlayViewChangeListener(): com.yalantis.ucrop.callback.OverlayViewChangeListener; 765 | public setTargetAspectRatio(param0: number): void; 766 | public setCircleDimmedLayer(param0: boolean): void; 767 | public setCropGridRowCount(param0: number): void; 768 | public setCropGridStrokeWidth(param0: number): void; 769 | public drawCropGrid(param0: androidgraphicsCanvas): void; 770 | public setCropFrameColor(param0: number): void; 771 | public setCropGridColor(param0: number): void; 772 | public init(): void; 773 | public setCropFrameStrokeWidth(param0: number): void; 774 | public getFreestyleCropMode(): number; 775 | public setFreestyleCropEnabled(param0: boolean): void; 776 | public drawDimmedLayer(param0: androidgraphicsCanvas): void; 777 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet); 778 | public setFreestyleCropMode(param0: number): void; 779 | public setShowCropGrid(param0: boolean): void; 780 | public onLayout(param0: boolean, param1: number, param2: number, param3: number, param4: number): void; 781 | public isFreestyleCropEnabled(): boolean; 782 | public constructor(param0: androidcontentContext); 783 | public setShowCropFrame(param0: boolean): void; 784 | public setupCropBounds(): void; 785 | public getCropViewRect(): androidgraphicsRectF; 786 | public setOverlayViewChangeListener(param0: com.yalantis.ucrop.callback.OverlayViewChangeListener): void; 787 | } 788 | export module OverlayView { 789 | export class FreestyleMode { 790 | /** 791 | * Constructs a new instance of the com.yalantis.ucrop.view.OverlayView$FreestyleMode interface with the provided implementation. 792 | */ 793 | public constructor(implementation: { 794 | }); 795 | } 796 | } 797 | } 798 | } 799 | } 800 | } 801 | 802 | import androidwidgetImageViewScaleType = android.widget.ImageView.ScaleType; 803 | /// 804 | /// 805 | /// 806 | /// 807 | /// 808 | /// 809 | /// 810 | /// 811 | declare module com { 812 | export module yalantis { 813 | export module ucrop { 814 | export module view { 815 | export class TransformImageView { 816 | public mCurrentImageCorners: native.Array; 817 | public mCurrentImageCenter: native.Array; 818 | public mCurrentImageMatrix: androidgraphicsMatrix; 819 | public mThisWidth: number; 820 | public mThisHeight: number; 821 | public mTransformImageListener: com.yalantis.ucrop.view.TransformImageView.TransformImageListener; 822 | public mBitmapDecoded: boolean; 823 | public mBitmapLaidOut: boolean; 824 | public getMatrixValue(param0: androidgraphicsMatrix, param1: number): number; 825 | public getMaxBitmapSize(): number; 826 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet, param2: number); 827 | public postRotate(param0: number, param1: number, param2: number): void; 828 | public setImageUri(param0: androidnetUri, param1: androidnetUri): void; 829 | public setMaxBitmapSize(param0: number): void; 830 | public setTransformImageListener(param0: com.yalantis.ucrop.view.TransformImageView.TransformImageListener): void; 831 | public postTranslate(param0: number, param1: number): void; 832 | public getExifInfo(): com.yalantis.ucrop.model.ExifInfo; 833 | public getImageInputPath(): string; 834 | public getMatrixAngle(param0: androidgraphicsMatrix): number; 835 | public postScale(param0: number, param1: number, param2: number): void; 836 | public setImageMatrix(param0: androidgraphicsMatrix): void; 837 | public setScaleType(param0: androidwidgetImageViewScaleType): void; 838 | public onImageLaidOut(): void; 839 | public getMatrixScale(param0: androidgraphicsMatrix): number; 840 | public getCurrentScale(): number; 841 | public getViewBitmap(): androidgraphicsBitmap; 842 | public getImageOutputPath(): string; 843 | public setImageBitmap(param0: androidgraphicsBitmap): void; 844 | public init(): void; 845 | public printMatrix(param0: string, param1: androidgraphicsMatrix): void; 846 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet); 847 | public onLayout(param0: boolean, param1: number, param2: number, param3: number, param4: number): void; 848 | public getCurrentAngle(): number; 849 | public constructor(param0: androidcontentContext); 850 | } 851 | export module TransformImageView { 852 | export class TransformImageListener { 853 | /** 854 | * Constructs a new instance of the com.yalantis.ucrop.view.TransformImageView$TransformImageListener interface with the provided implementation. 855 | */ 856 | public constructor(implementation: { 857 | onLoadComplete(): void; 858 | onLoadFailure(param0: javalangException): void; 859 | onRotate(param0: number): void; 860 | onScale(param0: number): void; 861 | }); 862 | public onLoadFailure(param0: javalangException): void; 863 | public onRotate(param0: number): void; 864 | public onScale(param0: number): void; 865 | public onLoadComplete(): void; 866 | } 867 | } 868 | } 869 | } 870 | } 871 | } 872 | 873 | /// 874 | /// 875 | /// 876 | /// 877 | declare module com { 878 | export module yalantis { 879 | export module ucrop { 880 | export module view { 881 | export class UCropView { 882 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet, param2: number); 883 | public shouldDelayChildPressedState(): boolean; 884 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet); 885 | public getCropImageView(): com.yalantis.ucrop.view.GestureCropImageView; 886 | public resetCropImageView(): void; 887 | public getOverlayView(): com.yalantis.ucrop.view.OverlayView; 888 | } 889 | } 890 | } 891 | } 892 | } 893 | 894 | /// 895 | /// 896 | /// 897 | /// 898 | declare module com { 899 | export module yalantis { 900 | export module ucrop { 901 | export module view { 902 | export module widget { 903 | export class AspectRatioTextView { 904 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet); 905 | public setActiveColor(param0: number): void; 906 | public getAspectRatio(param0: boolean): number; 907 | public onDraw(param0: androidgraphicsCanvas): void; 908 | public setAspectRatio(param0: com.yalantis.ucrop.model.AspectRatio): void; 909 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet, param2: number); 910 | public constructor(param0: androidcontentContext); 911 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet, param2: number, param3: number); 912 | } 913 | } 914 | } 915 | } 916 | } 917 | } 918 | 919 | /// 920 | /// 921 | /// 922 | /// 923 | declare module com { 924 | export module yalantis { 925 | export module ucrop { 926 | export module view { 927 | export module widget { 928 | export class HorizontalProgressWheelView { 929 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet); 930 | public setScrollingListener(param0: com.yalantis.ucrop.view.widget.HorizontalProgressWheelView.ScrollingListener): void; 931 | public onDraw(param0: androidgraphicsCanvas): void; 932 | public setMiddleLineColor(param0: number): void; 933 | public onTouchEvent(param0: androidviewMotionEvent): boolean; 934 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet, param2: number); 935 | public constructor(param0: androidcontentContext); 936 | public constructor(param0: androidcontentContext, param1: androidutilAttributeSet, param2: number, param3: number); 937 | } 938 | export module HorizontalProgressWheelView { 939 | export class ScrollingListener { 940 | /** 941 | * Constructs a new instance of the com.yalantis.ucrop.view.widget.HorizontalProgressWheelView$ScrollingListener interface with the provided implementation. 942 | */ 943 | public constructor(implementation: { 944 | onScrollStart(): void; 945 | onScroll(param0: number, param1: number): void; 946 | onScrollEnd(): void; 947 | }); 948 | public onScrollStart(): void; 949 | public onScroll(param0: number, param1: number): void; 950 | public onScrollEnd(): void; 951 | } 952 | } 953 | } 954 | } 955 | } 956 | } 957 | } 958 | 959 | -------------------------------------------------------------------------------- /src/typings/objc!TOCropViewController.d.ts: -------------------------------------------------------------------------------- 1 | 2 | declare class TOActivityCroppedImageProvider extends UIActivityItemProvider { 3 | 4 | static alloc(): TOActivityCroppedImageProvider; // inherited from NSObject 5 | 6 | static new(): TOActivityCroppedImageProvider; // inherited from NSObject 7 | 8 | readonly angle: number; 9 | 10 | readonly circular: boolean; 11 | 12 | readonly cropFrame: CGRect; 13 | 14 | readonly image: UIImage; 15 | 16 | constructor(o: { image: UIImage; cropFrame: CGRect; angle: number; circular: boolean; }); 17 | 18 | initWithImageCropFrameAngleCircular(image: UIImage, cropFrame: CGRect, angle: number, circular: boolean): this; 19 | } 20 | 21 | declare class TOCropOverlayView extends UIView { 22 | 23 | static alloc(): TOCropOverlayView; // inherited from NSObject 24 | 25 | static appearance(): TOCropOverlayView; // inherited from UIAppearance 26 | 27 | static appearanceForTraitCollection(trait: UITraitCollection): TOCropOverlayView; // inherited from UIAppearance 28 | 29 | static appearanceForTraitCollectionWhenContainedIn(trait: UITraitCollection, ContainerClass: typeof NSObject): TOCropOverlayView; // inherited from UIAppearance 30 | 31 | static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(trait: UITraitCollection, containerTypes: NSArray | typeof NSObject[]): TOCropOverlayView; // inherited from UIAppearance 32 | 33 | static appearanceWhenContainedIn(ContainerClass: typeof NSObject): TOCropOverlayView; // inherited from UIAppearance 34 | 35 | static appearanceWhenContainedInInstancesOfClasses(containerTypes: NSArray | typeof NSObject[]): TOCropOverlayView; // inherited from UIAppearance 36 | 37 | static new(): TOCropOverlayView; // inherited from NSObject 38 | 39 | displayHorizontalGridLines: boolean; 40 | 41 | displayVerticalGridLines: boolean; 42 | 43 | gridHidden: boolean; 44 | 45 | setGridHiddenAnimated(hidden: boolean, animated: boolean): void; 46 | } 47 | 48 | declare class TOCropScrollView extends UIScrollView { 49 | 50 | static alloc(): TOCropScrollView; // inherited from NSObject 51 | 52 | static appearance(): TOCropScrollView; // inherited from UIAppearance 53 | 54 | static appearanceForTraitCollection(trait: UITraitCollection): TOCropScrollView; // inherited from UIAppearance 55 | 56 | static appearanceForTraitCollectionWhenContainedIn(trait: UITraitCollection, ContainerClass: typeof NSObject): TOCropScrollView; // inherited from UIAppearance 57 | 58 | static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(trait: UITraitCollection, containerTypes: NSArray | typeof NSObject[]): TOCropScrollView; // inherited from UIAppearance 59 | 60 | static appearanceWhenContainedIn(ContainerClass: typeof NSObject): TOCropScrollView; // inherited from UIAppearance 61 | 62 | static appearanceWhenContainedInInstancesOfClasses(containerTypes: NSArray | typeof NSObject[]): TOCropScrollView; // inherited from UIAppearance 63 | 64 | static new(): TOCropScrollView; // inherited from NSObject 65 | 66 | touchesBegan: () => void; 67 | 68 | touchesCancelled: () => void; 69 | 70 | touchesEnded: () => void; 71 | } 72 | 73 | declare class TOCropToolbar extends UIView { 74 | 75 | static alloc(): TOCropToolbar; // inherited from NSObject 76 | 77 | static appearance(): TOCropToolbar; // inherited from UIAppearance 78 | 79 | static appearanceForTraitCollection(trait: UITraitCollection): TOCropToolbar; // inherited from UIAppearance 80 | 81 | static appearanceForTraitCollectionWhenContainedIn(trait: UITraitCollection, ContainerClass: typeof NSObject): TOCropToolbar; // inherited from UIAppearance 82 | 83 | static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(trait: UITraitCollection, containerTypes: NSArray | typeof NSObject[]): TOCropToolbar; // inherited from UIAppearance 84 | 85 | static appearanceWhenContainedIn(ContainerClass: typeof NSObject): TOCropToolbar; // inherited from UIAppearance 86 | 87 | static appearanceWhenContainedInInstancesOfClasses(containerTypes: NSArray | typeof NSObject[]): TOCropToolbar; // inherited from UIAppearance 88 | 89 | static new(): TOCropToolbar; // inherited from NSObject 90 | 91 | backgroundViewOutsets: UIEdgeInsets; 92 | 93 | cancelButtonTapped: () => void; 94 | 95 | readonly cancelIconButton: UIButton; 96 | 97 | readonly cancelTextButton: UIButton; 98 | 99 | cancelTextButtonTitle: string; 100 | 101 | readonly clampButton: UIButton; 102 | 103 | readonly clampButtonFrame: CGRect; 104 | 105 | clampButtonGlowing: boolean; 106 | 107 | clampButtonHidden: boolean; 108 | 109 | clampButtonTapped: () => void; 110 | 111 | readonly doneButtonFrame: CGRect; 112 | 113 | doneButtonTapped: () => void; 114 | 115 | readonly doneIconButton: UIButton; 116 | 117 | readonly doneTextButton: UIButton; 118 | 119 | doneTextButtonTitle: string; 120 | 121 | readonly resetButton: UIButton; 122 | 123 | resetButtonEnabled: boolean; 124 | 125 | resetButtonHidden: boolean; 126 | 127 | resetButtonTapped: () => void; 128 | 129 | readonly rotateButton: UIButton; 130 | 131 | readonly rotateClockwiseButton: UIButton; 132 | 133 | rotateClockwiseButtonHidden: boolean; 134 | 135 | rotateClockwiseButtonTapped: () => void; 136 | 137 | readonly rotateCounterclockwiseButton: UIButton; 138 | 139 | rotateCounterclockwiseButtonHidden: boolean; 140 | 141 | rotateCounterclockwiseButtonTapped: () => void; 142 | 143 | statusBarHeightInset: number; 144 | } 145 | 146 | declare class TOCropView extends UIView { 147 | 148 | static alloc(): TOCropView; // inherited from NSObject 149 | 150 | static appearance(): TOCropView; // inherited from UIAppearance 151 | 152 | static appearanceForTraitCollection(trait: UITraitCollection): TOCropView; // inherited from UIAppearance 153 | 154 | static appearanceForTraitCollectionWhenContainedIn(trait: UITraitCollection, ContainerClass: typeof NSObject): TOCropView; // inherited from UIAppearance 155 | 156 | static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(trait: UITraitCollection, containerTypes: NSArray | typeof NSObject[]): TOCropView; // inherited from UIAppearance 157 | 158 | static appearanceWhenContainedIn(ContainerClass: typeof NSObject): TOCropView; // inherited from UIAppearance 159 | 160 | static appearanceWhenContainedInInstancesOfClasses(containerTypes: NSArray | typeof NSObject[]): TOCropView; // inherited from UIAppearance 161 | 162 | static new(): TOCropView; // inherited from NSObject 163 | 164 | alwaysShowCroppingGrid: boolean; 165 | 166 | angle: number; 167 | 168 | aspectRatio: CGSize; 169 | 170 | aspectRatioLockDimensionSwapEnabled: boolean; 171 | 172 | aspectRatioLockEnabled: boolean; 173 | 174 | readonly canBeReset: boolean; 175 | 176 | cropAdjustingDelay: number; 177 | 178 | readonly cropBoxAspectRatioIsPortrait: boolean; 179 | 180 | readonly cropBoxFrame: CGRect; 181 | 182 | cropBoxResizeEnabled: boolean; 183 | 184 | cropRegionInsets: UIEdgeInsets; 185 | 186 | cropViewPadding: number; 187 | 188 | readonly croppingStyle: TOCropViewCroppingStyle; 189 | 190 | croppingViewsHidden: boolean; 191 | 192 | delegate: TOCropViewDelegate; 193 | 194 | readonly foregroundContainerView: UIView; 195 | 196 | gridOverlayHidden: boolean; 197 | 198 | readonly gridOverlayView: TOCropOverlayView; 199 | 200 | readonly image: UIImage; 201 | 202 | imageCropFrame: CGRect; 203 | 204 | readonly imageViewFrame: CGRect; 205 | 206 | internalLayoutDisabled: boolean; 207 | 208 | maximumZoomScale: number; 209 | 210 | minimumAspectRatio: number; 211 | 212 | resetAspectRatioEnabled: boolean; 213 | 214 | simpleRenderMode: boolean; 215 | 216 | translucencyAlwaysHidden: boolean; 217 | 218 | constructor(o: { croppingStyle: TOCropViewCroppingStyle; image: UIImage; }); 219 | 220 | constructor(o: { image: UIImage; }); 221 | 222 | initWithCroppingStyleImage(style: TOCropViewCroppingStyle, image: UIImage): this; 223 | 224 | initWithImage(image: UIImage): this; 225 | 226 | moveCroppedContentToCenterAnimated(animated: boolean): void; 227 | 228 | performInitialSetup(): void; 229 | 230 | performRelayoutForRotation(): void; 231 | 232 | prepareforRotation(): void; 233 | 234 | resetLayoutToDefaultAnimated(animated: boolean): void; 235 | 236 | rotateImageNinetyDegreesAnimated(animated: boolean): void; 237 | 238 | rotateImageNinetyDegreesAnimatedClockwise(animated: boolean, clockwise: boolean): void; 239 | 240 | setAspectRatioAnimated(aspectRatio: CGSize, animated: boolean): void; 241 | 242 | setBackgroundImageViewHiddenAnimated(hidden: boolean, animated: boolean): void; 243 | 244 | setCroppingViewsHiddenAnimated(hidden: boolean, animated: boolean): void; 245 | 246 | setGridOverlayHiddenAnimated(gridOverlayHidden: boolean, animated: boolean): void; 247 | 248 | setSimpleRenderModeAnimated(simpleMode: boolean, animated: boolean): void; 249 | } 250 | 251 | declare class TOCropViewController extends UIViewController { 252 | 253 | static alloc(): TOCropViewController; // inherited from NSObject 254 | 255 | static new(): TOCropViewController; // inherited from NSObject 256 | 257 | activityItems: NSArray; 258 | 259 | allowedAspectRatios: NSArray; 260 | 261 | angle: number; 262 | 263 | applicationActivities: NSArray; 264 | 265 | aspectRatioLockDimensionSwapEnabled: boolean; 266 | 267 | aspectRatioLockEnabled: boolean; 268 | 269 | aspectRatioPickerButtonHidden: boolean; 270 | 271 | aspectRatioPreset: TOCropViewControllerAspectRatioPreset; 272 | 273 | cancelButtonTitle: string; 274 | 275 | readonly cropView: TOCropView; 276 | 277 | readonly croppingStyle: TOCropViewCroppingStyle; 278 | 279 | customAspectRatio: CGSize; 280 | 281 | customAspectRatioName: string; 282 | 283 | delegate: TOCropViewControllerDelegate; 284 | 285 | doneButtonTitle: string; 286 | 287 | excludedActivityTypes: NSArray; 288 | 289 | hidesNavigationBar: boolean; 290 | 291 | readonly image: UIImage; 292 | 293 | imageCropFrame: CGRect; 294 | 295 | minimumAspectRatio: number; 296 | 297 | onDidCropImageToRect: (p1: CGRect, p2: number) => void; 298 | 299 | onDidCropToCircleImage: (p1: UIImage, p2: CGRect, p3: number) => void; 300 | 301 | onDidCropToRect: (p1: UIImage, p2: CGRect, p3: number) => void; 302 | 303 | onDidFinishCancelled: (p1: boolean) => void; 304 | 305 | resetAspectRatioEnabled: boolean; 306 | 307 | resetButtonHidden: boolean; 308 | 309 | rotateButtonsHidden: boolean; 310 | 311 | rotateClockwiseButtonHidden: boolean; 312 | 313 | showActivitySheetOnDone: boolean; 314 | 315 | showCancelConfirmationDialog: boolean; 316 | 317 | readonly titleLabel: UILabel; 318 | 319 | readonly toolbar: TOCropToolbar; 320 | 321 | toolbarPosition: TOCropViewControllerToolbarPosition; 322 | 323 | constructor(o: { croppingStyle: TOCropViewCroppingStyle; image: UIImage; }); 324 | 325 | constructor(o: { image: UIImage; }); 326 | 327 | dismissAnimatedFromParentViewControllerToViewToFrameSetupCompletion(viewController: UIViewController, toView: UIView, frame: CGRect, setup: () => void, completion: () => void): void; 328 | 329 | dismissAnimatedFromParentViewControllerWithCroppedImageToViewToFrameSetupCompletion(viewController: UIViewController, image: UIImage, toView: UIView, frame: CGRect, setup: () => void, completion: () => void): void; 330 | 331 | initWithCroppingStyleImage(style: TOCropViewCroppingStyle, image: UIImage): this; 332 | 333 | initWithImage(image: UIImage): this; 334 | 335 | presentAnimatedFromParentViewControllerFromImageFromViewFromFrameAngleToImageFrameSetupCompletion(viewController: UIViewController, image: UIImage, fromView: UIView, fromFrame: CGRect, angle: number, toFrame: CGRect, setup: () => void, completion: () => void): void; 336 | 337 | presentAnimatedFromParentViewControllerFromViewFromFrameSetupCompletion(viewController: UIViewController, fromView: UIView, fromFrame: CGRect, setup: () => void, completion: () => void): void; 338 | 339 | resetCropViewLayout(): void; 340 | 341 | setAspectRatioPresetAnimated(aspectRatioPreset: TOCropViewControllerAspectRatioPreset, animated: boolean): void; 342 | } 343 | 344 | declare const enum TOCropViewControllerAspectRatioPreset { 345 | 346 | PresetOriginal = 0, 347 | 348 | PresetSquare = 1, 349 | 350 | Preset3x2 = 2, 351 | 352 | Preset5x3 = 3, 353 | 354 | Preset4x3 = 4, 355 | 356 | Preset5x4 = 5, 357 | 358 | Preset7x5 = 6, 359 | 360 | Preset16x9 = 7, 361 | 362 | PresetCustom = 8 363 | } 364 | 365 | interface TOCropViewControllerDelegate extends NSObjectProtocol { 366 | 367 | cropViewControllerDidCropImageToRectAngle?(cropViewController: TOCropViewController, cropRect: CGRect, angle: number): void; 368 | 369 | cropViewControllerDidCropToCircularImageWithRectAngle?(cropViewController: TOCropViewController, image: UIImage, cropRect: CGRect, angle: number): void; 370 | 371 | cropViewControllerDidCropToImageWithRectAngle?(cropViewController: TOCropViewController, image: UIImage, cropRect: CGRect, angle: number): void; 372 | 373 | cropViewControllerDidFinishCancelled?(cropViewController: TOCropViewController, cancelled: boolean): void; 374 | } 375 | declare var TOCropViewControllerDelegate: { 376 | 377 | prototype: TOCropViewControllerDelegate; 378 | }; 379 | 380 | declare const enum TOCropViewControllerToolbarPosition { 381 | 382 | Bottom = 0, 383 | 384 | Top = 1 385 | } 386 | 387 | declare class TOCropViewControllerTransitioning extends NSObject implements UIViewControllerAnimatedTransitioning { 388 | 389 | static alloc(): TOCropViewControllerTransitioning; // inherited from NSObject 390 | 391 | static new(): TOCropViewControllerTransitioning; // inherited from NSObject 392 | 393 | fromFrame: CGRect; 394 | 395 | fromView: UIView; 396 | 397 | image: UIImage; 398 | 399 | isDismissing: boolean; 400 | 401 | prepareForTransitionHandler: () => void; 402 | 403 | toFrame: CGRect; 404 | 405 | toView: UIView; 406 | 407 | readonly debugDescription: string; // inherited from NSObjectProtocol 408 | 409 | readonly description: string; // inherited from NSObjectProtocol 410 | 411 | readonly hash: number; // inherited from NSObjectProtocol 412 | 413 | readonly isProxy: boolean; // inherited from NSObjectProtocol 414 | 415 | readonly superclass: typeof NSObject; // inherited from NSObjectProtocol 416 | 417 | readonly // inherited from NSObjectProtocol 418 | 419 | animateTransition(transitionContext: UIViewControllerContextTransitioning): void; 420 | 421 | animationEnded(transitionCompleted: boolean): void; 422 | 423 | class(): typeof NSObject; 424 | 425 | conformsToProtocol(aProtocol: any /* Protocol */): boolean; 426 | 427 | interruptibleAnimatorForTransition(transitionContext: UIViewControllerContextTransitioning): UIViewImplicitlyAnimating; 428 | 429 | isEqual(object: any): boolean; 430 | 431 | isKindOfClass(aClass: typeof NSObject): boolean; 432 | 433 | isMemberOfClass(aClass: typeof NSObject): boolean; 434 | 435 | performSelector(aSelector: string): any; 436 | 437 | performSelectorWithObject(aSelector: string, object: any): any; 438 | 439 | performSelectorWithObjectWithObject(aSelector: string, object1: any, object2: any): any; 440 | 441 | reset(): void; 442 | 443 | respondsToSelector(aSelector: string): boolean; 444 | 445 | retainCount(): number; 446 | 447 | self(): this; 448 | 449 | transitionDuration(transitionContext: UIViewControllerContextTransitioning): number; 450 | } 451 | 452 | declare var TOCropViewControllerVersionNumber: number; 453 | 454 | declare var TOCropViewControllerVersionString: interop.Reference; 455 | 456 | declare const enum TOCropViewCroppingStyle { 457 | 458 | Default = 0, 459 | 460 | Circular = 1 461 | } 462 | 463 | interface TOCropViewDelegate extends NSObjectProtocol { 464 | 465 | cropViewDidBecomeNonResettable(cropView: TOCropView): void; 466 | 467 | cropViewDidBecomeResettable(cropView: TOCropView): void; 468 | } 469 | declare var TOCropViewDelegate: { 470 | 471 | prototype: TOCropViewDelegate; 472 | }; 473 | 474 | declare class TOCroppedImageAttributes extends NSObject { 475 | 476 | static alloc(): TOCroppedImageAttributes; // inherited from NSObject 477 | 478 | static new(): TOCroppedImageAttributes; // inherited from NSObject 479 | 480 | readonly angle: number; 481 | 482 | readonly croppedFrame: CGRect; 483 | 484 | readonly originalImageSize: CGSize; 485 | 486 | constructor(o: { croppedFrame: CGRect; angle: number; originalImageSize: CGSize; }); 487 | 488 | initWithCroppedFrameAngleOriginalImageSize(croppedFrame: CGRect, angle: number, originalSize: CGSize): this; 489 | } 490 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "class-name": true, 4 | "comment-format": [ 5 | true, 6 | "check-space" 7 | ], 8 | "indent": [ 9 | true, 10 | "spaces" 11 | ], 12 | "no-duplicate-variable": true, 13 | "no-eval": true, 14 | "no-internal-module": true, 15 | "no-trailing-whitespace": true, 16 | "no-var-keyword": true, 17 | "one-line": [ 18 | true, 19 | "check-open-brace", 20 | "check-whitespace" 21 | ], 22 | "prefer-const": true, 23 | "quotemark": [ 24 | false, 25 | "double" 26 | ], 27 | "semicolon": [ 28 | true, 29 | "always" 30 | ], 31 | "triple-equals": [ 32 | true, 33 | "allow-null-check" 34 | ], 35 | "typedef-whitespace": [ 36 | true, 37 | { 38 | "call-signature": "nospace", 39 | "index-signature": "nospace", 40 | "parameter": "nospace", 41 | "property-declaration": "nospace", 42 | "variable-declaration": "nospace" 43 | } 44 | ], 45 | "variable-name": [ 46 | true, 47 | "ban-keywords" 48 | ], 49 | "whitespace": [ 50 | true, 51 | "check-branch", 52 | "check-decl", 53 | "check-operator", 54 | "check-separator", 55 | "check-type" 56 | ] 57 | } 58 | } --------------------------------------------------------------------------------